ezbrd.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794
  1. /*
  2. * File: arch/blackfin/mach-bf527/boards/ezbrd.c
  3. * Based on: arch/blackfin/mach-bf537/boards/stamp.c
  4. * Author: Aidan Williams <aidan@nicta.com.au>
  5. *
  6. * Created:
  7. * Description:
  8. *
  9. * Modified:
  10. * Copyright 2005 National ICT Australia (NICTA)
  11. * Copyright 2004-2008 Analog Devices Inc.
  12. *
  13. * Bugs: Enter bugs at http://blackfin.uclinux.org/
  14. *
  15. * This program is free software; you can redistribute it and/or modify
  16. * it under the terms of the GNU General Public License as published by
  17. * the Free Software Foundation; either version 2 of the License, or
  18. * (at your option) any later version.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU General Public License
  26. * along with this program; if not, see the file COPYING, or write
  27. * to the Free Software Foundation, Inc.,
  28. * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  29. */
  30. #include <linux/device.h>
  31. #include <linux/platform_device.h>
  32. #include <linux/mtd/mtd.h>
  33. #include <linux/mtd/partitions.h>
  34. #include <linux/mtd/physmap.h>
  35. #include <linux/spi/spi.h>
  36. #include <linux/spi/flash.h>
  37. #include <linux/i2c.h>
  38. #include <linux/irq.h>
  39. #include <linux/interrupt.h>
  40. #include <linux/usb/musb.h>
  41. #include <asm/dma.h>
  42. #include <asm/bfin5xx_spi.h>
  43. #include <asm/reboot.h>
  44. #include <asm/nand.h>
  45. #include <asm/portmux.h>
  46. #include <asm/dpmc.h>
  47. #include <linux/spi/ad7877.h>
  48. /*
  49. * Name the Board for the /proc/cpuinfo
  50. */
  51. const char bfin_board_name[] = "ADI BF526-EZBRD";
  52. /*
  53. * Driver needs to know address, irq and flag pin.
  54. */
  55. #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
  56. static struct resource musb_resources[] = {
  57. [0] = {
  58. .start = 0xffc03800,
  59. .end = 0xffc03cff,
  60. .flags = IORESOURCE_MEM,
  61. },
  62. [1] = { /* general IRQ */
  63. .start = IRQ_USB_INT0,
  64. .end = IRQ_USB_INT0,
  65. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  66. },
  67. [2] = { /* DMA IRQ */
  68. .start = IRQ_USB_DMA,
  69. .end = IRQ_USB_DMA,
  70. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  71. },
  72. };
  73. static struct musb_hdrc_config musb_config = {
  74. .multipoint = 0,
  75. .dyn_fifo = 0,
  76. .soft_con = 1,
  77. .dma = 1,
  78. .num_eps = 8,
  79. .dma_channels = 8,
  80. .gpio_vrsel = GPIO_PG13,
  81. };
  82. static struct musb_hdrc_platform_data musb_plat = {
  83. #if defined(CONFIG_USB_MUSB_OTG)
  84. .mode = MUSB_OTG,
  85. #elif defined(CONFIG_USB_MUSB_HDRC_HCD)
  86. .mode = MUSB_HOST,
  87. #elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
  88. .mode = MUSB_PERIPHERAL,
  89. #endif
  90. .config = &musb_config,
  91. };
  92. static u64 musb_dmamask = ~(u32)0;
  93. static struct platform_device musb_device = {
  94. .name = "musb_hdrc",
  95. .id = 0,
  96. .dev = {
  97. .dma_mask = &musb_dmamask,
  98. .coherent_dma_mask = 0xffffffff,
  99. .platform_data = &musb_plat,
  100. },
  101. .num_resources = ARRAY_SIZE(musb_resources),
  102. .resource = musb_resources,
  103. };
  104. #endif
  105. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  106. static struct mtd_partition ezbrd_partitions[] = {
  107. {
  108. .name = "bootloader(nor)",
  109. .size = 0x40000,
  110. .offset = 0,
  111. }, {
  112. .name = "linux kernel(nor)",
  113. .size = 0x1C0000,
  114. .offset = MTDPART_OFS_APPEND,
  115. }, {
  116. .name = "file system(nor)",
  117. .size = MTDPART_SIZ_FULL,
  118. .offset = MTDPART_OFS_APPEND,
  119. }
  120. };
  121. static struct physmap_flash_data ezbrd_flash_data = {
  122. .width = 2,
  123. .parts = ezbrd_partitions,
  124. .nr_parts = ARRAY_SIZE(ezbrd_partitions),
  125. };
  126. static struct resource ezbrd_flash_resource = {
  127. .start = 0x20000000,
  128. .end = 0x203fffff,
  129. .flags = IORESOURCE_MEM,
  130. };
  131. static struct platform_device ezbrd_flash_device = {
  132. .name = "physmap-flash",
  133. .id = 0,
  134. .dev = {
  135. .platform_data = &ezbrd_flash_data,
  136. },
  137. .num_resources = 1,
  138. .resource = &ezbrd_flash_resource,
  139. };
  140. #endif
  141. #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
  142. static struct mtd_partition partition_info[] = {
  143. {
  144. .name = "linux kernel(nand)",
  145. .offset = 0,
  146. .size = 4 * 1024 * 1024,
  147. },
  148. {
  149. .name = "file system(nand)",
  150. .offset = MTDPART_OFS_APPEND,
  151. .size = MTDPART_SIZ_FULL,
  152. },
  153. };
  154. static struct bf5xx_nand_platform bf5xx_nand_platform = {
  155. .page_size = NFC_PG_SIZE_256,
  156. .data_width = NFC_NWIDTH_8,
  157. .partitions = partition_info,
  158. .nr_partitions = ARRAY_SIZE(partition_info),
  159. .rd_dly = 3,
  160. .wr_dly = 3,
  161. };
  162. static struct resource bf5xx_nand_resources[] = {
  163. {
  164. .start = NFC_CTL,
  165. .end = NFC_DATA_RD + 2,
  166. .flags = IORESOURCE_MEM,
  167. },
  168. {
  169. .start = CH_NFC,
  170. .end = CH_NFC,
  171. .flags = IORESOURCE_IRQ,
  172. },
  173. };
  174. static struct platform_device bf5xx_nand_device = {
  175. .name = "bf5xx-nand",
  176. .id = 0,
  177. .num_resources = ARRAY_SIZE(bf5xx_nand_resources),
  178. .resource = bf5xx_nand_resources,
  179. .dev = {
  180. .platform_data = &bf5xx_nand_platform,
  181. },
  182. };
  183. #endif
  184. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  185. static struct platform_device rtc_device = {
  186. .name = "rtc-bfin",
  187. .id = -1,
  188. };
  189. #endif
  190. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  191. static struct platform_device bfin_mii_bus = {
  192. .name = "bfin_mii_bus",
  193. };
  194. static struct platform_device bfin_mac_device = {
  195. .name = "bfin_mac",
  196. .dev.platform_data = &bfin_mii_bus,
  197. };
  198. #endif
  199. #if defined(CONFIG_MTD_M25P80) \
  200. || defined(CONFIG_MTD_M25P80_MODULE)
  201. static struct mtd_partition bfin_spi_flash_partitions[] = {
  202. {
  203. .name = "bootloader(spi)",
  204. .size = 0x00040000,
  205. .offset = 0,
  206. .mask_flags = MTD_CAP_ROM
  207. }, {
  208. .name = "linux kernel(spi)",
  209. .size = MTDPART_SIZ_FULL,
  210. .offset = MTDPART_OFS_APPEND,
  211. }
  212. };
  213. static struct flash_platform_data bfin_spi_flash_data = {
  214. .name = "m25p80",
  215. .parts = bfin_spi_flash_partitions,
  216. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  217. .type = "m25p16",
  218. };
  219. /* SPI flash chip (m25p64) */
  220. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  221. .enable_dma = 0, /* use dma transfer with this chip*/
  222. .bits_per_word = 8,
  223. };
  224. #endif
  225. #if defined(CONFIG_SPI_ADC_BF533) \
  226. || defined(CONFIG_SPI_ADC_BF533_MODULE)
  227. /* SPI ADC chip */
  228. static struct bfin5xx_spi_chip spi_adc_chip_info = {
  229. .enable_dma = 1, /* use dma transfer with this chip*/
  230. .bits_per_word = 16,
  231. };
  232. #endif
  233. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  234. static struct bfin5xx_spi_chip mmc_spi_chip_info = {
  235. .enable_dma = 0,
  236. .bits_per_word = 8,
  237. };
  238. #endif
  239. #if defined(CONFIG_PBX)
  240. static struct bfin5xx_spi_chip spi_si3xxx_chip_info = {
  241. .ctl_reg = 0x4, /* send zero */
  242. .enable_dma = 0,
  243. .bits_per_word = 8,
  244. .cs_change_per_word = 1,
  245. };
  246. #endif
  247. #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
  248. static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
  249. .enable_dma = 0,
  250. .bits_per_word = 16,
  251. };
  252. static const struct ad7877_platform_data bfin_ad7877_ts_info = {
  253. .model = 7877,
  254. .vref_delay_usecs = 50, /* internal, no capacitor */
  255. .x_plate_ohms = 419,
  256. .y_plate_ohms = 486,
  257. .pressure_max = 1000,
  258. .pressure_min = 0,
  259. .stopacq_polarity = 1,
  260. .first_conversion_delay = 3,
  261. .acquisition_time = 1,
  262. .averaging = 1,
  263. .pen_down_acc_interval = 1,
  264. };
  265. #endif
  266. #if defined(CONFIG_TOUCHSCREEN_AD7879) || defined(CONFIG_TOUCHSCREEN_AD7879_MODULE)
  267. #include <linux/spi/ad7879.h>
  268. static const struct ad7879_platform_data bfin_ad7879_ts_info = {
  269. .model = 7879, /* Model = AD7879 */
  270. .x_plate_ohms = 620, /* 620 Ohm from the touch datasheet */
  271. .pressure_max = 10000,
  272. .pressure_min = 0,
  273. .first_conversion_delay = 3, /* wait 512us before do a first conversion */
  274. .acquisition_time = 1, /* 4us acquisition time per sample */
  275. .median = 2, /* do 8 measurements */
  276. .averaging = 1, /* take the average of 4 middle samples */
  277. .pen_down_acc_interval = 255, /* 9.4 ms */
  278. .gpio_output = 1, /* configure AUX/VBAT/GPIO as GPIO output */
  279. .gpio_default = 1, /* During initialization set GPIO = HIGH */
  280. };
  281. #endif
  282. #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
  283. static struct bfin5xx_spi_chip spi_ad7879_chip_info = {
  284. .enable_dma = 0,
  285. .bits_per_word = 16,
  286. };
  287. #endif
  288. #if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
  289. && defined(CONFIG_SND_SOC_WM8731_SPI)
  290. static struct bfin5xx_spi_chip spi_wm8731_chip_info = {
  291. .enable_dma = 0,
  292. .bits_per_word = 16,
  293. };
  294. #endif
  295. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  296. static struct bfin5xx_spi_chip spidev_chip_info = {
  297. .enable_dma = 0,
  298. .bits_per_word = 8,
  299. };
  300. #endif
  301. #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
  302. static struct bfin5xx_spi_chip lq035q1_spi_chip_info = {
  303. .enable_dma = 0,
  304. .bits_per_word = 8,
  305. };
  306. #endif
  307. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  308. #if defined(CONFIG_MTD_M25P80) \
  309. || defined(CONFIG_MTD_M25P80_MODULE)
  310. {
  311. /* the modalias must be the same as spi device driver name */
  312. .modalias = "m25p80", /* Name of spi_driver for this device */
  313. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  314. .bus_num = 0, /* Framework bus number */
  315. .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
  316. .platform_data = &bfin_spi_flash_data,
  317. .controller_data = &spi_flash_chip_info,
  318. .mode = SPI_MODE_3,
  319. },
  320. #endif
  321. #if defined(CONFIG_SPI_ADC_BF533) \
  322. || defined(CONFIG_SPI_ADC_BF533_MODULE)
  323. {
  324. .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
  325. .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
  326. .bus_num = 0, /* Framework bus number */
  327. .chip_select = 1, /* Framework chip select. */
  328. .platform_data = NULL, /* No spi_driver specific config */
  329. .controller_data = &spi_adc_chip_info,
  330. },
  331. #endif
  332. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  333. {
  334. .modalias = "mmc_spi",
  335. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  336. .bus_num = 0,
  337. .chip_select = 5,
  338. .controller_data = &mmc_spi_chip_info,
  339. .mode = SPI_MODE_3,
  340. },
  341. #endif
  342. #if defined(CONFIG_PBX)
  343. {
  344. .modalias = "fxs-spi",
  345. .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
  346. .bus_num = 0,
  347. .chip_select = 8 - CONFIG_J11_JUMPER,
  348. .controller_data = &spi_si3xxx_chip_info,
  349. .mode = SPI_MODE_3,
  350. },
  351. {
  352. .modalias = "fxo-spi",
  353. .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
  354. .bus_num = 0,
  355. .chip_select = 8 - CONFIG_J19_JUMPER,
  356. .controller_data = &spi_si3xxx_chip_info,
  357. .mode = SPI_MODE_3,
  358. },
  359. #endif
  360. #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
  361. {
  362. .modalias = "ad7877",
  363. .platform_data = &bfin_ad7877_ts_info,
  364. .irq = IRQ_PF8,
  365. .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
  366. .bus_num = 0,
  367. .chip_select = 2,
  368. .controller_data = &spi_ad7877_chip_info,
  369. },
  370. #endif
  371. #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
  372. {
  373. .modalias = "ad7879",
  374. .platform_data = &bfin_ad7879_ts_info,
  375. .irq = IRQ_PG0,
  376. .max_speed_hz = 5000000, /* max spi clock (SCK) speed in HZ */
  377. .bus_num = 0,
  378. .chip_select = 5,
  379. .controller_data = &spi_ad7879_chip_info,
  380. .mode = SPI_CPHA | SPI_CPOL,
  381. },
  382. #endif
  383. #if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
  384. && defined(CONFIG_SND_SOC_WM8731_SPI)
  385. {
  386. .modalias = "wm8731",
  387. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  388. .bus_num = 0,
  389. .chip_select = 5,
  390. .controller_data = &spi_wm8731_chip_info,
  391. .mode = SPI_MODE_0,
  392. },
  393. #endif
  394. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  395. {
  396. .modalias = "spidev",
  397. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  398. .bus_num = 0,
  399. .chip_select = 1,
  400. .controller_data = &spidev_chip_info,
  401. },
  402. #endif
  403. #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
  404. {
  405. .modalias = "bfin-lq035q1-spi",
  406. .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
  407. .bus_num = 0,
  408. .chip_select = 1,
  409. .controller_data = &lq035q1_spi_chip_info,
  410. .mode = SPI_CPHA | SPI_CPOL,
  411. },
  412. #endif
  413. };
  414. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  415. /* SPI controller data */
  416. static struct bfin5xx_spi_master bfin_spi0_info = {
  417. .num_chipselect = 8,
  418. .enable_dma = 1, /* master has the ability to do dma transfer */
  419. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  420. };
  421. /* SPI (0) */
  422. static struct resource bfin_spi0_resource[] = {
  423. [0] = {
  424. .start = SPI0_REGBASE,
  425. .end = SPI0_REGBASE + 0xFF,
  426. .flags = IORESOURCE_MEM,
  427. },
  428. [1] = {
  429. .start = CH_SPI,
  430. .end = CH_SPI,
  431. .flags = IORESOURCE_IRQ,
  432. },
  433. };
  434. static struct platform_device bfin_spi0_device = {
  435. .name = "bfin-spi",
  436. .id = 0, /* Bus number */
  437. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  438. .resource = bfin_spi0_resource,
  439. .dev = {
  440. .platform_data = &bfin_spi0_info, /* Passed to driver */
  441. },
  442. };
  443. #endif /* spi master and devices */
  444. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  445. static struct resource bfin_uart_resources[] = {
  446. #ifdef CONFIG_SERIAL_BFIN_UART0
  447. {
  448. .start = 0xFFC00400,
  449. .end = 0xFFC004FF,
  450. .flags = IORESOURCE_MEM,
  451. },
  452. #endif
  453. #ifdef CONFIG_SERIAL_BFIN_UART1
  454. {
  455. .start = 0xFFC02000,
  456. .end = 0xFFC020FF,
  457. .flags = IORESOURCE_MEM,
  458. },
  459. #endif
  460. };
  461. static struct platform_device bfin_uart_device = {
  462. .name = "bfin-uart",
  463. .id = 1,
  464. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  465. .resource = bfin_uart_resources,
  466. };
  467. #endif
  468. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  469. #ifdef CONFIG_BFIN_SIR0
  470. static struct resource bfin_sir0_resources[] = {
  471. {
  472. .start = 0xFFC00400,
  473. .end = 0xFFC004FF,
  474. .flags = IORESOURCE_MEM,
  475. },
  476. {
  477. .start = IRQ_UART0_RX,
  478. .end = IRQ_UART0_RX+1,
  479. .flags = IORESOURCE_IRQ,
  480. },
  481. {
  482. .start = CH_UART0_RX,
  483. .end = CH_UART0_RX+1,
  484. .flags = IORESOURCE_DMA,
  485. },
  486. };
  487. static struct platform_device bfin_sir0_device = {
  488. .name = "bfin_sir",
  489. .id = 0,
  490. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  491. .resource = bfin_sir0_resources,
  492. };
  493. #endif
  494. #ifdef CONFIG_BFIN_SIR1
  495. static struct resource bfin_sir1_resources[] = {
  496. {
  497. .start = 0xFFC02000,
  498. .end = 0xFFC020FF,
  499. .flags = IORESOURCE_MEM,
  500. },
  501. {
  502. .start = IRQ_UART1_RX,
  503. .end = IRQ_UART1_RX+1,
  504. .flags = IORESOURCE_IRQ,
  505. },
  506. {
  507. .start = CH_UART1_RX,
  508. .end = CH_UART1_RX+1,
  509. .flags = IORESOURCE_DMA,
  510. },
  511. };
  512. static struct platform_device bfin_sir1_device = {
  513. .name = "bfin_sir",
  514. .id = 1,
  515. .num_resources = ARRAY_SIZE(bfin_sir1_resources),
  516. .resource = bfin_sir1_resources,
  517. };
  518. #endif
  519. #endif
  520. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  521. static struct resource bfin_twi0_resource[] = {
  522. [0] = {
  523. .start = TWI0_REGBASE,
  524. .end = TWI0_REGBASE,
  525. .flags = IORESOURCE_MEM,
  526. },
  527. [1] = {
  528. .start = IRQ_TWI,
  529. .end = IRQ_TWI,
  530. .flags = IORESOURCE_IRQ,
  531. },
  532. };
  533. static struct platform_device i2c_bfin_twi_device = {
  534. .name = "i2c-bfin-twi",
  535. .id = 0,
  536. .num_resources = ARRAY_SIZE(bfin_twi0_resource),
  537. .resource = bfin_twi0_resource,
  538. };
  539. #endif
  540. static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
  541. #if defined(CONFIG_TWI_LCD) || defined(CONFIG_TWI_LCD_MODULE)
  542. {
  543. I2C_BOARD_INFO("pcf8574_lcd", 0x22),
  544. },
  545. #endif
  546. #if defined(CONFIG_TWI_KEYPAD) || defined(CONFIG_TWI_KEYPAD_MODULE)
  547. {
  548. I2C_BOARD_INFO("pcf8574_keypad", 0x27),
  549. .irq = IRQ_PF8,
  550. },
  551. #endif
  552. };
  553. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  554. static struct platform_device bfin_sport0_uart_device = {
  555. .name = "bfin-sport-uart",
  556. .id = 0,
  557. };
  558. static struct platform_device bfin_sport1_uart_device = {
  559. .name = "bfin-sport-uart",
  560. .id = 1,
  561. };
  562. #endif
  563. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  564. #include <linux/input.h>
  565. #include <linux/gpio_keys.h>
  566. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  567. {BTN_0, GPIO_PG0, 1, "gpio-keys: BTN0"},
  568. {BTN_1, GPIO_PG13, 1, "gpio-keys: BTN1"},
  569. };
  570. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  571. .buttons = bfin_gpio_keys_table,
  572. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  573. };
  574. static struct platform_device bfin_device_gpiokeys = {
  575. .name = "gpio-keys",
  576. .dev = {
  577. .platform_data = &bfin_gpio_keys_data,
  578. },
  579. };
  580. #endif
  581. static struct resource bfin_gpios_resources = {
  582. .start = 0,
  583. .end = MAX_BLACKFIN_GPIOS - 1,
  584. .flags = IORESOURCE_IRQ,
  585. };
  586. static struct platform_device bfin_gpios_device = {
  587. .name = "simple-gpio",
  588. .id = -1,
  589. .num_resources = 1,
  590. .resource = &bfin_gpios_resources,
  591. };
  592. static const unsigned int cclk_vlev_datasheet[] =
  593. {
  594. VRPAIR(VLEV_100, 400000000),
  595. VRPAIR(VLEV_105, 426000000),
  596. VRPAIR(VLEV_110, 500000000),
  597. VRPAIR(VLEV_115, 533000000),
  598. VRPAIR(VLEV_120, 600000000),
  599. };
  600. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  601. .tuple_tab = cclk_vlev_datasheet,
  602. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  603. .vr_settling_time = 25 /* us */,
  604. };
  605. static struct platform_device bfin_dpmc = {
  606. .name = "bfin dpmc",
  607. .dev = {
  608. .platform_data = &bfin_dmpc_vreg_data,
  609. },
  610. };
  611. #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
  612. #include <asm/bfin-lq035q1.h>
  613. static struct bfin_lq035q1fb_disp_info bfin_lq035q1_data = {
  614. .mode = LQ035_NORM | LQ035_RGB | LQ035_RL | LQ035_TB,
  615. .use_bl = 1,
  616. .gpio_bl = GPIO_PG12,
  617. };
  618. static struct resource bfin_lq035q1_resources[] = {
  619. {
  620. .start = IRQ_PPI_ERROR,
  621. .end = IRQ_PPI_ERROR,
  622. .flags = IORESOURCE_IRQ,
  623. },
  624. };
  625. static struct platform_device bfin_lq035q1_device = {
  626. .name = "bfin-lq035q1",
  627. .id = -1,
  628. .num_resources = ARRAY_SIZE(bfin_lq035q1_resources),
  629. .resource = bfin_lq035q1_resources,
  630. .dev = {
  631. .platform_data = &bfin_lq035q1_data,
  632. },
  633. };
  634. #endif
  635. static struct platform_device *stamp_devices[] __initdata = {
  636. &bfin_dpmc,
  637. #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
  638. &bf5xx_nand_device,
  639. #endif
  640. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  641. &rtc_device,
  642. #endif
  643. #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
  644. &musb_device,
  645. #endif
  646. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  647. &bfin_mii_bus,
  648. &bfin_mac_device,
  649. #endif
  650. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  651. &bfin_spi0_device,
  652. #endif
  653. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  654. &bfin_uart_device,
  655. #endif
  656. #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
  657. &bfin_lq035q1_device,
  658. #endif
  659. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  660. #ifdef CONFIG_BFIN_SIR0
  661. &bfin_sir0_device,
  662. #endif
  663. #ifdef CONFIG_BFIN_SIR1
  664. &bfin_sir1_device,
  665. #endif
  666. #endif
  667. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  668. &i2c_bfin_twi_device,
  669. #endif
  670. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  671. &bfin_sport0_uart_device,
  672. &bfin_sport1_uart_device,
  673. #endif
  674. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  675. &bfin_device_gpiokeys,
  676. #endif
  677. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  678. &ezbrd_flash_device,
  679. #endif
  680. &bfin_gpios_device,
  681. };
  682. static int __init ezbrd_init(void)
  683. {
  684. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  685. i2c_register_board_info(0, bfin_i2c_board_info,
  686. ARRAY_SIZE(bfin_i2c_board_info));
  687. platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
  688. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  689. return 0;
  690. }
  691. arch_initcall(ezbrd_init);
  692. void native_machine_restart(char *cmd)
  693. {
  694. /* workaround reboot hang when booting from SPI */
  695. if ((bfin_read_SYSCR() & 0x7) == 0x3)
  696. bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
  697. }
  698. void bfin_get_ether_addr(char *addr)
  699. {
  700. /* the MAC is stored in OTP memory page 0xDF */
  701. u32 ret;
  702. u64 otp_mac;
  703. u32 (*otp_read)(u32 page, u32 flags, u64 *page_content) = (void *)0xEF00001A;
  704. ret = otp_read(0xDF, 0x00, &otp_mac);
  705. if (!(ret & 0x1)) {
  706. char *otp_mac_p = (char *)&otp_mac;
  707. for (ret = 0; ret < 6; ++ret)
  708. addr[ret] = otp_mac_p[5 - ret];
  709. }
  710. }
  711. EXPORT_SYMBOL(bfin_get_ether_addr);