ezbrd.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892
  1. /*
  2. * Copyright 2004-2009 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 <asm/dma.h>
  21. #include <asm/bfin5xx_spi.h>
  22. #include <asm/reboot.h>
  23. #include <asm/nand.h>
  24. #include <asm/portmux.h>
  25. #include <asm/dpmc.h>
  26. #include <linux/spi/ad7877.h>
  27. /*
  28. * Name the Board for the /proc/cpuinfo
  29. */
  30. const char bfin_board_name[] = "ADI BF526-EZBRD";
  31. /*
  32. * Driver needs to know address, irq and flag pin.
  33. */
  34. #if IS_ENABLED(CONFIG_USB_MUSB_HDRC)
  35. static struct resource musb_resources[] = {
  36. [0] = {
  37. .start = 0xffc03800,
  38. .end = 0xffc03cff,
  39. .flags = IORESOURCE_MEM,
  40. },
  41. [1] = { /* general IRQ */
  42. .start = IRQ_USB_INT0,
  43. .end = IRQ_USB_INT0,
  44. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  45. .name = "mc"
  46. },
  47. [2] = { /* DMA IRQ */
  48. .start = IRQ_USB_DMA,
  49. .end = IRQ_USB_DMA,
  50. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  51. .name = "dma"
  52. },
  53. };
  54. static struct musb_hdrc_config musb_config = {
  55. .multipoint = 0,
  56. .dyn_fifo = 0,
  57. .soft_con = 1,
  58. .dma = 1,
  59. .num_eps = 8,
  60. .dma_channels = 8,
  61. .gpio_vrsel = GPIO_PG13,
  62. /* Some custom boards need to be active low, just set it to "0"
  63. * if it is the case.
  64. */
  65. .gpio_vrsel_active = 1,
  66. .clkin = 24, /* musb CLKIN in MHZ */
  67. };
  68. static struct musb_hdrc_platform_data musb_plat = {
  69. #if defined(CONFIG_USB_MUSB_OTG)
  70. .mode = MUSB_OTG,
  71. #elif defined(CONFIG_USB_MUSB_HDRC_HCD)
  72. .mode = MUSB_HOST,
  73. #elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
  74. .mode = MUSB_PERIPHERAL,
  75. #endif
  76. .config = &musb_config,
  77. };
  78. static u64 musb_dmamask = ~(u32)0;
  79. static struct platform_device musb_device = {
  80. .name = "musb-blackfin",
  81. .id = 0,
  82. .dev = {
  83. .dma_mask = &musb_dmamask,
  84. .coherent_dma_mask = 0xffffffff,
  85. .platform_data = &musb_plat,
  86. },
  87. .num_resources = ARRAY_SIZE(musb_resources),
  88. .resource = musb_resources,
  89. };
  90. #endif
  91. #if IS_ENABLED(CONFIG_MTD_PHYSMAP)
  92. static struct mtd_partition ezbrd_partitions[] = {
  93. {
  94. .name = "bootloader(nor)",
  95. .size = 0x40000,
  96. .offset = 0,
  97. }, {
  98. .name = "linux kernel(nor)",
  99. .size = 0x1C0000,
  100. .offset = MTDPART_OFS_APPEND,
  101. }, {
  102. .name = "file system(nor)",
  103. .size = MTDPART_SIZ_FULL,
  104. .offset = MTDPART_OFS_APPEND,
  105. }
  106. };
  107. static struct physmap_flash_data ezbrd_flash_data = {
  108. .width = 2,
  109. .parts = ezbrd_partitions,
  110. .nr_parts = ARRAY_SIZE(ezbrd_partitions),
  111. };
  112. static struct resource ezbrd_flash_resource = {
  113. .start = 0x20000000,
  114. .end = 0x203fffff,
  115. .flags = IORESOURCE_MEM,
  116. };
  117. static struct platform_device ezbrd_flash_device = {
  118. .name = "physmap-flash",
  119. .id = 0,
  120. .dev = {
  121. .platform_data = &ezbrd_flash_data,
  122. },
  123. .num_resources = 1,
  124. .resource = &ezbrd_flash_resource,
  125. };
  126. #endif
  127. #if IS_ENABLED(CONFIG_MTD_NAND_BF5XX)
  128. static struct mtd_partition partition_info[] = {
  129. {
  130. .name = "bootloader(nand)",
  131. .offset = 0,
  132. .size = 0x40000,
  133. }, {
  134. .name = "linux kernel(nand)",
  135. .offset = MTDPART_OFS_APPEND,
  136. .size = 4 * 1024 * 1024,
  137. },
  138. {
  139. .name = "file system(nand)",
  140. .offset = MTDPART_OFS_APPEND,
  141. .size = MTDPART_SIZ_FULL,
  142. },
  143. };
  144. static struct bf5xx_nand_platform bf5xx_nand_platform = {
  145. .data_width = NFC_NWIDTH_8,
  146. .partitions = partition_info,
  147. .nr_partitions = ARRAY_SIZE(partition_info),
  148. .rd_dly = 3,
  149. .wr_dly = 3,
  150. };
  151. static struct resource bf5xx_nand_resources[] = {
  152. {
  153. .start = NFC_CTL,
  154. .end = NFC_DATA_RD + 2,
  155. .flags = IORESOURCE_MEM,
  156. },
  157. {
  158. .start = CH_NFC,
  159. .end = CH_NFC,
  160. .flags = IORESOURCE_IRQ,
  161. },
  162. };
  163. static struct platform_device bf5xx_nand_device = {
  164. .name = "bf5xx-nand",
  165. .id = 0,
  166. .num_resources = ARRAY_SIZE(bf5xx_nand_resources),
  167. .resource = bf5xx_nand_resources,
  168. .dev = {
  169. .platform_data = &bf5xx_nand_platform,
  170. },
  171. };
  172. #endif
  173. #if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
  174. static struct platform_device rtc_device = {
  175. .name = "rtc-bfin",
  176. .id = -1,
  177. };
  178. #endif
  179. #if IS_ENABLED(CONFIG_BFIN_MAC)
  180. #include <linux/bfin_mac.h>
  181. static const unsigned short bfin_mac_peripherals[] = P_RMII0;
  182. static struct bfin_phydev_platform_data bfin_phydev_data[] = {
  183. {
  184. .addr = 1,
  185. .irq = IRQ_MAC_PHYINT,
  186. },
  187. };
  188. static struct bfin_mii_bus_platform_data bfin_mii_bus_data = {
  189. .phydev_number = 1,
  190. .phydev_data = bfin_phydev_data,
  191. .phy_mode = PHY_INTERFACE_MODE_RMII,
  192. .mac_peripherals = bfin_mac_peripherals,
  193. };
  194. static struct platform_device bfin_mii_bus = {
  195. .name = "bfin_mii_bus",
  196. .dev = {
  197. .platform_data = &bfin_mii_bus_data,
  198. }
  199. };
  200. static struct platform_device bfin_mac_device = {
  201. .name = "bfin_mac",
  202. .dev = {
  203. .platform_data = &bfin_mii_bus,
  204. }
  205. };
  206. #endif
  207. #if IS_ENABLED(CONFIG_MTD_M25P80)
  208. static struct mtd_partition bfin_spi_flash_partitions[] = {
  209. {
  210. .name = "bootloader(spi)",
  211. .size = 0x00040000,
  212. .offset = 0,
  213. .mask_flags = MTD_CAP_ROM
  214. }, {
  215. .name = "linux kernel(spi)",
  216. .size = MTDPART_SIZ_FULL,
  217. .offset = MTDPART_OFS_APPEND,
  218. }
  219. };
  220. static struct flash_platform_data bfin_spi_flash_data = {
  221. .name = "m25p80",
  222. .parts = bfin_spi_flash_partitions,
  223. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  224. .type = "sst25wf040",
  225. };
  226. /* SPI flash chip (sst25wf040) */
  227. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  228. .enable_dma = 0, /* use dma transfer with this chip*/
  229. };
  230. #endif
  231. #if IS_ENABLED(CONFIG_MMC_SPI)
  232. static struct bfin5xx_spi_chip mmc_spi_chip_info = {
  233. .enable_dma = 0,
  234. };
  235. #endif
  236. #if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7877)
  237. static const struct ad7877_platform_data bfin_ad7877_ts_info = {
  238. .model = 7877,
  239. .vref_delay_usecs = 50, /* internal, no capacitor */
  240. .x_plate_ohms = 419,
  241. .y_plate_ohms = 486,
  242. .pressure_max = 1000,
  243. .pressure_min = 0,
  244. .stopacq_polarity = 1,
  245. .first_conversion_delay = 3,
  246. .acquisition_time = 1,
  247. .averaging = 1,
  248. .pen_down_acc_interval = 1,
  249. };
  250. #endif
  251. #if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7879)
  252. #include <linux/platform_data/ad7879.h>
  253. static const struct ad7879_platform_data bfin_ad7879_ts_info = {
  254. .model = 7879, /* Model = AD7879 */
  255. .x_plate_ohms = 620, /* 620 Ohm from the touch datasheet */
  256. .pressure_max = 10000,
  257. .pressure_min = 0,
  258. .first_conversion_delay = 3, /* wait 512us before do a first conversion */
  259. .acquisition_time = 1, /* 4us acquisition time per sample */
  260. .median = 2, /* do 8 measurements */
  261. .averaging = 1, /* take the average of 4 middle samples */
  262. .pen_down_acc_interval = 255, /* 9.4 ms */
  263. .gpio_export = 1, /* Export GPIO to gpiolib */
  264. .gpio_base = -1, /* Dynamic allocation */
  265. };
  266. #endif
  267. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  268. #if IS_ENABLED(CONFIG_MTD_M25P80)
  269. {
  270. /* the modalias must be the same as spi device driver name */
  271. .modalias = "m25p80", /* Name of spi_driver for this device */
  272. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  273. .bus_num = 0, /* Framework bus number */
  274. .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
  275. .platform_data = &bfin_spi_flash_data,
  276. .controller_data = &spi_flash_chip_info,
  277. .mode = SPI_MODE_3,
  278. },
  279. #endif
  280. #if IS_ENABLED(CONFIG_MMC_SPI)
  281. {
  282. .modalias = "mmc_spi",
  283. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  284. .bus_num = 0,
  285. .chip_select = 5,
  286. .controller_data = &mmc_spi_chip_info,
  287. .mode = SPI_MODE_3,
  288. },
  289. #endif
  290. #if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7877)
  291. {
  292. .modalias = "ad7877",
  293. .platform_data = &bfin_ad7877_ts_info,
  294. .irq = IRQ_PF8,
  295. .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
  296. .bus_num = 0,
  297. .chip_select = 2,
  298. },
  299. #endif
  300. #if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7879_SPI)
  301. {
  302. .modalias = "ad7879",
  303. .platform_data = &bfin_ad7879_ts_info,
  304. .irq = IRQ_PG0,
  305. .max_speed_hz = 5000000, /* max spi clock (SCK) speed in HZ */
  306. .bus_num = 0,
  307. .chip_select = 5,
  308. .mode = SPI_CPHA | SPI_CPOL,
  309. },
  310. #endif
  311. #if IS_ENABLED(CONFIG_SND_SOC_WM8731) \
  312. && defined(CONFIG_SND_SOC_WM8731_SPI)
  313. {
  314. .modalias = "wm8731",
  315. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  316. .bus_num = 0,
  317. .chip_select = 5,
  318. .mode = SPI_MODE_0,
  319. },
  320. #endif
  321. #if IS_ENABLED(CONFIG_SPI_SPIDEV)
  322. {
  323. .modalias = "spidev",
  324. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  325. .bus_num = 0,
  326. .chip_select = 1,
  327. },
  328. #endif
  329. #if IS_ENABLED(CONFIG_FB_BFIN_LQ035Q1)
  330. {
  331. .modalias = "bfin-lq035q1-spi",
  332. .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
  333. .bus_num = 0,
  334. .chip_select = 1,
  335. .mode = SPI_CPHA | SPI_CPOL,
  336. },
  337. #endif
  338. };
  339. #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
  340. /* SPI controller data */
  341. static struct bfin5xx_spi_master bfin_spi0_info = {
  342. .num_chipselect = 8,
  343. .enable_dma = 1, /* master has the ability to do dma transfer */
  344. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  345. };
  346. /* SPI (0) */
  347. static struct resource bfin_spi0_resource[] = {
  348. [0] = {
  349. .start = SPI0_REGBASE,
  350. .end = SPI0_REGBASE + 0xFF,
  351. .flags = IORESOURCE_MEM,
  352. },
  353. [1] = {
  354. .start = CH_SPI,
  355. .end = CH_SPI,
  356. .flags = IORESOURCE_DMA,
  357. },
  358. [2] = {
  359. .start = IRQ_SPI,
  360. .end = IRQ_SPI,
  361. .flags = IORESOURCE_IRQ,
  362. },
  363. };
  364. static struct platform_device bfin_spi0_device = {
  365. .name = "bfin-spi",
  366. .id = 0, /* Bus number */
  367. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  368. .resource = bfin_spi0_resource,
  369. .dev = {
  370. .platform_data = &bfin_spi0_info, /* Passed to driver */
  371. },
  372. };
  373. #endif /* spi master and devices */
  374. #if IS_ENABLED(CONFIG_SERIAL_BFIN)
  375. #ifdef CONFIG_SERIAL_BFIN_UART0
  376. static struct resource bfin_uart0_resources[] = {
  377. {
  378. .start = UART0_THR,
  379. .end = UART0_GCTL+2,
  380. .flags = IORESOURCE_MEM,
  381. },
  382. {
  383. .start = IRQ_UART0_TX,
  384. .end = IRQ_UART0_TX,
  385. .flags = IORESOURCE_IRQ,
  386. },
  387. {
  388. .start = IRQ_UART0_RX,
  389. .end = IRQ_UART0_RX,
  390. .flags = IORESOURCE_IRQ,
  391. },
  392. {
  393. .start = IRQ_UART0_ERROR,
  394. .end = IRQ_UART0_ERROR,
  395. .flags = IORESOURCE_IRQ,
  396. },
  397. {
  398. .start = CH_UART0_TX,
  399. .end = CH_UART0_TX,
  400. .flags = IORESOURCE_DMA,
  401. },
  402. {
  403. .start = CH_UART0_RX,
  404. .end = CH_UART0_RX,
  405. .flags = IORESOURCE_DMA,
  406. },
  407. };
  408. static unsigned short bfin_uart0_peripherals[] = {
  409. P_UART0_TX, P_UART0_RX, 0
  410. };
  411. static struct platform_device bfin_uart0_device = {
  412. .name = "bfin-uart",
  413. .id = 0,
  414. .num_resources = ARRAY_SIZE(bfin_uart0_resources),
  415. .resource = bfin_uart0_resources,
  416. .dev = {
  417. .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
  418. },
  419. };
  420. #endif
  421. #ifdef CONFIG_SERIAL_BFIN_UART1
  422. static struct resource bfin_uart1_resources[] = {
  423. {
  424. .start = UART1_THR,
  425. .end = UART1_GCTL+2,
  426. .flags = IORESOURCE_MEM,
  427. },
  428. {
  429. .start = IRQ_UART1_TX,
  430. .end = IRQ_UART1_TX,
  431. .flags = IORESOURCE_IRQ,
  432. },
  433. {
  434. .start = IRQ_UART1_RX,
  435. .end = IRQ_UART1_RX,
  436. .flags = IORESOURCE_IRQ,
  437. },
  438. {
  439. .start = IRQ_UART1_ERROR,
  440. .end = IRQ_UART1_ERROR,
  441. .flags = IORESOURCE_IRQ,
  442. },
  443. {
  444. .start = CH_UART1_TX,
  445. .end = CH_UART1_TX,
  446. .flags = IORESOURCE_DMA,
  447. },
  448. {
  449. .start = CH_UART1_RX,
  450. .end = CH_UART1_RX,
  451. .flags = IORESOURCE_DMA,
  452. },
  453. #ifdef CONFIG_BFIN_UART1_CTSRTS
  454. { /* CTS pin */
  455. .start = GPIO_PG0,
  456. .end = GPIO_PG0,
  457. .flags = IORESOURCE_IO,
  458. },
  459. { /* RTS pin */
  460. .start = GPIO_PF10,
  461. .end = GPIO_PF10,
  462. .flags = IORESOURCE_IO,
  463. },
  464. #endif
  465. };
  466. static unsigned short bfin_uart1_peripherals[] = {
  467. P_UART1_TX, P_UART1_RX, 0
  468. };
  469. static struct platform_device bfin_uart1_device = {
  470. .name = "bfin-uart",
  471. .id = 1,
  472. .num_resources = ARRAY_SIZE(bfin_uart1_resources),
  473. .resource = bfin_uart1_resources,
  474. .dev = {
  475. .platform_data = &bfin_uart1_peripherals, /* Passed to driver */
  476. },
  477. };
  478. #endif
  479. #endif
  480. #if IS_ENABLED(CONFIG_BFIN_SIR)
  481. #ifdef CONFIG_BFIN_SIR0
  482. static struct resource bfin_sir0_resources[] = {
  483. {
  484. .start = 0xFFC00400,
  485. .end = 0xFFC004FF,
  486. .flags = IORESOURCE_MEM,
  487. },
  488. {
  489. .start = IRQ_UART0_RX,
  490. .end = IRQ_UART0_RX+1,
  491. .flags = IORESOURCE_IRQ,
  492. },
  493. {
  494. .start = CH_UART0_RX,
  495. .end = CH_UART0_RX+1,
  496. .flags = IORESOURCE_DMA,
  497. },
  498. };
  499. static struct platform_device bfin_sir0_device = {
  500. .name = "bfin_sir",
  501. .id = 0,
  502. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  503. .resource = bfin_sir0_resources,
  504. };
  505. #endif
  506. #ifdef CONFIG_BFIN_SIR1
  507. static struct resource bfin_sir1_resources[] = {
  508. {
  509. .start = 0xFFC02000,
  510. .end = 0xFFC020FF,
  511. .flags = IORESOURCE_MEM,
  512. },
  513. {
  514. .start = IRQ_UART1_RX,
  515. .end = IRQ_UART1_RX+1,
  516. .flags = IORESOURCE_IRQ,
  517. },
  518. {
  519. .start = CH_UART1_RX,
  520. .end = CH_UART1_RX+1,
  521. .flags = IORESOURCE_DMA,
  522. },
  523. };
  524. static struct platform_device bfin_sir1_device = {
  525. .name = "bfin_sir",
  526. .id = 1,
  527. .num_resources = ARRAY_SIZE(bfin_sir1_resources),
  528. .resource = bfin_sir1_resources,
  529. };
  530. #endif
  531. #endif
  532. #if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
  533. static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0};
  534. static struct resource bfin_twi0_resource[] = {
  535. [0] = {
  536. .start = TWI0_REGBASE,
  537. .end = TWI0_REGBASE,
  538. .flags = IORESOURCE_MEM,
  539. },
  540. [1] = {
  541. .start = IRQ_TWI,
  542. .end = IRQ_TWI,
  543. .flags = IORESOURCE_IRQ,
  544. },
  545. };
  546. static struct platform_device i2c_bfin_twi_device = {
  547. .name = "i2c-bfin-twi",
  548. .id = 0,
  549. .num_resources = ARRAY_SIZE(bfin_twi0_resource),
  550. .resource = bfin_twi0_resource,
  551. .dev = {
  552. .platform_data = &bfin_twi0_pins,
  553. },
  554. };
  555. #endif
  556. static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
  557. #if IS_ENABLED(CONFIG_BFIN_TWI_LCD)
  558. {
  559. I2C_BOARD_INFO("pcf8574_lcd", 0x22),
  560. },
  561. #endif
  562. #if IS_ENABLED(CONFIG_INPUT_PCF8574)
  563. {
  564. I2C_BOARD_INFO("pcf8574_keypad", 0x27),
  565. .irq = IRQ_PF8,
  566. },
  567. #endif
  568. };
  569. #if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
  570. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  571. static struct resource bfin_sport0_uart_resources[] = {
  572. {
  573. .start = SPORT0_TCR1,
  574. .end = SPORT0_MRCS3+4,
  575. .flags = IORESOURCE_MEM,
  576. },
  577. {
  578. .start = IRQ_SPORT0_RX,
  579. .end = IRQ_SPORT0_RX+1,
  580. .flags = IORESOURCE_IRQ,
  581. },
  582. {
  583. .start = IRQ_SPORT0_ERROR,
  584. .end = IRQ_SPORT0_ERROR,
  585. .flags = IORESOURCE_IRQ,
  586. },
  587. };
  588. static unsigned short bfin_sport0_peripherals[] = {
  589. P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
  590. P_SPORT0_DRPRI, P_SPORT0_RSCLK, 0
  591. };
  592. static struct platform_device bfin_sport0_uart_device = {
  593. .name = "bfin-sport-uart",
  594. .id = 0,
  595. .num_resources = ARRAY_SIZE(bfin_sport0_uart_resources),
  596. .resource = bfin_sport0_uart_resources,
  597. .dev = {
  598. .platform_data = &bfin_sport0_peripherals, /* Passed to driver */
  599. },
  600. };
  601. #endif
  602. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  603. static struct resource bfin_sport1_uart_resources[] = {
  604. {
  605. .start = SPORT1_TCR1,
  606. .end = SPORT1_MRCS3+4,
  607. .flags = IORESOURCE_MEM,
  608. },
  609. {
  610. .start = IRQ_SPORT1_RX,
  611. .end = IRQ_SPORT1_RX+1,
  612. .flags = IORESOURCE_IRQ,
  613. },
  614. {
  615. .start = IRQ_SPORT1_ERROR,
  616. .end = IRQ_SPORT1_ERROR,
  617. .flags = IORESOURCE_IRQ,
  618. },
  619. };
  620. static unsigned short bfin_sport1_peripherals[] = {
  621. P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
  622. P_SPORT1_DRPRI, P_SPORT1_RSCLK, 0
  623. };
  624. static struct platform_device bfin_sport1_uart_device = {
  625. .name = "bfin-sport-uart",
  626. .id = 1,
  627. .num_resources = ARRAY_SIZE(bfin_sport1_uart_resources),
  628. .resource = bfin_sport1_uart_resources,
  629. .dev = {
  630. .platform_data = &bfin_sport1_peripherals, /* Passed to driver */
  631. },
  632. };
  633. #endif
  634. #endif
  635. #if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
  636. #include <linux/input.h>
  637. #include <linux/gpio_keys.h>
  638. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  639. {BTN_0, GPIO_PG0, 1, "gpio-keys: BTN0"},
  640. {BTN_1, GPIO_PG13, 1, "gpio-keys: BTN1"},
  641. };
  642. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  643. .buttons = bfin_gpio_keys_table,
  644. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  645. };
  646. static struct platform_device bfin_device_gpiokeys = {
  647. .name = "gpio-keys",
  648. .dev = {
  649. .platform_data = &bfin_gpio_keys_data,
  650. },
  651. };
  652. #endif
  653. static const unsigned int cclk_vlev_datasheet[] =
  654. {
  655. VRPAIR(VLEV_100, 400000000),
  656. VRPAIR(VLEV_105, 426000000),
  657. VRPAIR(VLEV_110, 500000000),
  658. VRPAIR(VLEV_115, 533000000),
  659. VRPAIR(VLEV_120, 600000000),
  660. };
  661. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  662. .tuple_tab = cclk_vlev_datasheet,
  663. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  664. .vr_settling_time = 25 /* us */,
  665. };
  666. static struct platform_device bfin_dpmc = {
  667. .name = "bfin dpmc",
  668. .dev = {
  669. .platform_data = &bfin_dmpc_vreg_data,
  670. },
  671. };
  672. #if IS_ENABLED(CONFIG_FB_BFIN_LQ035Q1)
  673. #include <asm/bfin-lq035q1.h>
  674. static struct bfin_lq035q1fb_disp_info bfin_lq035q1_data = {
  675. .mode = LQ035_NORM | LQ035_RGB | LQ035_RL | LQ035_TB,
  676. .ppi_mode = USE_RGB565_16_BIT_PPI,
  677. .use_bl = 1,
  678. .gpio_bl = GPIO_PG12,
  679. };
  680. static struct resource bfin_lq035q1_resources[] = {
  681. {
  682. .start = IRQ_PPI_ERROR,
  683. .end = IRQ_PPI_ERROR,
  684. .flags = IORESOURCE_IRQ,
  685. },
  686. };
  687. static struct platform_device bfin_lq035q1_device = {
  688. .name = "bfin-lq035q1",
  689. .id = -1,
  690. .num_resources = ARRAY_SIZE(bfin_lq035q1_resources),
  691. .resource = bfin_lq035q1_resources,
  692. .dev = {
  693. .platform_data = &bfin_lq035q1_data,
  694. },
  695. };
  696. #endif
  697. static struct platform_device *stamp_devices[] __initdata = {
  698. &bfin_dpmc,
  699. #if IS_ENABLED(CONFIG_MTD_NAND_BF5XX)
  700. &bf5xx_nand_device,
  701. #endif
  702. #if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
  703. &rtc_device,
  704. #endif
  705. #if IS_ENABLED(CONFIG_USB_MUSB_HDRC)
  706. &musb_device,
  707. #endif
  708. #if IS_ENABLED(CONFIG_BFIN_MAC)
  709. &bfin_mii_bus,
  710. &bfin_mac_device,
  711. #endif
  712. #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
  713. &bfin_spi0_device,
  714. #endif
  715. #if IS_ENABLED(CONFIG_SERIAL_BFIN)
  716. #ifdef CONFIG_SERIAL_BFIN_UART0
  717. &bfin_uart0_device,
  718. #endif
  719. #ifdef CONFIG_SERIAL_BFIN_UART1
  720. &bfin_uart1_device,
  721. #endif
  722. #endif
  723. #if IS_ENABLED(CONFIG_FB_BFIN_LQ035Q1)
  724. &bfin_lq035q1_device,
  725. #endif
  726. #if IS_ENABLED(CONFIG_BFIN_SIR)
  727. #ifdef CONFIG_BFIN_SIR0
  728. &bfin_sir0_device,
  729. #endif
  730. #ifdef CONFIG_BFIN_SIR1
  731. &bfin_sir1_device,
  732. #endif
  733. #endif
  734. #if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
  735. &i2c_bfin_twi_device,
  736. #endif
  737. #if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
  738. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  739. &bfin_sport0_uart_device,
  740. #endif
  741. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  742. &bfin_sport1_uart_device,
  743. #endif
  744. #endif
  745. #if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
  746. &bfin_device_gpiokeys,
  747. #endif
  748. #if IS_ENABLED(CONFIG_MTD_PHYSMAP)
  749. &ezbrd_flash_device,
  750. #endif
  751. };
  752. static int __init ezbrd_init(void)
  753. {
  754. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  755. i2c_register_board_info(0, bfin_i2c_board_info,
  756. ARRAY_SIZE(bfin_i2c_board_info));
  757. platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
  758. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  759. return 0;
  760. }
  761. arch_initcall(ezbrd_init);
  762. static struct platform_device *ezbrd_early_devices[] __initdata = {
  763. #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
  764. #ifdef CONFIG_SERIAL_BFIN_UART0
  765. &bfin_uart0_device,
  766. #endif
  767. #ifdef CONFIG_SERIAL_BFIN_UART1
  768. &bfin_uart1_device,
  769. #endif
  770. #endif
  771. #if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
  772. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  773. &bfin_sport0_uart_device,
  774. #endif
  775. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  776. &bfin_sport1_uart_device,
  777. #endif
  778. #endif
  779. };
  780. void __init native_machine_early_platform_add_devices(void)
  781. {
  782. printk(KERN_INFO "register early platform devices\n");
  783. early_platform_add_devices(ezbrd_early_devices,
  784. ARRAY_SIZE(ezbrd_early_devices));
  785. }
  786. void native_machine_restart(char *cmd)
  787. {
  788. /* workaround reboot hang when booting from SPI */
  789. if ((bfin_read_SYSCR() & 0x7) == 0x3)
  790. bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
  791. }
  792. int bfin_get_ether_addr(char *addr)
  793. {
  794. /* the MAC is stored in OTP memory page 0xDF */
  795. u32 ret;
  796. u64 otp_mac;
  797. u32 (*otp_read)(u32 page, u32 flags, u64 *page_content) = (void *)0xEF00001A;
  798. ret = otp_read(0xDF, 0x00, &otp_mac);
  799. if (!(ret & 0x1)) {
  800. char *otp_mac_p = (char *)&otp_mac;
  801. for (ret = 0; ret < 6; ++ret)
  802. addr[ret] = otp_mac_p[5 - ret];
  803. }
  804. return 0;
  805. }
  806. EXPORT_SYMBOL(bfin_get_ether_addr);