]>
git.ipfire.org Git - people/ms/u-boot.git/blob - drivers/usb/musb/da8xx.c
653410a57324e88e589bf73959683576e177230f
2 * da8xx.c - TI's DA8xx platform specific usb wrapper functions.
4 * Author: Ajay Kumar Gupta <ajay.gupta@ti.com>
6 * Based on drivers/usb/musb/davinci.c
8 * Copyright (C) 2009 Texas Instruments Incorporated
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include "musb_core.h"
27 #include <asm/arch/da8xx-usb.h>
29 /* MUSB platform configuration */
30 struct musb_config musb_cfg
= {
31 .regs
= (struct musb_regs
*)DA8XX_USB_OTG_CORE_BASE
,
32 .timeout
= DA8XX_USB_OTG_TIMEOUT
,
37 * This function enables VBUS by driving the GPIO Bank4 Pin 15 high.
39 static void enable_vbus(void)
43 /* configure GPIO bank4 pin 15 in output direction */
44 value
= readl(&davinci_gpio_bank45
->dir
);
45 writel((value
& (~DA8XX_USB_VBUS_GPIO
)), &davinci_gpio_bank45
->dir
);
47 /* set GPIO bank4 pin 15 high to drive VBUS */
48 value
= readl(&davinci_gpio_bank45
->set_data
);
49 writel((value
| DA8XX_USB_VBUS_GPIO
), &davinci_gpio_bank45
->set_data
);
53 * Enable the usb0 phy. This initialization procedure is explained in
54 * the DA8xx USB user guide document.
56 static u8
phy_on(void)
61 cfgchip2
= readl(&davinci_syscfg_regs
->cfgchip2
);
63 cfgchip2
&= ~(CFGCHIP2_RESET
| CFGCHIP2_PHYPWRDN
| CFGCHIP2_OTGPWRDN
|
64 CFGCHIP2_OTGMODE
| CFGCHIP2_REFFREQ
);
65 cfgchip2
|= CFGCHIP2_SESENDEN
| CFGCHIP2_VBDTCTEN
| CFGCHIP2_PHY_PLLON
|
66 CFGCHIP2_REFFREQ_24MHZ
;
68 writel(cfgchip2
, &davinci_syscfg_regs
->cfgchip2
);
70 /* wait until the usb phy pll locks */
71 timeout
= musb_cfg
.timeout
;
73 if (readl(&davinci_syscfg_regs
->cfgchip2
) & CFGCHIP2_PHYCLKGD
)
76 /* USB phy was not turned on */
83 static void phy_off(void)
88 * Power down the on-chip PHY.
90 cfgchip2
= readl(&davinci_syscfg_regs
->cfgchip2
);
91 cfgchip2
&= ~CFGCHIP2_PHY_PLLON
;
92 cfgchip2
|= CFGCHIP2_PHYPWRDN
| CFGCHIP2_OTGPWRDN
;
93 writel(cfgchip2
, &davinci_syscfg_regs
->cfgchip2
);
97 * This function performs DA8xx platform specific initialization for usb0.
99 int musb_platform_init(void)
103 /* enable psc for usb2.0 */
106 /* enable usb vbus */
109 /* reset the controller */
110 writel(0x1, &da8xx_usb_regs
->control
);
113 /* start the on-chip usb phy and its pll */
117 /* Returns zero if e.g. not clocked */
118 revision
= readl(&da8xx_usb_regs
->revision
);
122 /* Disable all interrupts */
123 writel((DA8XX_USB_USBINT_MASK
| DA8XX_USB_TXINT_MASK
|
124 DA8XX_USB_RXINT_MASK
), &da8xx_usb_regs
->intmsk_set
);
129 * This function performs DA8xx platform specific deinitialization for usb0.
131 void musb_platform_deinit(void)
133 /* Turn of the phy */
136 /* flush any interrupts */
137 writel((DA8XX_USB_USBINT_MASK
| DA8XX_USB_TXINT_MASK
|
138 DA8XX_USB_RXINT_MASK
), &da8xx_usb_regs
->intmsk_clr
);
139 writel(0, &da8xx_usb_regs
->eoi
);