staging: fieldbus: anybus-s: support HMS Anybus-S bus
The Anybus-S/Anybus-M is a series of interchangeable fieldbus communication modules featuring on board memory and processing power. All software and hardware functionality required to communicate on the fieldbus is incorporated in the module itself, allowing the application to focus on other tasks. Typical applications are frequency inverters, HMI and visualization devices, instruments, scales, robotics, PLC’s and intelligent measuring devices. Official documentation: https://www.anybus.com/docs/librariesprovider7/default-document-library/ manuals-design-guides/hms-hmsi-27-275.pdf Signed-off-by: Sven Van Asbroeck <TheSven73@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
f9a82c4820
commit
308ee87a2f
|
@ -14,6 +14,5 @@ menuconfig FIELDBUS_DEV
|
|||
|
||||
If unsure, say no.
|
||||
|
||||
if FIELDBUS_DEV
|
||||
source "drivers/staging/fieldbus/anybuss/Kconfig"
|
||||
|
||||
endif
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
# Makefile for fieldbus_dev drivers.
|
||||
#
|
||||
|
||||
obj-$(CONFIG_FIELDBUS_DEV) += fieldbus_dev.o
|
||||
obj-$(CONFIG_FIELDBUS_DEV) += fieldbus_dev.o anybuss/
|
||||
fieldbus_dev-y := dev_core.o
|
||||
|
||||
# Devices
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
config HMS_ANYBUSS_BUS
|
||||
tristate "HMS Anybus-S Bus Support"
|
||||
select REGMAP
|
||||
depends on OF && FIELDBUS_DEV
|
||||
help
|
||||
Driver for the HMS Industrial Networks Anybus-S bus.
|
||||
You can attach a single Anybus-S compatible card to it, which
|
||||
typically provides fieldbus and industrial ethernet
|
||||
functionality.
|
|
@ -0,0 +1,7 @@
|
|||
# SPDX-License-Identifier: GPL-2.0
|
||||
#
|
||||
# Makefile for anybuss drivers.
|
||||
#
|
||||
|
||||
obj-$(CONFIG_HMS_ANYBUSS_BUS) += anybuss_core.o
|
||||
anybuss_core-y += host.o
|
|
@ -0,0 +1,102 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Anybus-S client adapter definitions
|
||||
*
|
||||
* Copyright 2018 Arcx Inc
|
||||
*/
|
||||
|
||||
#ifndef __LINUX_ANYBUSS_CLIENT_H__
|
||||
#define __LINUX_ANYBUSS_CLIENT_H__
|
||||
|
||||
#include <linux/device.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/poll.h>
|
||||
|
||||
struct anybuss_host;
|
||||
|
||||
struct anybuss_client {
|
||||
struct device dev;
|
||||
struct anybuss_host *host;
|
||||
u16 fieldbus_type;
|
||||
/*
|
||||
* these can be optionally set by the client to receive event
|
||||
* notifications from the host.
|
||||
*/
|
||||
void (*on_area_updated)(struct anybuss_client *client);
|
||||
void (*on_online_changed)(struct anybuss_client *client, bool online);
|
||||
};
|
||||
|
||||
struct anybuss_client_driver {
|
||||
struct device_driver driver;
|
||||
int (*probe)(struct anybuss_client *adev);
|
||||
int (*remove)(struct anybuss_client *adev);
|
||||
u16 fieldbus_type;
|
||||
};
|
||||
|
||||
int anybuss_client_driver_register(struct anybuss_client_driver *drv);
|
||||
void anybuss_client_driver_unregister(struct anybuss_client_driver *drv);
|
||||
|
||||
static inline struct anybuss_client *to_anybuss_client(struct device *dev)
|
||||
{
|
||||
return container_of(dev, struct anybuss_client, dev);
|
||||
}
|
||||
|
||||
static inline struct anybuss_client_driver *
|
||||
to_anybuss_client_driver(struct device_driver *drv)
|
||||
{
|
||||
return container_of(drv, struct anybuss_client_driver, driver);
|
||||
}
|
||||
|
||||
static inline void *
|
||||
anybuss_get_drvdata(const struct anybuss_client *client)
|
||||
{
|
||||
return dev_get_drvdata(&client->dev);
|
||||
}
|
||||
|
||||
static inline void
|
||||
anybuss_set_drvdata(struct anybuss_client *client, void *data)
|
||||
{
|
||||
dev_set_drvdata(&client->dev, data);
|
||||
}
|
||||
|
||||
int anybuss_set_power(struct anybuss_client *client, bool power_on);
|
||||
|
||||
enum anybuss_offl_mode {
|
||||
AB_OFFL_MODE_CLEAR = 0,
|
||||
AB_OFFL_MODE_FREEZE,
|
||||
AB_OFFL_MODE_SET
|
||||
};
|
||||
|
||||
struct anybuss_memcfg {
|
||||
u16 input_io;
|
||||
u16 input_dpram;
|
||||
u16 input_total;
|
||||
|
||||
u16 output_io;
|
||||
u16 output_dpram;
|
||||
u16 output_total;
|
||||
|
||||
enum anybuss_offl_mode offl_mode;
|
||||
};
|
||||
|
||||
int anybuss_start_init(struct anybuss_client *client,
|
||||
const struct anybuss_memcfg *cfg);
|
||||
int anybuss_finish_init(struct anybuss_client *client);
|
||||
int anybuss_read_fbctrl(struct anybuss_client *client, u16 addr,
|
||||
void *buf, size_t count);
|
||||
int anybuss_send_msg(struct anybuss_client *client, u16 cmd_num,
|
||||
const void *buf, size_t count);
|
||||
int anybuss_send_ext(struct anybuss_client *client, u16 cmd_num,
|
||||
const void *buf, size_t count);
|
||||
int anybuss_recv_msg(struct anybuss_client *client, u16 cmd_num,
|
||||
void *buf, size_t count);
|
||||
|
||||
/* these help clients make a struct file_operations */
|
||||
int anybuss_write_input(struct anybuss_client *client,
|
||||
const char __user *buf, size_t size,
|
||||
loff_t *offset);
|
||||
int anybuss_read_output(struct anybuss_client *client,
|
||||
char __user *buf, size_t size,
|
||||
loff_t *offset);
|
||||
|
||||
#endif /* __LINUX_ANYBUSS_CLIENT_H__ */
|
|
@ -0,0 +1,47 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Anybus-S controller definitions
|
||||
*
|
||||
* Copyright 2018 Arcx Inc
|
||||
*/
|
||||
|
||||
#ifndef __LINUX_ANYBUSS_CONTROLLER_H__
|
||||
#define __LINUX_ANYBUSS_CONTROLLER_H__
|
||||
|
||||
#include <linux/device.h>
|
||||
#include <linux/regmap.h>
|
||||
|
||||
/*
|
||||
* To instantiate an Anybus-S host, a controller should provide the following:
|
||||
* - a reset function which resets the attached card;
|
||||
* - a regmap which provides access to the attached card's dpram;
|
||||
* - the irq of the attached card
|
||||
*/
|
||||
/**
|
||||
* struct anybuss_ops - Controller resources to instantiate an Anybus-S host
|
||||
*
|
||||
* @reset: asserts/deasserts the anybus card's reset line.
|
||||
* @regmap: provides access to the card's dual-port RAM area.
|
||||
* @irq: number of the interrupt connected to the card's interrupt line.
|
||||
* @host_idx: for multi-host controllers, the host index:
|
||||
* 0 for the first host on the controller, 1 for the second, etc.
|
||||
*/
|
||||
struct anybuss_ops {
|
||||
void (*reset)(struct device *dev, bool assert);
|
||||
struct regmap *regmap;
|
||||
int irq;
|
||||
int host_idx;
|
||||
};
|
||||
|
||||
struct anybuss_host;
|
||||
|
||||
struct anybuss_host * __must_check
|
||||
anybuss_host_common_probe(struct device *dev,
|
||||
const struct anybuss_ops *ops);
|
||||
void anybuss_host_common_remove(struct anybuss_host *host);
|
||||
|
||||
struct anybuss_host * __must_check
|
||||
devm_anybuss_host_common_probe(struct device *dev,
|
||||
const struct anybuss_ops *ops);
|
||||
|
||||
#endif /* __LINUX_ANYBUSS_CONTROLLER_H__ */
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue