ezkit.c 27 KB

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