ezkit.c 25 KB

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