Skip to contentSkip to conversation

mvebu: usb: xhci: Add VBUS regulator supply to the host driver

PATCH Superseded kostap at marvell.com 2 participants 4 messages Feb 9, 2017

Subsystems (2)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 4/6 mvebu: usb: xhci: Add VBUS regulator supply to the host driver

From: Konstantin Porotchkin <[email protected]>

The USB device should linked to VBUS regulator through "vbus-supply" DTS property.
This patch adds handling for "vbus-supply" property inside the USB device entry for turning on the VBUS regulator upon the host adapter probe.

Cc Stefan Roese <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Nadav Haklai <[email protected]>
Cc Neta Zur Hershkovits <[email protected]>
Cc Igal Liberman <[email protected]>
Cc Haim Boot <[email protected]>

---
Changes for v4:
- Move the VBUS supply handling to use regulator framework
- Select DM_REGULATOR by Kconfig for mvebu XHCI driver

 doc/device-tree-bindings/usb/marvell.xhci-usb.txt | 29 +++++++++++++++++++++++
 drivers/usb/host/Kconfig                          |  1 +
 drivers/usb/host/xhci-mvebu.c                     | 14 ++++++++++-
 3 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 doc/device-tree-bindings/usb/marvell.xhci-usb.txt
doc/device-tree-bindings/usb/marvell.xhci-usb.txt new file +29 -0
new file mode 100644
index 0000000..cd21115
@@ -0,0 +1,29 @@
+Marvell SOC USB controllers
+
+This controller is integrated in Armada 3700/8K.
+It uses the same properties as a generic XHCI host controller
+
+Required properties :
+ - compatible: should be one or more of:
+   - "marvell,armada3700-xhci", "generic-xhci" for Armada 37xx SoCs
+   - "marvell,armada-8k-xhci", "generic-xhci" for Armada A8K SoCs
+ - reg: should contain address and length of the standard XHCI
+   register set for the device.
+ - interrupts: one XHCI interrupt should be described here.
+
+Optional properties:
+ - clocks: reference to a clock
+ - vbus-supply : If present, specifies the fixed regulator to be turned on
+   for providing power to the USB VBUS rail.
+
+Example:
+	cpm_usb3_0: usb3 at 500000 {
+		compatible = "marvell,armada-8k-xhci",
+			     "generic-xhci";
+		reg = <0x500000 0x4000>;
+		interrupts = <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&cpm_syscon0 1 22>;
+		vbus-supply = <&reg_usb3h0_vbus>;
+		status = "disabled";
+	};
+
drivers/usb/host/Kconfig +1 -0
index 5129a57..0bf8274 100644
@@ -25,6 +25,7 @@ config USB_XHCI_MVEBU
 	bool "MVEBU USB 3.0 support"
 	default y
 	depends on ARCH_MVEBU
+	select DM_REGULATOR
 	help
 	  Choose this option to add support for USB 3.0 driver on mvebu
 	  SoCs, which includes Armada8K, Armada3700 and other Armada
drivers/usb/host/xhci-mvebu.c +13 -1
index 46eb937..35d89ab 100644
@@ -10,6 +10,7 @@
 #include <dm.h>
 #include <fdtdec.h>
 #include <usb.h>
+#include <power/regulator.h>
 #include <asm/gpio.h>
 
 #include "xhci.h"
@@ -44,12 +45,23 @@ static int xhci_usb_probe(struct udevice *dev)
 	struct mvebu_xhci_platdata *plat = dev_get_platdata(dev);
 	struct mvebu_xhci *ctx = dev_get_priv(dev);
 	struct xhci_hcor *hcor;
-	int len;
+	int len, ret;
+	struct udevice *regulator;
 
 	ctx->hcd = (struct xhci_hccr *)plat->hcd_base;
 	len = HC_LENGTH(xhci_readl(&ctx->hcd->cr_capbase));
 	hcor = (struct xhci_hcor *)((uintptr_t)ctx->hcd + len);
 
