Skip to contentSkip to conversation

gpio: Add driver for TI TPIC2810

PATCH Superseded Andrew F. Davis 3 participants 4 messages Dec 15, 2015 – Jan 4, 2016 GPIO

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio: Add driver for TI TPIC2810

Add driver for TI TPIC2810 8-Bit LED Driver with I2C Interface.

The TPIC2810 has 8 open-drain outputs that can but used to drive LEDs and other low-side switched resistive loads.

---
 drivers/gpio/Kconfig         |   8 +++
 drivers/gpio/Makefile        |   1 +
 drivers/gpio/gpio-tpic2810.c | 165 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 174 insertions(+)
 create mode 100644 drivers/gpio/gpio-tpic2810.c
drivers/gpio/Kconfig +8 -0
index b60f40a..1696209 100644
@@ -709,6 +709,14 @@ config GPIO_SX150X
 	  8 bits:  sx1508q
 	  16 bits: sx1509q
 
+config GPIO_TPIC2810
+	tristate "TPIC2810 8-Bit I2C GPO expander"
+	help
+	  Say yes here to enable the GPO driver for the TI TPIC2810 chip.
+
+	  To compile this driver as a module, choose M here: the module will
+	  be called gpio-tpic2810.
+
 endmenu
 
 menu "MFD GPIO expanders"
drivers/gpio/Makefile +1 -0
index 548e9b5..3bc66c6 100644
@@ -96,6 +96,7 @@ obj-$(CONFIG_GPIO_TC3589X)	+= gpio-tc3589x.o
 obj-$(CONFIG_ARCH_TEGRA)	+= gpio-tegra.o
 obj-$(CONFIG_GPIO_TIMBERDALE)	+= gpio-timberdale.o
 obj-$(CONFIG_GPIO_PALMAS)	+= gpio-palmas.o
+obj-$(CONFIG_GPIO_TPIC2810)	+= gpio-tpic2810.o
 obj-$(CONFIG_GPIO_TPS6586X)	+= gpio-tps6586x.o
 obj-$(CONFIG_GPIO_TPS65910)	+= gpio-tps65910.o
 obj-$(CONFIG_GPIO_TPS65912)	+= gpio-tps65912.o
drivers/gpio/gpio-tpic2810.c new file +165 -0

165 lines not on this page · raw message

Signature · 1 line
2.6.4
#1 lore raw
Quoted 6 lines · Andrew F. Davis

Add driver for TI TPIC2810 8-Bit LED Driver with I2C Interface.

The TPIC2810 has 8 open-drain outputs that can but used to drive LEDs and other low-side switched resistive loads.

This patch will have to be rebased to apply and compile after the release of kernel v4.5-rc1, as we have too much lined up right now, I see no big problems
with it but here are some more minor comments.

+static inline struct tpic2810 *to_tpic2810(struct gpio_chip *chip)

drivers/gpio/gpio-tpic2810.c line 39

Quoted 3 lines
drivers/gpio/gpio-tpic2810.c new file +3 -0
+{
+       return container_of(chip, struct tpic2810, chip);
+}

We are getting rid of this design pattern, check the gpiochip_get_data() function that will be introduced in v4.5-rc1 and patches I merge to all other drivers.

