ezkit.c 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  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/pata_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. /*
  84. * USB-LAN EzExtender board
  85. * Driver needs to know address, irq and flag pin.
  86. */
  87. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  88. static struct resource smc91x_resources[] = {
  89. {
  90. .name = "smc91x-regs",
  91. .start = 0x2C010300,
  92. .end = 0x2C010300 + 16,
  93. .flags = IORESOURCE_MEM,
  94. }, {
  95. .start = IRQ_PF9,
  96. .end = IRQ_PF9,
  97. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  98. },
  99. };
  100. static struct platform_device smc91x_device = {
  101. .name = "smc91x",
  102. .id = 0,
  103. .num_resources = ARRAY_SIZE(smc91x_resources),
  104. .resource = smc91x_resources,
  105. };
  106. #endif
  107. #if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
  108. static struct resource ax88180_resources[] = {
  109. [0] = {
  110. .start = 0x2c000000,
  111. .end = 0x2c000000 + 0x8000,
  112. .flags = IORESOURCE_MEM,
  113. },
  114. [1] = {
  115. .start = IRQ_PF10,
  116. .end = IRQ_PF10,
  117. .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL),
  118. },
  119. };
  120. static struct platform_device ax88180_device = {
  121. .name = "ax88180",
  122. .id = -1,
  123. .num_resources = ARRAY_SIZE(ax88180_resources),
  124. .resource = ax88180_resources,
  125. };
  126. #endif
  127. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  128. static struct resource bfin_uart_resources[] = {
  129. {
  130. .start = 0xFFC00400,
  131. .end = 0xFFC004FF,
  132. .flags = IORESOURCE_MEM,
  133. },
  134. };
  135. static struct platform_device bfin_uart_device = {
  136. .name = "bfin-uart",
  137. .id = 1,
  138. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  139. .resource = bfin_uart_resources,
  140. };
  141. #endif
  142. static struct mtd_partition ezkit_partitions[] = {
  143. {
  144. .name = "Bootloader",
  145. .size = 0x20000,
  146. .offset = 0,
  147. }, {
  148. .name = "Kernel",
  149. .size = 0xE0000,
  150. .offset = MTDPART_OFS_APPEND,
  151. }, {
  152. .name = "RootFS",
  153. .size = MTDPART_SIZ_FULL,
  154. .offset = MTDPART_OFS_APPEND,
  155. }
  156. };
  157. static struct physmap_flash_data ezkit_flash_data = {
  158. .width = 2,
  159. .parts = ezkit_partitions,
  160. .nr_parts = ARRAY_SIZE(ezkit_partitions),
  161. };
  162. static struct resource ezkit_flash_resource = {
  163. .start = 0x20000000,
  164. .end = 0x207fffff,
  165. .flags = IORESOURCE_MEM,
  166. };
  167. static struct platform_device ezkit_flash_device = {
  168. .name = "physmap-flash",
  169. .id = 0,
  170. .dev = {
  171. .platform_data = &ezkit_flash_data,
  172. },
  173. .num_resources = 1,
  174. .resource = &ezkit_flash_resource,
  175. };
  176. #ifdef CONFIG_SPI_BFIN
  177. #if defined(CONFIG_SND_BLACKFIN_AD1836) \
  178. || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  179. static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
  180. .enable_dma = 0,
  181. .bits_per_word = 16,
  182. };
  183. #endif
  184. #endif
  185. /* SPI (0) */
  186. static struct resource bfin_spi0_resource[] = {
  187. [0] = {
  188. .start = SPI0_REGBASE,
  189. .end = SPI0_REGBASE + 0xFF,
  190. .flags = IORESOURCE_MEM,
  191. },
  192. [1] = {
  193. .start = CH_SPI,
  194. .end = CH_SPI,
  195. .flags = IORESOURCE_IRQ,
  196. }
  197. };
  198. /* SPI controller data */
  199. static struct bfin5xx_spi_master bfin_spi0_info = {
  200. .num_chipselect = 8,
  201. .enable_dma = 1, /* master has the ability to do dma transfer */
  202. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  203. };
  204. static struct platform_device bfin_spi0_device = {
  205. .name = "bfin-spi",
  206. .id = 0, /* Bus number */
  207. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  208. .resource = bfin_spi0_resource,
  209. .dev = {
  210. .platform_data = &bfin_spi0_info, /* Passed to driver */
  211. },
  212. };
  213. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  214. #if defined(CONFIG_SND_BLACKFIN_AD1836) \
  215. || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  216. {
  217. .modalias = "ad1836-spi",
  218. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  219. .bus_num = 0,
  220. .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
  221. .controller_data = &ad1836_spi_chip_info,
  222. },
  223. #endif
  224. };
  225. #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
  226. #define PATA_INT 55
  227. static struct pata_platform_info bfin_pata_platform_data = {
  228. .ioport_shift = 1,
  229. .irq_type = IRQF_TRIGGER_HIGH | IRQF_DISABLED,
  230. };
  231. static struct resource bfin_pata_resources[] = {
  232. {
  233. .start = 0x20314020,
  234. .end = 0x2031403F,
  235. .flags = IORESOURCE_MEM,
  236. },
  237. {
  238. .start = 0x2031401C,
  239. .end = 0x2031401F,
  240. .flags = IORESOURCE_MEM,
  241. },
  242. {
  243. .start = PATA_INT,
  244. .end = PATA_INT,
  245. .flags = IORESOURCE_IRQ,
  246. },
  247. };
  248. static struct platform_device bfin_pata_device = {
  249. .name = "pata_platform",
  250. .id = -1,
  251. .num_resources = ARRAY_SIZE(bfin_pata_resources),
  252. .resource = bfin_pata_resources,
  253. .dev = {
  254. .platform_data = &bfin_pata_platform_data,
  255. }
  256. };
  257. #endif
  258. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  259. #include <linux/input.h>
  260. #include <linux/gpio_keys.h>
  261. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  262. {BTN_0, GPIO_PF5, 1, "gpio-keys: BTN0"},
  263. {BTN_1, GPIO_PF6, 1, "gpio-keys: BTN1"},
  264. {BTN_2, GPIO_PF7, 1, "gpio-keys: BTN2"},
  265. {BTN_3, GPIO_PF8, 1, "gpio-keys: BTN3"},
  266. };
  267. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  268. .buttons = bfin_gpio_keys_table,
  269. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  270. };
  271. static struct platform_device bfin_device_gpiokeys = {
  272. .name = "gpio-keys",
  273. .dev = {
  274. .platform_data = &bfin_gpio_keys_data,
  275. },
  276. };
  277. #endif
  278. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  279. #include <linux/i2c-gpio.h>
  280. static struct i2c_gpio_platform_data i2c_gpio_data = {
  281. .sda_pin = 1,
  282. .scl_pin = 0,
  283. .sda_is_open_drain = 0,
  284. .scl_is_open_drain = 0,
  285. .udelay = 40,
  286. };
  287. static struct platform_device i2c_gpio_device = {
  288. .name = "i2c-gpio",
  289. .id = 0,
  290. .dev = {
  291. .platform_data = &i2c_gpio_data,
  292. },
  293. };
  294. #endif
  295. static struct platform_device *ezkit_devices[] __initdata = {
  296. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  297. &smc91x_device,
  298. #endif
  299. #if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
  300. &ax88180_device,
  301. #endif
  302. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  303. &bfin_spi0_device,
  304. #endif
  305. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  306. &bfin_uart_device,
  307. #endif
  308. #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
  309. &bfin_pata_device,
  310. #endif
  311. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  312. &bfin_device_gpiokeys,
  313. #endif
  314. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  315. &i2c_gpio_device,
  316. #endif
  317. &ezkit_flash_device,
  318. };
  319. static int __init ezkit_init(void)
  320. {
  321. int ret;
  322. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  323. ret = platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
  324. if (ret < 0)
  325. return ret;
  326. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  327. bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 12));
  328. SSYNC();
  329. #endif
  330. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  331. spi_register_board_info(bfin_spi_board_info,
  332. ARRAY_SIZE(bfin_spi_board_info));
  333. #endif
  334. #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
  335. irq_desc[PATA_INT].status |= IRQ_NOAUTOEN;
  336. #endif
  337. return 0;
  338. }
  339. arch_initcall(ezkit_init);