ezkit.c 11 KB

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