Skip to contentSkip to conversation

Support HMS Profinet Card over Anybus

PATCH Superseded [email protected] 4 participants 13 messages Oct 31, 2018 – Nov 15, 2018

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Support HMS Profinet Card over Anybus

From: Sven Van Asbroeck <[email protected]>

This patch set adds support for the HMS Industrial Networks AB 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 bridge', which is custom h/w designed by Arcx. Its driver is modeled as a misc device, which exposes a dual reset controller, plus a power readout unrelated to the anybus.

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 (5):
misc: support the Arcx anybus bridge.
dt-bindings: anybus-bridge: document devicetree binding.
bus: support HMS Anybus-S bus.
dt-bindings: anybuss-host: document devicetree binding.
misc: support HMS Profinet IRT industrial controller.

 .../bindings/bus/arcx,anybuss-host.txt        |   36 +
 .../bindings/misc/arcx,anybus-bridge.txt      |   34 +
 .../devicetree/bindings/vendor-prefixes.txt   |    1 +
 Documentation/ioctl/ioctl-number.txt          |    1 +
 drivers/bus/Kconfig                           |   10 +
 drivers/bus/Makefile                          |    1 +
 drivers/bus/anybuss-host.c                    | 1498 +++++++++++++++++
 drivers/misc/Kconfig                          |   19 +
 drivers/misc/Makefile                         |    2 +
 drivers/misc/anybus-bridge.c                  |  301 ++++
 drivers/misc/hms-profinet.c                   |  753 +++++++++
 include/linux/anybuss-client.h                |  100 ++
 include/uapi/linux/hms-common.h               |   14 +
 include/uapi/linux/hms-profinet.h             |  102 ++
 14 files changed, 2872 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/bus/arcx,anybuss-host.txt
 create mode 100644 Documentation/devicetree/bindings/misc/arcx,anybus-bridge.txt
 create mode 100644 drivers/bus/anybuss-host.c
 create mode 100644 drivers/misc/anybus-bridge.c
 create mode 100644 drivers/misc/hms-profinet.c
 create mode 100644 include/linux/anybuss-client.h
 create mode 100644 include/uapi/linux/hms-common.h
 create mode 100644 include/uapi/linux/hms-profinet.h
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 1/5 misc: support the Arcx anybus bridge.

From: Sven Van Asbroeck <[email protected]>

Add a driver for the Arcx anybus bridge.

This chip embeds up to two Anybus-S application connectors (slots), and connects to the SoC via a parallel memory bus. There is also a CAN power readout, unrelated to the Anybus.

---
 drivers/misc/Kconfig         |   9 ++
 drivers/misc/Makefile        |   1 +
 drivers/misc/anybus-bridge.c | 301 +++++++++++++++++++++++++++++++++++
 3 files changed, 311 insertions(+)
 create mode 100644 drivers/misc/anybus-bridge.c
drivers/misc/Kconfig +9 -0
index 3726eacdf65d..dd7fdbf659b7 100644
@@ -509,6 +509,15 @@ config PCI_ENDPOINT_TEST
            Enable this configuration option to enable the host side test driver
            for PCI Endpoint.
 
+config ARCX_ANYBUS_BRIDGE
+	tristate "Arcx Anybus-S Bridge"
+	depends on OF
+	help
+	  Select this to get support for the Arcx Anybus bridge.
+	  It connects to the SoC via a parallel memory bus, and
+	  embeds up to two Anybus-S application connectors (slots).
+	  There is also a CAN power readout, unrelated to the Anybus.
+
 config MISC_RTSX
 	tristate
 	default MISC_RTSX_PCI || MISC_RTSX_USB
drivers/misc/Makefile +1 -0
index af22bbc3d00c..20c9fbfb100b 100644
@@ -56,5 +56,6 @@ obj-$(CONFIG_CXL_BASE)		+= cxl/
 obj-$(CONFIG_ASPEED_LPC_CTRL)	+= aspeed-lpc-ctrl.o
 obj-$(CONFIG_ASPEED_LPC_SNOOP)	+= aspeed-lpc-snoop.o
 obj-$(CONFIG_PCI_ENDPOINT_TEST)	+= pci_endpoint_test.o
