1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19#include <asm/omap_common.h>
20#include <twl4030.h>
21#include <twl6030.h>
22#include "omap3.h"
23
24static int platform_needs_initialization = 1;
25
26struct musb_config musb_cfg = {
27 .regs = (struct musb_regs *)MENTOR_USB0_BASE,
28 .timeout = OMAP3_USB_TIMEOUT,
29 .musb_speed = 0,
30};
31
32
33
34
35struct omap3_otg_regs {
36 u32 revision;
37 u32 sysconfig;
38 u32 sysstatus;
39 u32 interfsel;
40 u32 simenable;
41 u32 forcestdby;
42};
43
44static struct omap3_otg_regs *otg;
45
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
53
54#define OMAP3_OTG_SYSSTATUS_RESETDONE 0x0001
55
56
57#ifdef CONFIG_OMAP44XX
58#define OMAP3_OTG_INTERFSEL_OMAP 0x0000
59#else
60#define OMAP3_OTG_INTERFSEL_OMAP 0x0001
61#endif
62
63#define OMAP3_OTG_FORCESTDBY_STANDBY 0x0001
64
65
66#ifdef DEBUG_MUSB_OMAP3
67static void musb_db_otg_regs(void)
68{
69 u32 l;
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);
80}
81#endif
82
83int musb_platform_init(void)
84{
85 int ret = -1;
86
87 if (platform_needs_initialization) {
88 u32 stdby;
89
90
91
92
93
94#ifdef CONFIG_TWL4030_USB
95 if (twl4030_usb_ulpi_init()) {
96 serial_printf("ERROR: %s Could not initialize PHY\n",
97 __PRETTY_FUNCTION__);
98 goto end;
99 }
100#endif
101
102#ifdef CONFIG_TWL6030_POWER
103 twl6030_usb_device_settings();
104#endif
105
106 otg = (struct omap3_otg_regs *)OMAP3_OTG_BASE;
107
108
109 writel(OMAP3_OTG_SYSCONFIG_NO_STANDBY_MODE |
110 OMAP3_OTG_SYSCONFIG_NO_IDLE_MODE, &otg->sysconfig);
111
112
113 writel(OMAP3_OTG_INTERFSEL_OMAP, &otg->interfsel);
114
115
116 stdby = readl(&otg->forcestdby);
117 stdby &= ~OMAP3_OTG_FORCESTDBY_STANDBY;
118 writel(stdby, &otg->forcestdby);
119
120#ifdef CONFIG_TARGET_OMAP3_EVM
121 musb_cfg.extvbus = omap3_evm_need_extvbus();
122#endif
123
124#ifdef CONFIG_OMAP44XX
125 u32 *usbotghs_control =
126 (u32 *)((*ctrl)->control_usbotghs_ctrl);
127 *usbotghs_control = 0x15;
128#endif
129 platform_needs_initialization = 0;
130 }
131
132 ret = platform_needs_initialization;
133
134#ifdef CONFIG_TWL4030_USB
135end:
136#endif
137 return ret;
138
139}
140
141void musb_platform_deinit(void)
142{
143
144}
145