Skip to contentSkip to conversation

gpio: Add driver for SPI serializers

PATCH Superseded Andrew F. Davis 4 participants 17 messages Dec 11, 2015 – Jan 27, 2016

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover gpio: Add driver for SPI serializers

Hello all,

This series adds a GPI(General Purpose Input) driver for generic parallel-in/serial-out shift registers, such as the SN65HVS882 that this driver was tested on. This should also work for the rest of the SN65HVS88x series as well as other 74x165 style devices.

Thanks,
Andrew

Andrew F. Davis (2):
dt-bindings: GPIO: Add generic serializer binding
gpio: Add driver for SPI serializers

 .../devicetree/bindings/gpio/gpio-pisosr.txt       |  34 ++++
 drivers/gpio/Kconfig                               |   6 +
 drivers/gpio/Makefile                              |   1 +
 drivers/gpio/gpio-pisosr.c                         | 182 +++++++++++++++++++++
 4 files changed, 223 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/gpio-pisosr.txt
 create mode 100644 drivers/gpio/gpio-pisosr.c
Signature · 1 line
2.6.4
#1 lore raw

PATCH 1/2 dt-bindings: GPIO: Add generic serializer binding

Add binding for generic parallel-in/serial-out shift register devices used as GPIO.

---
 .../devicetree/bindings/gpio/gpio-pisosr.txt       | 34 ++++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/gpio-pisosr.txt
Documentation/devicetree/bindings/gpio/gpio-pisosr.txt new file +34 -0
new file mode 100644
index 0000000..e69e8ec
@@ -0,0 +1,34 @@
+Generic Parallel-in/Serial-out Shift Register GPIO Driver
+
+This binding describes generic parallel-in/serial-out shift register
+devices that can be used for GPI (General Purpose Input). This includes
+SN74165 serial-out shift registers and the SN65HVS88x series of
+industrial serializers.
+
+Required properties:
+ - compatible		: Should be "pisosr-gpio".
+ - gpio-controller	: Marks the device node as a GPIO controller.
+ - #gpio-cells		: Should be two. For consumer use see gpio.txt.
+
+Optional properties:
+ - ngpios		: Number of GPIO lines, default is 8.
+ - load-gpios		: GPIO pin specifier attached to load enable, this
+			  pin is pulsed before reading from the device to
+			  load input pin values into the the device.
+
+For other required and optional properties of SPI slave
+nodes please refer to ../spi/spi-bus.txt.
+
+Example:
+
+	sn65hvs882@0 {
+		compatible = "pisosr-gpio";
+		gpio-controller;
+		#gpio-cells = <2>;
+
+		load-gpios = <&gpio2 23 GPIO_ACTIVE_LOW>;
+
+		reg = <0>;
+		spi-max-frequency = <1000000>;
+		spi-cpol;
+	};
Signature · 1 line
2.6.4
#13 lore raw

PATCH 2/2 gpio: Add driver for SPI serializers

In reply to Andrew F. Davis

Add generic parallel-in/serial-out shift register GPIO driver.

This includes SPI compatible devices like SN74165 serial-out shift registers and the SN65HVS88x series of industrial serializers that can be read over the SPI bus and used for GPI (General Purpose Input).

---
 drivers/gpio/Kconfig       |   6 ++
 drivers/gpio/Makefile      |   1 +
 drivers/gpio/gpio-pisosr.c | 182 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 189 insertions(+)
 create mode 100644 drivers/gpio/gpio-pisosr.c
drivers/gpio/Kconfig +6 -0
index 30d8bd3..95615b1 100644
@@ -1021,6 +1021,12 @@ config GPIO_MC33880
 	  SPI driver for Freescale MC33880 high-side/low-side switch.
 	  This provides GPIO interface supporting inputs and outputs.
 
+config GPIO_PISOSR
+	tristate "Generic parallel-in/serial-out shift register"
+	help
+	  GPIO driver for SPI compatible parallel-in/serial-out shift
+	  registers. These are input only devices.
+
 endmenu
 
 menu "SPI or I2C GPIO expanders"
drivers/gpio/Makefile +1 -0
index 548e9b5..ee26102 100644
@@ -75,6 +75,7 @@ obj-$(CONFIG_GPIO_OMAP)		+= gpio-omap.o
 obj-$(CONFIG_GPIO_PCA953X)	+= gpio-pca953x.o
 obj-$(CONFIG_GPIO_PCF857X)	+= gpio-pcf857x.o
 obj-$(CONFIG_GPIO_PCH)		+= gpio-pch.o
+obj-$(CONFIG_GPIO_PISOSR)	+= gpio-pisosr.o
 obj-$(CONFIG_GPIO_PL061)	+= gpio-pl061.o
 obj-$(CONFIG_GPIO_PXA)		+= gpio-pxa.o
 obj-$(CONFIG_GPIO_RC5T583)	+= gpio-rc5t583.o
