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