reset: Add driver for gpio-controlled reset pins
Subsystems (2)
Philipp Zabel
maintainerPATCH v11 1/1 reset: Add driver for gpio-controlled reset pins
This driver implements a reset controller device that toggle a gpio connected to a reset pin of a peripheral IC. The delay between assertion and de-assertion of the reset signal can be configured via device tree.
---
Changes since v10:
- Backed out the arch_initcall change again, use module_platform_driver
--- .../devicetree/bindings/reset/gpio-reset.txt | 35 +++++ drivers/reset/Kconfig | 11 ++ drivers/reset/Makefile | 1 + drivers/reset/gpio-reset.c | 174 +++++++++++++++++++++ 4 files changed, 221 insertions(+) create mode 100644 Documentation/devicetree/bindings/reset/gpio-reset.txt create mode 100644 drivers/reset/gpio-reset.c
Documentation/devicetree/bindings/reset/gpio-reset.txt new file +35 -0
@@ -0,0 +1,35 @@ +GPIO reset controller +===================== + +A GPIO reset controller controls a single GPIO that is connected to the reset +pin of a peripheral IC. Please also refer to reset.txt in this directory for +common reset controller binding usage. + +Required properties: +- compatible: Should be "gpio-reset" +- reset-gpios: A gpio used as reset line. The gpio specifier for this property + depends on the gpio controller that provides the gpio. +- #reset-cells: 0, see below + +Optional properties: +- reset-delay-us: delay in microseconds. The gpio reset line will be asserted for + this duration to reset. +- initially-in-reset: boolean. If not set, the initial state should be a + deasserted reset line. If this property exists, the + reset line should be kept in reset. + +example: + +sii902x_reset: gpio-reset { + compatible = "gpio-reset"; + reset-gpios = <&gpio5 0 GPIO_ACTIVE_LOW>; + reset-delay-us = <10000>; + initially-in-reset; + #reset-cells = <0>; +}; + +/* Device with nRESET pin connected to GPIO5_0 */ +sii902x at 39 { + /* ... */ + resets = <&sii902x_reset>; /* active-low GPIO5_0, 10 ms delay */ +};
drivers/reset/Kconfig +11 -0
@@ -11,3 +11,14 @@ menuconfig RESET_CONTROLLER via GPIOs or SoC-internal reset controller modules. If unsure, say no. + +if RESET_CONTROLLER + +config RESET_GPIO + tristate "GPIO reset controller support" + depends on GPIOLIB && OF + help + This driver provides support for reset lines that are controlled + directly by GPIOs. + +endif
drivers/reset/Makefile +1 -0
@@ -1 +1,2 @@ obj-$(CONFIG_RESET_CONTROLLER) += core.o +obj-$(CONFIG_RESET_GPIO) += gpio-reset.o
drivers/reset/gpio-reset.c new file +174 -0
174 lines not on this page · raw message
Signature · 1 line
1.8.3.2
PATCH v11 1/1 reset: Add driver for gpio-controlled reset pins
drivers/reset/gpio-reset.c line 23
Quoted 8 lines · Philipp Zabel
drivers/reset/gpio-reset.c new file +8
-0+#include <linux/platform_device.h> +#include <linux/reset-controller.h> + +struct gpio_reset_data { +struct reset_controller_dev rcdev; +unsigned int gpio; +bool active_low; +s32 delay_us;
Maybe I missed it, why is this signed? Do we plan to have negative time delays?
Review
Quoted 3 lines
(quoted diff) +2
-0+ +static struct reset_control_ops gpio_reset_ops = {
const?
Quoted 5 lines
drivers/reset/gpio-reset.c new file +4
-0+ .reset = gpio_reset, + .assert = gpio_reset_assert, + .deassert = gpio_reset_deassert, +};
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
PATCH v11 1/1 reset: Add driver for gpio-controlled reset pins
In reply to Philipp ZabelQuoted 6 lines · Philipp Zabel
This driver implements a reset controller device that toggle a gpio connected to a reset pin of a peripheral IC. The delay between assertion and de-assertion of the reset signal can be configured via device tree.
Signed-off-by Philipp Zabel<[email protected]>Reviewed-by Stephen Warren<[email protected]>
[snip]
drivers/reset/gpio-reset.c line 156
Quoted 4 lines
drivers/reset/gpio-reset.c new file +4
-0+static struct of_device_id gpio_reset_dt_ids[] = { + { .compatible ="gpio-reset" }, + { } +};
I think you need the following:MODULE_DEVICE_TABLE(of, gpio_reset_dt_ids);
Quoted 17 lines
drivers/reset/gpio-reset.c new file +17
-0+static struct platform_driver gpio_reset_driver = { + .probe = gpio_reset_probe, + .remove = gpio_reset_remove, + .driver = { + .name ="gpio-reset" , + .owner =THIS_MODULE , + .of_match_table =of_match_ptr (gpio_reset_dt_ids), + }, +}; + +module_platform_driver (gpio_reset_driver); + +MODULE_AUTHOR ("Philipp Zabel<[email protected]>" ); +MODULE_DESCRIPTION ("gpio reset controller" ); +MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("platform:gpio-reset" ); +MODULE_DEVICE_TABLE (of, gpio_reset_dt_ids);
Signature · 2 lines
Ben Dooks http://www.codethink.co.uk/ Senior Engineer Codethink - Providing Genius
PATCH v11 1/1 reset: Add driver for gpio-controlled reset pins
Quoted 10 lines · Ben Dooks
Quoted 6 lines · Philipp Zabel
This driver implements a reset controller device that toggle a gpio connected to a reset pin of a peripheral IC. The delay between assertion and de-assertion of the reset signal can be configured via device tree.
Signed-off-by Philipp Zabel<[email protected]>Reviewed-by Stephen Warren<[email protected]>[snip]
Quoted 7 lines
drivers/reset/gpio-reset.c line 156
Quoted 4 lines
drivers/reset/gpio-reset.c new file +4
-0+static struct of_device_id gpio_reset_dt_ids[] = { + { .compatible ="gpio-reset" }, + { } +};I think you need the following:
MODULE_DEVICE_TABLE(of, gpio_reset_dt_ids);
It's already there, at bottom of the file. But if I'm not mistaken the common practice is to keep it together with the actual array definition. At least that's the case with, e.g. EXPORT_SYMBOL*.
Quoted 6 lines
Quoted 6 lines
+static struct
platform_drivergpio_reset_driver= {
+ .probe =gpio_reset_probe,
+ .remove =gpio_reset_remove,
+ .driver = {
+ .name = "gpio-reset",
+ .owner =THIS_MODULE,
Quoted 8 lines
drivers/reset/gpio-reset.c line 171
Quoted 8 lines
+ .of_match_table =
of_match_ptr(gpio_reset_dt_ids),
+ },drivers/reset/gpio-reset.c new file +6
-0+}; + +module_platform_driver (gpio_reset_driver); + +MODULE_AUTHOR ("Philipp Zabel<[email protected]>" ); +MODULE_DESCRIPTION ("gpio reset controller" );
nit: shouldn't gpio be capitalized ?
Quoted 3 lines
drivers/reset/gpio-reset.c line 174
Quoted 3 lines
drivers/reset/gpio-reset.c new file +3
-0+MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("platform:gpio-reset" ); +MODULE_DEVICE_TABLE (of, gpio_reset_dt_ids);
--
Regards,
Sylwester
PATCH v11 1/1 reset: Add driver for gpio-controlled reset pins
Quoted 40 lines · Sylwester Nawrocki
Quoted 10 lines · Ben Dooks
Quoted 6 lines · Philipp Zabel
This driver implements a reset controller device that toggle a gpio connected to a reset pin of a peripheral IC. The delay between assertion and de-assertion of the reset signal can be configured via device tree.
Signed-off-by Philipp Zabel<[email protected]>Reviewed-by Stephen Warren<[email protected]>[snip]
Quoted 7 lines
drivers/reset/gpio-reset.c line 156
Quoted 4 lines
drivers/reset/gpio-reset.c new file +4
-0+static struct of_device_id gpio_reset_dt_ids[] = { + { .compatible ="gpio-reset" }, + { } +};I think you need the following:
MODULE_DEVICE_TABLE(of, gpio_reset_dt_ids);It's already there, at bottom of the file. But if I'm not mistaken the common practice is to keep it together with the actual array definition. At least that's the case with, e.g. EXPORT_SYMBOL*.
Quoted 6 lines
Quoted 6 lines
+static struct
platform_drivergpio_reset_driver= {
+ .probe =gpio_reset_probe,
+ .remove =gpio_reset_remove,
+ .driver = {
+ .name = "gpio-reset",
+ .owner =THIS_MODULE,Quoted 8 lines
drivers/reset/gpio-reset.c line 171
Quoted 8 lines
+ .of_match_table =
of_match_ptr(gpio_reset_dt_ids),
+ },drivers/reset/gpio-reset.c new file +6
-0+}; + +module_platform_driver (gpio_reset_driver); + +MODULE_AUTHOR ("Philipp Zabel<[email protected]>" ); +MODULE_DESCRIPTION ("gpio reset controller" );nit: shouldn't gpio be capitalized ?
Quoted 7 lines
Quoted 3 lines
drivers/reset/gpio-reset.c line 174
Quoted 3 lines
drivers/reset/gpio-reset.c new file +3
-0+MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("platform:gpio-reset" ); +MODULE_DEVICE_TABLE (of, gpio_reset_dt_ids);--
Regards,
Sylwester
ta, that's why I missed it. Nice if it stays with the table it references.
Signature · 2 lines
Ben Dooks http://www.codethink.co.uk/ Senior Engineer Codethink - Providing Genius