ezkit.c 27 KB

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