varianceMemoryDefinition.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. /*
  2. * arch/arm/mach-at91/at91sam9263_devices.c
  3. *
  4. * Copyright (C) 2007 Atmel Corporation.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. */
  12. #include <asm/mach/arch.h>
  13. #include <asm/mach/map.h>
  14. #include <linux/dma-mapping.h>
  15. #include <linux/gpio.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/i2c-gpio.h>
  18. #include <linux/fb.h>
  19. #include <video/atmel_lcdc.h>
  20. #include <mach/at91sam9263.h>
  21. #include <mach/at91sam9263_matrix.h>
  22. #include <mach/at91_matrix.h>
  23. #include <mach/at91sam9_smc.h>
  24. #include "board.h"
  25. #include "generic.h"
  26. /* --------------------------------------------------------------------
  27. * USB Host
  28. * -------------------------------------------------------------------- */
  29. #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  30. static u64 ohci_dmamask = DMA_BIT_MASK(32);
  31. static struct at91_usbh_data usbh_data;
  32. static struct resource usbh_resources[] = {
  33. [0] = {
  34. .start = AT91SAM9263_UHP_BASE,
  35. .end = AT91SAM9263_UHP_BASE + SZ_1M - 1,
  36. .flags = IORESOURCE_MEM,
  37. },
  38. [1] = {
  39. .start = NR_IRQS_LEGACY + AT91SAM9263_ID_UHP,
  40. .end = NR_IRQS_LEGACY + AT91SAM9263_ID_UHP,
  41. .flags = IORESOURCE_IRQ,
  42. },
  43. };
  44. static struct platform_device at91_usbh_device = {
  45. .name = "at91_ohci",
  46. .id = -1,
  47. .dev = {
  48. .dma_mask = &ohci_dmamask,
  49. .coherent_dma_mask = DMA_BIT_MASK(32),
  50. .platform_data = &usbh_data,
  51. },
  52. .resource = usbh_resources,
  53. .num_resources = ARRAY_SIZE(usbh_resources),
  54. };
  55. void __init at91_add_device_usbh(struct at91_usbh_data *data)
  56. {
  57. int i;
  58. if (!data)
  59. return;
  60. /* Enable VBus control for UHP ports */
  61. for (i = 0; i < data->ports; i++) {
  62. if (gpio_is_valid(data->vbus_pin[i]))
  63. at91_set_gpio_output(data->vbus_pin[i],
  64. data->vbus_pin_active_low[i]);
  65. }
  66. /* Enable overcurrent notification */
  67. for (i = 0; i < data->ports; i++) {
  68. if (gpio_is_valid(data->overcurrent_pin[i]))
  69. at91_set_gpio_input(data->overcurrent_pin[i], 1);
  70. }
  71. usbh_data = *data;
  72. platform_device_register(&at91_usbh_device);
  73. }
  74. #else
  75. void __init at91_add_device_usbh(struct at91_usbh_data *data) {}
  76. #endif
  77. /* --------------------------------------------------------------------
  78. * USB Device (Gadget)
  79. * -------------------------------------------------------------------- */
  80. #if defined(CONFIG_USB_AT91) || defined(CONFIG_USB_AT91_MODULE)
  81. static struct at91_udc_data udc_data;
  82. static struct resource udc_resources[] = {
  83. [0] = {
  84. .start = AT91SAM9263_BASE_UDP,
  85. .end = AT91SAM9263_BASE_UDP + SZ_16K - 1,
  86. .flags = IORESOURCE_MEM,
  87. },
  88. [1] = {
  89. .start = NR_IRQS_LEGACY + AT91SAM9263_ID_UDP,
  90. .end = NR_IRQS_LEGACY + AT91SAM9263_ID_UDP,
  91. .flags = IORESOURCE_IRQ,
  92. },
  93. };
  94. static struct platform_device at91_udc_device = {
  95. .name = "at91_udc",
  96. .id = -1,
  97. .dev = {
  98. .platform_data = &udc_data,
  99. },
  100. .resource = udc_resources,
  101. .num_resources = ARRAY_SIZE(udc_resources),
  102. };
  103. void __init at91_add_device_udc(struct at91_udc_data *data)
  104. {
  105. if (!data)
  106. return;
  107. if (gpio_is_valid(data->vbus_pin)) {
  108. at91_set_gpio_input(data->vbus_pin, 0);
  109. at91_set_deglitch(data->vbus_pin, 1);
  110. }
  111. /* Pullup pin is handled internally by USB device peripheral */
  112. udc_data = *data;
  113. platform_device_register(&at91_udc_device);
  114. }
  115. #else
  116. void __init at91_add_device_udc(struct at91_udc_data *data) {}
  117. #endif
  118. /* --------------------------------------------------------------------
  119. * Ethernet
  120. * -------------------------------------------------------------------- */
  121. #if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE)
  122. static u64 eth_dmamask = DMA_BIT_MASK(32);
  123. static struct macb_platform_data eth_data;
  124. static struct resource eth_resources[] = {
  125. [0] = {
  126. .start = AT91SAM9263_BASE_EMAC,
  127. .end = AT91SAM9263_BASE_EMAC + SZ_16K - 1,
  128. .flags = IORESOURCE_MEM,
  129. },
  130. [1] = {
  131. .start = NR_IRQS_LEGACY + AT91SAM9263_ID_EMAC,
  132. .end = NR_IRQS_LEGACY + AT91SAM9263_ID_EMAC,
  133. .flags = IORESOURCE_IRQ,
  134. },
  135. };
  136. static struct platform_device at91sam9263_eth_device = {
  137. .name = "macb",
  138. .id = -1,
  139. .dev = {
  140. .dma_mask = &eth_dmamask,
  141. .coherent_dma_mask = DMA_BIT_MASK(32),
  142. .platform_data = &eth_data,
  143. },
  144. .resource = eth_resources,
  145. .num_resources = ARRAY_SIZE(eth_resources),
  146. };
  147. void __init at91_add_device_eth(struct macb_platform_data *data)
  148. {
  149. if (!data)
  150. return;
  151. if (gpio_is_valid(data->phy_irq_pin)) {
  152. at91_set_gpio_input(data->phy_irq_pin, 0);
  153. at91_set_deglitch(data->phy_irq_pin, 1);
  154. }
  155. /* Pins used for MII and RMII */
  156. at91_set_A_periph(AT91_PIN_PE21, 0); /* ETXCK_EREFCK */
  157. at91_set_B_periph(AT91_PIN_PC25, 0); /* ERXDV */
  158. at91_set_A_periph(AT91_PIN_PE25, 0); /* ERX0 */
  159. at91_set_A_periph(AT91_PIN_PE26, 0); /* ERX1 */
  160. at91_set_A_periph(AT91_PIN_PE27, 0); /* ERXER */
  161. at91_set_A_periph(AT91_PIN_PE28, 0); /* ETXEN */
  162. at91_set_A_periph(AT91_PIN_PE23, 0); /* ETX0 */
  163. at91_set_A_periph(AT91_PIN_PE24, 0); /* ETX1 */
  164. at91_set_A_periph(AT91_PIN_PE30, 0); /* EMDIO */
  165. at91_set_A_periph(AT91_PIN_PE29, 0); /* EMDC */
  166. if (!data->is_rmii) {
  167. at91_set_A_periph(AT91_PIN_PE22, 0); /* ECRS */
  168. at91_set_B_periph(AT91_PIN_PC26, 0); /* ECOL */
  169. at91_set_B_periph(AT91_PIN_PC22, 0); /* ERX2 */
  170. at91_set_B_periph(AT91_PIN_PC23, 0); /* ERX3 */
  171. at91_set_B_periph(AT91_PIN_PC27, 0); /* ERXCK */
  172. at91_set_B_periph(AT91_PIN_PC20, 0); /* ETX2 */
  173. at91_set_B_periph(AT91_PIN_PC21, 0); /* ETX3 */
  174. at91_set_B_periph(AT91_PIN_PC24, 0); /* ETXER */
  175. }
  176. eth_data = *data;
  177. platform_device_register(&at91sam9263_eth_device);
  178. }
  179. #else
  180. void __init at91_add_device_eth(struct macb_platform_data *data) {}
  181. #endif
  182. /* --------------------------------------------------------------------
  183. * MMC / SD
  184. * -------------------------------------------------------------------- */
  185. #if IS_ENABLED(CONFIG_MMC_ATMELMCI)
  186. static u64 mmc_dmamask = DMA_BIT_MASK(32);
  187. static struct mci_platform_data mmc0_data, mmc1_data;
  188. static struct resource mmc0_resources[] = {
  189. [0] = {
  190. .start = AT91SAM9263_BASE_MCI0,
  191. .end = AT91SAM9263_BASE_MCI0 + SZ_16K - 1,
  192. .flags = IORESOURCE_MEM,
  193. },
  194. [1] = {
  195. .start = NR_IRQS_LEGACY + AT91SAM9263_ID_MCI0,
  196. .end = NR_IRQS_LEGACY + AT91SAM9263_ID_MCI0,
  197. .flags = IORESOURCE_IRQ,
  198. },
  199. };
  200. static struct platform_device at91sam9263_mmc0_device = {
  201. .name = "atmel_mci",
  202. .id = 0,
  203. .dev = {
  204. .dma_mask = &mmc_dmamask,
  205. .coherent_dma_mask = DMA_BIT_MASK(32),
  206. .platform_data = &mmc0_data,
  207. },
  208. .resource = mmc0_resources,
  209. .num_resources = ARRAY_SIZE(mmc0_resources),
  210. };
  211. static struct resource mmc1_resources[] = {
  212. [0] = {
  213. .start = AT91SAM9263_BASE_MCI1,
  214. .end = AT91SAM9263_BASE_MCI1 + SZ_16K - 1,
  215. .flags = IORESOURCE_MEM,
  216. },
  217. [1] = {
  218. .start = NR_IRQS_LEGACY + AT91SAM9263_ID_MCI1,
  219. .end = NR_IRQS_LEGACY + AT91SAM9263_ID_MCI1,
  220. .flags = IORESOURCE_IRQ,
  221. },
  222. };
  223. static struct platform_device at91sam9263_mmc1_device = {
  224. .name = "atmel_mci",
  225. .id = 1,
  226. .dev = {
  227. .dma_mask = &mmc_dmamask,
  228. .coherent_dma_mask = DMA_BIT_MASK(32),
  229. .platform_data = &mmc1_data,
  230. },
  231. .resource = mmc1_resources,
  232. .num_resources = ARRAY_SIZE(mmc1_resources),
  233. };
  234. void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data)
  235. {
  236. unsigned int i;
  237. unsigned int slot_count = 0;
  238. if (!data)
  239. return;
  240. for (i = 0; i < ATMCI_MAX_NR_SLOTS; i++) {
  241. if (!data->slot[i].bus_width)
  242. continue;
  243. /* input/irq */
  244. if (gpio_is_valid(data->slot[i].detect_pin)) {
  245. at91_set_gpio_input(data->slot[i].detect_pin,
  246. 1);
  247. at91_set_deglitch(data->slot[i].detect_pin,
  248. 1);
  249. }
  250. if (gpio_is_valid(data->slot[i].wp_pin))
  251. at91_set_gpio_input(data->slot[i].wp_pin, 1);
  252. if (mmc_id == 0) { /* MCI0 */
  253. switch (i) {
  254. case 0: /* slot A */
  255. /* CMD */
  256. at91_set_A_periph(AT91_PIN_PA1, 1);
  257. /* DAT0, maybe DAT1..DAT3 */
  258. at91_set_A_periph(AT91_PIN_PA0, 1);
  259. if (data->slot[i].bus_width == 4) {
  260. at91_set_A_periph(AT91_PIN_PA3, 1);
  261. at91_set_A_periph(AT91_PIN_PA4, 1);
  262. at91_set_A_periph(AT91_PIN_PA5, 1);
  263. }
  264. slot_count++;
  265. break;
  266. case 1: /* slot B */
  267. /* CMD */
  268. at91_set_A_periph(AT91_PIN_PA16, 1);
  269. /* DAT0, maybe DAT1..DAT3 */
  270. at91_set_A_periph(AT91_PIN_PA17, 1);
  271. if (data->slot[i].bus_width == 4) {
  272. at91_set_A_periph(AT91_PIN_PA18, 1);
  273. at91_set_A_periph(AT91_PIN_PA19, 1);
  274. at91_set_A_periph(AT91_PIN_PA20, 1);
  275. }
  276. slot_count++;
  277. break;
  278. default:
  279. printk(KERN_ERR
  280. "AT91: SD/MMC slot %d not available\n", i);
  281. break;
  282. }
  283. if (slot_count) {
  284. /* CLK */
  285. at91_set_A_periph(AT91_PIN_PA12, 0);
  286. mmc0_data = *data;
  287. platform_device_register(&at91sam9263_mmc0_device);
  288. }
  289. } else if (mmc_id == 1) { /* MCI1 */
  290. switch (i) {
  291. case 0: /* slot A */
  292. /* CMD */
  293. at91_set_A_periph(AT91_PIN_PA7, 1);
  294. /* DAT0, maybe DAT1..DAT3 */
  295. at91_set_A_periph(AT91_PIN_PA8, 1);
  296. if (data->slot[i].bus_width == 4) {
  297. at91_set_A_periph(AT91_PIN_PA9, 1);
  298. at91_set_A_periph(AT91_PIN_PA10, 1);
  299. at91_set_A_periph(AT91_PIN_PA11, 1);
  300. }
  301. slot_count++;
  302. break;
  303. case 1: /* slot B */
  304. /* CMD */
  305. at91_set_A_periph(AT91_PIN_PA21, 1);
  306. /* DAT0, maybe DAT1..DAT3 */
  307. at91_set_A_periph(AT91_PIN_PA22, 1);
  308. if (data->slot[i].bus_width == 4) {
  309. at91_set_A_periph(AT91_PIN_PA23, 1);
  310. at91_set_A_periph(AT91_PIN_PA24, 1);
  311. at91_set_A_periph(AT91_PIN_PA25, 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_PA6, 0);
  323. mmc1_data = *data;
  324. platform_device_register(&at91sam9263_mmc1_device);
  325. }
  326. }
  327. }
  328. }
  329. #else
  330. void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) {}
  331. #endif
  332. /* --------------------------------------------------------------------
  333. * Compact Flash (PCMCIA or IDE)
  334. * -------------------------------------------------------------------- */
  335. #if defined(CONFIG_PATA_AT91) || defined(CONFIG_PATA_AT91_MODULE) || \
  336. defined(CONFIG_AT91_CF) || defined(CONFIG_AT91_CF_MODULE)
  337. static struct at91_cf_data cf0_data;
  338. static struct resource cf0_resources[] = {
  339. [0] = {
  340. .start = AT91_CHIPSELECT_4,
  341. .end = AT91_CHIPSELECT_4 + SZ_256M - 1,
  342. .flags = IORESOURCE_MEM | IORESOURCE_MEM_8AND16BIT,
  343. }
  344. };
  345. static struct platform_device cf0_device = {
  346. .id = 0,
  347. .dev = {
  348. .platform_data = &cf0_data,
  349. },
  350. .resource = cf0_resources,
  351. .num_resources = ARRAY_SIZE(cf0_resources),
  352. };
  353. static struct at91_cf_data cf1_data;
  354. static struct resource cf1_resources[] = {
  355. [0] = {
  356. .start = AT91_CHIPSELECT_5,
  357. .end = AT91_CHIPSELECT_5 + SZ_256M - 1,
  358. .flags = IORESOURCE_MEM | IORESOURCE_MEM_8AND16BIT,
  359. }
  360. };
  361. static struct platform_device cf1_device = {
  362. .id = 1,
  363. .dev = {
  364. .platform_data = &cf1_data,
  365. },
  366. .resource = cf1_resources,
  367. .num_resources = ARRAY_SIZE(cf1_resources),
  368. };
  369. void __init at91_add_device_cf(struct at91_cf_data *data)
  370. {
  371. unsigned long ebi0_csa;
  372. struct platform_device *pdev;
  373. if (!data)
  374. return;
  375. /*
  376. * assign CS4 or CS5 to SMC with Compact Flash logic support,
  377. * we assume SMC timings are configured by board code,
  378. * except True IDE where timings are controlled by driver
  379. */
  380. ebi0_csa = at91_matrix_read(AT91_MATRIX_EBI0CSA);
  381. switch (data->chipselect) {
  382. case 4:
  383. at91_set_A_periph(AT91_PIN_PD6, 0); /* EBI0_NCS4/CFCS0 */
  384. ebi0_csa |= AT91_MATRIX_EBI0_CS4A_SMC_CF1;
  385. cf0_data = *data;
  386. pdev = &cf0_device;
  387. break;
  388. case 5:
  389. at91_set_A_periph(AT91_PIN_PD7, 0); /* EBI0_NCS5/CFCS1 */
  390. ebi0_csa |= AT91_MATRIX_EBI0_CS5A_SMC_CF2;
  391. cf1_data = *data;
  392. pdev = &cf1_device;
  393. break;
  394. default:
  395. printk(KERN_ERR "AT91 CF: bad chip-select requested (%u)\n",
  396. data->chipselect);
  397. return;
  398. }
  399. at91_matrix_write(AT91_MATRIX_EBI0CSA, ebi0_csa);
  400. if (gpio_is_valid(data->det_pin)) {
  401. at91_set_gpio_input(data->det_pin, 1);
  402. at91_set_deglitch(data->det_pin, 1);
  403. }
  404. if (gpio_is_valid(data->irq_pin)) {
  405. at91_set_gpio_input(data->irq_pin, 1);
  406. at91_set_deglitch(data->irq_pin, 1);