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