blackstamp.c 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  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_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  96. static struct bfin5xx_spi_chip mmc_spi_chip_info = {
  97. .enable_dma = 0,
  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_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  121. {
  122. .modalias = "mmc_spi",
  123. .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
  124. .bus_num = 0,
  125. .chip_select = 5,
  126. .controller_data = &mmc_spi_chip_info,
  127. .mode = SPI_MODE_3,
  128. },
  129. #endif
  130. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  131. {
  132. .modalias = "spidev",
  133. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  134. .bus_num = 0,
  135. .chip_select = 7,
  136. .controller_data = &spidev_chip_info,
  137. },
  138. #endif
  139. };
  140. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  141. /* SPI (0) */
  142. static struct resource bfin_spi0_resource[] = {
  143. [0] = {
  144. .start = SPI0_REGBASE,
  145. .end = SPI0_REGBASE + 0xFF,
  146. .flags = IORESOURCE_MEM,
  147. },
  148. [1] = {
  149. .start = CH_SPI,
  150. .end = CH_SPI,
  151. .flags = IORESOURCE_DMA,
  152. },
  153. [2] = {
  154. .start = IRQ_SPI,
  155. .end = IRQ_SPI,
  156. .flags = IORESOURCE_IRQ,
  157. }
  158. };
  159. /* SPI controller data */
  160. static struct bfin5xx_spi_master bfin_spi0_info = {
  161. .num_chipselect = 8,
  162. .enable_dma = 1, /* master has the ability to do dma transfer */
  163. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  164. };
  165. static struct platform_device bfin_spi0_device = {
  166. .name = "bfin-spi",
  167. .id = 0, /* Bus number */
  168. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  169. .resource = bfin_spi0_resource,
  170. .dev = {
  171. .platform_data = &bfin_spi0_info, /* Passed to driver */
  172. },
  173. };
  174. #endif /* spi master and devices */
  175. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  176. static struct resource bfin_uart_resources[] = {
  177. {
  178. .start = 0xFFC00400,
  179. .end = 0xFFC004FF,
  180. .flags = IORESOURCE_MEM,
  181. },
  182. };
  183. static struct platform_device bfin_uart_device = {
  184. .name = "bfin-uart",
  185. .id = 1,
  186. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  187. .resource = bfin_uart_resources,
  188. };
  189. #endif
  190. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  191. #ifdef CONFIG_BFIN_SIR0
  192. static struct resource bfin_sir0_resources[] = {
  193. {
  194. .start = 0xFFC00400,
  195. .end = 0xFFC004FF,
  196. .flags = IORESOURCE_MEM,
  197. },
  198. {
  199. .start = IRQ_UART0_RX,
  200. .end = IRQ_UART0_RX+1,
  201. .flags = IORESOURCE_IRQ,
  202. },
  203. {
  204. .start = CH_UART0_RX,
  205. .end = CH_UART0_RX+1,
  206. .flags = IORESOURCE_DMA,
  207. },
  208. };
  209. static struct platform_device bfin_sir0_device = {
  210. .name = "bfin_sir",
  211. .id = 0,
  212. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  213. .resource = bfin_sir0_resources,
  214. };
  215. #endif
  216. #endif
  217. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  218. static struct platform_device bfin_sport0_uart_device = {
  219. .name = "bfin-sport-uart",
  220. .id = 0,
  221. };
  222. static struct platform_device bfin_sport1_uart_device = {
  223. .name = "bfin-sport-uart",
  224. .id = 1,
  225. };
  226. #endif
  227. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  228. #include <linux/input.h>
  229. #include <linux/gpio_keys.h>
  230. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  231. {BTN_0, GPIO_PF4, 0, "gpio-keys: BTN0"},
  232. {BTN_1, GPIO_PF5, 0, "gpio-keys: BTN1"},
  233. {BTN_2, GPIO_PF6, 0, "gpio-keys: BTN2"},
  234. }; /* Mapped to the first three PF Test Points */
  235. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  236. .buttons = bfin_gpio_keys_table,
  237. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  238. };
  239. static struct platform_device bfin_device_gpiokeys = {
  240. .name = "gpio-keys",
  241. .dev = {
  242. .platform_data = &bfin_gpio_keys_data,
  243. },
  244. };
  245. #endif
  246. static struct resource bfin_gpios_resources = {
  247. .start = 0,
  248. .end = MAX_BLACKFIN_GPIOS - 1,
  249. .flags = IORESOURCE_IRQ,
  250. };
  251. static struct platform_device bfin_gpios_device = {
  252. .name = "simple-gpio",
  253. .id = -1,
  254. .num_resources = 1,
  255. .resource = &bfin_gpios_resources,
  256. };
  257. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  258. #include <linux/i2c-gpio.h>
  259. static struct i2c_gpio_platform_data i2c_gpio_data = {
  260. .sda_pin = 8,
  261. .scl_pin = 9,
  262. .sda_is_open_drain = 0,
  263. .scl_is_open_drain = 0,
  264. .udelay = 40,
  265. }; /* This hasn't actually been used these pins
  266. * are (currently) free pins on the expansion connector */
  267. static struct platform_device i2c_gpio_device = {
  268. .name = "i2c-gpio",
  269. .id = 0,
  270. .dev = {
  271. .platform_data = &i2c_gpio_data,
  272. },
  273. };
  274. #endif
  275. static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
  276. };
  277. static const unsigned int cclk_vlev_datasheet[] =
  278. {
  279. VRPAIR(VLEV_085, 250000000),
  280. VRPAIR(VLEV_090, 376000000),
  281. VRPAIR(VLEV_095, 426000000),
  282. VRPAIR(VLEV_100, 426000000),
  283. VRPAIR(VLEV_105, 476000000),
  284. VRPAIR(VLEV_110, 476000000),
  285. VRPAIR(VLEV_115, 476000000),
  286. VRPAIR(VLEV_120, 600000000),
  287. VRPAIR(VLEV_125, 600000000),
  288. VRPAIR(VLEV_130, 600000000),
  289. };
  290. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  291. .tuple_tab = cclk_vlev_datasheet,
  292. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  293. .vr_settling_time = 25 /* us */,
  294. };
  295. static struct platform_device bfin_dpmc = {
  296. .name = "bfin dpmc",
  297. .dev = {
  298. .platform_data = &bfin_dmpc_vreg_data,
  299. },
  300. };
  301. static struct platform_device *stamp_devices[] __initdata = {
  302. &bfin_dpmc,
  303. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  304. &rtc_device,
  305. #endif
  306. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  307. &smc91x_device,
  308. #endif
  309. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  310. &bfin_spi0_device,
  311. #endif
  312. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  313. &bfin_uart_device,
  314. #endif
  315. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  316. #ifdef CONFIG_BFIN_SIR0
  317. &bfin_sir0_device,
  318. #endif
  319. #endif
  320. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  321. &bfin_sport0_uart_device,
  322. &bfin_sport1_uart_device,
  323. #endif
  324. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  325. &bfin_device_gpiokeys,
  326. #endif
  327. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  328. &i2c_gpio_device,
  329. #endif
  330. &bfin_gpios_device,
  331. };
  332. static int __init blackstamp_init(void)
  333. {
  334. int ret;
  335. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  336. i2c_register_board_info(0, bfin_i2c_board_info,
  337. ARRAY_SIZE(bfin_i2c_board_info));
  338. ret = platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
  339. if (ret < 0)
  340. return ret;
  341. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  342. /* setup BF533_STAMP CPLD to route AMS3 to Ethernet MAC */
  343. bfin_write_FIO_DIR(bfin_read_FIO_DIR() | PF0);
  344. bfin_write_FIO_FLAG_S(PF0);
  345. SSYNC();
  346. #endif
  347. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  348. return 0;
  349. }
  350. arch_initcall(blackstamp_init);