+	ret = device_get_supply_regulator(dev, "vbus-supply", &regulator);
+	if (!ret) {
+		ret = regulator_set_enable(regulator, true);
+		if (ret) {
+			printf("Failed to turn ON the VBUS regulator\n");
+			return ret;
+		}
+	} else
+		printf("No VBUS regulator found\n");
+
 	/* Enable USB xHCI (VBUS, reset etc) in board specific code */
 	board_xhci_enable();
 
Signature · 1 line
2.7.4
#1 lore raw

PATCH v4 4/6 mvebu: usb: xhci: Add VBUS regulator supply to the host driver

Quoted 36 lines · kostap at marvell.com

From: Konstantin Porotchkin <[email protected]>

The USB device should linked to VBUS regulator through "vbus-supply" DTS property.
This patch adds handling for "vbus-supply" property inside the USB device entry for turning on the VBUS regulator upon the host adapter probe.

Cc Stefan Roese <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Nadav Haklai <[email protected]>
Cc Neta Zur Hershkovits <[email protected]>
Cc Igal Liberman <[email protected]>
Cc Haim Boot <[email protected]>

---
Changes for v4:
- Move the VBUS supply handling to use regulator framework
- Select DM_REGULATOR by Kconfig for mvebu XHCI driver

 doc/device-tree-bindings/usb/marvell.xhci-usb.txt | 29 +++++++++++++++++++++++
 drivers/usb/host/Kconfig                          |  1 +
 drivers/usb/host/xhci-mvebu.c                     | 14 ++++++++++-
 3 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 doc/device-tree-bindings/usb/marvell.xhci-usb.txt
doc/device-tree-bindings/usb/marvell.xhci-usb.txt new file +5 -0
new file mode 100644
index 0000000..cd21115
@@ -0,0 +1,29 @@
+Marvell SOC USB controllers
+
+This controller is integrated in Armada 3700/8K.
+It uses the same properties as a generic XHCI host controller
+

doc/device-tree-bindings/usb/marvell.xhci-usb.txt line 15

Quoted 10 lines
doc/device-tree-bindings/usb/marvell.xhci-usb.txt new file +10 -0
+Required properties :
+ - compatible: should be one or more of:
+   - "marvell,armada3700-xhci", "generic-xhci" for Armada 37xx SoCs
+   - "marvell,armada-8k-xhci", "generic-xhci" for Armada A8K SoCs
+ - reg: should contain address and length of the standard XHCI
+   register set for the device.
+ - interrupts: one XHCI interrupt should be described here.
+
+Optional properties:
+ - clocks: reference to a clock

I asked in the previous version , multiple times , what clock are these?

Quoted 49 lines
doc/device-tree-bindings/usb/marvell.xhci-usb.txt new file +14 -0
+ - vbus-supply : If present, specifies the fixed regulator to be turned on
+   for providing power to the USB VBUS rail.
+
+Example:
+	cpm_usb3_0: usb3 at 500000 {
+		compatible = "marvell,armada-8k-xhci",
+			     "generic-xhci";
+		reg = <0x500000 0x4000>;
+		interrupts = <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&cpm_syscon0 1 22>;
+		vbus-supply = <&reg_usb3h0_vbus>;
+		status = "disabled";
+	};
+
drivers/usb/host/Kconfig +1 -0
index 5129a57..0bf8274 100644
@@ -25,6 +25,7 @@ config USB_XHCI_MVEBU
 	bool "MVEBU USB 3.0 support"
 	default y
 	depends on ARCH_MVEBU
+	select DM_REGULATOR
 	help
 	  Choose this option to add support for USB 3.0 driver on mvebu
 	  SoCs, which includes Armada8K, Armada3700 and other Armada
drivers/usb/host/xhci-mvebu.c +3 -1
index 46eb937..35d89ab 100644
@@ -10,6 +10,7 @@
 #include <dm.h>
 #include <fdtdec.h>
 #include <usb.h>
+#include <power/regulator.h>
 #include <asm/gpio.h>
 
 #include "xhci.h"
@@ -44,12 +45,23 @@ static int xhci_usb_probe(struct udevice *dev)
 	struct mvebu_xhci_platdata *plat = dev_get_platdata(dev);
 	struct mvebu_xhci *ctx = dev_get_priv(dev);
 	struct xhci_hcor *hcor;
