blackstamp.c 9.8 KB

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