Quoted 5 lines
drivers/gpio/gpio-tpic2810.c new file +5 -0
+static const struct i2c_device_id tpic2810_id_table[] = {
+       { "tpic2810", },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(i2c, tpic2810_id_table);

drivers/gpio/gpio-tpic2810.c line 161

Quoted 10 lines
drivers/gpio/gpio-tpic2810.c new file +10 -0
+
+static struct i2c_driver tpic2810_driver = {
+       .driver = {
+               .name = "tpic2810",
+       },
+       .probe = tpic2810_probe,
+       .remove = tpic2810_remove,
+       .id_table = tpic2810_id_table,
+};
+module_i2c_driver(tpic2810_driver);

No device tree probing? Which platform uses this?
I was expecting an .of_match_table() in .driver.

Yours,
Linus Walleij

#2 lore raw
Quoted 7 lines · Linus Walleij
Quoted 5 lines · Andrew F. Davis

Add driver for TI TPIC2810 8-Bit LED Driver with I2C Interface.

The TPIC2810 has 8 open-drain outputs that can but used to drive LEDs and other low-side switched resistive loads.

Quoted 7 lines
Quoted 1 line

This patch will have to be rebased to apply and compile after the release of kernel v4.5-rc1, as we have too much lined up right now, I see no big problems
with it but here are some more minor comments.

Works for me.

Quoted 9 lines

+static inline struct tpic2810 *to_tpic2810(struct gpio_chip *chip)

drivers/gpio/gpio-tpic2810.c line 39

Quoted 3 lines
drivers/gpio/gpio-tpic2810.c new file +3 -0
+{
+       return container_of(chip, struct tpic2810, chip);
+}

We are getting rid of this design pattern, check the gpiochip_get_data() function that will be introduced in v4.5-rc1 and patches I merge to all other drivers.

ACK

Quoted 10 lines
Quoted 10 lines
drivers/gpio/gpio-tpic2810.c new file +10 -0
+static const struct i2c_device_id tpic2810_id_table[] = {
+       { "tpic2810", },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(i2c, tpic2810_id_table);
+
+static struct i2c_driver tpic2810_driver = {
+       .driver = {
+               .name = "tpic2810",
+       },
Quoted 9 lines

drivers/gpio/gpio-tpic2810.c line 161

Quoted 5 lines
drivers/gpio/gpio-tpic2810.c new file +5 -0
+       .probe = tpic2810_probe,
+       .remove = tpic2810_remove,
+       .id_table = tpic2810_id_table,
+};
+module_i2c_driver(tpic2810_driver);

No device tree probing? Which platform uses this?
I was expecting an .of_match_table() in .driver.

As far as I know .of_match_table and MODULE_ALIAS for DT have no real effect on I2C devices as they match on "anything,i2c_name". And only throw an I2C MODALIAS to userspace for loading. So we can use this device in a DTS without any driver modifications.

At least it worked like this on my test platform (am57xx-evm).

I think it might be best to keep drivers DT agnostic when possible, in case DT is superseded by something, so we don't end up with mountains of dead code.

Thanks,
Andrew

Quoted 3 lines

Yours,
Linus Walleij

#3 lore raw

Hello Andrew,

[snip]

Quoted 22 lines
Quoted 12 lines
Quoted 12 lines
drivers/gpio/gpio-tpic2810.c new file +11 -0
+static const struct i2c_device_id tpic2810_id_table[] = {
+       { "tpic2810", },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(i2c, tpic2810_id_table);
+
+static struct i2c_driver tpic2810_driver = {
+       .driver = {
+               .name = "tpic2810",
+       },
+       .probe = tpic2810_probe,
Quoted 9 lines

drivers/gpio/gpio-tpic2810.c line 161

Quoted 4 lines
drivers/gpio/gpio-tpic2810.c new file +4 -0
+       .remove = tpic2810_remove,
+       .id_table = tpic2810_id_table,
+};
+module_i2c_driver(tpic2810_driver);

No device tree probing? Which platform uses this?
I was expecting an .of_match_table() in .driver.

Quoted 9 lines

As far as I know .of_match_table and MODULE_ALIAS for DT have no real effect on I2C devices as they match on "anything,i2c_name". And only throw an I2C MODALIAS to userspace for loading. So we can use this device in a DTS without any driver modifications.

At least it worked like this on my test platform (am57xx-evm).

Is true that it works due how the I2C core is implemented but IMHO that is wrong and should be fixed at some point.

I posted a patch series [0] to fix most of the I2C drivers in preparation for this so please add a proper OF table to not introduce yet another issue to fix.

Quoted 4 lines

I think it might be best to keep drivers DT agnostic when possible, in case DT is superseded by something, so we don't end up with mountains of dead code.

It isn't mountain of code but just simple tables to match a device with a driver and to report proper module aliases.

The problem with using the I2C device ID as a fallback is that the DT binding doc list the compatible strings that are valid for this device but DTB can use "anything,i2c_name" as you said or just "i2c_name" and so not following the DT bindings.

Also, it would cause problems if there are two I2C drivers with the same "i2c_name" but a different vendor, so the vendor prefix is important.

Quoted 3 lines

Thanks,
Andrew

[0]: https://lkml.org/lkml/2015/7/30/519

Best regards,
Javier