-	int len;
+	int len, ret;
+	struct udevice *regulator;
 
 	ctx->hcd = (struct xhci_hccr *)plat->hcd_base;
 	len = HC_LENGTH(xhci_readl(&ctx->hcd->cr_capbase));
 	hcor = (struct xhci_hcor *)((uintptr_t)ctx->hcd + len);

drivers/usb/host/xhci-mvebu.c static int xhci_usb_probe(struct udevice *dev) · line 63

Quoted 10 lines
drivers/usb/host/xhci-mvebu.c +9 -0
 
+	ret = device_get_supply_regulator(dev, "vbus-supply", &regulator);
+	if (!ret) {
+		ret = regulator_set_enable(regulator, true);
+		if (ret) {
+			printf("Failed to turn ON the VBUS regulator\n");
+			return ret;
+		}
+	} else
+		printf("No VBUS regulator found\n");

This should be debug() , looks good otherwise.

Quoted 4 lines
drivers/usb/host/xhci-mvebu.c +0 -0
 	/* Enable USB xHCI (VBUS, reset etc) in board specific code */
 	board_xhci_enable();
 
Signature · 2 lines
Best regards,
Marek Vasut
#2 lore raw

PATCH v4 4/6 mvebu: usb: xhci: Add VBUS regulator supply to the host driver

Quoted 41 lines · Marek Vasut
Quoted 40 lines · kostap at marvell.com

From: Konstantin Porotchkin <[email protected]>

The USB device should linked to VBUS regulator through "vbus-supply" DTS property.
This patch adds handling for "vbus-supply" property inside the USB device entry for turning on the VBUS regulator upon the host adapter probe.

Cc Stefan Roese <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Nadav Haklai <[email protected]>
Cc Neta Zur Hershkovits <[email protected]>
Cc Igal Liberman <[email protected]>
Cc Haim Boot <[email protected]>

---
Changes for v4:
- Move the VBUS supply handling to use regulator framework
- Select DM_REGULATOR by Kconfig for mvebu XHCI driver

 doc/device-tree-bindings/usb/marvell.xhci-usb.txt | 29 +++++++++++++++++++++++
 drivers/usb/host/Kconfig                          |  1 +
 drivers/usb/host/xhci-mvebu.c                     | 14 ++++++++++-
 3 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 doc/device-tree-bindings/usb/marvell.xhci-usb.txt
doc/device-tree-bindings/usb/marvell.xhci-usb.txt new file +9 -0
new file mode 100644
index 0000000..cd21115
@@ -0,0 +1,29 @@
+Marvell SOC USB controllers
+
+This controller is integrated in Armada 3700/8K.
+It uses the same properties as a generic XHCI host controller
+
+Required properties :
+ - compatible: should be one or more of:
+   - "marvell,armada3700-xhci", "generic-xhci" for Armada 37xx SoCs
+   - "marvell,armada-8k-xhci", "generic-xhci" for Armada A8K SoCs
Quoted 8 lines

doc/device-tree-bindings/usb/marvell.xhci-usb.txt line 15

Quoted 6 lines
doc/device-tree-bindings/usb/marvell.xhci-usb.txt new file +6 -0
+ - reg: should contain address and length of the standard XHCI
+   register set for the device.
+ - interrupts: one XHCI interrupt should be described here.
+
+Optional properties:
+ - clocks: reference to a clock

I asked in the previous version , multiple times , what clock are these?

Yep, we discussed these clocks already. Do you want me to add a notice here? Like "the platform clocks that should be enabled upon initialization. may not exist on all platforms"

