Skip to contentSkip to conversation

XRA1403,gpio - add XRA1403 gpio expander driver

PATCH In review Nandor Han 3 participants 13 messages Mar 27, 2017 – Apr 8, 2017

Subsystems (2)
lore
Share & tools
lore

Nandor Han

author
#0 lore raw

cover XRA1403,gpio - add XRA1403 gpio expander driver

The patchset will add a driver to support basic functionality for XRA1403 device. Features supported:
- configure gpin as input/out
- get/set gpio status

Documentation: A gpio-xra1403.txt file was added to document the DTS
bindings related to driver.

Testing:

1. XRA1403 connected to iMX53 MCU
2. Export gpio from userspace
3. Verify that corresponding gpio directories are created in /sys/class/gpio/gpioXX
4. Export gpios from first and second bank as output
5. Set the output gpio pin to high/low and verify with the oscilloscope that gpio status is according with the configured value.

Nandor Han (3):
gpio - Add EXAR XRA1403 SPI GPIO expander driver doc,dts - add XRA1403 DTS binding documentation Add XRA1403 support to MAINTAINERS file

 .../devicetree/bindings/gpio/gpio-xra1403.txt      |  37 +++
 .../devicetree/bindings/vendor-prefixes.txt        |   1 +
 MAINTAINERS                                        |   8 +
 drivers/gpio/Kconfig                               |   5 +
 drivers/gpio/Makefile                              |   1 +
 drivers/gpio/gpio-xra1403.c                        | 252 +++++++++++++++++++++
 6 files changed, 304 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/gpio-xra1403.txt
 create mode 100644 drivers/gpio/gpio-xra1403.c
Signature · 1 line
2.10.1
author
#1 lore raw

PATCH 1/3 gpio - Add EXAR XRA1403 SPI GPIO expander driver

This is a simple driver that provides a /sys/class/gpio interface for controlling and configuring the GPIO lines. It does not provide support for chip select or interrupts.

---
 .../devicetree/bindings/vendor-prefixes.txt        |   1 +
 drivers/gpio/Kconfig                               |   5 +
 drivers/gpio/Makefile                              |   1 +
 drivers/gpio/gpio-xra1403.c                        | 252 +++++++++++++++++++++
 4 files changed, 259 insertions(+)
 create mode 100644 drivers/gpio/gpio-xra1403.c
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
index 0ad67d5..7ca9d41 100644
@@ -103,6 +103,7 @@ ettus	NI Ettus Research
 eukrea  Eukréa Electromatique
 everest	Everest Semiconductor Co. Ltd.
 everspin	Everspin Technologies, Inc.
+exar	Exar Corporation
 excito	Excito
 ezchip	EZchip Semiconductor
 faraday	Faraday Technology Corporation
drivers/gpio/Kconfig +5 -0
index d6e3cfd..3a6c9a3 100644
@@ -1208,6 +1208,11 @@ config GPIO_PISOSR
 	  GPIO driver for SPI compatible parallel-in/serial-out shift
 	  registers. These are input only devices.
 
+config GPIO_XRA1403
+	tristate "EXAR XRA1403 16-bit GPIO expander"
+	help
+	  GPIO driver for EXAR XRA1403 16-bit SPI-based GPIO expander.
+
 endmenu
 
 menu "SPI or I2C GPIO expanders"
drivers/gpio/Makefile +1 -0
index bd995dc..8f50844 100644
@@ -139,6 +139,7 @@ obj-$(CONFIG_GPIO_XGENE)	+= gpio-xgene.o
 obj-$(CONFIG_GPIO_XGENE_SB)	+= gpio-xgene-sb.o
 obj-$(CONFIG_GPIO_XILINX)	+= gpio-xilinx.o
 obj-$(CONFIG_GPIO_XLP)		+= gpio-xlp.o
+obj-$(CONFIG_GPIO_XRA1403)	+= gpio-xra1403.o
 obj-$(CONFIG_GPIO_XTENSA)	+= gpio-xtensa.o
 obj-$(CONFIG_GPIO_ZEVIO)	+= gpio-zevio.o
 obj-$(CONFIG_GPIO_ZYNQ)		+= gpio-zynq.o
drivers/gpio/gpio-xra1403.c new file +252 -0

252 lines not on this page · raw message

Signature · 6 lines
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw

Re: [PATCH 1/3] gpio - Add EXAR XRA1403 SPI GPIO expander driver

