1f298e4b6STom Rix /*
2f298e4b6STom Rix * Copyright (c) 2009 Wind River Systems, Inc.
3f298e4b6STom Rix * Tom Rix <Tom.Rix@windriver.com>
4f298e4b6STom Rix *
5f298e4b6STom Rix * This is file is based on
6f298e4b6STom Rix * repository git.gitorious.org/u-boot-omap3/mainline.git,
7f298e4b6STom Rix * branch omap3-dev-usb, file drivers/usb/host/omap3530_usb.c
8f298e4b6STom Rix *
9f298e4b6STom Rix * This is the unique part of its copyright :
10f298e4b6STom Rix *
11f298e4b6STom Rix * ------------------------------------------------------------------------
12f298e4b6STom Rix *
13f298e4b6STom Rix * Copyright (c) 2009 Texas Instruments
14f298e4b6STom Rix *
15f298e4b6STom Rix * ------------------------------------------------------------------------
16f298e4b6STom Rix *
171a459660SWolfgang Denk * SPDX-License-Identifier: GPL-2.0+
18f298e4b6STom Rix */
19f298e4b6STom Rix
209239f5b6SLokesh Vutla #include <asm/omap_common.h>
21f298e4b6STom Rix #include <twl4030.h>
229b167577SSteve Sakoman #include <twl6030.h>
23f298e4b6STom Rix #include "omap3.h"
24f298e4b6STom Rix
25f298e4b6STom Rix static int platform_needs_initialization = 1;
26f298e4b6STom Rix
27f298e4b6STom Rix struct musb_config musb_cfg = {
28bbf4c01eSAjay Kumar Gupta .regs = (struct musb_regs *)MENTOR_USB0_BASE,
29bbf4c01eSAjay Kumar Gupta .timeout = OMAP3_USB_TIMEOUT,
30bbf4c01eSAjay Kumar Gupta .musb_speed = 0,
31f298e4b6STom Rix };
32f298e4b6STom Rix
33f298e4b6STom Rix /*
34f298e4b6STom Rix * OMAP3 USB OTG registers.
35f298e4b6STom Rix */
36f298e4b6STom Rix struct omap3_otg_regs {
37f298e4b6STom Rix u32 revision;
38f298e4b6STom Rix u32 sysconfig;
39f298e4b6STom Rix u32 sysstatus;
40f298e4b6STom Rix u32 interfsel;
41f298e4b6STom Rix u32 simenable;
42f298e4b6STom Rix u32 forcestdby;
43f298e4b6STom Rix };
44f298e4b6STom Rix
45f298e4b6STom Rix static struct omap3_otg_regs *otg;
46f298e4b6STom Rix
47f298e4b6STom Rix #define OMAP3_OTG_SYSCONFIG_SMART_STANDBY_MODE 0x2000
48f298e4b6STom Rix #define OMAP3_OTG_SYSCONFIG_NO_STANDBY_MODE 0x1000
49f298e4b6STom Rix #define OMAP3_OTG_SYSCONFIG_SMART_IDLE_MODE 0x0010
50f298e4b6STom Rix #define OMAP3_OTG_SYSCONFIG_NO_IDLE_MODE 0x0008
51f298e4b6STom Rix #define OMAP3_OTG_SYSCONFIG_ENABLEWAKEUP 0x0004
52f298e4b6STom Rix #define OMAP3_OTG_SYSCONFIG_SOFTRESET 0x0002
53f298e4b6STom Rix #define OMAP3_OTG_SYSCONFIG_AUTOIDLE 0x0001
54f298e4b6STom Rix
55f298e4b6STom Rix #define OMAP3_OTG_SYSSTATUS_RESETDONE 0x0001
56f298e4b6STom Rix
579b167577SSteve Sakoman /* OMAP4430 has an internal PHY, use it */
58*77777f76STom Rini #ifdef CONFIG_OMAP44XX
599b167577SSteve Sakoman #define OMAP3_OTG_INTERFSEL_OMAP 0x0000
609b167577SSteve Sakoman #else
61f298e4b6STom Rix #define OMAP3_OTG_INTERFSEL_OMAP 0x0001
629b167577SSteve Sakoman #endif
63f298e4b6STom Rix
64f298e4b6STom Rix #define OMAP3_OTG_FORCESTDBY_STANDBY 0x0001
65f298e4b6STom Rix
66f298e4b6STom Rix
67f298e4b6STom Rix #ifdef DEBUG_MUSB_OMAP3
musb_db_otg_regs(void)68f298e4b6STom Rix static void musb_db_otg_regs(void)
69f298e4b6STom Rix {
70f298e4b6STom Rix u32 l;
71f298e4b6STom Rix l = readl(&otg->revision);
72f298e4b6STom Rix serial_printf("OTG_REVISION 0x%x\n", l);
73f298e4b6STom Rix l = readl(&otg->sysconfig);
74f298e4b6STom Rix serial_printf("OTG_SYSCONFIG 0x%x\n", l);
75f298e4b6STom Rix l = readl(&otg->sysstatus);
76f298e4b6STom Rix serial_printf("OTG_SYSSTATUS 0x%x\n", l);
77f298e4b6STom Rix l = readl(&otg->interfsel);
78f298e4b6STom Rix serial_printf("OTG_INTERFSEL 0x%x\n", l);
79f298e4b6STom Rix l = readl(&otg->forcestdby);
80f298e4b6STom Rix serial_printf("OTG_FORCESTDBY 0x%x\n", l);
81f298e4b6STom Rix }
82f298e4b6STom Rix #endif
83f298e4b6STom Rix
musb_platform_init(void)84f298e4b6STom Rix int musb_platform_init(void)
85f298e4b6STom Rix {
86f298e4b6STom Rix int ret = -1;
87f298e4b6STom Rix
88f298e4b6STom Rix if (platform_needs_initialization) {
89f298e4b6STom Rix u32 stdby;
90f298e4b6STom Rix
91ae4caf2fSTom Rix /*
92ae4caf2fSTom Rix * OMAP3EVM uses ISP1504 phy and so
93ae4caf2fSTom Rix * twl4030 related init is not required.
94ae4caf2fSTom Rix */
95ae4caf2fSTom Rix #ifdef CONFIG_TWL4030_USB
96f298e4b6STom Rix if (twl4030_usb_ulpi_init()) {
97f298e4b6STom Rix serial_printf("ERROR: %s Could not initialize PHY\n",
98f298e4b6STom Rix __PRETTY_FUNCTION__);
99f298e4b6STom Rix goto end;
100f298e4b6STom Rix }
101ae4caf2fSTom Rix #endif
1029b167577SSteve Sakoman
1039b167577SSteve Sakoman #ifdef CONFIG_TWL6030_POWER
1049b167577SSteve Sakoman twl6030_usb_device_settings();
1059b167577SSteve Sakoman #endif
1069b167577SSteve Sakoman
107f298e4b6STom Rix otg = (struct omap3_otg_regs *)OMAP3_OTG_BASE;
108f298e4b6STom Rix
109f298e4b6STom Rix /* Set OTG to always be on */
110f298e4b6STom Rix writel(OMAP3_OTG_SYSCONFIG_NO_STANDBY_MODE |
111f298e4b6STom Rix OMAP3_OTG_SYSCONFIG_NO_IDLE_MODE, &otg->sysconfig);
112f298e4b6STom Rix
113f298e4b6STom Rix /* Set the interface */
114f298e4b6STom Rix writel(OMAP3_OTG_INTERFSEL_OMAP, &otg->interfsel);
115f298e4b6STom Rix
116f298e4b6STom Rix /* Clear force standby */
117f298e4b6STom Rix stdby = readl(&otg->forcestdby);
118f298e4b6STom Rix stdby &= ~OMAP3_OTG_FORCESTDBY_STANDBY;
119f298e4b6STom Rix writel(stdby, &otg->forcestdby);
120f298e4b6STom Rix
121864896beSTom Rini #ifdef CONFIG_TARGET_OMAP3_EVM
122944a4894SAjay Kumar Gupta musb_cfg.extvbus = omap3_evm_need_extvbus();
123944a4894SAjay Kumar Gupta #endif
1249b167577SSteve Sakoman
125*77777f76STom Rini #ifdef CONFIG_OMAP44XX
1269239f5b6SLokesh Vutla u32 *usbotghs_control =
1279239f5b6SLokesh Vutla (u32 *)((*ctrl)->control_usbotghs_ctrl);
1289b167577SSteve Sakoman *usbotghs_control = 0x15;
1299b167577SSteve Sakoman #endif
130f298e4b6STom Rix platform_needs_initialization = 0;
131f298e4b6STom Rix }
132f298e4b6STom Rix
133f298e4b6STom Rix ret = platform_needs_initialization;
134b301be05SSanjeev Premi
135b301be05SSanjeev Premi #ifdef CONFIG_TWL4030_USB
136f298e4b6STom Rix end:
137b301be05SSanjeev Premi #endif
138f298e4b6STom Rix return ret;
139f298e4b6STom Rix
140f298e4b6STom Rix }
141f298e4b6STom Rix
musb_platform_deinit(void)142f298e4b6STom Rix void musb_platform_deinit(void)
143f298e4b6STom Rix {
144f298e4b6STom Rix /* noop */
145f298e4b6STom Rix }
146