Location for a kind of GPIO bus driver
Hi,
I am currently working on converting the LED driver leds-netxbig to DT. Doing so, I am also considering to move the GPIO extension bus functions (which are currently parts of leds-netxbig) into a separate driver.
On the LaCie "Big Network" board family (netxbig), the LEDs are controlled by a CPLD. In turn, the CPLD can be configured (mostly the LEDs modes) through a kind of parallel GPIO bus, called GPIO extension bus. Two registers (address and data) are exposed. Each of them is made up of several GPIOs. An extra GPIO is used to notify the CPLD that the registers have been updated. The leds-netxbig driver uses some dedicated functions (prefixed by "gpio_ext_") to handle the GPIO bus extension.
On the latest "Big Network" boards, this bus is also used to enable the PM wakeup sources: the CPLD can be asked to keep powered some devices (as the RTC or the Ethernet PHY) while the board is down. I think it could be nice to expose this feature to the userland. That's why I am thinking about moving the GPIO extension bus support into a separate driver. The problem is that I can't find a proper location for a such driver. AFAIK, it doesn't fit with anything existing supported by Linux. Maybe I should consider drivers/bus ? Or even drivers/misc ?
Also from a DT point, it not clear to me how the resulting bus and LEDs driver are going to work together.
Any advice is welcome. Thanks in advance.
Simon
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130723/14d4cf33/attachment.sig>
Quoted 14 lines · Simon Guinot
Hi,
I am currently working on converting the LED driver leds-netxbig to DT. Doing so, I am also considering to move the GPIO extension bus functions (which are currently parts of leds-netxbig) into a separate driver.
On the LaCie "Big Network" board family (netxbig), the LEDs are controlled by a CPLD. In turn, the CPLD can be configured (mostly the LEDs modes) through a kind of parallel GPIO bus, called GPIO extension bus. Two registers (address and data) are exposed. Each of them is made up of several GPIOs. An extra GPIO is used to notify the CPLD that the registers have been updated. The leds-netxbig driver uses some dedicated functions (prefixed by "
gpio_ext_") to handle the GPIO bus extension.
Quoted 8 lines
On the latest "Big Network" boards, this bus is also used to enable the PM wakeup sources: the CPLD can be asked to keep powered some devices (as the RTC or the Ethernet PHY) while the board is down. I think it could be nice to expose this feature to the userland. That's why I am thinking about moving the GPIO extension bus support into a separate driver. The problem is that I can't find a proper location for a such driver. AFAIK, it doesn't fit with anything existing supported by Linux. Maybe I should consider
drivers/bus? Or evendrivers/misc?
iiuc, the CPLD is more of gpio multiplexer/expander. Have you seen
66bcb58 arm: mvebu: enable gpio expander over i2c on Mirabox platform
? And the corresponding driver, drivers/gpio/gpio-pca953x.c?
I would try drivers/gpio. If there are complaints, it should be trivial to move it in a new version of the series.
Is there any reason why the new capabilities in the "Big Network" boards couldn't be covered by gpio-regulator?
thx,
Jason.
Quoted 15 lines · Jason Cooper
Quoted 14 lines · Simon Guinot
Hi,
I am currently working on converting the LED driver leds-netxbig to DT. Doing so, I am also considering to move the GPIO extension bus functions (which are currently parts of leds-netxbig) into a separate driver.
On the LaCie "Big Network" board family (netxbig), the LEDs are controlled by a CPLD. In turn, the CPLD can be configured (mostly the LEDs modes) through a kind of parallel GPIO bus, called GPIO extension bus. Two registers (address and data) are exposed. Each of them is made up of several GPIOs. An extra GPIO is used to notify the CPLD that the registers have been updated. The leds-netxbig driver uses some dedicated functions (prefixed by "
gpio_ext_") to handle the GPIO bus extension.
Quoted 8 lines
Quoted 8 lines
On the latest "Big Network" boards, this bus is also used to enable the PM wakeup sources: the CPLD can be asked to keep powered some devices (as the RTC or the Ethernet PHY) while the board is down. I think it could be nice to expose this feature to the userland. That's why I am thinking about moving the GPIO extension bus support into a separate driver. The problem is that I can't find a proper location for a such driver. AFAIK, it doesn't fit with anything existing supported by Linux. Maybe I should consider
drivers/bus? Or evendrivers/misc?
Hi Jason,
Thanks for your answer.
Quoted 6 lines
iiuc, the CPLD is more of gpio multiplexer/expander. Have you seen
66bcb58 arm: mvebu: enable gpio expander over i2c on Mirabox platform
? And the corresponding driver,
drivers/gpio/gpio-pca953x.c?
All the drivers under drivers/gpio are registering some GPIO chips. It is a big difference with the LaCie "GPIO extension bus". This last is more an extension mechanism on the top of GPIOs already existing (eventually provided by a SoC or a Super-I/O on x86 boards). No new GPIOs are added. I think that the name "extension" is quite confusing.
The idea behind this "bus" is to allow to configure a lot of LEDs (in various modes) using only few GPIOs and a CPLD (which is already available on the board for other purposes). This cheap solution allows precisely to save the cost of a GPIO expander :)
As an example, you can see the "GPIO extension bus" configuration for the Kirkwood "Big Network" boards in:arch/arm/mach-kirkwood/netxbig_v2-setup.c:132.
Quoted 3 lines
I would try
drivers/gpio. If there are complaints, it should be trivial to move it in a new version of the series.
Why not, as long it is clear that the resulting driver will not provide a GPIO chip but rather functions as a library.
Quoted 3 lines
Is there any reason why the new capabilities in the "Big Network" boards couldn't be covered by gpio-regulator?
I don't have looked at the details but I think that gpio-regulator could be able to configure the PM modes through the GPIO extension bus.
But a problem remains. The same GPIOs would be used by two different
drivers: leds-netxbig and gpio-regulator. This would lead to some conflicts. That's why I think that at some level a driver is needed to handle the GPIO extension bus.
Regards,
Simon
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130725/c2ada4ec/attachment.sig>
Quoted 34 lines · Simon Guinot
Quoted 15 lines · Jason Cooper
Quoted 14 lines · Simon Guinot
Hi,
I am currently working on converting the LED driver leds-netxbig to DT. Doing so, I am also considering to move the GPIO extension bus functions (which are currently parts of leds-netxbig) into a separate driver.
On the LaCie "Big Network" board family (netxbig), the LEDs are controlled by a CPLD. In turn, the CPLD can be configured (mostly the LEDs modes) through a kind of parallel GPIO bus, called GPIO extension bus. Two registers (address and data) are exposed. Each of them is made up of several GPIOs. An extra GPIO is used to notify the CPLD that the registers have been updated. The leds-netxbig driver uses some dedicated functions (prefixed by "
gpio_ext_") to handle the GPIO bus extension.Quoted 8 lines
Quoted 8 lines
On the latest "Big Network" boards, this bus is also used to enable the PM wakeup sources: the CPLD can be asked to keep powered some devices (as the RTC or the Ethernet PHY) while the board is down. I think it could be nice to expose this feature to the userland. That's why I am thinking about moving the GPIO extension bus support into a separate driver. The problem is that I can't find a proper location for a such driver. AFAIK, it doesn't fit with anything existing supported by Linux. Maybe I should consider
drivers/bus? Or evendrivers/misc?Hi Jason,
Thanks for your answer.
Quoted 5 lines
iiuc, the CPLD is more of gpio multiplexer/expander. Have you seen
66bcb58 arm: mvebu: enable gpio expander over i2c on Mirabox platform
Quoted 7 lines
Quoted 1 line
? And the corresponding driver,
drivers/gpio/gpio-pca953x.c?All the drivers under
drivers/gpioare registering some GPIO chips. It is a big difference with the LaCie "GPIO extension bus". This last is more an extension mechanism on the top of GPIOs already existing (eventually provided by a SoC or a Super-I/O on x86 boards). No new GPIOs are added. I think that the name "extension" is quite confusing.
Agreed.
Quoted 10 lines
The idea behind this "bus" is to allow to configure a lot of LEDs (in various modes) using only few GPIOs and a CPLD (which is already available on the board for other purposes). This cheap solution allows precisely to save the cost of a GPIO expander :)
As an example, you can see the "GPIO extension bus" configuration for the Kirkwood "Big Network" boards in:
arch/arm/mach-kirkwood/netxbig_v2-setup.c:132.Quoted 1 line
Quoted 5 lines
Quoted 2 lines
I would try
drivers/gpio. If there are complaints, it should be trivial to move it in a new version of the series.Why not, as long it is clear that the resulting driver will not provide a GPIO chip but rather functions as a library.
right, but the end result of what the library would do is expose a series of LEDs and PM 'virtual gpios'. So, even though it's not a gpio expander per-se, it's still filling that role. Or am I still missing something?
Quoted 10 lines
Quoted 2 lines
Is there any reason why the new capabilities in the "Big Network" boards couldn't be covered by gpio-regulator?
I don't have looked at the details but I think that gpio-regulator could be able to configure the PM modes through the GPIO extension bus.
But a problem remains. The same GPIOs would be used by two different
drivers: leds-netxbig and gpio-regulator. This would lead to some conflicts. That's why I think that at some level a driver is needed to handle the GPIO extension bus.
It may be simpler to combine it into one driver and place it under drivers/mfd as it's certainly a multi-function device. I don't think anyone outside of Lacie is going to be adopting this 'bus'...
thx,
Jason.
Quoted 58 lines · Jason Cooper
Quoted 34 lines · Simon Guinot
Quoted 15 lines · Jason Cooper
Quoted 14 lines · Simon Guinot
Hi,
I am currently working on converting the LED driver leds-netxbig to DT. Doing so, I am also considering to move the GPIO extension bus functions (which are currently parts of leds-netxbig) into a separate driver.
On the LaCie "Big Network" board family (netxbig), the LEDs are controlled by a CPLD. In turn, the CPLD can be configured (mostly the LEDs modes) through a kind of parallel GPIO bus, called GPIO extension bus. Two registers (address and data) are exposed. Each of them is made up of several GPIOs. An extra GPIO is used to notify the CPLD that the registers have been updated. The leds-netxbig driver uses some dedicated functions (prefixed by "
gpio_ext_") to handle the GPIO bus extension.Quoted 8 lines
Quoted 8 lines
On the latest "Big Network" boards, this bus is also used to enable the PM wakeup sources: the CPLD can be asked to keep powered some devices (as the RTC or the Ethernet PHY) while the board is down. I think it could be nice to expose this feature to the userland. That's why I am thinking about moving the GPIO extension bus support into a separate driver. The problem is that I can't find a proper location for a such driver. AFAIK, it doesn't fit with anything existing supported by Linux. Maybe I should consider
drivers/bus? Or evendrivers/misc?Hi Jason,
Thanks for your answer.
Quoted 5 lines
iiuc, the CPLD is more of gpio multiplexer/expander. Have you seen
66bcb58 arm: mvebu: enable gpio expander over i2c on Mirabox platform
Quoted 7 lines
Quoted 1 line
? And the corresponding driver,
drivers/gpio/gpio-pca953x.c?All the drivers under
drivers/gpioare registering some GPIO chips. It is a big difference with the LaCie "GPIO extension bus". This last is more an extension mechanism on the top of GPIOs already existing (eventually provided by a SoC or a Super-I/O on x86 boards). No new GPIOs are added. I think that the name "extension" is quite confusing.Agreed.
Quoted 13 lines
The idea behind this "bus" is to allow to configure a lot of LEDs (in various modes) using only few GPIOs and a CPLD (which is already available on the board for other purposes). This cheap solution allows precisely to save the cost of a GPIO expander :)
As an example, you can see the "GPIO extension bus" configuration for the Kirkwood "Big Network" boards in:
arch/arm/mach-kirkwood/netxbig_v2-setup.c:132.Quoted 3 lines
I would try
drivers/gpio. If there are complaints, it should be trivial to move it in a new version of the series.
Quoted 7 lines
Quoted 2 lines
Why not, as long it is clear that the resulting driver will not provide a GPIO chip but rather functions as a library.
right, but the end result of what the library would do is expose a series of LEDs and PM 'virtual gpios'. So, even though it's not a gpio expander per-se, it's still filling that role. Or am I still missing something?
The library could expose a function allowing to set the address and data
registers: gpio_ext_set_value(int addr, int value).
Actually, it is how it works inside leds-netxbig. Simply this function would be also accessible by other drivers.
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Is there any reason why the new capabilities in the "Big Network" boards couldn't be covered by gpio-regulator?
I don't have looked at the details but I think that gpio-regulator could be able to configure the PM modes through the GPIO extension bus.
Quoted 8 lines
Quoted 4 lines
But a problem remains. The same GPIOs would be used by two different
drivers: leds-netxbig and gpio-regulator. This would lead to some conflicts. That's why I think that at some level a driver is needed to handle the GPIO extension bus.It may be simpler to combine it into one driver and place it under
drivers/mfdas it's certainly a multi-function device. I don't think anyone outside of Lacie is going to be adopting this 'bus'...
I will definitively have a closer look at mfd. But as I understand, mfd is more oriented platform device and resources. Here, the device don't expose some memory regions but rather methods to configure a CPLD through GPIOs. I am not sure how it can work with the mfd framework.
Thanks,
Simon
Quoted 9 lines
thx,
Jason.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130726/e2ae24b0/attachment.sig>
Quoted 67 lines · Simon Guinot
Quoted 58 lines · Jason Cooper
Quoted 34 lines · Simon Guinot
Quoted 15 lines · Jason Cooper
Quoted 14 lines · Simon Guinot
Hi,
I am currently working on converting the LED driver leds-netxbig to DT. Doing so, I am also considering to move the GPIO extension bus functions (which are currently parts of leds-netxbig) into a separate driver.
On the LaCie "Big Network" board family (netxbig), the LEDs are controlled by a CPLD. In turn, the CPLD can be configured (mostly the LEDs modes) through a kind of parallel GPIO bus, called GPIO extension bus. Two registers (address and data) are exposed. Each of them is made up of several GPIOs. An extra GPIO is used to notify the CPLD that the registers have been updated. The leds-netxbig driver uses some dedicated functions (prefixed by "
gpio_ext_") to handle the GPIO bus extension.Quoted 8 lines
Quoted 8 lines
On the latest "Big Network" boards, this bus is also used to enable the PM wakeup sources: the CPLD can be asked to keep powered some devices (as the RTC or the Ethernet PHY) while the board is down. I think it could be nice to expose this feature to the userland. That's why I am thinking about moving the GPIO extension bus support into a separate driver. The problem is that I can't find a proper location for a such driver. AFAIK, it doesn't fit with anything existing supported by Linux. Maybe I should consider
drivers/bus? Or evendrivers/misc?Hi Jason,
Thanks for your answer.
Quoted 5 lines
iiuc, the CPLD is more of gpio multiplexer/expander. Have you seen
66bcb58 arm: mvebu: enable gpio expander over i2c on Mirabox platform
Quoted 7 lines
Quoted 1 line
? And the corresponding driver,
drivers/gpio/gpio-pca953x.c?All the drivers under
drivers/gpioare registering some GPIO chips. It is a big difference with the LaCie "GPIO extension bus". This last is more an extension mechanism on the top of GPIOs already existing (eventually provided by a SoC or a Super-I/O on x86 boards). No new GPIOs are added. I think that the name "extension" is quite confusing.Agreed.
Quoted 13 lines
The idea behind this "bus" is to allow to configure a lot of LEDs (in various modes) using only few GPIOs and a CPLD (which is already available on the board for other purposes). This cheap solution allows precisely to save the cost of a GPIO expander :)
As an example, you can see the "GPIO extension bus" configuration for the Kirkwood "Big Network" boards in:
arch/arm/mach-kirkwood/netxbig_v2-setup.c:132.Quoted 3 lines
I would try
drivers/gpio. If there are complaints, it should be trivial to move it in a new version of the series.Quoted 7 lines
Quoted 2 lines
Why not, as long it is clear that the resulting driver will not provide a GPIO chip but rather functions as a library.
right, but the end result of what the library would do is expose a series of LEDs and PM 'virtual gpios'. So, even though it's not a gpio expander per-se, it's still filling that role. Or am I still missing something?
Quoted 5 lines
The library could expose a function allowing to set the address and data
registers:gpio_ext_set_value(int addr, int value).Actually, it is how it works inside leds-netxbig. Simply this function would be also accessible by other drivers.
hmmm, at this point I'm inclined to say "post the code RFC" :-) We can bikeshed it all day long, and not get any further. And to answer your original question, put the library under drivers/bus. Maybe something like lacie_gpio?
thx,
Jason.
Quoted 14 lines · Simon Guinot
Quoted 5 lines · Jason Cooper
Quoted 3 lines · Simon Guinot
Quoted 2 lines
I would try
drivers/gpio. If there are complaints, it should be trivial to move it in a new version of the series.Quoted 7 lines
Quoted 2 lines
Why not, as long it is clear that the resulting driver will not provide a GPIO chip but rather functions as a library.
right, but the end result of what the library would do is expose a series of LEDs and PM 'virtual gpios'. So, even though it's not a gpio expander per-se, it's still filling that role. Or am I still missing something?
Quoted 5 lines
The library could expose a function allowing to set the address and data
registers:gpio_ext_set_value(int addr, int value).Actually, it is how it works inside leds-netxbig. Simply this function would be also accessible by other drivers.
With that prototype it still sounds like a regular gpiochip driver would fit that role well, since the function you describe is just like gpio_set_value().
Maybe you can post the driver to let others understand what you are trying to do if it's not just a gpio expander.
Arnd
Quoted 5 lines · Simon Guinot
(...) I am
thinking about moving the GPIO extension bus support into a separate driver. The problem is that I can't find a proper location for a such driver. AFAIK, it doesn't fit with anything existing supported by Linux. Maybe I should considerdrivers/bus? Or evendrivers/misc?
This is a question to Greg, the device core maintainer. AFAICT they go into drivers/base/foo-bus.c
In this case I would first consider using MFD though, please make a case for why this is not simply a multi function device with a few cells (== platform devices).
Quoted 2 lines
Also from a DT point, it not clear to me how the resulting bus and LEDs driver are going to work together.
Buses are nodes in the device tree and subdevices are subnodes.
Yours,
Linus Walleij
Quoted 10 lines · Linus Walleij
Quoted 5 lines · Simon Guinot
(...) I am
thinking about moving the GPIO extension bus support into a separate driver. The problem is that I can't find a proper location for a such driver. AFAIK, it doesn't fit with anything existing supported by Linux. Maybe I should considerdrivers/bus? Or evendrivers/misc?This is a question to Greg, the device core maintainer. AFAICT they go into
drivers/base/foo-bus.c
No, specific bus code does not go in drivers/base/ it goes where the rest of the subsystem lives.
Quoted 3 lines
In this case I would first consider using MFD though, please make a case for why this is not simply a multi function device with a few cells (== platform devices).
I agree with this as well.
thanks,
greg k-h
Quoted 9 lines · Greg KH
Quoted 8 lines · Linus Walleij
Quoted 5 lines · Simon Guinot
(...) I am
thinking about moving the GPIO extension bus support into a separate driver. The problem is that I can't find a proper location for a such driver. AFAIK, it doesn't fit with anything existing supported by Linux. Maybe I should considerdrivers/bus? Or evendrivers/misc?
Quoted 5 lines
Quoted 2 lines
This is a question to Greg, the device core maintainer. AFAICT they go into
drivers/base/foo-bus.cNo, specific bus code does not go in
drivers/base/it goes where the rest of the subsystem lives.
We were thinking drivers/bus since it is addressable and has multiple devices hanging off of it (leds, power management).
However, since each device is essentially an external gpio, drivers/gpio might be more appropriate. It's not a gpio expander, more of an enhanced gpio controller (led 1, brightness 7)
Quoted 5 lines
Quoted 3 lines
In this case I would first consider using MFD though, please make a case for why this is not simply a multi function device with a few cells (== platform devices).
I agree with this as well.
To quote Simon from a different response:
Quoted 5 lines
I will definitively have a closer look at mfd. But as I understand, mfd is more oriented platform device and resources. Here, the device don't expose some memory regions but rather methods to configure a CPLD through GPIOs. I am not sure how it can work with the mfd framework.
thx,
Jason.