Quoted 51 lines
Quoted 51 lines
doc/device-tree-bindings/usb/marvell.xhci-usb.txt new file +14 -0
+ - vbus-supply : If present, specifies the fixed regulator to be turned on
+   for providing power to the USB VBUS rail.
+
+Example:
+	cpm_usb3_0: usb3 at 500000 {
+		compatible = "marvell,armada-8k-xhci",
+			     "generic-xhci";
+		reg = <0x500000 0x4000>;
+		interrupts = <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&cpm_syscon0 1 22>;
+		vbus-supply = <&reg_usb3h0_vbus>;
+		status = "disabled";
+	};
+
drivers/usb/host/Kconfig +1 -0
index 5129a57..0bf8274 100644
@@ -25,6 +25,7 @@ config USB_XHCI_MVEBU
 	bool "MVEBU USB 3.0 support"
 	default y
 	depends on ARCH_MVEBU
+	select DM_REGULATOR
 	help
 	  Choose this option to add support for USB 3.0 driver on mvebu
 	  SoCs, which includes Armada8K, Armada3700 and other Armada
drivers/usb/host/xhci-mvebu.c +3 -1
index 46eb937..35d89ab 100644
@@ -10,6 +10,7 @@
 #include <dm.h>
 #include <fdtdec.h>
 #include <usb.h>
+#include <power/regulator.h>
 #include <asm/gpio.h>
 
 #include "xhci.h"
@@ -44,12 +45,23 @@ static int xhci_usb_probe(struct udevice *dev)
 	struct mvebu_xhci_platdata *plat = dev_get_platdata(dev);
 	struct mvebu_xhci *ctx = dev_get_priv(dev);
 	struct xhci_hcor *hcor;
-	int len;
+	int len, ret;
+	struct udevice *regulator;
 
 	ctx->hcd = (struct xhci_hccr *)plat->hcd_base;
 	len = HC_LENGTH(xhci_readl(&ctx->hcd->cr_capbase));
 	hcor = (struct xhci_hcor *)((uintptr_t)ctx->hcd + len);
 
Quoted 11 lines

drivers/usb/host/xhci-mvebu.c static int xhci_usb_probe(struct udevice *dev) · line 63

Quoted 9 lines
drivers/usb/host/xhci-mvebu.c +9 -0
+	ret = device_get_supply_regulator(dev, "vbus-supply", &regulator);
+	if (!ret) {
+		ret = regulator_set_enable(regulator, true);
+		if (ret) {
+			printf("Failed to turn ON the VBUS regulator\n");
+			return ret;
+		}
+	} else
+		printf("No VBUS regulator found\n");

This should be debug() , looks good otherwise.

OK, will change it to "debug"

Quoted 7 lines
Quoted 5 lines
drivers/usb/host/xhci-mvebu.c +0 -0
 	/* Enable USB xHCI (VBUS, reset etc) in board specific code */
 	board_xhci_enable();
 
#3 lore raw

PATCH v4 4/6 mvebu: usb: xhci: Add VBUS regulator supply to the host driver

Quoted 55 lines · Konstantin Porotchkin
Quoted 44 lines · Marek Vasut
Quoted 43 lines · kostap at marvell.com

From: Konstantin Porotchkin <[email protected]>

The USB device should linked to VBUS regulator through "vbus-supply" DTS property.
This patch adds handling for "vbus-supply" property inside the USB device entry for turning on the VBUS regulator upon the host adapter probe.

Cc Stefan Roese <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Nadav Haklai <[email protected]>
Cc Neta Zur Hershkovits <[email protected]>
Cc Igal Liberman <[email protected]>
Cc Haim Boot <[email protected]>

---
Changes for v4:
- Move the VBUS supply handling to use regulator framework
- Select DM_REGULATOR by Kconfig for mvebu XHCI driver

 doc/device-tree-bindings/usb/marvell.xhci-usb.txt | 29
+++++++++++++++++++++++
 drivers/usb/host/Kconfig                          |  1 +
 drivers/usb/host/xhci-mvebu.c                     | 14 ++++++++++-
 3 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 doc/device-tree-bindings/usb/marvell.xhci-usb.txt
doc/device-tree-bindings/usb/marvell.xhci-usb.txt new file +9 -0
new file mode 100644
index 0000000..cd21115
@@ -0,0 +1,29 @@
+Marvell SOC USB controllers
+
+This controller is integrated in Armada 3700/8K.
+It uses the same properties as a generic XHCI host controller
+
+Required properties :
+ - compatible: should be one or more of:
+   - "marvell,armada3700-xhci", "generic-xhci" for Armada 37xx SoCs
+   - "marvell,armada-8k-xhci", "generic-xhci" for Armada A8K SoCs
Quoted 8 lines

