16 #include <linux/module.h>
17 #include <linux/kernel.h>
18 #include <linux/slab.h>
19 #include <linux/device.h>
28 #include <mach/hardware.h>
52 #if defined(CONFIG_PXA310_ULPI)
53 enum u2d_ulpi_phy_mode {
61 static inline enum u2d_ulpi_phy_mode pxa310_ulpi_get_phymode(
void)
63 return (u2d_readl(
U2DOTGUSR) >> 28) & 0xF;
66 static int pxa310_ulpi_poll(
void)
77 pr_warning(
"%s: ULPI access timed out!\n", __func__);
86 if (pxa310_ulpi_get_phymode() != SYNCH) {
87 pr_warning(
"%s: PHY is not in SYNCH mode!\n", __func__);
94 err = pxa310_ulpi_poll();
103 if (pxa310_ulpi_get_phymode() != SYNCH) {
104 pr_warning(
"%s: PHY is not in SYNCH mode!\n", __func__);
111 return pxa310_ulpi_poll();
115 .
read = pxa310_ulpi_read,
116 .write = pxa310_ulpi_write,
119 static void pxa310_otg_transceiver_rtsm(
void)
136 static int pxa310_start_otg_host_transcvr(
struct usb_bus *
host)
140 pxa310_otg_transceiver_rtsm();
142 err = usb_phy_init(u2d->
otg);
144 pr_err(
"OTG transceiver init failed");
148 err = otg_set_vbus(u2d->
otg->otg, 1);
150 pr_err(
"OTG transceiver VBUS set failed");
154 err = otg_set_host(u2d->
otg->otg, host);
156 pr_err(
"OTG transceiver Host mode set failed");
161 static int pxa310_start_otg_hc(
struct usb_bus *host)
171 err = pxa310_start_otg_host_transcvr(host);
188 static void pxa310_stop_otg_hc(
void)
190 pxa310_otg_transceiver_rtsm();
192 otg_set_host(u2d->
otg->otg,
NULL);
193 otg_set_vbus(u2d->
otg->otg, 0);
194 usb_phy_shutdown(u2d->
otg);
197 static void pxa310_u2d_setup_otg_hc(
void)
233 static void pxa310_otg_exit(
void)
238 static inline void pxa310_u2d_setup_otg_hc(
void) {}
239 static inline int pxa310_start_otg_hc(
struct usb_bus *host)
243 static inline void pxa310_stop_otg_hc(
void) {}
248 static inline void pxa310_otg_exit(
void) {}
262 pxa310_u2d_setup_otg_hc();
263 err = pxa310_start_otg_hc(host);
277 pxa310_stop_otg_hc();
291 dev_err(&pdev->
dev,
"failed to allocate memory\n");
296 if (IS_ERR(u2d->
clk)) {
297 dev_err(&pdev->
dev,
"failed to get u2d clock\n");
298 err = PTR_ERR(u2d->
clk);
304 dev_err(&pdev->
dev,
"no IO memory resource defined\n");
311 dev_err(&pdev->
dev,
"failed to request memory resource\n");
331 err = pxa310_otg_init(pdata);
336 platform_set_drvdata(pdev, &u2d);
360 pxa310_stop_otg_hc();
367 platform_set_drvdata(pdev,
NULL);
381 .name =
"pxa3xx-u2d",
384 .probe = pxa3xx_u2d_probe,
385 .remove = pxa3xx_u2d_remove,
388 static int pxa3xx_u2d_ulpi_init(
void)
394 static void __exit pxa3xx_u2d_ulpi_exit(
void)