blob: b2e4c32baff415ade0644ecfb400f2b0cb9754de [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Tom Rixf298e4b2009-10-31 12:37:41 -05002/*
3 * Copyright (c) 2009 Wind River Systems, Inc.
4 * Tom Rix <Tom.Rix@windriver.com>
5 *
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
9 *
10 * This is the unique part of its copyright :
11 *
12 * ------------------------------------------------------------------------
13 *
14 * Copyright (c) 2009 Texas Instruments
15 *
16 * ------------------------------------------------------------------------
Tom Rixf298e4b2009-10-31 12:37:41 -050017 */
18
Lokesh Vutla9239f5b2013-05-30 02:54:30 +000019#include <asm/omap_common.h>
Tom Rixf298e4b2009-10-31 12:37:41 -050020#include <twl4030.h>
Steve Sakoman9b167572010-06-25 12:42:04 -070021#include <twl6030.h>
Tom Rixf298e4b2009-10-31 12:37:41 -050022#include "omap3.h"
23
24static int platform_needs_initialization = 1;
25
26struct musb_config musb_cfg = {
Ajay Kumar Guptabbf4c012010-06-10 11:20:47 +053027 .regs = (struct musb_regs *)MENTOR_USB0_BASE,
28 .timeout = OMAP3_USB_TIMEOUT,
29 .musb_speed = 0,
Tom Rixf298e4b2009-10-31 12:37:41 -050030};
31
32/*
33 * OMAP3 USB OTG registers.
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
Steve Sakoman9b167572010-06-25 12:42:04 -070056/* OMAP4430 has an internal PHY, use it */
Tom Rini77777f72017-05-12 22:33:19 -040057#ifdef CONFIG_OMAP44XX
Steve Sakoman9b167572010-06-25 12:42:04 -070058#define OMAP3_OTG_INTERFSEL_OMAP 0x0000
59#else
Tom Rixf298e4b2009-10-31 12:37:41 -050060#define OMAP3_OTG_INTERFSEL_OMAP 0x0001
Steve Sakoman9b167572010-06-25 12:42:04 -070061#endif
Tom Rixf298e4b2009-10-31 12:37:41 -050062
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
Tom Rixae4caf22009-10-31 12:37:46 -050090 /*
91 * OMAP3EVM uses ISP1504 phy and so
92 * twl4030 related init is not required.
93 */
94#ifdef CONFIG_TWL4030_USB
Tom Rixf298e4b2009-10-31 12:37:41 -050095 if (twl4030_usb_ulpi_init()) {
96 serial_printf("ERROR: %s Could not initialize PHY\n",
97 __PRETTY_FUNCTION__);
98 goto end;
99 }
Tom Rixae4caf22009-10-31 12:37:46 -0500100#endif
Steve Sakoman9b167572010-06-25 12:42:04 -0700101
102#ifdef CONFIG_TWL6030_POWER
103 twl6030_usb_device_settings();
104#endif
105
Tom Rixf298e4b2009-10-31 12:37:41 -0500106 otg = (struct omap3_otg_regs *)OMAP3_OTG_BASE;
107
108 /* Set OTG to always be on */
109 writel(OMAP3_OTG_SYSCONFIG_NO_STANDBY_MODE |
110 OMAP3_OTG_SYSCONFIG_NO_IDLE_MODE, &otg->sysconfig);
111
112 /* Set the interface */
113 writel(OMAP3_OTG_INTERFSEL_OMAP, &otg->interfsel);
114
115 /* Clear force standby */
116 stdby = readl(&otg->forcestdby);
117 stdby &= ~OMAP3_OTG_FORCESTDBY_STANDBY;
118 writel(stdby, &otg->forcestdby);
119
Tom Rini864896b2017-05-12 22:33:18 -0400120#ifdef CONFIG_TARGET_OMAP3_EVM
Ajay Kumar Gupta944a4892010-06-10 11:20:50 +0530121 musb_cfg.extvbus = omap3_evm_need_extvbus();
122#endif
Steve Sakoman9b167572010-06-25 12:42:04 -0700123
Tom Rini77777f72017-05-12 22:33:19 -0400124#ifdef CONFIG_OMAP44XX
Lokesh Vutla9239f5b2013-05-30 02:54:30 +0000125 u32 *usbotghs_control =
126 (u32 *)((*ctrl)->control_usbotghs_ctrl);
Steve Sakoman9b167572010-06-25 12:42:04 -0700127 *usbotghs_control = 0x15;
128#endif
Tom Rixf298e4b2009-10-31 12:37:41 -0500129 platform_needs_initialization = 0;
130 }
131
132 ret = platform_needs_initialization;
Sanjeev Premib301be02009-12-24 14:20:41 +0530133
134#ifdef CONFIG_TWL4030_USB
Tom Rixf298e4b2009-10-31 12:37:41 -0500135end:
Sanjeev Premib301be02009-12-24 14:20:41 +0530136#endif
Tom Rixf298e4b2009-10-31 12:37:41 -0500137 return ret;
138
139}
140
141void musb_platform_deinit(void)
142{
143 /* noop */
144}