ezkit.c 26 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078
  1. /*
  2. * File: arch/blackfin/mach-bf527/boards/ezkit.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. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  38. #include <linux/usb/isp1362.h>
  39. #endif
  40. #include <linux/i2c.h>
  41. #include <linux/irq.h>
  42. #include <linux/interrupt.h>
  43. #include <linux/usb/sl811.h>
  44. #include <linux/usb/musb.h>
  45. #include <asm/dma.h>
  46. #include <asm/bfin5xx_spi.h>
  47. #include <asm/reboot.h>
  48. #include <asm/nand.h>
  49. #include <asm/portmux.h>
  50. #include <asm/dpmc.h>
  51. #include <linux/spi/ad7877.h>
  52. /*
  53. * Name the Board for the /proc/cpuinfo
  54. */
  55. const char bfin_board_name[] = "ADI BF527-EZKIT";
  56. /*
  57. * Driver needs to know address, irq and flag pin.
  58. */
  59. #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
  60. #include <linux/usb/isp1760.h>
  61. static struct resource bfin_isp1760_resources[] = {
  62. [0] = {
  63. .start = 0x203C0000,
  64. .end = 0x203C0000 + 0x000fffff,
  65. .flags = IORESOURCE_MEM,
  66. },
  67. [1] = {
  68. .start = IRQ_PF7,
  69. .end = IRQ_PF7,
  70. .flags = IORESOURCE_IRQ,
  71. },
  72. };
  73. static struct isp1760_platform_data isp1760_priv = {
  74. .is_isp1761 = 0,
  75. .bus_width_16 = 1,
  76. .port1_otg = 0,
  77. .analog_oc = 0,
  78. .dack_polarity_high = 0,
  79. .dreq_polarity_high = 0,
  80. };
  81. static struct platform_device bfin_isp1760_device = {
  82. .name = "isp1760-hcd",
  83. .id = 0,
  84. .dev = {
  85. .platform_data = &isp1760_priv,
  86. },
  87. .num_resources = ARRAY_SIZE(bfin_isp1760_resources),
  88. .resource = bfin_isp1760_resources,
  89. };
  90. #endif
  91. #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
  92. static struct resource musb_resources[] = {
  93. [0] = {
  94. .start = 0xffc03800,
  95. .end = 0xffc03cff,
  96. .flags = IORESOURCE_MEM,
  97. },
  98. [1] = { /* general IRQ */
  99. .start = IRQ_USB_INT0,
  100. .end = IRQ_USB_INT0,
  101. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  102. },
  103. [2] = { /* DMA IRQ */
  104. .start = IRQ_USB_DMA,
  105. .end = IRQ_USB_DMA,
  106. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  107. },
  108. };
  109. static struct musb_hdrc_config musb_config = {
  110. .multipoint = 0,
  111. .dyn_fifo = 0,
  112. .soft_con = 1,
  113. .dma = 1,
  114. .num_eps = 8,
  115. .dma_channels = 8,
  116. .gpio_vrsel = GPIO_PG13,
  117. };
  118. static struct musb_hdrc_platform_data musb_plat = {
  119. #if defined(CONFIG_USB_MUSB_OTG)
  120. .mode = MUSB_OTG,
  121. #elif defined(CONFIG_USB_MUSB_HDRC_HCD)
  122. .mode = MUSB_HOST,
  123. #elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
  124. .mode = MUSB_PERIPHERAL,
  125. #endif
  126. .config = &musb_config,
  127. };
  128. static u64 musb_dmamask = ~(u32)0;
  129. static struct platform_device musb_device = {
  130. .name = "musb_hdrc",
  131. .id = 0,
  132. .dev = {
  133. .dma_mask = &musb_dmamask,
  134. .coherent_dma_mask = 0xffffffff,
  135. .platform_data = &musb_plat,
  136. },
  137. .num_resources = ARRAY_SIZE(musb_resources),
  138. .resource = musb_resources,
  139. };
  140. #endif
  141. #if defined(CONFIG_FB_BFIN_T350MCQB) || defined(CONFIG_FB_BFIN_T350MCQB_MODULE)
  142. static struct resource bf52x_t350mcqb_resources[] = {
  143. {
  144. .start = IRQ_PPI_ERROR,
  145. .end = IRQ_PPI_ERROR,
  146. .flags = IORESOURCE_IRQ,
  147. },
  148. };
  149. static struct platform_device bf52x_t350mcqb_device = {
  150. .name = "bfin-t350mcqb",
  151. .id = -1,
  152. .num_resources = ARRAY_SIZE(bf52x_t350mcqb_resources),
  153. .resource = bf52x_t350mcqb_resources,
  154. };
  155. #endif
  156. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  157. static struct mtd_partition ezkit_partitions[] = {
  158. {
  159. .name = "bootloader(nor)",
  160. .size = 0x40000,
  161. .offset = 0,
  162. }, {
  163. .name = "linux kernel(nor)",
  164. .size = 0x1C0000,
  165. .offset = MTDPART_OFS_APPEND,
  166. }, {
  167. .name = "file system(nor)",
  168. .size = MTDPART_SIZ_FULL,
  169. .offset = MTDPART_OFS_APPEND,
  170. }
  171. };
  172. static struct physmap_flash_data ezkit_flash_data = {
  173. .width = 2,
  174. .parts = ezkit_partitions,
  175. .nr_parts = ARRAY_SIZE(ezkit_partitions),
  176. };
  177. static struct resource ezkit_flash_resource = {
  178. .start = 0x20000000,
  179. .end = 0x203fffff,
  180. .flags = IORESOURCE_MEM,
  181. };
  182. static struct platform_device ezkit_flash_device = {
  183. .name = "physmap-flash",
  184. .id = 0,
  185. .dev = {
  186. .platform_data = &ezkit_flash_data,
  187. },
  188. .num_resources = 1,
  189. .resource = &ezkit_flash_resource,
  190. };
  191. #endif
  192. #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
  193. static struct mtd_partition partition_info[] = {
  194. {
  195. .name = "linux kernel(nand)",
  196. .offset = 0,
  197. .size = 4 * 1024 * 1024,
  198. },
  199. {
  200. .name = "file system(nand)",
  201. .offset = MTDPART_OFS_APPEND,
  202. .size = MTDPART_SIZ_FULL,
  203. },
  204. };
  205. static struct bf5xx_nand_platform bf5xx_nand_platform = {
  206. .page_size = NFC_PG_SIZE_256,
  207. .data_width = NFC_NWIDTH_8,
  208. .partitions = partition_info,
  209. .nr_partitions = ARRAY_SIZE(partition_info),
  210. .rd_dly = 3,
  211. .wr_dly = 3,
  212. };
  213. static struct resource bf5xx_nand_resources[] = {
  214. {
  215. .start = NFC_CTL,
  216. .end = NFC_DATA_RD + 2,
  217. .flags = IORESOURCE_MEM,
  218. },
  219. {
  220. .start = CH_NFC,
  221. .end = CH_NFC,
  222. .flags = IORESOURCE_IRQ,
  223. },
  224. };
  225. static struct platform_device bf5xx_nand_device = {
  226. .name = "bf5xx-nand",
  227. .id = 0,
  228. .num_resources = ARRAY_SIZE(bf5xx_nand_resources),
  229. .resource = bf5xx_nand_resources,
  230. .dev = {
  231. .platform_data = &bf5xx_nand_platform,
  232. },
  233. };
  234. #endif
  235. #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
  236. static struct resource bfin_pcmcia_cf_resources[] = {
  237. {
  238. .start = 0x20310000, /* IO PORT */
  239. .end = 0x20312000,
  240. .flags = IORESOURCE_MEM,
  241. }, {
  242. .start = 0x20311000, /* Attribute Memory */
  243. .end = 0x20311FFF,
  244. .flags = IORESOURCE_MEM,
  245. }, {
  246. .start = IRQ_PF4,
  247. .end = IRQ_PF4,
  248. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  249. }, {
  250. .start = 6, /* Card Detect PF6 */
  251. .end = 6,
  252. .flags = IORESOURCE_IRQ,
  253. },
  254. };
  255. static struct platform_device bfin_pcmcia_cf_device = {
  256. .name = "bfin_cf_pcmcia",
  257. .id = -1,
  258. .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
  259. .resource = bfin_pcmcia_cf_resources,
  260. };
  261. #endif
  262. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  263. static struct platform_device rtc_device = {
  264. .name = "rtc-bfin",
  265. .id = -1,
  266. };
  267. #endif
  268. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  269. #include <linux/smc91x.h>
  270. static struct smc91x_platdata smc91x_info = {
  271. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
  272. .leda = RPC_LED_100_10,
  273. .ledb = RPC_LED_TX_RX,
  274. };
  275. static struct resource smc91x_resources[] = {
  276. {
  277. .name = "smc91x-regs",
  278. .start = 0x20300300,
  279. .end = 0x20300300 + 16,
  280. .flags = IORESOURCE_MEM,
  281. }, {
  282. .start = IRQ_PF7,
  283. .end = IRQ_PF7,
  284. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  285. },
  286. };
  287. static struct platform_device smc91x_device = {
  288. .name = "smc91x",
  289. .id = 0,
  290. .num_resources = ARRAY_SIZE(smc91x_resources),
  291. .resource = smc91x_resources,
  292. .dev = {
  293. .platform_data = &smc91x_info,
  294. },
  295. };
  296. #endif
  297. #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
  298. static struct resource dm9000_resources[] = {
  299. [0] = {
  300. .start = 0x203FB800,
  301. .end = 0x203FB800 + 1,
  302. .flags = IORESOURCE_MEM,
  303. },
  304. [1] = {
  305. .start = 0x203FB800 + 4,
  306. .end = 0x203FB800 + 5,
  307. .flags = IORESOURCE_MEM,
  308. },
  309. [2] = {
  310. .start = IRQ_PF9,
  311. .end = IRQ_PF9,
  312. .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE),
  313. },
  314. };
  315. static struct platform_device dm9000_device = {
  316. .name = "dm9000",
  317. .id = -1,
  318. .num_resources = ARRAY_SIZE(dm9000_resources),
  319. .resource = dm9000_resources,
  320. };
  321. #endif
  322. #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
  323. static struct resource sl811_hcd_resources[] = {
  324. {
  325. .start = 0x20340000,
  326. .end = 0x20340000,
  327. .flags = IORESOURCE_MEM,
  328. }, {
  329. .start = 0x20340004,
  330. .end = 0x20340004,
  331. .flags = IORESOURCE_MEM,
  332. }, {
  333. .start = CONFIG_USB_SL811_BFIN_IRQ,
  334. .end = CONFIG_USB_SL811_BFIN_IRQ,
  335. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  336. },
  337. };
  338. #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
  339. void sl811_port_power(struct device *dev, int is_on)
  340. {
  341. gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS");
  342. gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS, is_on);
  343. }
  344. #endif
  345. static struct sl811_platform_data sl811_priv = {
  346. .potpg = 10,
  347. .power = 250, /* == 500mA */
  348. #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
  349. .port_power = &sl811_port_power,
  350. #endif
  351. };
  352. static struct platform_device sl811_hcd_device = {
  353. .name = "sl811-hcd",
  354. .id = 0,
  355. .dev = {
  356. .platform_data = &sl811_priv,
  357. },
  358. .num_resources = ARRAY_SIZE(sl811_hcd_resources),
  359. .resource = sl811_hcd_resources,
  360. };
  361. #endif
  362. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  363. static struct resource isp1362_hcd_resources[] = {
  364. {
  365. .start = 0x20360000,
  366. .end = 0x20360000,
  367. .flags = IORESOURCE_MEM,
  368. }, {
  369. .start = 0x20360004,
  370. .end = 0x20360004,
  371. .flags = IORESOURCE_MEM,
  372. }, {
  373. .start = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
  374. .end = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
  375. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  376. },
  377. };
  378. static struct isp1362_platform_data isp1362_priv = {
  379. .sel15Kres = 1,
  380. .clknotstop = 0,
  381. .oc_enable = 0,
  382. .int_act_high = 0,
  383. .int_edge_triggered = 0,
  384. .remote_wakeup_connected = 0,
  385. .no_power_switching = 1,
  386. .power_switching_mode = 0,
  387. };
  388. static struct platform_device isp1362_hcd_device = {
  389. .name = "isp1362-hcd",
  390. .id = 0,
  391. .dev = {
  392. .platform_data = &isp1362_priv,
  393. },
  394. .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
  395. .resource = isp1362_hcd_resources,
  396. };
  397. #endif
  398. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  399. static struct platform_device bfin_mii_bus = {
  400. .name = "bfin_mii_bus",
  401. };
  402. static struct platform_device bfin_mac_device = {
  403. .name = "bfin_mac",
  404. .dev.platform_data = &bfin_mii_bus,
  405. };
  406. #endif
  407. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  408. static struct resource net2272_bfin_resources[] = {
  409. {
  410. .start = 0x20300000,
  411. .end = 0x20300000 + 0x100,
  412. .flags = IORESOURCE_MEM,
  413. }, {
  414. .start = IRQ_PF7,
  415. .end = IRQ_PF7,
  416. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  417. },
  418. };
  419. static struct platform_device net2272_bfin_device = {
  420. .name = "net2272",
  421. .id = -1,
  422. .num_resources = ARRAY_SIZE(net2272_bfin_resources),
  423. .resource = net2272_bfin_resources,
  424. };
  425. #endif
  426. #if defined(CONFIG_MTD_M25P80) \
  427. || defined(CONFIG_MTD_M25P80_MODULE)
  428. static struct mtd_partition bfin_spi_flash_partitions[] = {
  429. {
  430. .name = "bootloader(spi)",
  431. .size = 0x00040000,
  432. .offset = 0,
  433. .mask_flags = MTD_CAP_ROM
  434. }, {
  435. .name = "linux kernel(spi)",
  436. .size = MTDPART_SIZ_FULL,
  437. .offset = MTDPART_OFS_APPEND,
  438. }
  439. };
  440. static struct flash_platform_data bfin_spi_flash_data = {
  441. .name = "m25p80",
  442. .parts = bfin_spi_flash_partitions,
  443. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  444. .type = "m25p16",
  445. };
  446. /* SPI flash chip (m25p64) */
  447. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  448. .enable_dma = 0, /* use dma transfer with this chip*/
  449. .bits_per_word = 8,
  450. };
  451. #endif
  452. #if defined(CONFIG_BFIN_SPI_ADC) \
  453. || defined(CONFIG_BFIN_SPI_ADC_MODULE)
  454. /* SPI ADC chip */
  455. static struct bfin5xx_spi_chip spi_adc_chip_info = {
  456. .enable_dma = 1, /* use dma transfer with this chip*/
  457. .bits_per_word = 16,
  458. };
  459. #endif
  460. #if defined(CONFIG_SND_BLACKFIN_AD1836) \
  461. || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  462. static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
  463. .enable_dma = 0,
  464. .bits_per_word = 16,
  465. };
  466. #endif
  467. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  468. static struct bfin5xx_spi_chip mmc_spi_chip_info = {
  469. .enable_dma = 0,
  470. .bits_per_word = 8,
  471. };
  472. #endif
  473. #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
  474. static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
  475. .enable_dma = 0,
  476. .bits_per_word = 16,
  477. };
  478. static const struct ad7877_platform_data bfin_ad7877_ts_info = {
  479. .model = 7877,
  480. .vref_delay_usecs = 50, /* internal, no capacitor */
  481. .x_plate_ohms = 419,
  482. .y_plate_ohms = 486,
  483. .pressure_max = 1000,
  484. .pressure_min = 0,
  485. .stopacq_polarity = 1,
  486. .first_conversion_delay = 3,
  487. .acquisition_time = 1,
  488. .averaging = 1,
  489. .pen_down_acc_interval = 1,
  490. };
  491. #endif
  492. #if defined(CONFIG_TOUCHSCREEN_AD7879) || defined(CONFIG_TOUCHSCREEN_AD7879_MODULE)
  493. #include <linux/spi/ad7879.h>
  494. static const struct ad7879_platform_data bfin_ad7879_ts_info = {
  495. .model = 7879, /* Model = AD7879 */
  496. .x_plate_ohms = 620, /* 620 Ohm from the touch datasheet */
  497. .pressure_max = 10000,
  498. .pressure_min = 0,
  499. .first_conversion_delay = 3, /* wait 512us before do a first conversion */
  500. .acquisition_time = 1, /* 4us acquisition time per sample */
  501. .median = 2, /* do 8 measurements */
  502. .averaging = 1, /* take the average of 4 middle samples */
  503. .pen_down_acc_interval = 255, /* 9.4 ms */
  504. .gpio_output = 1, /* configure AUX/VBAT/GPIO as GPIO output */
  505. .gpio_default = 1, /* During initialization set GPIO = HIGH */
  506. };
  507. #endif
  508. #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
  509. static struct bfin5xx_spi_chip spi_ad7879_chip_info = {
  510. .enable_dma = 0,
  511. .bits_per_word = 16,
  512. };
  513. #endif
  514. #if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
  515. && defined(CONFIG_SND_SOC_WM8731_SPI)
  516. static struct bfin5xx_spi_chip spi_wm8731_chip_info = {
  517. .enable_dma = 0,
  518. .bits_per_word = 16,
  519. };
  520. #endif
  521. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  522. static struct bfin5xx_spi_chip spidev_chip_info = {
  523. .enable_dma = 0,
  524. .bits_per_word = 8,
  525. };
  526. #endif
  527. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  528. #if defined(CONFIG_MTD_M25P80) \
  529. || defined(CONFIG_MTD_M25P80_MODULE)
  530. {
  531. /* the modalias must be the same as spi device driver name */
  532. .modalias = "m25p80", /* Name of spi_driver for this device */
  533. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  534. .bus_num = 0, /* Framework bus number */
  535. .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
  536. .platform_data = &bfin_spi_flash_data,
  537. .controller_data = &spi_flash_chip_info,
  538. .mode = SPI_MODE_3,
  539. },
  540. #endif
  541. #if defined(CONFIG_BFIN_SPI_ADC) \
  542. || defined(CONFIG_BFIN_SPI_ADC_MODULE)
  543. {
  544. .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
  545. .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
  546. .bus_num = 0, /* Framework bus number */
  547. .chip_select = 1, /* Framework chip select. */
  548. .platform_data = NULL, /* No spi_driver specific config */
  549. .controller_data = &spi_adc_chip_info,
  550. },
  551. #endif
  552. #if defined(CONFIG_SND_BLACKFIN_AD1836) \
  553. || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  554. {
  555. .modalias = "ad1836",
  556. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  557. .bus_num = 0,
  558. .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
  559. .controller_data = &ad1836_spi_chip_info,
  560. },
  561. #endif
  562. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  563. {
  564. .modalias = "mmc_spi",
  565. .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
  566. .bus_num = 0,
  567. .chip_select = 3,
  568. .controller_data = &mmc_spi_chip_info,
  569. .mode = SPI_MODE_0,
  570. },
  571. #endif
  572. #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
  573. {
  574. .modalias = "ad7877",
  575. .platform_data = &bfin_ad7877_ts_info,
  576. .irq = IRQ_PF8,
  577. .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
  578. .bus_num = 0,
  579. .chip_select = 2,
  580. .controller_data = &spi_ad7877_chip_info,
  581. },
  582. #endif
  583. #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
  584. {
  585. .modalias = "ad7879",
  586. .platform_data = &bfin_ad7879_ts_info,
  587. .irq = IRQ_PF8,
  588. .max_speed_hz = 5000000, /* max spi clock (SCK) speed in HZ */
  589. .bus_num = 0,
  590. .chip_select = 3,
  591. .controller_data = &spi_ad7879_chip_info,
  592. .mode = SPI_CPHA | SPI_CPOL,
  593. },
  594. #endif
  595. #if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
  596. && defined(CONFIG_SND_SOC_WM8731_SPI)
  597. {
  598. .modalias = "wm8731",
  599. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  600. .bus_num = 0,
  601. .chip_select = 5,
  602. .controller_data = &spi_wm8731_chip_info,
  603. .mode = SPI_MODE_0,
  604. },
  605. #endif
  606. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  607. {
  608. .modalias = "spidev",
  609. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  610. .bus_num = 0,
  611. .chip_select = 1,
  612. .controller_data = &spidev_chip_info,
  613. },
  614. #endif
  615. };
  616. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  617. /* SPI controller data */
  618. static struct bfin5xx_spi_master bfin_spi0_info = {
  619. .num_chipselect = 8,
  620. .enable_dma = 1, /* master has the ability to do dma transfer */
  621. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  622. };
  623. /* SPI (0) */
  624. static struct resource bfin_spi0_resource[] = {
  625. [0] = {
  626. .start = SPI0_REGBASE,
  627. .end = SPI0_REGBASE + 0xFF,
  628. .flags = IORESOURCE_MEM,
  629. },
  630. [1] = {
  631. .start = CH_SPI,
  632. .end = CH_SPI,
  633. .flags = IORESOURCE_DMA,
  634. },
  635. [2] = {
  636. .start = IRQ_SPI,
  637. .end = IRQ_SPI,
  638. .flags = IORESOURCE_IRQ,
  639. },
  640. };
  641. static struct platform_device bfin_spi0_device = {
  642. .name = "bfin-spi",
  643. .id = 0, /* Bus number */
  644. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  645. .resource = bfin_spi0_resource,
  646. .dev = {
  647. .platform_data = &bfin_spi0_info, /* Passed to driver */
  648. },
  649. };
  650. #endif /* spi master and devices */
  651. #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
  652. static struct platform_device bfin_fb_device = {
  653. .name = "bf537-lq035",
  654. };
  655. #endif
  656. #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
  657. static struct platform_device bfin_fb_adv7393_device = {
  658. .name = "bfin-adv7393",
  659. };
  660. #endif
  661. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  662. static struct resource bfin_uart_resources[] = {
  663. #ifdef CONFIG_SERIAL_BFIN_UART0
  664. {
  665. .start = 0xFFC00400,
  666. .end = 0xFFC004FF,
  667. .flags = IORESOURCE_MEM,
  668. },
  669. #endif
  670. #ifdef CONFIG_SERIAL_BFIN_UART1
  671. {
  672. .start = 0xFFC02000,
  673. .end = 0xFFC020FF,
  674. .flags = IORESOURCE_MEM,
  675. },
  676. #endif
  677. };
  678. static struct platform_device bfin_uart_device = {
  679. .name = "bfin-uart",
  680. .id = 1,
  681. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  682. .resource = bfin_uart_resources,
  683. };
  684. #endif
  685. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  686. #ifdef CONFIG_BFIN_SIR0
  687. static struct resource bfin_sir0_resources[] = {
  688. {
  689. .start = 0xFFC00400,
  690. .end = 0xFFC004FF,
  691. .flags = IORESOURCE_MEM,
  692. },
  693. {
  694. .start = IRQ_UART0_RX,
  695. .end = IRQ_UART0_RX+1,
  696. .flags = IORESOURCE_IRQ,
  697. },
  698. {
  699. .start = CH_UART0_RX,
  700. .end = CH_UART0_RX+1,
  701. .flags = IORESOURCE_DMA,
  702. },
  703. };
  704. static struct platform_device bfin_sir0_device = {
  705. .name = "bfin_sir",
  706. .id = 0,
  707. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  708. .resource = bfin_sir0_resources,
  709. };
  710. #endif
  711. #ifdef CONFIG_BFIN_SIR1
  712. static struct resource bfin_sir1_resources[] = {
  713. {
  714. .start = 0xFFC02000,
  715. .end = 0xFFC020FF,
  716. .flags = IORESOURCE_MEM,
  717. },
  718. {
  719. .start = IRQ_UART1_RX,
  720. .end = IRQ_UART1_RX+1,
  721. .flags = IORESOURCE_IRQ,
  722. },
  723. {
  724. .start = CH_UART1_RX,
  725. .end = CH_UART1_RX+1,
  726. .flags = IORESOURCE_DMA,
  727. },
  728. };
  729. static struct platform_device bfin_sir1_device = {
  730. .name = "bfin_sir",
  731. .id = 1,
  732. .num_resources = ARRAY_SIZE(bfin_sir1_resources),
  733. .resource = bfin_sir1_resources,
  734. };
  735. #endif
  736. #endif
  737. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  738. static struct resource bfin_twi0_resource[] = {
  739. [0] = {
  740. .start = TWI0_REGBASE,
  741. .end = TWI0_REGBASE,
  742. .flags = IORESOURCE_MEM,
  743. },
  744. [1] = {
  745. .start = IRQ_TWI,
  746. .end = IRQ_TWI,
  747. .flags = IORESOURCE_IRQ,
  748. },
  749. };
  750. static struct platform_device i2c_bfin_twi_device = {
  751. .name = "i2c-bfin-twi",
  752. .id = 0,
  753. .num_resources = ARRAY_SIZE(bfin_twi0_resource),
  754. .resource = bfin_twi0_resource,
  755. };
  756. #endif
  757. static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
  758. #if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
  759. {
  760. I2C_BOARD_INFO("pcf8574_lcd", 0x22),
  761. },
  762. #endif
  763. #if defined(CONFIG_INPUT_PCF8574) || defined(CONFIG_INPUT_PCF8574_MODULE)
  764. {
  765. I2C_BOARD_INFO("pcf8574_keypad", 0x27),
  766. .irq = IRQ_PF8,
  767. },
  768. #endif
  769. };
  770. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  771. static struct platform_device bfin_sport0_uart_device = {
  772. .name = "bfin-sport-uart",
  773. .id = 0,
  774. };
  775. static struct platform_device bfin_sport1_uart_device = {
  776. .name = "bfin-sport-uart",
  777. .id = 1,
  778. };
  779. #endif
  780. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  781. #include <linux/input.h>
  782. #include <linux/gpio_keys.h>
  783. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  784. {BTN_0, GPIO_PG0, 1, "gpio-keys: BTN0"},
  785. {BTN_1, GPIO_PG13, 1, "gpio-keys: BTN1"},
  786. };
  787. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  788. .buttons = bfin_gpio_keys_table,
  789. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  790. };
  791. static struct platform_device bfin_device_gpiokeys = {
  792. .name = "gpio-keys",
  793. .dev = {
  794. .platform_data = &bfin_gpio_keys_data,
  795. },
  796. };
  797. #endif
  798. #if defined(CONFIG_JOYSTICK_BFIN_ROTARY) || defined(CONFIG_JOYSTICK_BFIN_ROTARY_MODULE)
  799. #include <linux/input.h>
  800. #include <asm/bfin_rotary.h>
  801. static struct bfin_rotary_platform_data bfin_rotary_data = {
  802. /*.rotary_up_key = KEY_UP,*/
  803. /*.rotary_down_key = KEY_DOWN,*/
  804. .rotary_rel_code = REL_WHEEL,
  805. .rotary_button_key = KEY_ENTER,
  806. .debounce = 10, /* 0..17 */
  807. .mode = ROT_QUAD_ENC | ROT_DEBE,
  808. };
  809. static struct resource bfin_rotary_resources[] = {
  810. {
  811. .start = IRQ_CNT,
  812. .end = IRQ_CNT,
  813. .flags = IORESOURCE_IRQ,
  814. },
  815. };
  816. static struct platform_device bfin_rotary_device = {
  817. .name = "bfin-rotary",
  818. .id = -1,
  819. .num_resources = ARRAY_SIZE(bfin_rotary_resources),
  820. .resource = bfin_rotary_resources,
  821. .dev = {
  822. .platform_data = &bfin_rotary_data,
  823. },
  824. };
  825. #endif
  826. static struct resource bfin_gpios_resources = {
  827. .start = 0,
  828. .end = MAX_BLACKFIN_GPIOS - 1,
  829. .flags = IORESOURCE_IRQ,
  830. };
  831. static struct platform_device bfin_gpios_device = {
  832. .name = "simple-gpio",
  833. .id = -1,
  834. .num_resources = 1,
  835. .resource = &bfin_gpios_resources,
  836. };
  837. static const unsigned int cclk_vlev_datasheet[] =
  838. {
  839. VRPAIR(VLEV_100, 400000000),
  840. VRPAIR(VLEV_105, 426000000),
  841. VRPAIR(VLEV_110, 500000000),
  842. VRPAIR(VLEV_115, 533000000),
  843. VRPAIR(VLEV_120, 600000000),
  844. };
  845. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  846. .tuple_tab = cclk_vlev_datasheet,
  847. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  848. .vr_settling_time = 25 /* us */,
  849. };
  850. static struct platform_device bfin_dpmc = {
  851. .name = "bfin dpmc",
  852. .dev = {
  853. .platform_data = &bfin_dmpc_vreg_data,
  854. },
  855. };
  856. static struct platform_device *stamp_devices[] __initdata = {
  857. &bfin_dpmc,
  858. #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
  859. &bf5xx_nand_device,
  860. #endif
  861. #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
  862. &bfin_pcmcia_cf_device,
  863. #endif
  864. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  865. &rtc_device,
  866. #endif
  867. #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
  868. &sl811_hcd_device,
  869. #endif
  870. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  871. &isp1362_hcd_device,
  872. #endif
  873. #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
  874. &bfin_isp1760_device,
  875. #endif
  876. #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
  877. &musb_device,
  878. #endif
  879. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  880. &smc91x_device,
  881. #endif
  882. #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
  883. &dm9000_device,
  884. #endif
  885. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  886. &bfin_mii_bus,
  887. &bfin_mac_device,
  888. #endif
  889. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  890. &net2272_bfin_device,
  891. #endif
  892. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  893. &bfin_spi0_device,
  894. #endif
  895. #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
  896. &bfin_fb_device,
  897. #endif
  898. #if defined(CONFIG_FB_BFIN_T350MCQB) || defined(CONFIG_FB_BFIN_T350MCQB_MODULE)
  899. &bf52x_t350mcqb_device,
  900. #endif
  901. #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
  902. &bfin_fb_adv7393_device,
  903. #endif
  904. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  905. &bfin_uart_device,
  906. #endif
  907. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  908. #ifdef CONFIG_BFIN_SIR0
  909. &bfin_sir0_device,
  910. #endif
  911. #ifdef CONFIG_BFIN_SIR1
  912. &bfin_sir1_device,
  913. #endif
  914. #endif
  915. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  916. &i2c_bfin_twi_device,
  917. #endif
  918. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  919. &bfin_sport0_uart_device,
  920. &bfin_sport1_uart_device,
  921. #endif
  922. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  923. &bfin_device_gpiokeys,
  924. #endif
  925. #if defined(CONFIG_JOYSTICK_BFIN_ROTARY) || defined(CONFIG_JOYSTICK_BFIN_ROTARY_MODULE)
  926. &bfin_rotary_device,
  927. #endif
  928. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  929. &ezkit_flash_device,
  930. #endif
  931. &bfin_gpios_device,
  932. };
  933. static int __init ezkit_init(void)
  934. {
  935. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  936. i2c_register_board_info(0, bfin_i2c_board_info,
  937. ARRAY_SIZE(bfin_i2c_board_info));
  938. platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
  939. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  940. return 0;
  941. }
  942. arch_initcall(ezkit_init);
  943. void native_machine_restart(char *cmd)
  944. {
  945. /* workaround reboot hang when booting from SPI */
  946. if ((bfin_read_SYSCR() & 0x7) == 0x3)
  947. bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
  948. }
  949. void bfin_get_ether_addr(char *addr)
  950. {
  951. /* the MAC is stored in OTP memory page 0xDF */
  952. u32 ret;
  953. u64 otp_mac;
  954. u32 (*otp_read)(u32 page, u32 flags, u64 *page_content) = (void *)0xEF00001A;
  955. ret = otp_read(0xDF, 0x00, &otp_mac);
  956. if (!(ret & 0x1)) {
  957. char *otp_mac_p = (char *)&otp_mac;
  958. for (ret = 0; ret < 6; ++ret)
  959. addr[ret] = otp_mac_p[5 - ret];
  960. }
  961. }
  962. EXPORT_SYMBOL(bfin_get_ether_addr);