]>
git.ipfire.org Git - people/ms/u-boot.git/blob - drivers/usb/musb/am35x.c
1706c138bd56f984affc2b9aea73b40e833643cf
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 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 /* MUSB platform configuration */
29 struct musb_config musb_cfg
= {
30 .regs
= (struct musb_regs
*)AM35X_USB_OTG_CORE_BASE
,
31 .timeout
= AM35X_USB_OTG_TIMEOUT
,
38 static u8
phy_on(void)
43 devconf2
= readl(&am35x_scm_general_regs
->devconf2
);
45 devconf2
&= ~(DEVCONF2_RESET
| DEVCONF2_PHYPWRDN
| DEVCONF2_OTGPWRDN
|
46 DEVCONF2_OTGMODE
| DEVCONF2_REFFREQ
|
47 DEVCONF2_PHY_GPIOMODE
);
48 devconf2
|= DEVCONF2_SESENDEN
| DEVCONF2_VBDTCTEN
| DEVCONF2_PHY_PLLON
|
49 DEVCONF2_REFFREQ_13MHZ
| DEVCONF2_DATPOL
;
51 writel(devconf2
, &am35x_scm_general_regs
->devconf2
);
53 /* wait until the USB phy is turned on */
54 timeout
= musb_cfg
.timeout
;
56 if (readl(&am35x_scm_general_regs
->devconf2
) & DEVCONF2_PHYCKGD
)
59 /* USB phy was not turned on */
66 static void phy_off(void)
71 * Power down the on-chip PHY.
73 devconf2
= readl(&am35x_scm_general_regs
->devconf2
);
75 devconf2
&= ~DEVCONF2_PHY_PLLON
;
76 devconf2
|= DEVCONF2_PHYPWRDN
| DEVCONF2_OTGPWRDN
;
77 writel(devconf2
, &am35x_scm_general_regs
->devconf2
);
81 * This function performs platform specific initialization for usb0.
83 int musb_platform_init(void)
88 /* global usb reset */
89 sw_reset
= readl(&am35x_scm_general_regs
->ip_sw_reset
);
91 writel(sw_reset
, &am35x_scm_general_regs
->ip_sw_reset
);
92 sw_reset
&= ~(1 << 0);
93 writel(sw_reset
, &am35x_scm_general_regs
->ip_sw_reset
);
95 /* reset the controller */
96 writel(0x1, &am35x_usb_regs
->control
);
99 /* start the on-chip usb phy and its pll */
103 /* Returns zero if e.g. not clocked */
104 revision
= readl(&am35x_usb_regs
->revision
);
112 * This function performs platform specific deinitialization for usb0.
114 void musb_platform_deinit(void)
116 /* Turn off the phy */
121 * This function reads data from endpoint fifo for AM35x
122 * which supports only 32bit read operation.
124 * ep - endpoint number
125 * length - number of bytes to read from FIFO
126 * fifo_data - pointer to data buffer into which data is read
128 __attribute__((weak
))
129 void read_fifo(u8 ep
, u32 length
, void *fifo_data
)
131 u8
*data
= (u8
*)fifo_data
;
135 /* select the endpoint index */
136 writeb(ep
, &musbr
->index
);
139 for (i
= 0; i
< (length
>> 2); i
++) {
140 val
= readl(&musbr
->fifox
[ep
]);
141 memcpy(data
, &val
, 4);
147 val
= readl(&musbr
->fifox
[ep
]);
148 memcpy(data
, &val
, length
);