blackstamp.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  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/gpio.h>
  23. #include <linux/i2c.h>
  24. #include <asm/dma.h>
  25. #include <asm/bfin5xx_spi.h>
  26. #include <asm/portmux.h>
  27. #include <asm/dpmc.h>
  28. /*
  29. * Name the Board for the /proc/cpuinfo
  30. */
  31. const char bfin_board_name[] = "BlackStamp";
  32. #if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
  33. static struct platform_device rtc_device = {
  34. .name = "rtc-bfin",
  35. .id = -1,
  36. };
  37. #endif
  38. /*
  39. * Driver needs to know address, irq and flag pin.
  40. */
  41. #if IS_ENABLED(CONFIG_SMC91X)
  42. #include <linux/smc91x.h>
  43. static struct smc91x_platdata smc91x_info = {
  44. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
  45. .leda = RPC_LED_100_10,
  46. .ledb = RPC_LED_TX_RX,
  47. };
  48. static struct resource smc91x_resources[] = {
  49. {
  50. .name = "smc91x-regs",
  51. .start = 0x20300300,
  52. .end = 0x20300300 + 16,
  53. .flags = IORESOURCE_MEM,
  54. }, {
  55. .start = IRQ_PF3,
  56. .end = IRQ_PF3,
  57. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  58. },
  59. };
  60. static struct platform_device smc91x_device = {
  61. .name = "smc91x",
  62. .id = 0,
  63. .num_resources = ARRAY_SIZE(smc91x_resources),
  64. .resource = smc91x_resources,
  65. .dev = {
  66. .platform_data = &smc91x_info,
  67. },
  68. };
  69. #endif
  70. #if IS_ENABLED(CONFIG_MTD_M25P80)
  71. static struct mtd_partition bfin_spi_flash_partitions[] = {
  72. {
  73. .name = "bootloader(spi)",
  74. .size = 0x00040000,
  75. .offset = 0,
  76. .mask_flags = MTD_CAP_ROM
  77. }, {
  78. .name = "linux kernel(spi)",
  79. .size = 0x180000,
  80. .offset = MTDPART_OFS_APPEND,
  81. }, {
  82. .name = "file system(spi)",
  83. .size = MTDPART_SIZ_FULL,
  84. .offset = MTDPART_OFS_APPEND,
  85. }
  86. };
  87. static struct flash_platform_data bfin_spi_flash_data = {
  88. .name = "m25p80",
  89. .parts = bfin_spi_flash_partitions,
  90. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  91. .type = "m25p64",
  92. };
  93. /* SPI flash chip (m25p64) */
  94. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  95. .enable_dma = 0, /* use dma transfer with this chip*/
  96. };
  97. #endif
  98. #if IS_ENABLED(CONFIG_MMC_SPI)
  99. static struct bfin5xx_spi_chip mmc_spi_chip_info = {
  100. .enable_dma = 0,
  101. };
  102. #endif
  103. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  104. #if IS_ENABLED(CONFIG_MTD_M25P80)
  105. {
  106. /* the modalias must be the same as spi device driver name */
  107. .modalias = "m25p80", /* Name of spi_driver for this device */
  108. .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
  109. .bus_num = 0, /* Framework bus number */
  110. .chip_select = 2, /* Framework chip select. */
  111. .platform_data = &bfin_spi_flash_data,
  112. .controller_data = &spi_flash_chip_info,
  113. .mode = SPI_MODE_3,
  114. },
  115. #endif
  116. #if IS_ENABLED(CONFIG_MMC_SPI)
  117. {
  118. .modalias = "mmc_spi",
  119. .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
  120. .bus_num = 0,
  121. .chip_select = 5,
  122. .controller_data = &mmc_spi_chip_info,
  123. .mode = SPI_MODE_3,
  124. },
  125. #endif
  126. #if IS_ENABLED(CONFIG_SPI_SPIDEV)
  127. {
  128. .modalias = "spidev",
  129. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  130. .bus_num = 0,
  131. .chip_select = 7,
  132. },
  133. #endif
  134. };
  135. #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
  136. /* SPI (0) */
  137. static struct resource bfin_spi0_resource[] = {
  138. [0] = {
  139. .start = SPI0_REGBASE,
  140. .end = SPI0_REGBASE + 0xFF,
  141. .flags = IORESOURCE_MEM,
  142. },
  143. [1] = {
  144. .start = CH_SPI,
  145. .end = CH_SPI,
  146. .flags = IORESOURCE_DMA,
  147. },
  148. [2] = {
  149. .start = IRQ_SPI,
  150. .end = IRQ_SPI,
  151. .flags = IORESOURCE_IRQ,
  152. }
  153. };
  154. /* SPI controller data */
  155. static struct bfin5xx_spi_master bfin_spi0_info = {
  156. .num_chipselect = 8,
  157. .enable_dma = 1, /* master has the ability to do dma transfer */
  158. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  159. };
  160. static struct platform_device bfin_spi0_device = {
  161. .name = "bfin-spi",
  162. .id = 0, /* Bus number */
  163. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  164. .resource = bfin_spi0_resource,
  165. .dev = {
  166. .platform_data = &bfin_spi0_info, /* Passed to driver */
  167. },
  168. };
  169. #endif /* spi master and devices */
  170. #if IS_ENABLED(CONFIG_SERIAL_BFIN)
  171. #ifdef CONFIG_SERIAL_BFIN_UART0
  172. static struct resource bfin_uart0_resources[] = {
  173. {
  174. .start = BFIN_UART_THR,
  175. .end = BFIN_UART_GCTL+2,
  176. .flags = IORESOURCE_MEM,
  177. },
  178. {
  179. .start = IRQ_UART0_TX,
  180. .end = IRQ_UART0_TX,
  181. .flags = IORESOURCE_IRQ,
  182. },
  183. {
  184. .start = IRQ_UART0_RX,
  185. .end = IRQ_UART0_RX,
  186. .flags = IORESOURCE_IRQ,
  187. },
  188. {
  189. .start = IRQ_UART0_ERROR,
  190. .end = IRQ_UART0_ERROR,
  191. .flags = IORESOURCE_IRQ,
  192. },
  193. {
  194. .start = CH_UART0_TX,
  195. .end = CH_UART0_TX,
  196. .flags = IORESOURCE_DMA,
  197. },
  198. {
  199. .start = CH_UART0_RX,
  200. .end = CH_UART0_RX,
  201. .flags = IORESOURCE_DMA,
  202. },
  203. };
  204. static unsigned short bfin_uart0_peripherals[] = {
  205. P_UART0_TX, P_UART0_RX, 0
  206. };
  207. static struct platform_device bfin_uart0_device = {
  208. .name = "bfin-uart",
  209. .id = 0,
  210. .num_resources = ARRAY_SIZE(bfin_uart0_resources),
  211. .resource = bfin_uart0_resources,
  212. .dev = {
  213. .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
  214. },
  215. };
  216. #endif
  217. #endif
  218. #if IS_ENABLED(CONFIG_BFIN_SIR)
  219. #ifdef CONFIG_BFIN_SIR0
  220. static struct resource bfin_sir0_resources[] = {
  221. {
  222. .start = 0xFFC00400,
  223. .end = 0xFFC004FF,
  224. .flags = IORESOURCE_MEM,
  225. },
  226. {
  227. .start = IRQ_UART0_RX,
  228. .end = IRQ_UART0_RX+1,
  229. .flags = IORESOURCE_IRQ,
  230. },
  231. {
  232. .start = CH_UART0_RX,
  233. .end = CH_UART0_RX+1,
  234. .flags = IORESOURCE_DMA,
  235. },
  236. };
  237. static struct platform_device bfin_sir0_device = {
  238. .name = "bfin_sir",
  239. .id = 0,
  240. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  241. .resource = bfin_sir0_resources,
  242. };
  243. #endif
  244. #endif
  245. #if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
  246. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  247. static struct resource bfin_sport0_uart_resources[] = {
  248. {
  249. .start = SPORT0_TCR1,
  250. .end = SPORT0_MRCS3+4,
  251. .flags = IORESOURCE_MEM,
  252. },
  253. {
  254. .start = IRQ_SPORT0_RX,
  255. .end = IRQ_SPORT0_RX+1,
  256. .flags = IORESOURCE_IRQ,
  257. },
  258. {
  259. .start = IRQ_SPORT0_ERROR,
  260. .end = IRQ_SPORT0_ERROR,
  261. .flags = IORESOURCE_IRQ,
  262. },
  263. };
  264. static unsigned short bfin_sport0_peripherals[] = {
  265. P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
  266. P_SPORT0_DRPRI, P_SPORT0_RSCLK, 0
  267. };
  268. static struct platform_device bfin_sport0_uart_device = {
  269. .name = "bfin-sport-uart",
  270. .id = 0,
  271. .num_resources = ARRAY_SIZE(bfin_sport0_uart_resources),
  272. .resource = bfin_sport0_uart_resources,
  273. .dev = {
  274. .platform_data = &bfin_sport0_peripherals, /* Passed to driver */
  275. },
  276. };
  277. #endif
  278. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  279. static struct resource bfin_sport1_uart_resources[] = {
  280. {
  281. .start = SPORT1_TCR1,
  282. .end = SPORT1_MRCS3+4,
  283. .flags = IORESOURCE_MEM,
  284. },
  285. {
  286. .start = IRQ_SPORT1_RX,
  287. .end = IRQ_SPORT1_RX+1,
  288. .flags = IORESOURCE_IRQ,
  289. },
  290. {
  291. .start = IRQ_SPORT1_ERROR,
  292. .end = IRQ_SPORT1_ERROR,
  293. .flags = IORESOURCE_IRQ,
  294. },
  295. };
  296. static unsigned short bfin_sport1_peripherals[] = {
  297. P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
  298. P_SPORT1_DRPRI, P_SPORT1_RSCLK, 0
  299. };
  300. static struct platform_device bfin_sport1_uart_device = {
  301. .name = "bfin-sport-uart",
  302. .id = 1,
  303. .num_resources = ARRAY_SIZE(bfin_sport1_uart_resources),
  304. .resource = bfin_sport1_uart_resources,
  305. .dev = {
  306. .platform_data = &bfin_sport1_peripherals, /* Passed to driver */
  307. },
  308. };
  309. #endif
  310. #endif
  311. #if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
  312. #include <linux/input.h>
  313. #include <linux/gpio_keys.h>
  314. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  315. {BTN_0, GPIO_PF4, 0, "gpio-keys: BTN0"},
  316. {BTN_1, GPIO_PF5, 0, "gpio-keys: BTN1"},
  317. {BTN_2, GPIO_PF6, 0, "gpio-keys: BTN2"},
  318. }; /* Mapped to the first three PF Test Points */
  319. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  320. .buttons = bfin_gpio_keys_table,
  321. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  322. };
  323. static struct platform_device bfin_device_gpiokeys = {
  324. .name = "gpio-keys",
  325. .dev = {
  326. .platform_data = &bfin_gpio_keys_data,
  327. },
  328. };
  329. #endif
  330. #if IS_ENABLED(CONFIG_I2C_GPIO)
  331. #include <linux/i2c-gpio.h>
  332. static struct i2c_gpio_platform_data i2c_gpio_data = {
  333. .sda_pin = GPIO_PF8,
  334. .scl_pin = GPIO_PF9,
  335. .sda_is_open_drain = 0,
  336. .scl_is_open_drain = 0,
  337. .udelay = 40,
  338. }; /* This hasn't actually been used these pins
  339. * are (currently) free pins on the expansion connector */
  340. static struct platform_device i2c_gpio_device = {
  341. .name = "i2c-gpio",
  342. .id = 0,
  343. .dev = {
  344. .platform_data = &i2c_gpio_data,
  345. },
  346. };
  347. #endif
  348. static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
  349. };
  350. static const unsigned int cclk_vlev_datasheet[] =
  351. {
  352. VRPAIR(VLEV_085, 250000000),
  353. VRPAIR(VLEV_090, 376000000),
  354. VRPAIR(VLEV_095, 426000000),
  355. VRPAIR(VLEV_100, 426000000),
  356. VRPAIR(VLEV_105, 476000000),
  357. VRPAIR(VLEV_110, 476000000),
  358. VRPAIR(VLEV_115, 476000000),
  359. VRPAIR(VLEV_120, 600000000),
  360. VRPAIR(VLEV_125, 600000000),
  361. VRPAIR(VLEV_130, 600000000),
  362. };
  363. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  364. .tuple_tab = cclk_vlev_datasheet,
  365. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  366. .vr_settling_time = 25 /* us */,
  367. };
  368. static struct platform_device bfin_dpmc = {
  369. .name = "bfin dpmc",
  370. .dev = {
  371. .platform_data = &bfin_dmpc_vreg_data,
  372. },
  373. };
  374. static struct platform_device *stamp_devices[] __initdata = {
  375. &bfin_dpmc,
  376. #if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
  377. &rtc_device,
  378. #endif
  379. #if IS_ENABLED(CONFIG_SMC91X)
  380. &smc91x_device,
  381. #endif
  382. #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
  383. &bfin_spi0_device,
  384. #endif
  385. #if IS_ENABLED(CONFIG_SERIAL_BFIN)
  386. #ifdef CONFIG_SERIAL_BFIN_UART0
  387. &bfin_uart0_device,
  388. #endif
  389. #endif
  390. #if IS_ENABLED(CONFIG_BFIN_SIR)
  391. #ifdef CONFIG_BFIN_SIR0
  392. &bfin_sir0_device,
  393. #endif
  394. #endif
  395. #if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
  396. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  397. &bfin_sport0_uart_device,
  398. #endif
  399. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  400. &bfin_sport1_uart_device,
  401. #endif
  402. #endif
  403. #if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
  404. &bfin_device_gpiokeys,
  405. #endif
  406. #if IS_ENABLED(CONFIG_I2C_GPIO)
  407. &i2c_gpio_device,
  408. #endif
  409. };
  410. static int __init blackstamp_init(void)
  411. {
  412. int ret;
  413. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  414. i2c_register_board_info(0, bfin_i2c_board_info,
  415. ARRAY_SIZE(bfin_i2c_board_info));
  416. ret = platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
  417. if (ret < 0)
  418. return ret;
  419. #if IS_ENABLED(CONFIG_SMC91X)
  420. /*
  421. * setup BF533_STAMP CPLD to route AMS3 to Ethernet MAC.
  422. * the bfin-async-map driver takes care of flipping between
  423. * flash and ethernet when necessary.
  424. */
  425. ret = gpio_request(GPIO_PF0, "enet_cpld");
  426. if (!ret) {
  427. gpio_direction_output(GPIO_PF0, 1);
  428. gpio_free(GPIO_PF0);
  429. }
  430. #endif
  431. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  432. return 0;
  433. }
  434. arch_initcall(blackstamp_init);
  435. static struct platform_device *stamp_early_devices[] __initdata = {
  436. #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
  437. #ifdef CONFIG_SERIAL_BFIN_UART0
  438. &bfin_uart0_device,
  439. #endif
  440. #endif
  441. #if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
  442. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  443. &bfin_sport0_uart_device,
  444. #endif
  445. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  446. &bfin_sport1_uart_device,
  447. #endif
  448. #endif
  449. };
  450. void __init native_machine_early_platform_add_devices(void)
  451. {
  452. printk(KERN_INFO "register early platform devices\n");
  453. early_platform_add_devices(stamp_early_devices,
  454. ARRAY_SIZE(stamp_early_devices));
  455. }