ezbrd.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798
  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_mac_device = {
  192. .name = "bfin_mac",
  193. };
  194. #endif
  195. #if defined(CONFIG_MTD_M25P80) \
  196. || defined(CONFIG_MTD_M25P80_MODULE)
  197. static struct mtd_partition bfin_spi_flash_partitions[] = {
  198. {
  199. .name = "bootloader(spi)",
  200. .size = 0x00040000,
  201. .offset = 0,
  202. .mask_flags = MTD_CAP_ROM
  203. }, {
  204. .name = "linux kernel(spi)",
  205. .size = MTDPART_SIZ_FULL,
  206. .offset = MTDPART_OFS_APPEND,
  207. }
  208. };
  209. static struct flash_platform_data bfin_spi_flash_data = {
  210. .name = "m25p80",
  211. .parts = bfin_spi_flash_partitions,
  212. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  213. .type = "m25p16",
  214. };
  215. /* SPI flash chip (m25p64) */
  216. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  217. .enable_dma = 0, /* use dma transfer with this chip*/
  218. .bits_per_word = 8,
  219. };
  220. #endif
  221. #if defined(CONFIG_SPI_ADC_BF533) \
  222. || defined(CONFIG_SPI_ADC_BF533_MODULE)
  223. /* SPI ADC chip */
  224. static struct bfin5xx_spi_chip spi_adc_chip_info = {
  225. .enable_dma = 1, /* use dma transfer with this chip*/
  226. .bits_per_word = 16,
  227. };
  228. #endif
  229. #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
  230. static struct bfin5xx_spi_chip spi_mmc_chip_info = {
  231. .enable_dma = 1,
  232. .bits_per_word = 8,
  233. };
  234. #endif
  235. #if defined(CONFIG_PBX)
  236. static struct bfin5xx_spi_chip spi_si3xxx_chip_info = {
  237. .ctl_reg = 0x4, /* send zero */
  238. .enable_dma = 0,
  239. .bits_per_word = 8,
  240. .cs_change_per_word = 1,
  241. };
  242. #endif
  243. #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
  244. static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
  245. .enable_dma = 0,
  246. .bits_per_word = 16,
  247. };
  248. static const struct ad7877_platform_data bfin_ad7877_ts_info = {
  249. .model = 7877,
  250. .vref_delay_usecs = 50, /* internal, no capacitor */
  251. .x_plate_ohms = 419,
  252. .y_plate_ohms = 486,
  253. .pressure_max = 1000,
  254. .pressure_min = 0,
  255. .stopacq_polarity = 1,
  256. .first_conversion_delay = 3,
  257. .acquisition_time = 1,
  258. .averaging = 1,
  259. .pen_down_acc_interval = 1,
  260. };
  261. #endif
  262. #if defined(CONFIG_TOUCHSCREEN_AD7879) || defined(CONFIG_TOUCHSCREEN_AD7879_MODULE)
  263. #include <linux/spi/ad7879.h>
  264. static const struct ad7879_platform_data bfin_ad7879_ts_info = {
  265. .model = 7879, /* Model = AD7879 */
  266. .x_plate_ohms = 620, /* 620 Ohm from the touch datasheet */
  267. .pressure_max = 10000,
  268. .pressure_min = 0,
  269. .first_conversion_delay = 3, /* wait 512us before do a first conversion */
  270. .acquisition_time = 1, /* 4us acquisition time per sample */
  271. .median = 2, /* do 8 measurements */
  272. .averaging = 1, /* take the average of 4 middle samples */
  273. .pen_down_acc_interval = 255, /* 9.4 ms */
  274. .gpio_output = 1, /* configure AUX/VBAT/GPIO as GPIO output */
  275. .gpio_default = 1, /* During initialization set GPIO = HIGH */
  276. };
  277. #endif
  278. #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
  279. static struct bfin5xx_spi_chip spi_ad7879_chip_info = {
  280. .enable_dma = 0,
  281. .bits_per_word = 16,
  282. };
  283. #endif
  284. #if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
  285. && defined(CONFIG_SND_SOC_WM8731_SPI)
  286. static struct bfin5xx_spi_chip spi_wm8731_chip_info = {
  287. .enable_dma = 0,
  288. .bits_per_word = 16,
  289. };
  290. #endif
  291. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  292. static struct bfin5xx_spi_chip spidev_chip_info = {
  293. .enable_dma = 0,
  294. .bits_per_word = 8,
  295. };
  296. #endif
  297. #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
  298. static struct bfin5xx_spi_chip lq035q1_spi_chip_info = {
  299. .enable_dma = 0,
  300. .bits_per_word = 8,
  301. };
  302. #endif
  303. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  304. #if defined(CONFIG_MTD_M25P80) \
  305. || defined(CONFIG_MTD_M25P80_MODULE)
  306. {
  307. /* the modalias must be the same as spi device driver name */
  308. .modalias = "m25p80", /* Name of spi_driver for this device */
  309. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  310. .bus_num = 0, /* Framework bus number */
  311. .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
  312. .platform_data = &bfin_spi_flash_data,
  313. .controller_data = &spi_flash_chip_info,
  314. .mode = SPI_MODE_3,
  315. },
  316. #endif
  317. #if defined(CONFIG_SPI_ADC_BF533) \
  318. || defined(CONFIG_SPI_ADC_BF533_MODULE)
  319. {
  320. .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
  321. .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
  322. .bus_num = 0, /* Framework bus number */
  323. .chip_select = 1, /* Framework chip select. */
  324. .platform_data = NULL, /* No spi_driver specific config */
  325. .controller_data = &spi_adc_chip_info,
  326. },
  327. #endif
  328. #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
  329. {
  330. .modalias = "spi_mmc_dummy",
  331. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  332. .bus_num = 0,
  333. .chip_select = 0,
  334. .platform_data = NULL,
  335. .controller_data = &spi_mmc_chip_info,
  336. .mode = SPI_MODE_3,
  337. },
  338. {
  339. .modalias = "spi_mmc",
  340. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  341. .bus_num = 0,
  342. .chip_select = CONFIG_SPI_MMC_CS_CHAN,
  343. .platform_data = NULL,
  344. .controller_data = &spi_mmc_chip_info,
  345. .mode = SPI_MODE_3,
  346. },
  347. #endif
  348. #if defined(CONFIG_PBX)
  349. {
  350. .modalias = "fxs-spi",
  351. .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
  352. .bus_num = 0,
  353. .chip_select = 8 - CONFIG_J11_JUMPER,
  354. .controller_data = &spi_si3xxx_chip_info,
  355. .mode = SPI_MODE_3,
  356. },
  357. {
  358. .modalias = "fxo-spi",
  359. .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
  360. .bus_num = 0,
  361. .chip_select = 8 - CONFIG_J19_JUMPER,
  362. .controller_data = &spi_si3xxx_chip_info,
  363. .mode = SPI_MODE_3,
  364. },
  365. #endif
  366. #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
  367. {
  368. .modalias = "ad7877",
  369. .platform_data = &bfin_ad7877_ts_info,
  370. .irq = IRQ_PF8,
  371. .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
  372. .bus_num = 0,
  373. .chip_select = 2,
  374. .controller_data = &spi_ad7877_chip_info,
  375. },
  376. #endif
  377. #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
  378. {
  379. .modalias = "ad7879",
  380. .platform_data = &bfin_ad7879_ts_info,
  381. .irq = IRQ_PG0,
  382. .max_speed_hz = 5000000, /* max spi clock (SCK) speed in HZ */
  383. .bus_num = 0,
  384. .chip_select = 5,
  385. .controller_data = &spi_ad7879_chip_info,
  386. .mode = SPI_CPHA | SPI_CPOL,
  387. },
  388. #endif
  389. #if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
  390. && defined(CONFIG_SND_SOC_WM8731_SPI)
  391. {
  392. .modalias = "wm8731",
  393. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  394. .bus_num = 0,
  395. .chip_select = 5,
  396. .controller_data = &spi_wm8731_chip_info,
  397. .mode = SPI_MODE_0,
  398. },
  399. #endif
  400. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  401. {
  402. .modalias = "spidev",
  403. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  404. .bus_num = 0,
  405. .chip_select = 1,
  406. .controller_data = &spidev_chip_info,
  407. },
  408. #endif
  409. #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
  410. {
  411. .modalias = "bfin-lq035q1-spi",
  412. .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
  413. .bus_num = 0,
  414. .chip_select = 1,
  415. .controller_data = &lq035q1_spi_chip_info,
  416. .mode = SPI_CPHA | SPI_CPOL,
  417. },
  418. #endif
  419. };
  420. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  421. /* SPI controller data */
  422. static struct bfin5xx_spi_master bfin_spi0_info = {
  423. .num_chipselect = 8,
  424. .enable_dma = 1, /* master has the ability to do dma transfer */
  425. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  426. };
  427. /* SPI (0) */
  428. static struct resource bfin_spi0_resource[] = {
  429. [0] = {
  430. .start = SPI0_REGBASE,
  431. .end = SPI0_REGBASE + 0xFF,
  432. .flags = IORESOURCE_MEM,
  433. },
  434. [1] = {
  435. .start = CH_SPI,
  436. .end = CH_SPI,
  437. .flags = IORESOURCE_IRQ,
  438. },
  439. };
  440. static struct platform_device bfin_spi0_device = {
  441. .name = "bfin-spi",
  442. .id = 0, /* Bus number */
  443. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  444. .resource = bfin_spi0_resource,
  445. .dev = {
  446. .platform_data = &bfin_spi0_info, /* Passed to driver */
  447. },
  448. };
  449. #endif /* spi master and devices */
  450. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  451. static struct resource bfin_uart_resources[] = {
  452. #ifdef CONFIG_SERIAL_BFIN_UART0
  453. {
  454. .start = 0xFFC00400,
  455. .end = 0xFFC004FF,
  456. .flags = IORESOURCE_MEM,
  457. },
  458. #endif
  459. #ifdef CONFIG_SERIAL_BFIN_UART1
  460. {
  461. .start = 0xFFC02000,
  462. .end = 0xFFC020FF,
  463. .flags = IORESOURCE_MEM,
  464. },
  465. #endif
  466. };
  467. static struct platform_device bfin_uart_device = {
  468. .name = "bfin-uart",
  469. .id = 1,
  470. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  471. .resource = bfin_uart_resources,
  472. };
  473. #endif
  474. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  475. #ifdef CONFIG_BFIN_SIR0
  476. static struct resource bfin_sir0_resources[] = {
  477. {
  478. .start = 0xFFC00400,
  479. .end = 0xFFC004FF,
  480. .flags = IORESOURCE_MEM,
  481. },
  482. {
  483. .start = IRQ_UART0_RX,
  484. .end = IRQ_UART0_RX+1,
  485. .flags = IORESOURCE_IRQ,
  486. },
  487. {
  488. .start = CH_UART0_RX,
  489. .end = CH_UART0_RX+1,
  490. .flags = IORESOURCE_DMA,
  491. },
  492. };
  493. static struct platform_device bfin_sir0_device = {
  494. .name = "bfin_sir",
  495. .id = 0,
  496. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  497. .resource = bfin_sir0_resources,
  498. };
  499. #endif
  500. #ifdef CONFIG_BFIN_SIR1
  501. static struct resource bfin_sir1_resources[] = {
  502. {
  503. .start = 0xFFC02000,
  504. .end = 0xFFC020FF,
  505. .flags = IORESOURCE_MEM,
  506. },
  507. {
  508. .start = IRQ_UART1_RX,
  509. .end = IRQ_UART1_RX+1,
  510. .flags = IORESOURCE_IRQ,
  511. },
  512. {
  513. .start = CH_UART1_RX,
  514. .end = CH_UART1_RX+1,
  515. .flags = IORESOURCE_DMA,
  516. },
  517. };
  518. static struct platform_device bfin_sir1_device = {
  519. .name = "bfin_sir",
  520. .id = 1,
  521. .num_resources = ARRAY_SIZE(bfin_sir1_resources),
  522. .resource = bfin_sir1_resources,
  523. };
  524. #endif
  525. #endif
  526. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  527. static struct resource bfin_twi0_resource[] = {
  528. [0] = {
  529. .start = TWI0_REGBASE,
  530. .end = TWI0_REGBASE,
  531. .flags = IORESOURCE_MEM,
  532. },
  533. [1] = {
  534. .start = IRQ_TWI,
  535. .end = IRQ_TWI,
  536. .flags = IORESOURCE_IRQ,
  537. },
  538. };
  539. static struct platform_device i2c_bfin_twi_device = {
  540. .name = "i2c-bfin-twi",
  541. .id = 0,
  542. .num_resources = ARRAY_SIZE(bfin_twi0_resource),
  543. .resource = bfin_twi0_resource,
  544. };
  545. #endif
  546. static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
  547. #if defined(CONFIG_TWI_LCD) || defined(CONFIG_TWI_LCD_MODULE)
  548. {
  549. I2C_BOARD_INFO("pcf8574_lcd", 0x22),
  550. },
  551. #endif
  552. #if defined(CONFIG_TWI_KEYPAD) || defined(CONFIG_TWI_KEYPAD_MODULE)
  553. {
  554. I2C_BOARD_INFO("pcf8574_keypad", 0x27),
  555. .irq = IRQ_PF8,
  556. },
  557. #endif
  558. };
  559. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  560. static struct platform_device bfin_sport0_uart_device = {
  561. .name = "bfin-sport-uart",
  562. .id = 0,
  563. };
  564. static struct platform_device bfin_sport1_uart_device = {
  565. .name = "bfin-sport-uart",
  566. .id = 1,
  567. };
  568. #endif
  569. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  570. #include <linux/input.h>
  571. #include <linux/gpio_keys.h>
  572. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  573. {BTN_0, GPIO_PG0, 1, "gpio-keys: BTN0"},
  574. {BTN_1, GPIO_PG13, 1, "gpio-keys: BTN1"},
  575. };
  576. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  577. .buttons = bfin_gpio_keys_table,
  578. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  579. };
  580. static struct platform_device bfin_device_gpiokeys = {
  581. .name = "gpio-keys",
  582. .dev = {
  583. .platform_data = &bfin_gpio_keys_data,
  584. },
  585. };
  586. #endif
  587. static struct resource bfin_gpios_resources = {
  588. .start = 0,
  589. .end = MAX_BLACKFIN_GPIOS - 1,
  590. .flags = IORESOURCE_IRQ,
  591. };
  592. static struct platform_device bfin_gpios_device = {
  593. .name = "simple-gpio",
  594. .id = -1,
  595. .num_resources = 1,
  596. .resource = &bfin_gpios_resources,
  597. };
  598. static const unsigned int cclk_vlev_datasheet[] =
  599. {
  600. VRPAIR(VLEV_100, 400000000),
  601. VRPAIR(VLEV_105, 426000000),
  602. VRPAIR(VLEV_110, 500000000),
  603. VRPAIR(VLEV_115, 533000000),
  604. VRPAIR(VLEV_120, 600000000),
  605. };
  606. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  607. .tuple_tab = cclk_vlev_datasheet,
  608. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  609. .vr_settling_time = 25 /* us */,
  610. };
  611. static struct platform_device bfin_dpmc = {
  612. .name = "bfin dpmc",
  613. .dev = {
  614. .platform_data = &bfin_dmpc_vreg_data,
  615. },
  616. };
  617. #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
  618. #include <asm/bfin-lq035q1.h>
  619. static struct bfin_lq035q1fb_disp_info bfin_lq035q1_data = {
  620. .mode = LQ035_NORM | LQ035_RGB | LQ035_RL | LQ035_TB,
  621. .use_bl = 1,
  622. .gpio_bl = GPIO_PG12,
  623. };
  624. static struct resource bfin_lq035q1_resources[] = {
  625. {
  626. .start = IRQ_PPI_ERROR,
  627. .end = IRQ_PPI_ERROR,
  628. .flags = IORESOURCE_IRQ,
  629. },
  630. };
  631. static struct platform_device bfin_lq035q1_device = {
  632. .name = "bfin-lq035q1",
  633. .id = -1,
  634. .num_resources = ARRAY_SIZE(bfin_lq035q1_resources),
  635. .resource = bfin_lq035q1_resources,
  636. .dev = {
  637. .platform_data = &bfin_lq035q1_data,
  638. },
  639. };
  640. #endif
  641. static struct platform_device *stamp_devices[] __initdata = {
  642. &bfin_dpmc,
  643. #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
  644. &bf5xx_nand_device,
  645. #endif
  646. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  647. &rtc_device,
  648. #endif
  649. #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
  650. &musb_device,
  651. #endif
  652. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  653. &bfin_mac_device,
  654. #endif
  655. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  656. &bfin_spi0_device,
  657. #endif
  658. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  659. &bfin_uart_device,
  660. #endif
  661. #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
  662. &bfin_lq035q1_device,
  663. #endif
  664. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  665. #ifdef CONFIG_BFIN_SIR0
  666. &bfin_sir0_device,
  667. #endif
  668. #ifdef CONFIG_BFIN_SIR1
  669. &bfin_sir1_device,
  670. #endif
  671. #endif
  672. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  673. &i2c_bfin_twi_device,
  674. #endif
  675. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  676. &bfin_sport0_uart_device,
  677. &bfin_sport1_uart_device,
  678. #endif
  679. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  680. &bfin_device_gpiokeys,
  681. #endif
  682. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  683. &ezbrd_flash_device,
  684. #endif
  685. &bfin_gpios_device,
  686. };
  687. static int __init ezbrd_init(void)
  688. {
  689. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  690. i2c_register_board_info(0, bfin_i2c_board_info,
  691. ARRAY_SIZE(bfin_i2c_board_info));
  692. platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
  693. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  694. return 0;
  695. }
  696. arch_initcall(ezbrd_init);
  697. void native_machine_restart(char *cmd)
  698. {
  699. /* workaround reboot hang when booting from SPI */
  700. if ((bfin_read_SYSCR() & 0x7) == 0x3)
  701. bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
  702. }
  703. void bfin_get_ether_addr(char *addr)
  704. {
  705. /* the MAC is stored in OTP memory page 0xDF */
  706. u32 ret;
  707. u64 otp_mac;
  708. u32 (*otp_read)(u32 page, u32 flags, u64 *page_content) = (void *)0xEF00001A;
  709. ret = otp_read(0xDF, 0x00, &otp_mac);
  710. if (!(ret & 0x1)) {
  711. char *otp_mac_p = (char *)&otp_mac;
  712. for (ret = 0; ret < 6; ++ret)
  713. addr[ret] = otp_mac_p[5 - ret];
  714. }
  715. }
  716. EXPORT_SYMBOL(bfin_get_ether_addr);