Add Fieldbus subsystem + support HMS Profinet card
Subsystems (4)
v11 cover Add Fieldbus subsystem + support HMS Profinet card
This patch:
1. adds a Fieldbus subsystem
2. adds support for the HMS Industrial Networks AB Profinet card.
1. Fieldbus subsystem
---------------------
Fieldbus device (client) adapters allow data exchange with a PLC aka. "Fieldbus Controller" over a fieldbus (Profinet, FLNet, etc.) They are typically used when a Linux device wants to expose itself as an actuator, motor, console light, switch, etc. over the fieldbus. The framework is designed to provide a generic interface to Fieldbus Devices from both the Linux Kernel and the userspace.
2. Add support for HMS Profinet Card
------------------------------------
Profinet is an industry technical standard for data communication over Industrial Ethernet, designed for collecting data from, and controlling, equipment in industrial systems, with a particular strength in delivering data under tight time constraints (on the order of 1ms or less).
The profinet card itself is connected to the system via an industrial bus called 'anybus'.
I have followed the bus driver/client driver pattern, and created an anybus bus driver, plus a client driver for the profinet card.
In case this patch set gets (eventually) accepted, drivers for other anybus client cards may follow: flnet, cc-link, ...
The anybus slot on the host is located on an 'anybus controller', which is custom h/w designed by arcx. It exposes a dual anybus host implementation, plus a power readout unrelated to the anybus.
v11:
keep all staging code self-contained within the staging/ directory
v10:
add a TODO file on how to take this patch set out of staging fix linker errors on defconfigs without HAS_IOMEM or REGULATOR
v9:
Moved everything to staging/ so new userspace ABI can still be tweaked Suggested cross-posting to linux-netdev to widen audience Greg KH: call ida_destroy() on module exits
replace arcx anybus controller's reset spinlock with mutex
(no need for spinlock as never run in atomic context) udelay() can now be replaced with usleep_range()
harmonized email addresses across patchset
various whitespace changes to silence checkpatch.pl --strict
v8:
allow fieldbus core to be built as a module (define as tristate). use IS_ENABLED() in fieldbus_dev.h to conditionally compile dummy functions. anybuss_core.ko uses symbols from fieldbus_dev.ko. Use "top level kbuild
file" method to make this work.
See Documentation/kbuild/modules.txt, section 6.3
Confirm licence choice: GPL-v2 only. no changes.
v7:
use %zu printf formatter to display size_t
v6:
Randy Dunlap:
correctly/consistently indent Kconfig
spelling/punctuation improvements
Greg KH:
suggestion: simplify /sys/class/fieldbus_dev/fieldbus_devX/ -> /sys/class/fieldbus_dev/X/
can't simplify: create_device() also determines the name of the associated char device. simplification would result in a char device named /dev/X ?
applied above suggestion to arcx-controller driver, this works ok as it does not
have associated char device
class name left as-is (fieldbus_dev) to differentiate between
"fieldbus controller" and "fieldbus device" in the future
makefile clean-up
sysfs attributes: snprintf -> sprintf
except card_name, as it's externally provided and could potentially be > PAGE_SIZE
enabled/online sysfs attributes converted to "0/1" values
using kstrtobool()
v5:
Greg KH:
fix licence nit
consistent use of e-mail address
replaced raw sysfs attribute with kobject_uevent() call keep __ATTRIBUTE_GROUPS because we need is_visible field
Rob Herring:
controller devicetree entry now requires multiple address
regions and interrupts
controller child node(s) now mapped to child devices by
slot/host position (using devicetree reg = <>)
architectural overhaul to align closely to existing pci arch:
pci anybus
--------------------------------------------------------------------------------
Common bus code (spec), pci/pci_driver.c anybus/dev_core.c
calls bus_register() no of compatible no of compatible
--------------------------------------------------------------------------------
Device on bus, calls
XXX_client_driver_register() hwmon/k8temp.c fieldbus/hms-profinet.c
--------------------------------------------------------------------------------
Controller, silicon driver pci/pcie-tango.c anybus/arcx-anybus.c
platform_driver calls platform_driver calls
pci_host_probe() anybus_host_common_probe()
v4:
general
create fieldbus_dev subsystem, with standardized 'simple'
userspace interface (sysfs + cdev)
remove redundant __packed keywords
use __be16/32 types wherever values are explicitly big-endian
hms-profinet:
remove configuration code, and uapi headers: not supported (yet)
when registering as a fieldbus_dev.
anybuss-host:
use struct kref to reference-count tasks
replace busy loops with usleep_range() loop after 10 tries use threaded irq so time_before_eq(jiffies, timeout) will
continue to work
allow client devices to be assigned a devicetree node,
in the same way as pci/mmc/...
v3:
devicetree-bindings
adding the vendor prefix is now a separate commit
anybus-bridge:
moved misc driver to drivers/bus/ converted of_gpio_* to gpiod_* abstractions can power readout is now a fixed-voltage regulator
anybuss-host:
converted refcounts from atomic_t to refcount_t fixed potential use-after-free
hms-profinet:
applied minor kernel build robot suggestion
v2:
added architecture overview comments to host driver completely reworked anybus-bridge driver, it becomes a reset controller anybuss-host driver now needs devicetree entry, link to reset controller I will hold off on kernel-doc until the overall architecture gets
more validation / approval
fixed Kconfig, comment-style, document ioctl magic numbers removed redundant pwm dependency
renamed enable-gpios to reset-gpios
stop driving reset-gpio after unloading driver
use interrupt-parent / interrupts method to describe interrupts
in the devicetree
convert references 'i.MX WEIM parallel bus' to 'parallel bus' replace devicetree functions with more generic platform_get_resource()
platform_get_irq()
added device unique data to add_device_randomness()
v1:
first shot
Sven Van Asbroeck (7):
fieldbus_dev: add Fieldbus Device subsystem.
anybus-s: support HMS Anybus-S bus
anybus-s: support the Arcx anybus controller
dt-bindings: anybus-controller: document devicetree binding
dt-bindings: Add vendor prefix for arcx / Archronix
fieldbus_dev: support HMS Profinet IRT industrial controller
staging: fieldbus_dev: add TODO
.../fieldbus/arcx,anybus-controller.txt | 71 + .../devicetree/bindings/vendor-prefixes.txt | 1 + drivers/staging/Kconfig | 2 + drivers/staging/Makefile | 1 + .../Documentation/ABI/fieldbus-dev-cdev | 31 + .../ABI/sysfs-class-fieldbus-dev | 62 + .../fieldbus/Documentation/fieldbus_dev.txt | 66 + drivers/staging/fieldbus/Kconfig | 18 + drivers/staging/fieldbus/Makefile | 7 + drivers/staging/fieldbus/TODO | 5 + drivers/staging/fieldbus/anybuss/Kconfig | 39 + drivers/staging/fieldbus/anybuss/Makefile | 10 + .../staging/fieldbus/anybuss/anybuss-client.h | 102 ++ .../fieldbus/anybuss/anybuss-controller.h | 47 + .../staging/fieldbus/anybuss/arcx-anybus.c | 399 +++++ .../staging/fieldbus/anybuss/hms-profinet.c | 228 +++ drivers/staging/fieldbus/anybuss/host.c | 1460 +++++++++++++++++ drivers/staging/fieldbus/dev_core.c | 351 ++++ drivers/staging/fieldbus/fieldbus_dev.h | 108 ++ 19 files changed, 3008 insertions(+) create mode 100644 Documentation/devicetree/bindings/fieldbus/arcx,anybus-controller.txt create mode 100644 drivers/staging/fieldbus/Documentation/ABI/fieldbus-dev-cdev create mode 100644 drivers/staging/fieldbus/Documentation/ABI/sysfs-class-fieldbus-dev create mode 100644 drivers/staging/fieldbus/Documentation/fieldbus_dev.txt create mode 100644 drivers/staging/fieldbus/Kconfig create mode 100644 drivers/staging/fieldbus/Makefile create mode 100644 drivers/staging/fieldbus/TODO create mode 100644 drivers/staging/fieldbus/anybuss/Kconfig create mode 100644 drivers/staging/fieldbus/anybuss/Makefile create mode 100644 drivers/staging/fieldbus/anybuss/anybuss-client.h create mode 100644 drivers/staging/fieldbus/anybuss/anybuss-controller.h create mode 100644 drivers/staging/fieldbus/anybuss/arcx-anybus.c create mode 100644 drivers/staging/fieldbus/anybuss/hms-profinet.c create mode 100644 drivers/staging/fieldbus/anybuss/host.c create mode 100644 drivers/staging/fieldbus/dev_core.c create mode 100644 drivers/staging/fieldbus/fieldbus_dev.h
Signature · 1 line
2.17.1
PATCH v11 1/7 fieldbus_dev: add Fieldbus Device subsystem.
Fieldbus device (client) adapters allow data exchange with a PLC aka. "Fieldbus Controller" over a fieldbus (Profinet, FLNet, etc.)
They are typically used when a Linux device wants to expose itself as an actuator, motor, console light, switch, etc. over the fieldbus.
This framework is designed to provide a generic interface to Fieldbus Devices from both the Linux Kernel and the userspace.
--- drivers/staging/Kconfig | 2 + drivers/staging/Makefile | 1 + .../Documentation/ABI/fieldbus-dev-cdev | 31 ++ .../ABI/sysfs-class-fieldbus-dev | 62 ++++ .../fieldbus/Documentation/fieldbus_dev.txt | 66 ++++ drivers/staging/fieldbus/Kconfig | 19 + drivers/staging/fieldbus/Makefile | 9 + drivers/staging/fieldbus/dev_core.c | 351 ++++++++++++++++++ drivers/staging/fieldbus/fieldbus_dev.h | 108 ++++++ 9 files changed, 649 insertions(+) create mode 100644 drivers/staging/fieldbus/Documentation/ABI/fieldbus-dev-cdev create mode 100644 drivers/staging/fieldbus/Documentation/ABI/sysfs-class-fieldbus-dev create mode 100644 drivers/staging/fieldbus/Documentation/fieldbus_dev.txt create mode 100644 drivers/staging/fieldbus/Kconfig create mode 100644 drivers/staging/fieldbus/Makefile create mode 100644 drivers/staging/fieldbus/dev_core.c create mode 100644 drivers/staging/fieldbus/fieldbus_dev.h
drivers/staging/Kconfig +2 -0
@@ -122,4 +122,6 @@ source "drivers/staging/axis-fifo/Kconfig" source "drivers/staging/erofs/Kconfig" +source "drivers/staging/fieldbus/Kconfig" + endif # STAGING
drivers/staging/Makefile +1 -0
@@ -51,3 +51,4 @@ obj-$(CONFIG_SOC_MT7621) += mt7621-dts/ obj-$(CONFIG_STAGING_GASKET_FRAMEWORK) += gasket/ obj-$(CONFIG_XIL_AXIS_FIFO) += axis-fifo/ obj-$(CONFIG_EROFS_FS) += erofs/ +obj-$(CONFIG_FIELDBUS_DEV) += fieldbus/
drivers/staging/fieldbus/Documentation/ABI/fieldbus-dev-cdev new file +31 -0
@@ -0,0 +1,31 @@ +What: /dev/fieldbus_devX +Date: December 2018 +KernelVersion: 5.1 (staging) +Contact: Sven Van Asbroeck <[email protected]> +Description: + The cdev interface to drivers for Fieldbus Device Memory + (aka. Process Memory). + + The following file operations are supported: + + open(2) + Create an I/O context associated with the file descriptor. + + read(2) + Read from Process Memory's "read area". + Clears POLLERR | POLLPRI from the file descriptor. + + write(2) + Write to Process Memory's "write area". + + poll(2), select(2), epoll_wait(2) etc. + When a "Process Memory Read Area Changed" event occurs, + POLLERR | POLLPRI will be set on the file descriptor. + Note that POLLIN | POLLOUT events are always set, because the + process memory area is always readable and writable. + + close(2) + Free up the I/O context that was associated + with the file descriptor. + +Users: TBD
drivers/staging/fieldbus/Documentation/ABI/sysfs-class-fieldbus-dev new file +62 -0
62 lines not on this page · raw message
drivers/staging/fieldbus/Documentation/fieldbus_dev.txt new file +66 -0
66 lines not on this page · raw message
drivers/staging/fieldbus/Kconfig new file +19 -0
@@ -0,0 +1,19 @@ +menuconfig FIELDBUS_DEV + tristate "Fieldbus Device Support" + help + Support for Fieldbus Device Adapters. + + Fieldbus device (client) adapters allow data exchange with a PLC aka. + "Fieldbus Controller" over a fieldbus (Profinet, FLNet, etc.) + + They are typically used when a Linux device wants to expose itself + as an actuator, motor, console light, switch, etc. over the fieldbus. + + This framework is designed to provide a generic interface to Fieldbus + Devices from both the Linux Kernel and the userspace. + + If unsure, say no. + +if FIELDBUS_DEV + +endif
drivers/staging/fieldbus/Makefile new file +9 -0
@@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for fieldbus_dev drivers. +# + +obj-$(CONFIG_FIELDBUS_DEV) += fieldbus_dev.o +fieldbus_dev-y := dev_core.o + +# Devices
drivers/staging/fieldbus/dev_core.c new file +351 -0
351 lines not on this page · raw message
drivers/staging/fieldbus/fieldbus_dev.h new file +108 -0
108 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v11 2/7 anybus-s: support HMS Anybus-S bus
In reply to Sven Van AsbroeckThe 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
--- drivers/staging/fieldbus/Kconfig | 3 +- drivers/staging/fieldbus/Makefile | 3 +- drivers/staging/fieldbus/anybuss/Kconfig | 9 + drivers/staging/fieldbus/anybuss/Makefile | 7 + .../staging/fieldbus/anybuss/anybuss-client.h | 102 ++ .../fieldbus/anybuss/anybuss-controller.h | 47 + drivers/staging/fieldbus/anybuss/host.c | 1460 +++++++++++++++++ 7 files changed, 1627 insertions(+), 4 deletions(-) create mode 100644 drivers/staging/fieldbus/anybuss/Kconfig create mode 100644 drivers/staging/fieldbus/anybuss/Makefile create mode 100644 drivers/staging/fieldbus/anybuss/anybuss-client.h create mode 100644 drivers/staging/fieldbus/anybuss/anybuss-controller.h create mode 100644 drivers/staging/fieldbus/anybuss/host.c
drivers/staging/fieldbus/Kconfig +1 -2
@@ -14,6 +14,5 @@ menuconfig FIELDBUS_DEV If unsure, say no. -if FIELDBUS_DEV +source "drivers/staging/fieldbus/anybuss/Kconfig" -endif
drivers/staging/fieldbus/Makefile +1 -2
@@ -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
drivers/staging/fieldbus/anybuss/Kconfig new file +9 -0
@@ -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.
drivers/staging/fieldbus/anybuss/Makefile new file +7 -0
@@ -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
drivers/staging/fieldbus/anybuss/anybuss-client.h new file +102 -0
102 lines not on this page · raw message
drivers/staging/fieldbus/anybuss/anybuss-controller.h new file +47 -0
47 lines not on this page · raw message
drivers/staging/fieldbus/anybuss/host.c new file +1460 -0
1,460 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH v11 2/7] anybus-s: support HMS Anybus-S bus
On 16.04.19 17:56, Sven Van Asbroeck wrote:
Hi,
Quoted 5 lines
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.
I'm a bit confused, what this anybus stuff actually does.
Is it some proprietary backplane bus, where things like eg. fieldbus adapters are attached to ?
I see some struct bus_type field declaration - is that going to be some subsystem, similar to those for other bus'es (eg. pci, usb, ...) ?
Maybe that deserves a bit more documentation :p
--mtx
Signature · 3 lines
Enrico Weigelt, metux IT consult Free software and Linux embedded engineering [email protected] -- +49-151-27565287
Re: [PATCH v11 2/7] anybus-s: support HMS Anybus-S bus
Quoted 7 lines · metux IT consult
Is it some proprietary backplane bus, where things like eg. fieldbus adapters are attached to ?
I see some struct
bus_typefield declaration - is that going to be some subsystem, similar to those for other bus'es (eg. pci, usb, ...) ?
Correct on both points :)
The author of this proprietary standard (HMS) calls this a bus, but only a single card can be connected to a slot. So it's not like pci or usb, where you can connect multiple devices to a host.
Quoted 2 lines
Maybe that deserves a bit more documentation :p
Sure, I can do that. What would be the best location for this? The commit message? The Kconfig blurb? Comments in host.c? Somewhere in Documentation/ ?
Sven
Re: [PATCH v11 2/7] anybus-s: support HMS Anybus-S bus
On 16.04.19 20:43, Sven Van Asbroeck wrote:
Hi,
Quoted 4 lines
Correct on both points :)
The author of this proprietary standard (HMS) calls this a bus, but only a single card can be connected to a slot. So it's not like pci or usb, where you can connect multiple devices to a host.
But this port supports probing ?
(so it's, bit like a single usb port w/o hub ;-))
Quoted 6 lines
Quoted 2 lines
Maybe that deserves a bit more documentation :p
Sure, I can do that. What would be the best location for this? The commit message? The
Kconfigblurb? Comments inhost.c? Somewhere inDocumentation/?
In the long run, Documentation/ IMHO would be the best place (at least for longer explainations).
OTOH, a few more precise words in the commit message would be nice, too.
I guess that things like introducing new bus types or device classes are something that subsystem maintainers wanna be aware of :)
--mtx
Signature · 3 lines
Enrico Weigelt, metux IT consult Free software and Linux embedded engineering [email protected] -- +49-151-27565287
Re: [PATCH v11 2/7] anybus-s: support HMS Anybus-S bus
Quoted 3 lines · metux IT consult
But this port supports probing ?
(so it's, bit like a single usb port w/o hub ;-))
Yes, that's exactly it.
Quoted 5 lines
In the long run,
Documentation/IMHO would be the best place (at least for longer explainations).OTOH, a few more precise words in the commit message would be nice, too.
Ok, sounds like a plan.
Quoted 4 lines
I guess that things like introducing new bus types or device classes are something that subsystem maintainers wanna be aware of :)
fieldbus_dev is a new subsystem.
At first I attempted to mainline the anybus-s drivers with a 'roll-your-own' userspace API, but the feedback I got was: this userspace API should really be generic... So this is my attempt to create a generic fieldbus_dev API !
It's almost certainly insufficient, but it's a start. Ideally, this should get lots
of review from people in the industry, but response to this patchset has been underwhelming. That's the reason this is going into staging/. Hopefully it will create discussion, and a way forward to a more extensive userspace API. If not, it'll go to /dev/null after a year.
Re: [PATCH v11 2/7] anybus-s: support HMS Anybus-S bus
On 17.04.19 00:00, Sven Van Asbroeck wrote:
Hi,
Quoted 1 line
Quoted 1 line
But this port supports probing ?>> (so it's, bit like a single usb port w/o hub ;-))> > Yes, that's
exactly it.
Okay, then your approach introducing a bus_type is correct, IMHO.
Quoted 6 lines
Quoted 1 line
I guess that things like introducing new bus types or device classes>> are something that subsystem maintainers wanna be aware of :)>>>
fieldbus_devis a new subsystem.
At first I attempted to mainline the anybus-s drivers with a 'roll-your-own' userspace API, but the feedback I got was: this userspace API should really be generic... So this is my attempt to create a genericfieldbus_devAPI !
Yes, it's an own class of devices, many other (semantically) simiar devices out there. Therefore, an own subsystem for that is a good idea.
But: I'd rather call it it "iec61158" instead of fieldbus", as there're lots of different fieldbus types (eg. MVB has pretty different semantics than iec61158)
Quoted 3 lines
It's almost certainly insufficient, but it's a start. Ideally, this should get lots of review from people in the industry, but response to this patchset has been underwhelming.
It's still a niche, at least for Linux. Only few people here ever had their hands on such PLC systems.
--mtx
Signature · 3 lines
Enrico Weigelt, metux IT consult Free software and Linux embedded engineering [email protected] -- +49-151-27565287
Re: [PATCH v11 2/7] anybus-s: support HMS Anybus-S bus
Quoted 5 lines · metux IT consult
But: I'd rather call it it "iec61158" instead of fieldbus", as there're lots of different fieldbus types (eg. MVB has pretty different semantics than iec61158)
I agree that correct naming is very important.
In this case however, we can't let the perfect get in the way of the good. This subsystem has a single user right now (me) and that can change only if others can discover and understand it. And at this stage, simple is best.
At this point we don't know yet where the API might possibly go. It might evolve into something broader that includes IEC61158 as just one aspect.
If and when we mature and get more users/stakeholders, we can then look at changing to more specific naming. Definitely before coming out of staging/.
Greg KH has accepted the v11 patch set, so at this stage we can make changes only by circulating patches on the mailing list. Would you like me to post patches for anybus-s documentation / making the regulator optional? Or would you like to have a go at that yourself?
Sven
Re: [PATCH v11 2/7] anybus-s: support HMS Anybus-S bus
Quoted 3 lines · Sven Van Asbroeck
At this point we don't know yet where the API might possibly go. It might evolve into something broader that includes IEC61158 as just one aspect.
I doubt that, because:
* All the devices (at least those I've seen somewhere) that follow semantics similar to IEC61158, are actually IEC61158. (maybe not everybody fully spec compatible or some dialects). Because that's exactly the industry standard for anything that works on that shared process memory model.
* the other fieldbus'es I've mentioned have completely different semantics and just fit in here.
Therefore: we should call things exactly what they are. We don't call grapefruits apples, even though both are round and tend to contain a lot of sugar.
Quoted 3 lines
If and when we mature and get more users/stakeholders, we can then look at changing to more specific naming. Definitely before coming out of staging/.
I don't like the idea of name changing *after* this went to mainline and people are actually using it. At that point, people might even already written their own drivers, so they'd have to change them, too.
Please let's do that ASAP. It doesn't cost us much at this stage.
Quoted 2 lines
Greg KH has accepted the v11 patch set, so at this stage we can make changes only by circulating patches on the mailing list.
@Greg: is that already in your tree ? What do you think about doing the name change now ?
Quoted 2 lines
Would you like me to post patches for anybus-s documentation / making the regulator optional? Or would you like to have a go at that yourself?
If your patches haven't been taken by in Grek yet, it IMHO would be good to rework the queue w/ the missing pieces (-> v12). Otherwise separate patches ontop of the already applied queue probably would be better.
--mtx
Signature · 3 lines
Enrico Weigelt, metux IT consult Free software and Linux embedded engineering [email protected] -- +49-151-27565287
Re: [PATCH v11 2/7] anybus-s: support HMS Anybus-S bus
Quoted 5 lines · metux IT consult
I don't like the idea of name changing *after* this went to mainline and people are actually using it. At that point, people might even already written their own drivers, so they'd have to change them, too.
Quoted 8 lines
Please let's do that ASAP. It doesn't cost us much at this stage.
Quoted 2 lines
Greg KH has accepted the v11 patch set, so at this stage we can make changes only by circulating patches on the mailing list.
@Greg: is that already in your tree ? What do you think about doing the name change now ?
Greg KH has already taken the patch set.
If we annoy him too much with this niche subsystem, we run the very real risk that he'll just throw it out.
So any changes (naming or otherwise) will need to follow the tried-and-tested method of:
- cycling patches on the mailing list until fully cooked
- maintainer sending cooked patches upstream (i.e. Greg KH)
Sven
PATCH v11 3/7 anybus-s: support the Arcx anybus controller
In reply to Sven Van AsbroeckAdd a driver for the Arcx anybus controller.
This device implements two Anybus-S hosts (buses), and connects to the SoC via a parallel memory bus. There is also a CAN power readout, unrelated to the Anybus, modelled as a regulator.
--- drivers/staging/fieldbus/Makefile | 1 - drivers/staging/fieldbus/anybuss/Kconfig | 14 + drivers/staging/fieldbus/anybuss/Makefile | 2 + .../staging/fieldbus/anybuss/arcx-anybus.c | 399 ++++++++++++++++++ 4 files changed, 415 insertions(+), 1 deletion(-) create mode 100644 drivers/staging/fieldbus/anybuss/arcx-anybus.c
drivers/staging/fieldbus/Makefile +0 -1
@@ -5,4 +5,3 @@ obj-$(CONFIG_FIELDBUS_DEV) += fieldbus_dev.o anybuss/ fieldbus_dev-y := dev_core.o -
drivers/staging/fieldbus/anybuss/Kconfig +14 -0
@@ -7,3 +7,17 @@ config HMS_ANYBUSS_BUS You can attach a single Anybus-S compatible card to it, which typically provides fieldbus and industrial ethernet functionality. + +if HMS_ANYBUSS_BUS + +config ARCX_ANYBUS_CONTROLLER + tristate "Arcx Anybus-S Controller" + depends on OF && GPIOLIB && HAS_IOMEM && REGULATOR + help + Select this to get support for the Arcx Anybus controller. + It connects to the SoC via a parallel memory bus, and + embeds up to two Anybus-S buses (slots). + There is also a CAN power readout, unrelated to the Anybus, + modelled as a regulator. + +endif
drivers/staging/fieldbus/anybuss/Makefile +2 -0
@@ -5,3 +5,5 @@ obj-$(CONFIG_HMS_ANYBUSS_BUS) += anybuss_core.o anybuss_core-y += host.o + +obj-$(CONFIG_ARCX_ANYBUS_CONTROLLER) += arcx-anybus.o
drivers/staging/fieldbus/anybuss/arcx-anybus.c new file +399 -0
399 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH v11 3/7] anybus-s: support the Arcx anybus controller
Quoted 6 lines · Sven Van Asbroeck
Add a driver for the Arcx anybus controller.
This device implements two Anybus-S hosts (buses), and connects to the SoC via a parallel memory bus. There is also a CAN power readout, unrelated to the Anybus, modelled as a regulator.
How do the anybus host and the CAN stuff relate to each other ?
--mtx
Signature · 3 lines
Enrico Weigelt, metux IT consult Free software and Linux embedded engineering [email protected] -- +49-151-27565287
Re: [PATCH v11 3/7] anybus-s: support the Arcx anybus controller
Hi Enrico,
Quoted 3 lines · metux IT consult
How do the anybus host and the CAN stuff relate to each other ?
The "CAN stuff" is just a binary power read-out, routed from an external CAN card, which may or may not be present. The CAN card is not accessed from within this driver. This situation arises because our h/w developer team decided to integrate various unrelated pieces of functionality into the same hardware card (even into the same 8-bit register).
This arcx-anybus controller card has two unrelated pieces of functionality:
1. implements an anybus-s slot
2. implements a power read-out from an external CAN card
This situation is not ideal but it's what we have :)
Sven
Re: [PATCH v11 3/7] anybus-s: support the Arcx anybus controller
On 16.04.19 20:35, Sven Van Asbroeck wrote:
Hi,
Quoted 5 lines
The "CAN stuff" is just a binary power read-out, routed from an external CAN card, which may or may not be present. The CAN card is not accessed from within this driver. This situation arises because our h/w developer team decided to integrate various unrelated pieces of functionality into the same hardware card (even into the same 8-bit register).
BRRR!
Quoted 3 lines
This arcx-anybus controller card has two unrelated pieces of functionality:
1. implements an anybus-s slot
2. implements a power read-out from an external CAN card
So, it's an mfd (multi function device) ... hmm.
By the grey theory it would be better to split it into two separate drivers. But obviously, they need need a common part (a third piece).
Does it ever make sense to only use one of two functionalities ?
Does this power read-out involve some CAN traffic, or is it just fetching from some card that just happens to be some CAN interface ? (IOW: is cansocket needed for that ?)
--mtx
Signature · 3 lines
Enrico Weigelt, metux IT consult Free software and Linux embedded engineering [email protected] -- +49-151-27565287
Re: [PATCH v11 3/7] anybus-s: support the Arcx anybus controller
On Tue, Apr 16, 2019 at 5:07 PM Enrico Weigelt, metux IT consult <[email protected]> wrote:>
Quoted 2 lines
By the grey theory it would be better to split it into two separate drivers. But obviously, they need need a common part (a third piece).
Well yes, we could treat it as an mfd device, with a common register accessor, which registers anybus-s host and adc drivers, all selectable via Kconfig / defconfig... But that's a lot of extra code just to handle one single bit in a register, which is a boolean input.
Can be done but is it worth it?
Quoted 2 lines
Does it ever make sense to only use one of two functionalities ?
That depends on what the userspace app wants to do. Our userspace app always attempts to monitor the CAN readout.
Quoted 5 lines
Does this power read-out involve some CAN traffic, or is it just fetching from some card that just happens to be some CAN interface ? (IOW: is cansocket needed for that ?)
It is purely a boolean input. The boolean output of a voltage monitor chip. When our hardware is assembled, the voltage monitor input is connected to a signal which indicates the CAN status. In theory, it could be connected to the factory's light switch. It would then read out the status of the factory floor lights. It has no CAN functionality whatsoever.
Re: [PATCH v11 3/7] anybus-s: support the Arcx anybus controller
On 16.04.19 23:23, Sven Van Asbroeck wrote:
Hi,
Quoted 1 line
Well yes, we could treat it as an mfd device, with a common register accessor,> which registers anybus-s host and adc drivers, all selectable via>
Kconfig / defconfig... But that's a lot of extra code just to handle one single> bit in a register, which is a boolean input.> > Can be done but is it worth it?
hmm, I think the main question here is clean separation between subsystems - devices that span multiple subsystems, IMHO, fall into the category "mfd".
separate drivers probably don't make much sense here, but maybe a CONFIG_ flag for disabling this functionality ?
Quoted 9 lines
Quoted 3 lines
Does this power read-out involve some CAN traffic, or is it just fetching from some card that just happens to be some CAN interface ? (IOW: is cansocket needed for that ?)
It is purely a boolean input. The boolean output of a voltage monitor chip. When our hardware is assembled, the voltage monitor input is connected to a signal which indicates the CAN status. In theory, it could be connected to the factory's light switch. It would then read out the status of the factory floor lights. It has no CAN functionality whatsoever.
hmm, wouldn't the input subsystem be more appropriate for that ?
--mtx
Signature · 3 lines
Enrico Weigelt, metux IT consult Free software and Linux embedded engineering [email protected] -- +49-151-27565287
Re: [PATCH v11 3/7] anybus-s: support the Arcx anybus controller
Quoted 4 lines · metux IT consult
hmm, I think the main question here is clean separation between subsystems - devices that span multiple subsystems, IMHO, fall into the category "mfd".
Generally I agree wholeheartedly, but as we discussed, it might not be worth the trouble in this case.
Quoted 2 lines
separate drivers probably don't make much sense here, but maybe a
CONFIG_flag for disabling this functionality ?
Yes, I can add that for sure !
Quoted 3 lines
hmm, wouldn't the input subsystem be more appropriate for that ?
The input subsystem is concerned with input from humans? But in this case, it's really a power output from an external card on a PCB assembly. Regulator seemed the kernel abstraction closest to what this actually represents.
I'm honestly not fully satisfied by the use of the regulator abstraction here. If you know of a different abstraction which seems better, I'll definitely consider it.
Re: [PATCH v11 3/7] anybus-s: support the Arcx anybus controller
On 17.04.19 16:17, Sven Van Asbroeck wrote:
<snip>
Quoted 1 line
The input subsystem is concerned with input from humans?
Not necessarily.
Quoted 3 lines
But in this case, it's really a power output from an external card on a PCB assembly. Regulator seemed the kernel abstraction closest to what this actually represents.
IMHO, regulator framework is for actually controlling power supplies and things like some device driver asking for powering it's device.
Let's recap what the regulator framework was invented for:
* on many boards, some devices need to be explicitly powered (or are powered off for power saving) via external regulators
* these regulators usually are generic chips, just wired up differently on the individual boards
If I understood you correctly, your controller has an generic digital input, which you just use for monitoring that external power supply in your specific usecase - while other folks might attach completely different things here.
The really "formally correct" way, the pure doctine, IMHO would be having that line as a generic input, and in case that there really is this some power readback connected here, bind it to a generic driver. (of course, pure doctrine isn't necessarily the best way to do things)
Quoted 3 lines
I'm honestly not fully satisfied by the use of the regulator abstraction here. If you know of a different abstraction which seems better, I'll definitely consider it.
hmm, maybe we should talk about what is actually done with this information.
can you give some practical usecases ?
--mtx
Signature · 3 lines
Enrico Weigelt, metux IT consult Free software and Linux embedded engineering [email protected] -- +49-151-27565287
Re: [PATCH v11 3/7] anybus-s: support the Arcx anybus controller
In reply to Sven Van AsbroeckOn 17.04.19 16:17, Sven Van Asbroeck wrote:
<snip>
Quoted 1 line
But in this case, it's really a power output from an external card> on a PCB assembly. Regulator seemed the kernel abstraction> closest to
what this actually represents.
Oh, just missed that in my other mail.
So, that input line is *always* hardwired to the regulator ?Okay, that's a different situation.
--mtx
Signature · 3 lines
Enrico Weigelt, metux IT consult Free software and Linux embedded engineering [email protected] -- +49-151-27565287
Re: [PATCH v11 3/7] anybus-s: support the Arcx anybus controller
Quoted 4 lines · metux IT consult
So, that input line is *always* hardwired to the regulator ?Okay, that's a different situation.
Yes, it's always hardwired to the CAN regulator by production / assembly.
So it looks as if regulator is the closest suitable abstraction. I suggest we stick
with it until and unless someone has a better suggestion.
PATCH v11 4/7 dt-bindings: anybus-controller: document devicetree binding
In reply to Sven Van AsbroeckThis patch adds devicetree binding documentation for the Arcx anybus controller.
--- .../fieldbus/arcx,anybus-controller.txt | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 Documentation/devicetree/bindings/fieldbus/arcx,anybus-controller.txt
Documentation/devicetree/bindings/fieldbus/arcx,anybus-controller.txt new file +71 -0
@@ -0,0 +1,71 @@ +* Arcx Anybus-S controller + +This chip communicates with the SoC over a parallel bus. It is +expected that its Device Tree node is specified as the child of a node +corresponding to the parallel bus used for communication. + +Required properties: +-------------------- + + - compatible : The following chip-specific string: + "arcx,anybus-controller" + + - reg : three areas: + index 0: bus memory area where the cpld registers are located. + index 1: bus memory area of the first host's dual-port ram. + index 2: bus memory area of the second host's dual-port ram. + + - reset-gpios : the GPIO pin connected to the reset line of the controller. + + - interrupts : two interrupts: + index 0: interrupt connected to the first host + index 1: interrupt connected to the second host + Generic interrupt client node bindings are described in + interrupt-controller/interrupts.txt + +Optional: use of subnodes +------------------------- + +The card connected to a host may need additional properties. These can be +specified in subnodes to the controller node. + +The subnodes are identified by the standard 'reg' property. Which information +exactly can be specified depends on the bindings for the function driver +for the subnode. + +Required controller node properties when using subnodes: +- #address-cells: should be one. +- #size-cells: should be zero. + +Required subnode properties: +- reg: Must contain the host index of the card this subnode describes: + <0> for the first host on the controller + <1> for the second host on the controller + Note that only a single card can be plugged into a host, so the host + index uniquely describes the card location. + +Example of usage: +----------------- + +This example places the bridge on top of the i.MX WEIM parallel bus, see: +Documentation/devicetree/bindings/bus/imx-weim.txt + +&weim { + controller@0,0 { + compatible = "arcx,anybus-controller"; + reg = <0 0 0x100>, <0 0x400000 0x800>, <1 0x400000 0x800>; + reset-gpios = <&gpio5 2 GPIO_ACTIVE_HIGH>; + interrupt-parent = <&gpio1>; + interrupts = <1 IRQ_TYPE_LEVEL_LOW>, <5 IRQ_TYPE_LEVEL_LOW>; + /* fsl,weim-cs-timing is a i.MX WEIM bus specific property */ + fsl,weim-cs-timing = <0x024400b1 0x00001010 0x20081100 + 0x00000000 0xa0000240 0x00000000>; + /* optional subnode for a card plugged into the first host */ + #address-cells = <1>; + #size-cells = <0>; + card@0 { + reg = <0>; + /* card specific properties go here */ + }; + }; +};
Signature · 1 line
2.17.1
PATCH v11 5/7 dt-bindings: Add vendor prefix for arcx / Archronix
In reply to Sven Van Asbroeckarcx Inc. is an engineering company which provides advanced embedded systems and consulting services.
Archronix is a technology design and product engineering firm specializing in hardware control systems and enabling software. Clients include OEM's in the transportation, aerospace, medical and commercial sectors.
Websites:
http://www.arcx.com/ http://www.archronix.com/
--- Documentation/devicetree/bindings/vendor-prefixes.txt | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
@@ -36,6 +36,7 @@ aptina Aptina Imaging arasan Arasan Chip Systems archermind ArcherMind Technology (Nanjing) Co., Ltd. arctic Arctic Sand +arcx arcx Inc. / Archronix Inc. aries Aries Embedded GmbH arm ARM Ltd. armadeus ARMadeus Systems SARL
Signature · 1 line
2.17.1
PATCH v11 6/7 fieldbus_dev: support HMS Profinet IRT industrial controller
In reply to Sven Van AsbroeckThe Anybus-S PROFINET IRT communication module provides instant integration to any Ethernet based LAN via SMTP, FTP, HTTP as well as PROFINET and Modbus-TCP. Additional protocols can be implemented on top of TCP/IP or UDP using the transparent socket interface.
Official documentation:
https://www.anybus.com/docs/librariesprovider7/default-document-library
/manuals-design-guides/hms-hmsi-168-52.pdf
This implementation is an Anybus-S client driver, designed to be instantiated by the Anybus-S bus driver when it discovers the Profinet card.
If loaded successfully, the driver registers itself as a fieldbus_dev, and userspace can access it through the fieldbus_dev interface.
--- drivers/staging/fieldbus/anybuss/Kconfig | 16 ++ drivers/staging/fieldbus/anybuss/Makefile | 1 + .../staging/fieldbus/anybuss/hms-profinet.c | 228 ++++++++++++++++++ 3 files changed, 245 insertions(+) create mode 100644 drivers/staging/fieldbus/anybuss/hms-profinet.c
drivers/staging/fieldbus/anybuss/Kconfig +16 -0
@@ -20,4 +20,20 @@ config ARCX_ANYBUS_CONTROLLER There is also a CAN power readout, unrelated to the Anybus, modelled as a regulator. +config HMS_PROFINET + tristate "HMS Profinet IRT Controller (Anybus-S)" + depends on FIELDBUS_DEV && HMS_ANYBUSS_BUS + help + If you say yes here you get support for the HMS Industrial + Networks Profinet IRT Controller. + + It will be registered with the kernel as a fieldbus_dev, + so userspace can interact with it via the fieldbus_dev userspace + interface(s). + + This driver can also be built as a module. If so, the module + will be called hms-profinet. + + If unsure, say N. + endif
drivers/staging/fieldbus/anybuss/Makefile +1 -0
@@ -7,3 +7,4 @@ obj-$(CONFIG_HMS_ANYBUSS_BUS) += anybuss_core.o anybuss_core-y += host.o obj-$(CONFIG_ARCX_ANYBUS_CONTROLLER) += arcx-anybus.o +obj-$(CONFIG_HMS_PROFINET) += hms-profinet.o
drivers/staging/fieldbus/anybuss/hms-profinet.c new file +228 -0
228 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v11 7/7 staging: fieldbus_dev: add TODO
In reply to Sven Van AsbroeckAdd a TODO file which describes what needs to be done in order to get the fieldbus_dev subsystem out of staging.
--- drivers/staging/fieldbus/TODO | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 drivers/staging/fieldbus/TODO
drivers/staging/fieldbus/TODO new file +5 -0
@@ -0,0 +1,5 @@ +TODO: +-Get more people/drivers to use the Fieldbus userspace ABI. It requires + verification/sign-off by multiple users. + +Contact: Sven Van Asbroeck <[email protected]>
Signature · 1 line
2.17.1