ezkit.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  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-hcd",
  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_AX88180) || defined(CONFIG_AX88180_MODULE)
  146. static struct resource ax88180_resources[] = {
  147. [0] = {
  148. .start = 0x2c000000,
  149. .end = 0x2c000000 + 0x8000,
  150. .flags = IORESOURCE_MEM,
  151. },
  152. [1] = {
  153. .start = IRQ_PF10,
  154. .end = IRQ_PF10,
  155. .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL),
  156. },
  157. };
  158. static struct platform_device ax88180_device = {
  159. .name = "ax88180",
  160. .id = -1,
  161. .num_resources = ARRAY_SIZE(ax88180_resources),
  162. .resource = ax88180_resources,
  163. };
  164. #endif
  165. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  166. static struct resource bfin_uart_resources[] = {
  167. {
  168. .start = 0xFFC00400,
  169. .end = 0xFFC004FF,
  170. .flags = IORESOURCE_MEM,
  171. },
  172. };
  173. static struct platform_device bfin_uart_device = {
  174. .name = "bfin-uart",
  175. .id = 1,
  176. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  177. .resource = bfin_uart_resources,
  178. };
  179. #endif
  180. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  181. #ifdef CONFIG_BFIN_SIR0
  182. static struct resource bfin_sir0_resources[] = {
  183. {
  184. .start = 0xFFC00400,
  185. .end = 0xFFC004FF,
  186. .flags = IORESOURCE_MEM,
  187. },
  188. {
  189. .start = IRQ_UART0_RX,
  190. .end = IRQ_UART0_RX+1,
  191. .flags = IORESOURCE_IRQ,
  192. },
  193. {
  194. .start = CH_UART0_RX,
  195. .end = CH_UART0_RX+1,
  196. .flags = IORESOURCE_DMA,
  197. },
  198. };
  199. static struct platform_device bfin_sir0_device = {
  200. .name = "bfin_sir",
  201. .id = 0,
  202. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  203. .resource = bfin_sir0_resources,
  204. };
  205. #endif
  206. #endif
  207. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  208. static struct mtd_partition ezkit_partitions[] = {
  209. {
  210. .name = "bootloader(nor)",
  211. .size = 0x40000,
  212. .offset = 0,
  213. }, {
  214. .name = "linux kernel(nor)",
  215. .size = 0x1C0000,
  216. .offset = MTDPART_OFS_APPEND,
  217. }, {
  218. .name = "file system(nor)",
  219. .size = MTDPART_SIZ_FULL,
  220. .offset = MTDPART_OFS_APPEND,
  221. }
  222. };
  223. static struct physmap_flash_data ezkit_flash_data = {
  224. .width = 2,
  225. .parts = ezkit_partitions,
  226. .nr_parts = ARRAY_SIZE(ezkit_partitions),
  227. };
  228. static struct resource ezkit_flash_resource = {
  229. .start = 0x20000000,
  230. .end = 0x207fffff,
  231. .flags = IORESOURCE_MEM,
  232. };
  233. static struct platform_device ezkit_flash_device = {
  234. .name = "physmap-flash",
  235. .id = 0,
  236. .dev = {
  237. .platform_data = &ezkit_flash_data,
  238. },
  239. .num_resources = 1,
  240. .resource = &ezkit_flash_resource,
  241. };
  242. #endif
  243. #if defined(CONFIG_SND_BLACKFIN_AD1836) \
  244. || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  245. static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
  246. .enable_dma = 0,
  247. .bits_per_word = 16,
  248. };
  249. #endif
  250. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  251. static struct bfin5xx_spi_chip spidev_chip_info = {
  252. .enable_dma = 0,
  253. .bits_per_word = 8,
  254. };
  255. #endif
  256. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  257. /* SPI (0) */
  258. static struct resource bfin_spi0_resource[] = {
  259. [0] = {
  260. .start = SPI0_REGBASE,
  261. .end = SPI0_REGBASE + 0xFF,
  262. .flags = IORESOURCE_MEM,
  263. },
  264. [1] = {
  265. .start = CH_SPI,
  266. .end = CH_SPI,
  267. .flags = IORESOURCE_DMA,
  268. },
  269. [2] = {
  270. .start = IRQ_SPI,
  271. .end = IRQ_SPI,
  272. .flags = IORESOURCE_IRQ,
  273. }
  274. };
  275. /* SPI controller data */
  276. static struct bfin5xx_spi_master bfin_spi0_info = {
  277. .num_chipselect = 8,
  278. .enable_dma = 1, /* master has the ability to do dma transfer */
  279. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  280. };
  281. static struct platform_device bfin_spi0_device = {
  282. .name = "bfin-spi",
  283. .id = 0, /* Bus number */
  284. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  285. .resource = bfin_spi0_resource,
  286. .dev = {
  287. .platform_data = &bfin_spi0_info, /* Passed to driver */
  288. },
  289. };
  290. #endif
  291. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  292. #if defined(CONFIG_SND_BLACKFIN_AD1836) \
  293. || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  294. {
  295. .modalias = "ad1836",
  296. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  297. .bus_num = 0,
  298. .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
  299. .controller_data = &ad1836_spi_chip_info,
  300. },
  301. #endif
  302. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  303. {
  304. .modalias = "spidev",
  305. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  306. .bus_num = 0,
  307. .chip_select = 1,
  308. .controller_data = &spidev_chip_info,
  309. },
  310. #endif
  311. };
  312. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  313. #include <linux/input.h>
  314. #include <linux/gpio_keys.h>
  315. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  316. {BTN_0, GPIO_PF5, 1, "gpio-keys: BTN0"},
  317. {BTN_1, GPIO_PF6, 1, "gpio-keys: BTN1"},
  318. {BTN_2, GPIO_PF7, 1, "gpio-keys: BTN2"},
  319. {BTN_3, GPIO_PF8, 1, "gpio-keys: BTN3"},
  320. };
  321. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  322. .buttons = bfin_gpio_keys_table,
  323. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  324. };
  325. static struct platform_device bfin_device_gpiokeys = {
  326. .name = "gpio-keys",
  327. .dev = {
  328. .platform_data = &bfin_gpio_keys_data,
  329. },
  330. };
  331. #endif
  332. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  333. #include <linux/i2c-gpio.h>
  334. static struct i2c_gpio_platform_data i2c_gpio_data = {
  335. .sda_pin = 1,
  336. .scl_pin = 0,
  337. .sda_is_open_drain = 0,
  338. .scl_is_open_drain = 0,
  339. .udelay = 40,
  340. };
  341. static struct platform_device i2c_gpio_device = {
  342. .name = "i2c-gpio",
  343. .id = 0,
  344. .dev = {
  345. .platform_data = &i2c_gpio_data,
  346. },
  347. };
  348. #endif
  349. static const unsigned int cclk_vlev_datasheet[] =
  350. {
  351. VRPAIR(VLEV_085, 250000000),
  352. VRPAIR(VLEV_090, 300000000),
  353. VRPAIR(VLEV_095, 313000000),
  354. VRPAIR(VLEV_100, 350000000),
  355. VRPAIR(VLEV_105, 400000000),
  356. VRPAIR(VLEV_110, 444000000),
  357. VRPAIR(VLEV_115, 450000000),
  358. VRPAIR(VLEV_120, 475000000),
  359. VRPAIR(VLEV_125, 500000000),
  360. VRPAIR(VLEV_130, 600000000),
  361. };
  362. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  363. .tuple_tab = cclk_vlev_datasheet,
  364. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  365. .vr_settling_time = 25 /* us */,
  366. };
  367. static struct platform_device bfin_dpmc = {
  368. .name = "bfin dpmc",
  369. .dev = {
  370. .platform_data = &bfin_dmpc_vreg_data,
  371. },
  372. };
  373. static struct platform_device *ezkit_devices[] __initdata = {
  374. &bfin_dpmc,
  375. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  376. &smc91x_device,
  377. #endif
  378. #if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
  379. &ax88180_device,
  380. #endif
  381. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  382. &net2272_bfin_device,
  383. #endif
  384. #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
  385. &bfin_isp1760_device,
  386. #endif
  387. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  388. &bfin_spi0_device,
  389. #endif
  390. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  391. &bfin_uart_device,
  392. #endif
  393. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  394. #ifdef CONFIG_BFIN_SIR0
  395. &bfin_sir0_device,
  396. #endif
  397. #endif
  398. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  399. &bfin_device_gpiokeys,
  400. #endif
  401. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  402. &i2c_gpio_device,
  403. #endif
  404. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  405. &isp1362_hcd_device,
  406. #endif
  407. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  408. &ezkit_flash_device,
  409. #endif
  410. };
  411. static int __init ezkit_init(void)
  412. {
  413. int ret;
  414. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  415. ret = platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
  416. if (ret < 0)
  417. return ret;
  418. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  419. bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 12));
  420. SSYNC();
  421. #endif
  422. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  423. return 0;
  424. }
  425. arch_initcall(ezkit_init);