ezbrd.c 22 KB

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