ezkit.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  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_IRQ,
  281. }
  282. };
  283. /* SPI controller data */
  284. static struct bfin5xx_spi_master bfin_spi0_info = {
  285. .num_chipselect = 8,
  286. .enable_dma = 1, /* master has the ability to do dma transfer */
  287. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  288. };
  289. static struct platform_device bfin_spi0_device = {
  290. .name = "bfin-spi",
  291. .id = 0, /* Bus number */
  292. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  293. .resource = bfin_spi0_resource,
  294. .dev = {
  295. .platform_data = &bfin_spi0_info, /* Passed to driver */
  296. },
  297. };
  298. #endif
  299. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  300. #if defined(CONFIG_SND_BLACKFIN_AD1836) \
  301. || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  302. {
  303. .modalias = "ad1836-spi",
  304. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  305. .bus_num = 0,
  306. .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
  307. .controller_data = &ad1836_spi_chip_info,
  308. },
  309. #endif
  310. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  311. {
  312. .modalias = "spidev",
  313. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  314. .bus_num = 0,
  315. .chip_select = 1,
  316. .controller_data = &spidev_chip_info,
  317. },
  318. #endif
  319. };
  320. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  321. #include <linux/input.h>
  322. #include <linux/gpio_keys.h>
  323. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  324. {BTN_0, GPIO_PF5, 1, "gpio-keys: BTN0"},
  325. {BTN_1, GPIO_PF6, 1, "gpio-keys: BTN1"},
  326. {BTN_2, GPIO_PF7, 1, "gpio-keys: BTN2"},
  327. {BTN_3, GPIO_PF8, 1, "gpio-keys: BTN3"},
  328. };
  329. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  330. .buttons = bfin_gpio_keys_table,
  331. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  332. };
  333. static struct platform_device bfin_device_gpiokeys = {
  334. .name = "gpio-keys",
  335. .dev = {
  336. .platform_data = &bfin_gpio_keys_data,
  337. },
  338. };
  339. #endif
  340. static struct resource bfin_gpios_resources = {
  341. .start = 0,
  342. .end = MAX_BLACKFIN_GPIOS - 1,
  343. .flags = IORESOURCE_IRQ,
  344. };
  345. static struct platform_device bfin_gpios_device = {
  346. .name = "simple-gpio",
  347. .id = -1,
  348. .num_resources = 1,
  349. .resource = &bfin_gpios_resources,
  350. };
  351. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  352. #include <linux/i2c-gpio.h>
  353. static struct i2c_gpio_platform_data i2c_gpio_data = {
  354. .sda_pin = 1,
  355. .scl_pin = 0,
  356. .sda_is_open_drain = 0,
  357. .scl_is_open_drain = 0,
  358. .udelay = 40,
  359. };
  360. static struct platform_device i2c_gpio_device = {
  361. .name = "i2c-gpio",
  362. .id = 0,
  363. .dev = {
  364. .platform_data = &i2c_gpio_data,
  365. },
  366. };
  367. #endif
  368. static const unsigned int cclk_vlev_datasheet[] =
  369. {
  370. VRPAIR(VLEV_085, 250000000),
  371. VRPAIR(VLEV_090, 300000000),
  372. VRPAIR(VLEV_095, 313000000),
  373. VRPAIR(VLEV_100, 350000000),
  374. VRPAIR(VLEV_105, 400000000),
  375. VRPAIR(VLEV_110, 444000000),
  376. VRPAIR(VLEV_115, 450000000),
  377. VRPAIR(VLEV_120, 475000000),
  378. VRPAIR(VLEV_125, 500000000),
  379. VRPAIR(VLEV_130, 600000000),
  380. };
  381. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  382. .tuple_tab = cclk_vlev_datasheet,
  383. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  384. .vr_settling_time = 25 /* us */,
  385. };
  386. static struct platform_device bfin_dpmc = {
  387. .name = "bfin dpmc",
  388. .dev = {
  389. .platform_data = &bfin_dmpc_vreg_data,
  390. },
  391. };
  392. static struct platform_device *ezkit_devices[] __initdata = {
  393. &bfin_dpmc,
  394. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  395. &smc91x_device,
  396. #endif
  397. #if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
  398. &ax88180_device,
  399. #endif
  400. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  401. &net2272_bfin_device,
  402. #endif
  403. #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
  404. &bfin_isp1760_device,
  405. #endif
  406. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  407. &bfin_spi0_device,
  408. #endif
  409. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  410. &bfin_uart_device,
  411. #endif
  412. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  413. #ifdef CONFIG_BFIN_SIR0
  414. &bfin_sir0_device,
  415. #endif
  416. #endif
  417. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  418. &bfin_device_gpiokeys,
  419. #endif
  420. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  421. &i2c_gpio_device,
  422. #endif
  423. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  424. &isp1362_hcd_device,
  425. #endif
  426. &bfin_gpios_device,
  427. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  428. &ezkit_flash_device,
  429. #endif
  430. };
  431. static int __init ezkit_init(void)
  432. {
  433. int ret;
  434. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  435. ret = platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
  436. if (ret < 0)
  437. return ret;
  438. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  439. bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 12));
  440. SSYNC();
  441. #endif
  442. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  443. return 0;
  444. }
  445. arch_initcall(ezkit_init);