ezkit.c 12 KB

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