doc/device-tree-bindings/usb/marvell.xhci-usb.txt line 15

Quoted 6 lines
doc/device-tree-bindings/usb/marvell.xhci-usb.txt new file +6 -0
+ - reg: should contain address and length of the standard XHCI
+   register set for the device.
+ - interrupts: one XHCI interrupt should be described here.
+
+Optional properties:
+ - clocks: reference to a clock

I asked in the previous version , multiple times , what clock are these?

Quoted 4 lines

Yep, we discussed these clocks already. Do you want me to add a notice here?
Like "the platform clocks that should be enabled upon initialization. may not exist on all platforms"

Any description than opaque "reference to a clock" is better. I guess these clock have a description in the datasheet , so something like that would do.

Quoted 63 lines
Quoted 52 lines
Quoted 52 lines
doc/device-tree-bindings/usb/marvell.xhci-usb.txt new file +1 -0
+ - vbus-supply : If present, specifies the fixed regulator to be

turned on

doc/device-tree-bindings/usb/marvell.xhci-usb.txt new file +13 -0
+   for providing power to the USB VBUS rail.
+
+Example:
+    cpm_usb3_0: usb3 at 500000 {
+        compatible = "marvell,armada-8k-xhci",
+                 "generic-xhci";
+        reg = <0x500000 0x4000>;
+        interrupts = <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>;
+        clocks = <&cpm_syscon0 1 22>;
+        vbus-supply = <&reg_usb3h0_vbus>;
+        status = "disabled";
+    };
+
drivers/usb/host/Kconfig +1 -0
index 5129a57..0bf8274 100644
@@ -25,6 +25,7 @@ config USB_XHCI_MVEBU
     bool "MVEBU USB 3.0 support"
     default y
     depends on ARCH_MVEBU
+    select DM_REGULATOR
     help
       Choose this option to add support for USB 3.0 driver on mvebu
       SoCs, which includes Armada8K, Armada3700 and other Armada
drivers/usb/host/xhci-mvebu.c +3 -1
index 46eb937..35d89ab 100644
@@ -10,6 +10,7 @@
 #include <dm.h>
 #include <fdtdec.h>
 #include <usb.h>
+#include <power/regulator.h>
 #include <asm/gpio.h>
 
 #include "xhci.h"
@@ -44,12 +45,23 @@ static int xhci_usb_probe(struct udevice *dev)
     struct mvebu_xhci_platdata *plat = dev_get_platdata(dev);
     struct mvebu_xhci *ctx = dev_get_priv(dev);
     struct xhci_hcor *hcor;
-    int len;
+    int len, ret;
+    struct udevice *regulator;
 
     ctx->hcd = (struct xhci_hccr *)plat->hcd_base;
     len = HC_LENGTH(xhci_readl(&ctx->hcd->cr_capbase));
     hcor = (struct xhci_hcor *)((uintptr_t)ctx->hcd + len);
 
Quoted 11 lines

drivers/usb/host/xhci-mvebu.c static int xhci_usb_probe(struct udevice *dev) · line 63

Quoted 9 lines
drivers/usb/host/xhci-mvebu.c +9 -0
+    ret = device_get_supply_regulator(dev, "vbus-supply", &regulator);
+    if (!ret) {
+        ret = regulator_set_enable(regulator, true);
+        if (ret) {
+            printf("Failed to turn ON the VBUS regulator\n");
+            return ret;
+        }
+    } else
+        printf("No VBUS regulator found\n");

This should be debug() , looks good otherwise.

Quoted 1 line

OK, will change it to "debug"

Hm , in fact, you can drop it altogether . It's not really useful.

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
drivers/usb/host/xhci-mvebu.c +0 -0
     /* Enable USB xHCI (VBUS, reset etc) in board specific code */
     board_xhci_enable();
 
Signature · 2 lines
Best regards,
Marek Vasut