1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 2009 Wind River Systems, Inc.
4 * Tom Rix <Tom.Rix@windriver.com>
6 * This is file is based on
7 * repository git.gitorious.org/u-boot-omap3/mainline.git,
8 * branch omap3-dev-usb, file drivers/usb/host/omap3530_usb.c
10 * This is the unique part of its copyright :
12 * ------------------------------------------------------------------------
14 * Copyright (c) 2009 Texas Instruments
16 * ------------------------------------------------------------------------
19 #include <asm/omap_common.h>
24 static int platform_needs_initialization = 1;
26 struct musb_config musb_cfg = {
27 .regs = (struct musb_regs *)MENTOR_USB0_BASE,
28 .timeout = OMAP3_USB_TIMEOUT,
33 * OMAP3 USB OTG registers.
35 struct omap3_otg_regs {
44 static struct omap3_otg_regs *otg;
46 #define OMAP3_OTG_SYSCONFIG_SMART_STANDBY_MODE 0x2000
47 #define OMAP3_OTG_SYSCONFIG_NO_STANDBY_MODE 0x1000
48 #define OMAP3_OTG_SYSCONFIG_SMART_IDLE_MODE 0x0010
49 #define OMAP3_OTG_SYSCONFIG_NO_IDLE_MODE 0x0008
50 #define OMAP3_OTG_SYSCONFIG_ENABLEWAKEUP 0x0004
51 #define OMAP3_OTG_SYSCONFIG_SOFTRESET 0x0002
52 #define OMAP3_OTG_SYSCONFIG_AUTOIDLE 0x0001
54 #define OMAP3_OTG_SYSSTATUS_RESETDONE 0x0001
56 /* OMAP4430 has an internal PHY, use it */
57 #ifdef CONFIG_OMAP44XX
58 #define OMAP3_OTG_INTERFSEL_OMAP 0x0000
60 #define OMAP3_OTG_INTERFSEL_OMAP 0x0001
63 #define OMAP3_OTG_FORCESTDBY_STANDBY 0x0001
66 #ifdef DEBUG_MUSB_OMAP3
67 static void musb_db_otg_regs(void)
70 l = readl(&otg->revision);
71 serial_printf("OTG_REVISION 0x%x\n", l);
72 l = readl(&otg->sysconfig);
73 serial_printf("OTG_SYSCONFIG 0x%x\n", l);
74 l = readl(&otg->sysstatus);
75 serial_printf("OTG_SYSSTATUS 0x%x\n", l);
76 l = readl(&otg->interfsel);
77 serial_printf("OTG_INTERFSEL 0x%x\n", l);
78 l = readl(&otg->forcestdby);
79 serial_printf("OTG_FORCESTDBY 0x%x\n", l);
83 int musb_platform_init(void)
87 if (platform_needs_initialization) {
91 * OMAP3EVM uses ISP1504 phy and so
92 * twl4030 related init is not required.
94 #ifdef CONFIG_TWL4030_USB
95 if (twl4030_usb_ulpi_init()) {
96 serial_printf("ERROR: %s Could not initialize PHY\n",
102 #ifdef CONFIG_TWL6030_POWER
103 twl6030_usb_device_settings();
106 otg = (struct omap3_otg_regs *)OMAP3_OTG_BASE;
108 /* Set OTG to always be on */
109 writel(OMAP3_OTG_SYSCONFIG_NO_STANDBY_MODE |
110 OMAP3_OTG_SYSCONFIG_NO_IDLE_MODE, &otg->sysconfig);
112 /* Set the interface */
113 writel(OMAP3_OTG_INTERFSEL_OMAP, &otg->interfsel);
115 /* Clear force standby */
116 stdby = readl(&otg->forcestdby);
117 stdby &= ~OMAP3_OTG_FORCESTDBY_STANDBY;
118 writel(stdby, &otg->forcestdby);
120 #ifdef CONFIG_TARGET_OMAP3_EVM
121 musb_cfg.extvbus = omap3_evm_need_extvbus();
124 #ifdef CONFIG_OMAP44XX
125 u32 *usbotghs_control =
126 (u32 *)((*ctrl)->control_usbotghs_ctrl);
127 *usbotghs_control = 0x15;
129 platform_needs_initialization = 0;
132 ret = platform_needs_initialization;
134 #ifdef CONFIG_TWL4030_USB
141 void musb_platform_deinit(void)