Skip to contentSkip to conversation

power:reset: Add defer reset object to send board specific reset

RFC PATCH Superseded Houcheng Lin 2 participants 3 messages Jun 15, 2014 – Jun 17, 2014

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

RFC PATCH v2 1/1 power:reset: Add defer reset object to send board specific reset

The Problem
-----------
The reset signal on a hardware board is send either:
- during machine initialization
- during bus master's initialization

In some hardware design, devices on bus need a non-standard and extra reset signal after bus is initialied. Most reason is to wake up device from hanging state.

The board spefic reset code can not be put into machine init code, as it is too early. This code can not also be put onto chip's driver, as it is board specific and not suitable for a common chip driver.

Defer Reset Object
------------------
The defer reset object is to resolve this issue, developer can put a defer- reset device on the board's dts file and enable DEFER RESET OBJECT CONFIG. During driver init-calls, a defer-reset object is created and issue reset signal after the enclosing device is initialized.

This eliminate the need to rewrite a driver module with only one purpose: sending a board specific reset. This also allow mainstream kernel to support many boards that modify the common drivers to send board specific reset. Configuring defer-reset device in dts leave the board specific reset rules on board level and simple to maintain.

Example dts File
----------------

    usb-ehci-chip@1211000{
        usb-phy = <&usb2_phy>;
        defer_reset_vbus {
            compatible = "defer-reset";
            reset-gpios = <&gpx3 5 1>;
            reset-init = <0>;
            reset-end = <1>;
            delay = <5>;
        };
    };

Block Diagram of dts File
-------------------------

    +-------------------------------------+
    | usb-ehci-chip@1211000               |
    |   +-------------------------+       |
    |   | defer-reset(gpx3)       |       |
    |   +-------------------------+       |
    +-------------------------------------+
---
 .../devicetree/bindings/gpio/gpio-defer-reset.txt  |  22 +++
 drivers/power/reset/Kconfig                        |   8 +
 drivers/power/reset/Makefile                       |   1 +
 drivers/power/reset/gpio-defer-reset.c             | 192 +++++++++++++++++++++
 4 files changed, 223 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/gpio-defer-reset.txt
 create mode 100644 drivers/power/reset/gpio-defer-reset.c
Documentation/devicetree/bindings/gpio/gpio-defer-reset.txt new file +22 -0
new file mode 100644
index 0000000..5d55830
@@ -0,0 +1,22 @@
+GPIO defer reset binding
+
+Put a defer-reset device in a device node and enable DEFER RESET OBJECT CONFIG.
+During driver init-calls, a defer-reset object will be created and issue reset
+signal after the enclosing device node's initialization complete.
+
+Required properties:
+- compatible:
+  - "defer-reset" for creating defer reset object
+- reset-gpio: specify gpio pin, can be an array.
+- reset-init: specify reset signal initial value, can be 0 or 1.
+- reset-end: specify reset signal end value, can be 0 or 1.
+- delay: specify reset duration in ms.
+
+Example:
+	defer_reset_vbus {
+		compatible = "defer-reset";
+		reset-gpios = <&gpx3 5 1>;
+		reset-init = <0>;
+		reset-end = <1>;
+		delay = <5>;
+	};
drivers/power/reset/Kconfig +8 -0
index fa0e4e0..74b7eb0 100644
@@ -57,3 +57,11 @@ config POWER_RESET_XGENE
 	depends on POWER_RESET
 	help
 	  Reboot support for the APM SoC X-Gene Eval boards.
+
+config GPIO_DEFER_RESET
+	bool "Defer reset driver via gpio"
+	depends on OF_GPIO && POWER_RESET
+	help
+	  Enable defer reset drvier
+	  The reset signal would be issued after a device on USB or PCI bus is initialied.
+	  The dependency of reset signal and device can be specified in board's dts file.
drivers/power/reset/Makefile +1 -0
index a5b4a77..166baf9 100644
@@ -5,3 +5,4 @@ obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o
 obj-$(CONFIG_POWER_RESET_RESTART) += restart-poweroff.o
 obj-$(CONFIG_POWER_RESET_VEXPRESS) += vexpress-poweroff.o
 obj-$(CONFIG_POWER_RESET_XGENE) += xgene-reboot.o
+obj-$(CONFIG_GPIO_DEFER_RESET)	+= gpio-defer-reset.o
drivers/power/reset/gpio-defer-reset.c new file +192 -0

192 lines not on this page · raw message

Signature · 1 line
1.9.1
#1 lore raw

Hi,

Quoted 49 lines · Houcheng Lin

The Problem
-----------
The reset signal on a hardware board is send either:
- during machine initialization
- during bus master's initialization

In some hardware design, devices on bus need a non-standard and extra reset signal after bus is initialied. Most reason is to wake up device from hanging state.

The board spefic reset code can not be put into machine init code, as it is too early. This code can not also be put onto chip's driver, as it is board specific and not suitable for a common chip driver.

Defer Reset Object
------------------
The defer reset object is to resolve this issue, developer can put a defer- reset device on the board's dts file and enable DEFER RESET OBJECT CONFIG. During driver init-calls, a defer-reset object is created and issue reset signal after the enclosing device is initialized.

This eliminate the need to rewrite a driver module with only one purpose: sending a board specific reset. This also allow mainstream kernel to support many boards that modify the common drivers to send board specific reset. Configuring defer-reset device in dts leave the board specific reset rules on board level and simple to maintain.

Example dts File
----------------

    usb-ehci-chip@1211000{
        usb-phy = <&usb2_phy>;
        defer_reset_vbus {
            compatible = "defer-reset";
            reset-gpios = <&gpx3 5 1>;
            reset-init = <0>;
            reset-end = <1>;
            delay = <5>;
        };
    };

