ezkit.c 24 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009
  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. #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
  45. #include <linux/usb/musb.h>
  46. #endif
  47. #include <asm/cplb.h>
  48. #include <asm/dma.h>
  49. #include <asm/bfin5xx_spi.h>
  50. #include <asm/reboot.h>
  51. #include <asm/nand.h>
  52. #include <asm/portmux.h>
  53. #include <asm/dpmc.h>
  54. #include <linux/spi/ad7877.h>
  55. /*
  56. * Name the Board for the /proc/cpuinfo
  57. */
  58. const char bfin_board_name[] = "ADDS-BF527-EZKIT";
  59. /*
  60. * Driver needs to know address, irq and flag pin.
  61. */
  62. #define ISP1761_BASE 0x203C0000
  63. #define ISP1761_IRQ IRQ_PF7
  64. #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
  65. static struct resource bfin_isp1761_resources[] = {
  66. [0] = {
  67. .name = "isp1761-regs",
  68. .start = ISP1761_BASE + 0x00000000,
  69. .end = ISP1761_BASE + 0x000fffff,
  70. .flags = IORESOURCE_MEM,
  71. },
  72. [1] = {
  73. .start = ISP1761_IRQ,
  74. .end = ISP1761_IRQ,
  75. .flags = IORESOURCE_IRQ,
  76. },
  77. };
  78. static struct platform_device bfin_isp1761_device = {
  79. .name = "isp1761",
  80. .id = 0,
  81. .num_resources = ARRAY_SIZE(bfin_isp1761_resources),
  82. .resource = bfin_isp1761_resources,
  83. };
  84. static struct platform_device *bfin_isp1761_devices[] = {
  85. &bfin_isp1761_device,
  86. };
  87. int __init bfin_isp1761_init(void)
  88. {
  89. unsigned int num_devices = ARRAY_SIZE(bfin_isp1761_devices);
  90. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  91. set_irq_type(ISP1761_IRQ, IRQF_TRIGGER_FALLING);
  92. return platform_add_devices(bfin_isp1761_devices, num_devices);
  93. }
  94. void __exit bfin_isp1761_exit(void)
  95. {
  96. platform_device_unregister(&bfin_isp1761_device);
  97. }
  98. arch_initcall(bfin_isp1761_init);
  99. #endif
  100. #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
  101. static struct resource musb_resources[] = {
  102. [0] = {
  103. .start = 0xffc03800,
  104. .end = 0xffc03cff,
  105. .flags = IORESOURCE_MEM,
  106. },
  107. [1] = { /* general IRQ */
  108. .start = IRQ_USB_INT0,
  109. .end = IRQ_USB_INT0,
  110. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  111. },
  112. [2] = { /* DMA IRQ */
  113. .start = IRQ_USB_DMA,
  114. .end = IRQ_USB_DMA,
  115. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  116. },
  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. .multipoint = 0,
  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 * SIZE_1M,
  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. static struct resource smc91x_resources[] = {
  270. {
  271. .name = "smc91x-regs",
  272. .start = 0x20300300,
  273. .end = 0x20300300 + 16,
  274. .flags = IORESOURCE_MEM,
  275. }, {
  276. .start = IRQ_PF7,
  277. .end = IRQ_PF7,
  278. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  279. },
  280. };
  281. static struct platform_device smc91x_device = {
  282. .name = "smc91x",
  283. .id = 0,
  284. .num_resources = ARRAY_SIZE(smc91x_resources),
  285. .resource = smc91x_resources,
  286. };
  287. #endif
  288. #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
  289. static struct resource dm9000_resources[] = {
  290. [0] = {
  291. .start = 0x203FB800,
  292. .end = 0x203FB800 + 1,
  293. .flags = IORESOURCE_MEM,
  294. },
  295. [1] = {
  296. .start = 0x203FB800 + 4,
  297. .end = 0x203FB800 + 5,
  298. .flags = IORESOURCE_MEM,
  299. },
  300. [2] = {
  301. .start = IRQ_PF9,
  302. .end = IRQ_PF9,
  303. .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE),
  304. },
  305. };
  306. static struct platform_device dm9000_device = {
  307. .name = "dm9000",
  308. .id = -1,
  309. .num_resources = ARRAY_SIZE(dm9000_resources),
  310. .resource = dm9000_resources,
  311. };
  312. #endif
  313. #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
  314. static struct resource sl811_hcd_resources[] = {
  315. {
  316. .start = 0x20340000,
  317. .end = 0x20340000,
  318. .flags = IORESOURCE_MEM,
  319. }, {
  320. .start = 0x20340004,
  321. .end = 0x20340004,
  322. .flags = IORESOURCE_MEM,
  323. }, {
  324. .start = CONFIG_USB_SL811_BFIN_IRQ,
  325. .end = CONFIG_USB_SL811_BFIN_IRQ,
  326. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  327. },
  328. };
  329. #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
  330. void sl811_port_power(struct device *dev, int is_on)
  331. {
  332. gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS");
  333. gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS, is_on);
  334. }
  335. #endif
  336. static struct sl811_platform_data sl811_priv = {
  337. .potpg = 10,
  338. .power = 250, /* == 500mA */
  339. #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
  340. .port_power = &sl811_port_power,
  341. #endif
  342. };
  343. static struct platform_device sl811_hcd_device = {
  344. .name = "sl811-hcd",
  345. .id = 0,
  346. .dev = {
  347. .platform_data = &sl811_priv,
  348. },
  349. .num_resources = ARRAY_SIZE(sl811_hcd_resources),
  350. .resource = sl811_hcd_resources,
  351. };
  352. #endif
  353. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  354. static struct resource isp1362_hcd_resources[] = {
  355. {
  356. .start = 0x20360000,
  357. .end = 0x20360000,
  358. .flags = IORESOURCE_MEM,
  359. }, {
  360. .start = 0x20360004,
  361. .end = 0x20360004,
  362. .flags = IORESOURCE_MEM,
  363. }, {
  364. .start = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
  365. .end = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
  366. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  367. },
  368. };
  369. static struct isp1362_platform_data isp1362_priv = {
  370. .sel15Kres = 1,
  371. .clknotstop = 0,
  372. .oc_enable = 0,
  373. .int_act_high = 0,
  374. .int_edge_triggered = 0,
  375. .remote_wakeup_connected = 0,
  376. .no_power_switching = 1,
  377. .power_switching_mode = 0,
  378. };
  379. static struct platform_device isp1362_hcd_device = {
  380. .name = "isp1362-hcd",
  381. .id = 0,
  382. .dev = {
  383. .platform_data = &isp1362_priv,
  384. },
  385. .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
  386. .resource = isp1362_hcd_resources,
  387. };
  388. #endif
  389. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  390. static struct platform_device bfin_mac_device = {
  391. .name = "bfin_mac",
  392. };
  393. #endif
  394. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  395. static struct resource net2272_bfin_resources[] = {
  396. {
  397. .start = 0x20300000,
  398. .end = 0x20300000 + 0x100,
  399. .flags = IORESOURCE_MEM,
  400. }, {
  401. .start = IRQ_PF7,
  402. .end = IRQ_PF7,
  403. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  404. },
  405. };
  406. static struct platform_device net2272_bfin_device = {
  407. .name = "net2272",
  408. .id = -1,
  409. .num_resources = ARRAY_SIZE(net2272_bfin_resources),
  410. .resource = net2272_bfin_resources,
  411. };
  412. #endif
  413. #if defined(CONFIG_MTD_M25P80) \
  414. || defined(CONFIG_MTD_M25P80_MODULE)
  415. static struct mtd_partition bfin_spi_flash_partitions[] = {
  416. {
  417. .name = "bootloader(spi)",
  418. .size = 0x00040000,
  419. .offset = 0,
  420. .mask_flags = MTD_CAP_ROM
  421. }, {
  422. .name = "linux kernel(spi)",
  423. .size = MTDPART_SIZ_FULL,
  424. .offset = MTDPART_OFS_APPEND,
  425. }
  426. };
  427. static struct flash_platform_data bfin_spi_flash_data = {
  428. .name = "m25p80",
  429. .parts = bfin_spi_flash_partitions,
  430. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  431. .type = "m25p16",
  432. };
  433. /* SPI flash chip (m25p64) */
  434. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  435. .enable_dma = 0, /* use dma transfer with this chip*/
  436. .bits_per_word = 8,
  437. };
  438. #endif
  439. #if defined(CONFIG_SPI_ADC_BF533) \
  440. || defined(CONFIG_SPI_ADC_BF533_MODULE)
  441. /* SPI ADC chip */
  442. static struct bfin5xx_spi_chip spi_adc_chip_info = {
  443. .enable_dma = 1, /* use dma transfer with this chip*/
  444. .bits_per_word = 16,
  445. };
  446. #endif
  447. #if defined(CONFIG_SND_BLACKFIN_AD1836) \
  448. || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  449. static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
  450. .enable_dma = 0,
  451. .bits_per_word = 16,
  452. };
  453. #endif
  454. #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
  455. static struct bfin5xx_spi_chip ad9960_spi_chip_info = {
  456. .enable_dma = 0,
  457. .bits_per_word = 16,
  458. };
  459. #endif
  460. #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
  461. static struct bfin5xx_spi_chip spi_mmc_chip_info = {
  462. .enable_dma = 1,
  463. .bits_per_word = 8,
  464. };
  465. #endif
  466. #if defined(CONFIG_PBX)
  467. static struct bfin5xx_spi_chip spi_si3xxx_chip_info = {
  468. .ctl_reg = 0x4, /* send zero */
  469. .enable_dma = 0,
  470. .bits_per_word = 8,
  471. .cs_change_per_word = 1,
  472. };
  473. #endif
  474. #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
  475. static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
  476. .enable_dma = 0,
  477. .bits_per_word = 16,
  478. };
  479. static const struct ad7877_platform_data bfin_ad7877_ts_info = {
  480. .model = 7877,
  481. .vref_delay_usecs = 50, /* internal, no capacitor */
  482. .x_plate_ohms = 419,
  483. .y_plate_ohms = 486,
  484. .pressure_max = 1000,
  485. .pressure_min = 0,
  486. .stopacq_polarity = 1,
  487. .first_conversion_delay = 3,
  488. .acquisition_time = 1,
  489. .averaging = 1,
  490. .pen_down_acc_interval = 1,
  491. };
  492. #endif
  493. #if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
  494. && defined(CONFIG_SND_SOC_WM8731_SPI)
  495. static struct bfin5xx_spi_chip spi_wm8731_chip_info = {
  496. .enable_dma = 0,
  497. .bits_per_word = 16,
  498. };
  499. #endif
  500. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  501. static struct bfin5xx_spi_chip spidev_chip_info = {
  502. .enable_dma = 0,
  503. .bits_per_word = 8,
  504. };
  505. #endif
  506. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  507. #if defined(CONFIG_MTD_M25P80) \
  508. || defined(CONFIG_MTD_M25P80_MODULE)
  509. {
  510. /* the modalias must be the same as spi device driver name */
  511. .modalias = "m25p80", /* Name of spi_driver for this device */
  512. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  513. .bus_num = 0, /* Framework bus number */
  514. .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
  515. .platform_data = &bfin_spi_flash_data,
  516. .controller_data = &spi_flash_chip_info,
  517. .mode = SPI_MODE_3,
  518. },
  519. #endif
  520. #if defined(CONFIG_SPI_ADC_BF533) \
  521. || defined(CONFIG_SPI_ADC_BF533_MODULE)
  522. {
  523. .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
  524. .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
  525. .bus_num = 0, /* Framework bus number */
  526. .chip_select = 1, /* Framework chip select. */
  527. .platform_data = NULL, /* No spi_driver specific config */
  528. .controller_data = &spi_adc_chip_info,
  529. },
  530. #endif
  531. #if defined(CONFIG_SND_BLACKFIN_AD1836) \
  532. || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  533. {
  534. .modalias = "ad1836-spi",
  535. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  536. .bus_num = 0,
  537. .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
  538. .controller_data = &ad1836_spi_chip_info,
  539. },
  540. #endif
  541. #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
  542. {
  543. .modalias = "ad9960-spi",
  544. .max_speed_hz = 10000000, /* max spi clock (SCK) speed in HZ */
  545. .bus_num = 0,
  546. .chip_select = 1,
  547. .controller_data = &ad9960_spi_chip_info,
  548. },
  549. #endif
  550. #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
  551. {
  552. .modalias = "spi_mmc_dummy",
  553. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  554. .bus_num = 0,
  555. .chip_select = 0,
  556. .platform_data = NULL,
  557. .controller_data = &spi_mmc_chip_info,
  558. .mode = SPI_MODE_3,
  559. },
  560. {
  561. .modalias = "spi_mmc",
  562. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  563. .bus_num = 0,
  564. .chip_select = CONFIG_SPI_MMC_CS_CHAN,
  565. .platform_data = NULL,
  566. .controller_data = &spi_mmc_chip_info,
  567. .mode = SPI_MODE_3,
  568. },
  569. #endif
  570. #if defined(CONFIG_PBX)
  571. {
  572. .modalias = "fxs-spi",
  573. .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
  574. .bus_num = 0,
  575. .chip_select = 8 - CONFIG_J11_JUMPER,
  576. .controller_data = &spi_si3xxx_chip_info,
  577. .mode = SPI_MODE_3,
  578. },
  579. {
  580. .modalias = "fxo-spi",
  581. .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
  582. .bus_num = 0,
  583. .chip_select = 8 - CONFIG_J19_JUMPER,
  584. .controller_data = &spi_si3xxx_chip_info,
  585. .mode = SPI_MODE_3,
  586. },
  587. #endif
  588. #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
  589. {
  590. .modalias = "ad7877",
  591. .platform_data = &bfin_ad7877_ts_info,
  592. .irq = IRQ_PF8,
  593. .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
  594. .bus_num = 0,
  595. .chip_select = 2,
  596. .controller_data = &spi_ad7877_chip_info,
  597. },
  598. #endif
  599. #if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
  600. && defined(CONFIG_SND_SOC_WM8731_SPI)
  601. {
  602. .modalias = "wm8731",
  603. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  604. .bus_num = 0,
  605. .chip_select = 5,
  606. .controller_data = &spi_wm8731_chip_info,
  607. .mode = SPI_MODE_0,
  608. },
  609. #endif
  610. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  611. {
  612. .modalias = "spidev",
  613. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  614. .bus_num = 0,
  615. .chip_select = 1,
  616. .controller_data = &spidev_chip_info,
  617. },
  618. #endif
  619. };
  620. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  621. /* SPI controller data */
  622. static struct bfin5xx_spi_master bfin_spi0_info = {
  623. .num_chipselect = 8,
  624. .enable_dma = 1, /* master has the ability to do dma transfer */
  625. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  626. };
  627. /* SPI (0) */
  628. static struct resource bfin_spi0_resource[] = {
  629. [0] = {
  630. .start = SPI0_REGBASE,
  631. .end = SPI0_REGBASE + 0xFF,
  632. .flags = IORESOURCE_MEM,
  633. },
  634. [1] = {
  635. .start = CH_SPI,
  636. .end = CH_SPI,
  637. .flags = IORESOURCE_IRQ,
  638. },
  639. };
  640. static struct platform_device bfin_spi0_device = {
  641. .name = "bfin-spi",
  642. .id = 0, /* Bus number */
  643. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  644. .resource = bfin_spi0_resource,
  645. .dev = {
  646. .platform_data = &bfin_spi0_info, /* Passed to driver */
  647. },
  648. };
  649. #endif /* spi master and devices */
  650. #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
  651. static struct platform_device bfin_fb_device = {
  652. .name = "bf537-lq035",
  653. };
  654. #endif
  655. #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
  656. static struct platform_device bfin_fb_adv7393_device = {
  657. .name = "bfin-adv7393",
  658. };
  659. #endif
  660. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  661. static struct resource bfin_uart_resources[] = {
  662. #ifdef CONFIG_SERIAL_BFIN_UART0
  663. {
  664. .start = 0xFFC00400,
  665. .end = 0xFFC004FF,
  666. .flags = IORESOURCE_MEM,
  667. },
  668. #endif
  669. #ifdef CONFIG_SERIAL_BFIN_UART1
  670. {
  671. .start = 0xFFC02000,
  672. .end = 0xFFC020FF,
  673. .flags = IORESOURCE_MEM,
  674. },
  675. #endif
  676. };
  677. static struct platform_device bfin_uart_device = {
  678. .name = "bfin-uart",
  679. .id = 1,
  680. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  681. .resource = bfin_uart_resources,
  682. };
  683. #endif
  684. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  685. static struct resource bfin_sir_resources[] = {
  686. #ifdef CONFIG_BFIN_SIR0
  687. {
  688. .start = 0xFFC00400,
  689. .end = 0xFFC004FF,
  690. .flags = IORESOURCE_MEM,
  691. },
  692. #endif
  693. #ifdef CONFIG_BFIN_SIR1
  694. {
  695. .start = 0xFFC02000,
  696. .end = 0xFFC020FF,
  697. .flags = IORESOURCE_MEM,
  698. },
  699. #endif
  700. };
  701. static struct platform_device bfin_sir_device = {
  702. .name = "bfin_sir",
  703. .id = 0,
  704. .num_resources = ARRAY_SIZE(bfin_sir_resources),
  705. .resource = bfin_sir_resources,
  706. };
  707. #endif
  708. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  709. static struct resource bfin_twi0_resource[] = {
  710. [0] = {
  711. .start = TWI0_REGBASE,
  712. .end = TWI0_REGBASE,
  713. .flags = IORESOURCE_MEM,
  714. },
  715. [1] = {
  716. .start = IRQ_TWI,
  717. .end = IRQ_TWI,
  718. .flags = IORESOURCE_IRQ,
  719. },
  720. };
  721. static struct platform_device i2c_bfin_twi_device = {
  722. .name = "i2c-bfin-twi",
  723. .id = 0,
  724. .num_resources = ARRAY_SIZE(bfin_twi0_resource),
  725. .resource = bfin_twi0_resource,
  726. };
  727. #endif
  728. #ifdef CONFIG_I2C_BOARDINFO
  729. static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
  730. #if defined(CONFIG_TWI_LCD) || defined(CONFIG_TWI_LCD_MODULE)
  731. {
  732. I2C_BOARD_INFO("pcf8574_lcd", 0x22),
  733. },
  734. #endif
  735. #if defined(CONFIG_TWI_KEYPAD) || defined(CONFIG_TWI_KEYPAD_MODULE)
  736. {
  737. I2C_BOARD_INFO("pcf8574_keypad", 0x27),
  738. .irq = IRQ_PF8,
  739. },
  740. #endif
  741. };
  742. #endif
  743. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  744. static struct platform_device bfin_sport0_uart_device = {
  745. .name = "bfin-sport-uart",
  746. .id = 0,
  747. };
  748. static struct platform_device bfin_sport1_uart_device = {
  749. .name = "bfin-sport-uart",
  750. .id = 1,
  751. };
  752. #endif
  753. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  754. #include <linux/input.h>
  755. #include <linux/gpio_keys.h>
  756. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  757. {BTN_0, GPIO_PG0, 1, "gpio-keys: BTN0"},
  758. {BTN_1, GPIO_PG13, 1, "gpio-keys: BTN1"},
  759. };
  760. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  761. .buttons = bfin_gpio_keys_table,
  762. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  763. };
  764. static struct platform_device bfin_device_gpiokeys = {
  765. .name = "gpio-keys",
  766. .dev = {
  767. .platform_data = &bfin_gpio_keys_data,
  768. },
  769. };
  770. #endif
  771. static struct resource bfin_gpios_resources = {
  772. .start = 0,
  773. .end = MAX_BLACKFIN_GPIOS - 1,
  774. .flags = IORESOURCE_IRQ,
  775. };
  776. static struct platform_device bfin_gpios_device = {
  777. .name = "simple-gpio",
  778. .id = -1,
  779. .num_resources = 1,
  780. .resource = &bfin_gpios_resources,
  781. };
  782. static const unsigned int cclk_vlev_datasheet[] =
  783. {
  784. VRPAIR(VLEV_100, 400000000),
  785. VRPAIR(VLEV_105, 426000000),
  786. VRPAIR(VLEV_110, 500000000),
  787. VRPAIR(VLEV_115, 533000000),
  788. VRPAIR(VLEV_120, 600000000),
  789. };
  790. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  791. .tuple_tab = cclk_vlev_datasheet,
  792. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  793. .vr_settling_time = 25 /* us */,
  794. };
  795. static struct platform_device bfin_dpmc = {
  796. .name = "bfin dpmc",
  797. .dev = {
  798. .platform_data = &bfin_dmpc_vreg_data,
  799. },
  800. };
  801. static struct platform_device *stamp_devices[] __initdata = {
  802. &bfin_dpmc,
  803. #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
  804. &bf5xx_nand_device,
  805. #endif
  806. #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
  807. &bfin_pcmcia_cf_device,
  808. #endif
  809. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  810. &rtc_device,
  811. #endif
  812. #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
  813. &sl811_hcd_device,
  814. #endif
  815. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  816. &isp1362_hcd_device,
  817. #endif
  818. #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
  819. &musb_device,
  820. #endif
  821. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  822. &smc91x_device,
  823. #endif
  824. #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
  825. &dm9000_device,
  826. #endif
  827. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  828. &bfin_mac_device,
  829. #endif
  830. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  831. &net2272_bfin_device,
  832. #endif
  833. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  834. &bfin_spi0_device,
  835. #endif
  836. #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
  837. &bfin_fb_device,
  838. #endif
  839. #if defined(CONFIG_FB_BFIN_T350MCQB) || defined(CONFIG_FB_BFIN_T350MCQB_MODULE)
  840. &bf52x_t350mcqb_device,
  841. #endif
  842. #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
  843. &bfin_fb_adv7393_device,
  844. #endif
  845. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  846. &bfin_uart_device,
  847. #endif
  848. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  849. &bfin_sir_device,
  850. #endif
  851. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  852. &i2c_bfin_twi_device,
  853. #endif
  854. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  855. &bfin_sport0_uart_device,
  856. &bfin_sport1_uart_device,
  857. #endif
  858. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  859. &bfin_device_gpiokeys,
  860. #endif
  861. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  862. &ezkit_flash_device,
  863. #endif
  864. &bfin_gpios_device,
  865. };
  866. static int __init stamp_init(void)
  867. {
  868. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  869. #ifdef CONFIG_I2C_BOARDINFO
  870. i2c_register_board_info(0, bfin_i2c_board_info,
  871. ARRAY_SIZE(bfin_i2c_board_info));
  872. #endif
  873. platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
  874. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  875. return 0;
  876. }
  877. arch_initcall(stamp_init);
  878. void native_machine_restart(char *cmd)
  879. {
  880. /* workaround reboot hang when booting from SPI */
  881. if ((bfin_read_SYSCR() & 0x7) == 0x3)
  882. bfin_gpio_reset_spi0_ssel1();
  883. }
  884. void bfin_get_ether_addr(char *addr)
  885. {
  886. /* the MAC is stored in OTP memory page 0xDF */
  887. u32 ret;
  888. u64 otp_mac;
  889. u32 (*otp_read)(u32 page, u32 flags, u64 *page_content) = (void *)0xEF00001A;
  890. ret = otp_read(0xDF, 0x00, &otp_mac);
  891. if (!(ret & 0x1)) {
  892. char *otp_mac_p = (char *)&otp_mac;
  893. for (ret = 0; ret < 6; ++ret)
  894. addr[ret] = otp_mac_p[5 - ret];
  895. }
  896. }
  897. EXPORT_SYMBOL(bfin_get_ether_addr);