normalDataOperation.c 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. /*
  2. * Copyright 2004-2009 Analog Devices Inc.
  3. * 2008-2009 Bluetechnix
  4. * 2005 National ICT Australia (NICTA)
  5. * Aidan Williams <aidan@nicta.com.au>
  6. *
  7. * Licensed under the GPL-2 or later.
  8. */
  9. #include <linux/device.h>
  10. #include <linux/export.h>
  11. #include <linux/etherdevice.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/mtd/mtd.h>
  14. #include <linux/mtd/partitions.h>
  15. #include <linux/mtd/physmap.h>
  16. #include <linux/spi/spi.h>
  17. #include <linux/spi/flash.h>
  18. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  19. #include <linux/usb/isp1362.h>
  20. #endif
  21. #include <linux/ata_platform.h>
  22. #include <linux/irq.h>
  23. #include <asm/dma.h>
  24. #include <asm/bfin5xx_spi.h>
  25. #include <asm/portmux.h>
  26. #include <asm/dpmc.h>
  27. #include <asm/bfin_sport.h>
  28. /*
  29. * Name the Board for the /proc/cpuinfo
  30. */
  31. const char bfin_board_name[] = "Bluetechnix CM BF537E";
  32. #if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE)
  33. /* all SPI peripherals info goes here */
  34. #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
  35. static struct mtd_partition bfin_spi_flash_partitions[] = {
  36. {
  37. .name = "bootloader(spi)",
  38. .size = 0x00020000,
  39. .offset = 0,
  40. .mask_flags = MTD_CAP_ROM
  41. }, {
  42. .name = "linux kernel(spi)",
  43. .size = 0xe0000,
  44. .offset = 0x20000
  45. }, {
  46. .name = "file system(spi)",
  47. .size = 0x700000,
  48. .offset = 0x00100000,
  49. }
  50. };
  51. static struct flash_platform_data bfin_spi_flash_data = {
  52. .name = "m25p80",
  53. .parts = bfin_spi_flash_partitions,
  54. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  55. .type = "m25p64",
  56. };
  57. /* SPI flash chip (m25p64) */
  58. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  59. .enable_dma = 0, /* use dma transfer with this chip*/
  60. };
  61. #endif
  62. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  63. static struct bfin5xx_spi_chip mmc_spi_chip_info = {
  64. .enable_dma = 0,
  65. };
  66. #endif
  67. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  68. #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
  69. {
  70. /* the modalias must be the same as spi device driver name */
  71. .modalias = "m25p80", /* Name of spi_driver for this device */
  72. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  73. .bus_num = 0, /* Framework bus number */
  74. .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
  75. .platform_data = &bfin_spi_flash_data,
  76. .controller_data = &spi_flash_chip_info,
  77. .mode = SPI_MODE_3,
  78. },
  79. #endif
  80. #if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
  81. {
  82. .modalias = "ad183x",
  83. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  84. .bus_num = 0,
  85. .chip_select = 4,
  86. },
  87. #endif
  88. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  89. {
  90. .modalias = "mmc_spi",
  91. .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
  92. .bus_num = 0,
  93. .chip_select = 1,
  94. .controller_data = &mmc_spi_chip_info,
  95. .mode = SPI_MODE_3,
  96. },
  97. #endif
  98. };
  99. /* SPI (0) */
  100. static struct resource bfin_spi0_resource[] = {
  101. [0] = {
  102. .start = SPI0_REGBASE,
  103. .end = SPI0_REGBASE + 0xFF,
  104. .flags = IORESOURCE_MEM,
  105. },
  106. [1] = {
  107. .start = CH_SPI,
  108. .end = CH_SPI,
  109. .flags = IORESOURCE_DMA,
  110. },
  111. [2] = {
  112. .start = IRQ_SPI,
  113. .end = IRQ_SPI,
  114. .flags = IORESOURCE_IRQ,
  115. },
  116. };
  117. /* SPI controller data */
  118. static struct bfin5xx_spi_master bfin_spi0_info = {
  119. .num_chipselect = 8,
  120. .enable_dma = 1, /* master has the ability to do dma transfer */
  121. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  122. };
  123. static struct platform_device bfin_spi0_device = {
  124. .name = "bfin-spi",
  125. .id = 0, /* Bus number */
  126. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  127. .resource = bfin_spi0_resource,
  128. .dev = {
  129. .platform_data = &bfin_spi0_info, /* Passed to driver */
  130. },
  131. };
  132. #endif /* spi master and devices */
  133. #if defined(CONFIG_SPI_BFIN_SPORT) || defined(CONFIG_SPI_BFIN_SPORT_MODULE)
  134. /* SPORT SPI controller data */
  135. static struct bfin5xx_spi_master bfin_sport_spi0_info = {
  136. .num_chipselect = MAX_BLACKFIN_GPIOS,
  137. .enable_dma = 0, /* master don't support DMA */
  138. .pin_req = {P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_DRPRI,
  139. P_SPORT0_RSCLK, P_SPORT0_TFS, P_SPORT0_RFS, 0},
  140. };
  141. static struct resource bfin_sport_spi0_resource[] = {
  142. [0] = {
  143. .start = SPORT0_TCR1,
  144. .end = SPORT0_TCR1 + 0xFF,
  145. .flags = IORESOURCE_MEM,
  146. },
  147. [1] = {
  148. .start = IRQ_SPORT0_ERROR,
  149. .end = IRQ_SPORT0_ERROR,
  150. .flags = IORESOURCE_IRQ,
  151. },
  152. };
  153. static struct platform_device bfin_sport_spi0_device = {
  154. .name = "bfin-sport-spi",
  155. .id = 1, /* Bus number */
  156. .num_resources = ARRAY_SIZE(bfin_sport_spi0_resource),
  157. .resource = bfin_sport_spi0_resource,
  158. .dev = {
  159. .platform_data = &bfin_sport_spi0_info, /* Passed to driver */
  160. },
  161. };
  162. static struct bfin5xx_spi_master bfin_sport_spi1_info = {
  163. .num_chipselect = MAX_BLACKFIN_GPIOS,
  164. .enable_dma = 0, /* master don't support DMA */
  165. .pin_req = {P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_DRPRI,
  166. P_SPORT1_RSCLK, P_SPORT1_TFS, P_SPORT1_RFS, 0},
  167. };
  168. static struct resource bfin_sport_spi1_resource[] = {
  169. [0] = {
  170. .start = SPORT1_TCR1,
  171. .end = SPORT1_TCR1 + 0xFF,
  172. .flags = IORESOURCE_MEM,
  173. },
  174. [1] = {
  175. .start = IRQ_SPORT1_ERROR,
  176. .end = IRQ_SPORT1_ERROR,
  177. .flags = IORESOURCE_IRQ,
  178. },
  179. };
  180. static struct platform_device bfin_sport_spi1_device = {
  181. .name = "bfin-sport-spi",
  182. .id = 2, /* Bus number */
  183. .num_resources = ARRAY_SIZE(bfin_sport_spi1_resource),
  184. .resource = bfin_sport_spi1_resource,
  185. .dev = {
  186. .platform_data = &bfin_sport_spi1_info, /* Passed to driver */
  187. },
  188. };
  189. #endif /* sport spi master and devices */
  190. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  191. static struct platform_device rtc_device = {
  192. .name = "rtc-bfin",
  193. .id = -1,
  194. };
  195. #endif
  196. #if defined(CONFIG_FB_HITACHI_TX09) || defined(CONFIG_FB_HITACHI_TX09_MODULE)
  197. static struct platform_device hitachi_fb_device = {
  198. .name = "hitachi-tx09",
  199. };
  200. #endif
  201. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  202. #include <linux/smc91x.h>
  203. static struct smc91x_platdata smc91x_info = {
  204. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
  205. .leda = RPC_LED_100_10,
  206. .ledb = RPC_LED_TX_RX,
  207. };
  208. static struct resource smc91x_resources[] = {
  209. {
  210. .start = 0x20200300,
  211. .end = 0x20200300 + 16,
  212. .flags = IORESOURCE_MEM,
  213. }, {
  214. .start = IRQ_PF14,
  215. .end = IRQ_PF14,
  216. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  217. },
  218. };
  219. static struct platform_device smc91x_device = {
  220. .name = "smc91x",
  221. .id = 0,
  222. .num_resources = ARRAY_SIZE(smc91x_resources),
  223. .resource = smc91x_resources,
  224. .dev = {
  225. .platform_data = &smc91x_info,
  226. },
  227. };
  228. #endif
  229. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  230. static struct resource isp1362_hcd_resources[] = {
  231. {
  232. .start = 0x20308000,
  233. .end = 0x20308000,
  234. .flags = IORESOURCE_MEM,
  235. }, {
  236. .start = 0x20308004,
  237. .end = 0x20308004,
  238. .flags = IORESOURCE_MEM,
  239. }, {
  240. .start = IRQ_PG15,
  241. .end = IRQ_PG15,
  242. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
  243. },
  244. };
  245. static struct isp1362_platform_data isp1362_priv = {
  246. .sel15Kres = 1,
  247. .clknotstop = 0,
  248. .oc_enable = 0,
  249. .int_act_high = 0,
  250. .int_edge_triggered = 0,
  251. .remote_wakeup_connected = 0,
  252. .no_power_switching = 1,
  253. .power_switching_mode = 0,
  254. };
  255. static struct platform_device isp1362_hcd_device = {
  256. .name = "isp1362-hcd",
  257. .id = 0,
  258. .dev = {
  259. .platform_data = &isp1362_priv,
  260. },
  261. .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
  262. .resource = isp1362_hcd_resources,
  263. };
  264. #endif
  265. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  266. static struct resource net2272_bfin_resources[] = {
  267. {
  268. .start = 0x20300000,
  269. .end = 0x20300000 + 0x100,
  270. .flags = IORESOURCE_MEM,
  271. }, {
  272. .start = IRQ_PG13,
  273. .end = IRQ_PG13,
  274. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  275. },
  276. };
  277. static struct platform_device net2272_bfin_device = {
  278. .name = "net2272",
  279. .id = -1,
  280. .num_resources = ARRAY_SIZE(net2272_bfin_resources),
  281. .resource = net2272_bfin_resources,
  282. };
  283. #endif
  284. #if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE)
  285. static struct mtd_partition cm_partitions[] = {
  286. {
  287. .name = "bootloader(nor)",
  288. .size = 0x40000,
  289. .offset = 0,
  290. }, {
  291. .name = "linux kernel(nor)",
  292. .size = 0x100000,
  293. .offset = MTDPART_OFS_APPEND,
  294. }, {
  295. .name = "file system(nor)",
  296. .size = MTDPART_SIZ_FULL,
  297. .offset = MTDPART_OFS_APPEND,
  298. }
  299. };
  300. static struct physmap_flash_data cm_flash_data = {
  301. .width = 2,
  302. .parts = cm_partitions,
  303. .nr_parts = ARRAY_SIZE(cm_partitions),
  304. };
  305. static unsigned cm_flash_gpios[] = { GPIO_PF4 };
  306. static struct resource cm_flash_resource[] = {
  307. {
  308. .name = "cfi_probe",
  309. .start = 0x20000000,
  310. .end = 0x201fffff,
  311. .flags = IORESOURCE_MEM,
  312. }, {
  313. .start = (unsigned long)cm_flash_gpios,
  314. .end = ARRAY_SIZE(cm_flash_gpios),
  315. .flags = IORESOURCE_IRQ,
  316. }
  317. };
  318. static struct platform_device cm_flash_device = {
  319. .name = "gpio-addr-flash",
  320. .id = 0,
  321. .dev = {
  322. .platform_data = &cm_flash_data,