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);
82 * This function performs Davinci platform specific initialization for usb0.
84 int musb_platform_init(void)
89 #ifndef DAVINCI_DM365EVM
92 /* start the on-chip USB phy and its pll */
96 /* reset the controller */
97 dregs = (struct davinci_usb_regs *)DAVINCI_USB0_BASE;
98 writel(1, &dregs->ctrlr);
101 /* Returns zero if e.g. not clocked */
102 revision = readl(&dregs->version);
106 /* Disable all interrupts */
107 writel(DAVINCI_USB_USBINT_MASK | DAVINCI_USB_RXINT_MASK |
108 DAVINCI_USB_TXINT_MASK , &dregs->intmsksetr);
113 * This function performs Davinci platform specific deinitialization for usb0.
115 void musb_platform_deinit(void)
117 /* Turn of the phy */
120 /* flush any interrupts */
121 writel(DAVINCI_USB_USBINT_MASK | DAVINCI_USB_TXINT_MASK |
122 DAVINCI_USB_RXINT_MASK , &dregs->intclrr);