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