Quoted 2 lines · Nandor Han

This is a simple driver that provides a /sys/class/gpio interface for controlling and configuring the GPIO lines.

Use the gpio tools in tools/gpio, use the characcter device. Do not use sysfs. Change this to reference the tools.

Quoted 4 lines

It does not provide support for chip select or interrupts.

(...)

Quoted 1 line

+exar Exar Corporation

Send this as a separate patch to the DT bindings maintainer (Rob Herring.)

Quoted 6 lines
drivers/gpio/gpio-xra1403.c new file +6 -0
+static int xra1403_get_byte(struct xra1403 *xra, unsigned int addr)
+{
+       return spi_w8r8(xra->spi, XRA_READ | (addr << 1));
+}
+
+static int xra1403_get_bit(struct xra1403 *xra, unsigned int addr,

drivers/gpio/gpio-xra1403.c line 57

Quoted 10 lines
drivers/gpio/gpio-xra1403.c new file +10 -0
+                          unsigned int bit)
+{
+       int ret;
+
+       ret = xra1403_get_byte(xra, addr + (bit > 7));
+       if (ret < 0)
+               return ret;
+
+       return !!(ret & BIT(bit % 8));
+}

This looks like it can use regmap-spi right off, do you agree?

git grep devm_regmap_init_spi
should give you some examples of how to use it.

If it's not off-the shelf regmap drivers like drivers/iio/pressure/mpl115_spi.c
give examples of how to make more elaborate custom SPI transfers with regmap.

Quoted 24 lines
drivers/gpio/gpio-xra1403.c new file +24 -0
+static int xra1403_set_bit(struct xra1403 *xra, unsigned int addr,
+                          unsigned int bit, int value)
+{
+       int ret;
+       u8 mask;
+       u8 tx[2];
+
+       addr += bit > 7;
+
+       mutex_lock(&xra->lock);
+
+       ret = xra1403_get_byte(xra, addr);
+       if (ret < 0)
+               goto out_unlock;
+
+       mask = BIT(bit % 8);
+       if (value)
+               value = ret | mask;
+       else
+               value = ret & ~mask;
+
+       if (value != ret) {
+               tx[0] = addr << 1;
+               tx[1] = value;

drivers/gpio/gpio-xra1403.c line 92

Quoted 10 lines
drivers/gpio/gpio-xra1403.c new file +10 -0
+               ret = spi_write(xra->spi, tx, sizeof(tx));
+       } else {
+               ret = 0;
+       }
+
+out_unlock:
+       mutex_unlock(&xra->lock);
+
+       return ret;
+}

Classical mask-and-set implementation right?
With regmap this becomes simply regmap_update_bits(map, addr, mask, set)

Quoted 5 lines
drivers/gpio/gpio-xra1403.c new file +5 -0
+static int xra1403_probe(struct spi_device *spi)
+{
+       struct xra1403 *xra;
+       struct gpio_desc *reset_gpio;
+

drivers/gpio/gpio-xra1403.c line 177

Quoted 10 lines
drivers/gpio/gpio-xra1403.c new file +10 -0
+       xra = devm_kzalloc(&spi->dev, sizeof(*xra), GFP_KERNEL);
+       if (!xra)
+               return -ENOMEM;
+
+       /* bring the chip out of reset */
+       reset_gpio = gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT_LOW);
+       if (IS_ERR(reset_gpio))
+               dev_warn(&spi->dev, "could not get reset-gpios\n");
+       else if (reset_gpio)
+               gpiod_put(reset_gpio);

I don't think you should put it, other than in the remove() function and in that case you need to have it in the state container.

drivers/gpio/gpio-xra1403.c line 182

Quoted 4 lines
drivers/gpio/gpio-xra1403.c new file +4 -0
+       mutex_init(&xra->lock);
+
+       xra->chip.direction_input = xra1403_direction_input;
+       xra->chip.direction_output = xra1403_direction_output;

Please implement .get_direction(). This is very nice to have.

drivers/gpio/gpio-xra1403.c line 205