+obj-$(CONFIG_ARCX_ANYBUS_BRIDGE)	+= anybus-bridge.o
 obj-$(CONFIG_OCXL)		+= ocxl/
 obj-$(CONFIG_MISC_RTSX)		+= cardreader/
drivers/misc/anybus-bridge.c new file +301 -0

301 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH anybus v2 1/5] misc: support the Arcx anybus bridge.

Hi Sven,

Quoted 9 lines · On Wed, Oct 31, 2018 at 8:44 PM <[email protected]> wrote:

From: Sven Van Asbroeck <[email protected]>

Add a driver for the Arcx anybus bridge.

This chip embeds up to two Anybus-S application connectors (slots), and connects to the SoC via a parallel memory bus. There is also a CAN power readout, unrelated to the Anybus.

This is fun :)

Quoted 3 lines
 drivers/misc/Kconfig         |   9 ++
 drivers/misc/Makefile        |   1 +
 drivers/misc/anybus-bridge.c | 301 +++++++++++++++++++++++++++++++++++

I would put this also in drivers/bus, why not. Just two files there. It's a bus bridge for sure, we keep them there. drivers/reset if it is mostly about resetting stuff.

drivers/misc/Kconfig config PCI_ENDPOINT_TEST · line 514

Quoted 3 lines
drivers/misc/Kconfig +3 -0
+config ARCX_ANYBUS_BRIDGE
+       tristate "Arcx Anybus-S Bridge"
+       depends on OF

depends on GPIOLIB

Quoted 5 lines
drivers/misc/Kconfig +5 -0
+       help
+         Select this to get support for the Arcx Anybus bridge.
+         It connects to the SoC via a parallel memory bus, and
+         embeds up to two Anybus-S application connectors (slots).
+         There is also a CAN power readout, unrelated to the Anybus.

(...)

drivers/misc/anybus-bridge.c line 14

Quoted 2 lines
drivers/misc/anybus-bridge.c new file +2 -0
+#include <linux/gpio.h>
+#include <linux/of_gpio.h>

Don't use these please. Juse use
#include <linux/gpio/consumer.h>

drivers/misc/anybus-bridge.c line 38

