ezbrd.c 22 KB

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