blackstamp.c 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  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. #include <linux/smc91x.h>
  48. static struct smc91x_platdata smc91x_info = {
  49. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
  50. .leda = RPC_LED_100_10,
  51. .ledb = RPC_LED_TX_RX,
  52. };
  53. static struct resource smc91x_resources[] = {
  54. {
  55. .name = "smc91x-regs",
  56. .start = 0x20300300,
  57. .end = 0x20300300 + 16,
  58. .flags = IORESOURCE_MEM,
  59. }, {
  60. .start = IRQ_PF3,
  61. .end = IRQ_PF3,
  62. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  63. },
  64. };
  65. static struct platform_device smc91x_device = {
  66. .name = "smc91x",
  67. .id = 0,
  68. .num_resources = ARRAY_SIZE(smc91x_resources),
  69. .resource = smc91x_resources,
  70. .dev = {
  71. .platform_data = &smc91x_info,
  72. },
  73. };
  74. #endif
  75. #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
  76. static struct mtd_partition bfin_spi_flash_partitions[] = {
  77. {
  78. .name = "bootloader(spi)",
  79. .size = 0x00040000,
  80. .offset = 0,
  81. .mask_flags = MTD_CAP_ROM
  82. }, {
  83. .name = "linux kernel(spi)",
  84. .size = 0x180000,
  85. .offset = MTDPART_OFS_APPEND,
  86. }, {
  87. .name = "file system(spi)",
  88. .size = MTDPART_SIZ_FULL,
  89. .offset = MTDPART_OFS_APPEND,
  90. }
  91. };
  92. static struct flash_platform_data bfin_spi_flash_data = {
  93. .name = "m25p80",
  94. .parts = bfin_spi_flash_partitions,
  95. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  96. .type = "m25p64",
  97. };
  98. /* SPI flash chip (m25p64) */
  99. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  100. .enable_dma = 0, /* use dma transfer with this chip*/
  101. .bits_per_word = 8,
  102. };
  103. #endif
  104. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  105. static struct bfin5xx_spi_chip mmc_spi_chip_info = {
  106. .enable_dma = 0,
  107. .bits_per_word = 8,
  108. };
  109. #endif
  110. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  111. static struct bfin5xx_spi_chip spidev_chip_info = {
  112. .enable_dma = 0,
  113. .bits_per_word = 8,
  114. };
  115. #endif
  116. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  117. #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
  118. {
  119. /* the modalias must be the same as spi device driver name */
  120. .modalias = "m25p80", /* Name of spi_driver for this device */
  121. .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
  122. .bus_num = 0, /* Framework bus number */
  123. .chip_select = 2, /* Framework chip select. */
  124. .platform_data = &bfin_spi_flash_data,
  125. .controller_data = &spi_flash_chip_info,
  126. .mode = SPI_MODE_3,
  127. },
  128. #endif
  129. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  130. {
  131. .modalias = "mmc_spi",
  132. .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
  133. .bus_num = 0,
  134. .chip_select = 5,
  135. .controller_data = &mmc_spi_chip_info,
  136. .mode = SPI_MODE_3,
  137. },
  138. #endif
  139. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  140. {
  141. .modalias = "spidev",
  142. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  143. .bus_num = 0,
  144. .chip_select = 7,
  145. .controller_data = &spidev_chip_info,
  146. },
  147. #endif
  148. };
  149. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  150. /* SPI (0) */
  151. static struct resource bfin_spi0_resource[] = {
  152. [0] = {
  153. .start = SPI0_REGBASE,
  154. .end = SPI0_REGBASE + 0xFF,
  155. .flags = IORESOURCE_MEM,
  156. },
  157. [1] = {
  158. .start = CH_SPI,
  159. .end = CH_SPI,
  160. .flags = IORESOURCE_DMA,
  161. },
  162. [2] = {
  163. .start = IRQ_SPI,
  164. .end = IRQ_SPI,
  165. .flags = IORESOURCE_IRQ,
  166. }
  167. };
  168. /* SPI controller data */
  169. static struct bfin5xx_spi_master bfin_spi0_info = {
  170. .num_chipselect = 8,
  171. .enable_dma = 1, /* master has the ability to do dma transfer */
  172. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  173. };
  174. static struct platform_device bfin_spi0_device = {
  175. .name = "bfin-spi",
  176. .id = 0, /* Bus number */
  177. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  178. .resource = bfin_spi0_resource,
  179. .dev = {
  180. .platform_data = &bfin_spi0_info, /* Passed to driver */
  181. },
  182. };
  183. #endif /* spi master and devices */
  184. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  185. static struct resource bfin_uart_resources[] = {
  186. {
  187. .start = 0xFFC00400,
  188. .end = 0xFFC004FF,
  189. .flags = IORESOURCE_MEM,
  190. },
  191. };
  192. static struct platform_device bfin_uart_device = {
  193. .name = "bfin-uart",
  194. .id = 1,
  195. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  196. .resource = bfin_uart_resources,
  197. };
  198. #endif
  199. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  200. #ifdef CONFIG_BFIN_SIR0
  201. static struct resource bfin_sir0_resources[] = {
  202. {
  203. .start = 0xFFC00400,
  204. .end = 0xFFC004FF,
  205. .flags = IORESOURCE_MEM,
  206. },
  207. {
  208. .start = IRQ_UART0_RX,
  209. .end = IRQ_UART0_RX+1,
  210. .flags = IORESOURCE_IRQ,
  211. },
  212. {
  213. .start = CH_UART0_RX,
  214. .end = CH_UART0_RX+1,
  215. .flags = IORESOURCE_DMA,
  216. },
  217. };
  218. static struct platform_device bfin_sir0_device = {
  219. .name = "bfin_sir",
  220. .id = 0,
  221. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  222. .resource = bfin_sir0_resources,
  223. };
  224. #endif
  225. #endif
  226. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  227. static struct platform_device bfin_sport0_uart_device = {
  228. .name = "bfin-sport-uart",
  229. .id = 0,
  230. };
  231. static struct platform_device bfin_sport1_uart_device = {
  232. .name = "bfin-sport-uart",
  233. .id = 1,
  234. };
  235. #endif
  236. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  237. #include <linux/input.h>
  238. #include <linux/gpio_keys.h>
  239. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  240. {BTN_0, GPIO_PF4, 0, "gpio-keys: BTN0"},
  241. {BTN_1, GPIO_PF5, 0, "gpio-keys: BTN1"},
  242. {BTN_2, GPIO_PF6, 0, "gpio-keys: BTN2"},
  243. }; /* Mapped to the first three PF Test Points */
  244. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  245. .buttons = bfin_gpio_keys_table,
  246. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  247. };
  248. static struct platform_device bfin_device_gpiokeys = {
  249. .name = "gpio-keys",
  250. .dev = {
  251. .platform_data = &bfin_gpio_keys_data,
  252. },
  253. };
  254. #endif
  255. static struct resource bfin_gpios_resources = {
  256. .start = 0,
  257. .end = MAX_BLACKFIN_GPIOS - 1,
  258. .flags = IORESOURCE_IRQ,
  259. };
  260. static struct platform_device bfin_gpios_device = {
  261. .name = "simple-gpio",
  262. .id = -1,
  263. .num_resources = 1,
  264. .resource = &bfin_gpios_resources,
  265. };
  266. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  267. #include <linux/i2c-gpio.h>
  268. static struct i2c_gpio_platform_data i2c_gpio_data = {
  269. .sda_pin = 8,
  270. .scl_pin = 9,
  271. .sda_is_open_drain = 0,
  272. .scl_is_open_drain = 0,
  273. .udelay = 40,
  274. }; /* This hasn't actually been used these pins
  275. * are (currently) free pins on the expansion connector */
  276. static struct platform_device i2c_gpio_device = {
  277. .name = "i2c-gpio",
  278. .id = 0,
  279. .dev = {
  280. .platform_data = &i2c_gpio_data,
  281. },
  282. };
  283. #endif
  284. static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
  285. };
  286. static const unsigned int cclk_vlev_datasheet[] =
  287. {
  288. VRPAIR(VLEV_085, 250000000),
  289. VRPAIR(VLEV_090, 376000000),
  290. VRPAIR(VLEV_095, 426000000),
  291. VRPAIR(VLEV_100, 426000000),
  292. VRPAIR(VLEV_105, 476000000),
  293. VRPAIR(VLEV_110, 476000000),
  294. VRPAIR(VLEV_115, 476000000),
  295. VRPAIR(VLEV_120, 600000000),
  296. VRPAIR(VLEV_125, 600000000),
  297. VRPAIR(VLEV_130, 600000000),
  298. };
  299. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  300. .tuple_tab = cclk_vlev_datasheet,
  301. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  302. .vr_settling_time = 25 /* us */,
  303. };
  304. static struct platform_device bfin_dpmc = {
  305. .name = "bfin dpmc",
  306. .dev = {
  307. .platform_data = &bfin_dmpc_vreg_data,
  308. },
  309. };
  310. static struct platform_device *stamp_devices[] __initdata = {
  311. &bfin_dpmc,
  312. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  313. &rtc_device,
  314. #endif
  315. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  316. &smc91x_device,
  317. #endif
  318. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  319. &bfin_spi0_device,
  320. #endif
  321. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  322. &bfin_uart_device,
  323. #endif
  324. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  325. #ifdef CONFIG_BFIN_SIR0
  326. &bfin_sir0_device,
  327. #endif
  328. #endif
  329. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  330. &bfin_sport0_uart_device,
  331. &bfin_sport1_uart_device,
  332. #endif
  333. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  334. &bfin_device_gpiokeys,
  335. #endif
  336. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  337. &i2c_gpio_device,
  338. #endif
  339. &bfin_gpios_device,
  340. };
  341. static int __init blackstamp_init(void)
  342. {
  343. int ret;
  344. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  345. i2c_register_board_info(0, bfin_i2c_board_info,
  346. ARRAY_SIZE(bfin_i2c_board_info));
  347. ret = platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
  348. if (ret < 0)
  349. return ret;
  350. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  351. /* setup BF533_STAMP CPLD to route AMS3 to Ethernet MAC */
  352. bfin_write_FIO_DIR(bfin_read_FIO_DIR() | PF0);
  353. bfin_write_FIO_FLAG_S(PF0);
  354. SSYNC();
  355. #endif
  356. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  357. return 0;
  358. }
  359. arch_initcall(blackstamp_init);