2 * TI's Davinci platform specific USB wrapper functions.
4 * Copyright (c) 2008 Texas Instruments
6 * SPDX-License-Identifier: GPL-2.0+
8 * Author: Thomas Abraham t-abraham@ti.com, Texas Instruments
14 #include <asm/arch/hardware.h>
16 #if !defined(CONFIG_DV_USBPHY_CTL)
17 #define CONFIG_DV_USBPHY_CTL (USBPHY_SESNDEN | USBPHY_VBDTCTEN)
20 /* MUSB platform configuration */
21 struct musb_config musb_cfg
= {
22 .regs
= (struct musb_regs
*)MENTOR_USB0_BASE
,
23 .timeout
= DAVINCI_USB_TIMEOUT
,
27 /* MUSB module register overlay */
28 struct davinci_usb_regs
*dregs
;
33 static u8
phy_on(void)
36 #ifdef DAVINCI_DM365EVM
39 /* Wait until the USB phy is turned on */
40 #ifdef DAVINCI_DM365EVM
41 writel(USBPHY_PHY24MHZ
| USBPHY_SESNDEN
|
42 USBPHY_VBDTCTEN
, USBPHY_CTL_PADDR
);
44 writel(CONFIG_DV_USBPHY_CTL
, USBPHY_CTL_PADDR
);
46 timeout
= musb_cfg
.timeout
;
48 #ifdef DAVINCI_DM365EVM
49 /* Set the ownership of GIO33 to USB */
51 val
&= ~(PINMUX4_USBDRVBUS_BITCLEAR
);
52 val
|= PINMUX4_USBDRVBUS_BITSET
;
56 if (readl(USBPHY_CTL_PADDR
) & USBPHY_PHYCLKGD
)
59 /* USB phy was not turned on */
66 static void phy_off(void)
68 /* powerdown the on-chip PHY and its oscillator */
69 writel(USBPHY_OSCPDWN
| USBPHY_PHYPDWN
, USBPHY_CTL_PADDR
);
72 void __enable_vbus(void)
75 * nothing to do, vbus is handled through the cpu.
76 * Define this function in board code, if it is
77 * different on your board.
80 void enable_vbus(void)
81 __attribute__((weak
, alias("__enable_vbus")));
84 * This function performs Davinci platform specific initialization for usb0.
86 int musb_platform_init(void)
93 /* start the on-chip USB phy and its pll */
97 /* reset the controller */
98 dregs
= (struct davinci_usb_regs
*)DAVINCI_USB0_BASE
;
99 writel(1, &dregs
->ctrlr
);
102 /* Returns zero if e.g. not clocked */
103 revision
= readl(&dregs
->version
);
107 /* Disable all interrupts */
108 writel(DAVINCI_USB_USBINT_MASK
| DAVINCI_USB_RXINT_MASK
|
109 DAVINCI_USB_TXINT_MASK
, &dregs
->intmsksetr
);
114 * This function performs Davinci platform specific deinitialization for usb0.
116 void musb_platform_deinit(void)
118 /* Turn of the phy */
121 /* flush any interrupts */
122 writel(DAVINCI_USB_USBINT_MASK
| DAVINCI_USB_TXINT_MASK
|
123 DAVINCI_USB_RXINT_MASK
, &dregs
->intclrr
);