2 * am35x.c - TI's AM35x platform specific usb wrapper functions.
4 * Author: Ajay Kumar Gupta <ajay.gupta@ti.com>
6 * Based on drivers/usb/musb/da8xx.c
8 * Copyright (c) 2010 Texas Instruments Incorporated
10 * SPDX-License-Identifier: GPL-2.0+
17 /* MUSB platform configuration */
18 struct musb_config musb_cfg
= {
19 .regs
= (struct musb_regs
*)AM35X_USB_OTG_CORE_BASE
,
20 .timeout
= AM35X_USB_OTG_TIMEOUT
,
27 static u8
phy_on(void)
32 devconf2
= readl(&am35x_scm_general_regs
->devconf2
);
34 devconf2
&= ~(DEVCONF2_RESET
| DEVCONF2_PHYPWRDN
| DEVCONF2_OTGPWRDN
|
35 DEVCONF2_OTGMODE
| DEVCONF2_REFFREQ
|
36 DEVCONF2_PHY_GPIOMODE
);
37 devconf2
|= DEVCONF2_SESENDEN
| DEVCONF2_VBDTCTEN
| DEVCONF2_PHY_PLLON
|
38 DEVCONF2_REFFREQ_13MHZ
| DEVCONF2_DATPOL
;
40 writel(devconf2
, &am35x_scm_general_regs
->devconf2
);
42 /* wait until the USB phy is turned on */
43 timeout
= musb_cfg
.timeout
;
45 if (readl(&am35x_scm_general_regs
->devconf2
) & DEVCONF2_PHYCKGD
)
48 /* USB phy was not turned on */
55 static void phy_off(void)
60 * Power down the on-chip PHY.
62 devconf2
= readl(&am35x_scm_general_regs
->devconf2
);
64 devconf2
&= ~DEVCONF2_PHY_PLLON
;
65 devconf2
|= DEVCONF2_PHYPWRDN
| DEVCONF2_OTGPWRDN
;
66 writel(devconf2
, &am35x_scm_general_regs
->devconf2
);
70 * This function performs platform specific initialization for usb0.
72 int musb_platform_init(void)
77 /* global usb reset */
78 sw_reset
= readl(&am35x_scm_general_regs
->ip_sw_reset
);
80 writel(sw_reset
, &am35x_scm_general_regs
->ip_sw_reset
);
81 sw_reset
&= ~(1 << 0);
82 writel(sw_reset
, &am35x_scm_general_regs
->ip_sw_reset
);
84 /* reset the controller */
85 writel(0x1, &am35x_usb_regs
->control
);
88 /* start the on-chip usb phy and its pll */
92 /* Returns zero if e.g. not clocked */
93 revision
= readl(&am35x_usb_regs
->revision
);
101 * This function performs platform specific deinitialization for usb0.
103 void musb_platform_deinit(void)
105 /* Turn off the phy */
110 * This function reads data from endpoint fifo for AM35x
111 * which supports only 32bit read operation.
113 * ep - endpoint number
114 * length - number of bytes to read from FIFO
115 * fifo_data - pointer to data buffer into which data is read
117 __attribute__((weak
))
118 void read_fifo(u8 ep
, u32 length
, void *fifo_data
)
120 u8
*data
= (u8
*)fifo_data
;
124 /* select the endpoint index */
125 writeb(ep
, &musbr
->index
);
128 for (i
= 0; i
< (length
>> 2); i
++) {
129 val
= readl(&musbr
->fifox
[ep
]);
130 memcpy(data
, &val
, 4);
136 val
= readl(&musbr
->fifox
[ep
]);
137 memcpy(data
, &val
, length
);