ad7160eval.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858
  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. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  255. #if defined(CONFIG_MTD_M25P80) \
  256. || defined(CONFIG_MTD_M25P80_MODULE)
  257. {
  258. /* the modalias must be the same as spi device driver name */
  259. .modalias = "m25p80", /* Name of spi_driver for this device */
  260. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  261. .bus_num = 0, /* Framework bus number */
  262. .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
  263. .platform_data = &bfin_spi_flash_data,
  264. .controller_data = &spi_flash_chip_info,
  265. .mode = SPI_MODE_3,
  266. },
  267. #endif
  268. #if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
  269. || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
  270. {
  271. .modalias = "ad183x",
  272. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  273. .bus_num = 0,
  274. .chip_select = 4,
  275. },
  276. #endif
  277. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  278. {
  279. .modalias = "mmc_spi",
  280. .max_speed_hz = 30000000, /* max spi clock (SCK) speed in HZ */
  281. .bus_num = 0,
  282. .chip_select = GPIO_PH3 + MAX_CTRL_CS,
  283. .controller_data = &mmc_spi_chip_info,
  284. .mode = SPI_MODE_3,
  285. },
  286. #endif
  287. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  288. {
  289. .modalias = "spidev",
  290. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  291. .bus_num = 0,
  292. .chip_select = 1,
  293. },
  294. #endif
  295. };
  296. #if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE)
  297. /* SPI controller data */
  298. static struct bfin5xx_spi_master bfin_spi0_info = {
  299. .num_chipselect = MAX_CTRL_CS + MAX_BLACKFIN_GPIOS,
  300. .enable_dma = 1, /* master has the ability to do dma transfer */
  301. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  302. };
  303. /* SPI (0) */
  304. static struct resource bfin_spi0_resource[] = {
  305. [0] = {
  306. .start = SPI0_REGBASE,
  307. .end = SPI0_REGBASE + 0xFF,
  308. .flags = IORESOURCE_MEM,
  309. },
  310. [1] = {
  311. .start = CH_SPI,
  312. .end = CH_SPI,
  313. .flags = IORESOURCE_DMA,
  314. },
  315. [2] = {
  316. .start = IRQ_SPI,
  317. .end = IRQ_SPI,
  318. .flags = IORESOURCE_IRQ,
  319. },
  320. };
  321. static struct platform_device bfin_spi0_device = {
  322. .name = "bfin-spi",
  323. .id = 0, /* Bus number */
  324. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  325. .resource = bfin_spi0_resource,
  326. .dev = {
  327. .platform_data = &bfin_spi0_info, /* Passed to driver */
  328. },
  329. };
  330. #endif /* spi master and devices */
  331. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  332. #ifdef CONFIG_SERIAL_BFIN_UART0
  333. static struct resource bfin_uart0_resources[] = {
  334. {
  335. .start = UART0_THR,
  336. .end = UART0_GCTL+2,
  337. .flags = IORESOURCE_MEM,
  338. },
  339. {
  340. .start = IRQ_UART0_TX,
  341. .end = IRQ_UART0_TX,
  342. .flags = IORESOURCE_IRQ,
  343. },
  344. {
  345. .start = IRQ_UART0_RX,
  346. .end = IRQ_UART0_RX,
  347. .flags = IORESOURCE_IRQ,
  348. },
  349. {
  350. .start = IRQ_UART0_ERROR,
  351. .end = IRQ_UART0_ERROR,
  352. .flags = IORESOURCE_IRQ,
  353. },
  354. {
  355. .start = CH_UART0_TX,
  356. .end = CH_UART0_TX,
  357. .flags = IORESOURCE_DMA,
  358. },
  359. {
  360. .start = CH_UART0_RX,
  361. .end = CH_UART0_RX,
  362. .flags = IORESOURCE_DMA,
  363. },
  364. };
  365. static unsigned short bfin_uart0_peripherals[] = {
  366. P_UART0_TX, P_UART0_RX, 0
  367. };
  368. static struct platform_device bfin_uart0_device = {
  369. .name = "bfin-uart",
  370. .id = 0,
  371. .num_resources = ARRAY_SIZE(bfin_uart0_resources),
  372. .resource = bfin_uart0_resources,
  373. .dev = {
  374. .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
  375. },
  376. };
  377. #endif
  378. #ifdef CONFIG_SERIAL_BFIN_UART1
  379. static struct resource bfin_uart1_resources[] = {
  380. {
  381. .start = UART1_THR,
  382. .end = UART1_GCTL+2,
  383. .flags = IORESOURCE_MEM,
  384. },
  385. {
  386. .start = IRQ_UART1_TX,
  387. .end = IRQ_UART1_TX,
  388. .flags = IORESOURCE_IRQ,
  389. },
  390. {
  391. .start = IRQ_UART1_RX,
  392. .end = IRQ_UART1_RX,
  393. .flags = IORESOURCE_IRQ,
  394. },
  395. {
  396. .start = IRQ_UART1_ERROR,
  397. .end = IRQ_UART1_ERROR,
  398. .flags = IORESOURCE_IRQ,
  399. },
  400. {
  401. .start = CH_UART1_TX,
  402. .end = CH_UART1_TX,
  403. .flags = IORESOURCE_DMA,
  404. },
  405. {
  406. .start = CH_UART1_RX,
  407. .end = CH_UART1_RX,
  408. .flags = IORESOURCE_DMA,
  409. },
  410. #ifdef CONFIG_BFIN_UART1_CTSRTS
  411. { /* CTS pin */
  412. .start = GPIO_PF9,
  413. .end = GPIO_PF9,
  414. .flags = IORESOURCE_IO,
  415. },
  416. { /* RTS pin */
  417. .start = GPIO_PF10,
  418. .end = GPIO_PF10,
  419. .flags = IORESOURCE_IO,
  420. },
  421. #endif
  422. };
  423. static unsigned short bfin_uart1_peripherals[] = {
  424. P_UART1_TX, P_UART1_RX, 0
  425. };
  426. static struct platform_device bfin_uart1_device = {
  427. .name = "bfin-uart",
  428. .id = 1,
  429. .num_resources = ARRAY_SIZE(bfin_uart1_resources),
  430. .resource = bfin_uart1_resources,
  431. .dev = {
  432. .platform_data = &bfin_uart1_peripherals, /* Passed to driver */
  433. },
  434. };
  435. #endif
  436. #endif
  437. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  438. #ifdef CONFIG_BFIN_SIR0
  439. static struct resource bfin_sir0_resources[] = {
  440. {
  441. .start = 0xFFC00400,
  442. .end = 0xFFC004FF,
  443. .flags = IORESOURCE_MEM,
  444. },
  445. {
  446. .start = IRQ_UART0_RX,
  447. .end = IRQ_UART0_RX+1,
  448. .flags = IORESOURCE_IRQ,
  449. },
  450. {
  451. .start = CH_UART0_RX,
  452. .end = CH_UART0_RX+1,
  453. .flags = IORESOURCE_DMA,
  454. },
  455. };
  456. static struct platform_device bfin_sir0_device = {
  457. .name = "bfin_sir",
  458. .id = 0,
  459. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  460. .resource = bfin_sir0_resources,
  461. };
  462. #endif
  463. #ifdef CONFIG_BFIN_SIR1
  464. static struct resource bfin_sir1_resources[] = {
  465. {
  466. .start = 0xFFC02000,
  467. .end = 0xFFC020FF,
  468. .flags = IORESOURCE_MEM,
  469. },
  470. {
  471. .start = IRQ_UART1_RX,
  472. .end = IRQ_UART1_RX+1,
  473. .flags = IORESOURCE_IRQ,
  474. },
  475. {
  476. .start = CH_UART1_RX,
  477. .end = CH_UART1_RX+1,
  478. .flags = IORESOURCE_DMA,
  479. },
  480. };
  481. static struct platform_device bfin_sir1_device = {
  482. .name = "bfin_sir",
  483. .id = 1,
  484. .num_resources = ARRAY_SIZE(bfin_sir1_resources),
  485. .resource = bfin_sir1_resources,
  486. };
  487. #endif
  488. #endif
  489. #if defined(CONFIG_TOUCHSCREEN_AD7160) || defined(CONFIG_TOUCHSCREEN_AD7160_MODULE)
  490. #include <linux/input/ad7160.h>
  491. static const struct ad7160_platform_data bfin_ad7160_ts_info = {
  492. .sensor_x_res = 854,
  493. .sensor_y_res = 480,
  494. .pressure = 100,
  495. .filter_coef = 3,
  496. .coord_pref = AD7160_ORIG_TOP_LEFT,
  497. .first_touch_window = 5,
  498. .move_window = 3,
  499. .event_cabs = AD7160_EMIT_ABS_MT_TRACKING_ID |
  500. AD7160_EMIT_ABS_MT_PRESSURE |
  501. AD7160_TRACKING_ID_ASCENDING,
  502. .finger_act_ctrl = 0x64,
  503. .haptic_effect1_ctrl = AD7160_HAPTIC_SLOT_A(60) |
  504. AD7160_HAPTIC_SLOT_A_LVL_HIGH |
  505. AD7160_HAPTIC_SLOT_B(60) |
  506. AD7160_HAPTIC_SLOT_B_LVL_LOW,
  507. .haptic_effect2_ctrl = AD7160_HAPTIC_SLOT_A(20) |
  508. AD7160_HAPTIC_SLOT_A_LVL_HIGH |
  509. AD7160_HAPTIC_SLOT_B(80) |
  510. AD7160_HAPTIC_SLOT_B_LVL_LOW |
  511. AD7160_HAPTIC_SLOT_C(120) |
  512. AD7160_HAPTIC_SLOT_C_LVL_HIGH |
  513. AD7160_HAPTIC_SLOT_D(30) |
  514. AD7160_HAPTIC_SLOT_D_LVL_LOW,
  515. };
  516. #endif
  517. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  518. static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0};
  519. static struct resource bfin_twi0_resource[] = {
  520. [0] = {
  521. .start = TWI0_REGBASE,
  522. .end = TWI0_REGBASE,
  523. .flags = IORESOURCE_MEM,
  524. },
  525. [1] = {
  526. .start = IRQ_TWI,
  527. .end = IRQ_TWI,
  528. .flags = IORESOURCE_IRQ,
  529. },
  530. };
  531. static struct platform_device i2c_bfin_twi_device = {
  532. .name = "i2c-bfin-twi",
  533. .id = 0,
  534. .num_resources = ARRAY_SIZE(bfin_twi0_resource),
  535. .resource = bfin_twi0_resource,
  536. .dev = {
  537. .platform_data = &bfin_twi0_pins,
  538. },
  539. };
  540. #endif
  541. static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
  542. #if defined(CONFIG_TOUCHSCREEN_AD7160) || defined(CONFIG_TOUCHSCREEN_AD7160_MODULE)
  543. {
  544. I2C_BOARD_INFO("ad7160", 0x33),
  545. .irq = IRQ_PH1,
  546. .platform_data = (void *)&bfin_ad7160_ts_info,
  547. },
  548. #endif
  549. };
  550. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  551. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  552. static struct resource bfin_sport0_uart_resources[] = {
  553. {
  554. .start = SPORT0_TCR1,
  555. .end = SPORT0_MRCS3+4,
  556. .flags = IORESOURCE_MEM,
  557. },
  558. {
  559. .start = IRQ_SPORT0_RX,
  560. .end = IRQ_SPORT0_RX+1,
  561. .flags = IORESOURCE_IRQ,
  562. },
  563. {
  564. .start = IRQ_SPORT0_ERROR,
  565. .end = IRQ_SPORT0_ERROR,
  566. .flags = IORESOURCE_IRQ,
  567. },
  568. };
  569. static unsigned short bfin_sport0_peripherals[] = {
  570. P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
  571. P_SPORT0_DRPRI, P_SPORT0_RSCLK, 0
  572. };
  573. static struct platform_device bfin_sport0_uart_device = {
  574. .name = "bfin-sport-uart",
  575. .id = 0,
  576. .num_resources = ARRAY_SIZE(bfin_sport0_uart_resources),
  577. .resource = bfin_sport0_uart_resources,
  578. .dev = {
  579. .platform_data = &bfin_sport0_peripherals, /* Passed to driver */
  580. },
  581. };
  582. #endif
  583. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  584. static struct resource bfin_sport1_uart_resources[] = {
  585. {
  586. .start = SPORT1_TCR1,
  587. .end = SPORT1_MRCS3+4,
  588. .flags = IORESOURCE_MEM,
  589. },
  590. {
  591. .start = IRQ_SPORT1_RX,
  592. .end = IRQ_SPORT1_RX+1,
  593. .flags = IORESOURCE_IRQ,
  594. },
  595. {
  596. .start = IRQ_SPORT1_ERROR,
  597. .end = IRQ_SPORT1_ERROR,
  598. .flags = IORESOURCE_IRQ,
  599. },
  600. };
  601. static unsigned short bfin_sport1_peripherals[] = {
  602. P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
  603. P_SPORT1_DRPRI, P_SPORT1_RSCLK, 0
  604. };
  605. static struct platform_device bfin_sport1_uart_device = {
  606. .name = "bfin-sport-uart",
  607. .id = 1,
  608. .num_resources = ARRAY_SIZE(bfin_sport1_uart_resources),
  609. .resource = bfin_sport1_uart_resources,
  610. .dev = {
  611. .platform_data = &bfin_sport1_peripherals, /* Passed to driver */
  612. },
  613. };
  614. #endif
  615. #endif
  616. #if defined(CONFIG_INPUT_BFIN_ROTARY) || defined(CONFIG_INPUT_BFIN_ROTARY_MODULE)
  617. #include <asm/bfin_rotary.h>
  618. static struct bfin_rotary_platform_data bfin_rotary_data = {
  619. /*.rotary_up_key = KEY_UP,*/
  620. /*.rotary_down_key = KEY_DOWN,*/
  621. .rotary_rel_code = REL_WHEEL,
  622. .rotary_button_key = KEY_ENTER,
  623. .debounce = 10, /* 0..17 */
  624. .mode = ROT_QUAD_ENC | ROT_DEBE,
  625. .pm_wakeup = 1,
  626. };
  627. static struct resource bfin_rotary_resources[] = {
  628. {
  629. .start = IRQ_CNT,
  630. .end = IRQ_CNT,
  631. .flags = IORESOURCE_IRQ,
  632. },
  633. };
  634. static struct platform_device bfin_rotary_device = {
  635. .name = "bfin-rotary",
  636. .id = -1,
  637. .num_resources = ARRAY_SIZE(bfin_rotary_resources),
  638. .resource = bfin_rotary_resources,
  639. .dev = {
  640. .platform_data = &bfin_rotary_data,
  641. },
  642. };
  643. #endif
  644. static const unsigned int cclk_vlev_datasheet[] = {
  645. VRPAIR(VLEV_100, 400000000),
  646. VRPAIR(VLEV_105, 426000000),
  647. VRPAIR(VLEV_110, 500000000),
  648. VRPAIR(VLEV_115, 533000000),
  649. VRPAIR(VLEV_120, 600000000),
  650. };
  651. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  652. .tuple_tab = cclk_vlev_datasheet,
  653. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  654. .vr_settling_time = 25 /* us */,
  655. };
  656. static struct platform_device bfin_dpmc = {
  657. .name = "bfin dpmc",
  658. .dev = {
  659. .platform_data = &bfin_dmpc_vreg_data,
  660. },
  661. };
  662. static struct platform_device *stamp_devices[] __initdata = {
  663. &bfin_dpmc,
  664. #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
  665. &bf5xx_nand_device,
  666. #endif
  667. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  668. &rtc_device,
  669. #endif
  670. #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
  671. &musb_device,
  672. #endif
  673. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  674. &bfin_mii_bus,
  675. &bfin_mac_device,
  676. #endif
  677. #if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE)
  678. &bfin_spi0_device,
  679. #endif
  680. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  681. #ifdef CONFIG_SERIAL_BFIN_UART0
  682. &bfin_uart0_device,
  683. #endif
  684. #ifdef CONFIG_SERIAL_BFIN_UART1
  685. &bfin_uart1_device,
  686. #endif
  687. #endif
  688. #if defined(CONFIG_FB_BFIN_RA158Z) || defined(CONFIG_FB_BFIN_RA158Z_MODULE)
  689. &bf52x_ra158z_device,
  690. #endif
  691. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  692. #ifdef CONFIG_BFIN_SIR0
  693. &bfin_sir0_device,
  694. #endif
  695. #ifdef CONFIG_BFIN_SIR1
  696. &bfin_sir1_device,
  697. #endif
  698. #endif
  699. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  700. &i2c_bfin_twi_device,
  701. #endif
  702. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  703. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  704. &bfin_sport0_uart_device,
  705. #endif
  706. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  707. &bfin_sport1_uart_device,
  708. #endif
  709. #endif
  710. #if defined(CONFIG_INPUT_BFIN_ROTARY) || defined(CONFIG_INPUT_BFIN_ROTARY_MODULE)
  711. &bfin_rotary_device,
  712. #endif
  713. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  714. &ad7160eval_flash_device,
  715. #endif
  716. #if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
  717. &bfin_i2s,
  718. #endif
  719. };
  720. static int __init ad7160eval_init(void)
  721. {
  722. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  723. i2c_register_board_info(0, bfin_i2c_board_info,
  724. ARRAY_SIZE(bfin_i2c_board_info));
  725. platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
  726. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  727. return 0;
  728. }
  729. arch_initcall(ad7160eval_init);
  730. static struct platform_device *ad7160eval_early_devices[] __initdata = {
  731. #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
  732. #ifdef CONFIG_SERIAL_BFIN_UART0
  733. &bfin_uart0_device,
  734. #endif
  735. #ifdef CONFIG_SERIAL_BFIN_UART1
  736. &bfin_uart1_device,
  737. #endif
  738. #endif
  739. #if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
  740. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  741. &bfin_sport0_uart_device,
  742. #endif
  743. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  744. &bfin_sport1_uart_device,
  745. #endif
  746. #endif
  747. };
  748. void __init native_machine_early_platform_add_devices(void)
  749. {
  750. printk(KERN_INFO "register early platform devices\n");
  751. early_platform_add_devices(ad7160eval_early_devices,
  752. ARRAY_SIZE(ad7160eval_early_devices));
  753. }
  754. void native_machine_restart(char *cmd)
  755. {
  756. /* workaround reboot hang when booting from SPI */
  757. if ((bfin_read_SYSCR() & 0x7) == 0x3)
  758. bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
  759. }
  760. int bfin_get_ether_addr(char *addr)
  761. {
  762. /* the MAC is stored in OTP memory page 0xDF */
  763. u32 ret;
  764. u64 otp_mac;
  765. u32 (*otp_read)(u32 page, u32 flags, u64 *page_content) = (void *)0xEF00001A;
  766. ret = otp_read(0xDF, 0x00, &otp_mac);
  767. if (!(ret & 0x1)) {
  768. char *otp_mac_p = (char *)&otp_mac;
  769. for (ret = 0; ret < 6; ++ret)
  770. addr[ret] = otp_mac_p[5 - ret];
  771. }
  772. return 0;
  773. }
  774. EXPORT_SYMBOL(bfin_get_ether_addr);