gpio: Add driver for TI TPIC2810
PATCH v2 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.
---
Changes from v1:
- Added OF match table at Javier Martinez Canillas request
drivers/gpio/Kconfig | 8 +++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-tpic2810.c | 167 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 176 insertions(+) create mode 100644 drivers/gpio/gpio-tpic2810.c
drivers/gpio/Kconfig +8 -0
@@ -702,6 +702,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
@@ -95,6 +95,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 +167 -0
167 lines not on this page · raw message
Signature · 1 line
2.7.0
Quoted 9 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.
Signed-off-by Andrew F. Davis <[email protected]>---
Changes from v1:
- Added OF match table at Javier Martinez Canillas request
So the TI datasheet says:
"8 bit LED driver with I2C interface"
So it is *not* "general purpose input/output" (GPIO).
It is special purpose LED drive output-only circuit.
So why can it not have a driver directly in drivers/leds/*?
I understand that it can also be used as a GPIO (and that it is then nice to put leds-gpio on top of it) but then I want a reference to the hardware that actually went ahead and used this as a GPIO chip rather than using a proper GPIO expander.
Yours,
Linus Walleij
Quoted 21 lines · Linus Walleij
Quoted 9 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.
Signed-off-by Andrew F. Davis <[email protected]>---
Changes from v1:
- Added OF match table at Javier Martinez Canillas requestSo the TI datasheet says:
"8 bit LED driver with I2C interface"So it is *not* "general purpose input/output" (GPIO).
It is special purpose LED drive output-only circuit.
So why can it not have a driver directly in
drivers/leds/*?
Quoted 9 lines
I understand that it can also be used as a GPIO (and that it is then nice to put leds-gpio on top of it) but then I want a reference to the hardware that actually went ahead and used this as a GPIO chip rather than using a proper GPIO expander.
Yours,
Linus Walleij
These don't really have the traditional LED features (current control, HW blinking, etc), and all the use cases I've found treat them as GPO, including our Industrial Dev Kits (although they run them to test LEDs as well as the IO header):
http://www.ti.com/tool/tmdsice3359
http://www.ti.com/tool/tmdxidk437x
And a couple more that I don't think have any public schematics yet.
Like you said, they can still be used for LEDs with leds-gpio, as they don't have any LED specific features I figure this way we get both uses with one driver.
Andrew
Quoted 17 lines · Andrew F. Davis
Quoted 7 lines · Linus Walleij
So the TI datasheet says:
"8 bit LED driver with I2C interface"So it is *not* "general purpose input/output" (GPIO).
It is special purpose LED drive output-only circuit.
Quoted 7 lines
So why can it not have a driver directly in
drivers/leds/*?I understand that it can also be used as a GPIO (and that it is then nice to put leds-gpio on top of it) but then I want a reference to the hardware that actually went ahead and used this as a GPIO chip rather than using a proper GPIO expander.
Quoted 3 lines
These don't really have the traditional LED features (current control, HW blinking, etc), and all the use cases I've found treat them as GPO, including our Industrial Dev Kits…
It reminds me how 12 channel PWM chip is used on Intel Galileo Gen 2. Half pins are PWM, the other half is GPIO used for discrete based pin muxing and control. Nevertheless I think it's a userspace issue for now, otherwise we have to provide some 'semi-virtual' way of presenting pins as GPIO lines.
just my 2 cents.
Signature · 6 lines
With Best Regards, Andy Shevchenko -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 5 lines · Andy Shevchenko
It reminds me how 12 channel PWM chip is used on Intel Galileo Gen 2. Half pins are PWM, the other half is GPIO used for discrete based pin muxing and control. Nevertheless I think it's a userspace issue for now, otherwise we have to provide some 'semi-virtual' way of presenting pins as GPIO lines.
That sounds like an MFD spawning a GPIO and a PWM cell. That it is called "a PWM chip" is no big deal, it should be modeled according to what it is, not what it claims to be.
(Which makes me wanna merge this present patch as a GPIO driver since it claims to be a LED driver but is a GPO.)
See the ST Multipurpose Expander for an example drivers/mfd/stmpe.cdrivers/gpio/gpio-stmpe.c drivers/input/keyboard/stmpe-keypad.c
Yours,
Linus Walleij
Quoted 9 lines · Linus Walleij
Quoted 5 lines · Andy Shevchenko
It reminds me how 12 channel PWM chip is used on Intel Galileo Gen 2. Half pins are PWM, the other half is GPIO used for discrete based pin muxing and control. Nevertheless I think it's a userspace issue for now, otherwise we have to provide some 'semi-virtual' way of presenting pins as GPIO lines.
Quoted 3 lines
That sounds like an MFD spawning a GPIO and a PWM cell. That it is called "a PWM chip" is no big deal, it should be modeled according to what it is, not what it claims to be.
Although I agree with model I barely imagine how in this case drivers should access PWM chip registers in non-race way (take into account that PWM itself is connected to i2c bus).
Quoted 7 lines
(Which makes me wanna merge this present patch as a GPIO driver since it claims to be a LED driver but is a GPO.)
See the ST Multipurpose Expander for an example
drivers/mfd/stmpe.cdrivers/gpio/gpio-stmpe.cdrivers/input/keyboard/stmpe-keypad.c
I will look to the example later, thanks.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 10 lines · Andy Shevchenko
Quoted 9 lines · Linus Walleij
Quoted 5 lines · Andy Shevchenko
It reminds me how 12 channel PWM chip is used on Intel Galileo Gen 2. Half pins are PWM, the other half is GPIO used for discrete based pin muxing and control. Nevertheless I think it's a userspace issue for now, otherwise we have to provide some 'semi-virtual' way of presenting pins as GPIO lines.
Quoted 7 lines
Quoted 3 lines
That sounds like an MFD spawning a GPIO and a PWM cell. That it is called "a PWM chip" is no big deal, it should be modeled according to what it is, not what it claims to be.
Although I agree with model I barely imagine how in this case drivers should access PWM chip registers in non-race way (take into account that PWM itself is connected to i2c bus).
There is a pattern for that. You add a set of accessor functions that performs the I2C traffic in the MFD layer.
The accessor functions take a mutex. Since this is all slowpath, waiting/preempting in a mutex is perfectly fine for all subdrivers.
Look at this:
/**
* stmpe_reg_write() - write a single STMPE register
* @stmpe: Device to write to
* @reg: Register to write
* @val: Value to write
*/
int stmpe_reg_write(struct stmpe *stmpe, u8 reg, u8 val)
{
int ret;
mutex_lock(&stmpe->lock);
ret = __stmpe_reg_write(stmpe, reg, val);
mutex_unlock(&stmpe->lock);
return ret;
}EXPORT_SYMBOL_GPL(stmpe_reg_write);
Yours,
Linus Walleij
Quoted 11 lines · Andrew F. Davis
Quoted 5 lines
I understand that it can also be used as a GPIO (and that it is then nice to put leds-gpio on top of it) but then I want a reference to the hardware that actually went ahead and used this as a GPIO chip rather than using a proper GPIO expander.
These don't really have the traditional LED features (current control, HW blinking, etc), and all the use cases I've found treat them as GPO, including our Industrial Dev Kits (although they run them to test LEDs as well as the IO header):
Quoted 8 lines
http://www.ti.com/tool/tmdsice3359
http://www.ti.com/tool/tmdxidk437xAnd a couple more that I don't think have any public schematics yet.
Like you said, they can still be used for LEDs with leds-gpio, as they don't have any LED specific features I figure this way we get both uses with one driver.
Fair enough, merged as you see.
Yours,
Linus Walleij
Quoted 9 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.
Signed-off-by Andrew F. Davis <[email protected]>---
Changes from v1:
- Added OF match table at Javier Martinez Canillas request
Patch applied.
Yours,
Linus Walleij