preliminaryDataProcessing.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  1. /*
  2. * arch/arm/mach-at91/at91rm9200_devices.c
  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. #include <linux/dma-mapping.h>
  16. #include <linux/gpio.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/i2c-gpio.h>
  19. #include <mach/at91rm9200.h>
  20. #include <mach/at91rm9200_mc.h>
  21. #include <mach/at91_ramc.h>
  22. #include "board.h"
  23. #include "generic.h"
  24. /* --------------------------------------------------------------------
  25. * USB Host
  26. * -------------------------------------------------------------------- */
  27. #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  28. static u64 ohci_dmamask = DMA_BIT_MASK(32);
  29. static struct at91_usbh_data usbh_data;
  30. static struct resource usbh_resources[] = {
  31. [0] = {
  32. .start = AT91RM9200_UHP_BASE,
  33. .end = AT91RM9200_UHP_BASE + SZ_1M - 1,
  34. .flags = IORESOURCE_MEM,
  35. },
  36. [1] = {
  37. .start = NR_IRQS_LEGACY + AT91RM9200_ID_UHP,
  38. .end = NR_IRQS_LEGACY + AT91RM9200_ID_UHP,
  39. .flags = IORESOURCE_IRQ,
  40. },
  41. };
  42. static struct platform_device at91rm9200_usbh_device = {
  43. .name = "at91_ohci",
  44. .id = -1,
  45. .dev = {
  46. .dma_mask = &ohci_dmamask,
  47. .coherent_dma_mask = DMA_BIT_MASK(32),
  48. .platform_data = &usbh_data,
  49. },
  50. .resource = usbh_resources,
  51. .num_resources = ARRAY_SIZE(usbh_resources),
  52. };
  53. void __init at91_add_device_usbh(struct at91_usbh_data *data)
  54. {
  55. int i;
  56. if (!data)
  57. return;
  58. /* Enable overcurrent notification */
  59. for (i = 0; i < data->ports; i++) {
  60. if (gpio_is_valid(data->overcurrent_pin[i]))
  61. at91_set_gpio_input(data->overcurrent_pin[i], 1);
  62. }
  63. usbh_data = *data;
  64. platform_device_register(&at91rm9200_usbh_device);
  65. }
  66. #else
  67. void __init at91_add_device_usbh(struct at91_usbh_data *data) {}
  68. #endif
  69. /* --------------------------------------------------------------------
  70. * USB Device (Gadget)
  71. * -------------------------------------------------------------------- */
  72. #if defined(CONFIG_USB_AT91) || defined(CONFIG_USB_AT91_MODULE)
  73. static struct at91_udc_data udc_data;
  74. static struct resource udc_resources[] = {
  75. [0] = {
  76. .start = AT91RM9200_BASE_UDP,
  77. .end = AT91RM9200_BASE_UDP + SZ_16K - 1,
  78. .flags = IORESOURCE_MEM,
  79. },
  80. [1] = {
  81. .start = NR_IRQS_LEGACY + AT91RM9200_ID_UDP,
  82. .end = NR_IRQS_LEGACY + AT91RM9200_ID_UDP,
  83. .flags = IORESOURCE_IRQ,
  84. },
  85. };
  86. static struct platform_device at91rm9200_udc_device = {
  87. .name = "at91_udc",
  88. .id = -1,
  89. .dev = {
  90. .platform_data = &udc_data,
  91. },
  92. .resource = udc_resources,
  93. .num_resources = ARRAY_SIZE(udc_resources),
  94. };
  95. void __init at91_add_device_udc(struct at91_udc_data *data)
  96. {
  97. if (!data)
  98. return;
  99. if (gpio_is_valid(data->vbus_pin)) {
  100. at91_set_gpio_input(data->vbus_pin, 0);
  101. at91_set_deglitch(data->vbus_pin, 1);
  102. }
  103. if (gpio_is_valid(data->pullup_pin))
  104. at91_set_gpio_output(data->pullup_pin, 0);
  105. udc_data = *data;
  106. platform_device_register(&at91rm9200_udc_device);
  107. }
  108. #else
  109. void __init at91_add_device_udc(struct at91_udc_data *data) {}
  110. #endif
  111. /* --------------------------------------------------------------------
  112. * Ethernet
  113. * -------------------------------------------------------------------- */
  114. #if defined(CONFIG_ARM_AT91_ETHER) || defined(CONFIG_ARM_AT91_ETHER_MODULE)
  115. static u64 eth_dmamask = DMA_BIT_MASK(32);
  116. static struct macb_platform_data eth_data;
  117. static struct resource eth_resources[] = {
  118. [0] = {
  119. .start = AT91RM9200_BASE_EMAC,
  120. .end = AT91RM9200_BASE_EMAC + SZ_16K - 1,
  121. .flags = IORESOURCE_MEM,
  122. },
  123. [1] = {
  124. .start = NR_IRQS_LEGACY + AT91RM9200_ID_EMAC,
  125. .end = NR_IRQS_LEGACY + AT91RM9200_ID_EMAC,
  126. .flags = IORESOURCE_IRQ,
  127. },
  128. };
  129. static struct platform_device at91rm9200_eth_device = {
  130. .name = "at91_ether",
  131. .id = -1,
  132. .dev = {
  133. .dma_mask = &eth_dmamask,
  134. .coherent_dma_mask = DMA_BIT_MASK(32),
  135. .platform_data = &eth_data,
  136. },
  137. .resource = eth_resources,
  138. .num_resources = ARRAY_SIZE(eth_resources),
  139. };
  140. void __init at91_add_device_eth(struct macb_platform_data *data)
  141. {
  142. if (!data)
  143. return;
  144. if (gpio_is_valid(data->phy_irq_pin)) {
  145. at91_set_gpio_input(data->phy_irq_pin, 0);
  146. at91_set_deglitch(data->phy_irq_pin, 1);
  147. }
  148. /* Pins used for MII and RMII */
  149. at91_set_A_periph(AT91_PIN_PA16, 0); /* EMDIO */
  150. at91_set_A_periph(AT91_PIN_PA15, 0); /* EMDC */
  151. at91_set_A_periph(AT91_PIN_PA14, 0); /* ERXER */
  152. at91_set_A_periph(AT91_PIN_PA13, 0); /* ERX1 */
  153. at91_set_A_periph(AT91_PIN_PA12, 0); /* ERX0 */
  154. at91_set_A_periph(AT91_PIN_PA11, 0); /* ECRS_ECRSDV */
  155. at91_set_A_periph(AT91_PIN_PA10, 0); /* ETX1 */
  156. at91_set_A_periph(AT91_PIN_PA9, 0); /* ETX0 */
  157. at91_set_A_periph(AT91_PIN_PA8, 0); /* ETXEN */
  158. at91_set_A_periph(AT91_PIN_PA7, 0); /* ETXCK_EREFCK */
  159. if (!data->is_rmii) {
  160. at91_set_B_periph(AT91_PIN_PB19, 0); /* ERXCK */
  161. at91_set_B_periph(AT91_PIN_PB18, 0); /* ECOL */
  162. at91_set_B_periph(AT91_PIN_PB17, 0); /* ERXDV */
  163. at91_set_B_periph(AT91_PIN_PB16, 0); /* ERX3 */
  164. at91_set_B_periph(AT91_PIN_PB15, 0); /* ERX2 */
  165. at91_set_B_periph(AT91_PIN_PB14, 0); /* ETXER */
  166. at91_set_B_periph(AT91_PIN_PB13, 0); /* ETX3 */
  167. at91_set_B_periph(AT91_PIN_PB12, 0); /* ETX2 */
  168. }
  169. eth_data = *data;
  170. platform_device_register(&at91rm9200_eth_device);
  171. }
  172. #else
  173. void __init at91_add_device_eth(struct macb_platform_data *data) {}
  174. #endif
  175. /* --------------------------------------------------------------------
  176. * Compact Flash / PCMCIA
  177. * -------------------------------------------------------------------- */
  178. #if defined(CONFIG_AT91_CF) || defined(CONFIG_AT91_CF_MODULE)
  179. static struct at91_cf_data cf_data;
  180. #define CF_BASE AT91_CHIPSELECT_4
  181. static struct resource cf_resources[] = {
  182. [0] = {
  183. .start = CF_BASE,
  184. /* ties up CS4, CS5 and CS6 */
  185. .end = CF_BASE + (0x30000000 - 1),
  186. .flags = IORESOURCE_MEM | IORESOURCE_MEM_8AND16BIT,
  187. },
  188. };
  189. static struct platform_device at91rm9200_cf_device = {
  190. .name = "at91_cf",
  191. .id = -1,
  192. .dev = {
  193. .platform_data = &cf_data,
  194. },
  195. .resource = cf_resources,
  196. .num_resources = ARRAY_SIZE(cf_resources),
  197. };
  198. void __init at91_add_device_cf(struct at91_cf_data *data)
  199. {
  200. unsigned int csa;
  201. if (!data)
  202. return;
  203. data->chipselect = 4; /* can only use EBI ChipSelect 4 */
  204. /* CF takes over CS4, CS5, CS6 */
  205. csa = at91_ramc_read(0, AT91_EBI_CSA);
  206. at91_ramc_write(0, AT91_EBI_CSA, csa | AT91_EBI_CS4A_SMC_COMPACTFLASH);
  207. /*
  208. * Static memory controller timing adjustments.
  209. * REVISIT: these timings are in terms of MCK cycles, so
  210. * when MCK changes (cpufreq etc) so must these values...
  211. */
  212. at91_ramc_write(0, AT91_SMC_CSR(4),
  213. AT91_SMC_ACSS_STD
  214. | AT91_SMC_DBW_16
  215. | AT91_SMC_BAT
  216. | AT91_SMC_WSEN
  217. | AT91_SMC_NWS_(32) /* wait states */
  218. | AT91_SMC_RWSETUP_(6) /* setup time */
  219. | AT91_SMC_RWHOLD_(4) /* hold time */
  220. );
  221. /* input/irq */
  222. if (gpio_is_valid(data->irq_pin)) {
  223. at91_set_gpio_input(data->irq_pin, 1);
  224. at91_set_deglitch(data->irq_pin, 1);
  225. }
  226. at91_set_gpio_input(data->det_pin, 1);
  227. at91_set_deglitch(data->det_pin, 1);
  228. /* outputs, initially off */
  229. if (gpio_is_valid(data->vcc_pin))
  230. at91_set_gpio_output(data->vcc_pin, 0);
  231. at91_set_gpio_output(data->rst_pin, 0);
  232. /* force poweron defaults for these pins ... */
  233. at91_set_A_periph(AT91_PIN_PC9, 0); /* A25/CFRNW */
  234. at91_set_A_periph(AT91_PIN_PC10, 0); /* NCS4/CFCS */
  235. at91_set_A_periph(AT91_PIN_PC11, 0); /* NCS5/CFCE1 */
  236. at91_set_A_periph(AT91_PIN_PC12, 0); /* NCS6/CFCE2 */
  237. /* nWAIT is _not_ a default setting */
  238. at91_set_A_periph(AT91_PIN_PC6, 1); /* nWAIT */
  239. cf_data = *data;
  240. platform_device_register(&at91rm9200_cf_device);
  241. }
  242. #else
  243. void __init at91_add_device_cf(struct at91_cf_data *data) {}
  244. #endif
  245. /* --------------------------------------------------------------------
  246. * MMC / SD
  247. * -------------------------------------------------------------------- */
  248. #if IS_ENABLED(CONFIG_MMC_ATMELMCI)
  249. static u64 mmc_dmamask = DMA_BIT_MASK(32);
  250. static struct mci_platform_data mmc_data;
  251. static struct resource mmc_resources[] = {
  252. [0] = {
  253. .start = AT91RM9200_BASE_MCI,
  254. .end = AT91RM9200_BASE_MCI + SZ_16K - 1,
  255. .flags = IORESOURCE_MEM,
  256. },
  257. [1] = {
  258. .start = NR_IRQS_LEGACY + AT91RM9200_ID_MCI,
  259. .end = NR_IRQS_LEGACY + AT91RM9200_ID_MCI,
  260. .flags = IORESOURCE_IRQ,
  261. },
  262. };
  263. static struct platform_device at91rm9200_mmc_device = {
  264. .name = "atmel_mci",
  265. .id = -1,
  266. .dev = {
  267. .dma_mask = &mmc_dmamask,
  268. .coherent_dma_mask = DMA_BIT_MASK(32),
  269. .platform_data = &mmc_data,
  270. },
  271. .resource = mmc_resources,
  272. .num_resources = ARRAY_SIZE(mmc_resources),
  273. };
  274. void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data)
  275. {
  276. unsigned int i;
  277. unsigned int slot_count = 0;
  278. if (!data)
  279. return;
  280. for (i = 0; i < ATMCI_MAX_NR_SLOTS; i++) {
  281. if (!data->slot[i].bus_width)
  282. continue;
  283. /* input/irq */
  284. if (gpio_is_valid(data->slot[i].detect_pin)) {
  285. at91_set_gpio_input(data->slot[i].detect_pin, 1);
  286. at91_set_deglitch(data->slot[i].detect_pin, 1);
  287. }
  288. if (gpio_is_valid(data->slot[i].wp_pin))
  289. at91_set_gpio_input(data->slot[i].wp_pin, 1);
  290. switch (i) {
  291. case 0: /* slot A */
  292. /* CMD */
  293. at91_set_A_periph(AT91_PIN_PA28, 1);
  294. /* DAT0, maybe DAT1..DAT3 */
  295. at91_set_A_periph(AT91_PIN_PA29, 1);
  296. if (data->slot[i].bus_width == 4) {
  297. at91_set_B_periph(AT91_PIN_PB3, 1);
  298. at91_set_B_periph(AT91_PIN_PB4, 1);
  299. at91_set_B_periph(AT91_PIN_PB5, 1);
  300. }
  301. slot_count++;
  302. break;
  303. case 1: /* slot B */
  304. /* CMD */
  305. at91_set_B_periph(AT91_PIN_PA8, 1);
  306. /* DAT0, maybe DAT1..DAT3 */
  307. at91_set_B_periph(AT91_PIN_PA9, 1);
  308. if (data->slot[i].bus_width == 4) {
  309. at91_set_B_periph(AT91_PIN_PA10, 1);
  310. at91_set_B_periph(AT91_PIN_PA11, 1);
  311. at91_set_B_periph(AT91_PIN_PA12, 1);
  312. }
  313. slot_count++;
  314. break;
  315. default:
  316. printk(KERN_ERR
  317. "AT91: SD/MMC slot %d not available\n", i);
  318. break;
  319. }
  320. if (slot_count) {
  321. /* CLK */
  322. at91_set_A_periph(AT91_PIN_PA27, 0);
  323. mmc_data = *data;
  324. platform_device_register(&at91rm9200_mmc_device);
  325. }
  326. }
  327. }
  328. #else
  329. void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) {}
  330. #endif
  331. /* --------------------------------------------------------------------
  332. * NAND / SmartMedia
  333. * -------------------------------------------------------------------- */
  334. #if defined(CONFIG_MTD_NAND_ATMEL) || defined(CONFIG_MTD_NAND_ATMEL_MODULE)
  335. static struct atmel_nand_data nand_data;
  336. #define NAND_BASE AT91_CHIPSELECT_3
  337. static struct resource nand_resources[] = {
  338. {
  339. .start = NAND_BASE,
  340. .end = NAND_BASE + SZ_256M - 1,
  341. .flags = IORESOURCE_MEM,
  342. }
  343. };
  344. static struct platform_device at91rm9200_nand_device = {
  345. .name = "atmel_nand",
  346. .id = -1,
  347. .dev = {
  348. .platform_data = &nand_data,
  349. },
  350. .resource = nand_resources,
  351. .num_resources = ARRAY_SIZE(nand_resources),
  352. };
  353. void __init at91_add_device_nand(struct atmel_nand_data *data)
  354. {
  355. unsigned int csa;
  356. if (!data)
  357. return;
  358. /* enable the address range of CS3 */
  359. csa = at91_ramc_read(0, AT91_EBI_CSA);
  360. at91_ramc_write(0, AT91_EBI_CSA, csa | AT91_EBI_CS3A_SMC_SMARTMEDIA);
  361. /* set the bus interface characteristics */
  362. at91_ramc_write(0, AT91_SMC_CSR(3), AT91_SMC_ACSS_STD | AT91_SMC_DBW_8 | AT91_SMC_WSEN
  363. | AT91_SMC_NWS_(5)
  364. | AT91_SMC_TDF_(1)
  365. | AT91_SMC_RWSETUP_(0) /* tDS Data Set up Time 30 - ns */
  366. | AT91_SMC_RWHOLD_(1) /* tDH Data Hold Time 20 - ns */
  367. );
  368. /* enable pin */
  369. if (gpio_is_valid(data->enable_pin))
  370. at91_set_gpio_output(data->enable_pin, 1);
  371. /* ready/busy pin */
  372. if (gpio_is_valid(data->rdy_pin))
  373. at91_set_gpio_input(data->rdy_pin, 1);
  374. /* card detect pin */
  375. if (gpio_is_valid(data->det_pin))
  376. at91_set_gpio_input(data->det_pin, 1);
  377. at91_set_A_periph(AT91_PIN_PC1, 0); /* SMOE */
  378. at91_set_A_periph(AT91_PIN_PC3, 0); /* SMWE */
  379. nand_data = *data;
  380. platform_device_register(&at91rm9200_nand_device);
  381. }
  382. #else
  383. void __init at91_add_device_nand(struct atmel_nand_data *data) {}
  384. #endif
  385. /* --------------------------------------------------------------------
  386. * TWI (i2c)
  387. * -------------------------------------------------------------------- */
  388. /*
  389. * Prefer the GPIO code since the TWI controller isn't robust
  390. * (gets overruns and underruns under load) and can only issue
  391. * repeated STARTs in one scenario (the driver doesn't yet handle them).
  392. */
  393. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  394. static struct i2c_gpio_platform_data pdata = {
  395. .sda_pin = AT91_PIN_PA25,
  396. .sda_is_open_drain = 1,
  397. .scl_pin = AT91_PIN_PA26,
  398. .scl_is_open_drain = 1,
  399. .udelay = 2, /* ~100 kHz */
  400. };
  401. static struct platform_device at91rm9200_twi_device = {
  402. .name = "i2c-gpio",
  403. .id = 0,
  404. .dev.platform_data = &pdata,
  405. };
  406. void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
  407. {
  408. at91_set_GPIO_periph(AT91_PIN_PA25, 1); /* TWD (SDA) */
  409. at91_set_multi_drive(AT91_PIN_PA25, 1);
  410. at91_set_GPIO_periph(AT91_PIN_PA26, 1); /* TWCK (SCL) */
  411. at91_set_multi_drive(AT91_PIN_PA26, 1);
  412. i2c_register_board_info(0, devices, nr_devices);
  413. platform_device_register(&at91rm9200_twi_device);
  414. }
  415. #elif defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
  416. static struct resource twi_resources[] = {
  417. [0] = {
  418. .start = AT91RM9200_BASE_TWI,
  419. .end = AT91RM9200_BASE_TWI + SZ_16K - 1,
  420. .flags = IORESOURCE_MEM,
  421. },
  422. [1] = {
  423. .start = NR_IRQS_LEGACY + AT91RM9200_ID_TWI,
  424. .end = NR_IRQS_LEGACY + AT91RM9200_ID_TWI,
  425. .flags = IORESOURCE_IRQ,
  426. },
  427. };
  428. static struct platform_device at91rm9200_twi_device = {
  429. .name = "i2c-at91rm9200",
  430. .id = 0,
  431. .resource = twi_resources,
  432. .num_resources = ARRAY_SIZE(twi_resources),
  433. };
  434. void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
  435. {
  436. /* pins used for TWI interface */
  437. at91_set_A_periph(AT91_PIN_PA25, 0); /* TWD */
  438. at91_set_multi_drive(AT91_PIN_PA25, 1);
  439. at91_set_A_periph(AT91_PIN_PA26, 0); /* TWCK */
  440. at91_set_multi_drive(AT91_PIN_PA26, 1);
  441. i2c_register_board_info(0, devices, nr_devices);
  442. platform_device_register(&at91rm9200_twi_device);
  443. }
  444. #else
  445. void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) {}
  446. #endif
  447. /* --------------------------------------------------------------------
  448. * SPI
  449. * -------------------------------------------------------------------- */
  450. #if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
  451. static u64 spi_dmamask = DMA_BIT_MASK(32);
  452. static struct resource spi_resources[] = {
  453. [0] = {
  454. .start = AT91RM9200_BASE_SPI,
  455. .end = AT91RM9200_BASE_SPI + SZ_16K - 1,
  456. .flags = IORESOURCE_MEM,
  457. },
  458. [1] = {
  459. .start = NR_IRQS_LEGACY + AT91RM9200_ID_SPI,
  460. .end = NR_IRQS_LEGACY + AT91RM9200_ID_SPI,
  461. .flags = IORESOURCE_IRQ,
  462. },
  463. };
  464. static struct platform_device at91rm9200_spi_device = {
  465. .name = "atmel_spi",
  466. .id = 0,
  467. .dev = {
  468. .dma_mask = &spi_dmamask,
  469. .coherent_dma_mask = DMA_BIT_MASK(32),
  470. },
  471. .resource = spi_resources,
  472. .num_resources = ARRAY_SIZE(spi_resources),
  473. };
  474. static const unsigned spi_standard_cs[4] = { AT91_PIN_PA3, AT91_PIN_PA4, AT91_PIN_PA5, AT91_PIN_PA6 };
  475. void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
  476. {
  477. int i;
  478. unsigned long cs_pin;
  479. at91_set_A_periph(AT91_PIN_PA0, 0); /* MISO */
  480. at91_set_A_periph(AT91_PIN_PA1, 0); /* MOSI */
  481. at91_set_A_periph(AT91_PIN_PA2, 0); /* SPCK */
  482. /* Enable SPI chip-selects */
  483. for (i = 0; i < nr_devices; i++) {
  484. if (devices[i].controller_data)
  485. cs_pin = (unsigned long) devices[i].controller_data;
  486. else
  487. cs_pin = spi_standard_cs[devices[i].chip_select];
  488. if (devices[i].chip_select == 0) /* for CS0 errata */
  489. at91_set_A_periph(cs_pin, 0);
  490. else
  491. at91_set_gpio_output(cs_pin, 1);
  492. /* pass chip-select pin to driver */
  493. devices[i].controller_data = (void *) cs_pin;
  494. }
  495. spi_register_board_info(devices, nr_devices);
  496. platform_device_register(&at91rm9200_spi_device);
  497. }
  498. #else
  499. void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) {}
  500. #endif
  501. /* --------------------------------------------------------------------
  502. * Timer/Counter blocks
  503. * -------------------------------------------------------------------- */
  504. #ifdef CONFIG_ATMEL_TCLIB
  505. static struct resource tcb0_resources[] = {
  506. [0] = {
  507. .start = AT91RM9200_BASE_TCB0,
  508. .end = AT91RM9200_BASE_TCB0 + SZ_16K - 1,
  509. .flags = IORESOURCE_MEM,
  510. },
  511. [1] = {
  512. .start = NR_IRQS_LEGACY + AT91RM9200_ID_TC0,
  513. .end = NR_IRQS_LEGACY + AT91RM9200_ID_TC0,
  514. .flags = IORESOURCE_IRQ,
  515. },
  516. [2] = {
  517. .start = NR_IRQS_LEGACY + AT91RM9200_ID_TC1,
  518. .end = NR_IRQS_LEGACY + AT91RM9200_ID_TC1,
  519. .flags = IORESOURCE_IRQ,
  520. },
  521. [3] = {
  522. .start = NR_IRQS_LEGACY + AT91RM9200_ID_TC2,
  523. .end = NR_IRQS_LEGACY + AT91RM9200_ID_TC2,
  524. .flags = IORESOURCE_IRQ,
  525. },
  526. };
  527. static struct platform_device at91rm9200_tcb0_device = {
  528. .name = "atmel_tcb",
  529. .id = 0,
  530. .resource = tcb0_resources,
  531. .num_resources = ARRAY_SIZE(tcb0_resources),
  532. };
  533. static struct resource tcb1_resources[] = {
  534. [0] = {
  535. .start = AT91RM9200_BASE_TCB1,
  536. .end = AT91RM9200_BASE_TCB1 + SZ_16K - 1,
  537. .flags = IORESOURCE_MEM,
  538. },
  539. [1] = {
  540. .start = NR_IRQS_LEGACY + AT91RM9200_ID_TC3,
  541. .end = NR_IRQS_LEGACY + AT91RM9200_ID_TC3,
  542. .flags = IORESOURCE_IRQ,
  543. },
  544. [2] = {
  545. .start = NR_IRQS_LEGACY + AT91RM9200_ID_TC4,
  546. .end = NR_IRQS_LEGACY + AT91RM9200_ID_TC4,
  547. .flags = IORESOURCE_IRQ,
  548. },
  549. [3] = {
  550. .start = NR_IRQS_LEGACY + AT91RM9200_ID_TC5,
  551. .end = NR_IRQS_LEGACY + AT91RM9200_ID_TC5,
  552. .flags = IORESOURCE_IRQ,
  553. },
  554. };
  555. static struct platform_device at91rm9200_tcb1_device = {
  556. .name = "atmel_tcb",
  557. .id = 1,
  558. .resource = tcb1_resources,
  559. .num_resources = ARRAY_SIZE(tcb1_resources),
  560. };
  561. static void __init at91_add_device_tc(void)
  562. {
  563. platform_device_register(&at91rm9200_tcb0_device);
  564. platform_device_register(&at91rm9200_tcb1_device);
  565. }
  566. #else
  567. static void __init at91_add_device_tc(void) { }
  568. #endif
  569. /* --------------------------------------------------------------------
  570. * RTC
  571. * -------------------------------------------------------------------- */
  572. #if defined(CONFIG_RTC_DRV_AT91RM9200) || defined(CONFIG_RTC_DRV_AT91RM9200_MODULE)
  573. static struct resource rtc_resources[] = {
  574. [0] = {
  575. .start = AT91RM9200_BASE_RTC,
  576. .end = AT91RM9200_BASE_RTC + SZ_256 - 1,
  577. .flags = IORESOURCE_MEM,
  578. },
  579. [1] = {
  580. .start = NR_IRQS_LEGACY + AT91_ID_SYS,
  581. .end = NR_IRQS_LEGACY + AT91_ID_SYS,
  582. .flags = IORESOURCE_IRQ,
  583. },
  584. };
  585. static struct platform_device at91rm9200_rtc_device = {
  586. .name = "at91_rtc",
  587. .id = -1,