From: Konstantin Porotchkin <kos...@marvell.com>

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.

Change-Id: Ibcf72d82298be42353ca03fee064ae8077a7b9de
Signed-off-by: Konstantin Porotchkin <kos...@marvell.com>
Cc: Stefan Roese <s...@denx.de>
Cc: Marek Vasut <ma...@denx.de>
Cc: Nadav Haklai <nad...@marvell.com>
Cc: Neta Zur Hershkovits <n...@marvell.com>
Cc: Igal Liberman <ig...@marvell.com>
Cc: Haim Boot <ha...@marvell.com>
---
Changes for v3:
- Moved VBUS control from private GPIO to a fixed regulator
- Rebase on top of master branch


 doc/device-tree-bindings/usb/marvell.xhci-usb.txt | 28 ++++++++++++++++++++
 drivers/usb/host/xhci-mvebu.c                     | 31 +++++++++++++++++++++++
 2 files changed, 59 insertions(+)
 create mode 100644 doc/device-tree-bindings/usb/marvell.xhci-usb.txt

diff --git a/doc/device-tree-bindings/usb/marvell.xhci-usb.txt 
b/doc/device-tree-bindings/usb/marvell.xhci-usb.txt
new file mode 100644
index 0000000..672a829
--- /dev/null
+++ b/doc/device-tree-bindings/usb/marvell.xhci-usb.txt
@@ -0,0 +1,28 @@
+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@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";
+       };
diff --git a/drivers/usb/host/xhci-mvebu.c b/drivers/usb/host/xhci-mvebu.c
index 46eb937..149f6a4 100644
--- a/drivers/usb/host/xhci-mvebu.c
+++ b/drivers/usb/host/xhci-mvebu.c
@@ -45,7 +45,38 @@ static int xhci_usb_probe(struct udevice *dev)
        struct mvebu_xhci *ctx = dev_get_priv(dev);
        struct xhci_hcor *hcor;
        int len;
+#ifdef CONFIG_DM_REGULATOR_FIXED
+       const void *fdt = gd->fdt_blob;
+       int node = dev->of_offset;
+       const fdt32_t *regulator;
+       int size;
 
+       /*
+        * The VBUS supply regulator is not probed automatically
+        * Trigger the regulator probe upon USB port bring up
+        */
+       regulator = fdt_getprop(fdt, node, "vbus-supply", &size);
+       if (regulator) {
+               uint32_t phandle;
+               struct udevice *config;
+               int reg_node, ret;
+
+               phandle = fdt32_to_cpu(*regulator);
+               reg_node = fdt_node_offset_by_phandle(fdt, phandle);
+               if (reg_node < 0) {
+                       dev_err(dev, "vbus-supply has invalid phandle\n");
+                       return -EINVAL;
+               }
+               ret = uclass_get_device_by_of_offset(UCLASS_REGULATOR,
+                                                    reg_node, &config);
+               if (ret) {
+                       dev_err(dev, "failed to get VBUS regulator device\n");
+                       return ret;
+               }
+       }
+#else
+       debug("VBUS regulator support is missing\n");
+#endif
        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);
-- 
2.7.4

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to