summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Agner <stefan.agner@toradex.com>2017-01-26 13:08:44 -0800
committerMax Krummenacher <max.krummenacher@toradex.com>2017-03-16 13:47:39 +0100
commite38a3a9fe19e04fdc4bcf1b96ce4183d59bca112 (patch)
treefddf2708eb64b94f58f24b7a9c6acc7bc8a8abfd
parent785bcf4bc1b1d60b7d7558749fd4bb2eba9bcbc3 (diff)
colibri_imx7: implement board level USB PHY mode
Implement board level USB PHY mode callback. On USB OTG Port 1 the Colibri standard foresees GPIO USBC_DET to decide whether the port should run in Host or Device mode. Signed-off-by: Stefan Agner <stefan.agner@toradex.com> Acked-by: Max Krummenacher <max.krummenacher@toradex.com>
-rw-r--r--board/toradex/colibri_imx7/colibri_imx7.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/board/toradex/colibri_imx7/colibri_imx7.c b/board/toradex/colibri_imx7/colibri_imx7.c
index 8af59950924..7ac376e4e31 100644
--- a/board/toradex/colibri_imx7/colibri_imx7.c
+++ b/board/toradex/colibri_imx7/colibri_imx7.c
@@ -24,6 +24,7 @@
#include <netdev.h>
#include <power/pmic.h>
#include <power/rn5t567_pmic.h>
+#include <usb.h>
#include <usb/ehci-ci.h>
#include "../common/tdx-common.h"
@@ -47,6 +48,8 @@ DECLARE_GLOBAL_DATA_PTR;
#define NAND_PAD_READY0_CTRL (PAD_CTL_DSE_3P3V_49OHM | PAD_CTL_PUS_PU5KOHM)
+#define USB_CDET_GPIO IMX_GPIO_NR(7, 14)
+
int dram_init(void)
{
gd->ram_size = get_ram_size((void *)PHYS_SDRAM, PHYS_SDRAM_SIZE);
@@ -72,6 +75,10 @@ static iomux_v3_cfg_t const usdhc1_pads[] = {
MX7D_PAD_GPIO1_IO00__GPIO1_IO0 | MUX_PAD_CTRL(NO_PAD_CTRL),
};
+static iomux_v3_cfg_t const usb_cdet_pads[] = {
+ MX7D_PAD_ENET1_CRS__GPIO7_IO14 | MUX_PAD_CTRL(NO_PAD_CTRL),
+};
+
#ifdef CONFIG_NAND_MXS
static iomux_v3_cfg_t const gpmi_pads[] = {
MX7D_PAD_SD3_DATA0__NAND_DATA00 | MUX_PAD_CTRL(NAND_PAD_CTRL),
@@ -320,6 +327,11 @@ int board_init(void)
setup_lcd();
#endif
+#ifdef CONFIG_USB_EHCI_MX7
+ imx_iomux_v3_setup_multiple_pads(usb_cdet_pads, ARRAY_SIZE(usb_cdet_pads));
+ gpio_request(USB_CDET_GPIO, "usb-cdet-gpio");
+#endif
+
return 0;
}
@@ -466,4 +478,18 @@ int board_ehci_hcd_init(int port)
}
return 0;
}
+
+int board_usb_phy_mode(int port)
+{
+ switch (port) {
+ case 0:
+ if (gpio_get_value(USB_CDET_GPIO))
+ return USB_INIT_DEVICE;
+ else
+ return USB_INIT_HOST;
+ case 1:
+ default:
+ return USB_INIT_HOST;
+ }
+}
#endif