]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | // SPDX-License-Identifier: GPL-2.0+ |
f298e4b6 TR |
2 | /* |
3 | * Copyright (c) 2009 Wind River Systems, Inc. | |
4 | * Tom Rix <[email protected]> | |
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 | * ------------------------------------------------------------------------ | |
f298e4b6 TR |
17 | */ |
18 | ||
f516fd99 | 19 | #include <serial.h> |
9239f5b6 | 20 | #include <asm/omap_common.h> |
f298e4b6 TR |
21 | #include <twl4030.h> |
22 | #include "omap3.h" | |
23 | ||
24 | static int platform_needs_initialization = 1; | |
25 | ||
26 | struct musb_config musb_cfg = { | |
bbf4c01e AKG |
27 | .regs = (struct musb_regs *)MENTOR_USB0_BASE, |
28 | .timeout = OMAP3_USB_TIMEOUT, | |
29 | .musb_speed = 0, | |
f298e4b6 TR |
30 | }; |
31 | ||
32 | /* | |
33 | * OMAP3 USB OTG registers. | |
34 | */ | |
35 | struct omap3_otg_regs { | |
36 | u32 revision; | |
37 | u32 sysconfig; | |
38 | u32 sysstatus; | |
39 | u32 interfsel; | |
40 | u32 simenable; | |
41 | u32 forcestdby; | |
42 | }; | |
43 | ||
44 | static 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 | ||
f298e4b6 TR |
60 | #ifdef DEBUG_MUSB_OMAP3 |
61 | static 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 | ||
77 | int musb_platform_init(void) | |
78 | { | |
79 | int ret = -1; | |
80 | ||
81 | if (platform_needs_initialization) { | |
82 | u32 stdby; | |
83 | ||
ae4caf2f TR |
84 | /* |
85 | * OMAP3EVM uses ISP1504 phy and so | |
86 | * twl4030 related init is not required. | |
87 | */ | |
88 | #ifdef CONFIG_TWL4030_USB | |
f298e4b6 TR |
89 | if (twl4030_usb_ulpi_init()) { |
90 | serial_printf("ERROR: %s Could not initialize PHY\n", | |
91 | __PRETTY_FUNCTION__); | |
92 | goto end; | |
93 | } | |
ae4caf2f | 94 | #endif |
9b167577 | 95 | |
f298e4b6 TR |
96 | 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 | ||
864896be | 110 | #ifdef CONFIG_TARGET_OMAP3_EVM |
944a4894 AKG |
111 | musb_cfg.extvbus = omap3_evm_need_extvbus(); |
112 | #endif | |
9b167577 | 113 | |
f298e4b6 TR |
114 | platform_needs_initialization = 0; |
115 | } | |
116 | ||
117 | ret = platform_needs_initialization; | |
b301be05 SP |
118 | |
119 | #ifdef CONFIG_TWL4030_USB | |
f298e4b6 | 120 | end: |
b301be05 | 121 | #endif |
f298e4b6 TR |
122 | return ret; |
123 | ||
124 | } | |
125 | ||
126 | void musb_platform_deinit(void) | |
127 | { | |
128 | /* noop */ | |
129 | } |