Quoted 5 lines
drivers/gpio/gpio-xra1403.c new file +5 -0
+static int xra1403_remove(struct spi_device *spi)
+{
+       struct xra1403 *xra = spi_get_drvdata(spi);
+
+       gpiochip_remove(&xra->chip);

Use devm_gpiochip_add_data() and this remove is not needed at all.

Quoted 6 lines
drivers/gpio/gpio-xra1403.c new file +6 -0
+static int __init xra1403_init(void)
+{
+       return spi_register_driver(&xra1403_driver);
+}
+
+/*

drivers/gpio/gpio-xra1403.c line 247

Quoted 10 lines
drivers/gpio/gpio-xra1403.c new file +10 -0
+ * register after spi postcore initcall and before
+ * subsys initcalls that may rely on these GPIOs
+ */
+subsys_initcall(xra1403_init);
+
+static void __exit xra1403_exit(void)
+{
+       spi_unregister_driver(&xra1403_driver);
+}
+module_exit(xra1403_exit);

This seems like tricksy. Just module_spi_driver()
should be fine don't you think?

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw

PATCH 1/3 gpio - Add EXAR XRA1403 SPI GPIO expander driver

Quoted 21 lines

-----Original Message-----
From: Linus Walleij [mailto:[email protected]]
Sent: 29 March 2017 05:07
To: Han, Nandor (GE Healthcare) <[email protected]>
Cc: Alexandre Courbot <[email protected]>; Rob Herring <[email protected]>; Mark Rutland <[email protected]>; [email protected]; [email protected]; [email protected]; Malinen, Semi (GE Healthcare) <[email protected]>
Subject: EXT: Re: [PATCH 1/3] gpio - Add EXAR XRA1403 SPI GPIO expander driver

Quoted 2 lines · Nandor Han

This is a simple driver that provides a /sys/class/gpio interface for controlling and configuring the GPIO lines.

Use the gpio tools in tools/gpio, use the characcter device. Do not use sysfs. Change this to reference the tools.

Quoted 2 lines

It does not provide support for chip select or interrupts.

Quoted 8 lines
Quoted 2 lines

(...)

Quoted 1 line

+exar Exar Corporation

Send this as a separate patch to the DT bindings maintainer (Rob Herring.)

OK. I will create a separate patch with this one.
I guess is not an issue to send all the patches to Rob as well.

<snip>

Quoted 10 lines

drivers/gpio/gpio-xra1403.c line 57

Quoted 7 lines
drivers/gpio/gpio-xra1403.c new file +7 -0
+
+       ret = xra1403_get_byte(xra, addr + (bit > 7));
+       if (ret < 0)
+               return ret;
+
+       return !!(ret & BIT(bit % 8));
+}

This looks like it can use regmap-spi right off, do you agree?

Yes. Using regmap-spi will definitely improve the code readability and reduce boilerplate. Done.

Quoted 8 lines

git grep devm_regmap_init_spi
should give you some examples of how to use it.

If it's not off-the shelf regmap drivers like drivers/iio/pressure/mpl115_spi.c
give examples of how to make more elaborate custom SPI transfers with regmap.

Thanks, I did check other drivers as examples.
Not that I needed for this driver, but ...mpl115_spi.c doesn't seem to use regmap (checked on next-20170327)

<snip>

Quoted 9 lines
Quoted 9 lines
drivers/gpio/gpio-xra1403.c new file +9 -0
+
+       if (value != ret) {
+               tx[0] = addr << 1;
+               tx[1] = value;
+               ret = spi_write(xra->spi, tx, sizeof(tx));
+       } else {
+               ret = 0;
+       }
+
Quoted 9 lines

drivers/gpio/gpio-xra1403.c line 92

Quoted 5 lines
drivers/gpio/gpio-xra1403.c new file +5 -0
+out_unlock:
+       mutex_unlock(&xra->lock);
+
+       return ret;
+}

Classical mask-and-set implementation right?
With regmap this becomes simply regmap_update_bits(map, addr, mask, set)

True. :)

<snip>

Quoted 10 lines

drivers/gpio/gpio-xra1403.c line 177

Quoted 6 lines
drivers/gpio/gpio-xra1403.c new file +6 -0
+       /* bring the chip out of reset */
+       reset_gpio = gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT_LOW);
+       if (IS_ERR(reset_gpio))
+               dev_warn(&spi->dev, "could not get reset-gpios\n");
+       else if (reset_gpio)
+               gpiod_put(reset_gpio);

I don't think you should put it, other than in the remove() function and in that case you need to have it in the state container.

Can you please be more explicit here.

Currently I'm trying to bring the device out from reset in case reset GPIO is provided. I don't see how this could be done in remove() :)

Quoted 8 lines

drivers/gpio/gpio-xra1403.c line 182