Quoted 5 lines
drivers/misc/anybus-bridge.c new file +5 -0
+struct bridge_priv {
+       struct device *class_dev;
+       struct reset_controller_dev rcdev;
+       bool common_reset;
+       int reset_gpio;

struct gpio_desc *reset_gpiod;

Quoted 5 lines
drivers/misc/anybus-bridge.c new file +5 -0
+       void __iomem *cpld_base;
+       spinlock_t regs_lock;
+       u8 control_reg;
+       char version[3];
+       u16 design_no;

(...)

drivers/misc/anybus-bridge.c line 114

Quoted 8 lines
drivers/misc/anybus-bridge.c new file +8 -0
+static ssize_t version_show(struct device *dev,
+               struct device_attribute *attr, char *buf)
+{
+       struct bridge_priv *cd = dev_get_drvdata(dev);
+
+       return sprintf(buf, "%s\n", cd->version);
+}
+static DEVICE_ATTR_RO(version);

Do you need this in userspace really?

drivers/misc/anybus-bridge.c line 123

Quoted 8 lines
drivers/misc/anybus-bridge.c new file +8 -0
+static ssize_t design_number_show(struct device *dev,
+               struct device_attribute *attr, char *buf)
+{
+       struct bridge_priv *cd = dev_get_drvdata(dev);
+
+       return sprintf(buf, "%d\n", cd->design_no);
+}
+static DEVICE_ATTR_RO(design_number);

And this?

drivers/misc/anybus-bridge.c line 134

Quoted 10 lines
drivers/misc/anybus-bridge.c new file +10 -0
+static ssize_t can_power_show(struct device *dev,
+               struct device_attribute *attr, char *buf)
+{
+       struct bridge_priv *cd = dev_get_drvdata(dev);
+
+       return sprintf(buf, "%d\n",
+               !(readb(cd->cpld_base + CPLD_STATUS1) &
+                                       CPLD_STATUS1_CAN_POWER));
+}
+static DEVICE_ATTR_RO(can_power);

This should certainly be reflected as a fixed-voltage regulator and not a random integer in sysfs.

Quoted 4 lines
drivers/misc/anybus-bridge.c new file +4 -0
+static int bridge_probe(struct platform_device *pdev)
+{
+       struct bridge_priv *cd;
+       struct device *dev = &pdev->dev;

drivers/misc/anybus-bridge.c line 173

Quoted 10 lines
drivers/misc/anybus-bridge.c new file +10 -0
+       struct device_node *np = dev->of_node;
+       int err, id;
+       struct resource *res;
+       u8 status1, cap;
+
+       cd = devm_kzalloc(dev, sizeof(*cd), GFP_KERNEL);
+       if (!cd)
+               return -ENOMEM;
+       dev_set_drvdata(dev, cd);
+       spin_lock_init(&cd->regs_lock);

This:

drivers/misc/anybus-bridge.c line 180

Quoted 7 lines
drivers/misc/anybus-bridge.c new file +7 -0
+       cd->reset_gpio = of_get_named_gpio(np, "reset-gpios", 0);
+       if (!gpio_is_valid(cd->reset_gpio)) {
+               dev_err(dev, "reset-gpios not found\n");
+               return -EINVAL;
+       }
+       devm_gpio_request(dev, cd->reset_gpio, NULL);
+       gpio_direction_output(cd->reset_gpio, 0);

Should be:

cd->reset_gpiod = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); if (IS_ERR(cd->reset_gpiod))

    return PTR_ERR(cd->reset_gpiod);

You can turn it to input as you do in the .remove() function to let a pull-up resistor pull it high, but isn't it better to actively just drive it high?

Yours,
Linus Walleij

#3 lore raw

Re: [PATCH anybus v2 1/5] misc: support the Arcx anybus bridge.

Hi Linus,

Quoted 1 line

This is fun :)

It sure is ! It's fascinating to see how the kernel abstractions are designed, and how code is reviewed here.

Quoted 7 lines
Quoted 1 line

+static DEVICE_ATTR_RO(version);

Do you need this in userspace really?

Quoted 1 line

+static DEVICE_ATTR_RO(design_number);

And this?

Unfortunately, I do :(
The application software reads these out and displays them in an UI. It's important to be able to see these on a running device. Perhaps there is another kernel abstraction I could use?

Quoted 10 lines

This:

drivers/misc/anybus-bridge.c line 180

Quoted 8 lines
drivers/misc/anybus-bridge.c new file +7 -0
+       cd->reset_gpio = of_get_named_gpio(np, "reset-gpios", 0);
+       if (!gpio_is_valid(cd->reset_gpio)) {
+               dev_err(dev, "reset-gpios not found\n");
+               return -EINVAL;
+       }
+       devm_gpio_request(dev, cd->reset_gpio, NULL);
+       gpio_direction_output(cd->reset_gpio, 0);
Quoted 5 lines

Should be:

cd->reset_gpiod = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); if (IS_ERR(cd->reset_gpiod))

    return PTR_ERR(cd->reset_gpiod);

That's actually pretty neat !
Now we have nothing that explicitly refers to the devicetree (except the device binding, of course). I now see the point you made earlier:
resets, gpios, interrupts etc are associated with "struct device" and not necessarily with the devicetree.

The rest of your suggestions have already gone in.

I hope you'll have some time later to look at the architecture description in the bus driver. Looking forward to your feedback and to the next iteration !

