power: add power sequence library
Subsystems (5)
v2 cover power: add power sequence library
Hi all,
This is a follow-up for my last power sequence framework patch set [1]. According to Rob Herring and Ulf Hansson's comments[2], I use a generic power sequence library for parsing the power sequence elements on DT, and implement generic power sequence on library. The host driver can allocate power sequence instance, and calls pwrseq APIs accordingly.
In future, if there are special power sequence requirements, the special power sequence library can be created.
This patch set is tested on i.mx6 sabresx evk using a dts change, I use two hot-plug devices to simulate this use case, the related binding change is updated at patch[1/6], The udoo board changes were tested using my last power sequence patch set.[3]
Except for hard-wired MMC and USB devices, I find the USB ULPI PHY also need to power on itself before it can be found by ULPI bus.
[1] http://www.spinics.net/lists/linux-usb/msg142755.html
[2] http://www.spinics.net/lists/linux-usb/msg143106.html
[3] http://www.spinics.net/lists/linux-usb/msg142815.html
Changes for v2:
- Delete "pwrseq" prefix and clock-names for properties at dt binding
- Should use structure not but its pointer for kzalloc
- Since chipidea core has no of_node, let core's of_node equals glue layer's at core's probe
Peter Chen (6):
binding-doc: power: pwrseq-generic: add binding doc for generic power
sequence library
power: add power sequence library
binding-doc: usb: usb-device: add optional properties for power
sequence
usb: core: add power sequence handling for USB devices
usb: chipidea: let chipidea core device of_node equal's glue layer
device of_node
ARM: dts: imx6qdl-udoo.dtsi: fix onboard USB HUB property
.../bindings/power/pwrseq/pwrseq-generic.txt | 53 ++++++++ .../devicetree/bindings/usb/usb-device.txt | 9 ++ arch/arm/boot/dts/imx6qdl-udoo.dtsi | 27 +++-- drivers/power/Kconfig | 1 + drivers/power/Makefile | 1 + drivers/power/pwrseq/Kconfig | 20 +++ drivers/power/pwrseq/Makefile | 2 + drivers/power/pwrseq/core.c | 79 ++++++++++++ drivers/power/pwrseq/pwrseq_generic.c | 134 +++++++++++++++++++++ drivers/usb/chipidea/core.c | 10 ++ drivers/usb/core/Makefile | 1 + drivers/usb/core/hub.c | 12 +- drivers/usb/core/hub.h | 12 ++ drivers/usb/core/pwrseq.c | 102 ++++++++++++++++ include/linux/power/pwrseq.h | 55 +++++++++ 15 files changed, 502 insertions(+), 16 deletions(-) create mode 100644 Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt create mode 100644 drivers/power/pwrseq/Kconfig create mode 100644 drivers/power/pwrseq/Makefile create mode 100644 drivers/power/pwrseq/core.c create mode 100644 drivers/power/pwrseq/pwrseq_generic.c create mode 100644 drivers/usb/core/pwrseq.c create mode 100644 include/linux/power/pwrseq.h
Signature · 1 line
1.9.1
PATCH v2 1/6 binding-doc: power: pwrseq-generic: add binding doc for generic power sequence library
Add binding doc for generic power sequence library.
--- .../bindings/power/pwrseq/pwrseq-generic.txt | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt
Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt new file +53 -0
@@ -0,0 +1,53 @@ +The generic power sequence library + +Some hard-wired USB/MMC devices need to do power sequence to let the +device work normally, the typical power sequence like: enable USB +PHY clock, toggle reset pin, etc. But current Linux USB driver +lacks of such code to do it, it may cause some hard-wired USB devices +works abnormal or can't be recognized by controller at all. The +power sequence will be done before this device can be found at USB +bus. + +The power sequence properties is under the device node. + +Required properties: +- power-sequence: this device needs to do power sequence before enumeration + +Optional properties: +- clocks: the input clock for device. +- reset-gpios: Should specify the GPIO for reset. +- reset-duration-us: the duration in microsecond for assert reset signal. + +Below is the example of USB power sequence properties on USB device +nodes which have two level USB hubs. + +&usbotg1 { + vbus-supply = <®_usb_otg1_vbus>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_usb_otg1_id>; + status = "okay"; + + #address-cells = <1>; + #size-cells = <0>; + hub: genesys at 1 { + compatible = "usb5e3,608"; + reg = <1>; + + power-sequence; + clocks = <&clks IMX6SX_CLK_CKO>; + reset-gpios = <&gpio4 5 GPIO_ACTIVE_LOW>; /* hub reset pin */ + reset-duration-us = <10>; + + #address-cells = <1>; + #size-cells = <0>; + ethernet: asix at 1 { + compatible = "usbb95,1708"; + reg = <1>; + + power-sequence; + clocks = <&clks IMX6SX_CLK_IPG>; + reset-gpios = <&gpio4 6 GPIO_ACTIVE_LOW>; /* ethernet_rst */ + reset-duration-us = <15>; + }; + }; +};
Signature · 1 line
1.9.1
PATCH v2 1/6 binding-doc: power: pwrseq-generic: add binding doc for generic power sequence library
Am Mittwoch, den 13.07.2016, 10:06 +0800 schrieb Peter Chen:
Quoted 14 lines
Add binding doc for generic power sequence library.
Signed-off-by Peter Chen <[email protected]>--- .../bindings/power/pwrseq/pwrseq-generic.txt | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txtDocumentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt new file +0
-0
Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt line 4
Quoted 4 lines
Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt new file +4
-0@@ -0,0 +1,53 @@ +The generic power sequence library + +Some hard-wired USB/MMC devices need to do power sequence to let the +device work normally,
I would replace "to let the device work normally" with "before the device can be enumerated [on the bus]" here.
Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt line 14
Quoted 11 lines
Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt new file +10
-0the typical power sequence like: enable USB +PHY clock, toggle reset pin, etc. But current Linux USB driver +lacks of such code to do it, it may cause some hard-wired USB devices +works abnormal or can't be recognized by controller at all. The +power sequence will be done before this device can be found at USB +bus. + +The power sequence properties is under the device node. + +Required properties: +- power-sequence: this device needs to do power sequence before enumeration
As Joshua pointed out, is this even needed at all?
Quoted 4 lines
+Optional properties:
+- clocks: the input clock for device. +- reset-gpios: Should specify the GPIO for reset. +- reset-duration-us: the duration in microsecond for assert reset signal.
With the above two issues sorted out,
regards
Philipp
PATCH v2 1/6 binding-doc: power: pwrseq-generic: add binding doc for generic power sequence library
Quoted 9 lines · Philipp Zabel
Am Mittwoch, den 13.07.2016, 10:06 +0800 schrieb Peter Chen:
Quoted 8 lines
Add binding doc for generic power sequence library.
Signed-off-by Peter Chen <[email protected]>--- .../bindings/power/pwrseq/pwrseq-generic.txt | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt
Quoted 14 lines
Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt line 4
Quoted 10 lines
Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt new file +4
-0@@ -0,0 +1,53 @@ +The generic power sequence library + +Some hard-wired USB/MMC devices need to do power sequence to let the +device work normally,I would replace "to let the device work normally" with "before the device can be enumerated [on the bus]" here.
Ok.
Quoted 5 lines
Quoted 5 lines
Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt new file +4
-0the typical power sequence like: enable USB +PHY clock, toggle reset pin, etc. But current Linux USB driver +lacks of such code to do it, it may cause some hard-wired USB devices +works abnormal or can't be recognized by controller at all. The +power sequence will be done before this device can be found at USB
Quoted 9 lines
Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt line 14
Quoted 6 lines
Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt new file +6
-0+bus. + +The power sequence properties is under the device node. + +Required properties: +- power-sequence: this device needs to do power sequence before enumerationAs Joshua pointed out, is this even needed at all?
If no, how we decide whether allocates pwrseq instance through pwrseq library or not?
Signature · 2 lines
Best Regards, Peter Chen
PATCH v2 1/6 binding-doc: power: pwrseq-generic: add binding doc for generic power sequence library
Quoted 38 lines · Peter Chen
Quoted 9 lines · Philipp Zabel
Am Mittwoch, den 13.07.2016, 10:06 +0800 schrieb Peter Chen:
Quoted 8 lines
Add binding doc for generic power sequence library.
Signed-off-by Peter Chen <[email protected]>--- .../bindings/power/pwrseq/pwrseq-generic.txt | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txtQuoted 13 lines
Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt line 4
Quoted 10 lines
Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt new file +4
-0@@ -0,0 +1,53 @@ +The generic power sequence library + +Some hard-wired USB/MMC devices need to do power sequence to let the +device work normally,I would replace "to let the device work normally" with "before the device can be enumerated [on the bus]" here.
Ok.
Quoted 4 lines
Quoted 4 lines
Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt new file +3
-0the typical power sequence like: enable USB +PHY clock, toggle reset pin, etc. But current Linux USB driver +lacks of such code to do it, it may cause some hard-wired USB devices +works abnormal or can't be recognized by controller at all. TheQuoted 9 lines
Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt line 14
Quoted 7 lines
Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt new file +7
-0+power sequence will be done before this device can be found at USB +bus. + +The power sequence properties is under the device node. + +Required properties: +- power-sequence: this device needs to do power sequence before enumerationAs Joshua pointed out, is this even needed at all?
Quoted 3 lines
If no, how we decide whether allocates pwrseq instance through pwrseq library or not?
The pwrseq driver is Linux specific. The dts is supposed to be OS agnostic. It seems to me that If a driver supports pwrseq and the dts elements are there, it should use them, e.g. if there is a clock, enable the clock. if there is a reset gpio then take the device into and out of reset during probe.
Can you see a problem with that approach?
PATCH v2 1/6 binding-doc: power: pwrseq-generic: add binding doc for generic power sequence library
Quoted 41 lines · Joshua Clayton
Quoted 38 lines · Peter Chen
Quoted 9 lines · Philipp Zabel
Am Mittwoch, den 13.07.2016, 10:06 +0800 schrieb Peter Chen:
Quoted 8 lines
Add binding doc for generic power sequence library.
Signed-off-by Peter Chen <[email protected]>--- .../bindings/power/pwrseq/pwrseq-generic.txt | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txtQuoted 13 lines
Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt line 4
Quoted 10 lines
Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt new file +4
-0@@ -0,0 +1,53 @@ +The generic power sequence library + +Some hard-wired USB/MMC devices need to do power sequence to let the +device work normally,I would replace "to let the device work normally" with "before the device can be enumerated [on the bus]" here.
Ok.
Quoted 13 lines
Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt line 14
Quoted 11 lines
Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt new file +10
-0the typical power sequence like: enable USB +PHY clock, toggle reset pin, etc. But current Linux USB driver +lacks of such code to do it, it may cause some hard-wired USB devices +works abnormal or can't be recognized by controller at all. The +power sequence will be done before this device can be found at USB +bus. + +The power sequence properties is under the device node. + +Required properties: +- power-sequence: this device needs to do power sequence before enumerationAs Joshua pointed out, is this even needed at all?
Quoted 8 lines
Quoted 3 lines
If no, how we decide whether allocates pwrseq instance through pwrseq library or not?
The pwrseq driver is Linux specific. The dts is supposed to be OS agnostic. It seems to me that If a driver supports pwrseq and the dts elements are there, it should use them, e.g. if there is a clock, enable the clock. if there is a reset gpio then take the device into and out of reset during probe.
I agree with you, will delete this property.
Signature · 2 lines
Best Regards, Peter Chen
Rob Herring
maintainerPATCH v2 1/6 binding-doc: power: pwrseq-generic: add binding doc for generic power sequence library
In reply to Peter ChenQuoted 1 line · Peter Chen
Add binding doc for generic power sequence library.
I'd written a review on last version, but forgot to send it out. Anyway, I mostly had the same comments as Philipp and Joshua. A couple of things they missed...
Quoted 35 lines
Signed-off-by Peter Chen <[email protected]>--- .../bindings/power/pwrseq/pwrseq-generic.txt | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txtDocumentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt new file +22
-0@@ -0,0 +1,53 @@ +The generic power sequence library + +Some hard-wired USB/MMC devices need to do power sequence to let the +device work normally, the typical power sequence like: enable USB +PHY clock, toggle reset pin, etc. But current Linux USB driver +lacks of such code to do it, it may cause some hard-wired USB devices +works abnormal or can't be recognized by controller at all. The +power sequence will be done before this device can be found at USB +bus. + +The power sequence properties is under the device node. + +Required properties: +- power-sequence: this device needs to do power sequence before enumeration + +Optional properties: +- clocks: the input clock for device. +- reset-gpios: Should specify the GPIO for reset. +- reset-duration-us: the duration in microsecond for assert reset signal. + +Below is the example of USB power sequence properties on USB device +nodes which have two level USB hubs.
Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt line 32
Quoted 10 lines
Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt new file +10
-0+ +&usbotg1 { + vbus-supply = <®_usb_otg1_vbus>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_usb_otg1_id>; + status = "okay"; + + #address-cells = <1>; + #size-cells = <0>; + hub: genesys at 1 {
genesys: hub at 1
Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt line 43
Quoted 11 lines
Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt new file +11
-0+ compatible = "usb5e3,608"; + reg = <1>; + + power-sequence; + clocks = <&clks IMX6SX_CLK_CKO>; + reset-gpios = <&gpio4 5 GPIO_ACTIVE_LOW>; /* hub reset pin */ + reset-duration-us = <10>; + + #address-cells = <1>; + #size-cells = <0>; + ethernet: asix at 1 {
asix: ethernet at 1
Quoted 18 lines
Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt new file +10
-0+ compatible = "usbb95,1708"; + reg = <1>; + + power-sequence; + clocks = <&clks IMX6SX_CLK_IPG>; + reset-gpios = <&gpio4 6 GPIO_ACTIVE_LOW>; /* ethernet_rst */ + reset-duration-us = <15>; + }; + }; +};Signature · 7 lines
1.9.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel at lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v2 1/6 binding-doc: power: pwrseq-generic: add binding doc for generic power sequence library
Quoted 69 lines · Rob Herring
Quoted 1 line · Peter Chen
Add binding doc for generic power sequence library.
I'd written a review on last version, but forgot to send it out. Anyway, I mostly had the same comments as Philipp and Joshua. A couple of things they missed...
Quoted 35 lines
Signed-off-by Peter Chen <[email protected]>--- .../bindings/power/pwrseq/pwrseq-generic.txt | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txtDocumentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt new file +22
-0@@ -0,0 +1,53 @@ +The generic power sequence library + +Some hard-wired USB/MMC devices need to do power sequence to let the +device work normally, the typical power sequence like: enable USB +PHY clock, toggle reset pin, etc. But current Linux USB driver +lacks of such code to do it, it may cause some hard-wired USB devices +works abnormal or can't be recognized by controller at all. The +power sequence will be done before this device can be found at USB +bus. + +The power sequence properties is under the device node. + +Required properties: +- power-sequence: this device needs to do power sequence before enumeration + +Optional properties: +- clocks: the input clock for device. +- reset-gpios: Should specify the GPIO for reset. +- reset-duration-us: the duration in microsecond for assert reset signal. + +Below is the example of USB power sequence properties on USB device +nodes which have two level USB hubs.Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt line 32
Quoted 10 lines
Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt new file +10
-0+ +&usbotg1 { + vbus-supply = <®_usb_otg1_vbus>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_usb_otg1_id>; + status = "okay"; + + #address-cells = <1>; + #size-cells = <0>; + hub: genesys at 1 {genesys: hub at 1
Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt line 43
Quoted 11 lines
Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt new file +11
-0+ compatible = "usb5e3,608"; + reg = <1>; + + power-sequence; + clocks = <&clks IMX6SX_CLK_CKO>; + reset-gpios = <&gpio4 5 GPIO_ACTIVE_LOW>; /* hub reset pin */ + reset-duration-us = <10>; + + #address-cells = <1>; + #size-cells = <0>; + ethernet: asix at 1 {asix: ethernet at 1
Quoted 10 lines
Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt line 53
Quoted 10 lines
Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt new file +10
-0+ compatible = "usbb95,1708"; + reg = <1>; + + power-sequence; + clocks = <&clks IMX6SX_CLK_IPG>; + reset-gpios = <&gpio4 6 GPIO_ACTIVE_LOW>; /* ethernet_rst */ + reset-duration-us = <15>; + }; + }; +};
Will change, thanks.
Signature · 2 lines
Best Regards, Peter Chen
PATCH v2 2/6 power: add power sequence library
In reply to Peter ChenWe have an well-known problem that the device needs to do some power sequence before it can be recognized by related host, the typical example like hard-wired mmc devices and usb devices.
This power sequence is hard to be described at device tree and handled by related host driver, so we have created a common power sequence library to cover this requirement. The core code has supplied some common helpers for host driver, and individual power sequence libraries handle kinds of power sequence for devices.
pwrseq_generic is intended for general purpose of power sequence, which handles gpios and clocks currently, and can cover regulator and pinctrl in future. The host driver calls pwrseq_alloc_generic to create an generic pwrseq instance.
--- drivers/power/Kconfig | 1 + drivers/power/Makefile | 1 + drivers/power/pwrseq/Kconfig | 20 +++++ drivers/power/pwrseq/Makefile | 2 + drivers/power/pwrseq/core.c | 79 ++++++++++++++++++++ drivers/power/pwrseq/pwrseq_generic.c | 134 ++++++++++++++++++++++++++++++++++ include/linux/power/pwrseq.h | 55 ++++++++++++++ 7 files changed, 292 insertions(+) create mode 100644 drivers/power/pwrseq/Kconfig create mode 100644 drivers/power/pwrseq/Makefile create mode 100644 drivers/power/pwrseq/core.c create mode 100644 drivers/power/pwrseq/pwrseq_generic.c create mode 100644 include/linux/power/pwrseq.h
drivers/power/Kconfig +1 -0
@@ -515,3 +515,4 @@ endif # POWER_SUPPLY source "drivers/power/reset/Kconfig" source "drivers/power/avs/Kconfig" +source "drivers/power/pwrseq/Kconfig"
drivers/power/Makefile +1 -0
@@ -74,3 +74,4 @@ obj-$(CONFIG_CHARGER_TPS65217) += tps65217_charger.o obj-$(CONFIG_POWER_RESET) += reset/ obj-$(CONFIG_AXP288_FUEL_GAUGE) += axp288_fuel_gauge.o obj-$(CONFIG_AXP288_CHARGER) += axp288_charger.o +obj-$(CONFIG_POWER_SEQUENCE) += pwrseq/
drivers/power/pwrseq/Kconfig new file +20 -0
@@ -0,0 +1,20 @@ +# +# Power Sequence library +# + +config POWER_SEQUENCE + bool + +menu "Power Sequence Support" + +config PWRSEQ_GENERIC + bool "Generic power sequence control" + depends on OF + select POWER_SEQUENCE + help + It is used for drivers which needs to do power sequence + (eg, turn on clock, toggle reset gpio) before the related + devices can be found by hardware. This generic one can be + used for common power sequence control. + +endmenu
drivers/power/pwrseq/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +obj-$(CONFIG_POWER_SEQUENCE) += core.o +obj-$(CONFIG_PWRSEQ_GENERIC) += pwrseq_generic.o
drivers/power/pwrseq/core.c new file +79 -0
79 lines not on this page · raw message
drivers/power/pwrseq/pwrseq_generic.c new file +134 -0
134 lines not on this page · raw message
include/linux/power/pwrseq.h new file +55 -0
55 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 3/6 binding-doc: usb: usb-device: add optional properties for power sequence
In reply to Peter ChenAdd optional properties for power sequence.
--- Documentation/devicetree/bindings/usb/usb-device.txt | 9 +++++++++ 1 file changed, 9 insertions(+)
Documentation/devicetree/bindings/usb/usb-device.txt +9 -0
@@ -13,6 +13,10 @@ Required properties: - reg: the port number which this device is connecting to, the range is 1-31. +Optional properties: +power sequence properties, see +Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt for detail + Example: &usb1 {
@@ -24,5 +28,10 @@ Example: hub: genesys at 1 { compatible = "usb5e3,608"; reg = <1>; + + power-sequence; + clocks = <&clks IMX6SX_CLK_CKO>; + reset-gpios = <&gpio4 5 GPIO_ACTIVE_LOW>; /* hub reset pin */ + reset-duration-us = <10>; }; }
Signature · 1 line
1.9.1
Rob Herring
maintainerPATCH v2 3/6 binding-doc: usb: usb-device: add optional properties for power sequence
Quoted 23 lines · Peter Chen
Add optional properties for power sequence.
Signed-off-by Peter Chen <[email protected]>--- Documentation/devicetree/bindings/usb/usb-device.txt | 9 +++++++++ 1 file changed, 9 insertions(+)Documentation/devicetree/bindings/usb/usb-device.txt +4
-0@@ -13,6 +13,10 @@ Required properties: - reg: the port number which this device is connecting to, the range is 1-31. +Optional properties: +power sequence properties, see +Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt for detail + Example: &usb1 {
Documentation/devicetree/bindings/usb/usb-device.txt Example: · line 35
Quoted 8 lines
Documentation/devicetree/bindings/usb/usb-device.txt +5
-0@@ -24,5 +28,10 @@ Example: hub: genesys at 1 { compatible = "usb5e3,608"; reg = <1>; + + power-sequence; + clocks = <&clks IMX6SX_CLK_CKO>; + reset-gpios = <&gpio4 5 GPIO_ACTIVE_LOW>; /* hub reset pin */ + reset-duration-us = <10>;
These belong in the binding doc for the hub.
Quoted 9 lines
Documentation/devicetree/bindings/usb/usb-device.txt +0
-0}; }Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 3/6 binding-doc: usb: usb-device: add optional properties for power sequence
Quoted 22 lines · Rob Herring
Quoted 21 lines · Peter Chen
Add optional properties for power sequence.
Signed-off-by Peter Chen <[email protected]>--- Documentation/devicetree/bindings/usb/usb-device.txt | 9 +++++++++ 1 file changed, 9 insertions(+)Documentation/devicetree/bindings/usb/usb-device.txt +4
-0@@ -13,6 +13,10 @@ Required properties: - reg: the port number which this device is connecting to, the range is 1-31. +Optional properties: +power sequence properties, see +Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt for detail + Example:
Quoted 13 lines
Documentation/devicetree/bindings/usb/usb-device.txt Example: · line 35
Quoted 10 lines
Documentation/devicetree/bindings/usb/usb-device.txt +5
-0&usb1 {@@ -24,5 +28,10 @@ Example: hub: genesys at 1 { compatible = "usb5e3,608"; reg = <1>; + + power-sequence; + clocks = <&clks IMX6SX_CLK_CKO>; + reset-gpios = <&gpio4 5 GPIO_ACTIVE_LOW>; /* hub reset pin */ + reset-duration-us = <10>;These belong in the binding doc for the hub.
There is no dedicated binding doc for USB hub, we only have this binding doc for hard-wired USB devices.
Signature · 2 lines
Best Regards, Peter Chen
PATCH v2 4/6 usb: core: add power sequence handling for USB devices
In reply to Peter ChenSome hard-wired USB devices need to do power sequence to let the device work normally, the typical power sequence like: enable USB PHY clock, toggle reset pin, etc. But current Linux USB driver lacks of such code to do it, it may cause some hard-wired USB devices works abnormal or can't be recognized by controller at all.
In this patch, it calls power sequence library APIs to finish the power sequence events. At first, it calls pwrseq_alloc_generic to create a generic power sequence instance, then it will do power on sequence at hub's probe for all devices under this hub (includes root hub) if this device is described at dts and there is a property "power-sequence" for it.
At hub_disconnect, it will do power off sequence which is at powered on list.
--- drivers/usb/core/Makefile | 1 + drivers/usb/core/hub.c | 12 ++++-- drivers/usb/core/hub.h | 12 ++++++ drivers/usb/core/pwrseq.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 124 insertions(+), 3 deletions(-) create mode 100644 drivers/usb/core/pwrseq.c
drivers/usb/core/Makefile +1 -0
@@ -9,5 +9,6 @@ usbcore-y += port.o of.o usbcore-$(CONFIG_PCI) += hcd-pci.o usbcore-$(CONFIG_ACPI) += usb-acpi.o +usbcore-$(CONFIG_PWRSEQ_GENERIC) += pwrseq.o obj-$(CONFIG_USB) += usbcore.o
drivers/usb/core/hub.c +9 -3
@@ -1700,6 +1700,7 @@ static void hub_disconnect(struct usb_interface *intf) hub->error =0 ;hub_quiesce (hub,HUB_DISCONNECT ); +hub_pwrseq_off (hub);mutex_lock (&usb_port_peer_mutex);/* Avoid races with recursively_mark_NOTATTACHED() */
@@ -1733,6 +1734,7 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)struct usb_endpoint_descriptor *endpoint;struct usb_device *hdev;struct usb_hub *hub; +int ret = -ENODEV ; desc = intf->cur_altsetting; hdev =interface_to_usbdev (intf);
@@ -1839,6 +1841,7 @@ descriptor_error:INIT_DELAYED_WORK (&hub->leds, led_work);INIT_DELAYED_WORK (&hub->init_work,NULL );INIT_WORK (&hub->events, hub_event); +INIT_LIST_HEAD (&hub->pwrseq_on_list);usb_get_intf (intf);usb_get_dev (hdev);
@@ -1852,11 +1855,14 @@ descriptor_error:if (id->driver_info &HUB_QUIRK_CHECK_PORT_AUTOSUSPEND ) hub->quirk_check_port_auto_suspend =1 ; -if (hub_configure (hub, endpoint) >=0 ) -return 0 ; +if (hub_configure (hub, endpoint) >=0 ) { + ret =hub_pwrseq_on (hub); +if (!ret) +return 0 ; + }hub_disconnect (intf); -return -ENODEV ; +return ret; } static int
drivers/usb/core/hub.h +12 -0
@@ -78,6 +78,7 @@ struct usb_hub {struct delayed_work init_work;struct work_struct events;struct usb_port **ports; +struct list_head pwrseq_on_list;/* powered pwrseq node list */ };/**
@@ -166,3 +167,14 @@ static inline int hub_port_debounce_be_stable(struct usb_hub *hub, {return hub_port_debounce (hub, port1, false); } + +#if IS_ENABLED (CONFIG_PWRSEQ_GENERIC ) +int hub_pwrseq_on (struct usb_hub *hub); +void hub_pwrseq_off (struct usb_hub *hub); +#else +static inline int hub_pwrseq_on (struct usb_hub *hub) +{ +return 0 ; +} +static inline void hub_pwrseq_off (struct usb_hub *hub) {} +#endif /* CONFIG_PWRSEQ_GENERIC */
drivers/usb/core/pwrseq.c new file +102 -0
102 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 5/6 usb: chipidea: let chipidea core device of_node equal's glue layer device of_node
In reply to Peter ChenFrom: Peter Chen <[email protected]>
At device tree, we have no device node for chipidea core, the glue layer's node is the parent node for host and udc device. But in related driver, the parent device is chipidea core. So, in order to let the common driver get parent's node, we let the core's device node equals glue layer device node.
--- drivers/usb/chipidea/core.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/usb/chipidea/core.c +10 -0
@@ -914,6 +914,16 @@ static int ci_hdrc_probe(struct platform_device *pdev)if (!ci)return -ENOMEM ; +/* +* At device tree, we have no device node for chipidea core, +* the glue layer's node is the parent node for host and udc +* device. But in related driver, the parent device is chipidea +* core. So, in order to let the common driver get parent's node, +* we let the core's device node equals glue layer's node. +*/ +if (dev->parent && dev->parent->of_node) + dev->of_node = dev->parent->of_node; + ci->dev = dev; ci->platdata =dev_get_platdata (dev); ci->imx28_write_fix = !!(ci->platdata->flags &
Signature · 1 line
1.9.1
PATCH v2 6/6 ARM: dts: imx6qdl-udoo.dtsi: fix onboard USB HUB property
In reply to Peter ChenFrom: Peter Chen <[email protected]>
The current dts describes USB HUB's property at USB controller's entry, it is improper. The USB HUB should be the child node under USB controller, and power sequence properties are under it.
--- arch/arm/boot/dts/imx6qdl-udoo.dtsi | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)
arch/arm/boot/dts/imx6qdl-udoo.dtsi +14 -13
@@ -9,6 +9,8 @@ * */ +#include <dt-bindings/gpio/gpio.h> + / { aliases { backlight = &backlight;
@@ -58,17 +60,6 @@ #address-cells = <1>; #size-cells = <0>; - reg_usb_h1_vbus: regulator at 0 { - compatible = "regulator-fixed"; - reg = <0>; - regulator-name = "usb_h1_vbus"; - regulator-min-microvolt = <5000000>; - regulator-max-microvolt = <5000000>; - enable-active-high; - startup-delay-us = <2>; /* USB2415 requires a POR of 1 us minimum */ - gpio = <&gpio7 12 0>; - }; - reg_panel: regulator at 1 { compatible = "regulator-fixed"; reg = <1>;
@@ -259,9 +250,19 @@ &usbh1 { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_usbh>; - vbus-supply = <®_usb_h1_vbus>; - clocks = <&clks IMX6QDL_CLK_CKO>; status = "okay"; + + #address-cells = <1>; + #size-cells = <0>; + hub: usb2415 at 1 { + compatible = "usb424,2514"; + reg = <1>; + + power-sequence; + clocks = <&clks IMX6QDL_CLK_CKO>; + reset-gpios = <&gpio7 12 GPIO_ACTIVE_LOW>; + reset-duration-us = <3000>; + }; }; &usdhc3 {
Signature · 1 line
1.9.1
v2 cover power: add power sequence library
In reply to Peter ChenQuoted 11 lines · Peter Chen
Hi all,
This is a follow-up for my last power sequence framework patch set [1]. According to Rob Herring and Ulf Hansson's comments[2], I use a generic power sequence library for parsing the power sequence elements on DT, and implement generic power sequence on library. The host driver can allocate power sequence instance, and calls pwrseq APIs accordingly.
In future, if there are special power sequence requirements, the special power sequence library can be created.
Quoted 7 lines
This patch set is tested on i.mx6 sabresx evk using a dts change, I use two hot-plug devices to simulate this use case, the related binding change is updated at patch[1/6], The udoo board changes were tested using my last power sequence patch set.[3]
Except for hard-wired MMC and USB devices, I find the USB ULPI PHY also need to power on itself before it can be found by ULPI bus.
Sorry being so late in the discussion...
If I am not missing anything, then I am afraid to say that the generic library
implementation in this patch series is not going to solve many of the custom requirement of power on, off, etc...
I know you mentioned about adding another library when we come across such platforms, but should we not keep provision (or easy hooks/path) to enable that ?
Let me bring in the use case I am dealing with,
Host
||
V
USB port
------------------------------------------------------------
||
V
USB HUB device (May need custom on/off seq)
||
V
==================
|| ||
V V
Device-1 Device-2(Needs special power (Needs special power
on/off sequence. on/off sequence.
Also may need custom Also, may need custom
sequence for sequence for
suspend/resume) suspend/resume).
Note: Both Devices are connected to HUB via HSIC and may differ
in terms of functionality, features they support.
In the above case, both Device-1 and Device-2, need separate power on/off sequence. So generic library currently we have in this patch series is not going to satisfy the need here.
I looked at all 6 revisions of this patch-series, went through the review comments, and looked at MMC power sequence code; what I can say here is, we need something similar to MMC power sequence here, where every device can have its own power sequence (if needed).
I know Rob is not in favor of creating platform device for this, and I understand his comment.
If not platform device, but atleast we need mechanism to connect each device back to its of_node and its respective driver/library fns. For example, the Devices may support different boot modes, and platform driver needs to make sure that the right sequence is followed for booting.
Peter, My apologies for taking you back again on this series. I am OK, if you wish to address this in incremental addition, but my point is, we know that the current generic way is not enough for us, so I think we should try to fix it in initial phase only.
Thanks,
Vaibhav
Quoted 46 lines
[1] http://www.spinics.net/lists/linux-usb/msg142755.html
[2] http://www.spinics.net/lists/linux-usb/msg143106.html
[3] http://www.spinics.net/lists/linux-usb/msg142815.htmlChanges for v2:
- Delete "pwrseq" prefix and clock-names for properties at dt binding
- Should use structure not but its pointer for kzalloc
- Since chipidea core has noof_node, let core'sof_nodeequals glue layer's at core's probePeter Chen (6):
binding-doc: power: pwrseq-generic: add binding doc for generic power
sequence library
power: add power sequence library
binding-doc: usb: usb-device: add optional properties for power
sequence
usb: core: add power sequence handling for USB devices
usb: chipidea: let chipidea core deviceof_nodeequal's glue layer
deviceof_node
ARM: dts:imx6qdl-udoo.dtsi: fix onboard USB HUB property.../bindings/power/pwrseq/pwrseq-generic.txt | 53 ++++++++ .../devicetree/bindings/usb/usb-device.txt | 9 ++ arch/arm/boot/dts/imx6qdl-udoo.dtsi | 27 +++-- drivers/power/Kconfig | 1 + drivers/power/Makefile | 1 + drivers/power/pwrseq/Kconfig | 20 +++ drivers/power/pwrseq/Makefile | 2 + drivers/power/pwrseq/core.c | 79 ++++++++++++ drivers/power/pwrseq/pwrseq_generic.c | 134 +++++++++++++++++++++ drivers/usb/chipidea/core.c | 10 ++ drivers/usb/core/Makefile | 1 + drivers/usb/core/hub.c | 12 +- drivers/usb/core/hub.h | 12 ++ drivers/usb/core/pwrseq.c | 102 ++++++++++++++++ include/linux/power/pwrseq.h | 55 +++++++++ 15 files changed, 502 insertions(+), 16 deletions(-)create mode 100644
Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txtcreate mode 100644drivers/power/pwrseq/Kconfig
create mode 100644drivers/power/pwrseq/Makefile
create mode 100644drivers/power/pwrseq/core.c
create mode 100644drivers/power/pwrseq/pwrseq_generic.c
create mode 100644drivers/usb/core/pwrseq.c
create mode 100644include/linux/power/pwrseq.h
Signature · 2 lines
Thanks, Vaibhav
v2 cover power: add power sequence library
Quoted 19 lines · Vaibhav Hiremath
Quoted 16 lines · Peter Chen
Hi all,
This is a follow-up for my last power sequence framework patch set [1]. According to Rob Herring and Ulf Hansson's comments[2], I use a generic power sequence library for parsing the power sequence elements on DT, and implement generic power sequence on library. The host driver can allocate power sequence instance, and calls pwrseq APIs accordingly.
In future, if there are special power sequence requirements, the special power sequence library can be created.
This patch set is tested on i.mx6 sabresx evk using a dts change, I use two hot-plug devices to simulate this use case, the related binding change is updated at patch[1/6], The udoo board changes were tested using my last power sequence patch set.[3]
Quoted 5 lines
Quoted 2 lines
Except for hard-wired MMC and USB devices, I find the USB ULPI PHY also need to power on itself before it can be found by ULPI bus.
Sorry being so late in the discussion...
Mistakenly responded to v2. Please ignore this, I will paste same content on V6, which is the latest revision.
Thanks,
Vaibhav
Quoted 114 lines
If I am not missing anything, then I am afraid to say that the generic library
implementation in this patch series is not going to solve many of the custom
requirement of power on, off, etc...
I know you mentioned about adding another library when we come across such platforms, but should we not keep provision (or easy hooks/path)
to enable that ?Let me bring in the use case I am dealing with,
Host || V USB port ------------------------------------------------------------ || V USB HUB device (May need custom on/off seq) || V ================== || || V V Device-1 Device-2(Needs special power (Needs special power
on/off sequence. on/off sequence.
Also may need custom Also, may need custom
sequence for sequence for
suspend/resume) suspend/resume).Note: Both Devices are connected to HUB via HSIC and may differ
in terms of functionality, features they support.In the above case, both Device-1 and Device-2, need separate power on/off sequence. So generic library currently we have in this patch series is not going to satisfy the need here.
I looked at all 6 revisions of this patch-series, went through the review comments, and looked at MMC power sequence code; what I can say here is, we need something similar to MMC power sequence here, where every device can have its own power sequence (if needed).
I know Rob is not in favor of creating platform device for this, and I understand his comment.
If not platform device, but atleast we need mechanism to connect each device back to itsof_nodeand its respective driver/library fns. For example, the Devices may support different boot modes, and platform driver needs to make sure that the right sequence is followed for booting.Peter, My apologies for taking you back again on this series. I am OK, if you wish to address this in incremental addition, but my point is, we know that the current generic way is not enough for us, so I think we should try to fix it in initial phase only.
Thanks,
VaibhavQuoted 49 lines
[1] http://www.spinics.net/lists/linux-usb/msg142755.html
[2] http://www.spinics.net/lists/linux-usb/msg143106.html
[3] http://www.spinics.net/lists/linux-usb/msg142815.htmlChanges for v2:
- Delete "pwrseq" prefix and clock-names for properties at dt binding
- Should use structure not but its pointer for kzalloc
- Since chipidea core has noof_node, let core'sof_nodeequals glue layer's at core's probePeter Chen (6):
binding-doc: power: pwrseq-generic: add binding doc for generic power
sequence library
power: add power sequence library
binding-doc: usb: usb-device: add optional properties for power
sequence
usb: core: add power sequence handling for USB devices
usb: chipidea: let chipidea core deviceof_nodeequal's glue layer
deviceof_node
ARM: dts:imx6qdl-udoo.dtsi: fix onboard USB HUB property.../bindings/power/pwrseq/pwrseq-generic.txt | 53 ++++++++ .../devicetree/bindings/usb/usb-device.txt | 9 ++ arch/arm/boot/dts/imx6qdl-udoo.dtsi | 27 +++-- drivers/power/Kconfig | 1 + drivers/power/Makefile | 1 + drivers/power/pwrseq/Kconfig | 20 +++ drivers/power/pwrseq/Makefile | 2 + drivers/power/pwrseq/core.c | 79 ++++++++++++ drivers/power/pwrseq/pwrseq_generic.c | 134 +++++++++++++++++++++ drivers/usb/chipidea/core.c | 10 ++ drivers/usb/core/Makefile | 1 + drivers/usb/core/hub.c | 12 +- drivers/usb/core/hub.h | 12 ++ drivers/usb/core/pwrseq.c | 102 ++++++++++++++++ include/linux/power/pwrseq.h | 55 +++++++++ 15 files changed, 502 insertions(+), 16 deletions(-)create mode 100644
Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt
create mode 100644drivers/power/pwrseq/Kconfigcreate mode 100644drivers/power/pwrseq/Makefilecreate mode 100644drivers/power/pwrseq/core.c
create mode 100644drivers/power/pwrseq/pwrseq_generic.ccreate mode 100644drivers/usb/core/pwrseq.c
create mode 100644include/linux/power/pwrseq.h
Signature · 2 lines
Thanks, Vaibhav