pnav10.c 12 KB

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