blob: a395ebcc67e9685a138f8e6b3e1937b891db29a3 [file] [log] [blame]
Tom Rix09c82bc2009-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
Lokesh Vutla37bce592013-05-30 02:54:30 +000033#include <asm/omap_common.h>
Tom Rix09c82bc2009-10-31 12:37:41 -050034#include <twl4030.h>
Steve Sakoman31367d12010-06-25 12:42:04 -070035#include <twl6030.h>
Tom Rix09c82bc2009-10-31 12:37:41 -050036#include "omap3.h"
37
38static int platform_needs_initialization = 1;
39
40struct musb_config musb_cfg = {
Ajay Kumar Gupta7e71dc72010-06-10 11:20:47 +053041 .regs = (struct musb_regs *)MENTOR_USB0_BASE,
42 .timeout = OMAP3_USB_TIMEOUT,
43 .musb_speed = 0,
Tom Rix09c82bc2009-10-31 12:37:41 -050044};
45
46/*
47 * OMAP3 USB OTG registers.
48 */
49struct omap3_otg_regs {
50 u32 revision;
51 u32 sysconfig;
52 u32 sysstatus;
53 u32 interfsel;
54 u32 simenable;
55 u32 forcestdby;
56};
57
58static struct omap3_otg_regs *otg;
59
60#define OMAP3_OTG_SYSCONFIG_SMART_STANDBY_MODE 0x2000
61#define OMAP3_OTG_SYSCONFIG_NO_STANDBY_MODE 0x1000
62#define OMAP3_OTG_SYSCONFIG_SMART_IDLE_MODE 0x0010
63#define OMAP3_OTG_SYSCONFIG_NO_IDLE_MODE 0x0008
64#define OMAP3_OTG_SYSCONFIG_ENABLEWAKEUP 0x0004
65#define OMAP3_OTG_SYSCONFIG_SOFTRESET 0x0002
66#define OMAP3_OTG_SYSCONFIG_AUTOIDLE 0x0001
67
68#define OMAP3_OTG_SYSSTATUS_RESETDONE 0x0001
69
Steve Sakoman31367d12010-06-25 12:42:04 -070070/* OMAP4430 has an internal PHY, use it */
71#ifdef CONFIG_OMAP4430
72#define OMAP3_OTG_INTERFSEL_OMAP 0x0000
73#else
Tom Rix09c82bc2009-10-31 12:37:41 -050074#define OMAP3_OTG_INTERFSEL_OMAP 0x0001
Steve Sakoman31367d12010-06-25 12:42:04 -070075#endif
Tom Rix09c82bc2009-10-31 12:37:41 -050076
77#define OMAP3_OTG_FORCESTDBY_STANDBY 0x0001
78
79
80#ifdef DEBUG_MUSB_OMAP3
81static void musb_db_otg_regs(void)
82{
83 u32 l;
84 l = readl(&otg->revision);
85 serial_printf("OTG_REVISION 0x%x\n", l);
86 l = readl(&otg->sysconfig);
87 serial_printf("OTG_SYSCONFIG 0x%x\n", l);
88 l = readl(&otg->sysstatus);
89 serial_printf("OTG_SYSSTATUS 0x%x\n", l);
90 l = readl(&otg->interfsel);
91 serial_printf("OTG_INTERFSEL 0x%x\n", l);
92 l = readl(&otg->forcestdby);
93 serial_printf("OTG_FORCESTDBY 0x%x\n", l);
94}
95#endif
96
97int musb_platform_init(void)
98{
99 int ret = -1;
100
101 if (platform_needs_initialization) {
102 u32 stdby;
103
Tom Rix8526c6f2009-10-31 12:37:46 -0500104 /*
105 * OMAP3EVM uses ISP1504 phy and so
106 * twl4030 related init is not required.
107 */
108#ifdef CONFIG_TWL4030_USB
Tom Rix09c82bc2009-10-31 12:37:41 -0500109 if (twl4030_usb_ulpi_init()) {
110 serial_printf("ERROR: %s Could not initialize PHY\n",
111 __PRETTY_FUNCTION__);
112 goto end;
113 }
Tom Rix8526c6f2009-10-31 12:37:46 -0500114#endif
Steve Sakoman31367d12010-06-25 12:42:04 -0700115
116#ifdef CONFIG_TWL6030_POWER
117 twl6030_usb_device_settings();
118#endif
119
Tom Rix09c82bc2009-10-31 12:37:41 -0500120 otg = (struct omap3_otg_regs *)OMAP3_OTG_BASE;
121
122 /* Set OTG to always be on */
123 writel(OMAP3_OTG_SYSCONFIG_NO_STANDBY_MODE |
124 OMAP3_OTG_SYSCONFIG_NO_IDLE_MODE, &otg->sysconfig);
125
126 /* Set the interface */
127 writel(OMAP3_OTG_INTERFSEL_OMAP, &otg->interfsel);
128
129 /* Clear force standby */
130 stdby = readl(&otg->forcestdby);
131 stdby &= ~OMAP3_OTG_FORCESTDBY_STANDBY;
132 writel(stdby, &otg->forcestdby);
133
Ajay Kumar Guptaaeeac6b2010-06-10 11:20:50 +0530134#ifdef CONFIG_OMAP3_EVM
135 musb_cfg.extvbus = omap3_evm_need_extvbus();
136#endif
Steve Sakoman31367d12010-06-25 12:42:04 -0700137
138#ifdef CONFIG_OMAP4430
Lokesh Vutla37bce592013-05-30 02:54:30 +0000139 u32 *usbotghs_control =
140 (u32 *)((*ctrl)->control_usbotghs_ctrl);
Steve Sakoman31367d12010-06-25 12:42:04 -0700141 *usbotghs_control = 0x15;
142#endif
Tom Rix09c82bc2009-10-31 12:37:41 -0500143 platform_needs_initialization = 0;
144 }
145
146 ret = platform_needs_initialization;
Sanjeev Premi3a761ff2009-12-24 14:20:41 +0530147
148#ifdef CONFIG_TWL4030_USB
Tom Rix09c82bc2009-10-31 12:37:41 -0500149end:
Sanjeev Premi3a761ff2009-12-24 14:20:41 +0530150#endif
Tom Rix09c82bc2009-10-31 12:37:41 -0500151 return ret;
152
153}
154
155void musb_platform_deinit(void)
156{
157 /* noop */
158}