ezbrd.c 21 KB

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