[U-Boot] [PATCH 4/7] mvebu: usb: xhci: Add support for VBUS controlled by GPIO

kostap at marvell.com kostap at marvell.com
Mon Dec 19 16:14:46 CET 2016


From: Konstantin Porotchkin <kostap at marvell.com>

Add support for "marvell,vbus-gpio" property to mvebu XHCI
board init function.
This option is valid when CONFIG_DM_GPIO=y

Change-Id: I930b3ebe001e50ae8d5abe1f3c774bcdb1739e64
Signed-off-by: Konstantin Porotchkin <kostap at marvell.com>
Cc: Stefan Roese <sr at denx.de>
Cc: Nadav Haklai <nadavh at marvell.com>
Cc: Neta Zur Hershkovits <neta at marvell.com>
Cc: Omri Itach <omrii at marvell.com>
Cc: Igal Liberman <igall at marvell.com>
Cc: Haim Boot <hayim at marvell.com>
Cc: Hanna Hawa <hannah at marvell.com>
---
 board/Marvell/mvebu_armada-8k/board.c             | 32 ++++++++++++++++-------
 board/Marvell/mvebu_db-88f3720/board.c            |  2 +-
 doc/device-tree-bindings/usb/marvell.xhci-usb.txt | 29 ++++++++++++++++++++
 drivers/usb/host/xhci-mvebu.c                     |  5 ++--
 4 files changed, 55 insertions(+), 13 deletions(-)
 create mode 100644 doc/device-tree-bindings/usb/marvell.xhci-usb.txt

diff --git a/board/Marvell/mvebu_armada-8k/board.c b/board/Marvell/mvebu_armada-8k/board.c
index 7d1b5d9..aa6a6d7 100644
--- a/board/Marvell/mvebu_armada-8k/board.c
+++ b/board/Marvell/mvebu_armada-8k/board.c
@@ -8,6 +8,7 @@
 #include <dm.h>
 #include <i2c.h>
 #include <asm/io.h>
+#include <asm/gpio.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/soc.h>
 
@@ -95,19 +96,23 @@ int board_xhci_config(void)
 	return 0;
 }
 
-int board_xhci_enable(void)
+int board_xhci_enable(struct udevice *usb_dev)
 {
 	struct udevice *dev;
+#ifdef CONFIG_DM_GPIO
+	struct gpio_desc vbus_gpio;
+#endif
 	int ret;
 	u8 buf[8];
 
+	/*
+	 * This function enables all USB ports simultaniously,
+	 * it only needs to get called once
+	 */
+	if (usb_enabled)
+		return 0;
+
 	if (of_machine_is_compatible("marvell,armada7040-db")) {
-		/*
-		 * This function enables all USB ports simultaniously,
-		 * it only needs to get called once
-		 */
-		if (usb_enabled)
-			return 0;
 
 		/* Configure IO exander PCA9555: 7bit address 0x21 */
 		ret = i2c_get_chip_for_busnum(0, I2C_IO_EXP_ADDR, 1, &dev);
@@ -131,10 +136,19 @@ int board_xhci_enable(void)
 			return -EIO;
 		}
 
-		mdelay(500); /* required delay to let output value settle */
-		usb_enabled = 1;
 	}
 
+#ifdef CONFIG_DM_GPIO
+	gpio_request_by_name(usb_dev, "marvell,vbus-gpio", 0,
+			     &vbus_gpio, GPIOD_IS_OUT);
+
+	if (dm_gpio_is_valid(&vbus_gpio))
+		dm_gpio_set_value(&vbus_gpio, 1);
+#endif
+
+	mdelay(500); /* required delay to let output value settle */
+	usb_enabled = 1;
+
 	return 0;
 }
 
diff --git a/board/Marvell/mvebu_db-88f3720/board.c b/board/Marvell/mvebu_db-88f3720/board.c
index edf88c7..75679ff 100644
--- a/board/Marvell/mvebu_db-88f3720/board.c
+++ b/board/Marvell/mvebu_db-88f3720/board.c
@@ -69,7 +69,7 @@ int board_ahci_enable(void)
 }
 
 /* Board specific xHCI enable code */
-int board_xhci_enable(void)
+int board_xhci_enable(struct udevice *usb_dev)
 {
 	struct udevice *dev;
 	int ret;
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..b0a53ad
--- /dev/null
+++ b/doc/device-tree-bindings/usb/marvell.xhci-usb.txt
@@ -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
+ - marvell,vbus-gpio : If present, specifies a gpio that needs to be
+   activated for the bus to be powered.
+
+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>;
+		marvell,vbus-gpio = <&cpm_gpio1 15 GPIO_ACTIVE_HIGH>;
+		status = "disabled";
+	};
+
diff --git a/drivers/usb/host/xhci-mvebu.c b/drivers/usb/host/xhci-mvebu.c
index 46eb937..843a51b 100644
--- a/drivers/usb/host/xhci-mvebu.c
+++ b/drivers/usb/host/xhci-mvebu.c
@@ -10,7 +10,6 @@
 #include <dm.h>
 #include <fdtdec.h>
 #include <usb.h>
-#include <asm/gpio.h>
 
 #include "xhci.h"
 
@@ -34,7 +33,7 @@ struct mvebu_xhci {
  * Dummy implementation that can be overwritten by a board
  * specific function
  */
-__weak int board_xhci_enable(void)
+__weak int board_xhci_enable(struct udevice *usb_dev)
 {
 	return 0;
 }
@@ -51,7 +50,7 @@ static int xhci_usb_probe(struct udevice *dev)
 	hcor = (struct xhci_hcor *)((uintptr_t)ctx->hcd + len);
 
 	/* Enable USB xHCI (VBUS, reset etc) in board specific code */
-	board_xhci_enable();
+	board_xhci_enable(dev);
 
 	return xhci_register(dev, ctx->hcd, hcor);
 }
-- 
2.7.4



More information about the U-Boot mailing list