pinctrl: Add SX150X GPIO Extender Pinctrl Driver
Subsystems (2)
RFC PATCH 1/1 pinctrl: Add SX150X GPIO Extender Pinctrl Driver
Since the I2C sx150x GPIO expander driver uses platform_data to managed the pins configurations, rewrite the driver as a pinctrl driver using pinconf to get pin configurations from DT.
The pinctrl driver is functionnally as the gpio-only driver equivalent and can use DT for pinconf.
--- drivers/pinctrl/Kconfig | 15 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-sx150x.c | 1056 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 1072 insertions(+) create mode 100644 drivers/pinctrl/pinctrl-sx150x.c
drivers/pinctrl/Kconfig +15 -0
@@ -164,6 +164,21 @@ config PINCTRL_SIRF select GENERIC_PINCONF select GPIOLIB_IRQCHIP +config PINCTRL_SX150X + bool "Semtech SX150x I2C GPIO expander pinctrl driver" + depends on GPIOLIB && I2C=y + select PINMUX + select PINCONF + select GENERIC_PINCONF + select GPIOLIB_IRQCHIP + select OF_GPIO + help + Say yes here to provide support for Semtech SX150-series I2C + GPIO expanders as pinctrl module. + Compatible models include: + - 8 bits: sx1508q, sx1502q + - 16 bits: sx1509q, sx1506q + config PINCTRL_PISTACHIO def_bool y if MACH_PISTACHIO depends on GPIOLIB
drivers/pinctrl/Makefile +1 -0
@@ -25,6 +25,7 @@ obj-$(CONFIG_PINCTRL_PISTACHIO) += pinctrl-pistachio.o obj-$(CONFIG_PINCTRL_ROCKCHIP) += pinctrl-rockchip.o obj-$(CONFIG_PINCTRL_SINGLE) += pinctrl-single.o obj-$(CONFIG_PINCTRL_SIRF) += sirf/ +obj-$(CONFIG_PINCTRL_SX150X) += pinctrl-sx150x.o obj-$(CONFIG_ARCH_TEGRA) += tegra/ obj-$(CONFIG_PINCTRL_TZ1090) += pinctrl-tz1090.o obj-$(CONFIG_PINCTRL_TZ1090_PDC) += pinctrl-tz1090-pdc.o
drivers/pinctrl/pinctrl-sx150x.c new file +1056 -0
1,056 lines not on this page · raw message
Signature · 1 line
1.9.1
Quoted 8 lines · Neil Armstrong
Since the I2C sx150x GPIO expander driver uses
platform_datato managed the pins configurations, rewrite the driver as a pinctrl driver using pinconf to get pin configurations from DT.The pinctrl driver is functionnally as the gpio-only driver equivalent and can use DT for pinconf.
Signed-off-by Neil Armstrong <[email protected]>
Overall I'd say this is a nice rewrite. I'd like the following:
- Include Peter Rosin, Wei Chen, Roland Stigge and Vladimir Zapolskiy on subsequent posts
(Added on To:) ideally I want Tested-by: tags from them to verify that it doesn't break their current set-ups (does it? Especially LPC32xx)
- We need a migration plan: everything that was selecting GPIO_SX150X before should now select this instead. Just let the Kconfig entry in the drivers/gpio/Kconfig select this new driver?
- Make sure it is a slot-in replacement. Else make sure it is.
- Delete the old sx150x driver from drivers/gpio in the same patch. I'd hate to maintain them side by side. If I apply this, the old one must go out at the same time. Conversely I can revert the patch and get the old driver back.
- Strangely I don't see refernces to this driver in any device tree. Are people not upstreaming their boards?
Yours,
Linus Walleij
Quoted 11 lines · Linus Walleij
Quoted 8 lines · Neil Armstrong
Since the I2C sx150x GPIO expander driver uses
platform_datato managed the pins configurations, rewrite the driver as a pinctrl driver using pinconf to get pin configurations from DT.The pinctrl driver is functionnally as the gpio-only driver equivalent and can use DT for pinconf.
Signed-off-by Neil Armstrong <[email protected]>
Quoted 7 lines
Overall I'd say this is a nice rewrite. I'd like the following:
- Include Peter Rosin, Wei Chen, Roland Stigge and Vladimir Zapolskiy on subsequent posts
(Added on To:) ideally I want Tested-by: tags from them to verify that it doesn't break their current set-ups (does it? Especially LPC32xx)
I intend to test this, but it might be a couple of days. I need to bring the damn thing out of the closet and find the right cables etc etc. And I of course have other stuff to do as well...
Quoted 8 lines
- We need a migration plan: everything that was selecting
GPIO_SX150Xbefore should now select this instead. Just let theKconfigentry in thedrivers/gpio/Kconfigselect this new driver?- Make sure it is a slot-in replacement. Else make sure it is.
Quoted 7 lines
- Delete the old sx150x driver from
drivers/gpioin the same patch. I'd hate to maintain them side by side. If I apply this, the old one must go out at the same time. Conversely I can revert the patch and get the old driver back.- Strangely I don't see refernces to this driver in any device tree. Are people not upstreaming their boards?
No, we have not, because we depend on yet to be upstreamed drivers for all of our boards, sometimes written by us, sometimes from the CPU vendor. For this driver, we were using a rejected patch to configure the pins from DT in the gpio driver written by Wei Chen [1] that I adapted to also handle sx1502. I in fact had vague plans to move sx150x over to pinctrl myself so this is most welcome. It also means that *we* do not really need it to be a slot-in replacement, as there will be DT changes for our board because of this anyway given that we will have to back out that old gpio-dt patch. But that is not a problem *for* *us*, and I'll be pleased to take the churn, assuming it works in the end :-)
One thing I noted at the very end of the patch was that I on first glance did not see any i2c_del_driver call, maybe use the module_i2c_driver macro?
Cheers,
Peter
[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2015-January/316615.html
Hi Linus, Peter,
Quoted 12 lines · Peter Rosin
Quoted 11 lines · Linus Walleij
Quoted 8 lines · Neil Armstrong
Since the I2C sx150x GPIO expander driver uses
platform_datato managed the pins configurations, rewrite the driver as a pinctrl driver using pinconf to get pin configurations from DT.The pinctrl driver is functionnally as the gpio-only driver equivalent and can use DT for pinconf.
Signed-off-by Neil Armstrong <[email protected]>
Quoted 7 lines
Quoted 7 lines
Overall I'd say this is a nice rewrite. I'd like the following:
- Include Peter Rosin, Wei Chen, Roland Stigge and Vladimir Zapolskiy on subsequent posts
(Added on To:) ideally I want Tested-by: tags from them to verify that it doesn't break their current set-ups (does it? Especially LPC32xx)
Sure, I will need certainly need one of their tested-by tag.
Quoted 4 lines
I intend to test this, but it might be a couple of days. I need to bring the damn thing out of the closet and find the right cables etc etc. And I of course have other stuff to do as well...
Is it a DT only platform you intent to test with ? In this case the current version is OK.
Quoted 8 lines
Quoted 8 lines
- We need a migration plan: everything that was selecting
GPIO_SX150Xbefore should now select this instead. Just let theKconfigentry in thedrivers/gpio/Kconfigselect this new driver?- Make sure it is a slot-in replacement. Else make sure it is.
It was my main interrogation, should I drop the gpio version, but ...
To make a slot-in replacement, it misses the sx150x_platform_data management like the gpio version, I only made a pure DT version. It should be easy to add back.
But I see it nowhere... is it really necessary ?
I works as a simple i2c device, even while injecting it at runtime via sysfs new_device.
One other question : the gpio version was intended to be built without OF at all,
I hope this will not collide with the pinctrl version (even if I can omit the pinctrl stuff if !OF)
Quoted 5 lines
Quoted 5 lines
- Delete the old sx150x driver from
drivers/gpioin the same patch. I'd hate to maintain them side by side. If I apply this, the old one must go out at the same time. Conversely I can revert the patch and get the old driver back.
Seems legit. I will select the PINCTRL config.
Quoted 9 lines
Quoted 3 lines
- Strangely I don't see refernces to this driver in any device tree. Are people not upstreaming their boards?
No, we have not, because we depend on yet to be upstreamed drivers for all of our boards, sometimes written by us, sometimes from the CPU vendor. For this driver, we were using a rejected patch to configure the pins from DT in the gpio driver written by Wei Chen [1]
Actually it seems the patch was accepted, but it is not enough to handle DT completely since the gpio base is incorrect, this was the subject of my previous patch [2], make is DT compliant even for IRQ management. But having a pinctrl version seens far more reasonable.
Quoted 11 lines
that I adapted to also handle sx1502. I in fact had vague plans to move sx150x over to pinctrl myself so this is most welcome. It also means that *we* do not really need it to be a slot-in replacement, as there will be DT changes for our board because of this anyway given that we will have to back out that old gpio-dt patch. But that is not a problem *for* *us*, and I'll be pleased to take the churn, assuming it works in the end :-)
One thing I noted at the very end of the patch was that I on first glance did not see any
i2c_del_drivercall, maybe use themodule_i2c_drivermacro?
Well, it's not present in the gpio version and since it manages IRQs, I assume it was decided to not use is as a module since it's needed to attach very early.
Quoted 6 lines
Cheers,
Peter[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2015-January/316615.html
[2] http://lkml.kernel.org/r/[email protected]
Neil
Quoted 8 lines · Neil Armstrong
Hi Linus, Peter,
Quoted 3 lines · Peter Rosin
I intend to test this, but it might be a couple of days. I need to bring the damn thing out of the closet and find the right cables etc etc. And I of course have other stuff to do as well...
Is it a DT only platform you intent to test with ? In this case the current version is OK.
Yes, it's DT-only, but I don't expect it to be compatible as I linked the wrong patch, see below...
*snip*
Quoted 10 lines
Quoted 5 lines
No, we have not, because we depend on yet to be upstreamed drivers for all of our boards, sometimes written by us, sometimes from the CPU vendor. For this driver, we were using a rejected patch to configure the pins from DT in the gpio driver written by Wei Chen [1]
Actually it seems the patch was accepted, but it is not enough to handle DT completely since the gpio base is incorrect, this was the subject of my previous patch [2], make is DT compliant even for IRQ management. But having a pinctrl version seens far more reasonable.
Oh crap, wrong link... Here's a better one:
https://patchwork.kernel.org/patch/5437921/
Quoted 6 lines
Quoted 3 lines
One thing I noted at the very end of the patch was that I on first glance did not see any
i2c_del_drivercall, maybe use themodule_i2c_drivermacro?Well, it's not present in the gpio version and since it manages IRQs, I assume it was decided to not use is as a module since it's needed to attach very early.
I just noted the omission, someone else will shirley know better than me about what to do about it...
(BTW, we're not using interrupts)
Cheers,
Peter
Quoted 4 lines · Neil Armstrong
To make a slot-in replacement, it misses the
sx150x_platform_datamanagement like the gpio version, I only made a pure DT version. It should be easy to add back.But I see it nowhere... is it really necessary ?
If that is not used in the kernel, don't care to support it. We're not designing for out-of-tree usecases, and here apparently out-of-tree patches would be needed to make use of it.
Yours,
Linus Walleij