ezkit.c 24 KB

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