blackstamp.c 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  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. static struct resource bfin_uart_resources[] = {
  180. {
  181. .start = 0xFFC00400,
  182. .end = 0xFFC004FF,
  183. .flags = IORESOURCE_MEM,
  184. },
  185. };
  186. static struct platform_device bfin_uart_device = {
  187. .name = "bfin-uart",
  188. .id = 1,
  189. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  190. .resource = bfin_uart_resources,
  191. };
  192. #endif
  193. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  194. #ifdef CONFIG_BFIN_SIR0
  195. static struct resource bfin_sir0_resources[] = {
  196. {
  197. .start = 0xFFC00400,
  198. .end = 0xFFC004FF,
  199. .flags = IORESOURCE_MEM,
  200. },
  201. {
  202. .start = IRQ_UART0_RX,
  203. .end = IRQ_UART0_RX+1,
  204. .flags = IORESOURCE_IRQ,
  205. },
  206. {
  207. .start = CH_UART0_RX,
  208. .end = CH_UART0_RX+1,
  209. .flags = IORESOURCE_DMA,
  210. },
  211. };
  212. static struct platform_device bfin_sir0_device = {
  213. .name = "bfin_sir",
  214. .id = 0,
  215. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  216. .resource = bfin_sir0_resources,
  217. };
  218. #endif
  219. #endif
  220. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  221. static struct platform_device bfin_sport0_uart_device = {
  222. .name = "bfin-sport-uart",
  223. .id = 0,
  224. };
  225. static struct platform_device bfin_sport1_uart_device = {
  226. .name = "bfin-sport-uart",
  227. .id = 1,
  228. };
  229. #endif
  230. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  231. #include <linux/input.h>
  232. #include <linux/gpio_keys.h>
  233. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  234. {BTN_0, GPIO_PF4, 0, "gpio-keys: BTN0"},
  235. {BTN_1, GPIO_PF5, 0, "gpio-keys: BTN1"},
  236. {BTN_2, GPIO_PF6, 0, "gpio-keys: BTN2"},
  237. }; /* Mapped to the first three PF Test Points */
  238. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  239. .buttons = bfin_gpio_keys_table,
  240. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  241. };
  242. static struct platform_device bfin_device_gpiokeys = {
  243. .name = "gpio-keys",
  244. .dev = {
  245. .platform_data = &bfin_gpio_keys_data,
  246. },
  247. };
  248. #endif
  249. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  250. #include <linux/i2c-gpio.h>
  251. static struct i2c_gpio_platform_data i2c_gpio_data = {
  252. .sda_pin = 8,
  253. .scl_pin = 9,
  254. .sda_is_open_drain = 0,
  255. .scl_is_open_drain = 0,
  256. .udelay = 40,
  257. }; /* This hasn't actually been used these pins
  258. * are (currently) free pins on the expansion connector */
  259. static struct platform_device i2c_gpio_device = {
  260. .name = "i2c-gpio",
  261. .id = 0,
  262. .dev = {
  263. .platform_data = &i2c_gpio_data,
  264. },
  265. };
  266. #endif
  267. static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
  268. };
  269. static const unsigned int cclk_vlev_datasheet[] =
  270. {
  271. VRPAIR(VLEV_085, 250000000),
  272. VRPAIR(VLEV_090, 376000000),
  273. VRPAIR(VLEV_095, 426000000),
  274. VRPAIR(VLEV_100, 426000000),
  275. VRPAIR(VLEV_105, 476000000),
  276. VRPAIR(VLEV_110, 476000000),
  277. VRPAIR(VLEV_115, 476000000),
  278. VRPAIR(VLEV_120, 600000000),
  279. VRPAIR(VLEV_125, 600000000),
  280. VRPAIR(VLEV_130, 600000000),
  281. };
  282. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  283. .tuple_tab = cclk_vlev_datasheet,
  284. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  285. .vr_settling_time = 25 /* us */,
  286. };
  287. static struct platform_device bfin_dpmc = {
  288. .name = "bfin dpmc",
  289. .dev = {
  290. .platform_data = &bfin_dmpc_vreg_data,
  291. },
  292. };
  293. static struct platform_device *stamp_devices[] __initdata = {
  294. &bfin_dpmc,
  295. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  296. &rtc_device,
  297. #endif
  298. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  299. &smc91x_device,
  300. #endif
  301. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  302. &bfin_spi0_device,
  303. #endif
  304. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  305. &bfin_uart_device,
  306. #endif
  307. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  308. #ifdef CONFIG_BFIN_SIR0
  309. &bfin_sir0_device,
  310. #endif
  311. #endif
  312. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  313. &bfin_sport0_uart_device,
  314. &bfin_sport1_uart_device,
  315. #endif
  316. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  317. &bfin_device_gpiokeys,
  318. #endif
  319. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  320. &i2c_gpio_device,
  321. #endif
  322. };
  323. static int __init blackstamp_init(void)
  324. {
  325. int ret;
  326. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  327. i2c_register_board_info(0, bfin_i2c_board_info,
  328. ARRAY_SIZE(bfin_i2c_board_info));
  329. ret = platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
  330. if (ret < 0)
  331. return ret;
  332. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  333. /* setup BF533_STAMP CPLD to route AMS3 to Ethernet MAC */
  334. bfin_write_FIO_DIR(bfin_read_FIO_DIR() | PF0);
  335. bfin_write_FIO_FLAG_S(PF0);
  336. SSYNC();
  337. #endif
  338. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  339. return 0;
  340. }
  341. arch_initcall(blackstamp_init);