ezkit.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. /*
  2. * File: arch/blackfin/mach-bf561/ezkit.c
  3. * Based on:
  4. * Author:
  5. *
  6. * Created:
  7. * Description:
  8. *
  9. * Modified:
  10. * Copyright 2004-2006 Analog Devices Inc.
  11. *
  12. * Bugs: Enter bugs at http://blackfin.uclinux.org/
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation; either version 2 of the License, or
  17. * (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, see the file COPYING, or write
  26. * to the Free Software Foundation, Inc.,
  27. * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  28. */
  29. #include <linux/device.h>
  30. #include <linux/platform_device.h>
  31. #include <linux/mtd/mtd.h>
  32. #include <linux/mtd/partitions.h>
  33. #include <linux/mtd/physmap.h>
  34. #include <linux/spi/spi.h>
  35. #include <linux/irq.h>
  36. #include <linux/interrupt.h>
  37. #include <asm/dma.h>
  38. #include <asm/bfin5xx_spi.h>
  39. #include <asm/portmux.h>
  40. #include <asm/dpmc.h>
  41. /*
  42. * Name the Board for the /proc/cpuinfo
  43. */
  44. const char bfin_board_name[] = "ADI BF561-EZKIT";
  45. #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
  46. #include <linux/usb/isp1760.h>
  47. static struct resource bfin_isp1760_resources[] = {
  48. [0] = {
  49. .start = 0x2C0F0000,
  50. .end = 0x203C0000 + 0xfffff,
  51. .flags = IORESOURCE_MEM,
  52. },
  53. [1] = {
  54. .start = IRQ_PF10,
  55. .end = IRQ_PF10,
  56. .flags = IORESOURCE_IRQ,
  57. },
  58. };
  59. static struct isp1760_platform_data isp1760_priv = {
  60. .is_isp1761 = 0,
  61. .port1_disable = 0,
  62. .bus_width_16 = 1,
  63. .port1_otg = 0,
  64. .analog_oc = 0,
  65. .dack_polarity_high = 0,
  66. .dreq_polarity_high = 0,
  67. };
  68. static struct platform_device bfin_isp1760_device = {
  69. .name = "isp1760-hcd",
  70. .id = 0,
  71. .dev = {
  72. .platform_data = &isp1760_priv,
  73. },
  74. .num_resources = ARRAY_SIZE(bfin_isp1760_resources),
  75. .resource = bfin_isp1760_resources,
  76. };
  77. #endif
  78. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  79. #include <linux/usb/isp1362.h>
  80. static struct resource isp1362_hcd_resources[] = {
  81. {
  82. .start = 0x2c060000,
  83. .end = 0x2c060000,
  84. .flags = IORESOURCE_MEM,
  85. }, {
  86. .start = 0x2c060004,
  87. .end = 0x2c060004,
  88. .flags = IORESOURCE_MEM,
  89. }, {
  90. .start = IRQ_PF8,
  91. .end = IRQ_PF8,
  92. .flags = IORESOURCE_IRQ,
  93. },
  94. };
  95. static struct isp1362_platform_data isp1362_priv = {
  96. .sel15Kres = 1,
  97. .clknotstop = 0,
  98. .oc_enable = 0,
  99. .int_act_high = 0,
  100. .int_edge_triggered = 0,
  101. .remote_wakeup_connected = 0,
  102. .no_power_switching = 1,
  103. .power_switching_mode = 0,
  104. };
  105. static struct platform_device isp1362_hcd_device = {
  106. .name = "isp1362-hcd",
  107. .id = 0,
  108. .dev = {
  109. .platform_data = &isp1362_priv,
  110. },
  111. .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
  112. .resource = isp1362_hcd_resources,
  113. };
  114. #endif
  115. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  116. static struct resource net2272_bfin_resources[] = {
  117. {
  118. .start = 0x2C000000,
  119. .end = 0x2C000000 + 0x7F,
  120. .flags = IORESOURCE_MEM,
  121. }, {
  122. .start = IRQ_PF10,
  123. .end = IRQ_PF10,
  124. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  125. },
  126. };
  127. static struct platform_device net2272_bfin_device = {
  128. .name = "net2272",
  129. .id = -1,
  130. .num_resources = ARRAY_SIZE(net2272_bfin_resources),
  131. .resource = net2272_bfin_resources,
  132. };
  133. #endif
  134. /*
  135. * USB-LAN EzExtender board
  136. * Driver needs to know address, irq and flag pin.
  137. */
  138. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  139. static struct resource smc91x_resources[] = {
  140. {
  141. .name = "smc91x-regs",
  142. .start = 0x2C010300,
  143. .end = 0x2C010300 + 16,
  144. .flags = IORESOURCE_MEM,
  145. }, {
  146. .start = IRQ_PF9,
  147. .end = IRQ_PF9,
  148. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  149. },
  150. };
  151. static struct platform_device smc91x_device = {
  152. .name = "smc91x",
  153. .id = 0,
  154. .num_resources = ARRAY_SIZE(smc91x_resources),
  155. .resource = smc91x_resources,
  156. };
  157. #endif
  158. #if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
  159. static struct resource ax88180_resources[] = {
  160. [0] = {
  161. .start = 0x2c000000,
  162. .end = 0x2c000000 + 0x8000,
  163. .flags = IORESOURCE_MEM,
  164. },
  165. [1] = {
  166. .start = IRQ_PF10,
  167. .end = IRQ_PF10,
  168. .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL),
  169. },
  170. };
  171. static struct platform_device ax88180_device = {
  172. .name = "ax88180",
  173. .id = -1,
  174. .num_resources = ARRAY_SIZE(ax88180_resources),
  175. .resource = ax88180_resources,
  176. };
  177. #endif
  178. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  179. static struct resource bfin_uart_resources[] = {
  180. {
  181. .start = 0xFFC00400,
  182. .end = 0xFFC004FF,
  183. .flags = IORESOURCE_MEM,
  184. },
  185. };
  186. static struct platform_device bfin_uart_device = {
  187. .name = "bfin-uart",
  188. .id = 1,
  189. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  190. .resource = bfin_uart_resources,
  191. };
  192. #endif
  193. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  194. static struct resource bfin_sir_resources[] = {
  195. #ifdef CONFIG_BFIN_SIR0
  196. {
  197. .start = 0xFFC00400,
  198. .end = 0xFFC004FF,
  199. .flags = IORESOURCE_MEM,
  200. },
  201. #endif
  202. };
  203. static struct platform_device bfin_sir_device = {
  204. .name = "bfin_sir",
  205. .id = 0,
  206. .num_resources = ARRAY_SIZE(bfin_sir_resources),
  207. .resource = bfin_sir_resources,
  208. };
  209. #endif
  210. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  211. static struct mtd_partition ezkit_partitions[] = {
  212. {
  213. .name = "bootloader(nor)",
  214. .size = 0x40000,
  215. .offset = 0,
  216. }, {
  217. .name = "linux kernel(nor)",
  218. .size = 0x1C0000,
  219. .offset = MTDPART_OFS_APPEND,
  220. }, {
  221. .name = "file system(nor)",
  222. .size = MTDPART_SIZ_FULL,
  223. .offset = MTDPART_OFS_APPEND,
  224. }
  225. };
  226. static struct physmap_flash_data ezkit_flash_data = {
  227. .width = 2,
  228. .parts = ezkit_partitions,
  229. .nr_parts = ARRAY_SIZE(ezkit_partitions),
  230. };
  231. static struct resource ezkit_flash_resource = {
  232. .start = 0x20000000,
  233. .end = 0x207fffff,
  234. .flags = IORESOURCE_MEM,
  235. };
  236. static struct platform_device ezkit_flash_device = {
  237. .name = "physmap-flash",
  238. .id = 0,
  239. .dev = {
  240. .platform_data = &ezkit_flash_data,
  241. },
  242. .num_resources = 1,
  243. .resource = &ezkit_flash_resource,
  244. };
  245. #endif
  246. #if defined(CONFIG_SND_BLACKFIN_AD1836) \
  247. || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  248. static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
  249. .enable_dma = 0,
  250. .bits_per_word = 16,
  251. };
  252. #endif
  253. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  254. static struct bfin5xx_spi_chip spidev_chip_info = {
  255. .enable_dma = 0,
  256. .bits_per_word = 8,
  257. };
  258. #endif
  259. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  260. /* SPI (0) */
  261. static struct resource bfin_spi0_resource[] = {
  262. [0] = {
  263. .start = SPI0_REGBASE,
  264. .end = SPI0_REGBASE + 0xFF,
  265. .flags = IORESOURCE_MEM,
  266. },
  267. [1] = {
  268. .start = CH_SPI,
  269. .end = CH_SPI,
  270. .flags = IORESOURCE_IRQ,
  271. }
  272. };
  273. /* SPI controller data */
  274. static struct bfin5xx_spi_master bfin_spi0_info = {
  275. .num_chipselect = 8,
  276. .enable_dma = 1, /* master has the ability to do dma transfer */
  277. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  278. };
  279. static struct platform_device bfin_spi0_device = {
  280. .name = "bfin-spi",
  281. .id = 0, /* Bus number */
  282. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  283. .resource = bfin_spi0_resource,
  284. .dev = {
  285. .platform_data = &bfin_spi0_info, /* Passed to driver */
  286. },
  287. };
  288. #endif
  289. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  290. #if defined(CONFIG_SND_BLACKFIN_AD1836) \
  291. || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  292. {
  293. .modalias = "ad1836-spi",
  294. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  295. .bus_num = 0,
  296. .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
  297. .controller_data = &ad1836_spi_chip_info,
  298. },
  299. #endif
  300. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  301. {
  302. .modalias = "spidev",
  303. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  304. .bus_num = 0,
  305. .chip_select = 1,
  306. .controller_data = &spidev_chip_info,
  307. },
  308. #endif
  309. };
  310. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  311. #include <linux/input.h>
  312. #include <linux/gpio_keys.h>
  313. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  314. {BTN_0, GPIO_PF5, 1, "gpio-keys: BTN0"},
  315. {BTN_1, GPIO_PF6, 1, "gpio-keys: BTN1"},
  316. {BTN_2, GPIO_PF7, 1, "gpio-keys: BTN2"},
  317. {BTN_3, GPIO_PF8, 1, "gpio-keys: BTN3"},
  318. };
  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. static struct resource bfin_gpios_resources = {
  331. .start = 0,
  332. .end = MAX_BLACKFIN_GPIOS - 1,
  333. .flags = IORESOURCE_IRQ,
  334. };
  335. static struct platform_device bfin_gpios_device = {
  336. .name = "simple-gpio",
  337. .id = -1,
  338. .num_resources = 1,
  339. .resource = &bfin_gpios_resources,
  340. };
  341. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  342. #include <linux/i2c-gpio.h>
  343. static struct i2c_gpio_platform_data i2c_gpio_data = {
  344. .sda_pin = 1,
  345. .scl_pin = 0,
  346. .sda_is_open_drain = 0,
  347. .scl_is_open_drain = 0,
  348. .udelay = 40,
  349. };
  350. static struct platform_device i2c_gpio_device = {
  351. .name = "i2c-gpio",
  352. .id = 0,
  353. .dev = {
  354. .platform_data = &i2c_gpio_data,
  355. },
  356. };
  357. #endif
  358. static const unsigned int cclk_vlev_datasheet[] =
  359. {
  360. VRPAIR(VLEV_085, 250000000),
  361. VRPAIR(VLEV_090, 300000000),
  362. VRPAIR(VLEV_095, 313000000),
  363. VRPAIR(VLEV_100, 350000000),
  364. VRPAIR(VLEV_105, 400000000),
  365. VRPAIR(VLEV_110, 444000000),
  366. VRPAIR(VLEV_115, 450000000),
  367. VRPAIR(VLEV_120, 475000000),
  368. VRPAIR(VLEV_125, 500000000),
  369. VRPAIR(VLEV_130, 600000000),
  370. };
  371. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  372. .tuple_tab = cclk_vlev_datasheet,
  373. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  374. .vr_settling_time = 25 /* us */,
  375. };
  376. static struct platform_device bfin_dpmc = {
  377. .name = "bfin dpmc",
  378. .dev = {
  379. .platform_data = &bfin_dmpc_vreg_data,
  380. },
  381. };
  382. static struct platform_device *ezkit_devices[] __initdata = {
  383. &bfin_dpmc,
  384. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  385. &smc91x_device,
  386. #endif
  387. #if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
  388. &ax88180_device,
  389. #endif
  390. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  391. &net2272_bfin_device,
  392. #endif
  393. #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
  394. &bfin_isp1760_device,
  395. #endif
  396. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  397. &bfin_spi0_device,
  398. #endif
  399. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  400. &bfin_uart_device,
  401. #endif
  402. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  403. &bfin_sir_device,
  404. #endif
  405. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  406. &bfin_device_gpiokeys,
  407. #endif
  408. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  409. &i2c_gpio_device,
  410. #endif
  411. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  412. &isp1362_hcd_device,
  413. #endif
  414. &bfin_gpios_device,
  415. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  416. &ezkit_flash_device,
  417. #endif
  418. };
  419. static int __init ezkit_init(void)
  420. {
  421. int ret;
  422. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  423. ret = platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
  424. if (ret < 0)
  425. return ret;
  426. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  427. bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 12));
  428. SSYNC();
  429. #endif
  430. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  431. return 0;
  432. }
  433. arch_initcall(ezkit_init);