2 * TI's Davinci platform specific USB wrapper functions.
4 * Copyright (c) 2008 Texas Instruments
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of
9 * the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * Author: Thomas Abraham t-abraham@ti.com, Texas Instruments
27 #include <asm/arch/hardware.h>
29 /* MUSB platform configuration */
30 struct musb_config musb_cfg = {
31 .regs = (struct musb_regs *)MENTOR_USB0_BASE,
32 .timeout = DAVINCI_USB_TIMEOUT,
36 /* MUSB module register overlay */
37 struct davinci_usb_regs *dregs;
42 static u8 phy_on(void)
45 #ifdef DAVINCI_DM365EVM
48 /* Wait until the USB phy is turned on */
49 #ifdef DAVINCI_DM365EVM
50 writel(USBPHY_PHY24MHZ | USBPHY_SESNDEN |
51 USBPHY_VBDTCTEN, USBPHY_CTL_PADDR);
53 writel(USBPHY_SESNDEN | USBPHY_VBDTCTEN, USBPHY_CTL_PADDR);
55 timeout = musb_cfg.timeout;
57 #ifdef DAVINCI_DM365EVM
58 /* Set the ownership of GIO33 to USB */
60 val &= ~(PINMUX4_USBDRVBUS_BITCLEAR);
61 val |= PINMUX4_USBDRVBUS_BITSET;
65 if (readl(USBPHY_CTL_PADDR) & USBPHY_PHYCLKGD)
68 /* USB phy was not turned on */
75 static void phy_off(void)
77 /* powerdown the on-chip PHY and its oscillator */
78 writel(USBPHY_OSCPDWN | USBPHY_PHYPDWN, USBPHY_CTL_PADDR);
81 void __enable_vbus(void)
84 * nothing to do, vbus is handled through the cpu.
85 * Define this function in board code, if it is
86 * different on your board.
89 void enable_vbus(void)
90 __attribute__((weak, alias("__enable_vbus")));
93 * This function performs Davinci platform specific initialization for usb0.
95 int musb_platform_init(void)
102 /* start the on-chip USB phy and its pll */
106 /* reset the controller */
107 dregs = (struct davinci_usb_regs *)DAVINCI_USB0_BASE;
108 writel(1, &dregs->ctrlr);
111 /* Returns zero if e.g. not clocked */
112 revision = readl(&dregs->version);
116 /* Disable all interrupts */
117 writel(DAVINCI_USB_USBINT_MASK | DAVINCI_USB_RXINT_MASK |
118 DAVINCI_USB_TXINT_MASK , &dregs->intmsksetr);
123 * This function performs Davinci platform specific deinitialization for usb0.
125 void musb_platform_deinit(void)
127 /* Turn of the phy */
130 /* flush any interrupts */
131 writel(DAVINCI_USB_USBINT_MASK | DAVINCI_USB_TXINT_MASK |
132 DAVINCI_USB_RXINT_MASK , &dregs->intclrr);