ezkit.c 23 KB

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