[ARM] 3966/1: AT91: RM9200 device data update

This patch contains various updates the at91rm9200_devices.c file:
* Consistent naming of resources and platform_devices.
* PCMCIA/Compact Flash: Configuration of the memory controller
moved out of the driver and into this file.
* MMC: Enable the VCC pin (if one is configured)
* MMC: Enable the internal pullups on the I/O pins.
* NAND: Configuration of the memory controller moved out of the
driver and into this file.
* Added TWI/I2C resources.
* The names of some of the CONFIG_ variables were changed.

Signed-off-by: Andrew Victor <andrew@sanpeople.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by Andrew Victor and committed by Russell King 69c5eccd 58a0cd78

+110 -48
+110 -48
arch/arm/mach-at91rm9200/at91rm9200_devices.c
··· 15 16 #include <linux/platform_device.h> 17 18 - #include <asm/hardware.h> 19 #include <asm/arch/board.h> 20 #include <asm/arch/gpio.h> 21 22 #include "generic.h" 23 ··· 34 static u64 ohci_dmamask = 0xffffffffUL; 35 static struct at91_usbh_data usbh_data; 36 37 - static struct resource at91_usbh_resources[] = { 38 [0] = { 39 .start = AT91RM9200_UHP_BASE, 40 .end = AT91RM9200_UHP_BASE + SZ_1M - 1, ··· 55 .coherent_dma_mask = 0xffffffff, 56 .platform_data = &usbh_data, 57 }, 58 - .resource = at91_usbh_resources, 59 - .num_resources = ARRAY_SIZE(at91_usbh_resources), 60 }; 61 62 void __init at91_add_device_usbh(struct at91_usbh_data *data) ··· 79 #ifdef CONFIG_USB_GADGET_AT91 80 static struct at91_udc_data udc_data; 81 82 - static struct resource at91_udc_resources[] = { 83 [0] = { 84 .start = AT91RM9200_BASE_UDP, 85 .end = AT91RM9200_BASE_UDP + SZ_16K - 1, ··· 98 .dev = { 99 .platform_data = &udc_data, 100 }, 101 - .resource = at91_udc_resources, 102 - .num_resources = ARRAY_SIZE(at91_udc_resources), 103 }; 104 105 void __init at91_add_device_udc(struct at91_udc_data *data) ··· 130 static u64 eth_dmamask = 0xffffffffUL; 131 static struct at91_eth_data eth_data; 132 133 - static struct resource at91_eth_resources[] = { 134 [0] = { 135 .start = AT91_VA_BASE_EMAC, 136 .end = AT91_VA_BASE_EMAC + SZ_16K - 1, ··· 151 .coherent_dma_mask = 0xffffffff, 152 .platform_data = &eth_data, 153 }, 154 - .resource = at91_eth_resources, 155 - .num_resources = ARRAY_SIZE(at91_eth_resources), 156 }; 157 158 void __init at91_add_device_eth(struct at91_eth_data *data) ··· 203 #if defined(CONFIG_AT91_CF) || defined(CONFIG_AT91_CF_MODULE) 204 static struct at91_cf_data cf_data; 205 206 - static struct resource at91_cf_resources[] = { 207 [0] = { 208 - .start = AT91_CF_BASE, 209 /* ties up CS4, CS5 and CS6 */ 210 - .end = AT91_CF_BASE + (0x30000000 - 1), 211 .flags = IORESOURCE_MEM | IORESOURCE_MEM_8AND16BIT, 212 }, 213 }; ··· 220 .dev = { 221 .platform_data = &cf_data, 222 }, 223 - .resource = at91_cf_resources, 224 - .num_resources = ARRAY_SIZE(at91_cf_resources), 225 }; 226 227 void __init at91_add_device_cf(struct at91_cf_data *data) 228 { 229 if (!data) 230 return; 231 232 /* input/irq */ 233 if (data->irq_pin) { ··· 271 at91_set_A_periph(AT91_PIN_PC11, 0); /* NCS5/CFCE1 */ 272 at91_set_A_periph(AT91_PIN_PC12, 0); /* NCS6/CFCE2 */ 273 274 cf_data = *data; 275 platform_device_register(&at91rm9200_cf_device); 276 } ··· 286 * MMC / SD 287 * -------------------------------------------------------------------- */ 288 289 - #if defined(CONFIG_MMC_AT91RM9200) || defined(CONFIG_MMC_AT91RM9200_MODULE) 290 static u64 mmc_dmamask = 0xffffffffUL; 291 static struct at91_mmc_data mmc_data; 292 293 - static struct resource at91_mmc_resources[] = { 294 [0] = { 295 .start = AT91RM9200_BASE_MCI, 296 .end = AT91RM9200_BASE_MCI + SZ_16K - 1, ··· 311 .coherent_dma_mask = 0xffffffff, 312 .platform_data = &mmc_data, 313 }, 314 - .resource = at91_mmc_resources, 315 - .num_resources = ARRAY_SIZE(at91_mmc_resources), 316 }; 317 318 void __init at91_add_device_mmc(struct at91_mmc_data *data) ··· 327 } 328 if (data->wp_pin) 329 at91_set_gpio_input(data->wp_pin, 1); 330 331 /* CLK */ 332 at91_set_A_periph(AT91_PIN_PA27, 0); 333 334 - if (data->is_b) { 335 /* CMD */ 336 - at91_set_B_periph(AT91_PIN_PA8, 0); 337 338 /* DAT0, maybe DAT1..DAT3 */ 339 - at91_set_B_periph(AT91_PIN_PA9, 0); 340 if (data->wire4) { 341 - at91_set_B_periph(AT91_PIN_PA10, 0); 342 - at91_set_B_periph(AT91_PIN_PA11, 0); 343 - at91_set_B_periph(AT91_PIN_PA12, 0); 344 } 345 } else { 346 /* CMD */ 347 - at91_set_A_periph(AT91_PIN_PA28, 0); 348 349 /* DAT0, maybe DAT1..DAT3 */ 350 - at91_set_A_periph(AT91_PIN_PA29, 0); 351 if (data->wire4) { 352 - at91_set_B_periph(AT91_PIN_PB3, 0); 353 - at91_set_B_periph(AT91_PIN_PB4, 0); 354 - at91_set_B_periph(AT91_PIN_PB5, 0); 355 } 356 } 357 ··· 372 #if defined(CONFIG_MTD_NAND_AT91) || defined(CONFIG_MTD_NAND_AT91_MODULE) 373 static struct at91_nand_data nand_data; 374 375 - static struct resource at91_nand_resources[] = { 376 { 377 - .start = AT91_SMARTMEDIA_BASE, 378 - .end = AT91_SMARTMEDIA_BASE + SZ_8M - 1, 379 .flags = IORESOURCE_MEM, 380 } 381 }; 382 383 - static struct platform_device at91_nand_device = { 384 .name = "at91_nand", 385 .id = -1, 386 .dev = { 387 .platform_data = &nand_data, 388 }, 389 - .resource = at91_nand_resources, 390 - .num_resources = ARRAY_SIZE(at91_nand_resources), 391 }; 392 393 void __init at91_add_device_nand(struct at91_nand_data *data) 394 { 395 if (!data) 396 return; 397 398 /* enable pin */ 399 if (data->enable_pin) ··· 427 at91_set_A_periph(AT91_PIN_PC3, 0); /* SMWE */ 428 429 nand_data = *data; 430 - platform_device_register(&at91_nand_device); 431 } 432 #else 433 void __init at91_add_device_nand(struct at91_nand_data *data) {} ··· 439 * -------------------------------------------------------------------- */ 440 441 #if defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE) 442 static struct platform_device at91rm9200_twi_device = { 443 .name = "at91_i2c", 444 .id = -1, 445 - .num_resources = 0, 446 }; 447 448 void __init at91_add_device_i2c(void) ··· 483 #if defined(CONFIG_SPI_AT91) || defined(CONFIG_SPI_AT91_MODULE) || defined(CONFIG_AT91_SPI) || defined(CONFIG_AT91_SPI_MODULE) 484 static u64 spi_dmamask = 0xffffffffUL; 485 486 - static struct resource at91_spi_resources[] = { 487 [0] = { 488 .start = AT91RM9200_BASE_SPI, 489 .end = AT91RM9200_BASE_SPI + SZ_16K - 1, ··· 500 .name = "at91_spi", 501 .id = 0, 502 .dev = { 503 - .dma_mask = &spi_dmamask, 504 - .coherent_dma_mask = 0xffffffff, 505 }, 506 - .resource = at91_spi_resources, 507 - .num_resources = ARRAY_SIZE(at91_spi_resources), 508 }; 509 510 - static const unsigned at91_spi_standard_cs[4] = { AT91_PIN_PA3, AT91_PIN_PA4, AT91_PIN_PA5, AT91_PIN_PA6 }; 511 512 void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) 513 { ··· 523 if (devices[i].controller_data) 524 cs_pin = (unsigned long) devices[i].controller_data; 525 else 526 - cs_pin = at91_spi_standard_cs[devices[i].chip_select]; 527 528 #ifdef CONFIG_SPI_AT91_MANUAL_CS 529 at91_set_gpio_output(cs_pin, 1); ··· 536 } 537 538 spi_register_board_info(devices, nr_devices); 539 - at91_clock_associate("spi0_clk", &at91rm9200_spi_device.dev, "spi"); 540 platform_device_register(&at91rm9200_spi_device); 541 } 542 #else ··· 548 * RTC 549 * -------------------------------------------------------------------- */ 550 551 - #if defined(CONFIG_RTC_DRV_AT91) || defined(CONFIG_RTC_DRV_AT91_MODULE) 552 static struct platform_device at91rm9200_rtc_device = { 553 .name = "at91_rtc", 554 .id = -1, ··· 568 * Watchdog 569 * -------------------------------------------------------------------- */ 570 571 - #if defined(CONFIG_AT91_WATCHDOG) || defined(CONFIG_AT91_WATCHDOG_MODULE) 572 static struct platform_device at91rm9200_wdt_device = { 573 .name = "at91_wdt", 574 .id = -1,
··· 15 16 #include <linux/platform_device.h> 17 18 #include <asm/arch/board.h> 19 #include <asm/arch/gpio.h> 20 + #include <asm/arch/at91rm9200.h> 21 + #include <asm/arch/at91rm9200_mc.h> 22 23 #include "generic.h" 24 ··· 33 static u64 ohci_dmamask = 0xffffffffUL; 34 static struct at91_usbh_data usbh_data; 35 36 + static struct resource usbh_resources[] = { 37 [0] = { 38 .start = AT91RM9200_UHP_BASE, 39 .end = AT91RM9200_UHP_BASE + SZ_1M - 1, ··· 54 .coherent_dma_mask = 0xffffffff, 55 .platform_data = &usbh_data, 56 }, 57 + .resource = usbh_resources, 58 + .num_resources = ARRAY_SIZE(usbh_resources), 59 }; 60 61 void __init at91_add_device_usbh(struct at91_usbh_data *data) ··· 78 #ifdef CONFIG_USB_GADGET_AT91 79 static struct at91_udc_data udc_data; 80 81 + static struct resource udc_resources[] = { 82 [0] = { 83 .start = AT91RM9200_BASE_UDP, 84 .end = AT91RM9200_BASE_UDP + SZ_16K - 1, ··· 97 .dev = { 98 .platform_data = &udc_data, 99 }, 100 + .resource = udc_resources, 101 + .num_resources = ARRAY_SIZE(udc_resources), 102 }; 103 104 void __init at91_add_device_udc(struct at91_udc_data *data) ··· 129 static u64 eth_dmamask = 0xffffffffUL; 130 static struct at91_eth_data eth_data; 131 132 + static struct resource eth_resources[] = { 133 [0] = { 134 .start = AT91_VA_BASE_EMAC, 135 .end = AT91_VA_BASE_EMAC + SZ_16K - 1, ··· 150 .coherent_dma_mask = 0xffffffff, 151 .platform_data = &eth_data, 152 }, 153 + .resource = eth_resources, 154 + .num_resources = ARRAY_SIZE(eth_resources), 155 }; 156 157 void __init at91_add_device_eth(struct at91_eth_data *data) ··· 202 #if defined(CONFIG_AT91_CF) || defined(CONFIG_AT91_CF_MODULE) 203 static struct at91_cf_data cf_data; 204 205 + #define CF_BASE AT91_CHIPSELECT_4 206 + 207 + static struct resource cf_resources[] = { 208 [0] = { 209 + .start = CF_BASE, 210 /* ties up CS4, CS5 and CS6 */ 211 + .end = CF_BASE + (0x30000000 - 1), 212 .flags = IORESOURCE_MEM | IORESOURCE_MEM_8AND16BIT, 213 }, 214 }; ··· 217 .dev = { 218 .platform_data = &cf_data, 219 }, 220 + .resource = cf_resources, 221 + .num_resources = ARRAY_SIZE(cf_resources), 222 }; 223 224 void __init at91_add_device_cf(struct at91_cf_data *data) 225 { 226 + unsigned int csa; 227 + 228 if (!data) 229 return; 230 + 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 252 /* input/irq */ 253 if (data->irq_pin) { ··· 245 at91_set_A_periph(AT91_PIN_PC11, 0); /* NCS5/CFCE1 */ 246 at91_set_A_periph(AT91_PIN_PC12, 0); /* NCS6/CFCE2 */ 247 248 + /* nWAIT is _not_ a default setting */ 249 + at91_set_A_periph(AT91_PIN_PC6, 1); /* nWAIT */ 250 + 251 cf_data = *data; 252 platform_device_register(&at91rm9200_cf_device); 253 } ··· 257 * MMC / SD 258 * -------------------------------------------------------------------- */ 259 260 + #if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE) 261 static u64 mmc_dmamask = 0xffffffffUL; 262 static struct at91_mmc_data mmc_data; 263 264 + static struct resource mmc_resources[] = { 265 [0] = { 266 .start = AT91RM9200_BASE_MCI, 267 .end = AT91RM9200_BASE_MCI + SZ_16K - 1, ··· 282 .coherent_dma_mask = 0xffffffff, 283 .platform_data = &mmc_data, 284 }, 285 + .resource = mmc_resources, 286 + .num_resources = ARRAY_SIZE(mmc_resources), 287 }; 288 289 void __init at91_add_device_mmc(struct at91_mmc_data *data) ··· 298 } 299 if (data->wp_pin) 300 at91_set_gpio_input(data->wp_pin, 1); 301 + if (data->vcc_pin) 302 + at91_set_gpio_output(data->vcc_pin, 0); 303 304 /* CLK */ 305 at91_set_A_periph(AT91_PIN_PA27, 0); 306 307 + if (data->slot_b) { 308 /* CMD */ 309 + at91_set_B_periph(AT91_PIN_PA8, 1); 310 311 /* DAT0, maybe DAT1..DAT3 */ 312 + at91_set_B_periph(AT91_PIN_PA9, 1); 313 if (data->wire4) { 314 + at91_set_B_periph(AT91_PIN_PA10, 1); 315 + at91_set_B_periph(AT91_PIN_PA11, 1); 316 + at91_set_B_periph(AT91_PIN_PA12, 1); 317 } 318 } else { 319 /* CMD */ 320 + at91_set_A_periph(AT91_PIN_PA28, 1); 321 322 /* DAT0, maybe DAT1..DAT3 */ 323 + at91_set_A_periph(AT91_PIN_PA29, 1); 324 if (data->wire4) { 325 + at91_set_B_periph(AT91_PIN_PB3, 1); 326 + at91_set_B_periph(AT91_PIN_PB4, 1); 327 + at91_set_B_periph(AT91_PIN_PB5, 1); 328 } 329 } 330 ··· 341 #if defined(CONFIG_MTD_NAND_AT91) || defined(CONFIG_MTD_NAND_AT91_MODULE) 342 static struct at91_nand_data nand_data; 343 344 + #define NAND_BASE AT91_CHIPSELECT_3 345 + 346 + static struct resource nand_resources[] = { 347 { 348 + .start = NAND_BASE, 349 + .end = NAND_BASE + SZ_8M - 1, 350 .flags = IORESOURCE_MEM, 351 } 352 }; 353 354 + static struct platform_device at91rm9200_nand_device = { 355 .name = "at91_nand", 356 .id = -1, 357 .dev = { 358 .platform_data = &nand_data, 359 }, 360 + .resource = nand_resources, 361 + .num_resources = ARRAY_SIZE(nand_resources), 362 }; 363 364 void __init at91_add_device_nand(struct at91_nand_data *data) 365 { 366 + unsigned int csa; 367 + 368 if (!data) 369 return; 370 + 371 + /* enable the address range of CS3 */ 372 + csa = at91_sys_read(AT91_EBI_CSA); 373 + at91_sys_write(AT91_EBI_CSA, csa | AT91_EBI_CS3A_SMC_SMARTMEDIA); 374 + 375 + /* set the bus interface characteristics */ 376 + at91_sys_write(AT91_SMC_CSR(3), AT91_SMC_ACSS_STD | AT91_SMC_DBW_8 | AT91_SMC_WSEN 377 + | AT91_SMC_NWS_(5) 378 + | AT91_SMC_TDF_(1) 379 + | AT91_SMC_RWSETUP_(0) /* tDS Data Set up Time 30 - ns */ 380 + | AT91_SMC_RWHOLD_(1) /* tDH Data Hold Time 20 - ns */ 381 + ); 382 383 /* enable pin */ 384 if (data->enable_pin) ··· 380 at91_set_A_periph(AT91_PIN_PC3, 0); /* SMWE */ 381 382 nand_data = *data; 383 + platform_device_register(&at91rm9200_nand_device); 384 } 385 #else 386 void __init at91_add_device_nand(struct at91_nand_data *data) {} ··· 392 * -------------------------------------------------------------------- */ 393 394 #if defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE) 395 + 396 + static struct resource twi_resources[] = { 397 + [0] = { 398 + .start = AT91RM9200_BASE_TWI, 399 + .end = AT91RM9200_BASE_TWI + SZ_16K - 1, 400 + .flags = IORESOURCE_MEM, 401 + }, 402 + [1] = { 403 + .start = AT91RM9200_ID_TWI, 404 + .end = AT91RM9200_ID_TWI, 405 + .flags = IORESOURCE_IRQ, 406 + }, 407 + }; 408 + 409 static struct platform_device at91rm9200_twi_device = { 410 .name = "at91_i2c", 411 .id = -1, 412 + .resource = twi_resources, 413 + .num_resources = ARRAY_SIZE(twi_resources), 414 }; 415 416 void __init at91_add_device_i2c(void) ··· 421 #if defined(CONFIG_SPI_AT91) || defined(CONFIG_SPI_AT91_MODULE) || defined(CONFIG_AT91_SPI) || defined(CONFIG_AT91_SPI_MODULE) 422 static u64 spi_dmamask = 0xffffffffUL; 423 424 + static struct resource spi_resources[] = { 425 [0] = { 426 .start = AT91RM9200_BASE_SPI, 427 .end = AT91RM9200_BASE_SPI + SZ_16K - 1, ··· 438 .name = "at91_spi", 439 .id = 0, 440 .dev = { 441 + .dma_mask = &spi_dmamask, 442 + .coherent_dma_mask = 0xffffffff, 443 }, 444 + .resource = spi_resources, 445 + .num_resources = ARRAY_SIZE(spi_resources), 446 }; 447 448 + static const unsigned spi_standard_cs[4] = { AT91_PIN_PA3, AT91_PIN_PA4, AT91_PIN_PA5, AT91_PIN_PA6 }; 449 450 void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) 451 { ··· 461 if (devices[i].controller_data) 462 cs_pin = (unsigned long) devices[i].controller_data; 463 else 464 + cs_pin = spi_standard_cs[devices[i].chip_select]; 465 466 #ifdef CONFIG_SPI_AT91_MANUAL_CS 467 at91_set_gpio_output(cs_pin, 1); ··· 474 } 475 476 spi_register_board_info(devices, nr_devices); 477 + at91_clock_associate("spi_clk", &at91rm9200_spi_device.dev, "spi"); 478 platform_device_register(&at91rm9200_spi_device); 479 } 480 #else ··· 486 * RTC 487 * -------------------------------------------------------------------- */ 488 489 + #if defined(CONFIG_RTC_DRV_AT91RM9200) || defined(CONFIG_RTC_DRV_AT91RM9200_MODULE) 490 static struct platform_device at91rm9200_rtc_device = { 491 .name = "at91_rtc", 492 .id = -1, ··· 506 * Watchdog 507 * -------------------------------------------------------------------- */ 508 509 + #if defined(CONFIG_AT91RM9200_WATCHDOG) || defined(CONFIG_AT91RM9200_WATCHDOG_MODULE) 510 static struct platform_device at91rm9200_wdt_device = { 511 .name = "at91_wdt", 512 .id = -1,