Block Diagram of dts File
-------------------------

    +-------------------------------------+
    | usb-ehci-chip@1211000               |
    |   +-------------------------+       |
    |   | defer-reset(gpx3)       |       |
    |   +-------------------------+       |
    +-------------------------------------+
Quoted 6 lines
---
 .../devicetree/bindings/gpio/gpio-defer-reset.txt  |  22 +++
 drivers/power/reset/Kconfig                        |   8 +
 drivers/power/reset/Makefile                       |   1 +
 drivers/power/reset/gpio-defer-reset.c             | 192 +++++++++++++++++++++

I think this belongs to drivers/reset and not to drivers/power/reset. The drivers in drivers/power/reset are about board reboot / shutdown. This driver seems to be used for periphals.

Quoted 11 lines
 4 files changed, 223 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/gpio-defer-reset.txt
 create mode 100644 drivers/power/reset/gpio-defer-reset.c
Documentation/devicetree/bindings/gpio/gpio-defer-reset.txt new file +1 -0
new file mode 100644
index 0000000..5d55830
@@ -0,0 +1,22 @@
+GPIO defer reset binding

Documentation/devicetree/bindings/gpio/gpio-defer-reset.txt line 11

Quoted 10 lines
Documentation/devicetree/bindings/gpio/gpio-defer-reset.txt new file +10 -0
+
+Put a defer-reset device in a device node and enable DEFER RESET OBJECT CONFIG.
+During driver init-calls, a defer-reset object will be created and issue reset
+signal after the enclosing device node's initialization complete.
+
+Required properties:
+- compatible:
+  - "defer-reset" for creating defer reset object
+- reset-gpio: specify gpio pin, can be an array.
+- reset-init: specify reset signal initial value, can be 0 or 1.

You can simply use GPIO's HIGH_ACTIVE / LOW_ACTIVE flag for the "initial value".

Documentation/devicetree/bindings/gpio/gpio-defer-reset.txt line 12

Quoted 1 line
Documentation/devicetree/bindings/gpio/gpio-defer-reset.txt new file +1 -0
+- reset-end: specify reset signal end value, can be 0 or 1.

You can use a property without a value for booleans. If the property is there, the value is 1 and if its missing the value is 0.

For example in your case you could use

hold-reset-line;

to inform the system, that the reset signal should not be changed back after the specified time.

Documentation/devicetree/bindings/gpio/gpio-defer-reset.txt line 13

Quoted 1 line
Documentation/devicetree/bindings/gpio/gpio-defer-reset.txt new file +1 -0
+- delay: specify reset duration in ms.

Alternatively you could do this via the duration. An infinite long reset signal basically means, that the line is never changed back.

Documentation/devicetree/bindings/gpio/gpio-defer-reset.txt line 22

Quoted 9 lines
Documentation/devicetree/bindings/gpio/gpio-defer-reset.txt new file +9 -0
+
+Example:
+	defer_reset_vbus {
+		compatible = "defer-reset";
+		reset-gpios = <&gpx3 5 1>;
+		reset-init = <0>;
+		reset-end = <1>;
+		delay = <5>;
+	};

To give a few examples for the above comments:

/* keep "gpx3 5" low for 5ms, change back to high afterwards */

defer_reset_vbus {
    compatible = "defer-reset";
    reset-gpios = <&gpx3 5 GPIO_ACTIVE_LOW>;
    duration = <5>;
};

/* keep "gpx3 5" high for 5ms, change back to low afterwards */

defer_reset_vbus {
    compatible = "defer-reset";
    reset-gpios = <&gpx3 5 GPIO_ACTIVE_HIGH>;
    duration = <5>;
};

/* keep "gpx3 5" low */

defer_reset_vbus {
    compatible = "defer-reset";
    reset-gpios = <&gpx3 5 GPIO_ACTIVE_LOW>;
    duration = <0>;
};
Quoted 1 line

[...]

-- Sebastian

#2 lore raw

Hi,

2014-06-15 17:09 GMT+08:00 Sebastian Reichel <[email protected]>:

Quoted 4 lines

I think this belongs to drivers/reset and not to drivers/power/reset. The drivers in drivers/power/reset are about board reboot / shutdown. This driver seems to be used for periphals.

Yes, this driver is for pherphials and I think it is reasonble to placed it at drivers/reset. I'll moved it in next release.

Quoted 19 lines

Alternatively you could do this via the duration. An infinite long reset signal basically means, that the line is never changed back.

To give a few examples for the above comments:

/* keep "gpx3 5" low for 5ms, change back to high afterwards */

defer_reset_vbus {
    compatible = "defer-reset";
    reset-gpios = <&gpx3 5 GPIO_ACTIVE_LOW>;
    duration = <5>;
};

/* keep "gpx3 5" high for 5ms, change back to low afterwards */

defer_reset_vbus {
    compatible = "defer-reset";
    reset-gpios = <&gpx3 5 GPIO_ACTIVE_HIGH>;
    duration = <5>;
};
Quoted 5 lines

/* keep "gpx3 5" low */

defer_reset_vbus {
    compatible = "defer-reset";
    reset-gpios = <&gpx3 5 GPIO_ACTIVE_LOW>;
    duration = <0>;

These DT properties looks simpler and better: Use of GPIO_ACTIVE_HIGH and GPIO_ACTIVE_LOW increase readability for HW/SW developer, use of <0> to indicate holding the reset signal. I'll updated code according on this. Thanks for your comments.

Signature · 2 lines
Best regards,
Houcheng Lin