dataPreprocessingThread.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. /*
  2. * arch/arm/mach-at91/at91sam9261_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 <linux/fb.h>
  20. #include <video/atmel_lcdc.h>
  21. #include <mach/at91sam9261.h>
  22. #include <mach/at91sam9261_matrix.h>
  23. #include <mach/at91_matrix.h>
  24. #include <mach/at91sam9_smc.h>
  25. #include "board.h"
  26. #include "generic.h"
  27. /* --------------------------------------------------------------------
  28. * USB Host
  29. * -------------------------------------------------------------------- */
  30. #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  31. static u64 ohci_dmamask = DMA_BIT_MASK(32);
  32. static struct at91_usbh_data usbh_data;
  33. static struct resource usbh_resources[] = {
  34. [0] = {
  35. .start = AT91SAM9261_UHP_BASE,
  36. .end = AT91SAM9261_UHP_BASE + SZ_1M - 1,
  37. .flags = IORESOURCE_MEM,
  38. },
  39. [1] = {
  40. .start = NR_IRQS_LEGACY + AT91SAM9261_ID_UHP,
  41. .end = NR_IRQS_LEGACY + AT91SAM9261_ID_UHP,
  42. .flags = IORESOURCE_IRQ,
  43. },
  44. };
  45. static struct platform_device at91sam9261_usbh_device = {
  46. .name = "at91_ohci",
  47. .id = -1,
  48. .dev = {
  49. .dma_mask = &ohci_dmamask,
  50. .coherent_dma_mask = DMA_BIT_MASK(32),
  51. .platform_data = &usbh_data,
  52. },
  53. .resource = usbh_resources,
  54. .num_resources = ARRAY_SIZE(usbh_resources),
  55. };
  56. void __init at91_add_device_usbh(struct at91_usbh_data *data)
  57. {
  58. int i;
  59. if (!data)
  60. return;
  61. /* Enable overcurrent notification */
  62. for (i = 0; i < data->ports; i++) {
  63. if (gpio_is_valid(data->overcurrent_pin[i]))
  64. at91_set_gpio_input(data->overcurrent_pin[i], 1);
  65. }
  66. usbh_data = *data;
  67. platform_device_register(&at91sam9261_usbh_device);
  68. }
  69. #else
  70. void __init at91_add_device_usbh(struct at91_usbh_data *data) {}
  71. #endif
  72. /* --------------------------------------------------------------------
  73. * USB Device (Gadget)
  74. * -------------------------------------------------------------------- */
  75. #if defined(CONFIG_USB_AT91) || defined(CONFIG_USB_AT91_MODULE)
  76. static struct at91_udc_data udc_data;
  77. static struct resource udc_resources[] = {
  78. [0] = {
  79. .start = AT91SAM9261_BASE_UDP,
  80. .end = AT91SAM9261_BASE_UDP + SZ_16K - 1,
  81. .flags = IORESOURCE_MEM,
  82. },
  83. [1] = {
  84. .start = NR_IRQS_LEGACY + AT91SAM9261_ID_UDP,
  85. .end = NR_IRQS_LEGACY + AT91SAM9261_ID_UDP,
  86. .flags = IORESOURCE_IRQ,
  87. },
  88. };
  89. static struct platform_device at91sam9261_udc_device = {
  90. .name = "at91_udc",
  91. .id = -1,
  92. .dev = {
  93. .platform_data = &udc_data,
  94. },
  95. .resource = udc_resources,
  96. .num_resources = ARRAY_SIZE(udc_resources),
  97. };
  98. void __init at91_add_device_udc(struct at91_udc_data *data)
  99. {
  100. if (!data)
  101. return;
  102. if (gpio_is_valid(data->vbus_pin)) {
  103. at91_set_gpio_input(data->vbus_pin, 0);
  104. at91_set_deglitch(data->vbus_pin, 1);
  105. }
  106. /* Pullup pin is handled internally by USB device peripheral */
  107. udc_data = *data;
  108. platform_device_register(&at91sam9261_udc_device);
  109. }
  110. #else
  111. void __init at91_add_device_udc(struct at91_udc_data *data) {}
  112. #endif
  113. /* --------------------------------------------------------------------
  114. * MMC / SD
  115. * -------------------------------------------------------------------- */
  116. #if IS_ENABLED(CONFIG_MMC_ATMELMCI)
  117. static u64 mmc_dmamask = DMA_BIT_MASK(32);
  118. static struct mci_platform_data mmc_data;
  119. static struct resource mmc_resources[] = {
  120. [0] = {
  121. .start = AT91SAM9261_BASE_MCI,
  122. .end = AT91SAM9261_BASE_MCI + SZ_16K - 1,
  123. .flags = IORESOURCE_MEM,
  124. },
  125. [1] = {
  126. .start = NR_IRQS_LEGACY + AT91SAM9261_ID_MCI,
  127. .end = NR_IRQS_LEGACY + AT91SAM9261_ID_MCI,
  128. .flags = IORESOURCE_IRQ,
  129. },
  130. };
  131. static struct platform_device at91sam9261_mmc_device = {
  132. .name = "atmel_mci",
  133. .id = -1,
  134. .dev = {
  135. .dma_mask = &mmc_dmamask,
  136. .coherent_dma_mask = DMA_BIT_MASK(32),
  137. .platform_data = &mmc_data,
  138. },
  139. .resource = mmc_resources,
  140. .num_resources = ARRAY_SIZE(mmc_resources),
  141. };
  142. void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data)
  143. {
  144. if (!data)
  145. return;
  146. if (data->slot[0].bus_width) {
  147. /* input/irq */
  148. if (gpio_is_valid(data->slot[0].detect_pin)) {
  149. at91_set_gpio_input(data->slot[0].detect_pin, 1);
  150. at91_set_deglitch(data->slot[0].detect_pin, 1);
  151. }
  152. if (gpio_is_valid(data->slot[0].wp_pin))
  153. at91_set_gpio_input(data->slot[0].wp_pin, 1);
  154. /* CLK */
  155. at91_set_B_periph(AT91_PIN_PA2, 0);
  156. /* CMD */
  157. at91_set_B_periph(AT91_PIN_PA1, 1);
  158. /* DAT0, maybe DAT1..DAT3 */
  159. at91_set_B_periph(AT91_PIN_PA0, 1);
  160. if (data->slot[0].bus_width == 4) {
  161. at91_set_B_periph(AT91_PIN_PA4, 1);
  162. at91_set_B_periph(AT91_PIN_PA5, 1);
  163. at91_set_B_periph(AT91_PIN_PA6, 1);
  164. }
  165. mmc_data = *data;
  166. platform_device_register(&at91sam9261_mmc_device);
  167. }
  168. }
  169. #else
  170. void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) {}
  171. #endif
  172. /* --------------------------------------------------------------------
  173. * NAND / SmartMedia
  174. * -------------------------------------------------------------------- */
  175. #if defined(CONFIG_MTD_NAND_ATMEL) || defined(CONFIG_MTD_NAND_ATMEL_MODULE)
  176. static struct atmel_nand_data nand_data;
  177. #define NAND_BASE AT91_CHIPSELECT_3
  178. static struct resource nand_resources[] = {
  179. {
  180. .start = NAND_BASE,
  181. .end = NAND_BASE + SZ_256M - 1,
  182. .flags = IORESOURCE_MEM,
  183. }
  184. };
  185. static struct platform_device atmel_nand_device = {
  186. .name = "atmel_nand",
  187. .id = -1,
  188. .dev = {
  189. .platform_data = &nand_data,
  190. },
  191. .resource = nand_resources,
  192. .num_resources = ARRAY_SIZE(nand_resources),
  193. };
  194. void __init at91_add_device_nand(struct atmel_nand_data *data)
  195. {
  196. unsigned long csa;
  197. if (!data)
  198. return;
  199. csa = at91_matrix_read(AT91_MATRIX_EBICSA);
  200. at91_matrix_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA);
  201. /* enable pin */
  202. if (gpio_is_valid(data->enable_pin))
  203. at91_set_gpio_output(data->enable_pin, 1);
  204. /* ready/busy pin */
  205. if (gpio_is_valid(data->rdy_pin))
  206. at91_set_gpio_input(data->rdy_pin, 1);
  207. /* card detect pin */
  208. if (gpio_is_valid(data->det_pin))
  209. at91_set_gpio_input(data->det_pin, 1);
  210. at91_set_A_periph(AT91_PIN_PC0, 0); /* NANDOE */
  211. at91_set_A_periph(AT91_PIN_PC1, 0); /* NANDWE */
  212. nand_data = *data;
  213. platform_device_register(&atmel_nand_device);
  214. }
  215. #else
  216. void __init at91_add_device_nand(struct atmel_nand_data *data) {}
  217. #endif
  218. /* --------------------------------------------------------------------
  219. * TWI (i2c)
  220. * -------------------------------------------------------------------- */
  221. /*
  222. * Prefer the GPIO code since the TWI controller isn't robust
  223. * (gets overruns and underruns under load) and can only issue
  224. * repeated STARTs in one scenario (the driver doesn't yet handle them).
  225. */
  226. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  227. static struct i2c_gpio_platform_data pdata = {
  228. .sda_pin = AT91_PIN_PA7,
  229. .sda_is_open_drain = 1,
  230. .scl_pin = AT91_PIN_PA8,
  231. .scl_is_open_drain = 1,
  232. .udelay = 2, /* ~100 kHz */
  233. };
  234. static struct platform_device at91sam9261_twi_device = {
  235. .name = "i2c-gpio",
  236. .id = 0,
  237. .dev.platform_data = &pdata,
  238. };
  239. void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
  240. {
  241. at91_set_GPIO_periph(AT91_PIN_PA7, 1); /* TWD (SDA) */
  242. at91_set_multi_drive(AT91_PIN_PA7, 1);
  243. at91_set_GPIO_periph(AT91_PIN_PA8, 1); /* TWCK (SCL) */
  244. at91_set_multi_drive(AT91_PIN_PA8, 1);
  245. i2c_register_board_info(0, devices, nr_devices);
  246. platform_device_register(&at91sam9261_twi_device);
  247. }
  248. #elif defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
  249. static struct resource twi_resources[] = {
  250. [0] = {
  251. .start = AT91SAM9261_BASE_TWI,
  252. .end = AT91SAM9261_BASE_TWI + SZ_16K - 1,
  253. .flags = IORESOURCE_MEM,
  254. },
  255. [1] = {
  256. .start = NR_IRQS_LEGACY + AT91SAM9261_ID_TWI,
  257. .end = NR_IRQS_LEGACY + AT91SAM9261_ID_TWI,
  258. .flags = IORESOURCE_IRQ,
  259. },
  260. };
  261. static struct platform_device at91sam9261_twi_device = {
  262. .id = 0,
  263. .resource = twi_resources,
  264. .num_resources = ARRAY_SIZE(twi_resources),
  265. };
  266. void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
  267. {
  268. /* IP version is not the same on 9261 and g10 */
  269. if (cpu_is_at91sam9g10()) {
  270. at91sam9261_twi_device.name = "i2c-at91sam9g10";
  271. /* I2C PIO must not be configured as open-drain on this chip */
  272. } else {
  273. at91sam9261_twi_device.name = "i2c-at91sam9261";
  274. at91_set_multi_drive(AT91_PIN_PA7, 1);
  275. at91_set_multi_drive(AT91_PIN_PA8, 1);
  276. }
  277. /* pins used for TWI interface */
  278. at91_set_A_periph(AT91_PIN_PA7, 0); /* TWD */
  279. at91_set_A_periph(AT91_PIN_PA8, 0); /* TWCK */
  280. i2c_register_board_info(0, devices, nr_devices);
  281. platform_device_register(&at91sam9261_twi_device);
  282. }
  283. #else
  284. void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) {}
  285. #endif
  286. /* --------------------------------------------------------------------
  287. * SPI
  288. * -------------------------------------------------------------------- */
  289. #if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
  290. static u64 spi_dmamask = DMA_BIT_MASK(32);
  291. static struct resource spi0_resources[] = {
  292. [0] = {
  293. .start = AT91SAM9261_BASE_SPI0,
  294. .end = AT91SAM9261_BASE_SPI0 + SZ_16K - 1,
  295. .flags = IORESOURCE_MEM,
  296. },
  297. [1] = {
  298. .start = NR_IRQS_LEGACY + AT91SAM9261_ID_SPI0,
  299. .end = NR_IRQS_LEGACY + AT91SAM9261_ID_SPI0,
  300. .flags = IORESOURCE_IRQ,
  301. },
  302. };
  303. static struct platform_device at91sam9261_spi0_device = {
  304. .name = "atmel_spi",
  305. .id = 0,
  306. .dev = {
  307. .dma_mask = &spi_dmamask,
  308. .coherent_dma_mask = DMA_BIT_MASK(32),
  309. },
  310. .resource = spi0_resources,
  311. .num_resources = ARRAY_SIZE(spi0_resources),
  312. };
  313. static const unsigned spi0_standard_cs[4] = { AT91_PIN_PA3, AT91_PIN_PA4, AT91_PIN_PA5, AT91_PIN_PA6 };
  314. static struct resource spi1_resources[] = {
  315. [0] = {
  316. .start = AT91SAM9261_BASE_SPI1,
  317. .end = AT91SAM9261_BASE_SPI1 + SZ_16K - 1,
  318. .flags = IORESOURCE_MEM,
  319. },
  320. [1] = {
  321. .start = NR_IRQS_LEGACY + AT91SAM9261_ID_SPI1,
  322. .end = NR_IRQS_LEGACY + AT91SAM9261_ID_SPI1,
  323. .flags = IORESOURCE_IRQ,