blackstamp.c 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. /*
  2. * File: arch/blackfin/mach-bf533/blackstamp.c
  3. * Based on: arch/blackfin/mach-bf533/stamp.c
  4. * Author: Benjamin Matthews <bmat@lle.rochester.edu>
  5. * Aidan Williams <aidan@nicta.com.au>
  6. *
  7. * Created: 2008
  8. * Description: Board Info File for the BlackStamp
  9. *
  10. * Copyright 2005 National ICT Australia (NICTA)
  11. * Copyright 2004-2008 Analog Devices Inc.
  12. *
  13. * Enter bugs at http://blackfin.uclinux.org/
  14. *
  15. * More info about the BlackStamp at:
  16. * http://blackfin.uclinux.org/gf/project/blackstamp/
  17. *
  18. * Licensed under the GPL-2 or later.
  19. */
  20. #include <linux/device.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/mtd/mtd.h>
  23. #include <linux/mtd/partitions.h>
  24. #include <linux/mtd/physmap.h>
  25. #include <linux/spi/spi.h>
  26. #include <linux/spi/flash.h>
  27. #include <linux/irq.h>
  28. #include <linux/i2c.h>
  29. #include <asm/dma.h>
  30. #include <asm/bfin5xx_spi.h>
  31. #include <asm/portmux.h>
  32. #include <asm/dpmc.h>
  33. /*
  34. * Name the Board for the /proc/cpuinfo
  35. */
  36. const char bfin_board_name[] = "BlackStamp";
  37. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  38. static struct platform_device rtc_device = {
  39. .name = "rtc-bfin",
  40. .id = -1,
  41. };
  42. #endif
  43. /*
  44. * Driver needs to know address, irq and flag pin.
  45. */
  46. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  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. };
  65. #endif
  66. #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
  67. static struct mtd_partition bfin_spi_flash_partitions[] = {
  68. {
  69. .name = "bootloader(spi)",
  70. .size = 0x00040000,
  71. .offset = 0,
  72. .mask_flags = MTD_CAP_ROM
  73. }, {
  74. .name = "linux kernel(spi)",
  75. .size = 0x180000,
  76. .offset = MTDPART_OFS_APPEND,
  77. }, {
  78. .name = "file system(spi)",
  79. .size = MTDPART_SIZ_FULL,
  80. .offset = MTDPART_OFS_APPEND,
  81. }
  82. };
  83. static struct flash_platform_data bfin_spi_flash_data = {
  84. .name = "m25p80",
  85. .parts = bfin_spi_flash_partitions,
  86. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  87. .type = "m25p64",
  88. };
  89. /* SPI flash chip (m25p64) */
  90. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  91. .enable_dma = 0, /* use dma transfer with this chip*/
  92. .bits_per_word = 8,
  93. };
  94. #endif
  95. #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
  96. static struct bfin5xx_spi_chip spi_mmc_chip_info = {
  97. .enable_dma = 1,
  98. .bits_per_word = 8,
  99. };
  100. #endif
  101. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  102. static struct bfin5xx_spi_chip spidev_chip_info = {
  103. .enable_dma = 0,
  104. .bits_per_word = 8,
  105. };
  106. #endif
  107. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  108. #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
  109. {
  110. /* the modalias must be the same as spi device driver name */
  111. .modalias = "m25p80", /* Name of spi_driver for this device */
  112. .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
  113. .bus_num = 0, /* Framework bus number */
  114. .chip_select = 2, /* Framework chip select. */
  115. .platform_data = &bfin_spi_flash_data,
  116. .controller_data = &spi_flash_chip_info,
  117. .mode = SPI_MODE_3,
  118. },
  119. #endif
  120. #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
  121. {
  122. .modalias = "spi_mmc_dummy",
  123. .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
  124. .bus_num = 0,
  125. .chip_select = 0,
  126. .platform_data = NULL,
  127. .controller_data = &spi_mmc_chip_info,
  128. .mode = SPI_MODE_3,
  129. },
  130. {
  131. .modalias = "spi_mmc",
  132. .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
  133. .bus_num = 0,
  134. .chip_select = CONFIG_SPI_MMC_CS_CHAN,
  135. .platform_data = NULL,
  136. .controller_data = &spi_mmc_chip_info,
  137. .mode = SPI_MODE_3,
  138. },
  139. #endif
  140. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  141. {
  142. .modalias = "spidev",
  143. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  144. .bus_num = 0,
  145. .chip_select = 7,
  146. .controller_data = &spidev_chip_info,
  147. },
  148. #endif
  149. };
  150. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  151. /* SPI (0) */
  152. static struct resource bfin_spi0_resource[] = {
  153. [0] = {
  154. .start = SPI0_REGBASE,
  155. .end = SPI0_REGBASE + 0xFF,
  156. .flags = IORESOURCE_MEM,
  157. },
  158. [1] = {
  159. .start = CH_SPI,
  160. .end = CH_SPI,
  161. .flags = IORESOURCE_IRQ,
  162. }
  163. };
  164. /* SPI controller data */
  165. static struct bfin5xx_spi_master bfin_spi0_info = {
  166. .num_chipselect = 8,
  167. .enable_dma = 1, /* master has the ability to do dma transfer */
  168. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  169. };
  170. static struct platform_device bfin_spi0_device = {
  171. .name = "bfin-spi",
  172. .id = 0, /* Bus number */
  173. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  174. .resource = bfin_spi0_resource,
  175. .dev = {
  176. .platform_data = &bfin_spi0_info, /* Passed to driver */
  177. },
  178. };
  179. #endif /* spi master and devices */
  180. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  181. static struct resource bfin_uart_resources[] = {
  182. {
  183. .start = 0xFFC00400,
  184. .end = 0xFFC004FF,
  185. .flags = IORESOURCE_MEM,
  186. },
  187. };
  188. static struct platform_device bfin_uart_device = {
  189. .name = "bfin-uart",
  190. .id = 1,
  191. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  192. .resource = bfin_uart_resources,
  193. };
  194. #endif
  195. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  196. static struct resource bfin_sir_resources[] = {
  197. #ifdef CONFIG_BFIN_SIR0
  198. {
  199. .start = 0xFFC00400,
  200. .end = 0xFFC004FF,
  201. .flags = IORESOURCE_MEM,
  202. },
  203. #endif
  204. };
  205. static struct platform_device bfin_sir_device = {
  206. .name = "bfin_sir",
  207. .id = 0,
  208. .num_resources = ARRAY_SIZE(bfin_sir_resources),
  209. .resource = bfin_sir_resources,
  210. };
  211. #endif
  212. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  213. static struct platform_device bfin_sport0_uart_device = {
  214. .name = "bfin-sport-uart",
  215. .id = 0,
  216. };
  217. static struct platform_device bfin_sport1_uart_device = {
  218. .name = "bfin-sport-uart",
  219. .id = 1,
  220. };
  221. #endif
  222. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  223. #include <linux/input.h>
  224. #include <linux/gpio_keys.h>
  225. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  226. {BTN_0, GPIO_PF4, 0, "gpio-keys: BTN0"},
  227. {BTN_1, GPIO_PF5, 0, "gpio-keys: BTN1"},
  228. {BTN_2, GPIO_PF6, 0, "gpio-keys: BTN2"},
  229. }; /* Mapped to the first three PF Test Points */
  230. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  231. .buttons = bfin_gpio_keys_table,
  232. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  233. };
  234. static struct platform_device bfin_device_gpiokeys = {
  235. .name = "gpio-keys",
  236. .dev = {
  237. .platform_data = &bfin_gpio_keys_data,
  238. },
  239. };
  240. #endif
  241. static struct resource bfin_gpios_resources = {
  242. .start = 0,
  243. .end = MAX_BLACKFIN_GPIOS - 1,
  244. .flags = IORESOURCE_IRQ,
  245. };
  246. static struct platform_device bfin_gpios_device = {
  247. .name = "simple-gpio",
  248. .id = -1,
  249. .num_resources = 1,
  250. .resource = &bfin_gpios_resources,
  251. };
  252. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  253. #include <linux/i2c-gpio.h>
  254. static struct i2c_gpio_platform_data i2c_gpio_data = {
  255. .sda_pin = 8,
  256. .scl_pin = 9,
  257. .sda_is_open_drain = 0,
  258. .scl_is_open_drain = 0,
  259. .udelay = 40,
  260. }; /* This hasn't actually been used these pins
  261. * are (currently) free pins on the expansion connector */
  262. static struct platform_device i2c_gpio_device = {
  263. .name = "i2c-gpio",
  264. .id = 0,
  265. .dev = {
  266. .platform_data = &i2c_gpio_data,
  267. },
  268. };
  269. #endif
  270. #ifdef CONFIG_I2C_BOARDINFO
  271. static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
  272. };
  273. #endif
  274. static const unsigned int cclk_vlev_datasheet[] =
  275. {
  276. VRPAIR(VLEV_085, 250000000),
  277. VRPAIR(VLEV_090, 376000000),
  278. VRPAIR(VLEV_095, 426000000),
  279. VRPAIR(VLEV_100, 426000000),
  280. VRPAIR(VLEV_105, 476000000),
  281. VRPAIR(VLEV_110, 476000000),
  282. VRPAIR(VLEV_115, 476000000),
  283. VRPAIR(VLEV_120, 600000000),
  284. VRPAIR(VLEV_125, 600000000),
  285. VRPAIR(VLEV_130, 600000000),
  286. };
  287. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  288. .tuple_tab = cclk_vlev_datasheet,
  289. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  290. .vr_settling_time = 25 /* us */,
  291. };
  292. static struct platform_device bfin_dpmc = {
  293. .name = "bfin dpmc",
  294. .dev = {
  295. .platform_data = &bfin_dmpc_vreg_data,
  296. },
  297. };
  298. static struct platform_device *stamp_devices[] __initdata = {
  299. &bfin_dpmc,
  300. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  301. &rtc_device,
  302. #endif
  303. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  304. &smc91x_device,
  305. #endif
  306. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  307. &bfin_spi0_device,
  308. #endif
  309. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  310. &bfin_uart_device,
  311. #endif
  312. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  313. &bfin_sir_device,
  314. #endif
  315. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  316. &bfin_sport0_uart_device,
  317. &bfin_sport1_uart_device,
  318. #endif
  319. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  320. &bfin_device_gpiokeys,
  321. #endif
  322. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  323. &i2c_gpio_device,
  324. #endif
  325. &bfin_gpios_device,
  326. };
  327. static int __init blackstamp_init(void)
  328. {
  329. int ret;
  330. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  331. #ifdef CONFIG_I2C_BOARDINFO
  332. i2c_register_board_info(0, bfin_i2c_board_info,
  333. ARRAY_SIZE(bfin_i2c_board_info));
  334. #endif
  335. ret = platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
  336. if (ret < 0)
  337. return ret;
  338. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  339. /* setup BF533_STAMP CPLD to route AMS3 to Ethernet MAC */
  340. bfin_write_FIO_DIR(bfin_read_FIO_DIR() | PF0);
  341. bfin_write_FIO_FLAG_S(PF0);
  342. SSYNC();
  343. #endif
  344. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  345. return 0;
  346. }
  347. arch_initcall(blackstamp_init);