SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 1 | /* |
Andrew Victor | 9d04126 | 2007-02-05 11:42:07 +0100 | [diff] [blame] | 2 | * arch/arm/mach-at91/at91rm9200_devices.c |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 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 | |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 16 | #include <linux/platform_device.h> |
| 17 | |
| 18 | #include <asm/arch/board.h> |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 19 | #include <asm/arch/gpio.h> |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 20 | #include <asm/arch/at91rm9200.h> |
| 21 | #include <asm/arch/at91rm9200_mc.h> |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 22 | |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 23 | #include "generic.h" |
| 24 | |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 25 | |
| 26 | /* -------------------------------------------------------------------- |
| 27 | * USB Host |
| 28 | * -------------------------------------------------------------------- */ |
| 29 | |
| 30 | #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) |
| 31 | static u64 ohci_dmamask = 0xffffffffUL; |
| 32 | static struct at91_usbh_data usbh_data; |
| 33 | |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 34 | static struct resource usbh_resources[] = { |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 35 | [0] = { |
Andrew Victor | 7272991 | 2006-09-27 09:44:11 +0100 | [diff] [blame] | 36 | .start = AT91RM9200_UHP_BASE, |
| 37 | .end = AT91RM9200_UHP_BASE + SZ_1M - 1, |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 38 | .flags = IORESOURCE_MEM, |
| 39 | }, |
| 40 | [1] = { |
Andrew Victor | 7272991 | 2006-09-27 09:44:11 +0100 | [diff] [blame] | 41 | .start = AT91RM9200_ID_UHP, |
| 42 | .end = AT91RM9200_ID_UHP, |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 43 | .flags = IORESOURCE_IRQ, |
| 44 | }, |
| 45 | }; |
| 46 | |
| 47 | static struct platform_device at91rm9200_usbh_device = { |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 48 | .name = "at91_ohci", |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 49 | .id = -1, |
| 50 | .dev = { |
| 51 | .dma_mask = &ohci_dmamask, |
| 52 | .coherent_dma_mask = 0xffffffff, |
| 53 | .platform_data = &usbh_data, |
| 54 | }, |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 55 | .resource = usbh_resources, |
| 56 | .num_resources = ARRAY_SIZE(usbh_resources), |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | void __init at91_add_device_usbh(struct at91_usbh_data *data) |
| 60 | { |
| 61 | if (!data) |
| 62 | return; |
| 63 | |
| 64 | usbh_data = *data; |
| 65 | platform_device_register(&at91rm9200_usbh_device); |
| 66 | } |
| 67 | #else |
| 68 | void __init at91_add_device_usbh(struct at91_usbh_data *data) {} |
| 69 | #endif |
| 70 | |
| 71 | |
| 72 | /* -------------------------------------------------------------------- |
| 73 | * USB Device (Gadget) |
| 74 | * -------------------------------------------------------------------- */ |
| 75 | |
| 76 | #ifdef CONFIG_USB_GADGET_AT91 |
| 77 | static struct at91_udc_data udc_data; |
| 78 | |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 79 | static struct resource udc_resources[] = { |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 80 | [0] = { |
Andrew Victor | 7272991 | 2006-09-27 09:44:11 +0100 | [diff] [blame] | 81 | .start = AT91RM9200_BASE_UDP, |
| 82 | .end = AT91RM9200_BASE_UDP + SZ_16K - 1, |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 83 | .flags = IORESOURCE_MEM, |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 84 | }, |
| 85 | [1] = { |
Andrew Victor | 7272991 | 2006-09-27 09:44:11 +0100 | [diff] [blame] | 86 | .start = AT91RM9200_ID_UDP, |
| 87 | .end = AT91RM9200_ID_UDP, |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 88 | .flags = IORESOURCE_IRQ, |
| 89 | }, |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 90 | }; |
| 91 | |
| 92 | static struct platform_device at91rm9200_udc_device = { |
| 93 | .name = "at91_udc", |
| 94 | .id = -1, |
| 95 | .dev = { |
| 96 | .platform_data = &udc_data, |
| 97 | }, |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 98 | .resource = udc_resources, |
| 99 | .num_resources = ARRAY_SIZE(udc_resources), |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 100 | }; |
| 101 | |
| 102 | void __init at91_add_device_udc(struct at91_udc_data *data) |
| 103 | { |
| 104 | if (!data) |
| 105 | return; |
| 106 | |
| 107 | if (data->vbus_pin) { |
| 108 | at91_set_gpio_input(data->vbus_pin, 0); |
| 109 | at91_set_deglitch(data->vbus_pin, 1); |
| 110 | } |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 111 | if (data->pullup_pin) |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 112 | at91_set_gpio_output(data->pullup_pin, 0); |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 113 | |
| 114 | udc_data = *data; |
| 115 | platform_device_register(&at91rm9200_udc_device); |
| 116 | } |
| 117 | #else |
| 118 | void __init at91_add_device_udc(struct at91_udc_data *data) {} |
| 119 | #endif |
| 120 | |
| 121 | |
| 122 | /* -------------------------------------------------------------------- |
| 123 | * Ethernet |
| 124 | * -------------------------------------------------------------------- */ |
| 125 | |
| 126 | #if defined(CONFIG_ARM_AT91_ETHER) || defined(CONFIG_ARM_AT91_ETHER_MODULE) |
| 127 | static u64 eth_dmamask = 0xffffffffUL; |
| 128 | static struct at91_eth_data eth_data; |
| 129 | |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 130 | static struct resource eth_resources[] = { |
Andrew Victor | 3267c07 | 2006-04-02 17:15:51 +0100 | [diff] [blame] | 131 | [0] = { |
Andrew Victor | 1f51c10 | 2006-09-28 16:26:47 +0100 | [diff] [blame] | 132 | .start = AT91_VA_BASE_EMAC, |
| 133 | .end = AT91_VA_BASE_EMAC + SZ_16K - 1, |
Andrew Victor | 3267c07 | 2006-04-02 17:15:51 +0100 | [diff] [blame] | 134 | .flags = IORESOURCE_MEM, |
| 135 | }, |
| 136 | [1] = { |
Andrew Victor | 7272991 | 2006-09-27 09:44:11 +0100 | [diff] [blame] | 137 | .start = AT91RM9200_ID_EMAC, |
| 138 | .end = AT91RM9200_ID_EMAC, |
Andrew Victor | 3267c07 | 2006-04-02 17:15:51 +0100 | [diff] [blame] | 139 | .flags = IORESOURCE_IRQ, |
| 140 | }, |
| 141 | }; |
| 142 | |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 143 | static struct platform_device at91rm9200_eth_device = { |
| 144 | .name = "at91_ether", |
| 145 | .id = -1, |
| 146 | .dev = { |
| 147 | .dma_mask = ð_dmamask, |
| 148 | .coherent_dma_mask = 0xffffffff, |
| 149 | .platform_data = ð_data, |
| 150 | }, |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 151 | .resource = eth_resources, |
| 152 | .num_resources = ARRAY_SIZE(eth_resources), |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 153 | }; |
| 154 | |
| 155 | void __init at91_add_device_eth(struct at91_eth_data *data) |
| 156 | { |
| 157 | if (!data) |
| 158 | return; |
| 159 | |
| 160 | if (data->phy_irq_pin) { |
| 161 | at91_set_gpio_input(data->phy_irq_pin, 0); |
| 162 | at91_set_deglitch(data->phy_irq_pin, 1); |
| 163 | } |
| 164 | |
| 165 | /* Pins used for MII and RMII */ |
| 166 | at91_set_A_periph(AT91_PIN_PA16, 0); /* EMDIO */ |
| 167 | at91_set_A_periph(AT91_PIN_PA15, 0); /* EMDC */ |
| 168 | at91_set_A_periph(AT91_PIN_PA14, 0); /* ERXER */ |
| 169 | at91_set_A_periph(AT91_PIN_PA13, 0); /* ERX1 */ |
| 170 | at91_set_A_periph(AT91_PIN_PA12, 0); /* ERX0 */ |
| 171 | at91_set_A_periph(AT91_PIN_PA11, 0); /* ECRS_ECRSDV */ |
| 172 | at91_set_A_periph(AT91_PIN_PA10, 0); /* ETX1 */ |
| 173 | at91_set_A_periph(AT91_PIN_PA9, 0); /* ETX0 */ |
| 174 | at91_set_A_periph(AT91_PIN_PA8, 0); /* ETXEN */ |
| 175 | at91_set_A_periph(AT91_PIN_PA7, 0); /* ETXCK_EREFCK */ |
| 176 | |
| 177 | if (!data->is_rmii) { |
| 178 | at91_set_B_periph(AT91_PIN_PB19, 0); /* ERXCK */ |
| 179 | at91_set_B_periph(AT91_PIN_PB18, 0); /* ECOL */ |
| 180 | at91_set_B_periph(AT91_PIN_PB17, 0); /* ERXDV */ |
| 181 | at91_set_B_periph(AT91_PIN_PB16, 0); /* ERX3 */ |
| 182 | at91_set_B_periph(AT91_PIN_PB15, 0); /* ERX2 */ |
| 183 | at91_set_B_periph(AT91_PIN_PB14, 0); /* ETXER */ |
| 184 | at91_set_B_periph(AT91_PIN_PB13, 0); /* ETX3 */ |
| 185 | at91_set_B_periph(AT91_PIN_PB12, 0); /* ETX2 */ |
| 186 | } |
| 187 | |
| 188 | eth_data = *data; |
| 189 | platform_device_register(&at91rm9200_eth_device); |
| 190 | } |
| 191 | #else |
| 192 | void __init at91_add_device_eth(struct at91_eth_data *data) {} |
| 193 | #endif |
| 194 | |
| 195 | |
| 196 | /* -------------------------------------------------------------------- |
| 197 | * Compact Flash / PCMCIA |
| 198 | * -------------------------------------------------------------------- */ |
| 199 | |
| 200 | #if defined(CONFIG_AT91_CF) || defined(CONFIG_AT91_CF_MODULE) |
| 201 | static struct at91_cf_data cf_data; |
| 202 | |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 203 | #define CF_BASE AT91_CHIPSELECT_4 |
| 204 | |
| 205 | static struct resource cf_resources[] = { |
David Brownell | 2c53620 | 2006-04-14 18:05:38 -0700 | [diff] [blame] | 206 | [0] = { |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 207 | .start = CF_BASE, |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 208 | /* ties up CS4, CS5 and CS6 */ |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 209 | .end = CF_BASE + (0x30000000 - 1), |
David Brownell | 2c53620 | 2006-04-14 18:05:38 -0700 | [diff] [blame] | 210 | .flags = IORESOURCE_MEM | IORESOURCE_MEM_8AND16BIT, |
| 211 | }, |
| 212 | }; |
| 213 | |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 214 | static struct platform_device at91rm9200_cf_device = { |
| 215 | .name = "at91_cf", |
| 216 | .id = -1, |
| 217 | .dev = { |
| 218 | .platform_data = &cf_data, |
| 219 | }, |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 220 | .resource = cf_resources, |
| 221 | .num_resources = ARRAY_SIZE(cf_resources), |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 222 | }; |
| 223 | |
| 224 | void __init at91_add_device_cf(struct at91_cf_data *data) |
| 225 | { |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 226 | unsigned int csa; |
| 227 | |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 228 | if (!data) |
| 229 | return; |
| 230 | |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 231 | data->chipselect = 4; /* can only use EBI ChipSelect 4 */ |
| 232 | |
| 233 | /* CF takes over CS4, CS5, CS6 */ |
| 234 | csa = at91_sys_read(AT91_EBI_CSA); |
| 235 | at91_sys_write(AT91_EBI_CSA, csa | AT91_EBI_CS4A_SMC_COMPACTFLASH); |
| 236 | |
| 237 | /* |
| 238 | * Static memory controller timing adjustments. |
| 239 | * REVISIT: these timings are in terms of MCK cycles, so |
| 240 | * when MCK changes (cpufreq etc) so must these values... |
| 241 | */ |
| 242 | at91_sys_write(AT91_SMC_CSR(4), |
| 243 | AT91_SMC_ACSS_STD |
| 244 | | AT91_SMC_DBW_16 |
| 245 | | AT91_SMC_BAT |
| 246 | | AT91_SMC_WSEN |
| 247 | | AT91_SMC_NWS_(32) /* wait states */ |
| 248 | | AT91_SMC_RWSETUP_(6) /* setup time */ |
| 249 | | AT91_SMC_RWHOLD_(4) /* hold time */ |
| 250 | ); |
| 251 | |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 252 | /* input/irq */ |
| 253 | if (data->irq_pin) { |
| 254 | at91_set_gpio_input(data->irq_pin, 1); |
| 255 | at91_set_deglitch(data->irq_pin, 1); |
| 256 | } |
| 257 | at91_set_gpio_input(data->det_pin, 1); |
| 258 | at91_set_deglitch(data->det_pin, 1); |
| 259 | |
| 260 | /* outputs, initially off */ |
| 261 | if (data->vcc_pin) |
| 262 | at91_set_gpio_output(data->vcc_pin, 0); |
| 263 | at91_set_gpio_output(data->rst_pin, 0); |
| 264 | |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 265 | /* force poweron defaults for these pins ... */ |
| 266 | at91_set_A_periph(AT91_PIN_PC9, 0); /* A25/CFRNW */ |
| 267 | at91_set_A_periph(AT91_PIN_PC10, 0); /* NCS4/CFCS */ |
| 268 | at91_set_A_periph(AT91_PIN_PC11, 0); /* NCS5/CFCE1 */ |
| 269 | at91_set_A_periph(AT91_PIN_PC12, 0); /* NCS6/CFCE2 */ |
| 270 | |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 271 | /* nWAIT is _not_ a default setting */ |
Andrew Victor | a14d527 | 2007-01-09 09:03:42 +0100 | [diff] [blame] | 272 | at91_set_A_periph(AT91_PIN_PC6, 1); /* nWAIT */ |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 273 | |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 274 | cf_data = *data; |
| 275 | platform_device_register(&at91rm9200_cf_device); |
| 276 | } |
| 277 | #else |
| 278 | void __init at91_add_device_cf(struct at91_cf_data *data) {} |
| 279 | #endif |
| 280 | |
| 281 | |
| 282 | /* -------------------------------------------------------------------- |
| 283 | * MMC / SD |
| 284 | * -------------------------------------------------------------------- */ |
| 285 | |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 286 | #if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE) |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 287 | static u64 mmc_dmamask = 0xffffffffUL; |
| 288 | static struct at91_mmc_data mmc_data; |
| 289 | |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 290 | static struct resource mmc_resources[] = { |
Andrew Victor | 3267c07 | 2006-04-02 17:15:51 +0100 | [diff] [blame] | 291 | [0] = { |
Andrew Victor | 7272991 | 2006-09-27 09:44:11 +0100 | [diff] [blame] | 292 | .start = AT91RM9200_BASE_MCI, |
| 293 | .end = AT91RM9200_BASE_MCI + SZ_16K - 1, |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 294 | .flags = IORESOURCE_MEM, |
Andrew Victor | 3267c07 | 2006-04-02 17:15:51 +0100 | [diff] [blame] | 295 | }, |
| 296 | [1] = { |
Andrew Victor | 7272991 | 2006-09-27 09:44:11 +0100 | [diff] [blame] | 297 | .start = AT91RM9200_ID_MCI, |
| 298 | .end = AT91RM9200_ID_MCI, |
Andrew Victor | 3267c07 | 2006-04-02 17:15:51 +0100 | [diff] [blame] | 299 | .flags = IORESOURCE_IRQ, |
| 300 | }, |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 301 | }; |
| 302 | |
| 303 | static struct platform_device at91rm9200_mmc_device = { |
Andrew Victor | 3267c07 | 2006-04-02 17:15:51 +0100 | [diff] [blame] | 304 | .name = "at91_mci", |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 305 | .id = -1, |
| 306 | .dev = { |
| 307 | .dma_mask = &mmc_dmamask, |
| 308 | .coherent_dma_mask = 0xffffffff, |
| 309 | .platform_data = &mmc_data, |
| 310 | }, |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 311 | .resource = mmc_resources, |
| 312 | .num_resources = ARRAY_SIZE(mmc_resources), |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 313 | }; |
| 314 | |
Andrew Victor | d0760b3 | 2007-02-08 09:00:39 +0100 | [diff] [blame] | 315 | void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 316 | { |
| 317 | if (!data) |
| 318 | return; |
| 319 | |
| 320 | /* input/irq */ |
| 321 | if (data->det_pin) { |
| 322 | at91_set_gpio_input(data->det_pin, 1); |
| 323 | at91_set_deglitch(data->det_pin, 1); |
| 324 | } |
| 325 | if (data->wp_pin) |
| 326 | at91_set_gpio_input(data->wp_pin, 1); |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 327 | if (data->vcc_pin) |
| 328 | at91_set_gpio_output(data->vcc_pin, 0); |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 329 | |
| 330 | /* CLK */ |
| 331 | at91_set_A_periph(AT91_PIN_PA27, 0); |
| 332 | |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 333 | if (data->slot_b) { |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 334 | /* CMD */ |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 335 | at91_set_B_periph(AT91_PIN_PA8, 1); |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 336 | |
| 337 | /* DAT0, maybe DAT1..DAT3 */ |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 338 | at91_set_B_periph(AT91_PIN_PA9, 1); |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 339 | if (data->wire4) { |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 340 | at91_set_B_periph(AT91_PIN_PA10, 1); |
| 341 | at91_set_B_periph(AT91_PIN_PA11, 1); |
| 342 | at91_set_B_periph(AT91_PIN_PA12, 1); |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 343 | } |
| 344 | } else { |
| 345 | /* CMD */ |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 346 | at91_set_A_periph(AT91_PIN_PA28, 1); |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 347 | |
| 348 | /* DAT0, maybe DAT1..DAT3 */ |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 349 | at91_set_A_periph(AT91_PIN_PA29, 1); |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 350 | if (data->wire4) { |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 351 | at91_set_B_periph(AT91_PIN_PB3, 1); |
| 352 | at91_set_B_periph(AT91_PIN_PB4, 1); |
| 353 | at91_set_B_periph(AT91_PIN_PB5, 1); |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 354 | } |
| 355 | } |
| 356 | |
| 357 | mmc_data = *data; |
| 358 | platform_device_register(&at91rm9200_mmc_device); |
| 359 | } |
| 360 | #else |
Andrew Victor | d0760b3 | 2007-02-08 09:00:39 +0100 | [diff] [blame] | 361 | void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {} |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 362 | #endif |
| 363 | |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 364 | |
Andrew Victor | cc2832a | 2006-04-02 17:15:48 +0100 | [diff] [blame] | 365 | /* -------------------------------------------------------------------- |
Andrew Victor | 3267c07 | 2006-04-02 17:15:51 +0100 | [diff] [blame] | 366 | * NAND / SmartMedia |
| 367 | * -------------------------------------------------------------------- */ |
| 368 | |
| 369 | #if defined(CONFIG_MTD_NAND_AT91) || defined(CONFIG_MTD_NAND_AT91_MODULE) |
| 370 | static struct at91_nand_data nand_data; |
| 371 | |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 372 | #define NAND_BASE AT91_CHIPSELECT_3 |
| 373 | |
| 374 | static struct resource nand_resources[] = { |
Andrew Victor | 3267c07 | 2006-04-02 17:15:51 +0100 | [diff] [blame] | 375 | { |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 376 | .start = NAND_BASE, |
| 377 | .end = NAND_BASE + SZ_8M - 1, |
Andrew Victor | 3267c07 | 2006-04-02 17:15:51 +0100 | [diff] [blame] | 378 | .flags = IORESOURCE_MEM, |
| 379 | } |
| 380 | }; |
| 381 | |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 382 | static struct platform_device at91rm9200_nand_device = { |
Andrew Victor | 3267c07 | 2006-04-02 17:15:51 +0100 | [diff] [blame] | 383 | .name = "at91_nand", |
| 384 | .id = -1, |
| 385 | .dev = { |
| 386 | .platform_data = &nand_data, |
| 387 | }, |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 388 | .resource = nand_resources, |
| 389 | .num_resources = ARRAY_SIZE(nand_resources), |
Andrew Victor | 3267c07 | 2006-04-02 17:15:51 +0100 | [diff] [blame] | 390 | }; |
| 391 | |
| 392 | void __init at91_add_device_nand(struct at91_nand_data *data) |
| 393 | { |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 394 | unsigned int csa; |
| 395 | |
Andrew Victor | 3267c07 | 2006-04-02 17:15:51 +0100 | [diff] [blame] | 396 | if (!data) |
| 397 | return; |
| 398 | |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 399 | /* enable the address range of CS3 */ |
| 400 | csa = at91_sys_read(AT91_EBI_CSA); |
| 401 | at91_sys_write(AT91_EBI_CSA, csa | AT91_EBI_CS3A_SMC_SMARTMEDIA); |
| 402 | |
| 403 | /* set the bus interface characteristics */ |
| 404 | at91_sys_write(AT91_SMC_CSR(3), AT91_SMC_ACSS_STD | AT91_SMC_DBW_8 | AT91_SMC_WSEN |
| 405 | | AT91_SMC_NWS_(5) |
| 406 | | AT91_SMC_TDF_(1) |
| 407 | | AT91_SMC_RWSETUP_(0) /* tDS Data Set up Time 30 - ns */ |
| 408 | | AT91_SMC_RWHOLD_(1) /* tDH Data Hold Time 20 - ns */ |
| 409 | ); |
| 410 | |
Andrew Victor | 3267c07 | 2006-04-02 17:15:51 +0100 | [diff] [blame] | 411 | /* enable pin */ |
| 412 | if (data->enable_pin) |
| 413 | at91_set_gpio_output(data->enable_pin, 1); |
| 414 | |
| 415 | /* ready/busy pin */ |
| 416 | if (data->rdy_pin) |
| 417 | at91_set_gpio_input(data->rdy_pin, 1); |
| 418 | |
| 419 | /* card detect pin */ |
| 420 | if (data->det_pin) |
| 421 | at91_set_gpio_input(data->det_pin, 1); |
| 422 | |
| 423 | at91_set_A_periph(AT91_PIN_PC1, 0); /* SMOE */ |
| 424 | at91_set_A_periph(AT91_PIN_PC3, 0); /* SMWE */ |
| 425 | |
| 426 | nand_data = *data; |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 427 | platform_device_register(&at91rm9200_nand_device); |
Andrew Victor | 3267c07 | 2006-04-02 17:15:51 +0100 | [diff] [blame] | 428 | } |
| 429 | #else |
| 430 | void __init at91_add_device_nand(struct at91_nand_data *data) {} |
| 431 | #endif |
| 432 | |
| 433 | |
| 434 | /* -------------------------------------------------------------------- |
| 435 | * TWI (i2c) |
| 436 | * -------------------------------------------------------------------- */ |
| 437 | |
| 438 | #if defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE) |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 439 | |
| 440 | static struct resource twi_resources[] = { |
| 441 | [0] = { |
| 442 | .start = AT91RM9200_BASE_TWI, |
| 443 | .end = AT91RM9200_BASE_TWI + SZ_16K - 1, |
| 444 | .flags = IORESOURCE_MEM, |
| 445 | }, |
| 446 | [1] = { |
| 447 | .start = AT91RM9200_ID_TWI, |
| 448 | .end = AT91RM9200_ID_TWI, |
| 449 | .flags = IORESOURCE_IRQ, |
| 450 | }, |
| 451 | }; |
| 452 | |
Andrew Victor | 3267c07 | 2006-04-02 17:15:51 +0100 | [diff] [blame] | 453 | static struct platform_device at91rm9200_twi_device = { |
| 454 | .name = "at91_i2c", |
| 455 | .id = -1, |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 456 | .resource = twi_resources, |
| 457 | .num_resources = ARRAY_SIZE(twi_resources), |
Andrew Victor | 3267c07 | 2006-04-02 17:15:51 +0100 | [diff] [blame] | 458 | }; |
| 459 | |
| 460 | void __init at91_add_device_i2c(void) |
| 461 | { |
| 462 | /* pins used for TWI interface */ |
| 463 | at91_set_A_periph(AT91_PIN_PA25, 0); /* TWD */ |
| 464 | at91_set_multi_drive(AT91_PIN_PA25, 1); |
| 465 | |
| 466 | at91_set_A_periph(AT91_PIN_PA26, 0); /* TWCK */ |
| 467 | at91_set_multi_drive(AT91_PIN_PA26, 1); |
| 468 | |
| 469 | platform_device_register(&at91rm9200_twi_device); |
| 470 | } |
| 471 | #else |
| 472 | void __init at91_add_device_i2c(void) {} |
| 473 | #endif |
| 474 | |
| 475 | |
| 476 | /* -------------------------------------------------------------------- |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 477 | * SPI |
| 478 | * -------------------------------------------------------------------- */ |
| 479 | |
Andrew Victor | c06911c | 2007-07-16 11:35:40 +0100 | [diff] [blame^] | 480 | #if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE) |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 481 | static u64 spi_dmamask = 0xffffffffUL; |
| 482 | |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 483 | static struct resource spi_resources[] = { |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 484 | [0] = { |
Andrew Victor | 7272991 | 2006-09-27 09:44:11 +0100 | [diff] [blame] | 485 | .start = AT91RM9200_BASE_SPI, |
| 486 | .end = AT91RM9200_BASE_SPI + SZ_16K - 1, |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 487 | .flags = IORESOURCE_MEM, |
| 488 | }, |
| 489 | [1] = { |
Andrew Victor | 7272991 | 2006-09-27 09:44:11 +0100 | [diff] [blame] | 490 | .start = AT91RM9200_ID_SPI, |
| 491 | .end = AT91RM9200_ID_SPI, |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 492 | .flags = IORESOURCE_IRQ, |
| 493 | }, |
| 494 | }; |
| 495 | |
| 496 | static struct platform_device at91rm9200_spi_device = { |
Andrew Victor | c06911c | 2007-07-16 11:35:40 +0100 | [diff] [blame^] | 497 | .name = "atmel_spi", |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 498 | .id = 0, |
| 499 | .dev = { |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 500 | .dma_mask = &spi_dmamask, |
| 501 | .coherent_dma_mask = 0xffffffff, |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 502 | }, |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 503 | .resource = spi_resources, |
| 504 | .num_resources = ARRAY_SIZE(spi_resources), |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 505 | }; |
| 506 | |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 507 | static const unsigned spi_standard_cs[4] = { AT91_PIN_PA3, AT91_PIN_PA4, AT91_PIN_PA5, AT91_PIN_PA6 }; |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 508 | |
| 509 | void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) |
| 510 | { |
| 511 | int i; |
| 512 | unsigned long cs_pin; |
| 513 | |
| 514 | at91_set_A_periph(AT91_PIN_PA0, 0); /* MISO */ |
| 515 | at91_set_A_periph(AT91_PIN_PA1, 0); /* MOSI */ |
| 516 | at91_set_A_periph(AT91_PIN_PA2, 0); /* SPCK */ |
| 517 | |
| 518 | /* Enable SPI chip-selects */ |
| 519 | for (i = 0; i < nr_devices; i++) { |
| 520 | if (devices[i].controller_data) |
| 521 | cs_pin = (unsigned long) devices[i].controller_data; |
| 522 | else |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 523 | cs_pin = spi_standard_cs[devices[i].chip_select]; |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 524 | |
Andrew Victor | c06911c | 2007-07-16 11:35:40 +0100 | [diff] [blame^] | 525 | /* enable chip-select pin */ |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 526 | at91_set_gpio_output(cs_pin, 1); |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 527 | |
| 528 | /* pass chip-select pin to driver */ |
| 529 | devices[i].controller_data = (void *) cs_pin; |
| 530 | } |
| 531 | |
| 532 | spi_register_board_info(devices, nr_devices); |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 533 | platform_device_register(&at91rm9200_spi_device); |
| 534 | } |
| 535 | #else |
| 536 | void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) {} |
| 537 | #endif |
| 538 | |
| 539 | |
| 540 | /* -------------------------------------------------------------------- |
Andrew Victor | 3267c07 | 2006-04-02 17:15:51 +0100 | [diff] [blame] | 541 | * RTC |
| 542 | * -------------------------------------------------------------------- */ |
| 543 | |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 544 | #if defined(CONFIG_RTC_DRV_AT91RM9200) || defined(CONFIG_RTC_DRV_AT91RM9200_MODULE) |
Andrew Victor | 3267c07 | 2006-04-02 17:15:51 +0100 | [diff] [blame] | 545 | static struct platform_device at91rm9200_rtc_device = { |
| 546 | .name = "at91_rtc", |
| 547 | .id = -1, |
| 548 | .num_resources = 0, |
| 549 | }; |
| 550 | |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 551 | static void __init at91_add_device_rtc(void) |
Andrew Victor | 3267c07 | 2006-04-02 17:15:51 +0100 | [diff] [blame] | 552 | { |
| 553 | platform_device_register(&at91rm9200_rtc_device); |
| 554 | } |
| 555 | #else |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 556 | static void __init at91_add_device_rtc(void) {} |
| 557 | #endif |
| 558 | |
| 559 | |
| 560 | /* -------------------------------------------------------------------- |
| 561 | * Watchdog |
| 562 | * -------------------------------------------------------------------- */ |
| 563 | |
Andrew Victor | 69c5ecc | 2006-12-01 15:53:20 +0100 | [diff] [blame] | 564 | #if defined(CONFIG_AT91RM9200_WATCHDOG) || defined(CONFIG_AT91RM9200_WATCHDOG_MODULE) |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 565 | static struct platform_device at91rm9200_wdt_device = { |
| 566 | .name = "at91_wdt", |
| 567 | .id = -1, |
| 568 | .num_resources = 0, |
| 569 | }; |
| 570 | |
| 571 | static void __init at91_add_device_watchdog(void) |
| 572 | { |
| 573 | platform_device_register(&at91rm9200_wdt_device); |
| 574 | } |
| 575 | #else |
| 576 | static void __init at91_add_device_watchdog(void) {} |
Andrew Victor | 3267c07 | 2006-04-02 17:15:51 +0100 | [diff] [blame] | 577 | #endif |
| 578 | |
| 579 | |
| 580 | /* -------------------------------------------------------------------- |
Andrew Victor | cc2832a | 2006-04-02 17:15:48 +0100 | [diff] [blame] | 581 | * LEDs |
| 582 | * -------------------------------------------------------------------- */ |
| 583 | |
| 584 | #if defined(CONFIG_LEDS) |
| 585 | u8 at91_leds_cpu; |
| 586 | u8 at91_leds_timer; |
| 587 | |
| 588 | void __init at91_init_leds(u8 cpu_led, u8 timer_led) |
| 589 | { |
Andrew Victor | da11d02 | 2007-02-08 11:18:14 +0100 | [diff] [blame] | 590 | /* Enable GPIO to access the LEDs */ |
| 591 | at91_set_gpio_output(cpu_led, 1); |
| 592 | at91_set_gpio_output(timer_led, 1); |
| 593 | |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 594 | at91_leds_cpu = cpu_led; |
| 595 | at91_leds_timer = timer_led; |
Andrew Victor | cc2832a | 2006-04-02 17:15:48 +0100 | [diff] [blame] | 596 | } |
Andrew Victor | cc2832a | 2006-04-02 17:15:48 +0100 | [diff] [blame] | 597 | #else |
| 598 | void __init at91_init_leds(u8 cpu_led, u8 timer_led) {} |
| 599 | #endif |
| 600 | |
| 601 | |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 602 | /* -------------------------------------------------------------------- |
| 603 | * UART |
| 604 | * -------------------------------------------------------------------- */ |
| 605 | |
Haavard Skinnemoen | 749c4e6 | 2006-10-04 16:02:02 +0200 | [diff] [blame] | 606 | #if defined(CONFIG_SERIAL_ATMEL) |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 607 | static struct resource dbgu_resources[] = { |
| 608 | [0] = { |
| 609 | .start = AT91_VA_BASE_SYS + AT91_DBGU, |
| 610 | .end = AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1, |
| 611 | .flags = IORESOURCE_MEM, |
| 612 | }, |
| 613 | [1] = { |
| 614 | .start = AT91_ID_SYS, |
| 615 | .end = AT91_ID_SYS, |
| 616 | .flags = IORESOURCE_IRQ, |
| 617 | }, |
| 618 | }; |
| 619 | |
Haavard Skinnemoen | 73e2798 | 2006-10-04 16:02:04 +0200 | [diff] [blame] | 620 | static struct atmel_uart_data dbgu_data = { |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 621 | .use_dma_tx = 0, |
| 622 | .use_dma_rx = 0, /* DBGU not capable of receive DMA */ |
Haavard Skinnemoen | 75d3521 | 2006-10-04 16:02:08 +0200 | [diff] [blame] | 623 | .regs = (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU), |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 624 | }; |
| 625 | |
| 626 | static struct platform_device at91rm9200_dbgu_device = { |
Haavard Skinnemoen | 1e8ea80 | 2006-10-04 16:02:03 +0200 | [diff] [blame] | 627 | .name = "atmel_usart", |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 628 | .id = 0, |
| 629 | .dev = { |
| 630 | .platform_data = &dbgu_data, |
| 631 | .coherent_dma_mask = 0xffffffff, |
| 632 | }, |
| 633 | .resource = dbgu_resources, |
| 634 | .num_resources = ARRAY_SIZE(dbgu_resources), |
| 635 | }; |
| 636 | |
| 637 | static inline void configure_dbgu_pins(void) |
| 638 | { |
| 639 | at91_set_A_periph(AT91_PIN_PA30, 0); /* DRXD */ |
| 640 | at91_set_A_periph(AT91_PIN_PA31, 1); /* DTXD */ |
| 641 | } |
| 642 | |
| 643 | static struct resource uart0_resources[] = { |
| 644 | [0] = { |
Andrew Victor | 7272991 | 2006-09-27 09:44:11 +0100 | [diff] [blame] | 645 | .start = AT91RM9200_BASE_US0, |
| 646 | .end = AT91RM9200_BASE_US0 + SZ_16K - 1, |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 647 | .flags = IORESOURCE_MEM, |
| 648 | }, |
| 649 | [1] = { |
Andrew Victor | 7272991 | 2006-09-27 09:44:11 +0100 | [diff] [blame] | 650 | .start = AT91RM9200_ID_US0, |
| 651 | .end = AT91RM9200_ID_US0, |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 652 | .flags = IORESOURCE_IRQ, |
| 653 | }, |
| 654 | }; |
| 655 | |
Haavard Skinnemoen | 73e2798 | 2006-10-04 16:02:04 +0200 | [diff] [blame] | 656 | static struct atmel_uart_data uart0_data = { |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 657 | .use_dma_tx = 1, |
| 658 | .use_dma_rx = 1, |
| 659 | }; |
| 660 | |
| 661 | static struct platform_device at91rm9200_uart0_device = { |
Haavard Skinnemoen | 1e8ea80 | 2006-10-04 16:02:03 +0200 | [diff] [blame] | 662 | .name = "atmel_usart", |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 663 | .id = 1, |
| 664 | .dev = { |
| 665 | .platform_data = &uart0_data, |
| 666 | .coherent_dma_mask = 0xffffffff, |
| 667 | }, |
| 668 | .resource = uart0_resources, |
| 669 | .num_resources = ARRAY_SIZE(uart0_resources), |
| 670 | }; |
| 671 | |
| 672 | static inline void configure_usart0_pins(void) |
| 673 | { |
| 674 | at91_set_A_periph(AT91_PIN_PA17, 1); /* TXD0 */ |
| 675 | at91_set_A_periph(AT91_PIN_PA18, 0); /* RXD0 */ |
| 676 | at91_set_A_periph(AT91_PIN_PA20, 0); /* CTS0 */ |
| 677 | |
| 678 | /* |
| 679 | * AT91RM9200 Errata #39 - RTS0 is not internally connected to PA21. |
| 680 | * We need to drive the pin manually. Default is off (RTS is active low). |
| 681 | */ |
| 682 | at91_set_gpio_output(AT91_PIN_PA21, 1); |
| 683 | } |
| 684 | |
| 685 | static struct resource uart1_resources[] = { |
| 686 | [0] = { |
Andrew Victor | 7272991 | 2006-09-27 09:44:11 +0100 | [diff] [blame] | 687 | .start = AT91RM9200_BASE_US1, |
| 688 | .end = AT91RM9200_BASE_US1 + SZ_16K - 1, |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 689 | .flags = IORESOURCE_MEM, |
| 690 | }, |
| 691 | [1] = { |
Andrew Victor | 7272991 | 2006-09-27 09:44:11 +0100 | [diff] [blame] | 692 | .start = AT91RM9200_ID_US1, |
| 693 | .end = AT91RM9200_ID_US1, |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 694 | .flags = IORESOURCE_IRQ, |
| 695 | }, |
| 696 | }; |
| 697 | |
Haavard Skinnemoen | 73e2798 | 2006-10-04 16:02:04 +0200 | [diff] [blame] | 698 | static struct atmel_uart_data uart1_data = { |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 699 | .use_dma_tx = 1, |
| 700 | .use_dma_rx = 1, |
| 701 | }; |
| 702 | |
| 703 | static struct platform_device at91rm9200_uart1_device = { |
Haavard Skinnemoen | 1e8ea80 | 2006-10-04 16:02:03 +0200 | [diff] [blame] | 704 | .name = "atmel_usart", |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 705 | .id = 2, |
| 706 | .dev = { |
| 707 | .platform_data = &uart1_data, |
| 708 | .coherent_dma_mask = 0xffffffff, |
| 709 | }, |
| 710 | .resource = uart1_resources, |
| 711 | .num_resources = ARRAY_SIZE(uart1_resources), |
| 712 | }; |
| 713 | |
| 714 | static inline void configure_usart1_pins(void) |
| 715 | { |
| 716 | at91_set_A_periph(AT91_PIN_PB18, 0); /* RI1 */ |
| 717 | at91_set_A_periph(AT91_PIN_PB19, 0); /* DTR1 */ |
| 718 | at91_set_A_periph(AT91_PIN_PB20, 1); /* TXD1 */ |
| 719 | at91_set_A_periph(AT91_PIN_PB21, 0); /* RXD1 */ |
| 720 | at91_set_A_periph(AT91_PIN_PB23, 0); /* DCD1 */ |
| 721 | at91_set_A_periph(AT91_PIN_PB24, 0); /* CTS1 */ |
| 722 | at91_set_A_periph(AT91_PIN_PB25, 0); /* DSR1 */ |
| 723 | at91_set_A_periph(AT91_PIN_PB26, 0); /* RTS1 */ |
| 724 | } |
| 725 | |
| 726 | static struct resource uart2_resources[] = { |
| 727 | [0] = { |
Andrew Victor | 7272991 | 2006-09-27 09:44:11 +0100 | [diff] [blame] | 728 | .start = AT91RM9200_BASE_US2, |
| 729 | .end = AT91RM9200_BASE_US2 + SZ_16K - 1, |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 730 | .flags = IORESOURCE_MEM, |
| 731 | }, |
| 732 | [1] = { |
Andrew Victor | 7272991 | 2006-09-27 09:44:11 +0100 | [diff] [blame] | 733 | .start = AT91RM9200_ID_US2, |
| 734 | .end = AT91RM9200_ID_US2, |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 735 | .flags = IORESOURCE_IRQ, |
| 736 | }, |
| 737 | }; |
| 738 | |
Haavard Skinnemoen | 73e2798 | 2006-10-04 16:02:04 +0200 | [diff] [blame] | 739 | static struct atmel_uart_data uart2_data = { |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 740 | .use_dma_tx = 1, |
| 741 | .use_dma_rx = 1, |
| 742 | }; |
| 743 | |
| 744 | static struct platform_device at91rm9200_uart2_device = { |
Haavard Skinnemoen | 1e8ea80 | 2006-10-04 16:02:03 +0200 | [diff] [blame] | 745 | .name = "atmel_usart", |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 746 | .id = 3, |
| 747 | .dev = { |
| 748 | .platform_data = &uart2_data, |
| 749 | .coherent_dma_mask = 0xffffffff, |
| 750 | }, |
| 751 | .resource = uart2_resources, |
| 752 | .num_resources = ARRAY_SIZE(uart2_resources), |
| 753 | }; |
| 754 | |
| 755 | static inline void configure_usart2_pins(void) |
| 756 | { |
| 757 | at91_set_A_periph(AT91_PIN_PA22, 0); /* RXD2 */ |
| 758 | at91_set_A_periph(AT91_PIN_PA23, 1); /* TXD2 */ |
| 759 | } |
| 760 | |
| 761 | static struct resource uart3_resources[] = { |
| 762 | [0] = { |
Andrew Victor | 7272991 | 2006-09-27 09:44:11 +0100 | [diff] [blame] | 763 | .start = AT91RM9200_BASE_US3, |
| 764 | .end = AT91RM9200_BASE_US3 + SZ_16K - 1, |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 765 | .flags = IORESOURCE_MEM, |
| 766 | }, |
| 767 | [1] = { |
Andrew Victor | 7272991 | 2006-09-27 09:44:11 +0100 | [diff] [blame] | 768 | .start = AT91RM9200_ID_US3, |
| 769 | .end = AT91RM9200_ID_US3, |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 770 | .flags = IORESOURCE_IRQ, |
| 771 | }, |
| 772 | }; |
| 773 | |
Haavard Skinnemoen | 73e2798 | 2006-10-04 16:02:04 +0200 | [diff] [blame] | 774 | static struct atmel_uart_data uart3_data = { |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 775 | .use_dma_tx = 1, |
| 776 | .use_dma_rx = 1, |
| 777 | }; |
| 778 | |
| 779 | static struct platform_device at91rm9200_uart3_device = { |
Haavard Skinnemoen | 1e8ea80 | 2006-10-04 16:02:03 +0200 | [diff] [blame] | 780 | .name = "atmel_usart", |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 781 | .id = 4, |
| 782 | .dev = { |
| 783 | .platform_data = &uart3_data, |
| 784 | .coherent_dma_mask = 0xffffffff, |
| 785 | }, |
| 786 | .resource = uart3_resources, |
| 787 | .num_resources = ARRAY_SIZE(uart3_resources), |
| 788 | }; |
| 789 | |
| 790 | static inline void configure_usart3_pins(void) |
| 791 | { |
| 792 | at91_set_B_periph(AT91_PIN_PA5, 1); /* TXD3 */ |
| 793 | at91_set_B_periph(AT91_PIN_PA6, 0); /* RXD3 */ |
| 794 | } |
| 795 | |
Haavard Skinnemoen | 73e2798 | 2006-10-04 16:02:04 +0200 | [diff] [blame] | 796 | struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ |
| 797 | struct platform_device *atmel_default_console_device; /* the serial console device */ |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 798 | |
| 799 | void __init at91_init_serial(struct at91_uart_config *config) |
| 800 | { |
| 801 | int i; |
| 802 | |
| 803 | /* Fill in list of supported UARTs */ |
| 804 | for (i = 0; i < config->nr_tty; i++) { |
| 805 | switch (config->tty_map[i]) { |
| 806 | case 0: |
| 807 | configure_usart0_pins(); |
| 808 | at91_uarts[i] = &at91rm9200_uart0_device; |
| 809 | at91_clock_associate("usart0_clk", &at91rm9200_uart0_device.dev, "usart"); |
| 810 | break; |
| 811 | case 1: |
| 812 | configure_usart1_pins(); |
| 813 | at91_uarts[i] = &at91rm9200_uart1_device; |
| 814 | at91_clock_associate("usart1_clk", &at91rm9200_uart1_device.dev, "usart"); |
| 815 | break; |
| 816 | case 2: |
| 817 | configure_usart2_pins(); |
| 818 | at91_uarts[i] = &at91rm9200_uart2_device; |
| 819 | at91_clock_associate("usart2_clk", &at91rm9200_uart2_device.dev, "usart"); |
| 820 | break; |
| 821 | case 3: |
| 822 | configure_usart3_pins(); |
| 823 | at91_uarts[i] = &at91rm9200_uart3_device; |
| 824 | at91_clock_associate("usart3_clk", &at91rm9200_uart3_device.dev, "usart"); |
| 825 | break; |
| 826 | case 4: |
| 827 | configure_dbgu_pins(); |
| 828 | at91_uarts[i] = &at91rm9200_dbgu_device; |
| 829 | at91_clock_associate("mck", &at91rm9200_dbgu_device.dev, "usart"); |
| 830 | break; |
| 831 | default: |
| 832 | continue; |
| 833 | } |
| 834 | at91_uarts[i]->id = i; /* update ID number to mapped ID */ |
| 835 | } |
| 836 | |
| 837 | /* Set serial console device */ |
Haavard Skinnemoen | 73e2798 | 2006-10-04 16:02:04 +0200 | [diff] [blame] | 838 | if (config->console_tty < ATMEL_MAX_UART) |
| 839 | atmel_default_console_device = at91_uarts[config->console_tty]; |
| 840 | if (!atmel_default_console_device) |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 841 | printk(KERN_INFO "AT91: No default serial console defined.\n"); |
| 842 | } |
| 843 | |
| 844 | void __init at91_add_device_serial(void) |
| 845 | { |
| 846 | int i; |
| 847 | |
Haavard Skinnemoen | 73e2798 | 2006-10-04 16:02:04 +0200 | [diff] [blame] | 848 | for (i = 0; i < ATMEL_MAX_UART; i++) { |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 849 | if (at91_uarts[i]) |
| 850 | platform_device_register(at91_uarts[i]); |
| 851 | } |
| 852 | } |
| 853 | #else |
| 854 | void __init at91_init_serial(struct at91_uart_config *config) {} |
| 855 | void __init at91_add_device_serial(void) {} |
| 856 | #endif |
| 857 | |
| 858 | |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 859 | /* -------------------------------------------------------------------- */ |
Andrew Victor | 2e83640 | 2006-06-19 16:31:55 +0100 | [diff] [blame] | 860 | |
| 861 | /* |
| 862 | * These devices are always present and don't need any board-specific |
| 863 | * setup. |
| 864 | */ |
| 865 | static int __init at91_add_standard_devices(void) |
| 866 | { |
| 867 | at91_add_device_rtc(); |
| 868 | at91_add_device_watchdog(); |
| 869 | return 0; |
| 870 | } |
| 871 | |
| 872 | arch_initcall(at91_add_standard_devices); |