summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSanchayan Maity <maitysanchayan@gmail.com>2016-08-05 13:59:12 +0530
committerMarcel Ziswiler <marcel.ziswiler@toradex.com>2016-09-29 06:03:24 +0200
commitd6f3535c5ca41836297d55dd6f5342a53d900014 (patch)
treed58115b89568088c65cb4759ff71a54e9728c1a8
parentdfc215b18aefab24e72e031029a39113508735dc (diff)
colibri_vf: Add board_usb_phy_mode function
Add board_usb_phy_mode function for detecting whether a port is being used as host or client using a GPIO. On Colibri Vybrid we provide GPIO 102 for this very same purpose. Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com> Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
-rw-r--r--arch/arm/include/asm/arch-vf610/iomux-vf610.h1
-rw-r--r--board/toradex/colibri_vf/colibri_vf.c32
2 files changed, 33 insertions, 0 deletions
diff --git a/arch/arm/include/asm/arch-vf610/iomux-vf610.h b/arch/arm/include/asm/arch-vf610/iomux-vf610.h
index 3b6a5f3838..92c4e01e53 100644
--- a/arch/arm/include/asm/arch-vf610/iomux-vf610.h
+++ b/arch/arm/include/asm/arch-vf610/iomux-vf610.h
@@ -73,6 +73,7 @@ enum {
VF610_PAD_PTD6__DSPI1_SIN = IOMUX_PAD(0x0154, 0x0154, 3, 0x2fc, 1, VF610_DSPI_SIN_PAD_CTRL),
VF610_PAD_PTD7__DSPI1_SOUT = IOMUX_PAD(0x0158, 0x0158, 3, __NA_, 0, VF610_DSPI_PAD_CTRL),
VF610_PAD_PTD8__DSPI1_SCK = IOMUX_PAD(0x015c, 0x015c, 3, 0x2f8, 1, VF610_DSPI_PAD_CTRL),
+ VF610_PAD_PTC29__GPIO_102 = IOMUX_PAD(0x0198, 0x0198, 0, __NA_, 0, VF610_GPIO_PAD_CTRL),
VF610_PAD_PTC10__RMII1_MDIO = IOMUX_PAD(0x00dc, 0x00dc, 1, __NA_, 0, VF610_ENET_PAD_CTRL),
VF610_PAD_PTC9__RMII1_MDC = IOMUX_PAD(0x00d8, 0x00d8, 1, __NA_, 0, VF610_ENET_PAD_CTRL),
VF610_PAD_PTC11__RMII1_CRS_DV = IOMUX_PAD(0x00e0, 0x00e0, 1, __NA_, 0, VF610_ENET_PAD_CTRL),
diff --git a/board/toradex/colibri_vf/colibri_vf.c b/board/toradex/colibri_vf/colibri_vf.c
index 7f3d182f3e..df898f53d6 100644
--- a/board/toradex/colibri_vf/colibri_vf.c
+++ b/board/toradex/colibri_vf/colibri_vf.c
@@ -26,6 +26,7 @@
#include <i2c.h>
#include <jffs2/load_kernel.h>
#include <asm/gpio.h>
+#include <usb.h>
#include "../common/configblock.h"
@@ -41,9 +42,11 @@ DECLARE_GLOBAL_DATA_PTR;
PAD_CTL_DSE_50ohm | PAD_CTL_OBE_IBE_ENABLE)
#define USB_PEN_GPIO 83
+#define USB_CDET_GPIO 102
static const iomux_v3_cfg_t usb_pads[] = {
VF610_PAD_PTD4__GPIO_83,
+ VF610_PAD_PTC29__GPIO_102,
};
int dram_init(void)
@@ -479,6 +482,10 @@ int board_init(void)
setbits_le32(&scsc->sosc_ctr, SCSC_SOSC_CTR_SOSC_EN);
+#ifdef CONFIG_USB_EHCI_VF
+ gpio_request(USB_CDET_GPIO, "usb-cdet-gpio");
+#endif
+
return 0;
}
@@ -538,4 +545,29 @@ int board_ehci_hcd_init(int port)
}
return 0;
}
+
+int board_usb_phy_mode(int port)
+{
+ switch (port) {
+ case 0:
+ /*
+ * Port 0 is used only in client mode on Colibri Vybrid modules
+ * Check for state of USB client gpio pin and accordingly return
+ * USB_INIT_DEVICE or USB_INIT_HOST.
+ */
+ if (gpio_get_value(USB_CDET_GPIO))
+ return USB_INIT_DEVICE;
+ else
+ return USB_INIT_HOST;
+ case 1:
+ /* Port 1 is used only in host mode on Colibri Vybrid modules */
+ return USB_INIT_HOST;
+ default:
+ /*
+ * There are only two USB controllers on Vybrid. Ideally we will
+ * not reach here. However return USB_INIT_HOST if we do.
+ */
+ return USB_INIT_HOST;
+ }
+}
#endif