hiddenDangerAnalysis.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. /*
  2. * Copyright 2004-20010 Analog Devices Inc.
  3. * 2005 National ICT Australia (NICTA)
  4. * Aidan Williams <aidan@nicta.com.au>
  5. *
  6. * Licensed under the GPL-2 or later.
  7. */
  8. #include <linux/device.h>
  9. #include <linux/export.h>
  10. #include <linux/platform_device.h>
  11. #include <linux/mtd/mtd.h>
  12. #include <linux/mtd/partitions.h>
  13. #include <linux/mtd/physmap.h>
  14. #include <linux/spi/spi.h>
  15. #include <linux/spi/flash.h>
  16. #include <linux/i2c.h>
  17. #include <linux/irq.h>
  18. #include <linux/interrupt.h>
  19. #include <linux/usb/musb.h>
  20. #include <linux/leds.h>
  21. #include <linux/input.h>
  22. #include <asm/dma.h>
  23. #include <asm/bfin5xx_spi.h>
  24. #include <asm/reboot.h>
  25. #include <asm/nand.h>
  26. #include <asm/portmux.h>
  27. #include <asm/dpmc.h>
  28. /*
  29. * Name the Board for the /proc/cpuinfo
  30. */
  31. const char bfin_board_name[] = "ADI BF527-AD7160EVAL";
  32. /*
  33. * Driver needs to know address, irq and flag pin.
  34. */
  35. #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
  36. static struct resource musb_resources[] = {
  37. [0] = {
  38. .start = 0xffc03800,
  39. .end = 0xffc03cff,
  40. .flags = IORESOURCE_MEM,
  41. },
  42. [1] = { /* general IRQ */
  43. .start = IRQ_USB_INT0,
  44. .end = IRQ_USB_INT0,
  45. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  46. },
  47. [2] = { /* DMA IRQ */
  48. .start = IRQ_USB_DMA,
  49. .end = IRQ_USB_DMA,
  50. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  51. },
  52. };
  53. static struct musb_hdrc_config musb_config = {
  54. .multipoint = 0,
  55. .dyn_fifo = 0,
  56. .soft_con = 1,
  57. .dma = 1,
  58. .num_eps = 8,
  59. .dma_channels = 8,
  60. .gpio_vrsel = GPIO_PG13,
  61. /* Some custom boards need to be active low, just set it to "0"
  62. * if it is the case.
  63. */
  64. .gpio_vrsel_active = 1,
  65. .clkin = 24, /* musb CLKIN in MHZ */
  66. };
  67. static struct musb_hdrc_platform_data musb_plat = {
  68. #if defined(CONFIG_USB_MUSB_OTG)
  69. .mode = MUSB_OTG,
  70. #elif defined(CONFIG_USB_MUSB_HDRC_HCD)
  71. .mode = MUSB_HOST,
  72. #elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
  73. .mode = MUSB_PERIPHERAL,
  74. #endif
  75. .config = &musb_config,
  76. };
  77. static u64 musb_dmamask = ~(u32)0;
  78. static struct platform_device musb_device = {
  79. .name = "musb-blackfin",
  80. .id = 0,
  81. .dev = {
  82. .dma_mask = &musb_dmamask,
  83. .coherent_dma_mask = 0xffffffff,
  84. .platform_data = &musb_plat,
  85. },
  86. .num_resources = ARRAY_SIZE(musb_resources),
  87. .resource = musb_resources,
  88. };
  89. #endif
  90. #if defined(CONFIG_FB_BFIN_RA158Z) || defined(CONFIG_FB_BFIN_RA158Z_MODULE)
  91. static struct resource bf52x_ra158z_resources[] = {
  92. {
  93. .start = IRQ_PPI_ERROR,
  94. .end = IRQ_PPI_ERROR,
  95. .flags = IORESOURCE_IRQ,
  96. },
  97. };
  98. static struct platform_device bf52x_ra158z_device = {
  99. .name = "bfin-ra158z",
  100. .id = -1,
  101. .num_resources = ARRAY_SIZE(bf52x_ra158z_resources),
  102. .resource = bf52x_ra158z_resources,
  103. };
  104. #endif
  105. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  106. static struct mtd_partition ad7160eval_partitions[] = {
  107. {
  108. .name = "bootloader(nor)",
  109. .size = 0x40000,
  110. .offset = 0,
  111. }, {
  112. .name = "linux kernel(nor)",
  113. .size = 0x1C0000,
  114. .offset = MTDPART_OFS_APPEND,
  115. }, {
  116. .name = "file system(nor)",
  117. .size = MTDPART_SIZ_FULL,
  118. .offset = MTDPART_OFS_APPEND,
  119. }
  120. };
  121. static struct physmap_flash_data ad7160eval_flash_data = {
  122. .width = 2,
  123. .parts = ad7160eval_partitions,
  124. .nr_parts = ARRAY_SIZE(ad7160eval_partitions),
  125. };
  126. static struct resource ad7160eval_flash_resource = {
  127. .start = 0x20000000,
  128. .end = 0x203fffff,
  129. .flags = IORESOURCE_MEM,
  130. };
  131. static struct platform_device ad7160eval_flash_device = {
  132. .name = "physmap-flash",
  133. .id = 0,
  134. .dev = {
  135. .platform_data = &ad7160eval_flash_data,
  136. },
  137. .num_resources = 1,
  138. .resource = &ad7160eval_flash_resource,
  139. };
  140. #endif
  141. #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
  142. static struct mtd_partition partition_info[] = {
  143. {
  144. .name = "linux kernel(nand)",
  145. .offset = 0,
  146. .size = 4 * 1024 * 1024,
  147. },
  148. {
  149. .name = "file system(nand)",
  150. .offset = MTDPART_OFS_APPEND,
  151. .size = MTDPART_SIZ_FULL,
  152. },
  153. };
  154. static struct bf5xx_nand_platform bf5xx_nand_platform = {
  155. .data_width = NFC_NWIDTH_8,
  156. .partitions = partition_info,
  157. .nr_partitions = ARRAY_SIZE(partition_info),
  158. .rd_dly = 3,
  159. .wr_dly = 3,
  160. };
  161. static struct resource bf5xx_nand_resources[] = {
  162. {
  163. .start = NFC_CTL,
  164. .end = NFC_DATA_RD + 2,
  165. .flags = IORESOURCE_MEM,
  166. },
  167. {
  168. .start = CH_NFC,
  169. .end = CH_NFC,
  170. .flags = IORESOURCE_IRQ,
  171. },
  172. };
  173. static struct platform_device bf5xx_nand_device = {
  174. .name = "bf5xx-nand",
  175. .id = 0,
  176. .num_resources = ARRAY_SIZE(bf5xx_nand_resources),
  177. .resource = bf5xx_nand_resources,
  178. .dev = {
  179. .platform_data = &bf5xx_nand_platform,
  180. },
  181. };
  182. #endif
  183. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  184. static struct platform_device rtc_device = {
  185. .name = "rtc-bfin",
  186. .id = -1,
  187. };
  188. #endif
  189. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  190. #include <linux/bfin_mac.h>
  191. static const unsigned short bfin_mac_peripherals[] = P_RMII0;
  192. static struct bfin_phydev_platform_data bfin_phydev_data[] = {
  193. {
  194. .addr = 1,
  195. .irq = IRQ_MAC_PHYINT,
  196. },
  197. };
  198. static struct bfin_mii_bus_platform_data bfin_mii_bus_data = {
  199. .phydev_number = 1,
  200. .phydev_data = bfin_phydev_data,
  201. .phy_mode = PHY_INTERFACE_MODE_RMII,
  202. .mac_peripherals = bfin_mac_peripherals,
  203. };
  204. static struct platform_device bfin_mii_bus = {
  205. .name = "bfin_mii_bus",
  206. .dev = {
  207. .platform_data = &bfin_mii_bus_data,
  208. }
  209. };
  210. static struct platform_device bfin_mac_device = {
  211. .name = "bfin_mac",
  212. .dev = {
  213. .platform_data = &bfin_mii_bus,
  214. }
  215. };
  216. #endif
  217. #if defined(CONFIG_MTD_M25P80) \
  218. || defined(CONFIG_MTD_M25P80_MODULE)
  219. static struct mtd_partition bfin_spi_flash_partitions[] = {
  220. {
  221. .name = "bootloader(spi)",
  222. .size = 0x00040000,
  223. .offset = 0,
  224. .mask_flags = MTD_CAP_ROM
  225. }, {
  226. .name = "linux kernel(spi)",
  227. .size = MTDPART_SIZ_FULL,
  228. .offset = MTDPART_OFS_APPEND,
  229. }
  230. };
  231. static struct flash_platform_data bfin_spi_flash_data = {
  232. .name = "m25p80",
  233. .parts = bfin_spi_flash_partitions,
  234. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  235. .type = "m25p16",
  236. };
  237. /* SPI flash chip (m25p64) */
  238. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  239. .enable_dma = 0, /* use dma transfer with this chip*/
  240. };
  241. #endif
  242. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  243. static struct bfin5xx_spi_chip mmc_spi_chip_info = {
  244. .enable_dma = 0,
  245. };
  246. #endif
  247. #if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
  248. static struct platform_device bfin_i2s = {
  249. .name = "bfin-i2s",
  250. .id = CONFIG_SND_BF5XX_SPORT_NUM,
  251. /* TODO: add platform data here */
  252. };
  253. #endif
  254. #if defined(CONFIG_SND_BF5XX_TDM) || defined(CONFIG_SND_BF5XX_TDM_MODULE)
  255. static struct platform_device bfin_tdm = {
  256. .name = "bfin-tdm",
  257. .id = CONFIG_SND_BF5XX_SPORT_NUM,
  258. /* TODO: add platform data here */
  259. };
  260. #endif
  261. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  262. #if defined(CONFIG_MTD_M25P80) \
  263. || defined(CONFIG_MTD_M25P80_MODULE)
  264. {
  265. /* the modalias must be the same as spi device driver name */
  266. .modalias = "m25p80", /* Name of spi_driver for this device */
  267. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  268. .bus_num = 0, /* Framework bus number */
  269. .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
  270. .platform_data = &bfin_spi_flash_data,
  271. .controller_data = &spi_flash_chip_info,
  272. .mode = SPI_MODE_3,
  273. },
  274. #endif
  275. #if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
  276. || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
  277. {
  278. .modalias = "ad183x",
  279. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  280. .bus_num = 0,
  281. .chip_select = 4,
  282. },
  283. #endif
  284. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  285. {
  286. .modalias = "mmc_spi",
  287. .max_speed_hz = 30000000, /* max spi clock (SCK) speed in HZ */
  288. .bus_num = 0,
  289. .chip_select = GPIO_PH3 + MAX_CTRL_CS,
  290. .controller_data = &mmc_spi_chip_info,
  291. .mode = SPI_MODE_3,
  292. },
  293. #endif
  294. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  295. {
  296. .modalias = "spidev",
  297. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  298. .bus_num = 0,
  299. .chip_select = 1,
  300. },
  301. #endif
  302. };
  303. #if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE)
  304. /* SPI controller data */
  305. static struct bfin5xx_spi_master bfin_spi0_info = {
  306. .num_chipselect = MAX_CTRL_CS + MAX_BLACKFIN_GPIOS,
  307. .enable_dma = 1, /* master has the ability to do dma transfer */
  308. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  309. };
  310. /* SPI (0) */
  311. static struct resource bfin_spi0_resource[] = {
  312. [0] = {
  313. .start = SPI0_REGBASE,
  314. .end = SPI0_REGBASE + 0xFF,
  315. .flags = IORESOURCE_MEM,
  316. },
  317. [1] = {
  318. .start = CH_SPI,
  319. .end = CH_SPI,
  320. .flags = IORESOURCE_DMA,
  321. },
  322. [2] = {
  323. .start = IRQ_SPI,
  324. .end = IRQ_SPI,
  325. .flags = IORESOURCE_IRQ,
  326. },
  327. };
  328. static struct platform_device bfin_spi0_device = {
  329. .name = "bfin-spi",
  330. .id = 0, /* Bus number */
  331. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  332. .resource = bfin_spi0_resource,
  333. .dev = {
  334. .platform_data = &bfin_spi0_info, /* Passed to driver */
  335. },
  336. };
  337. #endif /* spi master and devices */
  338. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  339. #ifdef CONFIG_SERIAL_BFIN_UART0
  340. static struct resource bfin_uart0_resources[] = {
  341. {
  342. .start = UART0_THR,
  343. .end = UART0_GCTL+2,
  344. .flags = IORESOURCE_MEM,
  345. },
  346. {
  347. .start = IRQ_UART0_TX,
  348. .end = IRQ_UART0_TX,
  349. .flags = IORESOURCE_IRQ,
  350. },
  351. {
  352. .start = IRQ_UART0_RX,
  353. .end = IRQ_UART0_RX,
  354. .flags = IORESOURCE_IRQ,
  355. },
  356. {
  357. .start = IRQ_UART0_ERROR,
  358. .end = IRQ_UART0_ERROR,
  359. .flags = IORESOURCE_IRQ,
  360. },
  361. {
  362. .start = CH_UART0_TX,
  363. .end = CH_UART0_TX,
  364. .flags = IORESOURCE_DMA,
  365. },
  366. {
  367. .start = CH_UART0_RX,
  368. .end = CH_UART0_RX,
  369. .flags = IORESOURCE_DMA,
  370. },
  371. };
  372. static unsigned short bfin_uart0_peripherals[] = {
  373. P_UART0_TX, P_UART0_RX, 0
  374. };
  375. static struct platform_device bfin_uart0_device = {
  376. .name = "bfin-uart",
  377. .id = 0,
  378. .num_resources = ARRAY_SIZE(bfin_uart0_resources),
  379. .resource = bfin_uart0_resources,
  380. .dev = {
  381. .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
  382. },
  383. };
  384. #endif
  385. #ifdef CONFIG_SERIAL_BFIN_UART1
  386. static struct resource bfin_uart1_resources[] = {
  387. {
  388. .start = UART1_THR,
  389. .end = UART1_GCTL+2,
  390. .flags = IORESOURCE_MEM,
  391. },
  392. {
  393. .start = IRQ_UART1_TX,
  394. .end = IRQ_UART1_TX,
  395. .flags = IORESOURCE_IRQ,
  396. },
  397. {
  398. .start = IRQ_UART1_RX,
  399. .end = IRQ_UART1_RX,
  400. .flags = IORESOURCE_IRQ,
  401. },
  402. {
  403. .start = IRQ_UART1_ERROR,
  404. .end = IRQ_UART1_ERROR,
  405. .flags = IORESOURCE_IRQ,
  406. },
  407. {
  408. .start = CH_UART1_TX,
  409. .end = CH_UART1_TX,
  410. .flags = IORESOURCE_DMA,
  411. },
  412. {
  413. .start = CH_UART1_RX,
  414. .end = CH_UART1_RX,
  415. .flags = IORESOURCE_DMA,
  416. },
  417. #ifdef CONFIG_BFIN_UART1_CTSRTS
  418. { /* CTS pin */
  419. .start = GPIO_PF9,
  420. .end = GPIO_PF9,
  421. .flags = IORESOURCE_IO,
  422. },
  423. { /* RTS pin */
  424. .start = GPIO_PF10,
  425. .end = GPIO_PF10,
  426. .flags = IORESOURCE_IO,
  427. },
  428. #endif
  429. };
  430. static unsigned short bfin_uart1_peripherals[] = {
  431. P_UART1_TX, P_UART1_RX, 0
  432. };