drivers/gpio/gpio-pisosr.c new file +182 -0

182 lines not on this page · raw message

Signature · 1 line
2.6.4
#16 lore raw
In reply to Andrew F. Davis
Quoted 4 lines · Andrew F. Davis

This series adds a GPI(General Purpose Input) driver for generic parallel-in/serial-out shift registers, such as the SN65HVS882 that this driver was tested on. This should also work for the rest of the SN65HVS88x series as well as other 74x165 style devices.

Pretty interesting, I'd like you to CC SPI maintainer Mark Brown on this patch series, and the SPI mailing list.

Looking closer at the code.

Yours,
Linus Walleij

#2 lore raw

Re: [PATCH 1/2] dt-bindings: GPIO: Add generic serializer binding

In reply to Andrew F. Davis
Quoted 5 lines · Andrew F. Davis

Add binding for generic parallel-in/serial-out shift register devices used as GPIO.

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

Quoted 9 lines
Documentation/devicetree/bindings/gpio/gpio-pisosr.txt new file +9 -0
+Generic Parallel-in/Serial-out Shift Register GPIO Driver
+
+This binding describes generic parallel-in/serial-out shift register
+devices that can be used for GPI (General Purpose Input). This includes
+SN74165 serial-out shift registers and the SN65HVS88x series of
+industrial serializers.
+
+Required properties:
+ - compatible          : Should be "pisosr-gpio".

I think it should also define compatible strings on the "vendor,device" format apart from the generic compatible. Sooner or later we may need to differentiate them and then that comes in handy.

Documentation/devicetree/bindings/gpio/gpio-pisosr.txt line 14

Quoted 5 lines

+ - gpio-controller : Marks the device node as a GPIO controller.
+ - #gpio-cells : Should be two. For consumer use see gpio.txt.

Documentation/devicetree/bindings/gpio/gpio-pisosr.txt new file +3 -0
+
+Optional properties:
+ - ngpios              : Number of GPIO lines, default is 8.

If you didn't do "pisosr-gpio" but instead "foo,sn74165", maybe you don't need to have this in the device tree but instead it can be determined from the compatible string?

In that case do that.

Documentation/devicetree/bindings/gpio/gpio-pisosr.txt line 17

Quoted 3 lines

+ - load-gpios : GPIO pin specifier attached to load enable, this

Documentation/devicetree/bindings/gpio/gpio-pisosr.txt new file +2 -0
+                         pin is pulsed before reading from the device to
+                         load input pin values into the the device.

OK seems necessary.

Yours,
Linus Walleij

#14 lore raw
In reply to Andrew F. Davis
Quoted 7 lines · Andrew F. Davis

Add generic parallel-in/serial-out shift register GPIO driver.

This includes SPI compatible devices like SN74165 serial-out shift registers and the SN65HVS88x series of industrial serializers that can be read over the SPI bus and used for GPI (General Purpose Input).

(...)

drivers/gpio/gpio-pisosr.c line 16

Quoted 2 lines
drivers/gpio/gpio-pisosr.c new file +2 -0
+#include <linux/delay.h>
+#include <linux/gpio.h>

Use #include <linux/gpio/driver.h> instead.

Quoted 4 lines
drivers/gpio/gpio-pisosr.c new file +4 -0
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/spi/spi.h>
+

drivers/gpio/gpio-pisosr.c line 30

Quoted 10 lines
drivers/gpio/gpio-pisosr.c new file +10 -0
+#define DEFAULT_NGPIO 8
+
+struct pisosr_gpio {
+       struct gpio_chip chip;
+       struct spi_device *spi;
+       u8 *buffer;
+       size_t buffer_size;
+       struct gpio_desc *load_gpio;
+       struct mutex lock;
+};

Add kerneldoc to this struct.

drivers/gpio/gpio-pisosr.c line 35

Quoted 4 lines
drivers/gpio/gpio-pisosr.c new file +4 -0
+static inline struct pisosr_gpio *to_pisosr_gpio(struct gpio_chip *chip)
+{
+       return container_of(chip, struct pisosr_gpio, chip);
+}

We are doing away with this, but I can fix up the driver by a separate patch later of we merge it.

drivers/gpio/gpio-pisosr.c line 47

