ezkit.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  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[] = "ADDS-BF561-EZKIT";
  45. #define ISP1761_BASE 0x2C0F0000
  46. #define ISP1761_IRQ IRQ_PF10
  47. #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
  48. static struct resource bfin_isp1761_resources[] = {
  49. {
  50. .name = "isp1761-regs",
  51. .start = ISP1761_BASE + 0x00000000,
  52. .end = ISP1761_BASE + 0x000fffff,
  53. .flags = IORESOURCE_MEM,
  54. },
  55. {
  56. .start = ISP1761_IRQ,
  57. .end = ISP1761_IRQ,
  58. .flags = IORESOURCE_IRQ,
  59. },
  60. };
  61. static struct platform_device bfin_isp1761_device = {
  62. .name = "isp1761",
  63. .id = 0,
  64. .num_resources = ARRAY_SIZE(bfin_isp1761_resources),
  65. .resource = bfin_isp1761_resources,
  66. };
  67. static struct platform_device *bfin_isp1761_devices[] = {
  68. &bfin_isp1761_device,
  69. };
  70. int __init bfin_isp1761_init(void)
  71. {
  72. unsigned int num_devices = ARRAY_SIZE(bfin_isp1761_devices);
  73. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  74. set_irq_type(ISP1761_IRQ, IRQF_TRIGGER_FALLING);
  75. return platform_add_devices(bfin_isp1761_devices, num_devices);
  76. }
  77. void __exit bfin_isp1761_exit(void)
  78. {
  79. platform_device_unregister(&bfin_isp1761_device);
  80. }
  81. arch_initcall(bfin_isp1761_init);
  82. #endif
  83. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  84. #include <linux/usb/isp1362.h>
  85. static struct resource isp1362_hcd_resources[] = {
  86. {
  87. .start = 0x2c060000,
  88. .end = 0x2c060000,
  89. .flags = IORESOURCE_MEM,
  90. }, {
  91. .start = 0x2c060004,
  92. .end = 0x2c060004,
  93. .flags = IORESOURCE_MEM,
  94. }, {
  95. .start = IRQ_PF8,
  96. .end = IRQ_PF8,
  97. .flags = IORESOURCE_IRQ,
  98. },
  99. };
  100. static struct isp1362_platform_data isp1362_priv = {
  101. .sel15Kres = 1,
  102. .clknotstop = 0,
  103. .oc_enable = 0,
  104. .int_act_high = 0,
  105. .int_edge_triggered = 0,
  106. .remote_wakeup_connected = 0,
  107. .no_power_switching = 1,
  108. .power_switching_mode = 0,
  109. };
  110. static struct platform_device isp1362_hcd_device = {
  111. .name = "isp1362-hcd",
  112. .id = 0,
  113. .dev = {
  114. .platform_data = &isp1362_priv,
  115. },
  116. .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
  117. .resource = isp1362_hcd_resources,
  118. };
  119. #endif
  120. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  121. static struct resource net2272_bfin_resources[] = {
  122. {
  123. .start = 0x2C000000,
  124. .end = 0x2C000000 + 0x7F,
  125. .flags = IORESOURCE_MEM,
  126. }, {
  127. .start = IRQ_PF10,
  128. .end = IRQ_PF10,
  129. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  130. },
  131. };
  132. static struct platform_device net2272_bfin_device = {
  133. .name = "net2272",
  134. .id = -1,
  135. .num_resources = ARRAY_SIZE(net2272_bfin_resources),
  136. .resource = net2272_bfin_resources,
  137. };
  138. #endif
  139. /*
  140. * USB-LAN EzExtender board
  141. * Driver needs to know address, irq and flag pin.
  142. */
  143. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  144. static struct resource smc91x_resources[] = {
  145. {
  146. .name = "smc91x-regs",
  147. .start = 0x2C010300,
  148. .end = 0x2C010300 + 16,
  149. .flags = IORESOURCE_MEM,
  150. }, {
  151. .start = IRQ_PF9,
  152. .end = IRQ_PF9,
  153. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  154. },
  155. };
  156. static struct platform_device smc91x_device = {
  157. .name = "smc91x",
  158. .id = 0,
  159. .num_resources = ARRAY_SIZE(smc91x_resources),
  160. .resource = smc91x_resources,
  161. };
  162. #endif
  163. #if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
  164. static struct resource ax88180_resources[] = {
  165. [0] = {
  166. .start = 0x2c000000,
  167. .end = 0x2c000000 + 0x8000,
  168. .flags = IORESOURCE_MEM,
  169. },
  170. [1] = {
  171. .start = IRQ_PF10,
  172. .end = IRQ_PF10,
  173. .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL),
  174. },
  175. };
  176. static struct platform_device ax88180_device = {
  177. .name = "ax88180",
  178. .id = -1,
  179. .num_resources = ARRAY_SIZE(ax88180_resources),
  180. .resource = ax88180_resources,
  181. };
  182. #endif
  183. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  184. static struct resource bfin_uart_resources[] = {
  185. {
  186. .start = 0xFFC00400,
  187. .end = 0xFFC004FF,
  188. .flags = IORESOURCE_MEM,
  189. },
  190. };
  191. static struct platform_device bfin_uart_device = {
  192. .name = "bfin-uart",
  193. .id = 1,
  194. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  195. .resource = bfin_uart_resources,
  196. };
  197. #endif
  198. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  199. static struct resource bfin_sir_resources[] = {
  200. #ifdef CONFIG_BFIN_SIR0
  201. {
  202. .start = 0xFFC00400,
  203. .end = 0xFFC004FF,
  204. .flags = IORESOURCE_MEM,
  205. },
  206. #endif
  207. };
  208. static struct platform_device bfin_sir_device = {
  209. .name = "bfin_sir",
  210. .id = 0,
  211. .num_resources = ARRAY_SIZE(bfin_sir_resources),
  212. .resource = bfin_sir_resources,
  213. };
  214. #endif
  215. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  216. static struct mtd_partition ezkit_partitions[] = {
  217. {
  218. .name = "bootloader(nor)",
  219. .size = 0x40000,
  220. .offset = 0,
  221. }, {
  222. .name = "linux kernel(nor)",
  223. .size = 0x1C0000,
  224. .offset = MTDPART_OFS_APPEND,
  225. }, {
  226. .name = "file system(nor)",
  227. .size = MTDPART_SIZ_FULL,
  228. .offset = MTDPART_OFS_APPEND,
  229. }
  230. };
  231. static struct physmap_flash_data ezkit_flash_data = {
  232. .width = 2,
  233. .parts = ezkit_partitions,
  234. .nr_parts = ARRAY_SIZE(ezkit_partitions),
  235. };
  236. static struct resource ezkit_flash_resource = {
  237. .start = 0x20000000,
  238. .end = 0x207fffff,
  239. .flags = IORESOURCE_MEM,
  240. };
  241. static struct platform_device ezkit_flash_device = {
  242. .name = "physmap-flash",
  243. .id = 0,
  244. .dev = {
  245. .platform_data = &ezkit_flash_data,
  246. },
  247. .num_resources = 1,
  248. .resource = &ezkit_flash_resource,
  249. };
  250. #endif
  251. #if defined(CONFIG_SND_BLACKFIN_AD1836) \
  252. || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  253. static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
  254. .enable_dma = 0,
  255. .bits_per_word = 16,
  256. };
  257. #endif
  258. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  259. static struct bfin5xx_spi_chip spidev_chip_info = {
  260. .enable_dma = 0,
  261. .bits_per_word = 8,
  262. };
  263. #endif
  264. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  265. /* SPI (0) */
  266. static struct resource bfin_spi0_resource[] = {
  267. [0] = {
  268. .start = SPI0_REGBASE,
  269. .end = SPI0_REGBASE + 0xFF,
  270. .flags = IORESOURCE_MEM,
  271. },
  272. [1] = {
  273. .start = CH_SPI,
  274. .end = CH_SPI,
  275. .flags = IORESOURCE_IRQ,
  276. }
  277. };
  278. /* SPI controller data */
  279. static struct bfin5xx_spi_master bfin_spi0_info = {
  280. .num_chipselect = 8,
  281. .enable_dma = 1, /* master has the ability to do dma transfer */
  282. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  283. };
  284. static struct platform_device bfin_spi0_device = {
  285. .name = "bfin-spi",
  286. .id = 0, /* Bus number */
  287. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  288. .resource = bfin_spi0_resource,
  289. .dev = {
  290. .platform_data = &bfin_spi0_info, /* Passed to driver */
  291. },
  292. };
  293. #endif
  294. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  295. #if defined(CONFIG_SND_BLACKFIN_AD1836) \
  296. || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  297. {
  298. .modalias = "ad1836-spi",
  299. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  300. .bus_num = 0,
  301. .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
  302. .controller_data = &ad1836_spi_chip_info,
  303. },
  304. #endif
  305. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  306. {
  307. .modalias = "spidev",
  308. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  309. .bus_num = 0,
  310. .chip_select = 1,
  311. .controller_data = &spidev_chip_info,
  312. },
  313. #endif
  314. };
  315. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  316. #include <linux/input.h>
  317. #include <linux/gpio_keys.h>
  318. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  319. {BTN_0, GPIO_PF5, 1, "gpio-keys: BTN0"},
  320. {BTN_1, GPIO_PF6, 1, "gpio-keys: BTN1"},
  321. {BTN_2, GPIO_PF7, 1, "gpio-keys: BTN2"},
  322. {BTN_3, GPIO_PF8, 1, "gpio-keys: BTN3"},
  323. };
  324. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  325. .buttons = bfin_gpio_keys_table,
  326. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  327. };
  328. static struct platform_device bfin_device_gpiokeys = {
  329. .name = "gpio-keys",
  330. .dev = {
  331. .platform_data = &bfin_gpio_keys_data,
  332. },
  333. };
  334. #endif
  335. static struct resource bfin_gpios_resources = {
  336. .start = 0,
  337. .end = MAX_BLACKFIN_GPIOS - 1,
  338. .flags = IORESOURCE_IRQ,
  339. };
  340. static struct platform_device bfin_gpios_device = {
  341. .name = "simple-gpio",
  342. .id = -1,
  343. .num_resources = 1,
  344. .resource = &bfin_gpios_resources,
  345. };
  346. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  347. #include <linux/i2c-gpio.h>
  348. static struct i2c_gpio_platform_data i2c_gpio_data = {
  349. .sda_pin = 1,
  350. .scl_pin = 0,
  351. .sda_is_open_drain = 0,
  352. .scl_is_open_drain = 0,
  353. .udelay = 40,
  354. };
  355. static struct platform_device i2c_gpio_device = {
  356. .name = "i2c-gpio",
  357. .id = 0,
  358. .dev = {
  359. .platform_data = &i2c_gpio_data,
  360. },
  361. };
  362. #endif
  363. static const unsigned int cclk_vlev_datasheet[] =
  364. {
  365. VRPAIR(VLEV_085, 250000000),
  366. VRPAIR(VLEV_090, 300000000),
  367. VRPAIR(VLEV_095, 313000000),
  368. VRPAIR(VLEV_100, 350000000),
  369. VRPAIR(VLEV_105, 400000000),
  370. VRPAIR(VLEV_110, 444000000),
  371. VRPAIR(VLEV_115, 450000000),
  372. VRPAIR(VLEV_120, 475000000),
  373. VRPAIR(VLEV_125, 500000000),
  374. VRPAIR(VLEV_130, 600000000),
  375. };
  376. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  377. .tuple_tab = cclk_vlev_datasheet,
  378. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  379. .vr_settling_time = 25 /* us */,
  380. };
  381. static struct platform_device bfin_dpmc = {
  382. .name = "bfin dpmc",
  383. .dev = {
  384. .platform_data = &bfin_dmpc_vreg_data,
  385. },
  386. };
  387. static struct platform_device *ezkit_devices[] __initdata = {
  388. &bfin_dpmc,
  389. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  390. &smc91x_device,
  391. #endif
  392. #if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
  393. &ax88180_device,
  394. #endif
  395. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  396. &net2272_bfin_device,
  397. #endif
  398. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  399. &bfin_spi0_device,
  400. #endif
  401. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  402. &bfin_uart_device,
  403. #endif
  404. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  405. &bfin_sir_device,
  406. #endif
  407. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  408. &bfin_device_gpiokeys,
  409. #endif
  410. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  411. &i2c_gpio_device,
  412. #endif
  413. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  414. &isp1362_hcd_device,
  415. #endif
  416. &bfin_gpios_device,
  417. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  418. &ezkit_flash_device,
  419. #endif
  420. };
  421. static int __init ezkit_init(void)
  422. {
  423. int ret;
  424. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  425. ret = platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
  426. if (ret < 0)
  427. return ret;
  428. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  429. bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 12));
  430. SSYNC();
  431. #endif
  432. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  433. return 0;
  434. }
  435. arch_initcall(ezkit_init);