ezbrd.c 22 KB

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