ad7160eval.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863
  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. };
  433. static struct platform_device bfin_uart1_device = {
  434. .name = "bfin-uart",
  435. .id = 1,
  436. .num_resources = ARRAY_SIZE(bfin_uart1_resources),
  437. .resource = bfin_uart1_resources,
  438. .dev = {
  439. .platform_data = &bfin_uart1_peripherals, /* Passed to driver */
  440. },
  441. };
  442. #endif
  443. #endif
  444. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  445. #ifdef CONFIG_BFIN_SIR0
  446. static struct resource bfin_sir0_resources[] = {
  447. {
  448. .start = 0xFFC00400,
  449. .end = 0xFFC004FF,
  450. .flags = IORESOURCE_MEM,
  451. },
  452. {
  453. .start = IRQ_UART0_RX,
  454. .end = IRQ_UART0_RX+1,
  455. .flags = IORESOURCE_IRQ,
  456. },
  457. {
  458. .start = CH_UART0_RX,
  459. .end = CH_UART0_RX+1,
  460. .flags = IORESOURCE_DMA,
  461. },
  462. };
  463. static struct platform_device bfin_sir0_device = {
  464. .name = "bfin_sir",
  465. .id = 0,
  466. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  467. .resource = bfin_sir0_resources,
  468. };
  469. #endif
  470. #ifdef CONFIG_BFIN_SIR1
  471. static struct resource bfin_sir1_resources[] = {
  472. {
  473. .start = 0xFFC02000,
  474. .end = 0xFFC020FF,
  475. .flags = IORESOURCE_MEM,
  476. },
  477. {
  478. .start = IRQ_UART1_RX,
  479. .end = IRQ_UART1_RX+1,
  480. .flags = IORESOURCE_IRQ,
  481. },
  482. {
  483. .start = CH_UART1_RX,
  484. .end = CH_UART1_RX+1,
  485. .flags = IORESOURCE_DMA,
  486. },
  487. };
  488. static struct platform_device bfin_sir1_device = {
  489. .name = "bfin_sir",
  490. .id = 1,
  491. .num_resources = ARRAY_SIZE(bfin_sir1_resources),
  492. .resource = bfin_sir1_resources,
  493. };
  494. #endif
  495. #endif
  496. #if defined(CONFIG_TOUCHSCREEN_AD7160) || defined(CONFIG_TOUCHSCREEN_AD7160_MODULE)
  497. #include <linux/input/ad7160.h>
  498. static const struct ad7160_platform_data bfin_ad7160_ts_info = {
  499. .sensor_x_res = 854,
  500. .sensor_y_res = 480,
  501. .pressure = 100,
  502. .filter_coef = 3,
  503. .coord_pref = AD7160_ORIG_TOP_LEFT,
  504. .first_touch_window = 5,
  505. .move_window = 3,
  506. .event_cabs = AD7160_EMIT_ABS_MT_TRACKING_ID |
  507. AD7160_EMIT_ABS_MT_PRESSURE |
  508. AD7160_TRACKING_ID_ASCENDING,
  509. .finger_act_ctrl = 0x64,
  510. .haptic_effect1_ctrl = AD7160_HAPTIC_SLOT_A(60) |
  511. AD7160_HAPTIC_SLOT_A_LVL_HIGH |
  512. AD7160_HAPTIC_SLOT_B(60) |
  513. AD7160_HAPTIC_SLOT_B_LVL_LOW,
  514. .haptic_effect2_ctrl = AD7160_HAPTIC_SLOT_A(20) |
  515. AD7160_HAPTIC_SLOT_A_LVL_HIGH |
  516. AD7160_HAPTIC_SLOT_B(80) |
  517. AD7160_HAPTIC_SLOT_B_LVL_LOW |
  518. AD7160_HAPTIC_SLOT_C(120) |
  519. AD7160_HAPTIC_SLOT_C_LVL_HIGH |
  520. AD7160_HAPTIC_SLOT_D(30) |
  521. AD7160_HAPTIC_SLOT_D_LVL_LOW,
  522. };
  523. #endif
  524. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  525. static struct resource bfin_twi0_resource[] = {
  526. [0] = {
  527. .start = TWI0_REGBASE,
  528. .end = TWI0_REGBASE,
  529. .flags = IORESOURCE_MEM,
  530. },
  531. [1] = {
  532. .start = IRQ_TWI,
  533. .end = IRQ_TWI,
  534. .flags = IORESOURCE_IRQ,
  535. },
  536. };
  537. static struct platform_device i2c_bfin_twi_device = {
  538. .name = "i2c-bfin-twi",
  539. .id = 0,
  540. .num_resources = ARRAY_SIZE(bfin_twi0_resource),
  541. .resource = bfin_twi0_resource,
  542. };
  543. #endif
  544. static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
  545. #if defined(CONFIG_TOUCHSCREEN_AD7160) || defined(CONFIG_TOUCHSCREEN_AD7160_MODULE)
  546. {
  547. I2C_BOARD_INFO("ad7160", 0x33),
  548. .irq = IRQ_PH1,
  549. .platform_data = (void *)&bfin_ad7160_ts_info,
  550. },
  551. #endif
  552. };
  553. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  554. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  555. static struct resource bfin_sport0_uart_resources[] = {
  556. {
  557. .start = SPORT0_TCR1,
  558. .end = SPORT0_MRCS3+4,
  559. .flags = IORESOURCE_MEM,
  560. },
  561. {
  562. .start = IRQ_SPORT0_RX,
  563. .end = IRQ_SPORT0_RX+1,
  564. .flags = IORESOURCE_IRQ,
  565. },
  566. {
  567. .start = IRQ_SPORT0_ERROR,
  568. .end = IRQ_SPORT0_ERROR,
  569. .flags = IORESOURCE_IRQ,
  570. },
  571. };
  572. static unsigned short bfin_sport0_peripherals[] = {
  573. P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
  574. P_SPORT0_DRPRI, P_SPORT0_RSCLK, 0
  575. };
  576. static struct platform_device bfin_sport0_uart_device = {
  577. .name = "bfin-sport-uart",
  578. .id = 0,
  579. .num_resources = ARRAY_SIZE(bfin_sport0_uart_resources),
  580. .resource = bfin_sport0_uart_resources,
  581. .dev = {
  582. .platform_data = &bfin_sport0_peripherals, /* Passed to driver */
  583. },
  584. };
  585. #endif
  586. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  587. static struct resource bfin_sport1_uart_resources[] = {
  588. {
  589. .start = SPORT1_TCR1,
  590. .end = SPORT1_MRCS3+4,
  591. .flags = IORESOURCE_MEM,
  592. },
  593. {
  594. .start = IRQ_SPORT1_RX,
  595. .end = IRQ_SPORT1_RX+1,
  596. .flags = IORESOURCE_IRQ,
  597. },
  598. {
  599. .start = IRQ_SPORT1_ERROR,
  600. .end = IRQ_SPORT1_ERROR,
  601. .flags = IORESOURCE_IRQ,
  602. },
  603. };
  604. static unsigned short bfin_sport1_peripherals[] = {
  605. P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
  606. P_SPORT1_DRPRI, P_SPORT1_RSCLK, 0
  607. };
  608. static struct platform_device bfin_sport1_uart_device = {
  609. .name = "bfin-sport-uart",
  610. .id = 1,
  611. .num_resources = ARRAY_SIZE(bfin_sport1_uart_resources),
  612. .resource = bfin_sport1_uart_resources,
  613. .dev = {
  614. .platform_data = &bfin_sport1_peripherals, /* Passed to driver */
  615. },
  616. };
  617. #endif
  618. #endif
  619. #if defined(CONFIG_INPUT_BFIN_ROTARY) || defined(CONFIG_INPUT_BFIN_ROTARY_MODULE)
  620. #include <asm/bfin_rotary.h>
  621. static struct bfin_rotary_platform_data bfin_rotary_data = {
  622. /*.rotary_up_key = KEY_UP,*/
  623. /*.rotary_down_key = KEY_DOWN,*/
  624. .rotary_rel_code = REL_WHEEL,
  625. .rotary_button_key = KEY_ENTER,
  626. .debounce = 10, /* 0..17 */
  627. .mode = ROT_QUAD_ENC | ROT_DEBE,
  628. };
  629. static struct resource bfin_rotary_resources[] = {
  630. {
  631. .start = IRQ_CNT,
  632. .end = IRQ_CNT,
  633. .flags = IORESOURCE_IRQ,
  634. },
  635. };
  636. static struct platform_device bfin_rotary_device = {
  637. .name = "bfin-rotary",
  638. .id = -1,
  639. .num_resources = ARRAY_SIZE(bfin_rotary_resources),
  640. .resource = bfin_rotary_resources,
  641. .dev = {
  642. .platform_data = &bfin_rotary_data,
  643. },
  644. };
  645. #endif
  646. static const unsigned int cclk_vlev_datasheet[] = {
  647. VRPAIR(VLEV_100, 400000000),
  648. VRPAIR(VLEV_105, 426000000),
  649. VRPAIR(VLEV_110, 500000000),
  650. VRPAIR(VLEV_115, 533000000),
  651. VRPAIR(VLEV_120, 600000000),
  652. };
  653. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  654. .tuple_tab = cclk_vlev_datasheet,
  655. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  656. .vr_settling_time = 25 /* us */,
  657. };
  658. static struct platform_device bfin_dpmc = {
  659. .name = "bfin dpmc",
  660. .dev = {
  661. .platform_data = &bfin_dmpc_vreg_data,
  662. },
  663. };
  664. static struct platform_device *stamp_devices[] __initdata = {
  665. &bfin_dpmc,
  666. #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
  667. &bf5xx_nand_device,
  668. #endif
  669. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  670. &rtc_device,
  671. #endif
  672. #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
  673. &musb_device,
  674. #endif
  675. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  676. &bfin_mii_bus,
  677. &bfin_mac_device,
  678. #endif
  679. #if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE)
  680. &bfin_spi0_device,
  681. #endif
  682. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  683. #ifdef CONFIG_SERIAL_BFIN_UART0
  684. &bfin_uart0_device,
  685. #endif
  686. #ifdef CONFIG_SERIAL_BFIN_UART1
  687. &bfin_uart1_device,
  688. #endif
  689. #endif
  690. #if defined(CONFIG_FB_BFIN_RA158Z) || defined(CONFIG_FB_BFIN_RA158Z_MODULE)
  691. &bf52x_ra158z_device,
  692. #endif
  693. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  694. #ifdef CONFIG_BFIN_SIR0
  695. &bfin_sir0_device,
  696. #endif
  697. #ifdef CONFIG_BFIN_SIR1
  698. &bfin_sir1_device,
  699. #endif
  700. #endif
  701. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  702. &i2c_bfin_twi_device,
  703. #endif
  704. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  705. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  706. &bfin_sport0_uart_device,
  707. #endif
  708. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  709. &bfin_sport1_uart_device,
  710. #endif
  711. #endif
  712. #if defined(CONFIG_INPUT_BFIN_ROTARY) || defined(CONFIG_INPUT_BFIN_ROTARY_MODULE)
  713. &bfin_rotary_device,
  714. #endif
  715. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  716. &ad7160eval_flash_device,
  717. #endif
  718. #if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
  719. &bfin_i2s,
  720. #endif
  721. #if defined(CONFIG_SND_BF5XX_TDM) || defined(CONFIG_SND_BF5XX_TDM_MODULE)
  722. &bfin_tdm,
  723. #endif
  724. };
  725. static int __init ad7160eval_init(void)
  726. {
  727. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  728. i2c_register_board_info(0, bfin_i2c_board_info,
  729. ARRAY_SIZE(bfin_i2c_board_info));
  730. platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
  731. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  732. return 0;
  733. }
  734. arch_initcall(ad7160eval_init);
  735. static struct platform_device *ad7160eval_early_devices[] __initdata = {
  736. #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
  737. #ifdef CONFIG_SERIAL_BFIN_UART0
  738. &bfin_uart0_device,
  739. #endif
  740. #ifdef CONFIG_SERIAL_BFIN_UART1
  741. &bfin_uart1_device,
  742. #endif
  743. #endif
  744. #if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
  745. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  746. &bfin_sport0_uart_device,
  747. #endif
  748. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  749. &bfin_sport1_uart_device,
  750. #endif
  751. #endif
  752. };
  753. void __init native_machine_early_platform_add_devices(void)
  754. {
  755. printk(KERN_INFO "register early platform devices\n");
  756. early_platform_add_devices(ad7160eval_early_devices,
  757. ARRAY_SIZE(ad7160eval_early_devices));
  758. }
  759. void native_machine_restart(char *cmd)
  760. {
  761. /* workaround reboot hang when booting from SPI */
  762. if ((bfin_read_SYSCR() & 0x7) == 0x3)
  763. bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
  764. }
  765. void bfin_get_ether_addr(char *addr)
  766. {
  767. /* the MAC is stored in OTP memory page 0xDF */
  768. u32 ret;
  769. u64 otp_mac;
  770. u32 (*otp_read)(u32 page, u32 flags, u64 *page_content) = (void *)0xEF00001A;
  771. ret = otp_read(0xDF, 0x00, &otp_mac);
  772. if (!(ret & 0x1)) {
  773. char *otp_mac_p = (char *)&otp_mac;
  774. for (ret = 0; ret < 6; ++ret)
  775. addr[ret] = otp_mac_p[5 - ret];
  776. }
  777. }
  778. EXPORT_SYMBOL(bfin_get_ether_addr);