ezkit.c 13 KB

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