ezbrd.c 22 KB

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