Cheers,
Sven

#4 lore raw

Re: [PATCH anybus v2 1/5] misc: support the Arcx anybus bridge.

Quoted 11 lines · Sven Van Asbroeck
Quoted 7 lines
Quoted 1 line

+static DEVICE_ATTR_RO(version);

Do you need this in userspace really?

Quoted 1 line

+static DEVICE_ATTR_RO(design_number);

And this?

Unfortunately, I do :(
The application software reads these out and displays them in an UI. It's important to be able to see these on a running device.

OK...

Quoted 1 line

Perhaps there is another kernel abstraction I could use?

I don't think so. If you want to be pedantic, document the sysfs files in Documentation/ABI/testing/sysfs-*

Maybe the properties should be on the bus though? I don't know :/

Yours,
Linus Walleij

#5 lore raw

Re: [PATCH anybus v2 1/5] misc: support the Arcx anybus bridge.

Quoted 5 lines · Linus Walleij
Quoted 1 line · Sven Van Asbroeck

Perhaps there is another kernel abstraction I could use?

Maybe the properties should be on the bus though? I don't know :/

Let's keep the version associated with the bridge. After all, the bus has its own version associated with it. And the app developers have separate data structures for the bridge and the bus.

Cheers,
Sven

#6 lore raw

PATCH v2 2/5 dt-bindings: anybus-bridge: document devicetree binding.

In reply to [email protected]

From: Sven Van Asbroeck <[email protected]>

This patch adds devicetree binding documentation for the Arcx anybus bridge.

---
 .../bindings/misc/arcx,anybus-bridge.txt      | 34 +++++++++++++++++++
 .../devicetree/bindings/vendor-prefixes.txt   |  1 +
 2 files changed, 35 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/misc/arcx,anybus-bridge.txt
Documentation/devicetree/bindings/misc/arcx,anybus-bridge.txt new file +34 -0
new file mode 100644
index 000000000000..cb801b7568b0
@@ -0,0 +1,34 @@
+* Arcx anybus bridge
+
+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-bridge"
+
+  - reg : bus memory area where the cpld registers are located.
+
+  - reset-gpios : the GPIO pin connected to the reset line of the bridge.
+
+  - #reset-cells : Must be 1.
+	this bridge is a reset provider to its two embedded Anybus-S slots.
+
+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 {
+	anybus_bridge: bridge@0,0 {
+		compatible = "arcx,anybus-bridge";
+		reg = <0 0 0x100>;
+		reset-gpios = <&gpio5 2 GPIO_ACTIVE_HIGH>;
+		#reset-cells = <1>;
+		/* fsl,weim-cs-timing is a i.MX WEIM bus specific property */
+		fsl,weim-cs-timing = <0x024400b1 0x00001010 0x20081100
+				0x00000000 0xa0000240 0x00000000>;
+	};
+};
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
index 2c3fc512e746..1bf07b20a8af 100644
@@ -35,6 +35,7 @@ aptina	Aptina Imaging
 arasan	Arasan Chip Systems
 archermind ArcherMind Technology (Nanjing) Co., Ltd.
 arctic	Arctic Sand
+arcx	Arcx/Archronix Inc.
 aries	Aries Embedded GmbH
 arm	ARM Ltd.
 armadeus	ARMadeus Systems SARL
Signature · 1 line
2.17.1
#7 lore raw

Re: [PATCH anybus v2 2/5] dt-bindings: anybus-bridge: document devicetree binding.

Hi Sven,

Am 31.10.18 um 20:44 schrieb [email protected]:

Quoted 11 lines

From: Sven Van Asbroeck <[email protected]>

This patch adds devicetree binding documentation for the Arcx anybus bridge.

---
 .../bindings/misc/arcx,anybus-bridge.txt      | 34 +++++++++++++++++++
 .../devicetree/bindings/vendor-prefixes.txt   |  1 +
 2 files changed, 35 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/misc/arcx,anybus-bridge.txt

[...]

Documentation/devicetree/bindings/vendor-prefixes.txt aptina Aptina Imaging · line 41

Quoted 12 lines
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
index 2c3fc512e746..1bf07b20a8af 100644
@@ -35,6 +35,7 @@ aptina	Aptina Imaging
 arasan	Arasan Chip Systems
 archermind ArcherMind Technology (Nanjing) Co., Ltd.
 arctic	Arctic Sand
+arcx	Arcx/Archronix Inc.
 aries	Aries Embedded GmbH
 arm	ARM Ltd.
 armadeus	ARMadeus Systems SARL

Please move this to a separate patch, titled "dt-bindings: Add vendor prefix for Arcx", with the commit message describing what the company does. Also note that subject lines usually do not end with a full stop, similar to book titles or news headlines.
And it is usually preferable to have such a long list of people in CC rather than in To, to make it clear whom you expect to handle it and to facilitate replies going to you without hand-editing every other To.

I notice that arcx.com spells it ARCX Inc., in upper-case without any mention of Archronix in the name. So if that's a previous name you may want to write it as "ARCX Inc. (formerly Archronix Inc.)"? Look for other examples in that file.

Regards,
Andreas

Signature · 3 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
#8 lore raw

PATCH v2 3/5 bus: support HMS Anybus-S bus.

In reply to [email protected]

From: Sven Van Asbroeck <[email protected]>

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

---
 drivers/bus/Kconfig            |   10 +
 drivers/bus/Makefile           |    1 +
 drivers/bus/anybuss-host.c     | 1498 ++++++++++++++++++++++++++++++++
 include/linux/anybuss-client.h |  100 +++
 4 files changed, 1609 insertions(+)
 create mode 100644 drivers/bus/anybuss-host.c
 create mode 100644 include/linux/anybuss-client.h
drivers/bus/Kconfig +10 -0
index 1851112ccc29..196c603f516e 100644
@@ -45,6 +45,16 @@ config IMX_WEIM
 	  The WEIM(Wireless External Interface Module) works like a bus.
 	  You can attach many different devices on it, such as NOR, onenand.
 
+config HMS_ANYBUSS_HOST
+	tristate "HMS Anybus-S Host/Bus Driver"
+	select REGMAP
+	depends on OF
+	help
+	  Driver for the HMS Industrial Networks Anybus-S bus.
+	  You can attach Anybus-S compatible cards to it, which
+	  typically provide fieldbus and industrial ethernet
+	  functionality.
+
 config MIPS_CDMM
 	bool "MIPS Common Device Memory Map (CDMM) Driver"
 	depends on CPU_MIPSR2
drivers/bus/Makefile +1 -0
index ca300b1914ce..f67c6468126b 100644
@@ -13,6 +13,7 @@ obj-$(CONFIG_BRCMSTB_GISB_ARB)	+= brcmstb_gisb.o
 obj-$(CONFIG_FSL_MC_BUS)	+= fsl-mc/
 
 obj-$(CONFIG_IMX_WEIM)		+= imx-weim.o
+obj-$(CONFIG_HMS_ANYBUSS_HOST)	+= anybuss-host.o
 obj-$(CONFIG_MIPS_CDMM)		+= mips_cdmm.o
 obj-$(CONFIG_MVEBU_MBUS) 	+= mvebu-mbus.o
 
drivers/bus/anybuss-host.c new file +1498 -0

1,498 lines not on this page · raw message

include/linux/anybuss-client.h new file +100 -0

100 lines not on this page · raw message

Signature · 1 line
2.17.1
#9 lore raw

Re: [PATCH anybus v2 3/5] bus: support HMS Anybus-S bus.

Thank you for the patch! Yet something to improve:

Hi Sven,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on v4.20-rc2 next-20181114]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/thesven73-gmail-com/Support-HMS-Profinet-Card-over-Anybus/20181101-225600
config: um-allyesconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0 reproduce:

        # save the attached .config to linux build tree
        make ARCH=um 

