ezbrd.c 22 KB

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