ezkit.c 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. /*
  2. * File: arch/blackfin/mach-bf533/ezkit.c
  3. * Based on: Original Work
  4. * Author: Aidan Williams <aidan@nicta.com.au>
  5. *
  6. * Created: 2005
  7. * Description:
  8. *
  9. * Modified: Robin Getz <rgetz@blackfin.uclinux.org> - Named the boards
  10. * Copyright 2005 National ICT Australia (NICTA)
  11. * Copyright 2004-2006 Analog Devices Inc.
  12. *
  13. * Bugs: Enter bugs at http://blackfin.uclinux.org/
  14. *
  15. * This program is free software; you can redistribute it and/or modify
  16. * it under the terms of the GNU General Public License as published by
  17. * the Free Software Foundation; either version 2 of the License, or
  18. * (at your option) any later version.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU General Public License
  26. * along with this program; if not, see the file COPYING, or write
  27. * to the Free Software Foundation, Inc.,
  28. * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  29. */
  30. #include <linux/device.h>
  31. #include <linux/platform_device.h>
  32. #include <linux/mtd/mtd.h>
  33. #include <linux/mtd/partitions.h>
  34. #include <linux/spi/spi.h>
  35. #include <linux/spi/flash.h>
  36. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  37. #include <linux/usb/isp1362.h>
  38. #endif
  39. #include <linux/ata_platform.h>
  40. #include <linux/irq.h>
  41. #include <asm/dma.h>
  42. #include <asm/bfin5xx_spi.h>
  43. #include <asm/portmux.h>
  44. /*
  45. * Name the Board for the /proc/cpuinfo
  46. */
  47. const char bfin_board_name[] = "ADDS-BF533-EZKIT";
  48. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  49. static struct platform_device rtc_device = {
  50. .name = "rtc-bfin",
  51. .id = -1,
  52. };
  53. #endif
  54. #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
  55. static struct platform_device bfin_fb_adv7393_device = {
  56. .name = "bfin-adv7393",
  57. };
  58. #endif
  59. /*
  60. * USB-LAN EzExtender board
  61. * Driver needs to know address, irq and flag pin.
  62. */
  63. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  64. static struct resource smc91x_resources[] = {
  65. {
  66. .name = "smc91x-regs",
  67. .start = 0x20310300,
  68. .end = 0x20310300 + 16,
  69. .flags = IORESOURCE_MEM,
  70. }, {
  71. .start = IRQ_PF9,
  72. .end = IRQ_PF9,
  73. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  74. },
  75. };
  76. static struct platform_device smc91x_device = {
  77. .name = "smc91x",
  78. .id = 0,
  79. .num_resources = ARRAY_SIZE(smc91x_resources),
  80. .resource = smc91x_resources,
  81. };
  82. #endif
  83. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  84. /* all SPI peripherals info goes here */
  85. #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
  86. static struct mtd_partition bfin_spi_flash_partitions[] = {
  87. {
  88. .name = "bootloader",
  89. .size = 0x00020000,
  90. .offset = 0,
  91. .mask_flags = MTD_CAP_ROM
  92. }, {
  93. .name = "kernel",
  94. .size = 0xe0000,
  95. .offset = MTDPART_OFS_APPEND,
  96. }, {
  97. .name = "file system",
  98. .size = MTDPART_SIZ_FULL,
  99. .offset = MTDPART_OFS_APPEND,
  100. }
  101. };
  102. static struct flash_platform_data bfin_spi_flash_data = {
  103. .name = "m25p80",
  104. .parts = bfin_spi_flash_partitions,
  105. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  106. .type = "m25p64",
  107. };
  108. /* SPI flash chip (m25p64) */
  109. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  110. .enable_dma = 0, /* use dma transfer with this chip*/
  111. .bits_per_word = 8,
  112. };
  113. #endif
  114. #if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
  115. /* SPI ADC chip */
  116. static struct bfin5xx_spi_chip spi_adc_chip_info = {
  117. .enable_dma = 1, /* use dma transfer with this chip*/
  118. .bits_per_word = 16,
  119. };
  120. #endif
  121. #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  122. static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
  123. .enable_dma = 0,
  124. .bits_per_word = 16,
  125. };
  126. #endif
  127. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  128. static struct bfin5xx_spi_chip spidev_chip_info = {
  129. .enable_dma = 0,
  130. .bits_per_word = 8,
  131. };
  132. #endif
  133. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  134. #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
  135. {
  136. /* the modalias must be the same as spi device driver name */
  137. .modalias = "m25p80", /* Name of spi_driver for this device */
  138. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  139. .bus_num = 0, /* Framework bus number */
  140. .chip_select = 2, /* Framework chip select. On STAMP537 it is SPISSEL2*/
  141. .platform_data = &bfin_spi_flash_data,
  142. .controller_data = &spi_flash_chip_info,
  143. .mode = SPI_MODE_3,
  144. },
  145. #endif
  146. #if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
  147. {
  148. .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
  149. .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
  150. .bus_num = 0, /* Framework bus number */
  151. .chip_select = 1, /* Framework chip select. */
  152. .platform_data = NULL, /* No spi_driver specific config */
  153. .controller_data = &spi_adc_chip_info,
  154. },
  155. #endif
  156. #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  157. {
  158. .modalias = "ad1836-spi",
  159. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  160. .bus_num = 0,
  161. .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
  162. .controller_data = &ad1836_spi_chip_info,
  163. },
  164. #endif
  165. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  166. {
  167. .modalias = "spidev",
  168. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  169. .bus_num = 0,
  170. .chip_select = 1,
  171. .controller_data = &spidev_chip_info,
  172. },
  173. #endif
  174. };
  175. /* SPI (0) */
  176. static struct resource bfin_spi0_resource[] = {
  177. [0] = {
  178. .start = SPI0_REGBASE,
  179. .end = SPI0_REGBASE + 0xFF,
  180. .flags = IORESOURCE_MEM,
  181. },
  182. [1] = {
  183. .start = CH_SPI,
  184. .end = CH_SPI,
  185. .flags = IORESOURCE_IRQ,
  186. }
  187. };
  188. /* SPI controller data */
  189. static struct bfin5xx_spi_master bfin_spi0_info = {
  190. .num_chipselect = 8,
  191. .enable_dma = 1, /* master has the ability to do dma transfer */
  192. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  193. };
  194. static struct platform_device bfin_spi0_device = {
  195. .name = "bfin-spi",
  196. .id = 0, /* Bus number */
  197. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  198. .resource = bfin_spi0_resource,
  199. .dev = {
  200. .platform_data = &bfin_spi0_info, /* Passed to driver */
  201. },
  202. };
  203. #endif /* spi master and devices */
  204. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  205. static struct resource bfin_uart_resources[] = {
  206. {
  207. .start = 0xFFC00400,
  208. .end = 0xFFC004FF,
  209. .flags = IORESOURCE_MEM,
  210. },
  211. };
  212. static struct platform_device bfin_uart_device = {
  213. .name = "bfin-uart",
  214. .id = 1,
  215. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  216. .resource = bfin_uart_resources,
  217. };
  218. #endif
  219. #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
  220. #define PATA_INT 55
  221. static struct pata_platform_info bfin_pata_platform_data = {
  222. .ioport_shift = 1,
  223. .irq_type = IRQF_TRIGGER_HIGH | IRQF_DISABLED,
  224. };
  225. static struct resource bfin_pata_resources[] = {
  226. {
  227. .start = 0x20314020,
  228. .end = 0x2031403F,
  229. .flags = IORESOURCE_MEM,
  230. },
  231. {
  232. .start = 0x2031401C,
  233. .end = 0x2031401F,
  234. .flags = IORESOURCE_MEM,
  235. },
  236. {
  237. .start = PATA_INT,
  238. .end = PATA_INT,
  239. .flags = IORESOURCE_IRQ,
  240. },
  241. };
  242. static struct platform_device bfin_pata_device = {
  243. .name = "pata_platform",
  244. .id = -1,
  245. .num_resources = ARRAY_SIZE(bfin_pata_resources),
  246. .resource = bfin_pata_resources,
  247. .dev = {
  248. .platform_data = &bfin_pata_platform_data,
  249. }
  250. };
  251. #endif
  252. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  253. #include <linux/input.h>
  254. #include <linux/gpio_keys.h>
  255. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  256. {BTN_0, GPIO_PF7, 1, "gpio-keys: BTN0"},
  257. {BTN_1, GPIO_PF8, 1, "gpio-keys: BTN1"},
  258. {BTN_2, GPIO_PF9, 1, "gpio-keys: BTN2"},
  259. {BTN_3, GPIO_PF10, 1, "gpio-keys: BTN3"},
  260. };
  261. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  262. .buttons = bfin_gpio_keys_table,
  263. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  264. };
  265. static struct platform_device bfin_device_gpiokeys = {
  266. .name = "gpio-keys",
  267. .dev = {
  268. .platform_data = &bfin_gpio_keys_data,
  269. },
  270. };
  271. #endif
  272. static struct resource bfin_gpios_resources = {
  273. .start = 0,
  274. .end = MAX_BLACKFIN_GPIOS - 1,
  275. .flags = IORESOURCE_IRQ,
  276. };
  277. static struct platform_device bfin_gpios_device = {
  278. .name = "simple-gpio",
  279. .id = -1,
  280. .num_resources = 1,
  281. .resource = &bfin_gpios_resources,
  282. };
  283. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  284. #include <linux/i2c-gpio.h>
  285. static struct i2c_gpio_platform_data i2c_gpio_data = {
  286. .sda_pin = 1,
  287. .scl_pin = 0,
  288. .sda_is_open_drain = 0,
  289. .scl_is_open_drain = 0,
  290. .udelay = 40,
  291. };
  292. static struct platform_device i2c_gpio_device = {
  293. .name = "i2c-gpio",
  294. .id = 0,
  295. .dev = {
  296. .platform_data = &i2c_gpio_data,
  297. },
  298. };
  299. #endif
  300. static struct platform_device *ezkit_devices[] __initdata = {
  301. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  302. &smc91x_device,
  303. #endif
  304. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  305. &bfin_spi0_device,
  306. #endif
  307. #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
  308. &bfin_fb_adv7393_device,
  309. #endif
  310. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  311. &rtc_device,
  312. #endif
  313. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  314. &bfin_uart_device,
  315. #endif
  316. #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
  317. &bfin_pata_device,
  318. #endif
  319. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  320. &bfin_device_gpiokeys,
  321. #endif
  322. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  323. &i2c_gpio_device,
  324. #endif
  325. &bfin_gpios_device,
  326. };
  327. static int __init ezkit_init(void)
  328. {
  329. printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
  330. platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
  331. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  332. spi_register_board_info(bfin_spi_board_info, 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);