ezkit.c 12 KB

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