blackstamp.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  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. .bits_per_word = 8,
  96. };
  97. #endif
  98. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  99. static struct bfin5xx_spi_chip mmc_spi_chip_info = {
  100. .enable_dma = 0,
  101. .bits_per_word = 8,
  102. };
  103. #endif
  104. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  105. static struct bfin5xx_spi_chip spidev_chip_info = {
  106. .enable_dma = 0,
  107. .bits_per_word = 8,
  108. };
  109. #endif
  110. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  111. #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
  112. {
  113. /* the modalias must be the same as spi device driver name */
  114. .modalias = "m25p80", /* Name of spi_driver for this device */
  115. .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
  116. .bus_num = 0, /* Framework bus number */
  117. .chip_select = 2, /* Framework chip select. */
  118. .platform_data = &bfin_spi_flash_data,
  119. .controller_data = &spi_flash_chip_info,
  120. .mode = SPI_MODE_3,
  121. },
  122. #endif
  123. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  124. {
  125. .modalias = "mmc_spi",
  126. .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
  127. .bus_num = 0,
  128. .chip_select = 5,
  129. .controller_data = &mmc_spi_chip_info,
  130. .mode = SPI_MODE_3,
  131. },
  132. #endif
  133. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  134. {
  135. .modalias = "spidev",
  136. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  137. .bus_num = 0,
  138. .chip_select = 7,
  139. .controller_data = &spidev_chip_info,
  140. },
  141. #endif
  142. };
  143. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  144. /* SPI (0) */
  145. static struct resource bfin_spi0_resource[] = {
  146. [0] = {
  147. .start = SPI0_REGBASE,
  148. .end = SPI0_REGBASE + 0xFF,
  149. .flags = IORESOURCE_MEM,
  150. },
  151. [1] = {
  152. .start = CH_SPI,
  153. .end = CH_SPI,
  154. .flags = IORESOURCE_DMA,
  155. },
  156. [2] = {
  157. .start = IRQ_SPI,
  158. .end = IRQ_SPI,
  159. .flags = IORESOURCE_IRQ,
  160. }
  161. };
  162. /* SPI controller data */
  163. static struct bfin5xx_spi_master bfin_spi0_info = {
  164. .num_chipselect = 8,
  165. .enable_dma = 1, /* master has the ability to do dma transfer */
  166. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  167. };
  168. static struct platform_device bfin_spi0_device = {
  169. .name = "bfin-spi",
  170. .id = 0, /* Bus number */
  171. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  172. .resource = bfin_spi0_resource,
  173. .dev = {
  174. .platform_data = &bfin_spi0_info, /* Passed to driver */
  175. },
  176. };
  177. #endif /* spi master and devices */
  178. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  179. #ifdef CONFIG_SERIAL_BFIN_UART0
  180. static struct resource bfin_uart0_resources[] = {
  181. {
  182. .start = BFIN_UART_THR,
  183. .end = BFIN_UART_GCTL+2,
  184. .flags = IORESOURCE_MEM,
  185. },
  186. {
  187. .start = IRQ_UART0_RX,
  188. .end = IRQ_UART0_RX + 1,
  189. .flags = IORESOURCE_IRQ,
  190. },
  191. {
  192. .start = IRQ_UART0_ERROR,
  193. .end = IRQ_UART0_ERROR,
  194. .flags = IORESOURCE_IRQ,
  195. },
  196. {
  197. .start = CH_UART0_TX,
  198. .end = CH_UART0_TX,
  199. .flags = IORESOURCE_DMA,
  200. },
  201. {
  202. .start = CH_UART0_RX,
  203. .end = CH_UART0_RX,
  204. .flags = IORESOURCE_DMA,
  205. },
  206. };
  207. static unsigned short bfin_uart0_peripherals[] = {
  208. P_UART0_TX, P_UART0_RX, 0
  209. };
  210. static struct platform_device bfin_uart0_device = {
  211. .name = "bfin-uart",
  212. .id = 0,
  213. .num_resources = ARRAY_SIZE(bfin_uart0_resources),
  214. .resource = bfin_uart0_resources,
  215. .dev = {
  216. .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
  217. },
  218. };
  219. #endif
  220. #endif
  221. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  222. #ifdef CONFIG_BFIN_SIR0
  223. static struct resource bfin_sir0_resources[] = {
  224. {
  225. .start = 0xFFC00400,
  226. .end = 0xFFC004FF,
  227. .flags = IORESOURCE_MEM,
  228. },
  229. {
  230. .start = IRQ_UART0_RX,
  231. .end = IRQ_UART0_RX+1,
  232. .flags = IORESOURCE_IRQ,
  233. },
  234. {
  235. .start = CH_UART0_RX,
  236. .end = CH_UART0_RX+1,
  237. .flags = IORESOURCE_DMA,
  238. },
  239. };
  240. static struct platform_device bfin_sir0_device = {
  241. .name = "bfin_sir",
  242. .id = 0,
  243. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  244. .resource = bfin_sir0_resources,
  245. };
  246. #endif
  247. #endif
  248. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  249. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  250. static struct resource bfin_sport0_uart_resources[] = {
  251. {
  252. .start = SPORT0_TCR1,
  253. .end = SPORT0_MRCS3+4,
  254. .flags = IORESOURCE_MEM,
  255. },
  256. {
  257. .start = IRQ_SPORT0_RX,
  258. .end = IRQ_SPORT0_RX+1,
  259. .flags = IORESOURCE_IRQ,
  260. },
  261. {
  262. .start = IRQ_SPORT0_ERROR,
  263. .end = IRQ_SPORT0_ERROR,
  264. .flags = IORESOURCE_IRQ,
  265. },
  266. };
  267. static unsigned short bfin_sport0_peripherals[] = {
  268. P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
  269. P_SPORT0_DRPRI, P_SPORT0_RSCLK, 0
  270. };
  271. static struct platform_device bfin_sport0_uart_device = {
  272. .name = "bfin-sport-uart",
  273. .id = 0,
  274. .num_resources = ARRAY_SIZE(bfin_sport0_uart_resources),
  275. .resource = bfin_sport0_uart_resources,
  276. .dev = {
  277. .platform_data = &bfin_sport0_peripherals, /* Passed to driver */
  278. },
  279. };
  280. #endif
  281. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  282. static struct resource bfin_sport1_uart_resources[] = {
  283. {
  284. .start = SPORT1_TCR1,
  285. .end = SPORT1_MRCS3+4,
  286. .flags = IORESOURCE_MEM,
  287. },
  288. {
  289. .start = IRQ_SPORT1_RX,
  290. .end = IRQ_SPORT1_RX+1,
  291. .flags = IORESOURCE_IRQ,
  292. },
  293. {
  294. .start = IRQ_SPORT1_ERROR,
  295. .end = IRQ_SPORT1_ERROR,
  296. .flags = IORESOURCE_IRQ,
  297. },
  298. };
  299. static unsigned short bfin_sport1_peripherals[] = {
  300. P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
  301. P_SPORT1_DRPRI, P_SPORT1_RSCLK, 0
  302. };
  303. static struct platform_device bfin_sport1_uart_device = {
  304. .name = "bfin-sport-uart",
  305. .id = 1,
  306. .num_resources = ARRAY_SIZE(bfin_sport1_uart_resources),
  307. .resource = bfin_sport1_uart_resources,
  308. .dev = {
  309. .platform_data = &bfin_sport1_peripherals, /* Passed to driver */
  310. },
  311. };
  312. #endif
  313. #endif
  314. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  315. #include <linux/input.h>
  316. #include <linux/gpio_keys.h>
  317. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  318. {BTN_0, GPIO_PF4, 0, "gpio-keys: BTN0"},
  319. {BTN_1, GPIO_PF5, 0, "gpio-keys: BTN1"},
  320. {BTN_2, GPIO_PF6, 0, "gpio-keys: BTN2"},
  321. }; /* Mapped to the first three PF Test Points */
  322. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  323. .buttons = bfin_gpio_keys_table,
  324. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  325. };
  326. static struct platform_device bfin_device_gpiokeys = {
  327. .name = "gpio-keys",
  328. .dev = {
  329. .platform_data = &bfin_gpio_keys_data,
  330. },
  331. };
  332. #endif
  333. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  334. #include <linux/i2c-gpio.h>
  335. static struct i2c_gpio_platform_data i2c_gpio_data = {
  336. .sda_pin = GPIO_PF8,
  337. .scl_pin = GPIO_PF9,
  338. .sda_is_open_drain = 0,
  339. .scl_is_open_drain = 0,
  340. .udelay = 40,
  341. }; /* This hasn't actually been used these pins
  342. * are (currently) free pins on the expansion connector */
  343. static struct platform_device i2c_gpio_device = {
  344. .name = "i2c-gpio",
  345. .id = 0,
  346. .dev = {
  347. .platform_data = &i2c_gpio_data,
  348. },
  349. };
  350. #endif
  351. static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
  352. };
  353. static const unsigned int cclk_vlev_datasheet[] =
  354. {
  355. VRPAIR(VLEV_085, 250000000),
  356. VRPAIR(VLEV_090, 376000000),
  357. VRPAIR(VLEV_095, 426000000),
  358. VRPAIR(VLEV_100, 426000000),
  359. VRPAIR(VLEV_105, 476000000),
  360. VRPAIR(VLEV_110, 476000000),
  361. VRPAIR(VLEV_115, 476000000),
  362. VRPAIR(VLEV_120, 600000000),
  363. VRPAIR(VLEV_125, 600000000),
  364. VRPAIR(VLEV_130, 600000000),
  365. };
  366. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  367. .tuple_tab = cclk_vlev_datasheet,
  368. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  369. .vr_settling_time = 25 /* us */,
  370. };
  371. static struct platform_device bfin_dpmc = {
  372. .name = "bfin dpmc",
  373. .dev = {
  374. .platform_data = &bfin_dmpc_vreg_data,
  375. },
  376. };
  377. static struct platform_device *stamp_devices[] __initdata = {
  378. &bfin_dpmc,
  379. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  380. &rtc_device,
  381. #endif
  382. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  383. &smc91x_device,
  384. #endif
  385. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  386. &bfin_spi0_device,
  387. #endif
  388. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  389. #ifdef CONFIG_SERIAL_BFIN_UART0
  390. &bfin_uart0_device,
  391. #endif
  392. #endif
  393. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  394. #ifdef CONFIG_BFIN_SIR0
  395. &bfin_sir0_device,
  396. #endif
  397. #endif
  398. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  399. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  400. &bfin_sport0_uart_device,
  401. #endif
  402. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  403. &bfin_sport1_uart_device,
  404. #endif
  405. #endif
  406. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  407. &bfin_device_gpiokeys,
  408. #endif
  409. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  410. &i2c_gpio_device,
  411. #endif
  412. };
  413. static int __init blackstamp_init(void)
  414. {
  415. int ret;
  416. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  417. i2c_register_board_info(0, bfin_i2c_board_info,
  418. ARRAY_SIZE(bfin_i2c_board_info));
  419. ret = platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
  420. if (ret < 0)
  421. return ret;
  422. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  423. /*
  424. * setup BF533_STAMP CPLD to route AMS3 to Ethernet MAC.
  425. * the bfin-async-map driver takes care of flipping between
  426. * flash and ethernet when necessary.
  427. */
  428. ret = gpio_request(GPIO_PF0, "enet_cpld");
  429. if (!ret) {
  430. gpio_direction_output(GPIO_PF0, 1);
  431. gpio_free(GPIO_PF0);
  432. }
  433. #endif
  434. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  435. return 0;
  436. }
  437. arch_initcall(blackstamp_init);
  438. static struct platform_device *stamp_early_devices[] __initdata = {
  439. #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
  440. #ifdef CONFIG_SERIAL_BFIN_UART0
  441. &bfin_uart0_device,
  442. #endif
  443. #endif
  444. #if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
  445. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  446. &bfin_sport0_uart_device,
  447. #endif
  448. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  449. &bfin_sport1_uart_device,
  450. #endif
  451. #endif
  452. };
  453. void __init native_machine_early_platform_add_devices(void)
  454. {
  455. printk(KERN_INFO "register early platform devices\n");
  456. early_platform_add_devices(stamp_early_devices,
  457. ARRAY_SIZE(stamp_early_devices));
  458. }