ezkit.c 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110
  1. /*
  2. * File: arch/blackfin/mach-bf527/boards/ezkit.c
  3. * Based on: arch/blackfin/mach-bf537/boards/stamp.c
  4. * Author: Aidan Williams <aidan@nicta.com.au>
  5. *
  6. * Created:
  7. * Description:
  8. *
  9. * Modified:
  10. * Copyright 2005 National ICT Australia (NICTA)
  11. * Copyright 2004-2008 Analog Devices Inc.
  12. *
  13. * Bugs: Enter bugs at http://blackfin.uclinux.org/
  14. *
  15. * This program is free software; you can redistribute it and/or modify
  16. * it under the terms of the GNU General Public License as published by
  17. * the Free Software Foundation; either version 2 of the License, or
  18. * (at your option) any later version.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU General Public License
  26. * along with this program; if not, see the file COPYING, or write
  27. * to the Free Software Foundation, Inc.,
  28. * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  29. */
  30. #include <linux/device.h>
  31. #include <linux/platform_device.h>
  32. #include <linux/mtd/mtd.h>
  33. #include <linux/mtd/partitions.h>
  34. #include <linux/mtd/physmap.h>
  35. #include <linux/spi/spi.h>
  36. #include <linux/spi/flash.h>
  37. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  38. #include <linux/usb/isp1362.h>
  39. #endif
  40. #include <linux/i2c.h>
  41. #include <linux/irq.h>
  42. #include <linux/interrupt.h>
  43. #include <linux/usb/sl811.h>
  44. #include <linux/usb/musb.h>
  45. #include <asm/dma.h>
  46. #include <asm/bfin5xx_spi.h>
  47. #include <asm/reboot.h>
  48. #include <asm/nand.h>
  49. #include <asm/portmux.h>
  50. #include <asm/dpmc.h>
  51. #include <linux/spi/ad7877.h>
  52. /*
  53. * Name the Board for the /proc/cpuinfo
  54. */
  55. const char bfin_board_name[] = "ADI BF527-EZKIT";
  56. /*
  57. * Driver needs to know address, irq and flag pin.
  58. */
  59. #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
  60. #include <linux/usb/isp1760.h>
  61. static struct resource bfin_isp1760_resources[] = {
  62. [0] = {
  63. .start = 0x203C0000,
  64. .end = 0x203C0000 + 0x000fffff,
  65. .flags = IORESOURCE_MEM,
  66. },
  67. [1] = {
  68. .start = IRQ_PF7,
  69. .end = IRQ_PF7,
  70. .flags = IORESOURCE_IRQ,
  71. },
  72. };
  73. static struct isp1760_platform_data isp1760_priv = {
  74. .is_isp1761 = 0,
  75. .bus_width_16 = 1,
  76. .port1_otg = 0,
  77. .analog_oc = 0,
  78. .dack_polarity_high = 0,
  79. .dreq_polarity_high = 0,
  80. };
  81. static struct platform_device bfin_isp1760_device = {
  82. .name = "isp1760-hcd",
  83. .id = 0,
  84. .dev = {
  85. .platform_data = &isp1760_priv,
  86. },
  87. .num_resources = ARRAY_SIZE(bfin_isp1760_resources),
  88. .resource = bfin_isp1760_resources,
  89. };
  90. #endif
  91. #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
  92. static struct resource musb_resources[] = {
  93. [0] = {
  94. .start = 0xffc03800,
  95. .end = 0xffc03cff,
  96. .flags = IORESOURCE_MEM,
  97. },
  98. [1] = { /* general IRQ */
  99. .start = IRQ_USB_INT0,
  100. .end = IRQ_USB_INT0,
  101. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  102. },
  103. [2] = { /* DMA IRQ */
  104. .start = IRQ_USB_DMA,
  105. .end = IRQ_USB_DMA,
  106. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  107. },
  108. };
  109. static struct musb_hdrc_config musb_config = {
  110. .multipoint = 0,
  111. .dyn_fifo = 0,
  112. .soft_con = 1,
  113. .dma = 1,
  114. .num_eps = 8,
  115. .dma_channels = 8,
  116. .gpio_vrsel = GPIO_PG13,
  117. };
  118. static struct musb_hdrc_platform_data musb_plat = {
  119. #if defined(CONFIG_USB_MUSB_OTG)
  120. .mode = MUSB_OTG,
  121. #elif defined(CONFIG_USB_MUSB_HDRC_HCD)
  122. .mode = MUSB_HOST,
  123. #elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
  124. .mode = MUSB_PERIPHERAL,
  125. #endif
  126. .config = &musb_config,
  127. };
  128. static u64 musb_dmamask = ~(u32)0;
  129. static struct platform_device musb_device = {
  130. .name = "musb_hdrc",
  131. .id = 0,
  132. .dev = {
  133. .dma_mask = &musb_dmamask,
  134. .coherent_dma_mask = 0xffffffff,
  135. .platform_data = &musb_plat,
  136. },
  137. .num_resources = ARRAY_SIZE(musb_resources),
  138. .resource = musb_resources,
  139. };
  140. #endif
  141. #if defined(CONFIG_FB_BFIN_T350MCQB) || defined(CONFIG_FB_BFIN_T350MCQB_MODULE)
  142. static struct resource bf52x_t350mcqb_resources[] = {
  143. {
  144. .start = IRQ_PPI_ERROR,
  145. .end = IRQ_PPI_ERROR,
  146. .flags = IORESOURCE_IRQ,
  147. },
  148. };
  149. static struct platform_device bf52x_t350mcqb_device = {
  150. .name = "bfin-t350mcqb",
  151. .id = -1,
  152. .num_resources = ARRAY_SIZE(bf52x_t350mcqb_resources),
  153. .resource = bf52x_t350mcqb_resources,
  154. };
  155. #endif
  156. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  157. static struct mtd_partition ezkit_partitions[] = {
  158. {
  159. .name = "bootloader(nor)",
  160. .size = 0x40000,
  161. .offset = 0,
  162. }, {
  163. .name = "linux kernel(nor)",
  164. .size = 0x1C0000,
  165. .offset = MTDPART_OFS_APPEND,
  166. }, {
  167. .name = "file system(nor)",
  168. .size = MTDPART_SIZ_FULL,
  169. .offset = MTDPART_OFS_APPEND,
  170. }
  171. };
  172. static struct physmap_flash_data ezkit_flash_data = {
  173. .width = 2,
  174. .parts = ezkit_partitions,
  175. .nr_parts = ARRAY_SIZE(ezkit_partitions),
  176. };
  177. static struct resource ezkit_flash_resource = {
  178. .start = 0x20000000,
  179. .end = 0x203fffff,
  180. .flags = IORESOURCE_MEM,
  181. };
  182. static struct platform_device ezkit_flash_device = {
  183. .name = "physmap-flash",
  184. .id = 0,
  185. .dev = {
  186. .platform_data = &ezkit_flash_data,
  187. },
  188. .num_resources = 1,
  189. .resource = &ezkit_flash_resource,
  190. };
  191. #endif
  192. #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
  193. static struct mtd_partition partition_info[] = {
  194. {
  195. .name = "linux kernel(nand)",
  196. .offset = 0,
  197. .size = 4 * 1024 * 1024,
  198. },
  199. {
  200. .name = "file system(nand)",
  201. .offset = MTDPART_OFS_APPEND,
  202. .size = MTDPART_SIZ_FULL,
  203. },
  204. };
  205. static struct bf5xx_nand_platform bf5xx_nand_platform = {
  206. .page_size = NFC_PG_SIZE_256,
  207. .data_width = NFC_NWIDTH_8,
  208. .partitions = partition_info,
  209. .nr_partitions = ARRAY_SIZE(partition_info),
  210. .rd_dly = 3,
  211. .wr_dly = 3,
  212. };
  213. static struct resource bf5xx_nand_resources[] = {
  214. {
  215. .start = NFC_CTL,
  216. .end = NFC_DATA_RD + 2,
  217. .flags = IORESOURCE_MEM,
  218. },
  219. {
  220. .start = CH_NFC,
  221. .end = CH_NFC,
  222. .flags = IORESOURCE_IRQ,
  223. },
  224. };
  225. static struct platform_device bf5xx_nand_device = {
  226. .name = "bf5xx-nand",
  227. .id = 0,
  228. .num_resources = ARRAY_SIZE(bf5xx_nand_resources),
  229. .resource = bf5xx_nand_resources,
  230. .dev = {
  231. .platform_data = &bf5xx_nand_platform,
  232. },
  233. };
  234. #endif
  235. #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
  236. static struct resource bfin_pcmcia_cf_resources[] = {
  237. {
  238. .start = 0x20310000, /* IO PORT */
  239. .end = 0x20312000,
  240. .flags = IORESOURCE_MEM,
  241. }, {
  242. .start = 0x20311000, /* Attribute Memory */
  243. .end = 0x20311FFF,
  244. .flags = IORESOURCE_MEM,
  245. }, {
  246. .start = IRQ_PF4,
  247. .end = IRQ_PF4,
  248. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  249. }, {
  250. .start = 6, /* Card Detect PF6 */
  251. .end = 6,
  252. .flags = IORESOURCE_IRQ,
  253. },
  254. };
  255. static struct platform_device bfin_pcmcia_cf_device = {
  256. .name = "bfin_cf_pcmcia",
  257. .id = -1,
  258. .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
  259. .resource = bfin_pcmcia_cf_resources,
  260. };
  261. #endif
  262. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  263. static struct platform_device rtc_device = {
  264. .name = "rtc-bfin",
  265. .id = -1,
  266. };
  267. #endif
  268. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  269. 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_mii_bus = {
  391. .name = "bfin_mii_bus",
  392. };
  393. static struct platform_device bfin_mac_device = {
  394. .name = "bfin_mac",
  395. .dev.platform_data = &bfin_mii_bus,
  396. };
  397. #endif
  398. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  399. static struct resource net2272_bfin_resources[] = {
  400. {
  401. .start = 0x20300000,
  402. .end = 0x20300000 + 0x100,
  403. .flags = IORESOURCE_MEM,
  404. }, {
  405. .start = IRQ_PF7,
  406. .end = IRQ_PF7,
  407. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  408. },
  409. };
  410. static struct platform_device net2272_bfin_device = {
  411. .name = "net2272",
  412. .id = -1,
  413. .num_resources = ARRAY_SIZE(net2272_bfin_resources),
  414. .resource = net2272_bfin_resources,
  415. };
  416. #endif
  417. #if defined(CONFIG_MTD_M25P80) \
  418. || defined(CONFIG_MTD_M25P80_MODULE)
  419. static struct mtd_partition bfin_spi_flash_partitions[] = {
  420. {
  421. .name = "bootloader(spi)",
  422. .size = 0x00040000,
  423. .offset = 0,
  424. .mask_flags = MTD_CAP_ROM
  425. }, {
  426. .name = "linux kernel(spi)",
  427. .size = MTDPART_SIZ_FULL,
  428. .offset = MTDPART_OFS_APPEND,
  429. }
  430. };
  431. static struct flash_platform_data bfin_spi_flash_data = {
  432. .name = "m25p80",
  433. .parts = bfin_spi_flash_partitions,
  434. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  435. .type = "m25p16",
  436. };
  437. /* SPI flash chip (m25p64) */
  438. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  439. .enable_dma = 0, /* use dma transfer with this chip*/
  440. .bits_per_word = 8,
  441. };
  442. #endif
  443. #if defined(CONFIG_BFIN_SPI_ADC) \
  444. || defined(CONFIG_BFIN_SPI_ADC_MODULE)
  445. /* SPI ADC chip */
  446. static struct bfin5xx_spi_chip spi_adc_chip_info = {
  447. .enable_dma = 1, /* use dma transfer with this chip*/
  448. .bits_per_word = 16,
  449. };
  450. #endif
  451. #if defined(CONFIG_SND_BLACKFIN_AD1836) \
  452. || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  453. static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
  454. .enable_dma = 0,
  455. .bits_per_word = 16,
  456. };
  457. #endif
  458. #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
  459. static struct bfin5xx_spi_chip ad9960_spi_chip_info = {
  460. .enable_dma = 0,
  461. .bits_per_word = 16,
  462. };
  463. #endif
  464. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  465. static struct bfin5xx_spi_chip mmc_spi_chip_info = {
  466. .enable_dma = 0,
  467. .bits_per_word = 8,
  468. };
  469. #endif
  470. #if defined(CONFIG_PBX)
  471. static struct bfin5xx_spi_chip spi_si3xxx_chip_info = {
  472. .ctl_reg = 0x4, /* send zero */
  473. .enable_dma = 0,
  474. .bits_per_word = 8,
  475. .cs_change_per_word = 1,
  476. };
  477. #endif
  478. #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
  479. static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
  480. .enable_dma = 0,
  481. .bits_per_word = 16,
  482. };
  483. static const struct ad7877_platform_data bfin_ad7877_ts_info = {
  484. .model = 7877,
  485. .vref_delay_usecs = 50, /* internal, no capacitor */
  486. .x_plate_ohms = 419,
  487. .y_plate_ohms = 486,
  488. .pressure_max = 1000,
  489. .pressure_min = 0,
  490. .stopacq_polarity = 1,
  491. .first_conversion_delay = 3,
  492. .acquisition_time = 1,
  493. .averaging = 1,
  494. .pen_down_acc_interval = 1,
  495. };
  496. #endif
  497. #if defined(CONFIG_TOUCHSCREEN_AD7879) || defined(CONFIG_TOUCHSCREEN_AD7879_MODULE)
  498. #include <linux/spi/ad7879.h>
  499. static const struct ad7879_platform_data bfin_ad7879_ts_info = {
  500. .model = 7879, /* Model = AD7879 */
  501. .x_plate_ohms = 620, /* 620 Ohm from the touch datasheet */
  502. .pressure_max = 10000,
  503. .pressure_min = 0,
  504. .first_conversion_delay = 3, /* wait 512us before do a first conversion */
  505. .acquisition_time = 1, /* 4us acquisition time per sample */
  506. .median = 2, /* do 8 measurements */
  507. .averaging = 1, /* take the average of 4 middle samples */
  508. .pen_down_acc_interval = 255, /* 9.4 ms */
  509. .gpio_output = 1, /* configure AUX/VBAT/GPIO as GPIO output */
  510. .gpio_default = 1, /* During initialization set GPIO = HIGH */
  511. };
  512. #endif
  513. #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
  514. static struct bfin5xx_spi_chip spi_ad7879_chip_info = {
  515. .enable_dma = 0,
  516. .bits_per_word = 16,
  517. };
  518. #endif
  519. #if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
  520. && defined(CONFIG_SND_SOC_WM8731_SPI)
  521. static struct bfin5xx_spi_chip spi_wm8731_chip_info = {
  522. .enable_dma = 0,
  523. .bits_per_word = 16,
  524. };
  525. #endif
  526. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  527. static struct bfin5xx_spi_chip spidev_chip_info = {
  528. .enable_dma = 0,
  529. .bits_per_word = 8,
  530. };
  531. #endif
  532. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  533. #if defined(CONFIG_MTD_M25P80) \
  534. || defined(CONFIG_MTD_M25P80_MODULE)
  535. {
  536. /* the modalias must be the same as spi device driver name */
  537. .modalias = "m25p80", /* Name of spi_driver for this device */
  538. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  539. .bus_num = 0, /* Framework bus number */
  540. .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
  541. .platform_data = &bfin_spi_flash_data,
  542. .controller_data = &spi_flash_chip_info,
  543. .mode = SPI_MODE_3,
  544. },
  545. #endif
  546. #if defined(CONFIG_BFIN_SPI_ADC) \
  547. || defined(CONFIG_BFIN_SPI_ADC_MODULE)
  548. {
  549. .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
  550. .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
  551. .bus_num = 0, /* Framework bus number */
  552. .chip_select = 1, /* Framework chip select. */
  553. .platform_data = NULL, /* No spi_driver specific config */
  554. .controller_data = &spi_adc_chip_info,
  555. },
  556. #endif
  557. #if defined(CONFIG_SND_BLACKFIN_AD1836) \
  558. || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  559. {
  560. .modalias = "ad1836-spi",
  561. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  562. .bus_num = 0,
  563. .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
  564. .controller_data = &ad1836_spi_chip_info,
  565. },
  566. #endif
  567. #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
  568. {
  569. .modalias = "ad9960-spi",
  570. .max_speed_hz = 10000000, /* max spi clock (SCK) speed in HZ */
  571. .bus_num = 0,
  572. .chip_select = 1,
  573. .controller_data = &ad9960_spi_chip_info,
  574. },
  575. #endif
  576. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  577. {
  578. .modalias = "mmc_spi",
  579. .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
  580. .bus_num = 0,
  581. .chip_select = 3,
  582. .controller_data = &mmc_spi_chip_info,
  583. .mode = SPI_MODE_0,
  584. },
  585. #endif
  586. #if defined(CONFIG_PBX)
  587. {
  588. .modalias = "fxs-spi",
  589. .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
  590. .bus_num = 0,
  591. .chip_select = 8 - CONFIG_J11_JUMPER,
  592. .controller_data = &spi_si3xxx_chip_info,
  593. .mode = SPI_MODE_3,
  594. },
  595. {
  596. .modalias = "fxo-spi",
  597. .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
  598. .bus_num = 0,
  599. .chip_select = 8 - CONFIG_J19_JUMPER,
  600. .controller_data = &spi_si3xxx_chip_info,
  601. .mode = SPI_MODE_3,
  602. },
  603. #endif
  604. #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
  605. {
  606. .modalias = "ad7877",
  607. .platform_data = &bfin_ad7877_ts_info,
  608. .irq = IRQ_PF8,
  609. .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
  610. .bus_num = 0,
  611. .chip_select = 2,
  612. .controller_data = &spi_ad7877_chip_info,
  613. },
  614. #endif
  615. #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
  616. {
  617. .modalias = "ad7879",
  618. .platform_data = &bfin_ad7879_ts_info,
  619. .irq = IRQ_PF8,
  620. .max_speed_hz = 5000000, /* max spi clock (SCK) speed in HZ */
  621. .bus_num = 0,
  622. .chip_select = 3,
  623. .controller_data = &spi_ad7879_chip_info,
  624. .mode = SPI_CPHA | SPI_CPOL,
  625. },
  626. #endif
  627. #if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
  628. && defined(CONFIG_SND_SOC_WM8731_SPI)
  629. {
  630. .modalias = "wm8731",
  631. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  632. .bus_num = 0,
  633. .chip_select = 5,
  634. .controller_data = &spi_wm8731_chip_info,
  635. .mode = SPI_MODE_0,
  636. },
  637. #endif
  638. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  639. {
  640. .modalias = "spidev",
  641. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  642. .bus_num = 0,
  643. .chip_select = 1,
  644. .controller_data = &spidev_chip_info,
  645. },
  646. #endif
  647. };
  648. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  649. /* SPI controller data */
  650. static struct bfin5xx_spi_master bfin_spi0_info = {
  651. .num_chipselect = 8,
  652. .enable_dma = 1, /* master has the ability to do dma transfer */
  653. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  654. };
  655. /* SPI (0) */
  656. static struct resource bfin_spi0_resource[] = {
  657. [0] = {
  658. .start = SPI0_REGBASE,
  659. .end = SPI0_REGBASE + 0xFF,
  660. .flags = IORESOURCE_MEM,
  661. },
  662. [1] = {
  663. .start = CH_SPI,
  664. .end = CH_SPI,
  665. .flags = IORESOURCE_DMA,
  666. },
  667. [2] = {
  668. .start = IRQ_SPI,
  669. .end = IRQ_SPI,
  670. .flags = IORESOURCE_IRQ,
  671. },
  672. };
  673. static struct platform_device bfin_spi0_device = {
  674. .name = "bfin-spi",
  675. .id = 0, /* Bus number */
  676. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  677. .resource = bfin_spi0_resource,
  678. .dev = {
  679. .platform_data = &bfin_spi0_info, /* Passed to driver */
  680. },
  681. };
  682. #endif /* spi master and devices */
  683. #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
  684. static struct platform_device bfin_fb_device = {
  685. .name = "bf537-lq035",
  686. };
  687. #endif
  688. #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
  689. static struct platform_device bfin_fb_adv7393_device = {
  690. .name = "bfin-adv7393",
  691. };
  692. #endif
  693. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  694. static struct resource bfin_uart_resources[] = {
  695. #ifdef CONFIG_SERIAL_BFIN_UART0
  696. {
  697. .start = 0xFFC00400,
  698. .end = 0xFFC004FF,
  699. .flags = IORESOURCE_MEM,
  700. },
  701. #endif
  702. #ifdef CONFIG_SERIAL_BFIN_UART1
  703. {
  704. .start = 0xFFC02000,
  705. .end = 0xFFC020FF,
  706. .flags = IORESOURCE_MEM,
  707. },
  708. #endif
  709. };
  710. static struct platform_device bfin_uart_device = {
  711. .name = "bfin-uart",
  712. .id = 1,
  713. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  714. .resource = bfin_uart_resources,
  715. };
  716. #endif
  717. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  718. #ifdef CONFIG_BFIN_SIR0
  719. static struct resource bfin_sir0_resources[] = {
  720. {
  721. .start = 0xFFC00400,
  722. .end = 0xFFC004FF,
  723. .flags = IORESOURCE_MEM,
  724. },
  725. {
  726. .start = IRQ_UART0_RX,
  727. .end = IRQ_UART0_RX+1,
  728. .flags = IORESOURCE_IRQ,
  729. },
  730. {
  731. .start = CH_UART0_RX,
  732. .end = CH_UART0_RX+1,
  733. .flags = IORESOURCE_DMA,
  734. },
  735. };
  736. static struct platform_device bfin_sir0_device = {
  737. .name = "bfin_sir",
  738. .id = 0,
  739. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  740. .resource = bfin_sir0_resources,
  741. };
  742. #endif
  743. #ifdef CONFIG_BFIN_SIR1
  744. static struct resource bfin_sir1_resources[] = {
  745. {
  746. .start = 0xFFC02000,
  747. .end = 0xFFC020FF,
  748. .flags = IORESOURCE_MEM,
  749. },
  750. {
  751. .start = IRQ_UART1_RX,
  752. .end = IRQ_UART1_RX+1,
  753. .flags = IORESOURCE_IRQ,
  754. },
  755. {
  756. .start = CH_UART1_RX,
  757. .end = CH_UART1_RX+1,
  758. .flags = IORESOURCE_DMA,
  759. },
  760. };
  761. static struct platform_device bfin_sir1_device = {
  762. .name = "bfin_sir",
  763. .id = 1,
  764. .num_resources = ARRAY_SIZE(bfin_sir1_resources),
  765. .resource = bfin_sir1_resources,
  766. };
  767. #endif
  768. #endif
  769. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  770. static struct resource bfin_twi0_resource[] = {
  771. [0] = {
  772. .start = TWI0_REGBASE,
  773. .end = TWI0_REGBASE,
  774. .flags = IORESOURCE_MEM,
  775. },
  776. [1] = {
  777. .start = IRQ_TWI,
  778. .end = IRQ_TWI,
  779. .flags = IORESOURCE_IRQ,
  780. },
  781. };
  782. static struct platform_device i2c_bfin_twi_device = {
  783. .name = "i2c-bfin-twi",
  784. .id = 0,
  785. .num_resources = ARRAY_SIZE(bfin_twi0_resource),
  786. .resource = bfin_twi0_resource,
  787. };
  788. #endif
  789. static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
  790. #if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_TWI_LCD_MODULE)
  791. {
  792. I2C_BOARD_INFO("pcf8574_lcd", 0x22),
  793. },
  794. #endif
  795. #if defined(CONFIG_TWI_KEYPAD) || defined(CONFIG_TWI_KEYPAD_MODULE)
  796. {
  797. I2C_BOARD_INFO("pcf8574_keypad", 0x27),
  798. .irq = IRQ_PF8,
  799. },
  800. #endif
  801. };
  802. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  803. static struct platform_device bfin_sport0_uart_device = {
  804. .name = "bfin-sport-uart",
  805. .id = 0,
  806. };
  807. static struct platform_device bfin_sport1_uart_device = {
  808. .name = "bfin-sport-uart",
  809. .id = 1,
  810. };
  811. #endif
  812. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  813. #include <linux/input.h>
  814. #include <linux/gpio_keys.h>
  815. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  816. {BTN_0, GPIO_PG0, 1, "gpio-keys: BTN0"},
  817. {BTN_1, GPIO_PG13, 1, "gpio-keys: BTN1"},
  818. };
  819. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  820. .buttons = bfin_gpio_keys_table,
  821. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  822. };
  823. static struct platform_device bfin_device_gpiokeys = {
  824. .name = "gpio-keys",
  825. .dev = {
  826. .platform_data = &bfin_gpio_keys_data,
  827. },
  828. };
  829. #endif
  830. #if defined(CONFIG_JOYSTICK_BFIN_ROTARY) || defined(CONFIG_JOYSTICK_BFIN_ROTARY_MODULE)
  831. #include <linux/input.h>
  832. #include <asm/bfin_rotary.h>
  833. static struct bfin_rotary_platform_data bfin_rotary_data = {
  834. /*.rotary_up_key = KEY_UP,*/
  835. /*.rotary_down_key = KEY_DOWN,*/
  836. .rotary_rel_code = REL_WHEEL,
  837. .rotary_button_key = KEY_ENTER,
  838. .debounce = 10, /* 0..17 */
  839. .mode = ROT_QUAD_ENC | ROT_DEBE,
  840. };
  841. static struct resource bfin_rotary_resources[] = {
  842. {
  843. .start = IRQ_CNT,
  844. .end = IRQ_CNT,
  845. .flags = IORESOURCE_IRQ,
  846. },
  847. };
  848. static struct platform_device bfin_rotary_device = {
  849. .name = "bfin-rotary",
  850. .id = -1,
  851. .num_resources = ARRAY_SIZE(bfin_rotary_resources),
  852. .resource = bfin_rotary_resources,
  853. .dev = {
  854. .platform_data = &bfin_rotary_data,
  855. },
  856. };
  857. #endif
  858. static struct resource bfin_gpios_resources = {
  859. .start = 0,
  860. .end = MAX_BLACKFIN_GPIOS - 1,
  861. .flags = IORESOURCE_IRQ,
  862. };
  863. static struct platform_device bfin_gpios_device = {
  864. .name = "simple-gpio",
  865. .id = -1,
  866. .num_resources = 1,
  867. .resource = &bfin_gpios_resources,
  868. };
  869. static const unsigned int cclk_vlev_datasheet[] =
  870. {
  871. VRPAIR(VLEV_100, 400000000),
  872. VRPAIR(VLEV_105, 426000000),
  873. VRPAIR(VLEV_110, 500000000),
  874. VRPAIR(VLEV_115, 533000000),
  875. VRPAIR(VLEV_120, 600000000),
  876. };
  877. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  878. .tuple_tab = cclk_vlev_datasheet,
  879. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  880. .vr_settling_time = 25 /* us */,
  881. };
  882. static struct platform_device bfin_dpmc = {
  883. .name = "bfin dpmc",
  884. .dev = {
  885. .platform_data = &bfin_dmpc_vreg_data,
  886. },
  887. };
  888. static struct platform_device *stamp_devices[] __initdata = {
  889. &bfin_dpmc,
  890. #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
  891. &bf5xx_nand_device,
  892. #endif
  893. #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
  894. &bfin_pcmcia_cf_device,
  895. #endif
  896. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  897. &rtc_device,
  898. #endif
  899. #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
  900. &sl811_hcd_device,
  901. #endif
  902. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  903. &isp1362_hcd_device,
  904. #endif
  905. #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
  906. &bfin_isp1760_device,
  907. #endif
  908. #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
  909. &musb_device,
  910. #endif
  911. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  912. &smc91x_device,
  913. #endif
  914. #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
  915. &dm9000_device,
  916. #endif
  917. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  918. &bfin_mii_bus,
  919. &bfin_mac_device,
  920. #endif
  921. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  922. &net2272_bfin_device,
  923. #endif
  924. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  925. &bfin_spi0_device,
  926. #endif
  927. #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
  928. &bfin_fb_device,
  929. #endif
  930. #if defined(CONFIG_FB_BFIN_T350MCQB) || defined(CONFIG_FB_BFIN_T350MCQB_MODULE)
  931. &bf52x_t350mcqb_device,
  932. #endif
  933. #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
  934. &bfin_fb_adv7393_device,
  935. #endif
  936. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  937. &bfin_uart_device,
  938. #endif
  939. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  940. #ifdef CONFIG_BFIN_SIR0
  941. &bfin_sir0_device,
  942. #endif
  943. #ifdef CONFIG_BFIN_SIR1
  944. &bfin_sir1_device,
  945. #endif
  946. #endif
  947. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  948. &i2c_bfin_twi_device,
  949. #endif
  950. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  951. &bfin_sport0_uart_device,
  952. &bfin_sport1_uart_device,
  953. #endif
  954. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  955. &bfin_device_gpiokeys,
  956. #endif
  957. #if defined(CONFIG_JOYSTICK_BFIN_ROTARY) || defined(CONFIG_JOYSTICK_BFIN_ROTARY_MODULE)
  958. &bfin_rotary_device,
  959. #endif
  960. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  961. &ezkit_flash_device,
  962. #endif
  963. &bfin_gpios_device,
  964. };
  965. static int __init ezkit_init(void)
  966. {
  967. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  968. i2c_register_board_info(0, bfin_i2c_board_info,
  969. ARRAY_SIZE(bfin_i2c_board_info));
  970. platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
  971. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  972. return 0;
  973. }
  974. arch_initcall(ezkit_init);
  975. void native_machine_restart(char *cmd)
  976. {
  977. /* workaround reboot hang when booting from SPI */
  978. if ((bfin_read_SYSCR() & 0x7) == 0x3)
  979. bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
  980. }
  981. void bfin_get_ether_addr(char *addr)
  982. {
  983. /* the MAC is stored in OTP memory page 0xDF */
  984. u32 ret;
  985. u64 otp_mac;
  986. u32 (*otp_read)(u32 page, u32 flags, u64 *page_content) = (void *)0xEF00001A;
  987. ret = otp_read(0xDF, 0x00, &otp_mac);
  988. if (!(ret & 0x1)) {
  989. char *otp_mac_p = (char *)&otp_mac;
  990. for (ret = 0; ret < 6; ++ret)
  991. addr[ret] = otp_mac_p[5 - ret];
  992. }
  993. }
  994. EXPORT_SYMBOL(bfin_get_ether_addr);