aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/omap_phy_internal.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-03-17 22:28:15 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-03-17 22:28:15 -0400
commit0df0914d414a504b975f3cc66ace0c16ef55b7f3 (patch)
treec97ffa357943a8b226cdec1b9632c4cede813205 /arch/arm/mach-omap2/omap_phy_internal.c
parent6899608533410557e6698cb9d4ff6df553916e98 (diff)
parent05f689400ea5fa3d71af82f910c8b140f87ad1f3 (diff)
Merge branch 'omap-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap-2.6
* 'omap-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap-2.6: (258 commits) omap: zoom: host should not pull up wl1271's irq line arm: plat-omap: iommu: fix request_mem_region() error path OMAP2+: Common CPU DIE ID reading code reads wrong registers for OMAP4430 omap4: mux: Remove duplicate mux modes omap: iovmm: don't check 'da' to set IOVMF_DA_FIXED flag omap: iovmm: disallow mapping NULL address when IOVMF_DA_ANON is set omap2+: mux: Fix compile when CONFIG_OMAP_MUX is not selected omap4: board-omap4panda: Initialise the serial pads omap3: board-3430sdp: Initialise the serial pads omap4: board-4430sdp: Initialise the serial pads omap2+: mux: Add macro for configuring static with omap_hwmod_mux_init omap2+: mux: Remove the use of IDLE flag omap2+: Add separate list for dynamic pads to mux perf: add OMAP support for the new power events OMAP4: Add IVA OPP enteries. OMAP4: Update Voltage Rail Values for MPU, IVA and CORE OMAP4: Enable 800 MHz and 1 GHz MPU-OPP OMAP3+: OPP: Replace voltage values with Macros OMAP3: wdtimer: Fix CORE idle transition Watchdog: omap_wdt: add fine grain runtime-pm ... Fix up various conflicts in - arch/arm/mach-omap2/board-omap3evm.c - arch/arm/mach-omap2/clock3xxx_data.c - arch/arm/mach-omap2/usb-musb.c - arch/arm/plat-omap/include/plat/usb.h - drivers/usb/musb/musb_core.h
Diffstat (limited to 'arch/arm/mach-omap2/omap_phy_internal.c')
-rw-r--r--arch/arm/mach-omap2/omap_phy_internal.c93
1 files changed, 93 insertions, 0 deletions
diff --git a/arch/arm/mach-omap2/omap_phy_internal.c b/arch/arm/mach-omap2/omap_phy_internal.c
index ebe33df708bd..e2e605fe9138 100644
--- a/arch/arm/mach-omap2/omap_phy_internal.c
+++ b/arch/arm/mach-omap2/omap_phy_internal.c
@@ -29,6 +29,7 @@
29#include <linux/usb.h> 29#include <linux/usb.h>
30 30
31#include <plat/usb.h> 31#include <plat/usb.h>
32#include "control.h"
32 33
33/* OMAP control module register for UTMI PHY */ 34/* OMAP control module register for UTMI PHY */
34#define CONTROL_DEV_CONF 0x300 35#define CONTROL_DEV_CONF 0x300
@@ -162,3 +163,95 @@ int omap4430_phy_exit(struct device *dev)
162 163
163 return 0; 164 return 0;
164} 165}
166
167void am35x_musb_reset(void)
168{
169 u32 regval;
170
171 /* Reset the musb interface */
172 regval = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET);
173
174 regval |= AM35XX_USBOTGSS_SW_RST;
175 omap_ctrl_writel(regval, AM35XX_CONTROL_IP_SW_RESET);
176
177 regval &= ~AM35XX_USBOTGSS_SW_RST;
178 omap_ctrl_writel(regval, AM35XX_CONTROL_IP_SW_RESET);
179
180 regval = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET);
181}
182
183void am35x_musb_phy_power(u8 on)
184{
185 unsigned long timeout = jiffies + msecs_to_jiffies(100);
186 u32 devconf2;
187
188 if (on) {
189 /*
190 * Start the on-chip PHY and its PLL.
191 */
192 devconf2 = omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2);
193
194 devconf2 &= ~(CONF2_RESET | CONF2_PHYPWRDN | CONF2_OTGPWRDN);
195 devconf2 |= CONF2_PHY_PLLON;
196
197 omap_ctrl_writel(devconf2, AM35XX_CONTROL_DEVCONF2);
198
199 pr_info(KERN_INFO "Waiting for PHY clock good...\n");
200 while (!(omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2)
201 & CONF2_PHYCLKGD)) {
202 cpu_relax();
203
204 if (time_after(jiffies, timeout)) {
205 pr_err(KERN_ERR "musb PHY clock good timed out\n");
206 break;
207 }
208 }
209 } else {
210 /*
211 * Power down the on-chip PHY.
212 */
213 devconf2 = omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2);
214
215 devconf2 &= ~CONF2_PHY_PLLON;
216 devconf2 |= CONF2_PHYPWRDN | CONF2_OTGPWRDN;
217 omap_ctrl_writel(devconf2, AM35XX_CONTROL_DEVCONF2);
218 }
219}
220
221void am35x_musb_clear_irq(void)
222{
223 u32 regval;
224
225 regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
226 regval |= AM35XX_USBOTGSS_INT_CLR;
227 omap_ctrl_writel(regval, AM35XX_CONTROL_LVL_INTR_CLEAR);
228 regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
229}
230
231void am35x_musb_set_mode(u8 musb_mode)
232{
233 u32 devconf2 = omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2);
234
235 devconf2 &= ~CONF2_OTGMODE;
236 switch (musb_mode) {
237#ifdef CONFIG_USB_MUSB_HDRC_HCD
238 case MUSB_HOST: /* Force VBUS valid, ID = 0 */
239 devconf2 |= CONF2_FORCE_HOST;
240 break;
241#endif
242#ifdef CONFIG_USB_GADGET_MUSB_HDRC
243 case MUSB_PERIPHERAL: /* Force VBUS valid, ID = 1 */
244 devconf2 |= CONF2_FORCE_DEVICE;
245 break;
246#endif
247#ifdef CONFIG_USB_MUSB_OTG
248 case MUSB_OTG: /* Don't override the VBUS/ID comparators */
249 devconf2 |= CONF2_NO_OVERRIDE;
250 break;
251#endif
252 default:
253 pr_info(KERN_INFO "Unsupported mode %u\n", musb_mode);
254 }
255
256 omap_ctrl_writel(devconf2, AM35XX_CONTROL_DEVCONF2);
257}