2 * arch/arm/mach-at91rm9200/devices.c
4 * Copyright (C) 2005 Thibaut VARENE <varenet@parisc-linux.org>
5 * Copyright (C) 2005 David Brownell
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.
13 #include <asm/mach/arch.h>
14 #include <asm/mach/map.h>
16 #include <linux/config.h>
17 #include <linux/platform_device.h>
19 #include <asm/arch/board.h>
20 #include <asm/arch/pio.h>
23 /* --------------------------------------------------------------------
25 * -------------------------------------------------------------------- */
27 #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
28 static u64 ohci_dmamask = 0xffffffffUL;
29 static struct at91_usbh_data usbh_data;
31 static struct resource at91_usbh_resource[] = {
33 .start = AT91_UHP_BASE,
34 .end = AT91_UHP_BASE + SZ_1M - 1,
35 .flags = IORESOURCE_MEM,
40 .flags = IORESOURCE_IRQ,
44 static struct platform_device at91rm9200_usbh_device = {
45 .name = "at91rm9200-ohci",
48 .dma_mask = &ohci_dmamask,
49 .coherent_dma_mask = 0xffffffff,
50 .platform_data = &usbh_data,
52 .resource = at91_usbh_resource,
53 .num_resources = ARRAY_SIZE(at91_usbh_resource),
56 void __init at91_add_device_usbh(struct at91_usbh_data *data)
62 platform_device_register(&at91rm9200_usbh_device);
65 void __init at91_add_device_usbh(struct at91_usbh_data *data) {}
69 /* --------------------------------------------------------------------
71 * -------------------------------------------------------------------- */
73 #ifdef CONFIG_USB_GADGET_AT91
74 static struct at91_udc_data udc_data;
76 static struct resource at91_udc_resources[] = {
78 .start = AT91_BASE_UDP,
79 .end = AT91_BASE_UDP + SZ_16K - 1,
80 .flags = IORESOURCE_MEM,
84 static struct platform_device at91rm9200_udc_device = {
88 .platform_data = &udc_data,
90 .resource = at91_udc_resources,
91 .num_resources = ARRAY_SIZE(at91_udc_resources),
94 void __init at91_add_device_udc(struct at91_udc_data *data)
100 at91_set_gpio_input(data->vbus_pin, 0);
101 at91_set_deglitch(data->vbus_pin, 1);
103 if (data->pullup_pin) {
104 at91_set_gpio_output(data->pullup_pin, 0);
105 at91_set_multi_drive(data->pullup_pin, 1);
109 platform_device_register(&at91rm9200_udc_device);
112 void __init at91_add_device_udc(struct at91_udc_data *data) {}
116 /* --------------------------------------------------------------------
118 * -------------------------------------------------------------------- */
120 #if defined(CONFIG_ARM_AT91_ETHER) || defined(CONFIG_ARM_AT91_ETHER_MODULE)
121 static u64 eth_dmamask = 0xffffffffUL;
122 static struct at91_eth_data eth_data;
124 static struct resource at91_eth_resources[] = {
126 .start = AT91_BASE_EMAC,
127 .end = AT91_BASE_EMAC + SZ_16K - 1,
128 .flags = IORESOURCE_MEM,
131 .start = AT91_ID_EMAC,
133 .flags = IORESOURCE_IRQ,
137 static struct platform_device at91rm9200_eth_device = {
138 .name = "at91_ether",
141 .dma_mask = ð_dmamask,
142 .coherent_dma_mask = 0xffffffff,
143 .platform_data = ð_data,
145 .resource = at91_eth_resources,
146 .num_resources = ARRAY_SIZE(at91_eth_resources),
149 void __init at91_add_device_eth(struct at91_eth_data *data)
154 if (data->phy_irq_pin) {
155 at91_set_gpio_input(data->phy_irq_pin, 0);
156 at91_set_deglitch(data->phy_irq_pin, 1);
159 /* Pins used for MII and RMII */
160 at91_set_A_periph(AT91_PIN_PA16, 0); /* EMDIO */
161 at91_set_A_periph(AT91_PIN_PA15, 0); /* EMDC */
162 at91_set_A_periph(AT91_PIN_PA14, 0); /* ERXER */
163 at91_set_A_periph(AT91_PIN_PA13, 0); /* ERX1 */
164 at91_set_A_periph(AT91_PIN_PA12, 0); /* ERX0 */
165 at91_set_A_periph(AT91_PIN_PA11, 0); /* ECRS_ECRSDV */
166 at91_set_A_periph(AT91_PIN_PA10, 0); /* ETX1 */
167 at91_set_A_periph(AT91_PIN_PA9, 0); /* ETX0 */
168 at91_set_A_periph(AT91_PIN_PA8, 0); /* ETXEN */
169 at91_set_A_periph(AT91_PIN_PA7, 0); /* ETXCK_EREFCK */
171 if (!data->is_rmii) {
172 at91_set_B_periph(AT91_PIN_PB19, 0); /* ERXCK */
173 at91_set_B_periph(AT91_PIN_PB18, 0); /* ECOL */
174 at91_set_B_periph(AT91_PIN_PB17, 0); /* ERXDV */
175 at91_set_B_periph(AT91_PIN_PB16, 0); /* ERX3 */
176 at91_set_B_periph(AT91_PIN_PB15, 0); /* ERX2 */
177 at91_set_B_periph(AT91_PIN_PB14, 0); /* ETXER */
178 at91_set_B_periph(AT91_PIN_PB13, 0); /* ETX3 */
179 at91_set_B_periph(AT91_PIN_PB12, 0); /* ETX2 */
183 platform_device_register(&at91rm9200_eth_device);
186 void __init at91_add_device_eth(struct at91_eth_data *data) {}
190 /* --------------------------------------------------------------------
191 * Compact Flash / PCMCIA
192 * -------------------------------------------------------------------- */
194 #if defined(CONFIG_AT91_CF) || defined(CONFIG_AT91_CF_MODULE)
195 static struct at91_cf_data cf_data;
197 static struct platform_device at91rm9200_cf_device = {
201 .platform_data = &cf_data,
206 void __init at91_add_device_cf(struct at91_cf_data *data)
213 at91_set_gpio_input(data->irq_pin, 1);
214 at91_set_deglitch(data->irq_pin, 1);
216 at91_set_gpio_input(data->det_pin, 1);
217 at91_set_deglitch(data->det_pin, 1);
219 /* outputs, initially off */
221 at91_set_gpio_output(data->vcc_pin, 0);
222 at91_set_gpio_output(data->rst_pin, 0);
225 platform_device_register(&at91rm9200_cf_device);
228 void __init at91_add_device_cf(struct at91_cf_data *data) {}
232 /* --------------------------------------------------------------------
234 * -------------------------------------------------------------------- */
236 #if defined(CONFIG_MMC_AT91RM9200) || defined(CONFIG_MMC_AT91RM9200_MODULE)
237 static u64 mmc_dmamask = 0xffffffffUL;
238 static struct at91_mmc_data mmc_data;
240 static struct resource at91_mmc_resources[] = {
242 .start = AT91_BASE_MCI,
243 .end = AT91_BASE_MCI + SZ_16K - 1,
244 .flags = IORESOURCE_MEM,
247 .start = AT91_ID_MCI,
249 .flags = IORESOURCE_IRQ,
253 static struct platform_device at91rm9200_mmc_device = {
257 .dma_mask = &mmc_dmamask,
258 .coherent_dma_mask = 0xffffffff,
259 .platform_data = &mmc_data,
261 .resource = at91_mmc_resources,
262 .num_resources = ARRAY_SIZE(at91_mmc_resources),
265 void __init at91_add_device_mmc(struct at91_mmc_data *data)
272 at91_set_gpio_input(data->det_pin, 1);
273 at91_set_deglitch(data->det_pin, 1);
276 at91_set_gpio_input(data->wp_pin, 1);
279 at91_set_A_periph(AT91_PIN_PA27, 0);
283 at91_set_B_periph(AT91_PIN_PA8, 0);
285 /* DAT0, maybe DAT1..DAT3 */
286 at91_set_B_periph(AT91_PIN_PA9, 0);
288 at91_set_B_periph(AT91_PIN_PA10, 0);
289 at91_set_B_periph(AT91_PIN_PA11, 0);
290 at91_set_B_periph(AT91_PIN_PA12, 0);
294 at91_set_A_periph(AT91_PIN_PA28, 0);
296 /* DAT0, maybe DAT1..DAT3 */
297 at91_set_A_periph(AT91_PIN_PA29, 0);
299 at91_set_B_periph(AT91_PIN_PB3, 0);
300 at91_set_B_periph(AT91_PIN_PB4, 0);
301 at91_set_B_periph(AT91_PIN_PB5, 0);
306 platform_device_register(&at91rm9200_mmc_device);
309 void __init at91_add_device_mmc(struct at91_mmc_data *data) {}
312 /* --------------------------------------------------------------------
314 * -------------------------------------------------------------------- */
316 #if defined(CONFIG_MTD_NAND_AT91) || defined(CONFIG_MTD_NAND_AT91_MODULE)
317 static struct at91_nand_data nand_data;
319 static struct resource at91_nand_resources[] = {
321 .start = AT91_SMARTMEDIA_BASE,
322 .end = AT91_SMARTMEDIA_BASE + SZ_8M - 1,
323 .flags = IORESOURCE_MEM,
327 static struct platform_device at91_nand_device = {
331 .platform_data = &nand_data,
333 .resource = at91_nand_resources,
334 .num_resources = ARRAY_SIZE(at91_nand_resources),
337 void __init at91_add_device_nand(struct at91_nand_data *data)
343 if (data->enable_pin)
344 at91_set_gpio_output(data->enable_pin, 1);
348 at91_set_gpio_input(data->rdy_pin, 1);
350 /* card detect pin */
352 at91_set_gpio_input(data->det_pin, 1);
354 at91_set_A_periph(AT91_PIN_PC1, 0); /* SMOE */
355 at91_set_A_periph(AT91_PIN_PC3, 0); /* SMWE */
358 platform_device_register(&at91_nand_device);
361 void __init at91_add_device_nand(struct at91_nand_data *data) {}
365 /* --------------------------------------------------------------------
367 * -------------------------------------------------------------------- */
369 #if defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
370 static struct platform_device at91rm9200_twi_device = {
376 void __init at91_add_device_i2c(void)
378 /* pins used for TWI interface */
379 at91_set_A_periph(AT91_PIN_PA25, 0); /* TWD */
380 at91_set_multi_drive(AT91_PIN_PA25, 1);
382 at91_set_A_periph(AT91_PIN_PA26, 0); /* TWCK */
383 at91_set_multi_drive(AT91_PIN_PA26, 1);
385 platform_device_register(&at91rm9200_twi_device);
388 void __init at91_add_device_i2c(void) {}
392 /* --------------------------------------------------------------------
394 * -------------------------------------------------------------------- */
396 #if defined(CONFIG_AT91_RTC) || defined(CONFIG_AT91_RTC_MODULE)
397 static struct platform_device at91rm9200_rtc_device = {
403 void __init at91_add_device_rtc(void)
405 platform_device_register(&at91rm9200_rtc_device);
408 void __init at91_add_device_rtc(void) {}
412 /* --------------------------------------------------------------------
414 * -------------------------------------------------------------------- */
416 #if defined(CONFIG_LEDS)
420 void __init at91_init_leds(u8 cpu_led, u8 timer_led)
422 at91_leds_cpu = cpu_led;
423 at91_leds_timer = timer_led;
427 void __init at91_init_leds(u8 cpu_led, u8 timer_led) {}
431 /* -------------------------------------------------------------------- */