diff options
Diffstat (limited to 'arch/arm/mach-omap1/usb.c')
-rw-r--r-- | arch/arm/mach-omap1/usb.c | 116 |
1 files changed, 115 insertions, 1 deletions
diff --git a/arch/arm/mach-omap1/usb.c b/arch/arm/mach-omap1/usb.c index e61afd922766..65f88176fba8 100644 --- a/arch/arm/mach-omap1/usb.c +++ b/arch/arm/mach-omap1/usb.c | |||
@@ -27,7 +27,8 @@ | |||
27 | #include <asm/irq.h> | 27 | #include <asm/irq.h> |
28 | 28 | ||
29 | #include <plat/mux.h> | 29 | #include <plat/mux.h> |
30 | #include <plat/usb.h> | 30 | |
31 | #include <mach/usb.h> | ||
31 | 32 | ||
32 | #include "common.h" | 33 | #include "common.h" |
33 | 34 | ||
@@ -55,6 +56,119 @@ | |||
55 | #define INT_USB_IRQ_HGEN INT_USB_HHC_1 | 56 | #define INT_USB_IRQ_HGEN INT_USB_HHC_1 |
56 | #define INT_USB_IRQ_OTG IH2_BASE + 8 | 57 | #define INT_USB_IRQ_OTG IH2_BASE + 8 |
57 | 58 | ||
59 | #ifdef CONFIG_ARCH_OMAP_OTG | ||
60 | |||
61 | void __init | ||
62 | omap_otg_init(struct omap_usb_config *config) | ||
63 | { | ||
64 | u32 syscon; | ||
65 | int alt_pingroup = 0; | ||
66 | |||
67 | /* NOTE: no bus or clock setup (yet?) */ | ||
68 | |||
69 | syscon = omap_readl(OTG_SYSCON_1) & 0xffff; | ||
70 | if (!(syscon & OTG_RESET_DONE)) | ||
71 | pr_debug("USB resets not complete?\n"); | ||
72 | |||
73 | //omap_writew(0, OTG_IRQ_EN); | ||
74 | |||
75 | /* pin muxing and transceiver pinouts */ | ||
76 | if (config->pins[0] > 2) /* alt pingroup 2 */ | ||
77 | alt_pingroup = 1; | ||
78 | syscon |= config->usb0_init(config->pins[0], is_usb0_device(config)); | ||
79 | syscon |= config->usb1_init(config->pins[1]); | ||
80 | syscon |= config->usb2_init(config->pins[2], alt_pingroup); | ||
81 | pr_debug("OTG_SYSCON_1 = %08x\n", omap_readl(OTG_SYSCON_1)); | ||
82 | omap_writel(syscon, OTG_SYSCON_1); | ||
83 | |||
84 | syscon = config->hmc_mode; | ||
85 | syscon |= USBX_SYNCHRO | (4 << 16) /* B_ASE0_BRST */; | ||
86 | #ifdef CONFIG_USB_OTG | ||
87 | if (config->otg) | ||
88 | syscon |= OTG_EN; | ||
89 | #endif | ||
90 | if (cpu_class_is_omap1()) | ||
91 | pr_debug("USB_TRANSCEIVER_CTRL = %03x\n", | ||
92 | omap_readl(USB_TRANSCEIVER_CTRL)); | ||
93 | pr_debug("OTG_SYSCON_2 = %08x\n", omap_readl(OTG_SYSCON_2)); | ||
94 | omap_writel(syscon, OTG_SYSCON_2); | ||
95 | |||
96 | printk("USB: hmc %d", config->hmc_mode); | ||
97 | if (!alt_pingroup) | ||
98 | printk(", usb2 alt %d wires", config->pins[2]); | ||
99 | else if (config->pins[0]) | ||
100 | printk(", usb0 %d wires%s", config->pins[0], | ||
101 | is_usb0_device(config) ? " (dev)" : ""); | ||
102 | if (config->pins[1]) | ||
103 | printk(", usb1 %d wires", config->pins[1]); | ||
104 | if (!alt_pingroup && config->pins[2]) | ||
105 | printk(", usb2 %d wires", config->pins[2]); | ||
106 | if (config->otg) | ||
107 | printk(", Mini-AB on usb%d", config->otg - 1); | ||
108 | printk("\n"); | ||
109 | |||
110 | if (cpu_class_is_omap1()) { | ||
111 | u16 w; | ||
112 | |||
113 | /* leave USB clocks/controllers off until needed */ | ||
114 | w = omap_readw(ULPD_SOFT_REQ); | ||
115 | w &= ~SOFT_USB_CLK_REQ; | ||
116 | omap_writew(w, ULPD_SOFT_REQ); | ||
117 | |||
118 | w = omap_readw(ULPD_CLOCK_CTRL); | ||
119 | w &= ~USB_MCLK_EN; | ||
120 | w |= DIS_USB_PVCI_CLK; | ||
121 | omap_writew(w, ULPD_CLOCK_CTRL); | ||
122 | } | ||
123 | syscon = omap_readl(OTG_SYSCON_1); | ||
124 | syscon |= HST_IDLE_EN|DEV_IDLE_EN|OTG_IDLE_EN; | ||
125 | |||
126 | #ifdef CONFIG_USB_GADGET_OMAP | ||
127 | if (config->otg || config->register_dev) { | ||
128 | struct platform_device *udc_device = config->udc_device; | ||
129 | int status; | ||
130 | |||
131 | syscon &= ~DEV_IDLE_EN; | ||
132 | udc_device->dev.platform_data = config; | ||
133 | status = platform_device_register(udc_device); | ||
134 | if (status) | ||
135 | pr_debug("can't register UDC device, %d\n", status); | ||
136 | } | ||
137 | #endif | ||
138 | |||
139 | #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) | ||
140 | if (config->otg || config->register_host) { | ||
141 | struct platform_device *ohci_device = config->ohci_device; | ||
142 | int status; | ||
143 | |||
144 | syscon &= ~HST_IDLE_EN; | ||
145 | ohci_device->dev.platform_data = config; | ||
146 | status = platform_device_register(ohci_device); | ||
147 | if (status) | ||
148 | pr_debug("can't register OHCI device, %d\n", status); | ||
149 | } | ||
150 | #endif | ||
151 | |||
152 | #ifdef CONFIG_USB_OTG | ||
153 | if (config->otg) { | ||
154 | struct platform_device *otg_device = config->otg_device; | ||
155 | int status; | ||
156 | |||
157 | syscon &= ~OTG_IDLE_EN; | ||
158 | otg_device->dev.platform_data = config; | ||
159 | status = platform_device_register(otg_device); | ||
160 | if (status) | ||
161 | pr_debug("can't register OTG device, %d\n", status); | ||
162 | } | ||
163 | #endif | ||
164 | pr_debug("OTG_SYSCON_1 = %08x\n", omap_readl(OTG_SYSCON_1)); | ||
165 | omap_writel(syscon, OTG_SYSCON_1); | ||
166 | } | ||
167 | |||
168 | #else | ||
169 | void omap_otg_init(struct omap_usb_config *config) {} | ||
170 | #endif | ||
171 | |||
58 | #ifdef CONFIG_USB_GADGET_OMAP | 172 | #ifdef CONFIG_USB_GADGET_OMAP |
59 | 173 | ||
60 | static struct resource udc_resources[] = { | 174 | static struct resource udc_resources[] = { |