blob: e5238bc02f891794186ce659e1ca977a2589b70b [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Tom Rix09c82bc2009-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 Rix09c82bc2009-10-31 12:37:41 -050017 */
18
Simon Glassbd7a59a2019-11-14 12:57:23 -070019#include <serial.h>
Lokesh Vutla37bce592013-05-30 02:54:30 +000020#include <asm/omap_common.h>
Tom Rix09c82bc2009-10-31 12:37:41 -050021#include <twl4030.h>
22#include "omap3.h"
23
24static int platform_needs_initialization = 1;
25
26struct musb_config musb_cfg = {
Ajay Kumar Gupta7e71dc72010-06-10 11:20:47 +053027 .regs = (struct musb_regs *)MENTOR_USB0_BASE,
28 .timeout = OMAP3_USB_TIMEOUT,
29 .musb_speed = 0,
Tom Rix09c82bc2009-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
56#define OMAP3_OTG_INTERFSEL_OMAP 0x0001
57
58#define OMAP3_OTG_FORCESTDBY_STANDBY 0x0001
59
Tom Rix09c82bc2009-10-31 12:37:41 -050060#ifdef DEBUG_MUSB_OMAP3
61static void musb_db_otg_regs(void)
62{
63 u32 l;
64 l = readl(&otg->revision);
65 serial_printf("OTG_REVISION 0x%x\n", l);
66 l = readl(&otg->sysconfig);
67 serial_printf("OTG_SYSCONFIG 0x%x\n", l);
68 l = readl(&otg->sysstatus);
69 serial_printf("OTG_SYSSTATUS 0x%x\n", l);
70 l = readl(&otg->interfsel);
71 serial_printf("OTG_INTERFSEL 0x%x\n", l);
72 l = readl(&otg->forcestdby);
73 serial_printf("OTG_FORCESTDBY 0x%x\n", l);
74}
75#endif
76
77int musb_platform_init(void)
78{
79 int ret = -1;
80
81 if (platform_needs_initialization) {
82 u32 stdby;
83
Tom Rix8526c6f2009-10-31 12:37:46 -050084 /*
85 * OMAP3EVM uses ISP1504 phy and so
86 * twl4030 related init is not required.
87 */
88#ifdef CONFIG_TWL4030_USB
Tom Rix09c82bc2009-10-31 12:37:41 -050089 if (twl4030_usb_ulpi_init()) {
90 serial_printf("ERROR: %s Could not initialize PHY\n",
91 __PRETTY_FUNCTION__);
92 goto end;
93 }
Tom Rix8526c6f2009-10-31 12:37:46 -050094#endif
Steve Sakoman31367d12010-06-25 12:42:04 -070095
Tom Rix09c82bc2009-10-31 12:37:41 -050096 otg = (struct omap3_otg_regs *)OMAP3_OTG_BASE;
97
98 /* Set OTG to always be on */
99 writel(OMAP3_OTG_SYSCONFIG_NO_STANDBY_MODE |
100 OMAP3_OTG_SYSCONFIG_NO_IDLE_MODE, &otg->sysconfig);
101
102 /* Set the interface */
103 writel(OMAP3_OTG_INTERFSEL_OMAP, &otg->interfsel);
104
105 /* Clear force standby */
106 stdby = readl(&otg->forcestdby);
107 stdby &= ~OMAP3_OTG_FORCESTDBY_STANDBY;
108 writel(stdby, &otg->forcestdby);
109
Tom Rini38216ee2017-05-12 22:33:18 -0400110#ifdef CONFIG_TARGET_OMAP3_EVM
Ajay Kumar Guptaaeeac6b2010-06-10 11:20:50 +0530111 musb_cfg.extvbus = omap3_evm_need_extvbus();
112#endif
Steve Sakoman31367d12010-06-25 12:42:04 -0700113
Tom Rix09c82bc2009-10-31 12:37:41 -0500114 platform_needs_initialization = 0;
115 }
116
117 ret = platform_needs_initialization;
Sanjeev Premi3a761ff2009-12-24 14:20:41 +0530118
119#ifdef CONFIG_TWL4030_USB
Tom Rix09c82bc2009-10-31 12:37:41 -0500120end:
Sanjeev Premi3a761ff2009-12-24 14:20:41 +0530121#endif
Tom Rix09c82bc2009-10-31 12:37:41 -0500122 return ret;
123
124}
125
126void musb_platform_deinit(void)
127{
128 /* noop */
129}