Quoted 11 lines
drivers/gpio/gpio-pisosr.c new file +11 -0
+static int pisosr_gpio_refresh(struct pisosr_gpio *gpio)
+{
+       int ret;
+
+       mutex_lock(&gpio->lock);
+
+       if (gpio->load_gpio) {
+               gpiod_set_value(gpio->load_gpio, 1);
+               udelay(1); /* registers load time (~10ns) */
+               gpiod_set_value(gpio->load_gpio, 0);
+               udelay(1); /* registers recovery time (~5ns) */

So aren't these load/recovery times dependent on the device? I think these should come from the compatible string.

drivers/gpio/gpio-pisosr.c line 63

Quoted 5 lines
drivers/gpio/gpio-pisosr.c new file +5 -0
+static int pisosr_gpio_get_direction(struct gpio_chip *chip,
+                                    unsigned offset)
+{
+       return GPIOF_DIR_IN;
+}

Just return 1, GPIOF_DIR_IN is for the external API.

drivers/gpio/gpio-pisosr.c line 87

Quoted 9 lines
drivers/gpio/gpio-pisosr.c new file +9 -0
+static int pisosr_gpio_get(struct gpio_chip *chip, unsigned offset)
+{
+       struct pisosr_gpio *gpio = to_pisosr_gpio(chip);
+
+       /* Refresh may not always be needed */
+       pisosr_gpio_refresh(gpio);
+
+       return (gpio->buffer[offset / 8] >> (offset % 8)) & 0x1;
+}

This looks like a good reason to implement .get_multiple() in the same way that we have .set_multiple(), so you agree?

But it's not like I'm requiring you to engineer all that. Just an academic reflection of the fact.

drivers/gpio/gpio-pisosr.c line 105

Quoted 5 lines
drivers/gpio/gpio-pisosr.c new file +5 -0
+static int pisosr_gpio_probe(struct spi_device *spi)
+{
+       struct pisosr_gpio *gpio;
+       struct device_node *np = spi->dev.of_node;
+       int ret;

To match and get a pointer to a compatible-string-specific data variant, look at the example in drivers/mfd/tc3589x.c

drivers/gpio/gpio-pisosr.c line 115

Quoted 9 lines
drivers/gpio/gpio-pisosr.c new file +9 -0
+       gpio = devm_kzalloc(&spi->dev, sizeof(*gpio), GFP_KERNEL);
+       if (!gpio)
+               return -ENOMEM;
+
+       spi_set_drvdata(spi, gpio);
+
+       gpio->chip = template_chip;
+       gpio->chip.parent = &spi->dev;
+       of_property_read_u16(np, "ngpios", &gpio->chip.ngpio);

As I wrote elsewhere, should come from the variant data, based on the compatible string. ngpios is in case you're not using all of them and need to restrict the number of used GPIOs. Usually this only applies to on-SoC GPIOs that are unrouted.

drivers/gpio/gpio-pisosr.c line 129

Quoted 13 lines
drivers/gpio/gpio-pisosr.c new file +13 -0
+       gpio->spi = spi;
+
+       gpio->buffer_size = DIV_ROUND_UP(gpio->chip.ngpio, 8);
+       gpio->buffer = devm_kzalloc(&spi->dev, gpio->buffer_size, GFP_KERNEL);
+       if (!gpio->buffer)
+               return -ENOMEM;
+
+       gpio->load_gpio = devm_gpiod_get(&spi->dev, "load", GPIOD_OUT_LOW);
+       if (IS_ERR(gpio->load_gpio)) {
+               ret = PTR_ERR(gpio->load_gpio);
+               if (ret != -ENOENT && ret != -ENOSYS) {
+                       if (ret != -EPROBE_DEFER)
+                               dev_err(&spi->dev, "Unable to allocate reset gpio\n");

Reset gpio? Really? Load GPIO?

Apart from that it looks good.

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

Re: [PATCH 1/2] dt-bindings: GPIO: Add generic serializer binding

In reply to Linus Walleij
Quoted 7 lines · Linus Walleij
Quoted 4 lines · Andrew F. Davis

Add binding for generic parallel-in/serial-out shift register devices used as GPIO.

Quoted 14 lines

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

Quoted 9 lines
Documentation/devicetree/bindings/gpio/gpio-pisosr.txt new file +9 -0
+Generic Parallel-in/Serial-out Shift Register GPIO Driver
+
+This binding describes generic parallel-in/serial-out shift register
+devices that can be used for GPI (General Purpose Input). This includes
+SN74165 serial-out shift registers and the SN65HVS88x series of
+industrial serializers.
+
+Required properties:
+ - compatible          : Should be "pisosr-gpio".

I think it should also define compatible strings on the "vendor,device" format apart from the generic compatible. Sooner or later we may need to differentiate them and then that comes in handy.

Would it be better to wait until/if this issue arises? This driver targets the generic features, as these parts are very generic and have been produced by many companies since the 70s I'm not sure if privileging any of them makes much sense.

What I'm worried about looks to have happened with the gpio-74x164 driver, this is kind of the companion device to mine (74164 / 74165) and should work with any 74164 compatible shift register (possibly 100s of versions of them), but the compatible string that was added is "fairchild,74hc595", a relatively new device by a single manufacturer. The problem this has is then that boards will use this compatible string even if the parts are not actually the Fairchild version, just to get the match, when they should be using a generic string.

Quoted 10 lines

Documentation/devicetree/bindings/gpio/gpio-pisosr.txt line 14

Quoted 5 lines

+ - gpio-controller : Marks the device node as a GPIO controller.
+ - #gpio-cells : Should be two. For consumer use see gpio.txt.

Documentation/devicetree/bindings/gpio/gpio-pisosr.txt new file +3 -0
+
+Optional properties:
+ - ngpios              : Number of GPIO lines, default is 8.

If you didn't do "pisosr-gpio" but instead "foo,sn74165", maybe you don't need to have this in the device tree but instead it can be determined from the compatible string?

Quoted 2 lines

In that case do that.

These devices can be daisy-chained together, so three 8bit registers look exactly like one 24bit register. The only way to know this is from the physical wiring of the board, not from the part number.

Thanks,
Andrew

Quoted 9 lines

Documentation/devicetree/bindings/gpio/gpio-pisosr.txt line 17

Quoted 3 lines

+ - load-gpios : GPIO pin specifier attached to load enable, this

Documentation/devicetree/bindings/gpio/gpio-pisosr.txt new file +2 -0
+                         pin is pulsed before reading from the device to
+                         load input pin values into the the device.

OK seems necessary.

Yours,
Linus Walleij

#15 lore raw
In reply to Linus Walleij
Quoted 8 lines · Linus Walleij
Quoted 6 lines · Andrew F. Davis

Add generic parallel-in/serial-out shift register GPIO driver.

This includes SPI compatible devices like SN74165 serial-out shift registers and the SN65HVS88x series of industrial serializers that can be read over the SPI bus and used for GPI (General Purpose Input).

Quoted 7 lines
Quoted 1 line

(...)

drivers/gpio/gpio-pisosr.c line 16

Quoted 2 lines
drivers/gpio/gpio-pisosr.c new file +2 -0
+#include <linux/delay.h>
+#include <linux/gpio.h>

Use #include <linux/gpio/driver.h> instead.

ACK

Quoted 8 lines
Quoted 8 lines
drivers/gpio/gpio-pisosr.c new file +8 -0
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/spi/spi.h>
+
+#define DEFAULT_NGPIO 8
+
+struct pisosr_gpio {
+       struct gpio_chip chip;
Quoted 9 lines

drivers/gpio/gpio-pisosr.c line 30

Quoted 6 lines
drivers/gpio/gpio-pisosr.c new file +6 -0
+       struct spi_device *spi;
+       u8 *buffer;
+       size_t buffer_size;
+       struct gpio_desc *load_gpio;
+       struct mutex lock;
+};

Add kerneldoc to this struct.

Will do.

Quoted 8 lines

drivers/gpio/gpio-pisosr.c line 35

Quoted 4 lines
drivers/gpio/gpio-pisosr.c new file +4 -0
+static inline struct pisosr_gpio *to_pisosr_gpio(struct gpio_chip *chip)
+{
+       return container_of(chip, struct pisosr_gpio, chip);
+}

We are doing away with this, but I can fix up the driver by a separate patch later of we merge it.

That will work, thanks.

Quoted 7 lines
Quoted 7 lines
drivers/gpio/gpio-pisosr.c new file +7 -0
+static int pisosr_gpio_refresh(struct pisosr_gpio *gpio)
+{
+       int ret;
+
+       mutex_lock(&gpio->lock);
+
+       if (gpio->load_gpio) {
Quoted 9 lines

drivers/gpio/gpio-pisosr.c line 47

Quoted 4 lines
drivers/gpio/gpio-pisosr.c new file +4 -0
+               gpiod_set_value(gpio->load_gpio, 1);
+               udelay(1); /* registers load time (~10ns) */
+               gpiod_set_value(gpio->load_gpio, 0);
+               udelay(1); /* registers recovery time (~5ns) */

So aren't these load/recovery times dependent on the device? I think these should come from the compatible string.

Yes, but they are all under 20ns or so, I just put the smallest reasonable delay to keep a fast host from going under this limit. (although I doubt any could)

Quoted 8 lines

drivers/gpio/gpio-pisosr.c line 63

Quoted 5 lines
drivers/gpio/gpio-pisosr.c new file +5 -0
+static int pisosr_gpio_get_direction(struct gpio_chip *chip,
+                                    unsigned offset)
+{
+       return GPIOF_DIR_IN;
+}

Just return 1, GPIOF_DIR_IN is for the external API.

ACK

Quoted 13 lines

drivers/gpio/gpio-pisosr.c line 87

Quoted 9 lines
drivers/gpio/gpio-pisosr.c new file +9 -0
+static int pisosr_gpio_get(struct gpio_chip *chip, unsigned offset)
+{
+       struct pisosr_gpio *gpio = to_pisosr_gpio(chip);
+
+       /* Refresh may not always be needed */
+       pisosr_gpio_refresh(gpio);
+
+       return (gpio->buffer[offset / 8] >> (offset % 8)) & 0x1;
+}

This looks like a good reason to implement .get_multiple() in the same way that we have .set_multiple(), so you agree?

Quoted 3 lines

But it's not like I'm requiring you to engineer all that. Just an academic reflection of the fact.

I was disappointed when I saw only set_multiple, so this would be something nice to have, I'll look into it.

Quoted 10 lines

drivers/gpio/gpio-pisosr.c line 105

Quoted 5 lines
drivers/gpio/gpio-pisosr.c new file +5 -0
+static int pisosr_gpio_probe(struct spi_device *spi)
+{
+       struct pisosr_gpio *gpio;
+       struct device_node *np = spi->dev.of_node;
+       int ret;

To match and get a pointer to a compatible-string-specific data variant, look at the example in drivers/mfd/tc3589x.c

ACK

Quoted 6 lines
Quoted 6 lines
drivers/gpio/gpio-pisosr.c new file +6 -0
+       gpio = devm_kzalloc(&spi->dev, sizeof(*gpio), GFP_KERNEL);
+       if (!gpio)
+               return -ENOMEM;
+
+       spi_set_drvdata(spi, gpio);
+
Quoted 9 lines

drivers/gpio/gpio-pisosr.c line 115

Quoted 3 lines
drivers/gpio/gpio-pisosr.c new file +3 -0
+       gpio->chip = template_chip;
+       gpio->chip.parent = &spi->dev;
+       of_property_read_u16(np, "ngpios", &gpio->chip.ngpio);

As I wrote elsewhere, should come from the variant data, based on the compatible string. ngpios is in case you're not using all of them and need to restrict the number of used GPIOs. Usually this only applies to on-SoC GPIOs that are unrouted.

(See my reply to your previous comment on this)

Quoted 7 lines
Quoted 7 lines
drivers/gpio/gpio-pisosr.c new file +7 -0
+       gpio->spi = spi;
+
+       gpio->buffer_size = DIV_ROUND_UP(gpio->chip.ngpio, 8);
+       gpio->buffer = devm_kzalloc(&spi->dev, gpio->buffer_size, GFP_KERNEL);
+       if (!gpio->buffer)
+               return -ENOMEM;
+
Quoted 9 lines

drivers/gpio/gpio-pisosr.c line 129

Quoted 6 lines
drivers/gpio/gpio-pisosr.c new file +6 -0
+       gpio->load_gpio = devm_gpiod_get(&spi->dev, "load", GPIOD_OUT_LOW);
+       if (IS_ERR(gpio->load_gpio)) {
+               ret = PTR_ERR(gpio->load_gpio);
+               if (ret != -ENOENT && ret != -ENOSYS) {
+                       if (ret != -EPROBE_DEFER)
+                               dev_err(&spi->dev, "Unable to allocate reset gpio\n");

Reset gpio? Really? Load GPIO?

Ops, copy/paste error I think.

Thanks,
Andrew

Quoted 5 lines

Apart from that it looks good.

Yours,
Linus Walleij

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

#4 lore raw

Re: [PATCH 1/2] dt-bindings: GPIO: Add generic serializer binding

In reply to Andrew F. Davis
Quoted 31 lines · Andrew F. Davis
Quoted 9 lines · Linus Walleij
Quoted 4 lines · Andrew F. Davis

Add binding for generic parallel-in/serial-out shift register devices used as GPIO.

Quoted 15 lines

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

Quoted 9 lines
Documentation/devicetree/bindings/gpio/gpio-pisosr.txt new file +9 -0
+Generic Parallel-in/Serial-out Shift Register GPIO Driver
+
+This binding describes generic parallel-in/serial-out shift register
+devices that can be used for GPI (General Purpose Input). This includes
+SN74165 serial-out shift registers and the SN65HVS88x series of
+industrial serializers.
+
+Required properties:
+ - compatible          : Should be "pisosr-gpio".

I think it should also define compatible strings on the "vendor,device" format apart from the generic compatible. Sooner or later we may need to differentiate them and then that comes in handy.

Would it be better to wait until/if this issue arises? This driver targets the generic features, as these parts are very generic and have been produced by many companies since the 70s I'm not sure if privileging any of them makes much sense.

Quoted 8 lines

What I'm worried about looks to have happened with the gpio-74x164 driver, this is kind of the companion device to mine (74164 / 74165) and should work with any 74164 compatible shift register (possibly 100s of versions of them), but the compatible string that was added is "fairchild,74hc595", a relatively new device by a single manufacturer. The problem this has is then that boards will use this compatible string even if the parts are not actually the Fairchild version, just to get the match, when they should be using a generic string.

I agree the generic version is fine (or find who made the first part ;)). What "pisosr" is is not very obvious though. Having 74165 in the compatible would make it somewhat more obvious it is a standard logic part.

Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

+Optional properties:
+ - ngpios : Number of GPIO lines, default is 8.

If you didn't do "pisosr-gpio" but instead "foo,sn74165", maybe you don't need to have this in the device tree but instead it can be determined from the compatible string?

Quoted 6 lines
Quoted 2 lines

In that case do that.

These devices can be daisy-chained together, so three 8bit registers look exactly like one 24bit register. The only way to know this is from the physical wiring of the board, not from the part number.

Then you should say it must be multiple of 8 (or are there other lengths?).

Rob

#5 lore raw

Re: [PATCH 1/2] dt-bindings: GPIO: Add generic serializer binding

Quoted 41 lines · Rob Herring
Quoted 31 lines · Andrew F. Davis
Quoted 9 lines · Linus Walleij
Quoted 4 lines · Andrew F. Davis

Add binding for generic parallel-in/serial-out shift register devices used as GPIO.

Quoted 15 lines

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

Quoted 9 lines
Documentation/devicetree/bindings/gpio/gpio-pisosr.txt new file +9 -0
+Generic Parallel-in/Serial-out Shift Register GPIO Driver
+
+This binding describes generic parallel-in/serial-out shift register
+devices that can be used for GPI (General Purpose Input). This includes
+SN74165 serial-out shift registers and the SN65HVS88x series of
+industrial serializers.
+
+Required properties:
+ - compatible          : Should be "pisosr-gpio".

I think it should also define compatible strings on the "vendor,device" format apart from the generic compatible. Sooner or later we may need to differentiate them and then that comes in handy.

Would it be better to wait until/if this issue arises? This driver targets the generic features, as these parts are very generic and have been produced by many companies since the 70s I'm not sure if privileging any of them makes much sense.

Quoted 8 lines

What I'm worried about looks to have happened with the gpio-74x164 driver, this is kind of the companion device to mine (74164 / 74165) and should work with any 74164 compatible shift register (possibly 100s of versions of them), but the compatible string that was added is "fairchild,74hc595", a relatively new device by a single manufacturer. The problem this has is then that boards will use this compatible string even if the parts are not actually the Fairchild version, just to get the match, when they should be using a generic string.

Quoted 5 lines

I agree the generic version is fine (or find who made the first part ;)). What "pisosr" is is not very obvious though. Having 74165 in the compatible would make it somewhat more obvious it is a standard logic part.

A quick search shows shift-registers being made from vacuum tubes for the Colossus! Those might work with this driver if you could match the voltage to an SPI bus... :)

I agree about the name not being very good, but I'm not sure about 74165 ether as it is also just a single part number. The idea was to have a non-part number compatible string for any shift-register you can hook to the SPI line. That way when we have boards with a sn65x882 or something we wont have to call it a 74165. But I guess that's why it's a "compatible:" string, and not "is-a:" string.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

+Optional properties:
+ - ngpios : Number of GPIO lines, default is 8.

If you didn't do "pisosr-gpio" but instead "foo,sn74165", maybe you don't need to have this in the device tree but instead it can be determined from the compatible string?

Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

In that case do that.

These devices can be daisy-chained together, so three 8bit registers look exactly like one 24bit register. The only way to know this is from the physical wiring of the board, not from the part number.

Then you should say it must be multiple of 8 (or are there other lengths?).

Some are 4bit, you can even just hook a single flip-flop to the SPI bus for a single bit (or multiples) of input.

Andrew

Quoted 2 lines

Rob

#6 lore raw

Re: [PATCH 1/2] dt-bindings: GPIO: Add generic serializer binding

Quoted 8 lines · Andrew F. Davis
Quoted 7 lines · Rob Herring
Quoted 5 lines · Andrew F. Davis
Quoted 3 lines · Linus Walleij

On Fri, Dec 11, 2015 at 8:46 PM, Andrew F. Davis <[email protected]> wrote:

[...]

Quoted 34 lines
Quoted 24 lines
Quoted 14 lines
Quoted 8 lines
Quoted 1 line

+ - compatible : Should be "pisosr-gpio".

I think it should also define compatible strings on the "vendor,device" format apart from the generic compatible. Sooner or later we may need to differentiate them and then that comes in handy.

Would it be better to wait until/if this issue arises? This driver targets the generic features, as these parts are very generic and have been produced by many companies since the 70s I'm not sure if privileging any of them makes much sense.

Quoted 8 lines

What I'm worried about looks to have happened with the gpio-74x164 driver, this is kind of the companion device to mine (74164 / 74165) and should work with any 74164 compatible shift register (possibly 100s of versions of them), but the compatible string that was added is "fairchild,74hc595", a relatively new device by a single manufacturer. The problem this has is then that boards will use this compatible string even if the parts are not actually the Fairchild version, just to get the match, when they should be using a generic string.

Quoted 5 lines

I agree the generic version is fine (or find who made the first part ;)). What "pisosr" is is not very obvious though. Having 74165 in the compatible would make it somewhat more obvious it is a standard logic part.

A quick search shows shift-registers being made from vacuum tubes for the Colossus! Those might work with this driver if you could match the voltage to an SPI bus... :)

Quoted 6 lines

I agree about the name not being very good, but I'm not sure about 74165 ether as it is also just a single part number. The idea was to have a non-part number compatible string for any shift-register you can hook to the SPI line. That way when we have boards with a sn65x882 or something we wont have to call it a 74165. But I guess that's why it's a "compatible:" string, and not "is-a:" string.

If there are a couple then I think it is okay. If there are 10s then maybe not. Perhaps logic-pisosr or discrete-pisosr?

Quoted 17 lines
Quoted 17 lines
Quoted 15 lines
Quoted 11 lines
Quoted 2 lines

+Optional properties:
+ - ngpios : Number of GPIO lines, default is 8.

If you didn't do "pisosr-gpio" but instead "foo,sn74165", maybe you don't need to have this in the device tree but instead it can be determined from the compatible string?

In that case do that.

These devices can be daisy-chained together, so three 8bit registers look exactly like one 24bit register. The only way to know this is from the physical wiring of the board, not from the part number.

Quoted 6 lines
Quoted 3 lines

Then you should say it must be multiple of 8 (or are there other lengths?).

Some are 4bit, you can even just hook a single flip-flop to the SPI bus for a single bit (or multiples) of input.

One would hope you would just connect the CS signal directly to that input for 1-bit... I guess you could be out of GPIOs and only have a free output only CS signal.

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

#11 lore raw

Re: [PATCH 1/2] dt-bindings: GPIO: Add generic serializer binding

In reply to Andrew F. Davis
Quoted 5 lines · Andrew F. Davis

What I'm worried about looks to have happened with the gpio-74x164 driver, this is kind of the companion device to mine (74164 / 74165) and should work with any 74164 compatible shift register (possibly 100s of versions of them), but the compatible string that was added is "fairchild,74hc595", a relatively new device by a single manufacturer.

In hindsight, that probably should have been "motorola,mc74hc595" instead. Recently I read that Motorola invented the 74hc59x for their "new" SPI bus as that time, as the 74164 is not 100% SPI-compatible.

Given the limitations of the '164 for SPI, is the same true for '165, and should it be "[...]74[...]597" instead?

Quoted 3 lines

The problem this has is then that boards will use this compatible string even if the parts are not actually the Fairchild version, just to get the match, when they should be using a generic string.

They're all supposed to be "compatible".
Personally, I wouldn't object to just "74595", cfr. "ns16550a".

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#12 lore raw

Re: [PATCH 1/2] dt-bindings: GPIO: Add generic serializer binding

Quoted 2 lines · Geert Uytterhoeven

Given the limitations of the '164 for SPI, is the same true for '165, and should it be "[...]74[...]597" instead?

Forget it, this driver is not about SPI.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#8 lore raw

Re: [PATCH 1/2] dt-bindings: GPIO: Add generic serializer binding

In reply to Andrew F. Davis
Quoted 7 lines · Andrew F. Davis

[Rob]

Quoted 5 lines

I agree the generic version is fine (or find who made the first part ;)). What "pisosr" is is not very obvious though. Having 74165 in the compatible would make it somewhat more obvious it is a standard logic part.

Quoted 6 lines

A quick search shows shift-registers being made from vacuum tubes for the Colossus! Those might work with this driver if you could match the voltage to an SPI bus... :)

I agree about the name not being very good, but I'm not sure about 74165 ether as it is also just a single part number.

We can add many compatible strings so it's not an issue. "ti,74165" works for me as TI invented the 74xx series.

Quoted 3 lines

The idea was to
have a non-part number compatible string for any shift-register you can hook to the SPI line.

Again, one does not exclude the other. I'm happy with a generic compatible *and* "ti,74165".

Quoted 3 lines

That way when we have boards with a sn65x882
or something we wont have to call it a 74165. But I guess that's why it's a "compatible:" string, and not "is-a:" string.

Compatible ranges from the specific to the more generic so compatible = "ti,74165", "pisosr"; is just fine. Something will match if there is a suitable driver. The OS may choose to provide something part-specific or something more generic.

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

#7 lore raw

Re: [PATCH 1/2] dt-bindings: GPIO: Add generic serializer binding

In reply to Rob Herring
Quoted 53 lines · Rob Herring
Quoted 8 lines · Andrew F. Davis
Quoted 7 lines · Rob Herring
Quoted 5 lines · Andrew F. Davis
Quoted 3 lines · Linus Walleij

On Fri, Dec 11, 2015 at 8:46 PM, Andrew F. Davis <[email protected]> wrote:

[...]

Quoted 34 lines
Quoted 24 lines
Quoted 14 lines
Quoted 8 lines
Quoted 1 line

+ - compatible : Should be "pisosr-gpio".

I think it should also define compatible strings on the "vendor,device" format apart from the generic compatible. Sooner or later we may need to differentiate them and then that comes in handy.

Would it be better to wait until/if this issue arises? This driver targets the generic features, as these parts are very generic and have been produced by many companies since the 70s I'm not sure if privileging any of them makes much sense.

Quoted 8 lines

What I'm worried about looks to have happened with the gpio-74x164 driver, this is kind of the companion device to mine (74164 / 74165) and should work with any 74164 compatible shift register (possibly 100s of versions of them), but the compatible string that was added is "fairchild,74hc595", a relatively new device by a single manufacturer. The problem this has is then that boards will use this compatible string even if the parts are not actually the Fairchild version, just to get the match, when they should be using a generic string.

Quoted 5 lines

I agree the generic version is fine (or find who made the first part ;)). What "pisosr" is is not very obvious though. Having 74165 in the compatible would make it somewhat more obvious it is a standard logic part.

A quick search shows shift-registers being made from vacuum tubes for the Colossus! Those might work with this driver if you could match the voltage to an SPI bus... :)

Quoted 6 lines

I agree about the name not being very good, but I'm not sure about 74165 ether as it is also just a single part number. The idea was to have a non-part number compatible string for any shift-register you can hook to the SPI line. That way when we have boards with a sn65x882 or something we wont have to call it a 74165. But I guess that's why it's a "compatible:" string, and not "is-a:" string.

Quoted 3 lines

If there are a couple then I think it is okay. If there are 10s then maybe not. Perhaps logic-pisosr or discrete-pisosr?

My concern as well, there are a lot of them, and every device doesn't need its own string, so why privilege the name of any that don't have anything different.

I'd like to leave the named ones for odd cases that needs special handling.

Quoted 21 lines
Quoted 21 lines
Quoted 20 lines
Quoted 9 lines
Quoted 9 lines
Quoted 2 lines

+Optional properties:
+ - ngpios : Number of GPIO lines, default is 8.

If you didn't do "pisosr-gpio" but instead "foo,sn74165", maybe you don't need to have this in the device tree but instead it can be determined from the compatible string?

Quoted 6 lines
Quoted 2 lines

In that case do that.

These devices can be daisy-chained together, so three 8bit registers look exactly like one 24bit register. The only way to know this is from the physical wiring of the board, not from the part number.

Then you should say it must be multiple of 8 (or are there other lengths?).

Quoted 7 lines
Quoted 2 lines

Some are 4bit, you can even just hook a single flip-flop to the SPI bus for a single bit (or multiples) of input.

One would hope you would just connect the CS signal directly to that input for 1-bit... I guess you could be out of GPIOs and only have a free output only CS signal.

Interesting use-case idea :), I'm more worried about a device with any prime number of pins where multiples will fail, not that I have ever seen one.

