Commit 4906e4b9ff0e75ad517fa3ed3d49430d3533d3f6
1 parent
022a729756
Exists in
smarc_8mq_lf_v2020.04
and in
4 other branches
MLK-14445-6 mx7ulp_evk: Add USB OTG0 support
Porting codes to support USB OTG0 on the EVK board. Convert to use DM USB driver. Signed-off-by: Ye Li <ye.li@nxp.com> (cherry picked from commit b4e01a67a0740c524e7522da7ace0488f86261db) (cherry picked from commit 23144983d3347f8f91695cea73aab8558cc66629) (cherry picked from commit a5d3e7a334689b5c7b4e99f10c1a6044e4775699)
Showing 4 changed files with 60 additions and 0 deletions Side-by-side Diff
board/freescale/mx7ulp_evk/mx7ulp_evk.c
| ... | ... | @@ -10,11 +10,15 @@ |
| 10 | 10 | #include <asm/arch/mx7ulp-pins.h> |
| 11 | 11 | #include <asm/arch/iomux.h> |
| 12 | 12 | #include <asm/mach-imx/boot_mode.h> |
| 13 | +#include <asm/gpio.h> | |
| 14 | +#include <usb.h> | |
| 15 | +#include <dm.h> | |
| 13 | 16 | |
| 14 | 17 | DECLARE_GLOBAL_DATA_PTR; |
| 15 | 18 | |
| 16 | 19 | #define UART_PAD_CTRL (PAD_CTL_PUS_UP) |
| 17 | 20 | #define QSPI_PAD_CTRL1 (PAD_CTL_PUS_UP | PAD_CTL_DSE) |
| 21 | +#define OTG_ID_GPIO_PAD_CTRL (PAD_CTL_IBE_ENABLE) | |
| 18 | 22 | |
| 19 | 23 | int dram_init(void) |
| 20 | 24 | { |
| ... | ... | @@ -64,6 +68,37 @@ |
| 64 | 68 | } |
| 65 | 69 | #endif |
| 66 | 70 | |
| 71 | +#ifdef CONFIG_DM_USB | |
| 72 | +static iomux_cfg_t const usb_otg1_pads[] = { | |
| 73 | + MX7ULP_PAD_PTC8__PTC8 | MUX_PAD_CTRL(OTG_ID_GPIO_PAD_CTRL), /* gpio for OTG ID*/ | |
| 74 | +}; | |
| 75 | + | |
| 76 | +static void setup_usb(void) | |
| 77 | +{ | |
| 78 | + mx7ulp_iomux_setup_multiple_pads(usb_otg1_pads, | |
| 79 | + ARRAY_SIZE(usb_otg1_pads)); | |
| 80 | + | |
| 81 | + gpio_request(IMX_GPIO_NR(3, 8), "otg_id"); | |
| 82 | + gpio_direction_input(IMX_GPIO_NR(3, 8)); | |
| 83 | +} | |
| 84 | + | |
| 85 | +int board_ehci_usb_phy_mode(struct udevice *dev) | |
| 86 | +{ | |
| 87 | + int ret = 0; | |
| 88 | + | |
| 89 | + if (devfdt_get_addr(dev) == USBOTG0_RBASE) { | |
| 90 | + ret = gpio_get_value(IMX_GPIO_NR(3, 8)); | |
| 91 | + | |
| 92 | + if (ret) | |
| 93 | + return USB_INIT_DEVICE; | |
| 94 | + else | |
| 95 | + return USB_INIT_HOST; | |
| 96 | + } | |
| 97 | + | |
| 98 | + return USB_INIT_HOST; | |
| 99 | +} | |
| 100 | +#endif | |
| 101 | + | |
| 67 | 102 | int board_early_init_f(void) |
| 68 | 103 | { |
| 69 | 104 | setup_iomux_uart(); |
| ... | ... | @@ -78,6 +113,10 @@ |
| 78 | 113 | |
| 79 | 114 | #ifdef CONFIG_FSL_QSPI |
| 80 | 115 | board_qspi_init(); |
| 116 | +#endif | |
| 117 | + | |
| 118 | +#ifdef CONFIG_DM_USB | |
| 119 | + setup_usb(); | |
| 81 | 120 | #endif |
| 82 | 121 | |
| 83 | 122 | return 0; |
configs/mx7ulp_evk_defconfig
| ... | ... | @@ -50,4 +50,13 @@ |
| 50 | 50 | CONFIG_SF_DEFAULT_SPEED=40000000 |
| 51 | 51 | CONFIG_SF_DEFAULT_MODE=0 |
| 52 | 52 | CONFIG_ULP_WATCHDOG=y |
| 53 | +CONFIG_CMD_USB=y | |
| 54 | +CONFIG_USB=y | |
| 55 | +CONFIG_DM_USB=y | |
| 56 | +CONFIG_USB_EHCI_HCD=y | |
| 57 | +CONFIG_MXC_USB_OTG_HACTIVE=y | |
| 58 | +CONFIG_USB_STORAGE=y | |
| 59 | +CONFIG_USB_HOST_ETHER=y | |
| 60 | +CONFIG_USB_ETHER_ASIX=y | |
| 61 | +CONFIG_USB_ETHER_RTL8152=y |
configs/mx7ulp_evk_plugin_defconfig
| ... | ... | @@ -49,4 +49,13 @@ |
| 49 | 49 | CONFIG_SF_DEFAULT_SPEED=40000000 |
| 50 | 50 | CONFIG_SF_DEFAULT_MODE=0 |
| 51 | 51 | CONFIG_ULP_WATCHDOG=y |
| 52 | +CONFIG_CMD_USB=y | |
| 53 | +CONFIG_USB=y | |
| 54 | +CONFIG_DM_USB=y | |
| 55 | +CONFIG_USB_EHCI_HCD=y | |
| 56 | +CONFIG_MXC_USB_OTG_HACTIVE=y | |
| 57 | +CONFIG_USB_STORAGE=y | |
| 58 | +CONFIG_USB_HOST_ETHER=y | |
| 59 | +CONFIG_USB_ETHER_ASIX=y | |
| 60 | +CONFIG_USB_ETHER_RTL8152=y |