ezbrd.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804
  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_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
  234. static struct bfin5xx_spi_chip spi_mmc_chip_info = {
  235. .enable_dma = 1,
  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_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
  333. {
  334. .modalias = "spi_mmc_dummy",
  335. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  336. .bus_num = 0,
  337. .chip_select = 0,
  338. .platform_data = NULL,
  339. .controller_data = &spi_mmc_chip_info,
  340. .mode = SPI_MODE_3,
  341. },
  342. {
  343. .modalias = "spi_mmc",
  344. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  345. .bus_num = 0,
  346. .chip_select = CONFIG_SPI_MMC_CS_CHAN,
  347. .platform_data = NULL,
  348. .controller_data = &spi_mmc_chip_info,
  349. .mode = SPI_MODE_3,
  350. },
  351. #endif
  352. #if defined(CONFIG_PBX)
  353. {
  354. .modalias = "fxs-spi",
  355. .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
  356. .bus_num = 0,
  357. .chip_select = 8 - CONFIG_J11_JUMPER,
  358. .controller_data = &spi_si3xxx_chip_info,
  359. .mode = SPI_MODE_3,
  360. },
  361. {
  362. .modalias = "fxo-spi",
  363. .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
  364. .bus_num = 0,
  365. .chip_select = 8 - CONFIG_J19_JUMPER,
  366. .controller_data = &spi_si3xxx_chip_info,
  367. .mode = SPI_MODE_3,
  368. },
  369. #endif
  370. #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
  371. {
  372. .modalias = "ad7877",
  373. .platform_data = &bfin_ad7877_ts_info,
  374. .irq = IRQ_PF8,
  375. .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
  376. .bus_num = 0,
  377. .chip_select = 2,
  378. .controller_data = &spi_ad7877_chip_info,
  379. },
  380. #endif
  381. #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
  382. {
  383. .modalias = "ad7879",
  384. .platform_data = &bfin_ad7879_ts_info,
  385. .irq = IRQ_PG0,
  386. .max_speed_hz = 5000000, /* max spi clock (SCK) speed in HZ */
  387. .bus_num = 0,
  388. .chip_select = 5,
  389. .controller_data = &spi_ad7879_chip_info,
  390. .mode = SPI_CPHA | SPI_CPOL,
  391. },
  392. #endif
  393. #if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
  394. && defined(CONFIG_SND_SOC_WM8731_SPI)
  395. {
  396. .modalias = "wm8731",
  397. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  398. .bus_num = 0,
  399. .chip_select = 5,
  400. .controller_data = &spi_wm8731_chip_info,
  401. .mode = SPI_MODE_0,
  402. },
  403. #endif
  404. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  405. {
  406. .modalias = "spidev",
  407. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  408. .bus_num = 0,
  409. .chip_select = 1,
  410. .controller_data = &spidev_chip_info,
  411. },
  412. #endif
  413. #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
  414. {
  415. .modalias = "bfin-lq035q1-spi",
  416. .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
  417. .bus_num = 0,
  418. .chip_select = 1,
  419. .controller_data = &lq035q1_spi_chip_info,
  420. .mode = SPI_CPHA | SPI_CPOL,
  421. },
  422. #endif
  423. };
  424. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  425. /* SPI controller data */
  426. static struct bfin5xx_spi_master bfin_spi0_info = {
  427. .num_chipselect = 8,
  428. .enable_dma = 1, /* master has the ability to do dma transfer */
  429. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  430. };
  431. /* SPI (0) */
  432. static struct resource bfin_spi0_resource[] = {
  433. [0] = {
  434. .start = SPI0_REGBASE,
  435. .end = SPI0_REGBASE + 0xFF,
  436. .flags = IORESOURCE_MEM,
  437. },
  438. [1] = {
  439. .start = CH_SPI,
  440. .end = CH_SPI,
  441. .flags = IORESOURCE_IRQ,
  442. },
  443. };
  444. static struct platform_device bfin_spi0_device = {
  445. .name = "bfin-spi",
  446. .id = 0, /* Bus number */
  447. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  448. .resource = bfin_spi0_resource,
  449. .dev = {
  450. .platform_data = &bfin_spi0_info, /* Passed to driver */
  451. },
  452. };
  453. #endif /* spi master and devices */
  454. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  455. static struct resource bfin_uart_resources[] = {
  456. #ifdef CONFIG_SERIAL_BFIN_UART0
  457. {
  458. .start = 0xFFC00400,
  459. .end = 0xFFC004FF,
  460. .flags = IORESOURCE_MEM,
  461. },
  462. #endif
  463. #ifdef CONFIG_SERIAL_BFIN_UART1
  464. {
  465. .start = 0xFFC02000,
  466. .end = 0xFFC020FF,
  467. .flags = IORESOURCE_MEM,
  468. },
  469. #endif
  470. };
  471. static struct platform_device bfin_uart_device = {
  472. .name = "bfin-uart",
  473. .id = 1,
  474. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  475. .resource = bfin_uart_resources,
  476. };
  477. #endif
  478. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  479. #ifdef CONFIG_BFIN_SIR0
  480. static struct resource bfin_sir0_resources[] = {
  481. {
  482. .start = 0xFFC00400,
  483. .end = 0xFFC004FF,
  484. .flags = IORESOURCE_MEM,
  485. },
  486. {
  487. .start = IRQ_UART0_RX,
  488. .end = IRQ_UART0_RX+1,
  489. .flags = IORESOURCE_IRQ,
  490. },
  491. {
  492. .start = CH_UART0_RX,
  493. .end = CH_UART0_RX+1,
  494. .flags = IORESOURCE_DMA,
  495. },
  496. };
  497. static struct platform_device bfin_sir0_device = {
  498. .name = "bfin_sir",
  499. .id = 0,
  500. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  501. .resource = bfin_sir0_resources,
  502. };
  503. #endif
  504. #ifdef CONFIG_BFIN_SIR1
  505. static struct resource bfin_sir1_resources[] = {
  506. {
  507. .start = 0xFFC02000,
  508. .end = 0xFFC020FF,
  509. .flags = IORESOURCE_MEM,
  510. },
  511. {
  512. .start = IRQ_UART1_RX,
  513. .end = IRQ_UART1_RX+1,
  514. .flags = IORESOURCE_IRQ,
  515. },
  516. {
  517. .start = CH_UART1_RX,
  518. .end = CH_UART1_RX+1,
  519. .flags = IORESOURCE_DMA,
  520. },
  521. };
  522. static struct platform_device bfin_sir1_device = {
  523. .name = "bfin_sir",
  524. .id = 1,
  525. .num_resources = ARRAY_SIZE(bfin_sir1_resources),
  526. .resource = bfin_sir1_resources,
  527. };
  528. #endif
  529. #endif
  530. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  531. static struct resource bfin_twi0_resource[] = {
  532. [0] = {
  533. .start = TWI0_REGBASE,
  534. .end = TWI0_REGBASE,
  535. .flags = IORESOURCE_MEM,
  536. },
  537. [1] = {
  538. .start = IRQ_TWI,
  539. .end = IRQ_TWI,
  540. .flags = IORESOURCE_IRQ,
  541. },
  542. };
  543. static struct platform_device i2c_bfin_twi_device = {
  544. .name = "i2c-bfin-twi",
  545. .id = 0,
  546. .num_resources = ARRAY_SIZE(bfin_twi0_resource),
  547. .resource = bfin_twi0_resource,
  548. };
  549. #endif
  550. static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
  551. #if defined(CONFIG_TWI_LCD) || defined(CONFIG_TWI_LCD_MODULE)
  552. {
  553. I2C_BOARD_INFO("pcf8574_lcd", 0x22),
  554. },
  555. #endif
  556. #if defined(CONFIG_TWI_KEYPAD) || defined(CONFIG_TWI_KEYPAD_MODULE)
  557. {
  558. I2C_BOARD_INFO("pcf8574_keypad", 0x27),
  559. .irq = IRQ_PF8,
  560. },
  561. #endif
  562. };
  563. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  564. static struct platform_device bfin_sport0_uart_device = {
  565. .name = "bfin-sport-uart",
  566. .id = 0,
  567. };
  568. static struct platform_device bfin_sport1_uart_device = {
  569. .name = "bfin-sport-uart",
  570. .id = 1,
  571. };
  572. #endif
  573. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  574. #include <linux/input.h>
  575. #include <linux/gpio_keys.h>
  576. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  577. {BTN_0, GPIO_PG0, 1, "gpio-keys: BTN0"},
  578. {BTN_1, GPIO_PG13, 1, "gpio-keys: BTN1"},
  579. };
  580. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  581. .buttons = bfin_gpio_keys_table,
  582. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  583. };
  584. static struct platform_device bfin_device_gpiokeys = {
  585. .name = "gpio-keys",
  586. .dev = {
  587. .platform_data = &bfin_gpio_keys_data,
  588. },
  589. };
  590. #endif
  591. static struct resource bfin_gpios_resources = {
  592. .start = 0,
  593. .end = MAX_BLACKFIN_GPIOS - 1,
  594. .flags = IORESOURCE_IRQ,
  595. };
  596. static struct platform_device bfin_gpios_device = {
  597. .name = "simple-gpio",
  598. .id = -1,
  599. .num_resources = 1,
  600. .resource = &bfin_gpios_resources,
  601. };
  602. static const unsigned int cclk_vlev_datasheet[] =
  603. {
  604. VRPAIR(VLEV_100, 400000000),
  605. VRPAIR(VLEV_105, 426000000),
  606. VRPAIR(VLEV_110, 500000000),
  607. VRPAIR(VLEV_115, 533000000),
  608. VRPAIR(VLEV_120, 600000000),
  609. };
  610. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  611. .tuple_tab = cclk_vlev_datasheet,
  612. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  613. .vr_settling_time = 25 /* us */,
  614. };
  615. static struct platform_device bfin_dpmc = {
  616. .name = "bfin dpmc",
  617. .dev = {
  618. .platform_data = &bfin_dmpc_vreg_data,
  619. },
  620. };
  621. #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
  622. #include <asm/bfin-lq035q1.h>
  623. static struct bfin_lq035q1fb_disp_info bfin_lq035q1_data = {
  624. .mode = LQ035_NORM | LQ035_RGB | LQ035_RL | LQ035_TB,
  625. .use_bl = 1,
  626. .gpio_bl = GPIO_PG12,
  627. };
  628. static struct resource bfin_lq035q1_resources[] = {
  629. {
  630. .start = IRQ_PPI_ERROR,
  631. .end = IRQ_PPI_ERROR,
  632. .flags = IORESOURCE_IRQ,
  633. },
  634. };
  635. static struct platform_device bfin_lq035q1_device = {
  636. .name = "bfin-lq035q1",
  637. .id = -1,
  638. .num_resources = ARRAY_SIZE(bfin_lq035q1_resources),
  639. .resource = bfin_lq035q1_resources,
  640. .dev = {
  641. .platform_data = &bfin_lq035q1_data,
  642. },
  643. };
  644. #endif
  645. static struct platform_device *stamp_devices[] __initdata = {
  646. &bfin_dpmc,
  647. #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
  648. &bf5xx_nand_device,
  649. #endif
  650. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  651. &rtc_device,
  652. #endif
  653. #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
  654. &musb_device,
  655. #endif
  656. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  657. &bfin_mii_bus,
  658. &bfin_mac_device,
  659. #endif
  660. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  661. &bfin_spi0_device,
  662. #endif
  663. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  664. &bfin_uart_device,
  665. #endif
  666. #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
  667. &bfin_lq035q1_device,
  668. #endif
  669. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  670. #ifdef CONFIG_BFIN_SIR0
  671. &bfin_sir0_device,
  672. #endif
  673. #ifdef CONFIG_BFIN_SIR1
  674. &bfin_sir1_device,
  675. #endif
  676. #endif
  677. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  678. &i2c_bfin_twi_device,
  679. #endif
  680. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  681. &bfin_sport0_uart_device,
  682. &bfin_sport1_uart_device,
  683. #endif
  684. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  685. &bfin_device_gpiokeys,
  686. #endif
  687. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  688. &ezbrd_flash_device,
  689. #endif
  690. &bfin_gpios_device,
  691. };
  692. static int __init ezbrd_init(void)
  693. {
  694. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  695. i2c_register_board_info(0, bfin_i2c_board_info,
  696. ARRAY_SIZE(bfin_i2c_board_info));
  697. platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
  698. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  699. return 0;
  700. }
  701. arch_initcall(ezbrd_init);
  702. void native_machine_restart(char *cmd)
  703. {
  704. /* workaround reboot hang when booting from SPI */
  705. if ((bfin_read_SYSCR() & 0x7) == 0x3)
  706. bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
  707. }
  708. void bfin_get_ether_addr(char *addr)
  709. {
  710. /* the MAC is stored in OTP memory page 0xDF */
  711. u32 ret;
  712. u64 otp_mac;
  713. u32 (*otp_read)(u32 page, u32 flags, u64 *page_content) = (void *)0xEF00001A;
  714. ret = otp_read(0xDF, 0x00, &otp_mac);
  715. if (!(ret & 0x1)) {
  716. char *otp_mac_p = (char *)&otp_mac;
  717. for (ret = 0; ret < 6; ++ret)
  718. addr[ret] = otp_mac_p[5 - ret];
  719. }
  720. }
  721. EXPORT_SYMBOL(bfin_get_ether_addr);