ezkit.c 12 KB

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