ezbrd.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887
  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 defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
  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 defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  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 defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
  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 defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  174. static struct platform_device rtc_device = {
  175. .name = "rtc-bfin",
  176. .id = -1,
  177. };
  178. #endif
  179. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  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 defined(CONFIG_MTD_M25P80) \
  208. || defined(CONFIG_MTD_M25P80_MODULE)
  209. static struct mtd_partition bfin_spi_flash_partitions[] = {
  210. {
  211. .name = "bootloader(spi)",
  212. .size = 0x00040000,
  213. .offset = 0,
  214. .mask_flags = MTD_CAP_ROM
  215. }, {
  216. .name = "linux kernel(spi)",
  217. .size = MTDPART_SIZ_FULL,
  218. .offset = MTDPART_OFS_APPEND,
  219. }
  220. };
  221. static struct flash_platform_data bfin_spi_flash_data = {
  222. .name = "m25p80",
  223. .parts = bfin_spi_flash_partitions,
  224. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  225. .type = "sst25wf040",
  226. };
  227. /* SPI flash chip (sst25wf040) */
  228. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  229. .enable_dma = 0, /* use dma transfer with this chip*/
  230. };
  231. #endif
  232. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  233. static struct bfin5xx_spi_chip mmc_spi_chip_info = {
  234. .enable_dma = 0,
  235. };
  236. #endif
  237. #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
  238. static const struct ad7877_platform_data bfin_ad7877_ts_info = {
  239. .model = 7877,
  240. .vref_delay_usecs = 50, /* internal, no capacitor */
  241. .x_plate_ohms = 419,
  242. .y_plate_ohms = 486,
  243. .pressure_max = 1000,
  244. .pressure_min = 0,
  245. .stopacq_polarity = 1,
  246. .first_conversion_delay = 3,
  247. .acquisition_time = 1,
  248. .averaging = 1,
  249. .pen_down_acc_interval = 1,
  250. };
  251. #endif
  252. #if defined(CONFIG_TOUCHSCREEN_AD7879) || defined(CONFIG_TOUCHSCREEN_AD7879_MODULE)
  253. #include <linux/spi/ad7879.h>
  254. static const struct ad7879_platform_data bfin_ad7879_ts_info = {
  255. .model = 7879, /* Model = AD7879 */
  256. .x_plate_ohms = 620, /* 620 Ohm from the touch datasheet */
  257. .pressure_max = 10000,
  258. .pressure_min = 0,
  259. .first_conversion_delay = 3, /* wait 512us before do a first conversion */
  260. .acquisition_time = 1, /* 4us acquisition time per sample */
  261. .median = 2, /* do 8 measurements */
  262. .averaging = 1, /* take the average of 4 middle samples */
  263. .pen_down_acc_interval = 255, /* 9.4 ms */
  264. .gpio_export = 1, /* Export GPIO to gpiolib */
  265. .gpio_base = -1, /* Dynamic allocation */
  266. };
  267. #endif
  268. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  269. #if defined(CONFIG_MTD_M25P80) \
  270. || defined(CONFIG_MTD_M25P80_MODULE)
  271. {
  272. /* the modalias must be the same as spi device driver name */
  273. .modalias = "m25p80", /* Name of spi_driver for this device */
  274. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  275. .bus_num = 0, /* Framework bus number */
  276. .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
  277. .platform_data = &bfin_spi_flash_data,
  278. .controller_data = &spi_flash_chip_info,
  279. .mode = SPI_MODE_3,
  280. },
  281. #endif
  282. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  283. {
  284. .modalias = "mmc_spi",
  285. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  286. .bus_num = 0,
  287. .chip_select = 5,
  288. .controller_data = &mmc_spi_chip_info,
  289. .mode = SPI_MODE_3,
  290. },
  291. #endif
  292. #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
  293. {
  294. .modalias = "ad7877",
  295. .platform_data = &bfin_ad7877_ts_info,
  296. .irq = IRQ_PF8,
  297. .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
  298. .bus_num = 0,
  299. .chip_select = 2,
  300. },
  301. #endif
  302. #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
  303. {
  304. .modalias = "ad7879",
  305. .platform_data = &bfin_ad7879_ts_info,
  306. .irq = IRQ_PG0,
  307. .max_speed_hz = 5000000, /* max spi clock (SCK) speed in HZ */
  308. .bus_num = 0,
  309. .chip_select = 5,
  310. .mode = SPI_CPHA | SPI_CPOL,
  311. },
  312. #endif
  313. #if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
  314. && defined(CONFIG_SND_SOC_WM8731_SPI)
  315. {
  316. .modalias = "wm8731",
  317. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  318. .bus_num = 0,
  319. .chip_select = 5,
  320. .mode = SPI_MODE_0,
  321. },
  322. #endif
  323. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  324. {
  325. .modalias = "spidev",
  326. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  327. .bus_num = 0,
  328. .chip_select = 1,
  329. },
  330. #endif
  331. #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
  332. {
  333. .modalias = "bfin-lq035q1-spi",
  334. .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
  335. .bus_num = 0,
  336. .chip_select = 1,
  337. .mode = SPI_CPHA | SPI_CPOL,
  338. },
  339. #endif
  340. };
  341. #if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE)
  342. /* SPI controller data */
  343. static struct bfin5xx_spi_master bfin_spi0_info = {
  344. .num_chipselect = 8,
  345. .enable_dma = 1, /* master has the ability to do dma transfer */
  346. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  347. };
  348. /* SPI (0) */
  349. static struct resource bfin_spi0_resource[] = {
  350. [0] = {
  351. .start = SPI0_REGBASE,
  352. .end = SPI0_REGBASE + 0xFF,
  353. .flags = IORESOURCE_MEM,
  354. },
  355. [1] = {
  356. .start = CH_SPI,
  357. .end = CH_SPI,
  358. .flags = IORESOURCE_DMA,
  359. },
  360. [2] = {
  361. .start = IRQ_SPI,
  362. .end = IRQ_SPI,
  363. .flags = IORESOURCE_IRQ,
  364. },
  365. };
  366. static struct platform_device bfin_spi0_device = {
  367. .name = "bfin-spi",
  368. .id = 0, /* Bus number */
  369. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  370. .resource = bfin_spi0_resource,
  371. .dev = {
  372. .platform_data = &bfin_spi0_info, /* Passed to driver */
  373. },
  374. };
  375. #endif /* spi master and devices */
  376. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  377. #ifdef CONFIG_SERIAL_BFIN_UART0
  378. static struct resource bfin_uart0_resources[] = {
  379. {
  380. .start = UART0_THR,
  381. .end = UART0_GCTL+2,
  382. .flags = IORESOURCE_MEM,
  383. },
  384. {
  385. .start = IRQ_UART0_TX,
  386. .end = IRQ_UART0_TX,
  387. .flags = IORESOURCE_IRQ,
  388. },
  389. {
  390. .start = IRQ_UART0_RX,
  391. .end = IRQ_UART0_RX,
  392. .flags = IORESOURCE_IRQ,
  393. },
  394. {
  395. .start = IRQ_UART0_ERROR,
  396. .end = IRQ_UART0_ERROR,
  397. .flags = IORESOURCE_IRQ,
  398. },
  399. {
  400. .start = CH_UART0_TX,
  401. .end = CH_UART0_TX,
  402. .flags = IORESOURCE_DMA,
  403. },
  404. {
  405. .start = CH_UART0_RX,
  406. .end = CH_UART0_RX,
  407. .flags = IORESOURCE_DMA,
  408. },
  409. };
  410. static unsigned short bfin_uart0_peripherals[] = {
  411. P_UART0_TX, P_UART0_RX, 0
  412. };
  413. static struct platform_device bfin_uart0_device = {
  414. .name = "bfin-uart",
  415. .id = 0,
  416. .num_resources = ARRAY_SIZE(bfin_uart0_resources),
  417. .resource = bfin_uart0_resources,
  418. .dev = {
  419. .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
  420. },
  421. };
  422. #endif
  423. #ifdef CONFIG_SERIAL_BFIN_UART1
  424. static struct resource bfin_uart1_resources[] = {
  425. {
  426. .start = UART1_THR,
  427. .end = UART1_GCTL+2,
  428. .flags = IORESOURCE_MEM,
  429. },
  430. {
  431. .start = IRQ_UART1_TX,
  432. .end = IRQ_UART1_TX,
  433. .flags = IORESOURCE_IRQ,
  434. },
  435. {
  436. .start = IRQ_UART1_RX,
  437. .end = IRQ_UART1_RX,
  438. .flags = IORESOURCE_IRQ,
  439. },
  440. {
  441. .start = IRQ_UART1_ERROR,
  442. .end = IRQ_UART1_ERROR,
  443. .flags = IORESOURCE_IRQ,
  444. },
  445. {
  446. .start = CH_UART1_TX,
  447. .end = CH_UART1_TX,
  448. .flags = IORESOURCE_DMA,
  449. },
  450. {
  451. .start = CH_UART1_RX,
  452. .end = CH_UART1_RX,
  453. .flags = IORESOURCE_DMA,
  454. },
  455. #ifdef CONFIG_BFIN_UART1_CTSRTS
  456. { /* CTS pin */
  457. .start = GPIO_PG0,
  458. .end = GPIO_PG0,
  459. .flags = IORESOURCE_IO,
  460. },
  461. { /* RTS pin */
  462. .start = GPIO_PF10,
  463. .end = GPIO_PF10,
  464. .flags = IORESOURCE_IO,
  465. },
  466. #endif
  467. };
  468. static unsigned short bfin_uart1_peripherals[] = {
  469. P_UART1_TX, P_UART1_RX, 0
  470. };
  471. static struct platform_device bfin_uart1_device = {
  472. .name = "bfin-uart",
  473. .id = 1,
  474. .num_resources = ARRAY_SIZE(bfin_uart1_resources),
  475. .resource = bfin_uart1_resources,
  476. .dev = {
  477. .platform_data = &bfin_uart1_peripherals, /* Passed to driver */
  478. },
  479. };
  480. #endif
  481. #endif
  482. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  483. #ifdef CONFIG_BFIN_SIR0
  484. static struct resource bfin_sir0_resources[] = {
  485. {
  486. .start = 0xFFC00400,
  487. .end = 0xFFC004FF,
  488. .flags = IORESOURCE_MEM,
  489. },
  490. {
  491. .start = IRQ_UART0_RX,
  492. .end = IRQ_UART0_RX+1,
  493. .flags = IORESOURCE_IRQ,
  494. },
  495. {
  496. .start = CH_UART0_RX,
  497. .end = CH_UART0_RX+1,
  498. .flags = IORESOURCE_DMA,
  499. },
  500. };
  501. static struct platform_device bfin_sir0_device = {
  502. .name = "bfin_sir",
  503. .id = 0,
  504. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  505. .resource = bfin_sir0_resources,
  506. };
  507. #endif
  508. #ifdef CONFIG_BFIN_SIR1
  509. static struct resource bfin_sir1_resources[] = {
  510. {
  511. .start = 0xFFC02000,
  512. .end = 0xFFC020FF,
  513. .flags = IORESOURCE_MEM,
  514. },
  515. {
  516. .start = IRQ_UART1_RX,
  517. .end = IRQ_UART1_RX+1,
  518. .flags = IORESOURCE_IRQ,
  519. },
  520. {
  521. .start = CH_UART1_RX,
  522. .end = CH_UART1_RX+1,
  523. .flags = IORESOURCE_DMA,
  524. },
  525. };
  526. static struct platform_device bfin_sir1_device = {
  527. .name = "bfin_sir",
  528. .id = 1,
  529. .num_resources = ARRAY_SIZE(bfin_sir1_resources),
  530. .resource = bfin_sir1_resources,
  531. };
  532. #endif
  533. #endif
  534. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  535. static struct resource bfin_twi0_resource[] = {
  536. [0] = {
  537. .start = TWI0_REGBASE,
  538. .end = TWI0_REGBASE,
  539. .flags = IORESOURCE_MEM,
  540. },
  541. [1] = {
  542. .start = IRQ_TWI,
  543. .end = IRQ_TWI,
  544. .flags = IORESOURCE_IRQ,
  545. },
  546. };
  547. static struct platform_device i2c_bfin_twi_device = {
  548. .name = "i2c-bfin-twi",
  549. .id = 0,
  550. .num_resources = ARRAY_SIZE(bfin_twi0_resource),
  551. .resource = bfin_twi0_resource,
  552. };
  553. #endif
  554. static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
  555. #if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
  556. {
  557. I2C_BOARD_INFO("pcf8574_lcd", 0x22),
  558. },
  559. #endif
  560. #if defined(CONFIG_INPUT_PCF8574) || defined(CONFIG_INPUT_PCF8574_MODULE)
  561. {
  562. I2C_BOARD_INFO("pcf8574_keypad", 0x27),
  563. .irq = IRQ_PF8,
  564. },
  565. #endif
  566. };
  567. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  568. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  569. static struct resource bfin_sport0_uart_resources[] = {
  570. {
  571. .start = SPORT0_TCR1,
  572. .end = SPORT0_MRCS3+4,
  573. .flags = IORESOURCE_MEM,
  574. },
  575. {
  576. .start = IRQ_SPORT0_RX,
  577. .end = IRQ_SPORT0_RX+1,
  578. .flags = IORESOURCE_IRQ,
  579. },
  580. {
  581. .start = IRQ_SPORT0_ERROR,
  582. .end = IRQ_SPORT0_ERROR,
  583. .flags = IORESOURCE_IRQ,
  584. },
  585. };
  586. static unsigned short bfin_sport0_peripherals[] = {
  587. P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
  588. P_SPORT0_DRPRI, P_SPORT0_RSCLK, 0
  589. };
  590. static struct platform_device bfin_sport0_uart_device = {
  591. .name = "bfin-sport-uart",
  592. .id = 0,
  593. .num_resources = ARRAY_SIZE(bfin_sport0_uart_resources),
  594. .resource = bfin_sport0_uart_resources,
  595. .dev = {
  596. .platform_data = &bfin_sport0_peripherals, /* Passed to driver */
  597. },
  598. };
  599. #endif
  600. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  601. static struct resource bfin_sport1_uart_resources[] = {
  602. {
  603. .start = SPORT1_TCR1,
  604. .end = SPORT1_MRCS3+4,
  605. .flags = IORESOURCE_MEM,
  606. },
  607. {
  608. .start = IRQ_SPORT1_RX,
  609. .end = IRQ_SPORT1_RX+1,
  610. .flags = IORESOURCE_IRQ,
  611. },
  612. {
  613. .start = IRQ_SPORT1_ERROR,
  614. .end = IRQ_SPORT1_ERROR,
  615. .flags = IORESOURCE_IRQ,
  616. },
  617. };
  618. static unsigned short bfin_sport1_peripherals[] = {
  619. P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
  620. P_SPORT1_DRPRI, P_SPORT1_RSCLK, 0
  621. };
  622. static struct platform_device bfin_sport1_uart_device = {
  623. .name = "bfin-sport-uart",
  624. .id = 1,
  625. .num_resources = ARRAY_SIZE(bfin_sport1_uart_resources),
  626. .resource = bfin_sport1_uart_resources,
  627. .dev = {
  628. .platform_data = &bfin_sport1_peripherals, /* Passed to driver */
  629. },
  630. };
  631. #endif
  632. #endif
  633. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  634. #include <linux/input.h>
  635. #include <linux/gpio_keys.h>
  636. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  637. {BTN_0, GPIO_PG0, 1, "gpio-keys: BTN0"},
  638. {BTN_1, GPIO_PG13, 1, "gpio-keys: BTN1"},
  639. };
  640. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  641. .buttons = bfin_gpio_keys_table,
  642. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  643. };
  644. static struct platform_device bfin_device_gpiokeys = {
  645. .name = "gpio-keys",
  646. .dev = {
  647. .platform_data = &bfin_gpio_keys_data,
  648. },
  649. };
  650. #endif
  651. static const unsigned int cclk_vlev_datasheet[] =
  652. {
  653. VRPAIR(VLEV_100, 400000000),
  654. VRPAIR(VLEV_105, 426000000),
  655. VRPAIR(VLEV_110, 500000000),
  656. VRPAIR(VLEV_115, 533000000),
  657. VRPAIR(VLEV_120, 600000000),
  658. };
  659. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  660. .tuple_tab = cclk_vlev_datasheet,
  661. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  662. .vr_settling_time = 25 /* us */,
  663. };
  664. static struct platform_device bfin_dpmc = {
  665. .name = "bfin dpmc",
  666. .dev = {
  667. .platform_data = &bfin_dmpc_vreg_data,
  668. },
  669. };
  670. #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
  671. #include <asm/bfin-lq035q1.h>
  672. static struct bfin_lq035q1fb_disp_info bfin_lq035q1_data = {
  673. .mode = LQ035_NORM | LQ035_RGB | LQ035_RL | LQ035_TB,
  674. .ppi_mode = USE_RGB565_16_BIT_PPI,
  675. .use_bl = 1,
  676. .gpio_bl = GPIO_PG12,
  677. };
  678. static struct resource bfin_lq035q1_resources[] = {
  679. {
  680. .start = IRQ_PPI_ERROR,
  681. .end = IRQ_PPI_ERROR,
  682. .flags = IORESOURCE_IRQ,
  683. },
  684. };
  685. static struct platform_device bfin_lq035q1_device = {
  686. .name = "bfin-lq035q1",
  687. .id = -1,
  688. .num_resources = ARRAY_SIZE(bfin_lq035q1_resources),
  689. .resource = bfin_lq035q1_resources,
  690. .dev = {
  691. .platform_data = &bfin_lq035q1_data,
  692. },
  693. };
  694. #endif
  695. static struct platform_device *stamp_devices[] __initdata = {
  696. &bfin_dpmc,
  697. #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
  698. &bf5xx_nand_device,
  699. #endif
  700. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  701. &rtc_device,
  702. #endif
  703. #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
  704. &musb_device,
  705. #endif
  706. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  707. &bfin_mii_bus,
  708. &bfin_mac_device,
  709. #endif
  710. #if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE)
  711. &bfin_spi0_device,
  712. #endif
  713. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  714. #ifdef CONFIG_SERIAL_BFIN_UART0
  715. &bfin_uart0_device,
  716. #endif
  717. #ifdef CONFIG_SERIAL_BFIN_UART1
  718. &bfin_uart1_device,
  719. #endif
  720. #endif
  721. #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
  722. &bfin_lq035q1_device,
  723. #endif
  724. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  725. #ifdef CONFIG_BFIN_SIR0
  726. &bfin_sir0_device,
  727. #endif
  728. #ifdef CONFIG_BFIN_SIR1
  729. &bfin_sir1_device,
  730. #endif
  731. #endif
  732. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  733. &i2c_bfin_twi_device,
  734. #endif
  735. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  736. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  737. &bfin_sport0_uart_device,
  738. #endif
  739. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  740. &bfin_sport1_uart_device,
  741. #endif
  742. #endif
  743. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  744. &bfin_device_gpiokeys,
  745. #endif
  746. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  747. &ezbrd_flash_device,
  748. #endif
  749. };
  750. static int __init ezbrd_init(void)
  751. {
  752. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  753. i2c_register_board_info(0, bfin_i2c_board_info,
  754. ARRAY_SIZE(bfin_i2c_board_info));
  755. platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
  756. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  757. return 0;
  758. }
  759. arch_initcall(ezbrd_init);
  760. static struct platform_device *ezbrd_early_devices[] __initdata = {
  761. #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
  762. #ifdef CONFIG_SERIAL_BFIN_UART0
  763. &bfin_uart0_device,
  764. #endif
  765. #ifdef CONFIG_SERIAL_BFIN_UART1
  766. &bfin_uart1_device,
  767. #endif
  768. #endif
  769. #if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
  770. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  771. &bfin_sport0_uart_device,
  772. #endif
  773. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  774. &bfin_sport1_uart_device,
  775. #endif
  776. #endif
  777. };
  778. void __init native_machine_early_platform_add_devices(void)
  779. {
  780. printk(KERN_INFO "register early platform devices\n");
  781. early_platform_add_devices(ezbrd_early_devices,
  782. ARRAY_SIZE(ezbrd_early_devices));
  783. }
  784. void native_machine_restart(char *cmd)
  785. {
  786. /* workaround reboot hang when booting from SPI */
  787. if ((bfin_read_SYSCR() & 0x7) == 0x3)
  788. bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
  789. }
  790. void bfin_get_ether_addr(char *addr)
  791. {
  792. /* the MAC is stored in OTP memory page 0xDF */
  793. u32 ret;
  794. u64 otp_mac;
  795. u32 (*otp_read)(u32 page, u32 flags, u64 *page_content) = (void *)0xEF00001A;
  796. ret = otp_read(0xDF, 0x00, &otp_mac);
  797. if (!(ret & 0x1)) {
  798. char *otp_mac_p = (char *)&otp_mac;
  799. for (ret = 0; ret < 6; ++ret)
  800. addr[ret] = otp_mac_p[5 - ret];
  801. }
  802. }
  803. EXPORT_SYMBOL(bfin_get_ether_addr);