aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-at91rm9200/devices.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-at91rm9200/devices.c')
-rw-r--r--arch/arm/mach-at91rm9200/devices.c291
1 files changed, 291 insertions, 0 deletions
diff --git a/arch/arm/mach-at91rm9200/devices.c b/arch/arm/mach-at91rm9200/devices.c
new file mode 100644
index 000000000000..8df3e5245651
--- /dev/null
+++ b/arch/arm/mach-at91rm9200/devices.c
@@ -0,0 +1,291 @@
1/*
2 * arch/arm/mach-at91rm9200/devices.c
3 *
4 * Copyright (C) 2005 Thibaut VARENE <varenet@parisc-linux.org>
5 * Copyright (C) 2005 David Brownell
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 */
13#include <asm/mach/arch.h>
14#include <asm/mach/map.h>
15
16#include <linux/config.h>
17#include <linux/platform_device.h>
18
19#include <asm/arch/board.h>
20#include <asm/arch/pio.h>
21
22
23/* --------------------------------------------------------------------
24 * USB Host
25 * -------------------------------------------------------------------- */
26
27#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
28static u64 ohci_dmamask = 0xffffffffUL;
29static struct at91_usbh_data usbh_data;
30
31static struct resource at91rm9200_usbh_resource[] = {
32 [0] = {
33 .start = AT91_UHP_BASE,
34 .end = AT91_UHP_BASE + SZ_1M -1,
35 .flags = IORESOURCE_MEM,
36 },
37 [1] = {
38 .start = AT91_ID_UHP,
39 .end = AT91_ID_UHP,
40 .flags = IORESOURCE_IRQ,
41 },
42};
43
44static struct platform_device at91rm9200_usbh_device = {
45 .name = "at91rm9200-ohci",
46 .id = -1,
47 .dev = {
48 .dma_mask = &ohci_dmamask,
49 .coherent_dma_mask = 0xffffffff,
50 .platform_data = &usbh_data,
51 },
52 .resource = at91rm9200_usbh_resource,
53 .num_resources = ARRAY_SIZE(at91rm9200_usbh_resource),
54};
55
56void __init at91_add_device_usbh(struct at91_usbh_data *data)
57{
58 if (!data)
59 return;
60
61 usbh_data = *data;
62 platform_device_register(&at91rm9200_usbh_device);
63}
64#else
65void __init at91_add_device_usbh(struct at91_usbh_data *data) {}
66#endif
67
68
69/* --------------------------------------------------------------------
70 * USB Device (Gadget)
71 * -------------------------------------------------------------------- */
72
73#ifdef CONFIG_USB_GADGET_AT91
74static struct at91_udc_data udc_data;
75
76static struct resource at91_udc_resources[] = {
77 {
78 .start = AT91_BASE_UDP,
79 .end = AT91_BASE_UDP + SZ_16K - 1,
80 .flags = IORESOURCE_MEM,
81 }
82};
83
84static struct platform_device at91rm9200_udc_device = {
85 .name = "at91_udc",
86 .id = -1,
87 .dev = {
88 .platform_data = &udc_data,
89 },
90 .resource = at91_udc_resources,
91 .num_resources = ARRAY_SIZE(at91_udc_resources),
92};
93
94void __init at91_add_device_udc(struct at91_udc_data *data)
95{
96 if (!data)
97 return;
98
99 if (data->vbus_pin) {
100 at91_set_gpio_input(data->vbus_pin, 0);
101 at91_set_deglitch(data->vbus_pin, 1);
102 }
103 if (data->pullup_pin)
104 at91_set_gpio_output(data->pullup_pin, 0);
105
106 udc_data = *data;
107 platform_device_register(&at91rm9200_udc_device);
108}
109#else
110void __init at91_add_device_udc(struct at91_udc_data *data) {}
111#endif
112
113
114/* --------------------------------------------------------------------
115 * Ethernet
116 * -------------------------------------------------------------------- */
117
118#if defined(CONFIG_ARM_AT91_ETHER) || defined(CONFIG_ARM_AT91_ETHER_MODULE)
119static u64 eth_dmamask = 0xffffffffUL;
120static struct at91_eth_data eth_data;
121
122static struct platform_device at91rm9200_eth_device = {
123 .name = "at91_ether",
124 .id = -1,
125 .dev = {
126 .dma_mask = &eth_dmamask,
127 .coherent_dma_mask = 0xffffffff,
128 .platform_data = &eth_data,
129 },
130 .num_resources = 0,
131};
132
133void __init at91_add_device_eth(struct at91_eth_data *data)
134{
135 if (!data)
136 return;
137
138 if (data->phy_irq_pin) {
139 at91_set_gpio_input(data->phy_irq_pin, 0);
140 at91_set_deglitch(data->phy_irq_pin, 1);
141 }
142
143 /* Pins used for MII and RMII */
144 at91_set_A_periph(AT91_PIN_PA16, 0); /* EMDIO */
145 at91_set_A_periph(AT91_PIN_PA15, 0); /* EMDC */
146 at91_set_A_periph(AT91_PIN_PA14, 0); /* ERXER */
147 at91_set_A_periph(AT91_PIN_PA13, 0); /* ERX1 */
148 at91_set_A_periph(AT91_PIN_PA12, 0); /* ERX0 */
149 at91_set_A_periph(AT91_PIN_PA11, 0); /* ECRS_ECRSDV */
150 at91_set_A_periph(AT91_PIN_PA10, 0); /* ETX1 */
151 at91_set_A_periph(AT91_PIN_PA9, 0); /* ETX0 */
152 at91_set_A_periph(AT91_PIN_PA8, 0); /* ETXEN */
153 at91_set_A_periph(AT91_PIN_PA7, 0); /* ETXCK_EREFCK */
154
155 if (!data->is_rmii) {
156 at91_set_B_periph(AT91_PIN_PB19, 0); /* ERXCK */
157 at91_set_B_periph(AT91_PIN_PB18, 0); /* ECOL */
158 at91_set_B_periph(AT91_PIN_PB17, 0); /* ERXDV */
159 at91_set_B_periph(AT91_PIN_PB16, 0); /* ERX3 */
160 at91_set_B_periph(AT91_PIN_PB15, 0); /* ERX2 */
161 at91_set_B_periph(AT91_PIN_PB14, 0); /* ETXER */
162 at91_set_B_periph(AT91_PIN_PB13, 0); /* ETX3 */
163 at91_set_B_periph(AT91_PIN_PB12, 0); /* ETX2 */
164 }
165
166 eth_data = *data;
167 platform_device_register(&at91rm9200_eth_device);
168}
169#else
170void __init at91_add_device_eth(struct at91_eth_data *data) {}
171#endif
172
173
174/* --------------------------------------------------------------------
175 * Compact Flash / PCMCIA
176 * -------------------------------------------------------------------- */
177
178#if defined(CONFIG_AT91_CF) || defined(CONFIG_AT91_CF_MODULE)
179static struct at91_cf_data cf_data;
180
181static struct platform_device at91rm9200_cf_device = {
182 .name = "at91_cf",
183 .id = -1,
184 .dev = {
185 .platform_data = &cf_data,
186 },
187 .num_resources = 0,
188};
189
190void __init at91_add_device_cf(struct at91_cf_data *data)
191{
192 if (!data)
193 return;
194
195 /* input/irq */
196 if (data->irq_pin) {
197 at91_set_gpio_input(data->irq_pin, 1);
198 at91_set_deglitch(data->irq_pin, 1);
199 }
200 at91_set_gpio_input(data->det_pin, 1);
201 at91_set_deglitch(data->det_pin, 1);
202
203 /* outputs, initially off */
204 if (data->vcc_pin)
205 at91_set_gpio_output(data->vcc_pin, 0);
206 at91_set_gpio_output(data->rst_pin, 0);
207
208 cf_data = *data;
209 platform_device_register(&at91rm9200_cf_device);
210}
211#else
212void __init at91_add_device_cf(struct at91_cf_data *data) {}
213#endif
214
215
216/* --------------------------------------------------------------------
217 * MMC / SD
218 * -------------------------------------------------------------------- */
219
220#if defined(CONFIG_MMC_AT91RM9200) || defined(CONFIG_MMC_AT91RM9200_MODULE)
221static u64 mmc_dmamask = 0xffffffffUL;
222static struct at91_mmc_data mmc_data;
223
224static struct resource at91_mmc_resources[] = {
225 {
226 .start = AT91_BASE_MCI,
227 .end = AT91_BASE_MCI + SZ_16K - 1,
228 .flags = IORESOURCE_MEM,
229 }
230};
231
232static struct platform_device at91rm9200_mmc_device = {
233 .name = "at91rm9200_mci",
234 .id = -1,
235 .dev = {
236 .dma_mask = &mmc_dmamask,
237 .coherent_dma_mask = 0xffffffff,
238 .platform_data = &mmc_data,
239 },
240 .resource = at91_mmc_resources,
241 .num_resources = ARRAY_SIZE(at91_mmc_resources),
242};
243
244void __init at91_add_device_mmc(struct at91_mmc_data *data)
245{
246 if (!data)
247 return;
248
249 /* input/irq */
250 if (data->det_pin) {
251 at91_set_gpio_input(data->det_pin, 1);
252 at91_set_deglitch(data->det_pin, 1);
253 }
254 if (data->wp_pin)
255 at91_set_gpio_input(data->wp_pin, 1);
256
257 /* CLK */
258 at91_set_A_periph(AT91_PIN_PA27, 0);
259
260 if (data->is_b) {
261 /* CMD */
262 at91_set_B_periph(AT91_PIN_PA8, 0);
263
264 /* DAT0, maybe DAT1..DAT3 */
265 at91_set_B_periph(AT91_PIN_PA9, 0);
266 if (data->wire4) {
267 at91_set_B_periph(AT91_PIN_PA10, 0);
268 at91_set_B_periph(AT91_PIN_PA11, 0);
269 at91_set_B_periph(AT91_PIN_PA12, 0);
270 }
271 } else {
272 /* CMD */
273 at91_set_A_periph(AT91_PIN_PA28, 0);
274
275 /* DAT0, maybe DAT1..DAT3 */
276 at91_set_A_periph(AT91_PIN_PA29, 0);
277 if (data->wire4) {
278 at91_set_B_periph(AT91_PIN_PB3, 0);
279 at91_set_B_periph(AT91_PIN_PB4, 0);
280 at91_set_B_periph(AT91_PIN_PB5, 0);
281 }
282 }
283
284 mmc_data = *data;
285 platform_device_register(&at91rm9200_mmc_device);
286}
287#else
288void __init at91_add_device_mmc(struct at91_mmc_data *data) {}
289#endif
290
291/* -------------------------------------------------------------------- */