reset: Add generic GPIO reset driver.
Subsystems (2)
PATCH 1/1 reset: Add generic GPIO reset driver.
This driver allows GPIO lines to be used as reset signals. It has two main use cases:
1) Allow drivers to reset their hardware via a GPIO line in a standard fashion as supplied by the reset framework.
This allows adhoc driver code requesting GPIOs etc to be replaced with a single call to device_reset().
2) Allow hardware on discoverable busses to be rest via a GPIO line without driver modifications.
Examples of the second use case include:
* SDIO wifi modules
* USB hub chips with a reset line
In this second use case the reset has to be done externally to the driver managing the hardware since resetting the device from the driver's probe() method will either do nothing (if the device needs to be reset before ennumeration will work) or cause racy beahviour (when the device disappears from the bus during probe()).
So, in addition to providing a gpio based reset controller implementation it is also possible to reset devices at boot via a DT property or from userspace on request via sysfs attributes.
--- Documentation/ABI/testing/sysfs-driver-gpio-reset | 18 + Documentation/devicetree/bindings/reset/gpio.txt | 44 ++ drivers/reset/Kconfig | 13 + drivers/reset/Makefile | 1 drivers/reset/gpio-reset.c | 460 +++++++++++++++++++++ 5 files changed, 536 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-driver-gpio-reset create mode 100644 Documentation/devicetree/bindings/reset/gpio.txt create mode 100644 drivers/reset/gpio-reset.c
Documentation/ABI/testing/sysfs-driver-gpio-reset new file +18 -0
@@ -0,0 +1,18 @@ +In the descriptions below <line-name> is the name of the device tree node +describing the reset line. + +What: /sys/bus/platform/devices/gpio-reset.<ID>/<line-name>/duration_ms +Date: February 2014 +Contact: Martin Fuzzey <[email protected]> +Description: Allows reset duration to be configured + Read: returns reset duration in ms (decimal) + Write: sets new resst duration in ms (decimal) + +What: /sys/bus/platform/devices/gpio-reset.<ID>/<line-name>/control +Date: February 2014 +Contact: Martin Fuzzey <[email protected]> +Description: Allows reset line state to be controlled + Write only accepting the following strings: + "reset" : Line will be asserted during the reset duration then deasserted + "assert" : Line will be asserted until next write operation + "deassert" : Line will be deasserted until the next write operation
Documentation/devicetree/bindings/reset/gpio.txt new file +44 -0
44 lines not on this page · raw message
drivers/reset/Kconfig +13 -0
@@ -11,3 +11,16 @@ menuconfig RESET_CONTROLLER via GPIOs or SoC-internal reset controller modules. If unsure, say no. + +config GPIO_RESET_CONTROLLER + tristate "GPIO reset controller" + help + Reset controller using GPIO lines + + There are two main methods of using this controller: + * As a reset controller within the reset framework allowing device + drivers to request a hardware reset of their devices. + * As a standalone driver performing reset at boot or upon userspace + request (via sysfs) + The second method is suitable for devices on discoverable busses + (SDIO, USB)
drivers/reset/Makefile +1 -0
@@ -1 +1,2 @@ obj-$(CONFIG_RESET_CONTROLLER) += core.o +obj-$(CONFIG_GPIO_RESET_CONTROLLER) += gpio-reset.o
drivers/reset/gpio-reset.c new file +460 -0
460 lines not on this page · raw message
Philipp Zabel
maintainerHi Martin,
Am Montag, den 10.02.2014, 13:54 +0100 schrieb Martin Fuzzey:
Quoted 7 lines
This driver allows GPIO lines to be used as reset signals. It has two main use cases:
1) Allow drivers to reset their hardware via a GPIO line in a standard fashion as supplied by the reset framework.
This allows adhoc driver code requesting GPIOs etc to be replaced with a single call todevice_reset().
have you seen the patch at https://lkml.org/lkml/2014/1/8/190:
"reset: Add GPIO support to reset controller framework" ?
Adding a GPIO reset controller device node to the device tree is the wrong approach for devices enumerated in the device tree. Those should just declare their reset-gpios directly.
Quoted 6 lines
2) Allow hardware on discoverable busses to be rest via a GPIO line without driver modifications.
Examples of the second use case include:
* SDIO wifi modules
* USB hub chips with a reset line
Now this is interesting. But if you export it to userspace anyway, why not use the existing gpio sysfs API?
I think a proper solution should handle this in the kernel. For SDIO wifi modules you usually have a powerdown line that can be implemented as an rfkill switch.
regards
Philipp
Hi Philipp,
Quoted 6 lines · Philipp Zabel
Hi Martin,
Am Montag, den 10.02.2014, 13:54 +0100 schrieb Martin Fuzzey:
Quoted 3 lines
This driver allows GPIO lines to be used as reset signals. It has two main use cases:
Quoted 8 lines
Quoted 4 lines
1) Allow drivers to reset their hardware via a GPIO line in a standard fashion as supplied by the reset framework.
This allows adhoc driver code requesting GPIOs etc to be replaced with a single call todevice_reset().have you seen the patch at https://lkml.org/lkml/2014/1/8/190:
"reset: Add GPIO support to reset controller framework" ?
Ah no missed that.
Quoted 4 lines
Adding a GPIO reset controller device node to the device tree is the wrong approach for devices enumerated in the device tree. Those should just declare their reset-gpios directly.
Oh well if that was the conclusion.
My use case is 2) anyway - just thought it would be sensible to implement a reset controller too.
As that simplifies the driver code and makes gpio / vs more complex reset controller (FPGA, ..) a pure DT change.
I do get the point about having to continue to support the old way anyway though.
Quoted 10 lines
Quoted 6 lines
2) Allow hardware on discoverable busses to be rest via a GPIO line without driver modifications.
Examples of the second use case include:
* SDIO wifi modules
* USB hub chips with a reset lineNow this is interesting. But if you export it to userspace anyway, why not use the existing gpio sysfs API?
In the normal case of reset on boot the userspace interface isn't needed. Setting the "auto" dt property will make the kernel do the reset by itself during
early boot. This is the standard use case.
The userspace interface is to let applications deal with special cases. It is also simpler for userspace than manlually toggling the GPIO line and keeps the configuration (active high / low, delay) centralised in the DT and consistent between the automatic on boot reset and the manually triggered reset.
Quoted 4 lines
I think a proper solution should handle this in the kernel. For SDIO wifi modules you usually have a powerdown line that can be implemented as an rfkill switch.
I think this is too specific. It's not just for SDIO wifi. We also have the problem
of a USB hub needing to be reset.
Also even for the SDIO wifi case rfkill doesn't ssem the right abstraction to say "reset me"
(particularly when firmware fails to load on warm boot if you don't).
cheers,
Martin
Philipp Zabel
maintainerHi Martin,
Am Dienstag, den 11.02.2014, 10:34 +0100 schrieb Fuzzey, Martin:
[...]
Quoted 27 lines
Quoted 10 lines
Quoted 6 lines
2) Allow hardware on discoverable busses to be rest via a GPIO line without driver modifications.
Examples of the second use case include:
* SDIO wifi modules
* USB hub chips with a reset lineNow this is interesting. But if you export it to userspace anyway, why not use the existing gpio sysfs API?
In the normal case of reset on boot the userspace interface isn't needed. Setting the "auto" dt property will make the kernel do the reset by itself during
early boot. This is the standard use case.The userspace interface is to let applications deal with special cases. It is also simpler for userspace than manlually toggling the GPIO line and keeps the configuration (active high / low, delay) centralised in the DT and consistent between the automatic on boot reset and the manually triggered reset.
Quoted 4 lines
I think a proper solution should handle this in the kernel. For SDIO wifi modules you usually have a powerdown line that can be implemented as an rfkill switch.
Quoted 7 lines
I think this is too specific. It's not just for SDIO wifi. We also have the problem
of a USB hub needing to be reset.Also even for the SDIO wifi case rfkill doesn't ssem the right abstraction to say "reset me"
(particularly when firmware fails to load on warm boot if you don't).
so long as you need to take devices out of reset before they can be discovered, maybe the corresponding host controller would be the right place to put the reset.
regards
Philipp