1 // SPDX-License-Identifier: GPL-2.0+
3 * TI's Davinci platform specific USB wrapper functions.
5 * Copyright (c) 2008 Texas Instruments
7 * Author: Thomas Abraham t-abraham@ti.com, Texas Instruments
13 #include <asm/arch/hardware.h>
15 #if !defined(CONFIG_DV_USBPHY_CTL)
16 #define CONFIG_DV_USBPHY_CTL (USBPHY_SESNDEN | USBPHY_VBDTCTEN)
19 /* MUSB platform configuration */
20 struct musb_config musb_cfg
= {
21 .regs
= (struct musb_regs
*)MENTOR_USB0_BASE
,
22 .timeout
= DAVINCI_USB_TIMEOUT
,
26 /* MUSB module register overlay */
27 struct davinci_usb_regs
*dregs
;
32 static u8
phy_on(void)
35 #ifdef DAVINCI_DM365EVM
38 /* Wait until the USB phy is turned on */
39 #ifdef DAVINCI_DM365EVM
40 writel(USBPHY_PHY24MHZ
| USBPHY_SESNDEN
|
41 USBPHY_VBDTCTEN
, USBPHY_CTL_PADDR
);
43 writel(CONFIG_DV_USBPHY_CTL
, USBPHY_CTL_PADDR
);
45 timeout
= musb_cfg
.timeout
;
47 #ifdef DAVINCI_DM365EVM
48 /* Set the ownership of GIO33 to USB */
50 val
&= ~(PINMUX4_USBDRVBUS_BITCLEAR
);
51 val
|= PINMUX4_USBDRVBUS_BITSET
;
55 if (readl(USBPHY_CTL_PADDR
) & USBPHY_PHYCLKGD
)
58 /* USB phy was not turned on */
65 static void phy_off(void)
67 /* powerdown the on-chip PHY and its oscillator */
68 writel(USBPHY_OSCPDWN
| USBPHY_PHYPDWN
, USBPHY_CTL_PADDR
);
71 void __enable_vbus(void)
74 * nothing to do, vbus is handled through the cpu.
75 * Define this function in board code, if it is
76 * different on your board.
79 void enable_vbus(void)
80 __attribute__((weak
, alias("__enable_vbus")));
83 * This function performs Davinci platform specific initialization for usb0.
85 int musb_platform_init(void)
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
);