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
26 #include "davinci_usb.h"
28 /* MUSB platform configuration */
29 struct musb_config musb_cfg = {
30 (struct musb_regs *)MENTOR_USB0_BASE,
35 /* MUSB module register overlay */
36 struct davinci_usb_regs *dregs;
41 static u8 phy_on(void)
45 /* Wait until the USB phy is turned on */
46 writel(USBPHY_SESNDEN | USBPHY_VBDTCTEN, USBPHY_CTL_PADDR);
47 timeout = musb_cfg.timeout;
49 if (readl(USBPHY_CTL_PADDR) & USBPHY_PHYCLKGD)
52 /* USB phy was not turned on */
59 static void phy_off(void)
61 /* powerdown the on-chip PHY and its oscillator */
62 writel(USBPHY_OSCPDWN | USBPHY_PHYPDWN, USBPHY_CTL_PADDR);
66 * This function performs Davinci platform specific initialization for usb0.
68 int musb_platform_init(void)
75 /* start the on-chip USB phy and its pll */
79 /* reset the controller */
80 dregs = (struct davinci_usb_regs *)DAVINCI_USB0_BASE;
81 writel(1, &dregs->ctrlr);
84 /* Returns zero if e.g. not clocked */
85 revision = readl(&dregs->version);
89 /* Disable all interrupts */
90 writel(DAVINCI_USB_USBINT_MASK | DAVINCI_USB_RXINT_MASK |
91 DAVINCI_USB_TXINT_MASK , &dregs->intmsksetr);
96 * This function performs Davinci platform specific deinitialization for usb0.
98 void musb_platform_deinit(void)
100 /* Turn of the phy */
103 /* flush any interrupts */
104 writel(DAVINCI_USB_USBINT_MASK | DAVINCI_USB_TXINT_MASK |
105 DAVINCI_USB_RXINT_MASK , &dregs->intclrr);