ezbrd.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885
  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 <asm/dma.h>
  19. #include <asm/bfin5xx_spi.h>
  20. #include <asm/reboot.h>
  21. #include <asm/portmux.h>
  22. #include <asm/dpmc.h>
  23. #include <asm/bfin_sdh.h>
  24. #include <linux/spi/ad7877.h>
  25. #include <net/dsa.h>
  26. /*
  27. * Name the Board for the /proc/cpuinfo
  28. */
  29. const char bfin_board_name[] = "ADI BF518F-EZBRD";
  30. /*
  31. * Driver needs to know address, irq and flag pin.
  32. */
  33. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  34. static struct mtd_partition ezbrd_partitions[] = {
  35. {
  36. .name = "bootloader(nor)",
  37. .size = 0x40000,
  38. .offset = 0,
  39. }, {
  40. .name = "linux kernel(nor)",
  41. .size = 0x1C0000,
  42. .offset = MTDPART_OFS_APPEND,
  43. }, {
  44. .name = "file system(nor)",
  45. .size = MTDPART_SIZ_FULL,
  46. .offset = MTDPART_OFS_APPEND,
  47. }
  48. };
  49. static struct physmap_flash_data ezbrd_flash_data = {
  50. .width = 2,
  51. .parts = ezbrd_partitions,
  52. .nr_parts = ARRAY_SIZE(ezbrd_partitions),
  53. };
  54. static struct resource ezbrd_flash_resource = {
  55. .start = 0x20000000,
  56. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  57. .end = 0x202fffff,
  58. #else
  59. .end = 0x203fffff,
  60. #endif
  61. .flags = IORESOURCE_MEM,
  62. };
  63. static struct platform_device ezbrd_flash_device = {
  64. .name = "physmap-flash",
  65. .id = 0,
  66. .dev = {
  67. .platform_data = &ezbrd_flash_data,
  68. },
  69. .num_resources = 1,
  70. .resource = &ezbrd_flash_resource,
  71. };
  72. #endif
  73. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  74. static struct platform_device rtc_device = {
  75. .name = "rtc-bfin",
  76. .id = -1,
  77. };
  78. #endif
  79. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  80. #include <linux/bfin_mac.h>
  81. static const unsigned short bfin_mac_peripherals[] = {
  82. P_MII0_ETxD0,
  83. P_MII0_ETxD1,
  84. P_MII0_ETxEN,
  85. P_MII0_ERxD0,
  86. P_MII0_ERxD1,
  87. P_MII0_TxCLK,
  88. P_MII0_PHYINT,
  89. P_MII0_CRS,
  90. P_MII0_MDC,
  91. P_MII0_MDIO,
  92. 0
  93. };
  94. static struct bfin_phydev_platform_data bfin_phydev_data[] = {
  95. {
  96. .addr = 1,
  97. .irq = IRQ_MAC_PHYINT,
  98. },
  99. {
  100. .addr = 2,
  101. .irq = IRQ_MAC_PHYINT,
  102. },
  103. {
  104. .addr = 3,
  105. .irq = IRQ_MAC_PHYINT,
  106. },
  107. };
  108. static struct bfin_mii_bus_platform_data bfin_mii_bus_data = {
  109. .phydev_number = 3,
  110. .phydev_data = bfin_phydev_data,
  111. .phy_mode = PHY_INTERFACE_MODE_MII,
  112. .mac_peripherals = bfin_mac_peripherals,
  113. };
  114. static struct platform_device bfin_mii_bus = {
  115. .name = "bfin_mii_bus",
  116. .dev = {
  117. .platform_data = &bfin_mii_bus_data,
  118. }
  119. };
  120. static struct platform_device bfin_mac_device = {
  121. .name = "bfin_mac",
  122. .dev = {
  123. .platform_data = &bfin_mii_bus,
  124. }
  125. };
  126. #if defined(CONFIG_NET_DSA_KSZ8893M) || defined(CONFIG_NET_DSA_KSZ8893M_MODULE)
  127. static struct dsa_chip_data ksz8893m_switch_chip_data = {
  128. .mii_bus = &bfin_mii_bus.dev,
  129. .port_names = {
  130. NULL,
  131. "eth%d",
  132. "eth%d",
  133. "cpu",
  134. },
  135. };
  136. static struct dsa_platform_data ksz8893m_switch_data = {
  137. .nr_chips = 1,
  138. .netdev = &bfin_mac_device.dev,
  139. .chip = &ksz8893m_switch_chip_data,
  140. };
  141. static struct platform_device ksz8893m_switch_device = {
  142. .name = "dsa",
  143. .id = 0,
  144. .num_resources = 0,
  145. .dev.platform_data = &ksz8893m_switch_data,
  146. };
  147. #endif
  148. #endif
  149. #if defined(CONFIG_MTD_M25P80) \
  150. || defined(CONFIG_MTD_M25P80_MODULE)
  151. static struct mtd_partition bfin_spi_flash_partitions[] = {
  152. {
  153. .name = "bootloader(spi)",
  154. .size = 0x00040000,
  155. .offset = 0,
  156. .mask_flags = MTD_CAP_ROM
  157. }, {
  158. .name = "linux kernel(spi)",
  159. .size = MTDPART_SIZ_FULL,
  160. .offset = MTDPART_OFS_APPEND,
  161. }
  162. };
  163. static struct flash_platform_data bfin_spi_flash_data = {
  164. .name = "m25p80",
  165. .parts = bfin_spi_flash_partitions,
  166. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  167. .type = "m25p16",
  168. };
  169. /* SPI flash chip (m25p64) */
  170. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  171. .enable_dma = 0, /* use dma transfer with this chip*/
  172. .bits_per_word = 8,
  173. };
  174. #endif
  175. #if defined(CONFIG_BFIN_SPI_ADC) \
  176. || defined(CONFIG_BFIN_SPI_ADC_MODULE)
  177. /* SPI ADC chip */
  178. static struct bfin5xx_spi_chip spi_adc_chip_info = {
  179. .enable_dma = 1, /* use dma transfer with this chip*/
  180. .bits_per_word = 16,
  181. };
  182. #endif
  183. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  184. #if defined(CONFIG_NET_DSA_KSZ8893M) \
  185. || defined(CONFIG_NET_DSA_KSZ8893M_MODULE)
  186. /* SPI SWITCH CHIP */
  187. static struct bfin5xx_spi_chip spi_switch_info = {
  188. .enable_dma = 0,
  189. .bits_per_word = 8,
  190. };
  191. #endif
  192. #endif
  193. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  194. static struct bfin5xx_spi_chip mmc_spi_chip_info = {
  195. .enable_dma = 0,
  196. .bits_per_word = 8,
  197. };
  198. #endif
  199. #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
  200. static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
  201. .enable_dma = 0,
  202. .bits_per_word = 16,
  203. };
  204. static const struct ad7877_platform_data bfin_ad7877_ts_info = {
  205. .model = 7877,
  206. .vref_delay_usecs = 50, /* internal, no capacitor */
  207. .x_plate_ohms = 419,
  208. .y_plate_ohms = 486,
  209. .pressure_max = 1000,
  210. .pressure_min = 0,
  211. .stopacq_polarity = 1,
  212. .first_conversion_delay = 3,
  213. .acquisition_time = 1,
  214. .averaging = 1,
  215. .pen_down_acc_interval = 1,
  216. };
  217. #endif
  218. #if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
  219. && defined(CONFIG_SND_SOC_WM8731_SPI)
  220. static struct bfin5xx_spi_chip spi_wm8731_chip_info = {
  221. .enable_dma = 0,
  222. .bits_per_word = 16,
  223. };
  224. #endif
  225. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  226. static struct bfin5xx_spi_chip spidev_chip_info = {
  227. .enable_dma = 0,
  228. .bits_per_word = 8,
  229. };
  230. #endif
  231. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  232. #if defined(CONFIG_MTD_M25P80) \
  233. || defined(CONFIG_MTD_M25P80_MODULE)
  234. {
  235. /* the modalias must be the same as spi device driver name */
  236. .modalias = "m25p80", /* Name of spi_driver for this device */
  237. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  238. .bus_num = 0, /* Framework bus number */
  239. .chip_select = 2, /* On BF518F-EZBRD it's SPI0_SSEL2 */
  240. .platform_data = &bfin_spi_flash_data,
  241. .controller_data = &spi_flash_chip_info,
  242. .mode = SPI_MODE_3,
  243. },
  244. #endif
  245. #if defined(CONFIG_BFIN_SPI_ADC) \
  246. || defined(CONFIG_BFIN_SPI_ADC_MODULE)
  247. {
  248. .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
  249. .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
  250. .bus_num = 0, /* Framework bus number */
  251. .chip_select = 1, /* Framework chip select. */
  252. .platform_data = NULL, /* No spi_driver specific config */
  253. .controller_data = &spi_adc_chip_info,
  254. },
  255. #endif
  256. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  257. #if defined(CONFIG_NET_DSA_KSZ8893M) \
  258. || defined(CONFIG_NET_DSA_KSZ8893M_MODULE)
  259. {
  260. .modalias = "ksz8893m",
  261. .max_speed_hz = 5000000,
  262. .bus_num = 0,
  263. .chip_select = 1,
  264. .platform_data = NULL,
  265. .controller_data = &spi_switch_info,
  266. .mode = SPI_MODE_3,
  267. },
  268. #endif
  269. #endif
  270. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  271. {
  272. .modalias = "mmc_spi",
  273. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  274. .bus_num = 0,
  275. .chip_select = 5,
  276. .controller_data = &mmc_spi_chip_info,
  277. .mode = SPI_MODE_3,
  278. },
  279. #endif
  280. #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
  281. {
  282. .modalias = "ad7877",
  283. .platform_data = &bfin_ad7877_ts_info,
  284. .irq = IRQ_PF8,
  285. .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
  286. .bus_num = 0,
  287. .chip_select = 2,
  288. .controller_data = &spi_ad7877_chip_info,
  289. },
  290. #endif
  291. #if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
  292. && defined(CONFIG_SND_SOC_WM8731_SPI)
  293. {
  294. .modalias = "wm8731",
  295. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  296. .bus_num = 0,
  297. .chip_select = 5,
  298. .controller_data = &spi_wm8731_chip_info,
  299. .mode = SPI_MODE_0,
  300. },
  301. #endif
  302. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  303. {
  304. .modalias = "spidev",
  305. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  306. .bus_num = 0,
  307. .chip_select = 1,
  308. .controller_data = &spidev_chip_info,
  309. },
  310. #endif
  311. #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
  312. {
  313. .modalias = "bfin-lq035q1-spi",
  314. .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
  315. .bus_num = 0,
  316. .chip_select = 1,
  317. .controller_data = &lq035q1_spi_chip_info,
  318. .mode = SPI_CPHA | SPI_CPOL,
  319. },
  320. #endif
  321. };
  322. /* SPI controller data */
  323. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  324. /* SPI (0) */
  325. static struct bfin5xx_spi_master bfin_spi0_info = {
  326. .num_chipselect = 6,
  327. .enable_dma = 1, /* master has the ability to do dma transfer */
  328. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  329. };
  330. static struct resource bfin_spi0_resource[] = {
  331. [0] = {
  332. .start = SPI0_REGBASE,
  333. .end = SPI0_REGBASE + 0xFF,
  334. .flags = IORESOURCE_MEM,
  335. },
  336. [1] = {
  337. .start = CH_SPI0,
  338. .end = CH_SPI0,
  339. .flags = IORESOURCE_DMA,
  340. },
  341. [2] = {
  342. .start = IRQ_SPI0,
  343. .end = IRQ_SPI0,
  344. .flags = IORESOURCE_IRQ,
  345. },
  346. };
  347. static struct platform_device bfin_spi0_device = {
  348. .name = "bfin-spi",
  349. .id = 0, /* Bus number */
  350. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  351. .resource = bfin_spi0_resource,
  352. .dev = {
  353. .platform_data = &bfin_spi0_info, /* Passed to driver */
  354. },
  355. };
  356. /* SPI (1) */
  357. static struct bfin5xx_spi_master bfin_spi1_info = {
  358. .num_chipselect = 6,
  359. .enable_dma = 1, /* master has the ability to do dma transfer */
  360. .pin_req = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0},
  361. };
  362. static struct resource bfin_spi1_resource[] = {
  363. [0] = {
  364. .start = SPI1_REGBASE,
  365. .end = SPI1_REGBASE + 0xFF,
  366. .flags = IORESOURCE_MEM,
  367. },
  368. [1] = {
  369. .start = CH_SPI1,
  370. .end = CH_SPI1,
  371. .flags = IORESOURCE_DMA,
  372. },
  373. [2] = {
  374. .start = IRQ_SPI1,
  375. .end = IRQ_SPI1,
  376. .flags = IORESOURCE_IRQ,
  377. },
  378. };
  379. static struct platform_device bfin_spi1_device = {
  380. .name = "bfin-spi",
  381. .id = 1, /* Bus number */
  382. .num_resources = ARRAY_SIZE(bfin_spi1_resource),
  383. .resource = bfin_spi1_resource,
  384. .dev = {
  385. .platform_data = &bfin_spi1_info, /* Passed to driver */
  386. },
  387. };
  388. #endif /* spi master and devices */
  389. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  390. #ifdef CONFIG_SERIAL_BFIN_UART0
  391. static struct resource bfin_uart0_resources[] = {
  392. {
  393. .start = UART0_THR,
  394. .end = UART0_GCTL+2,
  395. .flags = IORESOURCE_MEM,
  396. },
  397. {
  398. .start = IRQ_UART0_RX,
  399. .end = IRQ_UART0_RX+1,
  400. .flags = IORESOURCE_IRQ,
  401. },
  402. {
  403. .start = IRQ_UART0_ERROR,
  404. .end = IRQ_UART0_ERROR,
  405. .flags = IORESOURCE_IRQ,
  406. },
  407. {
  408. .start = CH_UART0_TX,
  409. .end = CH_UART0_TX,
  410. .flags = IORESOURCE_DMA,
  411. },
  412. {
  413. .start = CH_UART0_RX,
  414. .end = CH_UART0_RX,
  415. .flags = IORESOURCE_DMA,
  416. },
  417. };
  418. unsigned short bfin_uart0_peripherals[] = {
  419. P_UART0_TX, P_UART0_RX, 0
  420. };
  421. static struct platform_device bfin_uart0_device = {
  422. .name = "bfin-uart",
  423. .id = 0,
  424. .num_resources = ARRAY_SIZE(bfin_uart0_resources),
  425. .resource = bfin_uart0_resources,
  426. .dev = {
  427. .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
  428. },
  429. };
  430. #endif
  431. #ifdef CONFIG_SERIAL_BFIN_UART1
  432. static struct resource bfin_uart1_resources[] = {
  433. {
  434. .start = UART1_THR,
  435. .end = UART1_GCTL+2,
  436. .flags = IORESOURCE_MEM,
  437. },
  438. {
  439. .start = IRQ_UART1_RX,
  440. .end = IRQ_UART1_RX+1,
  441. .flags = IORESOURCE_IRQ,
  442. },
  443. {
  444. .start = IRQ_UART1_ERROR,
  445. .end = IRQ_UART1_ERROR,
  446. .flags = IORESOURCE_IRQ,
  447. },
  448. {
  449. .start = CH_UART1_TX,
  450. .end = CH_UART1_TX,
  451. .flags = IORESOURCE_DMA,
  452. },
  453. {
  454. .start = CH_UART1_RX,
  455. .end = CH_UART1_RX,
  456. .flags = IORESOURCE_DMA,
  457. },
  458. };
  459. unsigned short bfin_uart1_peripherals[] = {
  460. P_UART1_TX, P_UART1_RX, 0
  461. };
  462. static struct platform_device bfin_uart1_device = {
  463. .name = "bfin-uart",
  464. .id = 1,
  465. .num_resources = ARRAY_SIZE(bfin_uart1_resources),
  466. .resource = bfin_uart1_resources,
  467. .dev = {
  468. .platform_data = &bfin_uart1_peripherals, /* Passed to driver */
  469. },
  470. };
  471. #endif
  472. #endif
  473. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  474. #ifdef CONFIG_BFIN_SIR0
  475. static struct resource bfin_sir0_resources[] = {
  476. {
  477. .start = 0xFFC00400,
  478. .end = 0xFFC004FF,
  479. .flags = IORESOURCE_MEM,
  480. },
  481. {
  482. .start = IRQ_UART0_RX,
  483. .end = IRQ_UART0_RX+1,
  484. .flags = IORESOURCE_IRQ,
  485. },
  486. {
  487. .start = CH_UART0_RX,
  488. .end = CH_UART0_RX+1,
  489. .flags = IORESOURCE_DMA,
  490. },
  491. };
  492. static struct platform_device bfin_sir0_device = {
  493. .name = "bfin_sir",
  494. .id = 0,
  495. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  496. .resource = bfin_sir0_resources,
  497. };
  498. #endif
  499. #ifdef CONFIG_BFIN_SIR1
  500. static struct resource bfin_sir1_resources[] = {
  501. {
  502. .start = 0xFFC02000,
  503. .end = 0xFFC020FF,
  504. .flags = IORESOURCE_MEM,
  505. },
  506. {
  507. .start = IRQ_UART1_RX,
  508. .end = IRQ_UART1_RX+1,
  509. .flags = IORESOURCE_IRQ,
  510. },
  511. {
  512. .start = CH_UART1_RX,
  513. .end = CH_UART1_RX+1,
  514. .flags = IORESOURCE_DMA,
  515. },
  516. };
  517. static struct platform_device bfin_sir1_device = {
  518. .name = "bfin_sir",
  519. .id = 1,
  520. .num_resources = ARRAY_SIZE(bfin_sir1_resources),
  521. .resource = bfin_sir1_resources,
  522. };
  523. #endif
  524. #endif
  525. #if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
  526. static struct platform_device bfin_i2s = {
  527. .name = "bfin-i2s",
  528. .id = CONFIG_SND_BF5XX_SPORT_NUM,
  529. /* TODO: add platform data here */
  530. };
  531. #endif
  532. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  533. static struct resource bfin_twi0_resource[] = {
  534. [0] = {
  535. .start = TWI0_REGBASE,
  536. .end = TWI0_REGBASE,
  537. .flags = IORESOURCE_MEM,
  538. },
  539. [1] = {
  540. .start = IRQ_TWI,
  541. .end = IRQ_TWI,
  542. .flags = IORESOURCE_IRQ,
  543. },
  544. };
  545. static struct platform_device i2c_bfin_twi_device = {
  546. .name = "i2c-bfin-twi",
  547. .id = 0,
  548. .num_resources = ARRAY_SIZE(bfin_twi0_resource),
  549. .resource = bfin_twi0_resource,
  550. };
  551. #endif
  552. static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
  553. #if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
  554. {
  555. I2C_BOARD_INFO("pcf8574_lcd", 0x22),
  556. },
  557. #endif
  558. #if defined(CONFIG_INPUT_PCF8574) || defined(CONFIG_INPUT_PCF8574_MODULE)
  559. {
  560. I2C_BOARD_INFO("pcf8574_keypad", 0x27),
  561. .irq = IRQ_PF8,
  562. },
  563. #endif
  564. #if defined(CONFIG_SND_SOC_SSM2602) || defined(CONFIG_SND_SOC_SSM2602_MODULE)
  565. {
  566. I2C_BOARD_INFO("ssm2602", 0x1b),
  567. },
  568. #endif
  569. };
  570. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  571. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  572. static struct resource bfin_sport0_uart_resources[] = {
  573. {
  574. .start = SPORT0_TCR1,
  575. .end = SPORT0_MRCS3+4,
  576. .flags = IORESOURCE_MEM,
  577. },
  578. {
  579. .start = IRQ_SPORT0_RX,
  580. .end = IRQ_SPORT0_RX+1,
  581. .flags = IORESOURCE_IRQ,
  582. },
  583. {
  584. .start = IRQ_SPORT0_ERROR,
  585. .end = IRQ_SPORT0_ERROR,
  586. .flags = IORESOURCE_IRQ,
  587. },
  588. };
  589. unsigned short bfin_sport0_peripherals[] = {
  590. P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
  591. P_SPORT0_DRPRI, P_SPORT0_RSCLK, 0
  592. };
  593. static struct platform_device bfin_sport0_uart_device = {
  594. .name = "bfin-sport-uart",
  595. .id = 0,
  596. .num_resources = ARRAY_SIZE(bfin_sport0_uart_resources),
  597. .resource = bfin_sport0_uart_resources,
  598. .dev = {
  599. .platform_data = &bfin_sport0_peripherals, /* Passed to driver */
  600. },
  601. };
  602. #endif
  603. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  604. static struct resource bfin_sport1_uart_resources[] = {
  605. {
  606. .start = SPORT1_TCR1,
  607. .end = SPORT1_MRCS3+4,
  608. .flags = IORESOURCE_MEM,
  609. },
  610. {
  611. .start = IRQ_SPORT1_RX,
  612. .end = IRQ_SPORT1_RX+1,
  613. .flags = IORESOURCE_IRQ,
  614. },
  615. {
  616. .start = IRQ_SPORT1_ERROR,
  617. .end = IRQ_SPORT1_ERROR,
  618. .flags = IORESOURCE_IRQ,
  619. },
  620. };
  621. unsigned short bfin_sport1_peripherals[] = {
  622. P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
  623. P_SPORT1_DRPRI, P_SPORT1_RSCLK, 0
  624. };
  625. static struct platform_device bfin_sport1_uart_device = {
  626. .name = "bfin-sport-uart",
  627. .id = 1,
  628. .num_resources = ARRAY_SIZE(bfin_sport1_uart_resources),
  629. .resource = bfin_sport1_uart_resources,
  630. .dev = {
  631. .platform_data = &bfin_sport1_peripherals, /* Passed to driver */
  632. },
  633. };
  634. #endif
  635. #endif
  636. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  637. #include <linux/input.h>
  638. #include <linux/gpio_keys.h>
  639. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  640. {BTN_0, GPIO_PG0, 1, "gpio-keys: BTN0"},
  641. {BTN_1, GPIO_PG13, 1, "gpio-keys: BTN1"},
  642. };
  643. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  644. .buttons = bfin_gpio_keys_table,
  645. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  646. };
  647. static struct platform_device bfin_device_gpiokeys = {
  648. .name = "gpio-keys",
  649. .dev = {
  650. .platform_data = &bfin_gpio_keys_data,
  651. },
  652. };
  653. #endif
  654. #if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN_MODULE)
  655. static struct bfin_sd_host bfin_sdh_data = {
  656. .dma_chan = CH_RSI,
  657. .irq_int0 = IRQ_RSI_INT0,
  658. .pin_req = {P_RSI_DATA0, P_RSI_DATA1, P_RSI_DATA2, P_RSI_DATA3, P_RSI_CMD, P_RSI_CLK, 0},
  659. };
  660. static struct platform_device bf51x_sdh_device = {
  661. .name = "bfin-sdh",
  662. .id = 0,
  663. .dev = {
  664. .platform_data = &bfin_sdh_data,
  665. },
  666. };
  667. #endif
  668. static const unsigned int cclk_vlev_datasheet[] =
  669. {
  670. VRPAIR(VLEV_100, 400000000),
  671. VRPAIR(VLEV_105, 426000000),
  672. VRPAIR(VLEV_110, 500000000),
  673. VRPAIR(VLEV_115, 533000000),
  674. VRPAIR(VLEV_120, 600000000),
  675. };
  676. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  677. .tuple_tab = cclk_vlev_datasheet,
  678. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  679. .vr_settling_time = 25 /* us */,
  680. };
  681. static struct platform_device bfin_dpmc = {
  682. .name = "bfin dpmc",
  683. .dev = {
  684. .platform_data = &bfin_dmpc_vreg_data,
  685. },
  686. };
  687. static struct platform_device *stamp_devices[] __initdata = {
  688. &bfin_dpmc,
  689. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  690. &rtc_device,
  691. #endif
  692. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  693. &bfin_mii_bus,
  694. &bfin_mac_device,
  695. #if defined(CONFIG_NET_DSA_KSZ8893M) || defined(CONFIG_NET_DSA_KSZ8893M_MODULE)
  696. &ksz8893m_switch_device,
  697. #endif
  698. #endif
  699. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  700. &bfin_spi0_device,
  701. &bfin_spi1_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_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  712. #ifdef CONFIG_BFIN_SIR0
  713. &bfin_sir0_device,
  714. #endif
  715. #ifdef CONFIG_BFIN_SIR1
  716. &bfin_sir1_device,
  717. #endif
  718. #endif
  719. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  720. &i2c_bfin_twi_device,
  721. #endif
  722. #if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
  723. &bfin_i2s,
  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_SDH_BFIN) || defined(CONFIG_SDH_BFIN_MODULE)
  737. &bf51x_sdh_device,
  738. #endif
  739. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  740. &ezbrd_flash_device,
  741. #endif
  742. };
  743. static int __init ezbrd_init(void)
  744. {
  745. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  746. i2c_register_board_info(0, bfin_i2c_board_info,
  747. ARRAY_SIZE(bfin_i2c_board_info));
  748. platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
  749. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  750. /* setup BF518-EZBRD GPIO pin PG11 to AMS2, PG15 to AMS3. */
  751. peripheral_request(P_AMS2, "ParaFlash");
  752. #if !defined(CONFIG_SPI_BFIN) && !defined(CONFIG_SPI_BFIN_MODULE)
  753. peripheral_request(P_AMS3, "ParaFlash");
  754. #endif
  755. return 0;
  756. }
  757. arch_initcall(ezbrd_init);
  758. static struct platform_device *ezbrd_early_devices[] __initdata = {
  759. #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
  760. #ifdef CONFIG_SERIAL_BFIN_UART0
  761. &bfin_uart0_device,
  762. #endif
  763. #ifdef CONFIG_SERIAL_BFIN_UART1
  764. &bfin_uart1_device,
  765. #endif
  766. #endif
  767. #if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
  768. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  769. &bfin_sport0_uart_device,
  770. #endif
  771. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  772. &bfin_sport1_uart_device,
  773. #endif
  774. #endif
  775. };
  776. void __init native_machine_early_platform_add_devices(void)
  777. {
  778. printk(KERN_INFO "register early platform devices\n");
  779. early_platform_add_devices(ezbrd_early_devices,
  780. ARRAY_SIZE(ezbrd_early_devices));
  781. }
  782. void native_machine_restart(char *cmd)
  783. {
  784. /* workaround reboot hang when booting from SPI */
  785. if ((bfin_read_SYSCR() & 0x7) == 0x3)
  786. bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
  787. }
  788. void bfin_get_ether_addr(char *addr)
  789. {
  790. /* the MAC is stored in OTP memory page 0xDF */
  791. u32 ret;
  792. u64 otp_mac;
  793. u32 (*otp_read)(u32 page, u32 flags, u64 *page_content) = (void *)0xEF00001A;
  794. ret = otp_read(0xDF, 0x00, &otp_mac);
  795. if (!(ret & 0x1)) {
  796. char *otp_mac_p = (char *)&otp_mac;
  797. for (ret = 0; ret < 6; ++ret)
  798. addr[ret] = otp_mac_p[5 - ret];
  799. }
  800. }
  801. EXPORT_SYMBOL(bfin_get_ether_addr);