Quoted 5 lines
drivers/gpio/gpio-xra1403.c new file +4 -0
+       mutex_init(&xra->lock);
+
+       xra->chip.direction_input = xra1403_direction_input;
+       xra->chip.direction_output = xra1403_direction_output;

Please implement .get_direction(). This is very nice to have.

Done

Quoted 9 lines

drivers/gpio/gpio-xra1403.c line 205

Quoted 5 lines
drivers/gpio/gpio-xra1403.c new file +5 -0
+static int xra1403_remove(struct spi_device *spi)
+{
+       struct xra1403 *xra = spi_get_drvdata(spi);
+
+       gpiochip_remove(&xra->chip);

Use devm_gpiochip_add_data() and this remove is not needed at all.

True. Done

<snip>

Quoted 10 lines

drivers/gpio/gpio-xra1403.c line 247

Quoted 7 lines
drivers/gpio/gpio-xra1403.c new file +7 -0
+subsys_initcall(xra1403_init);
+
+static void __exit xra1403_exit(void)
+{
+       spi_unregister_driver(&xra1403_driver);
+}
+module_exit(xra1403_exit);

This seems like tricksy. Just module_spi_driver() should be fine don't you think?

Yeah. TBH I don't have a strong reason why module_spi_driver init level shouldn't be enough. Done.

Regards,
Nandor

#4 lore raw

Re: [PATCH 1/3] gpio - Add EXAR XRA1403 SPI GPIO expander driver

Quoted 8 lines · Nandor (GE Healthcare)

[Me]

Quoted 7 lines
Quoted 6 lines
drivers/gpio/gpio-xra1403.c new file +6 -0
+       /* bring the chip out of reset */
+       reset_gpio = gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT_LOW);
+       if (IS_ERR(reset_gpio))
+               dev_warn(&spi->dev, "could not get reset-gpios\n");
+       else if (reset_gpio)
+               gpiod_put(reset_gpio);
Quoted 8 lines
Quoted 3 lines

I don't think you should put it, other than in the remove() function and in that case you need to have it in the state container.

Can you please be more explicit here.

Currently I'm trying to bring the device out from reset in case reset GPIO is provided. I don't see how this could be done in remove() :)

If you issue gpiod_put() you release the GPIO hande so something else can go in and grab the GPIO and assert the reset.

This is not what you want to make possible: you want to hold this gpiod handle as long as the driver is running. devm_gpiod_get_optional() will do the trick if you don't want to put the handle under explicit control.

Yours,
Linus Walleij

#5 lore raw

PATCH 1/3 gpio - Add EXAR XRA1403 SPI GPIO expander driver

DQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogTGludXMgV2FsbGVpaiBb bWFpbHRvOmxpbnVzLndhbGxlaWpAbGluYXJvLm9yZ10NCj4gU2VudDogMDcgQXByaWwgMjAxNyAx MzowNw0KPiBUbzogSGFuLCBOYW5kb3IgKEdFIEhlYWx0aGNhcmUpIDxuYW5kb3IuaGFuQGdlLmNv bT4NCj4gQ2M6IEFsZXhhbmRyZSBDb3VyYm90IDxnbnVyb3VAZ21haWwuY29tPjsgUm9iIEhlcnJp bmcgPHJvYmgrZHRAa2VybmVsLm9yZz47IE1hcmsgUnV0bGFuZA0KPiA8bWFyay5ydXRsYW5kQGFy bS5jb20+OyBsaW51eC1ncGlvQHZnZXIua2VybmVsLm9yZzsgZGV2aWNldHJlZUB2Z2VyLmtlcm5l bC5vcmc7IGxpbnV4LWtlcm5lbEB2Z2VyLmtlcm5lbC5vcmc7DQo+IE1hbGluZW4sIFNlbWkgKEdF IEhlYWx0aGNhcmUpIDxzZW1pLm1hbGluZW5AZ2UuY29tPg0KPiBTdWJqZWN0OiBFWFQ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aWRlZCB0byB0aGUgZHJp dmVyIHRoZSBkcml2ZXIgd2lsbCBvd24gaXQgYW5kIGJyaW5nIG91dCB0aGUgZGV2aWNlIGZyb20g cmVzZXQuIEluIGNhc2Ugbm90DQpwcm92aWRlZCB0aGUgcmVzZXQgbGluZSBpcyBzb21lYm9keSBl bHNlIHJlc3BvbnNpYmlsaXR5LiANCg0KVGhpcyB3YXkgd2UgYXJlIGFibGUgdG8gY292ZXIgbXVs dGlwbGUgdXNlLWNhc2VzLiANCg0KVGhhbmtzIExpbnVzLA0KTmFuZHkNCg0KPiBZb3VycywNCj4g TGludXMgV2FsbGVpag0K
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#6 lore raw

