ezbrd.c 19 KB

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