blob: c7876ed094b1a8bd02eb552babea20db4fe61487 [file] [log] [blame]
Tom Rixf298e4b2009-10-31 12:37:41 -05001/*
2 * Copyright (c) 2009 Wind River Systems, Inc.
3 * Tom Rix <Tom.Rix@windriver.com>
4 *
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
8 *
9 * This is the unique part of its copyright :
10 *
11 * ------------------------------------------------------------------------
12 *
13 * Copyright (c) 2009 Texas Instruments
14 *
15 * ------------------------------------------------------------------------
16 *
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License as
19 * published by the Free Software Foundation; either version 2 of
20 * the License, or (at your option) any later version.
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
30 * MA 02111-1307 USA
31 */
32
33#include <twl4030.h>
Steve Sakoman9b167572010-06-25 12:42:04 -070034#include <twl6030.h>
Tom Rixf298e4b2009-10-31 12:37:41 -050035#include "omap3.h"
36
37static int platform_needs_initialization = 1;
38
39struct musb_config musb_cfg = {
Ajay Kumar Guptabbf4c012010-06-10 11:20:47 +053040 .regs = (struct musb_regs *)MENTOR_USB0_BASE,
41 .timeout = OMAP3_USB_TIMEOUT,
42 .musb_speed = 0,
Tom Rixf298e4b2009-10-31 12:37:41 -050043};
44
45/*
46 * OMAP3 USB OTG registers.
47 */
48struct omap3_otg_regs {
49 u32 revision;
50 u32 sysconfig;
51 u32 sysstatus;
52 u32 interfsel;
53 u32 simenable;
54 u32 forcestdby;
55};
56
57static struct omap3_otg_regs *otg;
58
59#define OMAP3_OTG_SYSCONFIG_SMART_STANDBY_MODE 0x2000
60#define OMAP3_OTG_SYSCONFIG_NO_STANDBY_MODE 0x1000
61#define OMAP3_OTG_SYSCONFIG_SMART_IDLE_MODE 0x0010
62#define OMAP3_OTG_SYSCONFIG_NO_IDLE_MODE 0x0008
63#define OMAP3_OTG_SYSCONFIG_ENABLEWAKEUP 0x0004
64#define OMAP3_OTG_SYSCONFIG_SOFTRESET 0x0002
65#define OMAP3_OTG_SYSCONFIG_AUTOIDLE 0x0001
66
67#define OMAP3_OTG_SYSSTATUS_RESETDONE 0x0001
68
Steve Sakoman9b167572010-06-25 12:42:04 -070069/* OMAP4430 has an internal PHY, use it */
70#ifdef CONFIG_OMAP4430
71#define OMAP3_OTG_INTERFSEL_OMAP 0x0000
72#else
Tom Rixf298e4b2009-10-31 12:37:41 -050073#define OMAP3_OTG_INTERFSEL_OMAP 0x0001
Steve Sakoman9b167572010-06-25 12:42:04 -070074#endif
Tom Rixf298e4b2009-10-31 12:37:41 -050075
76#define OMAP3_OTG_FORCESTDBY_STANDBY 0x0001
77
78
79#ifdef DEBUG_MUSB_OMAP3
80static void musb_db_otg_regs(void)
81{
82 u32 l;
83 l = readl(&otg->revision);
84 serial_printf("OTG_REVISION 0x%x\n", l);
85 l = readl(&otg->sysconfig);
86 serial_printf("OTG_SYSCONFIG 0x%x\n", l);
87 l = readl(&otg->sysstatus);
88 serial_printf("OTG_SYSSTATUS 0x%x\n", l);
89 l = readl(&otg->interfsel);
90 serial_printf("OTG_INTERFSEL 0x%x\n", l);
91 l = readl(&otg->forcestdby);
92 serial_printf("OTG_FORCESTDBY 0x%x\n", l);
93}
94#endif
95
96int musb_platform_init(void)
97{
98 int ret = -1;
99
100 if (platform_needs_initialization) {
101 u32 stdby;
102
Tom Rixae4caf22009-10-31 12:37:46 -0500103 /*
104 * OMAP3EVM uses ISP1504 phy and so
105 * twl4030 related init is not required.
106 */
107#ifdef CONFIG_TWL4030_USB
Tom Rixf298e4b2009-10-31 12:37:41 -0500108 if (twl4030_usb_ulpi_init()) {
109 serial_printf("ERROR: %s Could not initialize PHY\n",
110 __PRETTY_FUNCTION__);
111 goto end;
112 }
Tom Rixae4caf22009-10-31 12:37:46 -0500113#endif
Steve Sakoman9b167572010-06-25 12:42:04 -0700114
115#ifdef CONFIG_TWL6030_POWER
116 twl6030_usb_device_settings();
117#endif
118
Tom Rixf298e4b2009-10-31 12:37:41 -0500119 otg = (struct omap3_otg_regs *)OMAP3_OTG_BASE;
120
121 /* Set OTG to always be on */
122 writel(OMAP3_OTG_SYSCONFIG_NO_STANDBY_MODE |
123 OMAP3_OTG_SYSCONFIG_NO_IDLE_MODE, &otg->sysconfig);
124
125 /* Set the interface */
126 writel(OMAP3_OTG_INTERFSEL_OMAP, &otg->interfsel);
127
128 /* Clear force standby */
129 stdby = readl(&otg->forcestdby);
130 stdby &= ~OMAP3_OTG_FORCESTDBY_STANDBY;
131 writel(stdby, &otg->forcestdby);
132
Ajay Kumar Gupta944a4892010-06-10 11:20:50 +0530133#ifdef CONFIG_OMAP3_EVM
134 musb_cfg.extvbus = omap3_evm_need_extvbus();
135#endif
Steve Sakoman9b167572010-06-25 12:42:04 -0700136
137#ifdef CONFIG_OMAP4430
138 u32 *usbotghs_control = (u32 *)(CTRL_BASE + 0x33C);
139 *usbotghs_control = 0x15;
140#endif
Tom Rixf298e4b2009-10-31 12:37:41 -0500141 platform_needs_initialization = 0;
142 }
143
144 ret = platform_needs_initialization;
Sanjeev Premib301be02009-12-24 14:20:41 +0530145
146#ifdef CONFIG_TWL4030_USB
Tom Rixf298e4b2009-10-31 12:37:41 -0500147end:
Sanjeev Premib301be02009-12-24 14:20:41 +0530148#endif
Tom Rixf298e4b2009-10-31 12:37:41 -0500149 return ret;
150
151}
152
153void musb_platform_deinit(void)
154{
155 /* noop */
156}