pnav10.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  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/export.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/mtd/mtd.h>
  13. #include <linux/mtd/partitions.h>
  14. #include <linux/spi/spi.h>
  15. #include <linux/spi/flash.h>
  16. #include <linux/irq.h>
  17. #include <asm/dma.h>
  18. #include <asm/bfin5xx_spi.h>
  19. #include <asm/portmux.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_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  91. #include <linux/bfin_mac.h>
  92. #include <linux/export.h>
  93. static const unsigned short bfin_mac_peripherals[] = P_RMII0;
  94. static struct bfin_phydev_platform_data bfin_phydev_data[] = {
  95. {
  96. .addr = 1,
  97. .irq = IRQ_MAC_PHYINT,
  98. },
  99. };
  100. static struct bfin_mii_bus_platform_data bfin_mii_bus_data = {
  101. .phydev_number = 1,
  102. .phydev_data = bfin_phydev_data,
  103. .phy_mode = PHY_INTERFACE_MODE_RMII,
  104. .mac_peripherals = bfin_mac_peripherals,
  105. };
  106. static struct platform_device bfin_mii_bus = {
  107. .name = "bfin_mii_bus",
  108. .dev = {
  109. .platform_data = &bfin_mii_bus_data,
  110. }
  111. };
  112. static struct platform_device bfin_mac_device = {
  113. .name = "bfin_mac",
  114. .dev = {
  115. .platform_data = &bfin_mii_bus,
  116. }
  117. };
  118. #endif
  119. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  120. static struct resource net2272_bfin_resources[] = {
  121. {
  122. .start = 0x20300000,
  123. .end = 0x20300000 + 0x100,
  124. .flags = IORESOURCE_MEM,
  125. }, {
  126. .start = IRQ_PF7,
  127. .end = IRQ_PF7,
  128. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  129. },
  130. };
  131. static struct platform_device net2272_bfin_device = {
  132. .name = "net2272",
  133. .id = -1,
  134. .num_resources = ARRAY_SIZE(net2272_bfin_resources),
  135. .resource = net2272_bfin_resources,
  136. };
  137. #endif
  138. #if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE)
  139. /* all SPI peripherals info goes here */
  140. #if defined(CONFIG_MTD_M25P80) \
  141. || defined(CONFIG_MTD_M25P80_MODULE)
  142. static struct mtd_partition bfin_spi_flash_partitions[] = {
  143. {
  144. .name = "bootloader(spi)",
  145. .size = 0x00020000,
  146. .offset = 0,
  147. .mask_flags = MTD_CAP_ROM
  148. }, {
  149. .name = "linux kernel(spi)",
  150. .size = 0xe0000,
  151. .offset = 0x20000
  152. }, {
  153. .name = "file system(spi)",
  154. .size = 0x700000,
  155. .offset = 0x00100000,
  156. }
  157. };
  158. static struct flash_platform_data bfin_spi_flash_data = {
  159. .name = "m25p80",
  160. .parts = bfin_spi_flash_partitions,
  161. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  162. .type = "m25p64",
  163. };
  164. /* SPI flash chip (m25p64) */
  165. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  166. .enable_dma = 0, /* use dma transfer with this chip*/
  167. };
  168. #endif
  169. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  170. static struct bfin5xx_spi_chip mmc_spi_chip_info = {
  171. .enable_dma = 0,
  172. };
  173. #endif
  174. #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
  175. static const struct ad7877_platform_data bfin_ad7877_ts_info = {
  176. .model = 7877,
  177. .vref_delay_usecs = 50, /* internal, no capacitor */
  178. .x_plate_ohms = 419,
  179. .y_plate_ohms = 486,
  180. .pressure_max = 1000,
  181. .pressure_min = 0,
  182. .stopacq_polarity = 1,
  183. .first_conversion_delay = 3,
  184. .acquisition_time = 1,
  185. .averaging = 1,
  186. .pen_down_acc_interval = 1,
  187. };
  188. #endif
  189. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  190. #if defined(CONFIG_MTD_M25P80) \
  191. || defined(CONFIG_MTD_M25P80_MODULE)
  192. {
  193. /* the modalias must be the same as spi device driver name */
  194. .modalias = "m25p80", /* Name of spi_driver for this device */
  195. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  196. .bus_num = 0, /* Framework bus number */
  197. .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
  198. .platform_data = &bfin_spi_flash_data,
  199. .controller_data = &spi_flash_chip_info,
  200. .mode = SPI_MODE_3,
  201. },
  202. #endif
  203. #if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
  204. || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
  205. {
  206. .modalias = "ad183x",
  207. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  208. .bus_num = 0,
  209. .chip_select = 4,
  210. },
  211. #endif
  212. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  213. {
  214. .modalias = "mmc_spi",
  215. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  216. .bus_num = 0,
  217. .chip_select = 5,
  218. .controller_data = &mmc_spi_chip_info,
  219. .mode = SPI_MODE_3,
  220. },
  221. #endif
  222. #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
  223. {
  224. .modalias = "ad7877",
  225. .platform_data = &bfin_ad7877_ts_info,
  226. .irq = IRQ_PF2,
  227. .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
  228. .bus_num = 0,
  229. .chip_select = 5,
  230. },
  231. #endif
  232. };
  233. /* SPI (0) */
  234. static struct resource bfin_spi0_resource[] = {
  235. [0] = {
  236. .start = SPI0_REGBASE,
  237. .end = SPI0_REGBASE + 0xFF,
  238. .flags = IORESOURCE_MEM,
  239. },
  240. [1] = {
  241. .start = CH_SPI,
  242. .end = CH_SPI,
  243. .flags = IORESOURCE_DMA,
  244. },
  245. [2] = {
  246. .start = IRQ_SPI,
  247. .end = IRQ_SPI,
  248. .flags = IORESOURCE_IRQ,
  249. },
  250. };
  251. /* SPI controller data */
  252. static struct bfin5xx_spi_master bfin_spi0_info = {
  253. .num_chipselect = 8,
  254. .enable_dma = 1, /* master has the ability to do dma transfer */
  255. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  256. };
  257. static struct platform_device bfin_spi0_device = {
  258. .name = "bfin-spi",
  259. .id = 0, /* Bus number */
  260. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  261. .resource = bfin_spi0_resource,
  262. .dev = {
  263. .platform_data = &bfin_spi0_info, /* Passed to driver */
  264. },
  265. };
  266. #endif /* spi master and devices */
  267. #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
  268. static struct platform_device bfin_fb_device = {
  269. .name = "bf537-lq035",
  270. };
  271. #endif
  272. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  273. #ifdef CONFIG_SERIAL_BFIN_UART0
  274. static struct resource bfin_uart0_resources[] = {
  275. {
  276. .start = UART0_THR,
  277. .end = UART0_GCTL+2,
  278. .flags = IORESOURCE_MEM,
  279. },
  280. {
  281. .start = IRQ_UART0_TX,
  282. .end = IRQ_UART0_TX,
  283. .flags = IORESOURCE_IRQ,
  284. },
  285. {
  286. .start = IRQ_UART0_RX,
  287. .end = IRQ_UART0_RX,
  288. .flags = IORESOURCE_IRQ,
  289. },
  290. {
  291. .start = IRQ_UART0_ERROR,
  292. .end = IRQ_UART0_ERROR,
  293. .flags = IORESOURCE_IRQ,
  294. },
  295. {
  296. .start = CH_UART0_TX,
  297. .end = CH_UART0_TX,
  298. .flags = IORESOURCE_DMA,
  299. },
  300. {
  301. .start = CH_UART0_RX,
  302. .end = CH_UART0_RX,
  303. .flags = IORESOURCE_DMA,
  304. },
  305. };
  306. static unsigned short bfin_uart0_peripherals[] = {
  307. P_UART0_TX, P_UART0_RX, 0
  308. };
  309. static struct platform_device bfin_uart0_device = {
  310. .name = "bfin-uart",
  311. .id = 0,
  312. .num_resources = ARRAY_SIZE(bfin_uart0_resources),
  313. .resource = bfin_uart0_resources,
  314. .dev = {
  315. .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
  316. },
  317. };
  318. #endif
  319. #ifdef CONFIG_SERIAL_BFIN_UART1
  320. static struct resource bfin_uart1_resources[] = {
  321. {
  322. .start = UART1_THR,
  323. .end = UART1_GCTL+2,
  324. .flags = IORESOURCE_MEM,
  325. },
  326. {
  327. .start = IRQ_UART1_TX,
  328. .end = IRQ_UART1_TX,
  329. .flags = IORESOURCE_IRQ,
  330. },
  331. {
  332. .start = IRQ_UART1_RX,
  333. .end = IRQ_UART1_RX,
  334. .flags = IORESOURCE_IRQ,
  335. },
  336. {
  337. .start = IRQ_UART1_ERROR,
  338. .end = IRQ_UART1_ERROR,
  339. .flags = IORESOURCE_IRQ,
  340. },
  341. {
  342. .start = CH_UART1_TX,
  343. .end = CH_UART1_TX,
  344. .flags = IORESOURCE_DMA,
  345. },
  346. {
  347. .start = CH_UART1_RX,
  348. .end = CH_UART1_RX,
  349. .flags = IORESOURCE_DMA,
  350. },
  351. };
  352. static unsigned short bfin_uart1_peripherals[] = {
  353. P_UART1_TX, P_UART1_RX, 0
  354. };
  355. static struct platform_device bfin_uart1_device = {
  356. .name = "bfin-uart",
  357. .id = 1,
  358. .num_resources = ARRAY_SIZE(bfin_uart1_resources),
  359. .resource = bfin_uart1_resources,
  360. .dev = {
  361. .platform_data = &bfin_uart1_peripherals, /* Passed to driver */
  362. },
  363. };
  364. #endif
  365. #endif
  366. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  367. #ifdef CONFIG_BFIN_SIR0
  368. static struct resource bfin_sir0_resources[] = {
  369. {
  370. .start = 0xFFC00400,
  371. .end = 0xFFC004FF,
  372. .flags = IORESOURCE_MEM,
  373. },
  374. {
  375. .start = IRQ_UART0_RX,
  376. .end = IRQ_UART0_RX+1,
  377. .flags = IORESOURCE_IRQ,
  378. },
  379. {
  380. .start = CH_UART0_RX,
  381. .end = CH_UART0_RX+1,
  382. .flags = IORESOURCE_DMA,
  383. },
  384. };
  385. static struct platform_device bfin_sir0_device = {
  386. .name = "bfin_sir",
  387. .id = 0,
  388. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  389. .resource = bfin_sir0_resources,
  390. };
  391. #endif
  392. #ifdef CONFIG_BFIN_SIR1
  393. static struct resource bfin_sir1_resources[] = {
  394. {
  395. .start = 0xFFC02000,
  396. .end = 0xFFC020FF,
  397. .flags = IORESOURCE_MEM,
  398. },
  399. {
  400. .start = IRQ_UART1_RX,
  401. .end = IRQ_UART1_RX+1,
  402. .flags = IORESOURCE_IRQ,
  403. },
  404. {
  405. .start = CH_UART1_RX,
  406. .end = CH_UART1_RX+1,
  407. .flags = IORESOURCE_DMA,
  408. },
  409. };
  410. static struct platform_device bfin_sir1_device = {
  411. .name = "bfin_sir",
  412. .id = 1,
  413. .num_resources = ARRAY_SIZE(bfin_sir1_resources),
  414. .resource = bfin_sir1_resources,
  415. };
  416. #endif
  417. #endif
  418. static struct platform_device *stamp_devices[] __initdata = {
  419. #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
  420. &bfin_pcmcia_cf_device,
  421. #endif
  422. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  423. &rtc_device,
  424. #endif
  425. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  426. &smc91x_device,
  427. #endif
  428. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  429. &bfin_mii_bus,
  430. &bfin_mac_device,
  431. #endif
  432. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  433. &net2272_bfin_device,
  434. #endif
  435. #if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE)
  436. &bfin_spi0_device,
  437. #endif
  438. #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
  439. &bfin_fb_device,
  440. #endif
  441. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  442. #ifdef CONFIG_SERIAL_BFIN_UART0
  443. &bfin_uart0_device,
  444. #endif
  445. #ifdef CONFIG_SERIAL_BFIN_UART1
  446. &bfin_uart1_device,
  447. #endif
  448. #endif
  449. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  450. #ifdef CONFIG_BFIN_SIR0
  451. &bfin_sir0_device,
  452. #endif
  453. #ifdef CONFIG_BFIN_SIR1
  454. &bfin_sir1_device,
  455. #endif
  456. #endif
  457. };
  458. static int __init pnav_init(void)
  459. {
  460. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  461. platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
  462. #if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE)
  463. spi_register_board_info(bfin_spi_board_info,
  464. ARRAY_SIZE(bfin_spi_board_info));
  465. #endif
  466. return 0;
  467. }
  468. arch_initcall(pnav_init);
  469. static struct platform_device *stamp_early_devices[] __initdata = {
  470. #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
  471. #ifdef CONFIG_SERIAL_BFIN_UART0
  472. &bfin_uart0_device,
  473. #endif
  474. #ifdef CONFIG_SERIAL_BFIN_UART1
  475. &bfin_uart1_device,
  476. #endif
  477. #endif
  478. };
  479. void __init native_machine_early_platform_add_devices(void)
  480. {
  481. printk(KERN_INFO "register early platform devices\n");
  482. early_platform_add_devices(stamp_early_devices,
  483. ARRAY_SIZE(stamp_early_devices));
  484. }
  485. void bfin_get_ether_addr(char *addr)
  486. {
  487. random_ether_addr(addr);
  488. printk(KERN_WARNING "%s:%s: Setting Ethernet MAC to a random one\n", __FILE__, __func__);
  489. }
  490. EXPORT_SYMBOL(bfin_get_ether_addr);