2 * da8xx.c - TI's DA8xx platform specific usb wrapper functions.
4 * Author: Ajay Kumar Gupta <ajay.gupta@ti.com>
6 * Based on drivers/usb/musb/davinci.c
8 * Copyright (C) 2009 Texas Instruments Incorporated
10 * SPDX-License-Identifier: GPL-2.0+
14 #include "musb_core.h"
15 #include <asm/arch/da8xx-usb.h>
17 /* MUSB platform configuration */
18 struct musb_config musb_cfg
= {
19 .regs
= (struct musb_regs
*)DA8XX_USB_OTG_CORE_BASE
,
20 .timeout
= DA8XX_USB_OTG_TIMEOUT
,
25 * This function enables VBUS by driving the GPIO Bank4 Pin 15 high.
27 static void enable_vbus(void)
31 /* configure GPIO bank4 pin 15 in output direction */
32 value
= readl(&davinci_gpio_bank45
->dir
);
33 writel((value
& (~DA8XX_USB_VBUS_GPIO
)), &davinci_gpio_bank45
->dir
);
35 /* set GPIO bank4 pin 15 high to drive VBUS */
36 value
= readl(&davinci_gpio_bank45
->set_data
);
37 writel((value
| DA8XX_USB_VBUS_GPIO
), &davinci_gpio_bank45
->set_data
);
41 * Enable the usb0 phy. This initialization procedure is explained in
42 * the DA8xx USB user guide document.
44 static u8
phy_on(void)
49 cfgchip2
= readl(&davinci_syscfg_regs
->cfgchip2
);
51 cfgchip2
&= ~(CFGCHIP2_RESET
| CFGCHIP2_PHYPWRDN
| CFGCHIP2_OTGPWRDN
|
52 CFGCHIP2_OTGMODE
| CFGCHIP2_REFFREQ
);
53 cfgchip2
|= CFGCHIP2_SESENDEN
| CFGCHIP2_VBDTCTEN
| CFGCHIP2_PHY_PLLON
|
54 CFGCHIP2_REFFREQ_24MHZ
;
56 writel(cfgchip2
, &davinci_syscfg_regs
->cfgchip2
);
58 /* wait until the usb phy pll locks */
59 timeout
= musb_cfg
.timeout
;
61 if (readl(&davinci_syscfg_regs
->cfgchip2
) & CFGCHIP2_PHYCLKGD
)
64 /* USB phy was not turned on */
71 static void phy_off(void)
76 * Power down the on-chip PHY.
78 cfgchip2
= readl(&davinci_syscfg_regs
->cfgchip2
);
79 cfgchip2
&= ~CFGCHIP2_PHY_PLLON
;
80 cfgchip2
|= CFGCHIP2_PHYPWRDN
| CFGCHIP2_OTGPWRDN
;
81 writel(cfgchip2
, &davinci_syscfg_regs
->cfgchip2
);
85 * This function performs DA8xx platform specific initialization for usb0.
87 int musb_platform_init(void)
91 /* enable psc for usb2.0 */
97 /* reset the controller */
98 writel(0x1, &da8xx_usb_regs
->control
);
101 /* start the on-chip usb phy and its pll */
105 /* Returns zero if e.g. not clocked */
106 revision
= readl(&da8xx_usb_regs
->revision
);
110 /* Disable all interrupts */
111 writel((DA8XX_USB_USBINT_MASK
| DA8XX_USB_TXINT_MASK
|
112 DA8XX_USB_RXINT_MASK
), &da8xx_usb_regs
->intmsk_set
);
117 * This function performs DA8xx platform specific deinitialization for usb0.
119 void musb_platform_deinit(void)
121 /* Turn of the phy */
124 /* flush any interrupts */
125 writel((DA8XX_USB_USBINT_MASK
| DA8XX_USB_TXINT_MASK
|
126 DA8XX_USB_RXINT_MASK
), &da8xx_usb_regs
->intmsk_clr
);
127 writel(0, &da8xx_usb_regs
->eoi
);