pnav10.c 12 KB

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