ezbrd.c 19 KB

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