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 #if !defined(CONFIG_DV_USBPHY_CTL)
30 #define CONFIG_DV_USBPHY_CTL (USBPHY_SESNDEN | USBPHY_VBDTCTEN)
33 /* MUSB platform configuration */
34 struct musb_config musb_cfg = {
35 .regs = (struct musb_regs *)MENTOR_USB0_BASE,
36 .timeout = DAVINCI_USB_TIMEOUT,
40 /* MUSB module register overlay */
41 struct davinci_usb_regs *dregs;
46 static u8 phy_on(void)
49 #ifdef DAVINCI_DM365EVM
52 /* Wait until the USB phy is turned on */
53 #ifdef DAVINCI_DM365EVM
54 writel(USBPHY_PHY24MHZ | USBPHY_SESNDEN |
55 USBPHY_VBDTCTEN, USBPHY_CTL_PADDR);
57 writel(CONFIG_DV_USBPHY_CTL, USBPHY_CTL_PADDR);
59 timeout = musb_cfg.timeout;
61 #ifdef DAVINCI_DM365EVM
62 /* Set the ownership of GIO33 to USB */
64 val &= ~(PINMUX4_USBDRVBUS_BITCLEAR);
65 val |= PINMUX4_USBDRVBUS_BITSET;
69 if (readl(USBPHY_CTL_PADDR) & USBPHY_PHYCLKGD)
72 /* USB phy was not turned on */
79 static void phy_off(void)
81 /* powerdown the on-chip PHY and its oscillator */
82 writel(USBPHY_OSCPDWN | USBPHY_PHYPDWN, USBPHY_CTL_PADDR);
85 void __enable_vbus(void)
88 * nothing to do, vbus is handled through the cpu.
89 * Define this function in board code, if it is
90 * different on your board.
93 void enable_vbus(void)
94 __attribute__((weak, alias("__enable_vbus")));
97 * This function performs Davinci platform specific initialization for usb0.
99 int musb_platform_init(void)
103 /* enable USB VBUS */
106 /* start the on-chip USB phy and its pll */
110 /* reset the controller */
111 dregs = (struct davinci_usb_regs *)DAVINCI_USB0_BASE;
112 writel(1, &dregs->ctrlr);
115 /* Returns zero if e.g. not clocked */
116 revision = readl(&dregs->version);
120 /* Disable all interrupts */
121 writel(DAVINCI_USB_USBINT_MASK | DAVINCI_USB_RXINT_MASK |
122 DAVINCI_USB_TXINT_MASK , &dregs->intmsksetr);
127 * This function performs Davinci platform specific deinitialization for usb0.
129 void musb_platform_deinit(void)
131 /* Turn of the phy */
134 /* flush any interrupts */
135 writel(DAVINCI_USB_USBINT_MASK | DAVINCI_USB_TXINT_MASK |
136 DAVINCI_USB_RXINT_MASK , &dregs->intclrr);