ezbrd.c 22 KB

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