Re: [PATCH 1/3] gpio - Add EXAR XRA1403 SPI GPIO expander driver

In reply to Nandor Han
Quoted 8 lines · Nandor Han

This is a simple driver that provides a /sys/class/gpio interface for controlling and configuring the GPIO lines. It does not provide support for chip select or interrupts.

---
 .../devicetree/bindings/vendor-prefixes.txt        |   1 +

This should go with the binding patch or by itself.

Quoted 5 lines
 drivers/gpio/Kconfig                               |   5 +
 drivers/gpio/Makefile                              |   1 +
 drivers/gpio/gpio-xra1403.c                        | 252 +++++++++++++++++++++
 4 files changed, 259 insertions(+)
 create mode 100644 drivers/gpio/gpio-xra1403.c
author
#7 lore raw

PATCH 2/3 doc,dts - add XRA1403 DTS binding documentation

In reply to Nandor Han

Add the XRA1403 DTS binding documentation.

---
 .../devicetree/bindings/gpio/gpio-xra1403.txt      | 37 ++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/gpio-xra1403.txt
Documentation/devicetree/bindings/gpio/gpio-xra1403.txt new file +37 -0
new file mode 100644
index 0000000..ccf5337
@@ -0,0 +1,37 @@
+GPIO Driver for XRA1403 16-BIT GPIO Expander With Reset Input from EXAR
+
+The XRA1403 is an 16-bit GPIO expander with an SPI interface. Features available:
+	- Individually programmable inputs:
+		- Internal pull-up resistors
+		- Polarity inversion
+		- Individual interrupt enable
+		- Rising edge and/or Falling edge interrupt
+		- Input filter
+	- Individually programmable outputs
+		- Output Level Control
+		- Output Three-State Control
+
+Properties
+----------
+Check documentation for SPI and GPIO controllers regarding properties needed to configure the node.
+
+	- compatible = "exar,xra1403".
+	- reg = SPI id of the device.
+	- gpio-controller: mark the node as gpio.
+
+Optional properties:
+-------------------
+	- reset-gpios: in case available used to control the device reset line.
+
+Example
+--------
+
+	gpioxra0: gpio@2 {
+		compatible = "exar,xra1403";
+		reg = <2>;
+		gpio-controller;
+		#gpio-cells = <2>;
+		reset-gpios = <&gpio3 6 GPIO_ACTIVE_LOW>;
+		spi-max-frequency = <1000000>;
+		status = "okay";
+	};
Signature · 1 line
2.10.1
#8 lore raw

Re: [PATCH 2/3] doc,dts - add XRA1403 DTS binding documentation

Quoted 3 lines · Nandor Han

Add the XRA1403 DTS binding documentation.

There is no big problem with this but:

Documentation/devicetree/bindings/gpio/gpio-xra1403.txt line 9

Quoted 7 lines
Documentation/devicetree/bindings/gpio/gpio-xra1403.txt new file +7 -0
+The XRA1403 is an 16-bit GPIO expander with an SPI interface. Features available:
+       - Individually programmable inputs:
+               - Internal pull-up resistors
+               - Polarity inversion
+               - Individual interrupt enable
+               - Rising edge and/or Falling edge interrupt
+               - Input filter

Since you mention that it has interrupts maybe you want to add bindings for the cascaded interrupt and the interrupt-controller; keyword etc already now.

We just document what the hardware can do, we don't have to do all of it in the first Linux driver submission.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#9 lore raw

Re: [PATCH 2/3] doc,dts - add XRA1403 DTS binding documentation

In reply to Nandor Han
Quoted 1 line · Nandor Han

Add the XRA1403 DTS binding documentation.

"dt-bindings: gpio: ..." for the subject prefix please.

Quoted 23 lines
---
 .../devicetree/bindings/gpio/gpio-xra1403.txt      | 37 ++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/gpio-xra1403.txt