Andrew

Quoted 2 lines

Rob

#9 lore raw

Re: [PATCH 1/2] dt-bindings: GPIO: Add generic serializer binding

In reply to Linus Walleij
Quoted 12 lines · Linus Walleij
Quoted 11 lines · Andrew F. Davis

[Rob]

Quoted 5 lines

I agree the generic version is fine (or find who made the first part ;)). What "pisosr" is is not very obvious though. Having 74165 in the compatible would make it somewhat more obvious it is a standard logic part.

A quick search shows shift-registers being made from vacuum tubes for the Colossus! Those might work with this driver if you could match the voltage to an SPI bus... :)

Quoted 6 lines
Quoted 2 lines

I agree about the name not being very good, but I'm not sure about 74165 ether as it is also just a single part number.

We can add many compatible strings so it's not an issue. "ti,74165" works for me as TI invented the 74xx series.

Free advertising for our parts :)

Quoted 7 lines
Quoted 3 lines

The idea was to
have a non-part number compatible string for any shift-register you can hook to the SPI line.

Again, one does not exclude the other. I'm happy with a generic compatible *and* "ti,74165".

Quoted 9 lines
Quoted 3 lines

That way when we have boards with a sn65x882
or something we wont have to call it a 74165. But I guess that's why it's a "compatible:" string, and not "is-a:" string.

Compatible ranges from the specific to the more generic so compatible = "ti,74165", "pisosr"; is just fine. Something will match if there is a suitable driver. The OS may choose to provide something part-specific or something more generic.

And so we won't need to have "ti,74165" in the driver itself, if we just have "pisosr", then dts files can use what ever they like to correctly identify the part then fall back to pisosr.

compatible = "company,random_numbers_of_exact_part_actually_on_board", "pisosr";

Andrew

Quoted 3 lines

Yours,
Linus Walleij

#10 lore raw

Re: [PATCH 1/2] dt-bindings: GPIO: Add generic serializer binding

Quoted 7 lines · Andrew F. Davis

[Me]

Quoted 5 lines

Compatible ranges from the specific to the more generic so compatible = "ti,74165", "pisosr"; is just fine. Something will match if there is a suitable driver. The OS may choose to provide something part-specific or something more generic.

Quoted 6 lines

And so we won't need to have "ti,74165" in the driver itself, if we just have "pisosr", then dts files can use what ever they like to correctly identify the part then fall back to pisosr.

compatible = "company,random_numbers_of_exact_part_actually_on_board", "pisosr";

Exactly. Sorry for slow replies.

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