blackstamp.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  1. /*
  2. * Board Info File for the BlackStamp
  3. *
  4. * Copyright 2004-2008 Analog Devices Inc.
  5. * 2008 Benjamin Matthews <bmat@lle.rochester.edu>
  6. * 2005 National ICT Australia (NICTA)
  7. * Aidan Williams <aidan@nicta.com.au>
  8. *
  9. * More info about the BlackStamp at:
  10. * http://blackfin.uclinux.org/gf/project/blackstamp/
  11. *
  12. * Licensed under the GPL-2 or later.
  13. */
  14. #include <linux/device.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/mtd/mtd.h>
  17. #include <linux/mtd/partitions.h>
  18. #include <linux/mtd/physmap.h>
  19. #include <linux/spi/spi.h>
  20. #include <linux/spi/flash.h>
  21. #include <linux/irq.h>
  22. #include <linux/i2c.h>
  23. #include <asm/dma.h>
  24. #include <asm/bfin5xx_spi.h>
  25. #include <asm/portmux.h>
  26. #include <asm/dpmc.h>
  27. /*
  28. * Name the Board for the /proc/cpuinfo
  29. */
  30. const char bfin_board_name[] = "BlackStamp";
  31. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  32. static struct platform_device rtc_device = {
  33. .name = "rtc-bfin",
  34. .id = -1,
  35. };
  36. #endif
  37. /*
  38. * Driver needs to know address, irq and flag pin.
  39. */
  40. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  41. #include <linux/smc91x.h>
  42. static struct smc91x_platdata smc91x_info = {
  43. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
  44. .leda = RPC_LED_100_10,
  45. .ledb = RPC_LED_TX_RX,
  46. };
  47. static struct resource smc91x_resources[] = {
  48. {
  49. .name = "smc91x-regs",
  50. .start = 0x20300300,
  51. .end = 0x20300300 + 16,
  52. .flags = IORESOURCE_MEM,
  53. }, {
  54. .start = IRQ_PF3,
  55. .end = IRQ_PF3,
  56. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  57. },
  58. };
  59. static struct platform_device smc91x_device = {
  60. .name = "smc91x",
  61. .id = 0,
  62. .num_resources = ARRAY_SIZE(smc91x_resources),
  63. .resource = smc91x_resources,
  64. .dev = {
  65. .platform_data = &smc91x_info,
  66. },
  67. };
  68. #endif
  69. #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
  70. static struct mtd_partition bfin_spi_flash_partitions[] = {
  71. {
  72. .name = "bootloader(spi)",
  73. .size = 0x00040000,
  74. .offset = 0,
  75. .mask_flags = MTD_CAP_ROM
  76. }, {
  77. .name = "linux kernel(spi)",
  78. .size = 0x180000,
  79. .offset = MTDPART_OFS_APPEND,
  80. }, {
  81. .name = "file system(spi)",
  82. .size = MTDPART_SIZ_FULL,
  83. .offset = MTDPART_OFS_APPEND,
  84. }
  85. };
  86. static struct flash_platform_data bfin_spi_flash_data = {
  87. .name = "m25p80",
  88. .parts = bfin_spi_flash_partitions,
  89. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  90. .type = "m25p64",
  91. };
  92. /* SPI flash chip (m25p64) */
  93. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  94. .enable_dma = 0, /* use dma transfer with this chip*/
  95. };
  96. #endif
  97. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  98. static struct bfin5xx_spi_chip mmc_spi_chip_info = {
  99. .enable_dma = 0,
  100. };
  101. #endif
  102. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  103. #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
  104. {
  105. /* the modalias must be the same as spi device driver name */
  106. .modalias = "m25p80", /* Name of spi_driver for this device */
  107. .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
  108. .bus_num = 0, /* Framework bus number */
  109. .chip_select = 2, /* Framework chip select. */
  110. .platform_data = &bfin_spi_flash_data,
  111. .controller_data = &spi_flash_chip_info,
  112. .mode = SPI_MODE_3,
  113. },
  114. #endif
  115. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  116. {
  117. .modalias = "mmc_spi",
  118. .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
  119. .bus_num = 0,
  120. .chip_select = 5,
  121. .controller_data = &mmc_spi_chip_info,
  122. .mode = SPI_MODE_3,
  123. },
  124. #endif
  125. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  126. {
  127. .modalias = "spidev",
  128. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  129. .bus_num = 0,
  130. .chip_select = 7,
  131. },
  132. #endif
  133. };
  134. #if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE)
  135. /* SPI (0) */
  136. static struct resource bfin_spi0_resource[] = {
  137. [0] = {
  138. .start = SPI0_REGBASE,
  139. .end = SPI0_REGBASE + 0xFF,
  140. .flags = IORESOURCE_MEM,
  141. },
  142. [1] = {
  143. .start = CH_SPI,
  144. .end = CH_SPI,
  145. .flags = IORESOURCE_DMA,
  146. },
  147. [2] = {
  148. .start = IRQ_SPI,
  149. .end = IRQ_SPI,
  150. .flags = IORESOURCE_IRQ,
  151. }
  152. };
  153. /* SPI controller data */
  154. static struct bfin5xx_spi_master bfin_spi0_info = {
  155. .num_chipselect = 8,
  156. .enable_dma = 1, /* master has the ability to do dma transfer */
  157. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  158. };
  159. static struct platform_device bfin_spi0_device = {
  160. .name = "bfin-spi",
  161. .id = 0, /* Bus number */
  162. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  163. .resource = bfin_spi0_resource,
  164. .dev = {
  165. .platform_data = &bfin_spi0_info, /* Passed to driver */
  166. },
  167. };
  168. #endif /* spi master and devices */
  169. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  170. #ifdef CONFIG_SERIAL_BFIN_UART0
  171. static struct resource bfin_uart0_resources[] = {
  172. {
  173. .start = BFIN_UART_THR,
  174. .end = BFIN_UART_GCTL+2,
  175. .flags = IORESOURCE_MEM,
  176. },
  177. {
  178. .start = IRQ_UART0_TX,
  179. .end = IRQ_UART0_TX,
  180. .flags = IORESOURCE_IRQ,
  181. },
  182. {
  183. .start = IRQ_UART0_RX,
  184. .end = IRQ_UART0_RX,
  185. .flags = IORESOURCE_IRQ,
  186. },
  187. {
  188. .start = IRQ_UART0_ERROR,
  189. .end = IRQ_UART0_ERROR,
  190. .flags = IORESOURCE_IRQ,
  191. },
  192. {
  193. .start = CH_UART0_TX,
  194. .end = CH_UART0_TX,
  195. .flags = IORESOURCE_DMA,
  196. },
  197. {
  198. .start = CH_UART0_RX,
  199. .end = CH_UART0_RX,
  200. .flags = IORESOURCE_DMA,
  201. },
  202. };
  203. static unsigned short bfin_uart0_peripherals[] = {
  204. P_UART0_TX, P_UART0_RX, 0
  205. };
  206. static struct platform_device bfin_uart0_device = {
  207. .name = "bfin-uart",
  208. .id = 0,
  209. .num_resources = ARRAY_SIZE(bfin_uart0_resources),
  210. .resource = bfin_uart0_resources,
  211. .dev = {
  212. .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
  213. },
  214. };
  215. #endif
  216. #endif
  217. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  218. #ifdef CONFIG_BFIN_SIR0
  219. static struct resource bfin_sir0_resources[] = {
  220. {
  221. .start = 0xFFC00400,
  222. .end = 0xFFC004FF,
  223. .flags = IORESOURCE_MEM,
  224. },
  225. {
  226. .start = IRQ_UART0_RX,
  227. .end = IRQ_UART0_RX+1,
  228. .flags = IORESOURCE_IRQ,
  229. },
  230. {
  231. .start = CH_UART0_RX,
  232. .end = CH_UART0_RX+1,
  233. .flags = IORESOURCE_DMA,
  234. },
  235. };
  236. static struct platform_device bfin_sir0_device = {
  237. .name = "bfin_sir",
  238. .id = 0,
  239. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  240. .resource = bfin_sir0_resources,
  241. };
  242. #endif
  243. #endif
  244. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  245. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  246. static struct resource bfin_sport0_uart_resources[] = {
  247. {
  248. .start = SPORT0_TCR1,
  249. .end = SPORT0_MRCS3+4,
  250. .flags = IORESOURCE_MEM,
  251. },
  252. {
  253. .start = IRQ_SPORT0_RX,
  254. .end = IRQ_SPORT0_RX+1,
  255. .flags = IORESOURCE_IRQ,
  256. },
  257. {
  258. .start = IRQ_SPORT0_ERROR,
  259. .end = IRQ_SPORT0_ERROR,
  260. .flags = IORESOURCE_IRQ,
  261. },
  262. };
  263. static unsigned short bfin_sport0_peripherals[] = {
  264. P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
  265. P_SPORT0_DRPRI, P_SPORT0_RSCLK, 0
  266. };
  267. static struct platform_device bfin_sport0_uart_device = {
  268. .name = "bfin-sport-uart",
  269. .id = 0,
  270. .num_resources = ARRAY_SIZE(bfin_sport0_uart_resources),
  271. .resource = bfin_sport0_uart_resources,
  272. .dev = {
  273. .platform_data = &bfin_sport0_peripherals, /* Passed to driver */
  274. },
  275. };
  276. #endif
  277. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  278. static struct resource bfin_sport1_uart_resources[] = {
  279. {
  280. .start = SPORT1_TCR1,
  281. .end = SPORT1_MRCS3+4,
  282. .flags = IORESOURCE_MEM,
  283. },
  284. {
  285. .start = IRQ_SPORT1_RX,
  286. .end = IRQ_SPORT1_RX+1,
  287. .flags = IORESOURCE_IRQ,
  288. },
  289. {
  290. .start = IRQ_SPORT1_ERROR,
  291. .end = IRQ_SPORT1_ERROR,
  292. .flags = IORESOURCE_IRQ,
  293. },
  294. };
  295. static unsigned short bfin_sport1_peripherals[] = {
  296. P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
  297. P_SPORT1_DRPRI, P_SPORT1_RSCLK, 0
  298. };
  299. static struct platform_device bfin_sport1_uart_device = {
  300. .name = "bfin-sport-uart",
  301. .id = 1,
  302. .num_resources = ARRAY_SIZE(bfin_sport1_uart_resources),
  303. .resource = bfin_sport1_uart_resources,
  304. .dev = {
  305. .platform_data = &bfin_sport1_peripherals, /* Passed to driver */
  306. },
  307. };
  308. #endif
  309. #endif
  310. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  311. #include <linux/input.h>
  312. #include <linux/gpio_keys.h>
  313. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  314. {BTN_0, GPIO_PF4, 0, "gpio-keys: BTN0"},
  315. {BTN_1, GPIO_PF5, 0, "gpio-keys: BTN1"},
  316. {BTN_2, GPIO_PF6, 0, "gpio-keys: BTN2"},
  317. }; /* Mapped to the first three PF Test Points */
  318. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  319. .buttons = bfin_gpio_keys_table,
  320. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  321. };
  322. static struct platform_device bfin_device_gpiokeys = {
  323. .name = "gpio-keys",
  324. .dev = {
  325. .platform_data = &bfin_gpio_keys_data,
  326. },
  327. };
  328. #endif
  329. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  330. #include <linux/i2c-gpio.h>
  331. static struct i2c_gpio_platform_data i2c_gpio_data = {
  332. .sda_pin = GPIO_PF8,
  333. .scl_pin = GPIO_PF9,
  334. .sda_is_open_drain = 0,
  335. .scl_is_open_drain = 0,
  336. .udelay = 40,
  337. }; /* This hasn't actually been used these pins
  338. * are (currently) free pins on the expansion connector */
  339. static struct platform_device i2c_gpio_device = {
  340. .name = "i2c-gpio",
  341. .id = 0,
  342. .dev = {
  343. .platform_data = &i2c_gpio_data,
  344. },
  345. };
  346. #endif
  347. static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
  348. };
  349. static const unsigned int cclk_vlev_datasheet[] =
  350. {
  351. VRPAIR(VLEV_085, 250000000),
  352. VRPAIR(VLEV_090, 376000000),
  353. VRPAIR(VLEV_095, 426000000),
  354. VRPAIR(VLEV_100, 426000000),
  355. VRPAIR(VLEV_105, 476000000),
  356. VRPAIR(VLEV_110, 476000000),
  357. VRPAIR(VLEV_115, 476000000),
  358. VRPAIR(VLEV_120, 600000000),
  359. VRPAIR(VLEV_125, 600000000),
  360. VRPAIR(VLEV_130, 600000000),
  361. };
  362. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  363. .tuple_tab = cclk_vlev_datasheet,
  364. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  365. .vr_settling_time = 25 /* us */,
  366. };
  367. static struct platform_device bfin_dpmc = {
  368. .name = "bfin dpmc",
  369. .dev = {
  370. .platform_data = &bfin_dmpc_vreg_data,
  371. },
  372. };
  373. static struct platform_device *stamp_devices[] __initdata = {
  374. &bfin_dpmc,
  375. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  376. &rtc_device,
  377. #endif
  378. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  379. &smc91x_device,
  380. #endif
  381. #if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE)
  382. &bfin_spi0_device,
  383. #endif
  384. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  385. #ifdef CONFIG_SERIAL_BFIN_UART0
  386. &bfin_uart0_device,
  387. #endif
  388. #endif
  389. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  390. #ifdef CONFIG_BFIN_SIR0
  391. &bfin_sir0_device,
  392. #endif
  393. #endif
  394. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  395. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  396. &bfin_sport0_uart_device,
  397. #endif
  398. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  399. &bfin_sport1_uart_device,
  400. #endif
  401. #endif
  402. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  403. &bfin_device_gpiokeys,
  404. #endif
  405. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  406. &i2c_gpio_device,
  407. #endif
  408. };
  409. static int __init blackstamp_init(void)
  410. {
  411. int ret;
  412. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  413. i2c_register_board_info(0, bfin_i2c_board_info,
  414. ARRAY_SIZE(bfin_i2c_board_info));
  415. ret = platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
  416. if (ret < 0)
  417. return ret;
  418. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  419. /*
  420. * setup BF533_STAMP CPLD to route AMS3 to Ethernet MAC.
  421. * the bfin-async-map driver takes care of flipping between
  422. * flash and ethernet when necessary.
  423. */
  424. ret = gpio_request(GPIO_PF0, "enet_cpld");
  425. if (!ret) {
  426. gpio_direction_output(GPIO_PF0, 1);
  427. gpio_free(GPIO_PF0);
  428. }
  429. #endif
  430. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  431. return 0;
  432. }
  433. arch_initcall(blackstamp_init);
  434. static struct platform_device *stamp_early_devices[] __initdata = {
  435. #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
  436. #ifdef CONFIG_SERIAL_BFIN_UART0
  437. &bfin_uart0_device,
  438. #endif
  439. #endif
  440. #if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
  441. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  442. &bfin_sport0_uart_device,
  443. #endif
  444. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  445. &bfin_sport1_uart_device,
  446. #endif
  447. #endif
  448. };
  449. void __init native_machine_early_platform_add_devices(void)
  450. {
  451. printk(KERN_INFO "register early platform devices\n");
  452. early_platform_add_devices(stamp_early_devices,
  453. ARRAY_SIZE(stamp_early_devices));
  454. }