Documentation/devicetree/bindings/gpio/gpio-xra1403.txt new file +10 -0
new file mode 100644
index 0000000..ccf5337
@@ -0,0 +1,37 @@
+GPIO Driver for XRA1403 16-BIT GPIO Expander With Reset Input from EXAR
+
+The XRA1403 is an 16-bit GPIO expander with an SPI interface. Features available:
+	- Individually programmable inputs:
+		- Internal pull-up resistors
+		- Polarity inversion
+		- Individual interrupt enable
+		- Rising edge and/or Falling edge interrupt
+		- Input filter
+	- Individually programmable outputs

Documentation/devicetree/bindings/gpio/gpio-xra1403.txt line 20

Quoted 10 lines
Documentation/devicetree/bindings/gpio/gpio-xra1403.txt new file +10 -0
+		- Output Level Control
+		- Output Three-State Control
+
+Properties
+----------
+Check documentation for SPI and GPIO controllers regarding properties needed to configure the node.
+
+	- compatible = "exar,xra1403".
+	- reg = SPI id of the device.
+	- gpio-controller: mark the node as gpio.

#gpio-cells?

Quoted 6 lines
Documentation/devicetree/bindings/gpio/gpio-xra1403.txt new file +6 -0
+
+Optional properties:
+-------------------
+	- reset-gpios: in case available used to control the device reset line.
+
+Example

Documentation/devicetree/bindings/gpio/gpio-xra1403.txt line 36

Quoted 10 lines
Documentation/devicetree/bindings/gpio/gpio-xra1403.txt new file +10 -0
+--------
+
+	gpioxra0: gpio@2 {
+		compatible = "exar,xra1403";
+		reg = <2>;
+		gpio-controller;
+		#gpio-cells = <2>;
+		reset-gpios = <&gpio3 6 GPIO_ACTIVE_LOW>;
+		spi-max-frequency = <1000000>;
+		status = "okay";

Don't show status in examples.

Quoted 4 lines
Documentation/devicetree/bindings/gpio/gpio-xra1403.txt new file +1 -0
+	};
Signature · 1 line
2.10.1
author
#10 lore raw

PATCH 3/3 Add XRA1403 support to MAINTAINERS file

In reply to Nandor Han

Add the XRA1403 support to MAINTAINERS list.

---
 MAINTAINERS | 8 ++++++++
 1 file changed, 8 insertions(+)
MAINTAINERS +8 -0
index 58b3a22..539c88c 100644
@@ -13903,6 +13903,14 @@ L:	[email protected]
 S:	Supported
 F:	drivers/char/xillybus/
 
+XRA1403 GPIO EXPANDER
+M:	Nandor Han <[email protected]>
+M:	Semi Malinen <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/gpio/gpio-xra1403.c
+F:	Documentation/devicetree/bindings/gpio/gpio-xra1403.txt
+
 XTENSA XTFPGA PLATFORM SUPPORT
 M:	Max Filippov <[email protected]>
 L:	[email protected]
Signature · 1 line
2.10.1
#11 lore raw
In reply to Nandor Han
Quoted 10 lines · Nandor Han

Testing:

1. XRA1403 connected to iMX53 MCU
2. Export gpio from userspace
3. Verify that corresponding gpio directories are created in /sys/class/gpio/gpioXX
4. Export gpios from first and second bank as output
5. Set the output gpio pin to high/low and verify with the oscilloscope that gpio status is according with the configured value.

Do *NOT* use the sysfs for testing GPIO.
This is being phased out.

Use the tools in tools/gpio/* so that you exercise the character device instead of the old deprecated ABI.

Yours,
Linus Walleij

#12 lore raw

cover XRA1403,gpio - add XRA1403 gpio expander driver

Quoted 10 lines

-----Original Message-----
From: Linus Walleij [mailto:[email protected]]
Sent: 29 March 2017 04:51
To: Han, Nandor (GE Healthcare) <[email protected]>
Cc: Alexandre Courbot <[email protected]>; Rob Herring <[email protected]>; Mark Rutland <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: EXT: Re: [PATCH 0/3] XRA1403,gpio - add XRA1403 gpio expander driver

<snip>

Quoted 6 lines

Do *NOT* use the sysfs for testing GPIO.
This is being phased out.

Use the tools in tools/gpio/* so that you exercise the character device instead of the old deprecated ABI.

Thanks Linus, really good and helpful comments. I agree that make more sense to test with tools/gpio/*.

Quoted 2 lines

Yours,
Linus Walleij