All errors (new ones prefixed by >>):

arch/um/drivers/vde.o: In function `vde_open_real':
(.text+0x951): warning: Using 'getgrnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking (.text+0x79c): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking arch/um/drivers/vector_user.o: In function `user_init_socket_fds':
vector_user.c:(.text+0x334): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking arch/um/drivers/pcap.o: In function `pcap_nametoaddr':
(.text+0xdee5): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking arch/um/drivers/pcap.o: In function `pcap_nametonetaddr':
(.text+0xdf85): warning: Using 'getnetbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking arch/um/drivers/pcap.o: In function `pcap_nametoproto':
(.text+0xe1a5): warning: Using 'getprotobyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking arch/um/drivers/pcap.o: In function `pcap_nametoport':
(.text+0xdfd7): warning: Using 'getservbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking drivers/bus/anybuss-host.o: In function `create_parallel_regmap':

>> anybuss-host.c:(.text+0x1afd): undefined reference to `devm_ioremap_resource'

collect2: error: ld returned 1 exit status

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#10 lore raw

PATCH v2 4/5 dt-bindings: anybuss-host: document devicetree binding.

In reply to [email protected]

From: Sven Van Asbroeck <[email protected]>

This patch adds devicetree binding documentation for the Arcx Anybus-S host.

---
 .../bindings/bus/arcx,anybuss-host.txt        | 36 +++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/bus/arcx,anybuss-host.txt
Documentation/devicetree/bindings/bus/arcx,anybuss-host.txt new file +36 -0
new file mode 100644
index 000000000000..5c28e4e09bb2
@@ -0,0 +1,36 @@
+* Arcx Anybus-S host
+
+This host 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 string:
+        "arcx,anybuss-host"
+
+  - reg : bus memory area where the Anybus-S host dpram is located.
+
+  - interrupts : interrupt connected to the Anybus-S host interrupt line.
+	Generic interrupt client node bindings are described in
+		interrupt-controller/interrupts.txt
+
+  - resets : the reset line associated with the Anybus-S host.
+
+Example of usage:
+
+This example places the Anybus-S host on top of the i.MX WEIM parallel bus, see:
+Documentation/devicetree/bindings/bus/imx-weim.txt
+
+&weim {
+	anybus-host@0 {
+		compatible = "arcx,anybuss-host";
+		reg = <0 0x400000 0x800>;
+		interrupt-parent = <&gpio1>;
+		interrupts = <1 IRQ_TYPE_LEVEL_LOW>;
+		resets = <&anybus_bridge 0>;
+		/* fsl,weim-cs-timing is a i.MX WEIM bus specific property */
+		fsl,weim-cs-timing = <0x024400b1 0x00001010 0x20081100
+				0x00000000 0xa0000240 0x00000000>;
+	};
+};
Signature · 1 line
2.17.1
#11 lore raw

PATCH v2 5/5 misc: support HMS Profinet IRT industrial controller.

In reply to [email protected]

From: Sven Van Asbroeck <[email protected]>

The 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 creates a /dev/profinet%d devnode, and a /sys/class/misc/profinet%d sysfs subdir:
- the card can be configured with a single, atomic ioctl on the devnode;
- the card's internal dpram is accessed by calling read/write/seek on the devnode.
- the card's "fieldbus specific area" properties can be accessed via the sysfs dir.

---
 Documentation/ioctl/ioctl-number.txt |   1 +
 drivers/misc/Kconfig                 |  10 +
 drivers/misc/Makefile                |   1 +
 drivers/misc/hms-profinet.c          | 753 +++++++++++++++++++++++++++
 include/uapi/linux/hms-common.h      |  14 +
 include/uapi/linux/hms-profinet.h    | 102 ++++
 6 files changed, 881 insertions(+)
 create mode 100644 drivers/misc/hms-profinet.c
 create mode 100644 include/uapi/linux/hms-common.h
 create mode 100644 include/uapi/linux/hms-profinet.h
Documentation/ioctl/ioctl-number.txt +1 -0
index 13a7c999c04a..a389a4ec1429 100644
@@ -241,6 +241,7 @@ Code  Seq#(hex)	Include File		Comments
 					<http://web.archive.org/web/*/http://mikonos.dia.unisa.it/tcfs>
 'l'	40-7F	linux/udf_fs_i.h	in development:
 					<http://sourceforge.net/projects/linux-udf/>
+'l'	80-9F	linux/hms-profinet.h	Anybus-S
 'm'	00-09	linux/mmtimer.h		conflict!
 'm'	all	linux/mtio.h		conflict!
 'm'	all	linux/soundcard.h	conflict!
drivers/misc/Kconfig +10 -0
index dd7fdbf659b7..d17b581c06f7 100644
@@ -406,6 +406,16 @@ config SPEAR13XX_PCIE_GADGET
 	 entry will be created for that controller. User can use these
 	 sysfs node to configure PCIe EP as per his requirements.
 
+config HMS_PROFINET
+	tristate "HMS Profinet IRT Controller (Anybus-S)"
+	select HMS_ANYBUSS_HOST
+	help
+	 If you say yes here you get support for the HMS Industrial
+	 Networks Profinet IRT Controller.
+	 This driver can also be built as a module. If so, the module
+	 will be called hms-profinet.
+	 If unsure, say N.
+
 config VMWARE_BALLOON
 	tristate "VMware Balloon Driver"
 	depends on VMWARE_VMCI && X86 && HYPERVISOR_GUEST
drivers/misc/Makefile +1 -0
index 20c9fbfb100b..087c48273179 100644
@@ -34,6 +34,7 @@ obj-$(CONFIG_SENSORS_TSL2550)	+= tsl2550.o
 obj-$(CONFIG_DS1682)		+= ds1682.o
 obj-$(CONFIG_C2PORT)		+= c2port/
 obj-$(CONFIG_HMC6352)		+= hmc6352.o
+obj-$(CONFIG_HMS_PROFINET)	+= hms-profinet.o
 obj-y				+= eeprom/
 obj-y				+= cb710/
 obj-$(CONFIG_SPEAR13XX_PCIE_GADGET)	+= spear13xx_pcie_gadget.o
drivers/misc/hms-profinet.c new file +753 -0

753 lines not on this page · raw message

include/uapi/linux/hms-common.h new file +14 -0
new file mode 100644
index 000000000000..4b69963a3863
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright 2018 Archronix Corp. All Rights Reserved.
+ *
+ */
+
+#ifndef _UAPILINUX_HMSCOMMON_H_
+#define _UAPILINUX_HMSCOMMON_H_
+
+#define HMS_SMA_CLEAR		0
+#define HMS_SMA_FREEZE		1
+#define HMS_SMA_SET		2
+
+#endif /* _UAPILINUX_HMSCOMMON_H_ */
include/uapi/linux/hms-profinet.h new file +102 -0

102 lines not on this page · raw message

Signature · 1 line
2.17.1
#12 lore raw

Re: [PATCH anybus v2 5/5] misc: support HMS Profinet IRT industrial controller.

Thank you for the patch! Perhaps something to improve:

Hi Sven,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on char-misc/char-misc-testing]
[also build test WARNING on v4.19 next-20181101]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/thesven73-gmail-com/Support-HMS-Profinet-Card-over-Anybus/20181101-225600
config: i386-tinyconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0 reproduce:

        # save the attached .config to linux build tree
        make ARCH=i386 

All warnings (new ones prefixed by >>):

>> ./usr/include/linux/hms-profinet.h:10: include of <linux/types.h> is preferred over <asm/types.h>
>> ./usr/include/linux/hms-profinet.h:18: found __[us]{8,16,32,64} type without #include <linux/types.h>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation