pnav10.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  1. /*
  2. * File: arch/blackfin/mach-bf537/boards/stamp.c
  3. * Based on: arch/blackfin/mach-bf533/boards/ezkit.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-2006 Analog Devices Inc.
  12. *
  13. * Bugs: Enter bugs at http://blackfin.uclinux.org/
  14. *
  15. * This program is free software; you can redistribute it and/or modify
  16. * it under the terms of the GNU General Public License as published by
  17. * the Free Software Foundation; either version 2 of the License, or
  18. * (at your option) any later version.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU General Public License
  26. * along with this program; if not, see the file COPYING, or write
  27. * to the Free Software Foundation, Inc.,
  28. * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  29. */
  30. #include <linux/device.h>
  31. #include <linux/platform_device.h>
  32. #include <linux/mtd/mtd.h>
  33. #include <linux/mtd/partitions.h>
  34. #include <linux/spi/spi.h>
  35. #include <linux/spi/flash.h>
  36. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  37. #include <linux/usb_isp1362.h>
  38. #endif
  39. #include <linux/irq.h>
  40. #include <asm/dma.h>
  41. #include <asm/bfin5xx_spi.h>
  42. #include <linux/usb/sl811.h>
  43. #include <linux/spi/ad7877.h>
  44. /*
  45. * Name the Board for the /proc/cpuinfo
  46. */
  47. char *bfin_board_name = "PNAV-1.0";
  48. /*
  49. * Driver needs to know address, irq and flag pin.
  50. */
  51. #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
  52. static struct resource bfin_pcmcia_cf_resources[] = {
  53. {
  54. .start = 0x20310000, /* IO PORT */
  55. .end = 0x20312000,
  56. .flags = IORESOURCE_MEM,
  57. }, {
  58. .start = 0x20311000, /* Attribute Memory */
  59. .end = 0x20311FFF,
  60. .flags = IORESOURCE_MEM,
  61. }, {
  62. .start = IRQ_PF4,
  63. .end = IRQ_PF4,
  64. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  65. }, {
  66. .start = 6, /* Card Detect PF6 */
  67. .end = 6,
  68. .flags = IORESOURCE_IRQ,
  69. },
  70. };
  71. static struct platform_device bfin_pcmcia_cf_device = {
  72. .name = "bfin_cf_pcmcia",
  73. .id = -1,
  74. .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
  75. .resource = bfin_pcmcia_cf_resources,
  76. };
  77. #endif
  78. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  79. static struct platform_device rtc_device = {
  80. .name = "rtc-bfin",
  81. .id = -1,
  82. };
  83. #endif
  84. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  85. static struct resource smc91x_resources[] = {
  86. {
  87. .name = "smc91x-regs",
  88. .start = 0x20300300,
  89. .end = 0x20300300 + 16,
  90. .flags = IORESOURCE_MEM,
  91. }, {
  92. .start = IRQ_PF7,
  93. .end = IRQ_PF7,
  94. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  95. },
  96. };
  97. static struct platform_device smc91x_device = {
  98. .name = "smc91x",
  99. .id = 0,
  100. .num_resources = ARRAY_SIZE(smc91x_resources),
  101. .resource = smc91x_resources,
  102. };
  103. #endif
  104. #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
  105. static struct resource sl811_hcd_resources[] = {
  106. {
  107. .start = 0x20340000,
  108. .end = 0x20340000,
  109. .flags = IORESOURCE_MEM,
  110. }, {
  111. .start = 0x20340004,
  112. .end = 0x20340004,
  113. .flags = IORESOURCE_MEM,
  114. }, {
  115. .start = CONFIG_USB_SL811_BFIN_IRQ,
  116. .end = CONFIG_USB_SL811_BFIN_IRQ,
  117. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  118. },
  119. };
  120. #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
  121. void sl811_port_power(struct device *dev, int is_on)
  122. {
  123. gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS");
  124. gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS);
  125. if (is_on)
  126. gpio_set_value(CONFIG_USB_SL811_BFIN_GPIO_VBUS, 1);
  127. else
  128. gpio_set_value(CONFIG_USB_SL811_BFIN_GPIO_VBUS, 0);
  129. }
  130. #endif
  131. static struct sl811_platform_data sl811_priv = {
  132. .potpg = 10,
  133. .power = 250, /* == 500mA */
  134. #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
  135. .port_power = &sl811_port_power,
  136. #endif
  137. };
  138. static struct platform_device sl811_hcd_device = {
  139. .name = "sl811-hcd",
  140. .id = 0,
  141. .dev = {
  142. .platform_data = &sl811_priv,
  143. },
  144. .num_resources = ARRAY_SIZE(sl811_hcd_resources),
  145. .resource = sl811_hcd_resources,
  146. };
  147. #endif
  148. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  149. static struct resource isp1362_hcd_resources[] = {
  150. {
  151. .start = 0x20360000,
  152. .end = 0x20360000,
  153. .flags = IORESOURCE_MEM,
  154. }, {
  155. .start = 0x20360004,
  156. .end = 0x20360004,
  157. .flags = IORESOURCE_MEM,
  158. }, {
  159. .start = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
  160. .end = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
  161. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  162. },
  163. };
  164. static struct isp1362_platform_data isp1362_priv = {
  165. .sel15Kres = 1,
  166. .clknotstop = 0,
  167. .oc_enable = 0,
  168. .int_act_high = 0,
  169. .int_edge_triggered = 0,
  170. .remote_wakeup_connected = 0,
  171. .no_power_switching = 1,
  172. .power_switching_mode = 0,
  173. };
  174. static struct platform_device isp1362_hcd_device = {
  175. .name = "isp1362-hcd",
  176. .id = 0,
  177. .dev = {
  178. .platform_data = &isp1362_priv,
  179. },
  180. .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
  181. .resource = isp1362_hcd_resources,
  182. };
  183. #endif
  184. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  185. static struct platform_device bfin_mac_device = {
  186. .name = "bfin_mac",
  187. };
  188. #endif
  189. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  190. static struct resource net2272_bfin_resources[] = {
  191. {
  192. .start = 0x20300000,
  193. .end = 0x20300000 + 0x100,
  194. .flags = IORESOURCE_MEM,
  195. }, {
  196. .start = IRQ_PF7,
  197. .end = IRQ_PF7,
  198. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  199. },
  200. };
  201. static struct platform_device net2272_bfin_device = {
  202. .name = "net2272",
  203. .id = -1,
  204. .num_resources = ARRAY_SIZE(net2272_bfin_resources),
  205. .resource = net2272_bfin_resources,
  206. };
  207. #endif
  208. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  209. /* all SPI peripherals info goes here */
  210. #if defined(CONFIG_MTD_M25P80) \
  211. || defined(CONFIG_MTD_M25P80_MODULE)
  212. static struct mtd_partition bfin_spi_flash_partitions[] = {
  213. {
  214. .name = "bootloader",
  215. .size = 0x00020000,
  216. .offset = 0,
  217. .mask_flags = MTD_CAP_ROM
  218. }, {
  219. .name = "kernel",
  220. .size = 0xe0000,
  221. .offset = 0x20000
  222. }, {
  223. .name = "file system",
  224. .size = 0x700000,
  225. .offset = 0x00100000,
  226. }
  227. };
  228. static struct flash_platform_data bfin_spi_flash_data = {
  229. .name = "m25p80",
  230. .parts = bfin_spi_flash_partitions,
  231. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  232. .type = "m25p64",
  233. };
  234. /* SPI flash chip (m25p64) */
  235. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  236. .enable_dma = 0, /* use dma transfer with this chip*/
  237. .bits_per_word = 8,
  238. };
  239. #endif
  240. #if defined(CONFIG_SPI_ADC_BF533) \
  241. || defined(CONFIG_SPI_ADC_BF533_MODULE)
  242. /* SPI ADC chip */
  243. static struct bfin5xx_spi_chip spi_adc_chip_info = {
  244. .enable_dma = 1, /* use dma transfer with this chip*/
  245. .bits_per_word = 16,
  246. };
  247. #endif
  248. #if defined(CONFIG_SND_BLACKFIN_AD1836) \
  249. || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  250. static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
  251. .enable_dma = 0,
  252. .bits_per_word = 16,
  253. };
  254. #endif
  255. #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
  256. static struct bfin5xx_spi_chip ad9960_spi_chip_info = {
  257. .enable_dma = 0,
  258. .bits_per_word = 16,
  259. };
  260. #endif
  261. #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
  262. static struct bfin5xx_spi_chip spi_mmc_chip_info = {
  263. .enable_dma = 1,
  264. .bits_per_word = 8,
  265. };
  266. #endif
  267. #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
  268. static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
  269. .cs_change_per_word = 1,
  270. .enable_dma = 0,
  271. .bits_per_word = 16,
  272. };
  273. static const struct ad7877_platform_data bfin_ad7877_ts_info = {
  274. .model = 7877,
  275. .vref_delay_usecs = 50, /* internal, no capacitor */
  276. .x_plate_ohms = 419,
  277. .y_plate_ohms = 486,
  278. .pressure_max = 1000,
  279. .pressure_min = 0,
  280. .stopacq_polarity = 1,
  281. .first_conversion_delay = 3,
  282. .acquisition_time = 1,
  283. .averaging = 1,
  284. .pen_down_acc_interval = 1,
  285. };
  286. #endif
  287. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  288. #if defined(CONFIG_MTD_M25P80) \
  289. || defined(CONFIG_MTD_M25P80_MODULE)
  290. {
  291. /* the modalias must be the same as spi device driver name */
  292. .modalias = "m25p80", /* Name of spi_driver for this device */
  293. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  294. .bus_num = 0, /* Framework bus number */
  295. .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
  296. .platform_data = &bfin_spi_flash_data,
  297. .controller_data = &spi_flash_chip_info,
  298. .mode = SPI_MODE_3,
  299. },
  300. #endif
  301. #if defined(CONFIG_SPI_ADC_BF533) \
  302. || defined(CONFIG_SPI_ADC_BF533_MODULE)
  303. {
  304. .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
  305. .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
  306. .bus_num = 0, /* Framework bus number */
  307. .chip_select = 1, /* Framework chip select. */
  308. .platform_data = NULL, /* No spi_driver specific config */
  309. .controller_data = &spi_adc_chip_info,
  310. },
  311. #endif
  312. #if defined(CONFIG_SND_BLACKFIN_AD1836) \
  313. || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  314. {
  315. .modalias = "ad1836-spi",
  316. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  317. .bus_num = 0,
  318. .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
  319. .controller_data = &ad1836_spi_chip_info,
  320. },
  321. #endif
  322. #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
  323. {
  324. .modalias = "ad9960-spi",
  325. .max_speed_hz = 10000000, /* max spi clock (SCK) speed in HZ */
  326. .bus_num = 0,
  327. .chip_select = 1,
  328. .controller_data = &ad9960_spi_chip_info,
  329. },
  330. #endif
  331. #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
  332. {
  333. .modalias = "spi_mmc_dummy",
  334. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  335. .bus_num = 0,
  336. .chip_select = 7,
  337. .platform_data = NULL,
  338. .controller_data = &spi_mmc_chip_info,
  339. .mode = SPI_MODE_3,
  340. },
  341. {
  342. .modalias = "spi_mmc",
  343. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  344. .bus_num = 0,
  345. .chip_select = CONFIG_SPI_MMC_CS_CHAN,
  346. .platform_data = NULL,
  347. .controller_data = &spi_mmc_chip_info,
  348. .mode = SPI_MODE_3,
  349. },
  350. #endif
  351. #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
  352. {
  353. .modalias = "ad7877",
  354. .platform_data = &bfin_ad7877_ts_info,
  355. .irq = IRQ_PF2,
  356. .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
  357. .bus_num = 1,
  358. .chip_select = 5,
  359. .controller_data = &spi_ad7877_chip_info,
  360. },
  361. #endif
  362. };
  363. /* SPI (0) */
  364. static struct resource bfin_spi0_resource[] = {
  365. [0] = {
  366. .start = SPI0_REGBASE,
  367. .end = SPI0_REGBASE + 0xFF,
  368. .flags = IORESOURCE_MEM,
  369. },
  370. [1] = {
  371. .start = CH_SPI,
  372. .end = CH_SPI,
  373. .flags = IORESOURCE_IRQ,
  374. }
  375. };
  376. /* SPI controller data */
  377. static struct bfin5xx_spi_master bfin_spi0_info = {
  378. .num_chipselect = 8,
  379. .enable_dma = 1, /* master has the ability to do dma transfer */
  380. };
  381. static struct platform_device bfin_spi0_device = {
  382. .name = "bfin-spi",
  383. .id = 0, /* Bus number */
  384. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  385. .resource = bfin_spi0_resource,
  386. .dev = {
  387. .platform_data = &bfin_spi0_info, /* Passed to driver */
  388. },
  389. };
  390. #endif /* spi master and devices */
  391. #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
  392. static struct platform_device bfin_fb_device = {
  393. .name = "bf537-lq035",
  394. };
  395. #endif
  396. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  397. static struct resource bfin_uart_resources[] = {
  398. {
  399. .start = 0xFFC00400,
  400. .end = 0xFFC004FF,
  401. .flags = IORESOURCE_MEM,
  402. }, {
  403. .start = 0xFFC02000,
  404. .end = 0xFFC020FF,
  405. .flags = IORESOURCE_MEM,
  406. },
  407. };
  408. static struct platform_device bfin_uart_device = {
  409. .name = "bfin-uart",
  410. .id = 1,
  411. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  412. .resource = bfin_uart_resources,
  413. };
  414. #endif
  415. static struct platform_device *stamp_devices[] __initdata = {
  416. #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
  417. &bfin_pcmcia_cf_device,
  418. #endif
  419. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  420. &rtc_device,
  421. #endif
  422. #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
  423. &sl811_hcd_device,
  424. #endif
  425. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  426. &isp1362_hcd_device,
  427. #endif
  428. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  429. &smc91x_device,
  430. #endif
  431. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  432. &bfin_mac_device,
  433. #endif
  434. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  435. &net2272_bfin_device,
  436. #endif
  437. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  438. &bfin_spi0_device,
  439. #endif
  440. #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
  441. &bfin_fb_device,
  442. #endif
  443. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  444. &bfin_uart_device,
  445. #endif
  446. };
  447. static int __init stamp_init(void)
  448. {
  449. printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
  450. platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
  451. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  452. spi_register_board_info(bfin_spi_board_info,
  453. ARRAY_SIZE(bfin_spi_board_info));
  454. #endif
  455. return 0;
  456. }
  457. arch_initcall(stamp_init);