Merge branch 'picoxcell/timer' into next/timer
[deliverable/linux.git] / arch / arm / plat-omap / usb.c
CommitLineData
f35ae634 1 /*
5e1c5ff4
TL
2 * arch/arm/plat-omap/usb.c -- platform level USB initialization
3 *
4 * Copyright (C) 2004 Texas Instruments, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#undef DEBUG
22
5e1c5ff4
TL
23#include <linux/module.h>
24#include <linux/kernel.h>
5e1c5ff4 25#include <linux/init.h>
d052d1be 26#include <linux/platform_device.h>
fced80c7 27#include <linux/io.h>
5e1c5ff4 28
ce491cf8
TL
29#include <plat/usb.h>
30#include <plat/board.h>
5e1c5ff4 31
2c799cef
TL
32#include <mach/hardware.h>
33
5e1c5ff4
TL
34#ifdef CONFIG_ARCH_OMAP_OTG
35
36void __init
37omap_otg_init(struct omap_usb_config *config)
38{
f35ae634 39 u32 syscon;
5e1c5ff4
TL
40 int alt_pingroup = 0;
41
42 /* NOTE: no bus or clock setup (yet?) */
43
f35ae634 44 syscon = omap_readl(OTG_SYSCON_1) & 0xffff;
5e1c5ff4
TL
45 if (!(syscon & OTG_RESET_DONE))
46 pr_debug("USB resets not complete?\n");
47
f35ae634 48 //omap_writew(0, OTG_IRQ_EN);
5e1c5ff4
TL
49
50 /* pin muxing and transceiver pinouts */
51 if (config->pins[0] > 2) /* alt pingroup 2 */
52 alt_pingroup = 1;
b5e8905b
TL
53 syscon |= config->usb0_init(config->pins[0], is_usb0_device(config));
54 syscon |= config->usb1_init(config->pins[1]);
55 syscon |= config->usb2_init(config->pins[2], alt_pingroup);
f35ae634
TL
56 pr_debug("OTG_SYSCON_1 = %08x\n", omap_readl(OTG_SYSCON_1));
57 omap_writel(syscon, OTG_SYSCON_1);
5e1c5ff4
TL
58
59 syscon = config->hmc_mode;
60 syscon |= USBX_SYNCHRO | (4 << 16) /* B_ASE0_BRST */;
61#ifdef CONFIG_USB_OTG
62 if (config->otg)
63 syscon |= OTG_EN;
64#endif
c40fae95 65 if (cpu_class_is_omap1())
f35ae634
TL
66 pr_debug("USB_TRANSCEIVER_CTRL = %03x\n",
67 omap_readl(USB_TRANSCEIVER_CTRL));
68 pr_debug("OTG_SYSCON_2 = %08x\n", omap_readl(OTG_SYSCON_2));
69 omap_writel(syscon, OTG_SYSCON_2);
5e1c5ff4
TL
70
71 printk("USB: hmc %d", config->hmc_mode);
c40fae95 72 if (!alt_pingroup)
5e1c5ff4
TL
73 printk(", usb2 alt %d wires", config->pins[2]);
74 else if (config->pins[0])
75 printk(", usb0 %d wires%s", config->pins[0],
76 is_usb0_device(config) ? " (dev)" : "");
77 if (config->pins[1])
78 printk(", usb1 %d wires", config->pins[1]);
79 if (!alt_pingroup && config->pins[2])
80 printk(", usb2 %d wires", config->pins[2]);
81 if (config->otg)
82 printk(", Mini-AB on usb%d", config->otg - 1);
83 printk("\n");
84
c40fae95 85 if (cpu_class_is_omap1()) {
f35ae634
TL
86 u16 w;
87
c40fae95 88 /* leave USB clocks/controllers off until needed */
f35ae634
TL
89 w = omap_readw(ULPD_SOFT_REQ);
90 w &= ~SOFT_USB_CLK_REQ;
91 omap_writew(w, ULPD_SOFT_REQ);
92
93 w = omap_readw(ULPD_CLOCK_CTRL);
94 w &= ~USB_MCLK_EN;
95 w |= DIS_USB_PVCI_CLK;
96 omap_writew(w, ULPD_CLOCK_CTRL);
c40fae95 97 }
f35ae634 98 syscon = omap_readl(OTG_SYSCON_1);
5e1c5ff4
TL
99 syscon |= HST_IDLE_EN|DEV_IDLE_EN|OTG_IDLE_EN;
100
101#ifdef CONFIG_USB_GADGET_OMAP
102 if (config->otg || config->register_dev) {
b5e8905b 103 struct platform_device *udc_device = config->udc_device;
19b08b33 104 int status;
b5e8905b 105
5e1c5ff4 106 syscon &= ~DEV_IDLE_EN;
b5e8905b 107 udc_device->dev.platform_data = config;
b5e8905b 108 status = platform_device_register(udc_device);
5e1c5ff4
TL
109 if (status)
110 pr_debug("can't register UDC device, %d\n", status);
111 }
112#endif
113
114#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
115 if (config->otg || config->register_host) {
b5e8905b 116 struct platform_device *ohci_device = config->ohci_device;
19b08b33 117 int status;
b5e8905b 118
5e1c5ff4 119 syscon &= ~HST_IDLE_EN;
b5e8905b 120 ohci_device->dev.platform_data = config;
b5e8905b 121 status = platform_device_register(ohci_device);
5e1c5ff4
TL
122 if (status)
123 pr_debug("can't register OHCI device, %d\n", status);
124 }
125#endif
126
127#ifdef CONFIG_USB_OTG
128 if (config->otg) {
b5e8905b 129 struct platform_device *otg_device = config->otg_device;
19b08b33 130 int status;
b5e8905b 131
5e1c5ff4 132 syscon &= ~OTG_IDLE_EN;
b5e8905b 133 otg_device->dev.platform_data = config;
b5e8905b 134 status = platform_device_register(otg_device);
5e1c5ff4
TL
135 if (status)
136 pr_debug("can't register OTG device, %d\n", status);
137 }
138#endif
f35ae634
TL
139 pr_debug("OTG_SYSCON_1 = %08x\n", omap_readl(OTG_SYSCON_1));
140 omap_writel(syscon, OTG_SYSCON_1);
5e1c5ff4
TL
141}
142
143#else
b5e8905b 144void omap_otg_init(struct omap_usb_config *config) {}
5e1c5ff4 145#endif
This page took 0.504826 seconds and 5 git commands to generate.