Merge branch 'next'
[u-boot/qq2440-u-boot.git] / drivers / usb / musb / omap3.c
blob97da529b44e99d30c7267d47b3f161e50697a749
1 /*
2 * Copyright (c) 2009 Wind River Systems, Inc.
3 * Tom Rix <Tom.Rix@windriver.com>
5 * This is file is based on
6 * repository git.gitorious.org/u-boot-omap3/mainline.git,
7 * branch omap3-dev-usb, file drivers/usb/host/omap3530_usb.c
9 * This is the unique part of its copyright :
11 * ------------------------------------------------------------------------
13 * Copyright (c) 2009 Texas Instruments
15 * ------------------------------------------------------------------------
17 * SPDX-License-Identifier: GPL-2.0+
20 #include <asm/omap_common.h>
21 #include <twl4030.h>
22 #include <twl6030.h>
23 #include "omap3.h"
25 static int platform_needs_initialization = 1;
27 struct musb_config musb_cfg = {
28 .regs = (struct musb_regs *)MENTOR_USB0_BASE,
29 .timeout = OMAP3_USB_TIMEOUT,
30 .musb_speed = 0,
34 * OMAP3 USB OTG registers.
36 struct omap3_otg_regs {
37 u32 revision;
38 u32 sysconfig;
39 u32 sysstatus;
40 u32 interfsel;
41 u32 simenable;
42 u32 forcestdby;
45 static struct omap3_otg_regs *otg;
47 #define OMAP3_OTG_SYSCONFIG_SMART_STANDBY_MODE 0x2000
48 #define OMAP3_OTG_SYSCONFIG_NO_STANDBY_MODE 0x1000
49 #define OMAP3_OTG_SYSCONFIG_SMART_IDLE_MODE 0x0010
50 #define OMAP3_OTG_SYSCONFIG_NO_IDLE_MODE 0x0008
51 #define OMAP3_OTG_SYSCONFIG_ENABLEWAKEUP 0x0004
52 #define OMAP3_OTG_SYSCONFIG_SOFTRESET 0x0002
53 #define OMAP3_OTG_SYSCONFIG_AUTOIDLE 0x0001
55 #define OMAP3_OTG_SYSSTATUS_RESETDONE 0x0001
57 /* OMAP4430 has an internal PHY, use it */
58 #ifdef CONFIG_OMAP4430
59 #define OMAP3_OTG_INTERFSEL_OMAP 0x0000
60 #else
61 #define OMAP3_OTG_INTERFSEL_OMAP 0x0001
62 #endif
64 #define OMAP3_OTG_FORCESTDBY_STANDBY 0x0001
67 #ifdef DEBUG_MUSB_OMAP3
68 static void musb_db_otg_regs(void)
70 u32 l;
71 l = readl(&otg->revision);
72 serial_printf("OTG_REVISION 0x%x\n", l);
73 l = readl(&otg->sysconfig);
74 serial_printf("OTG_SYSCONFIG 0x%x\n", l);
75 l = readl(&otg->sysstatus);
76 serial_printf("OTG_SYSSTATUS 0x%x\n", l);
77 l = readl(&otg->interfsel);
78 serial_printf("OTG_INTERFSEL 0x%x\n", l);
79 l = readl(&otg->forcestdby);
80 serial_printf("OTG_FORCESTDBY 0x%x\n", l);
82 #endif
84 int musb_platform_init(void)
86 int ret = -1;
88 if (platform_needs_initialization) {
89 u32 stdby;
92 * OMAP3EVM uses ISP1504 phy and so
93 * twl4030 related init is not required.
95 #ifdef CONFIG_TWL4030_USB
96 if (twl4030_usb_ulpi_init()) {
97 serial_printf("ERROR: %s Could not initialize PHY\n",
98 __PRETTY_FUNCTION__);
99 goto end;
101 #endif
103 #ifdef CONFIG_TWL6030_POWER
104 twl6030_usb_device_settings();
105 #endif
107 otg = (struct omap3_otg_regs *)OMAP3_OTG_BASE;
109 /* Set OTG to always be on */
110 writel(OMAP3_OTG_SYSCONFIG_NO_STANDBY_MODE |
111 OMAP3_OTG_SYSCONFIG_NO_IDLE_MODE, &otg->sysconfig);
113 /* Set the interface */
114 writel(OMAP3_OTG_INTERFSEL_OMAP, &otg->interfsel);
116 /* Clear force standby */
117 stdby = readl(&otg->forcestdby);
118 stdby &= ~OMAP3_OTG_FORCESTDBY_STANDBY;
119 writel(stdby, &otg->forcestdby);
121 #ifdef CONFIG_OMAP3_EVM
122 musb_cfg.extvbus = omap3_evm_need_extvbus();
123 #endif
125 #ifdef CONFIG_OMAP4430
126 u32 *usbotghs_control =
127 (u32 *)((*ctrl)->control_usbotghs_ctrl);
128 *usbotghs_control = 0x15;
129 #endif
130 platform_needs_initialization = 0;
133 ret = platform_needs_initialization;
135 #ifdef CONFIG_TWL4030_USB
136 end:
137 #endif
138 return ret;
142 void musb_platform_deinit(void)
144 /* noop */