ezkit.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. /*
  2. * Copyright 2004-2009 Analog Devices Inc.
  3. * 2005 National ICT Australia (NICTA)
  4. * Aidan Williams <aidan@nicta.com.au>
  5. *
  6. * Licensed under the GPL-2 or later.
  7. */
  8. #include <linux/device.h>
  9. #include <linux/platform_device.h>
  10. #include <linux/mtd/mtd.h>
  11. #include <linux/mtd/partitions.h>
  12. #include <linux/mtd/physmap.h>
  13. #include <linux/spi/spi.h>
  14. #include <linux/irq.h>
  15. #include <linux/interrupt.h>
  16. #include <asm/dma.h>
  17. #include <asm/bfin5xx_spi.h>
  18. #include <asm/portmux.h>
  19. #include <asm/dpmc.h>
  20. /*
  21. * Name the Board for the /proc/cpuinfo
  22. */
  23. const char bfin_board_name[] = "ADI BF561-EZKIT";
  24. #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
  25. #include <linux/usb/isp1760.h>
  26. static struct resource bfin_isp1760_resources[] = {
  27. [0] = {
  28. .start = 0x2C0F0000,
  29. .end = 0x203C0000 + 0xfffff,
  30. .flags = IORESOURCE_MEM,
  31. },
  32. [1] = {
  33. .start = IRQ_PF10,
  34. .end = IRQ_PF10,
  35. .flags = IORESOURCE_IRQ,
  36. },
  37. };
  38. static struct isp1760_platform_data isp1760_priv = {
  39. .is_isp1761 = 0,
  40. .bus_width_16 = 1,
  41. .port1_otg = 0,
  42. .analog_oc = 0,
  43. .dack_polarity_high = 0,
  44. .dreq_polarity_high = 0,
  45. };
  46. static struct platform_device bfin_isp1760_device = {
  47. .name = "isp1760",
  48. .id = 0,
  49. .dev = {
  50. .platform_data = &isp1760_priv,
  51. },
  52. .num_resources = ARRAY_SIZE(bfin_isp1760_resources),
  53. .resource = bfin_isp1760_resources,
  54. };
  55. #endif
  56. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  57. #include <linux/usb/isp1362.h>
  58. static struct resource isp1362_hcd_resources[] = {
  59. {
  60. .start = 0x2c060000,
  61. .end = 0x2c060000,
  62. .flags = IORESOURCE_MEM,
  63. }, {
  64. .start = 0x2c060004,
  65. .end = 0x2c060004,
  66. .flags = IORESOURCE_MEM,
  67. }, {
  68. .start = IRQ_PF8,
  69. .end = IRQ_PF8,
  70. .flags = IORESOURCE_IRQ,
  71. },
  72. };
  73. static struct isp1362_platform_data isp1362_priv = {
  74. .sel15Kres = 1,
  75. .clknotstop = 0,
  76. .oc_enable = 0,
  77. .int_act_high = 0,
  78. .int_edge_triggered = 0,
  79. .remote_wakeup_connected = 0,
  80. .no_power_switching = 1,
  81. .power_switching_mode = 0,
  82. };
  83. static struct platform_device isp1362_hcd_device = {
  84. .name = "isp1362-hcd",
  85. .id = 0,
  86. .dev = {
  87. .platform_data = &isp1362_priv,
  88. },
  89. .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
  90. .resource = isp1362_hcd_resources,
  91. };
  92. #endif
  93. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  94. static struct resource net2272_bfin_resources[] = {
  95. {
  96. .start = 0x2C000000,
  97. .end = 0x2C000000 + 0x7F,
  98. .flags = IORESOURCE_MEM,
  99. }, {
  100. .start = IRQ_PF10,
  101. .end = IRQ_PF10,
  102. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  103. },
  104. };
  105. static struct platform_device net2272_bfin_device = {
  106. .name = "net2272",
  107. .id = -1,
  108. .num_resources = ARRAY_SIZE(net2272_bfin_resources),
  109. .resource = net2272_bfin_resources,
  110. };
  111. #endif
  112. /*
  113. * USB-LAN EzExtender board
  114. * Driver needs to know address, irq and flag pin.
  115. */
  116. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  117. #include <linux/smc91x.h>
  118. static struct smc91x_platdata smc91x_info = {
  119. .flags = SMC91X_USE_32BIT | SMC91X_NOWAIT,
  120. .leda = RPC_LED_100_10,
  121. .ledb = RPC_LED_TX_RX,
  122. };
  123. static struct resource smc91x_resources[] = {
  124. {
  125. .name = "smc91x-regs",
  126. .start = 0x2C010300,
  127. .end = 0x2C010300 + 16,
  128. .flags = IORESOURCE_MEM,
  129. }, {
  130. .start = IRQ_PF9,
  131. .end = IRQ_PF9,
  132. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  133. },
  134. };
  135. static struct platform_device smc91x_device = {
  136. .name = "smc91x",
  137. .id = 0,
  138. .num_resources = ARRAY_SIZE(smc91x_resources),
  139. .resource = smc91x_resources,
  140. .dev = {
  141. .platform_data = &smc91x_info,
  142. },
  143. };
  144. #endif
  145. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  146. static struct resource bfin_uart_resources[] = {
  147. {
  148. .start = 0xFFC00400,
  149. .end = 0xFFC004FF,
  150. .flags = IORESOURCE_MEM,
  151. },
  152. };
  153. static struct platform_device bfin_uart_device = {
  154. .name = "bfin-uart",
  155. .id = 1,
  156. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  157. .resource = bfin_uart_resources,
  158. };
  159. #endif
  160. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  161. #ifdef CONFIG_BFIN_SIR0
  162. static struct resource bfin_sir0_resources[] = {
  163. {
  164. .start = 0xFFC00400,
  165. .end = 0xFFC004FF,
  166. .flags = IORESOURCE_MEM,
  167. },
  168. {
  169. .start = IRQ_UART0_RX,
  170. .end = IRQ_UART0_RX+1,
  171. .flags = IORESOURCE_IRQ,
  172. },
  173. {
  174. .start = CH_UART0_RX,
  175. .end = CH_UART0_RX+1,
  176. .flags = IORESOURCE_DMA,
  177. },
  178. };
  179. static struct platform_device bfin_sir0_device = {
  180. .name = "bfin_sir",
  181. .id = 0,
  182. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  183. .resource = bfin_sir0_resources,
  184. };
  185. #endif
  186. #endif
  187. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  188. static struct mtd_partition ezkit_partitions[] = {
  189. {
  190. .name = "bootloader(nor)",
  191. .size = 0x40000,
  192. .offset = 0,
  193. }, {
  194. .name = "linux kernel(nor)",
  195. .size = 0x1C0000,
  196. .offset = MTDPART_OFS_APPEND,
  197. }, {
  198. .name = "file system(nor)",
  199. .size = MTDPART_SIZ_FULL,
  200. .offset = MTDPART_OFS_APPEND,
  201. }
  202. };
  203. static struct physmap_flash_data ezkit_flash_data = {
  204. .width = 2,
  205. .parts = ezkit_partitions,
  206. .nr_parts = ARRAY_SIZE(ezkit_partitions),
  207. };
  208. static struct resource ezkit_flash_resource = {
  209. .start = 0x20000000,
  210. .end = 0x207fffff,
  211. .flags = IORESOURCE_MEM,
  212. };
  213. static struct platform_device ezkit_flash_device = {
  214. .name = "physmap-flash",
  215. .id = 0,
  216. .dev = {
  217. .platform_data = &ezkit_flash_data,
  218. },
  219. .num_resources = 1,
  220. .resource = &ezkit_flash_resource,
  221. };
  222. #endif
  223. #if defined(CONFIG_SND_BLACKFIN_AD1836) \
  224. || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  225. static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
  226. .enable_dma = 0,
  227. .bits_per_word = 16,
  228. };
  229. #endif
  230. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  231. static struct bfin5xx_spi_chip spidev_chip_info = {
  232. .enable_dma = 0,
  233. .bits_per_word = 8,
  234. };
  235. #endif
  236. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  237. /* SPI (0) */
  238. static struct resource bfin_spi0_resource[] = {
  239. [0] = {
  240. .start = SPI0_REGBASE,
  241. .end = SPI0_REGBASE + 0xFF,
  242. .flags = IORESOURCE_MEM,
  243. },
  244. [1] = {
  245. .start = CH_SPI,
  246. .end = CH_SPI,
  247. .flags = IORESOURCE_DMA,
  248. },
  249. [2] = {
  250. .start = IRQ_SPI,
  251. .end = IRQ_SPI,
  252. .flags = IORESOURCE_IRQ,
  253. }
  254. };
  255. /* SPI controller data */
  256. static struct bfin5xx_spi_master bfin_spi0_info = {
  257. .num_chipselect = 8,
  258. .enable_dma = 1, /* master has the ability to do dma transfer */
  259. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  260. };
  261. static struct platform_device bfin_spi0_device = {
  262. .name = "bfin-spi",
  263. .id = 0, /* Bus number */
  264. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  265. .resource = bfin_spi0_resource,
  266. .dev = {
  267. .platform_data = &bfin_spi0_info, /* Passed to driver */
  268. },
  269. };
  270. #endif
  271. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  272. #if defined(CONFIG_SND_BLACKFIN_AD1836) \
  273. || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  274. {
  275. .modalias = "ad1836",
  276. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  277. .bus_num = 0,
  278. .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
  279. .controller_data = &ad1836_spi_chip_info,
  280. },
  281. #endif
  282. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  283. {
  284. .modalias = "spidev",
  285. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  286. .bus_num = 0,
  287. .chip_select = 1,
  288. .controller_data = &spidev_chip_info,
  289. },
  290. #endif
  291. };
  292. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  293. #include <linux/input.h>
  294. #include <linux/gpio_keys.h>
  295. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  296. {BTN_0, GPIO_PF5, 1, "gpio-keys: BTN0"},
  297. {BTN_1, GPIO_PF6, 1, "gpio-keys: BTN1"},
  298. {BTN_2, GPIO_PF7, 1, "gpio-keys: BTN2"},
  299. {BTN_3, GPIO_PF8, 1, "gpio-keys: BTN3"},
  300. };
  301. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  302. .buttons = bfin_gpio_keys_table,
  303. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  304. };
  305. static struct platform_device bfin_device_gpiokeys = {
  306. .name = "gpio-keys",
  307. .dev = {
  308. .platform_data = &bfin_gpio_keys_data,
  309. },
  310. };
  311. #endif
  312. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  313. #include <linux/i2c-gpio.h>
  314. static struct i2c_gpio_platform_data i2c_gpio_data = {
  315. .sda_pin = 1,
  316. .scl_pin = 0,
  317. .sda_is_open_drain = 0,
  318. .scl_is_open_drain = 0,
  319. .udelay = 40,
  320. };
  321. static struct platform_device i2c_gpio_device = {
  322. .name = "i2c-gpio",
  323. .id = 0,
  324. .dev = {
  325. .platform_data = &i2c_gpio_data,
  326. },
  327. };
  328. #endif
  329. static const unsigned int cclk_vlev_datasheet[] =
  330. {
  331. VRPAIR(VLEV_085, 250000000),
  332. VRPAIR(VLEV_090, 300000000),
  333. VRPAIR(VLEV_095, 313000000),
  334. VRPAIR(VLEV_100, 350000000),
  335. VRPAIR(VLEV_105, 400000000),
  336. VRPAIR(VLEV_110, 444000000),
  337. VRPAIR(VLEV_115, 450000000),
  338. VRPAIR(VLEV_120, 475000000),
  339. VRPAIR(VLEV_125, 500000000),
  340. VRPAIR(VLEV_130, 600000000),
  341. };
  342. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  343. .tuple_tab = cclk_vlev_datasheet,
  344. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  345. .vr_settling_time = 25 /* us */,
  346. };
  347. static struct platform_device bfin_dpmc = {
  348. .name = "bfin dpmc",
  349. .dev = {
  350. .platform_data = &bfin_dmpc_vreg_data,
  351. },
  352. };
  353. static struct platform_device *ezkit_devices[] __initdata = {
  354. &bfin_dpmc,
  355. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  356. &smc91x_device,
  357. #endif
  358. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  359. &net2272_bfin_device,
  360. #endif
  361. #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
  362. &bfin_isp1760_device,
  363. #endif
  364. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  365. &bfin_spi0_device,
  366. #endif
  367. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  368. &bfin_uart_device,
  369. #endif
  370. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  371. #ifdef CONFIG_BFIN_SIR0
  372. &bfin_sir0_device,
  373. #endif
  374. #endif
  375. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  376. &bfin_device_gpiokeys,
  377. #endif
  378. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  379. &i2c_gpio_device,
  380. #endif
  381. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  382. &isp1362_hcd_device,
  383. #endif
  384. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  385. &ezkit_flash_device,
  386. #endif
  387. };
  388. static int __init ezkit_init(void)
  389. {
  390. int ret;
  391. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  392. ret = platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
  393. if (ret < 0)
  394. return ret;
  395. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  396. bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 12));
  397. SSYNC();
  398. #endif
  399. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  400. return 0;
  401. }
  402. arch_initcall(ezkit_init);