ezbrd.c 20 KB

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