ezkit.c 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  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. #include <linux/usb/isp1362.h>
  37. #include <linux/ata_platform.h>
  38. #include <linux/irq.h>
  39. #include <asm/dma.h>
  40. #include <asm/bfin5xx_spi.h>
  41. #include <asm/portmux.h>
  42. /*
  43. * Name the Board for the /proc/cpuinfo
  44. */
  45. const char bfin_board_name[] = "ADDS-BF533-EZKIT";
  46. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  47. static struct platform_device rtc_device = {
  48. .name = "rtc-bfin",
  49. .id = -1,
  50. };
  51. #endif
  52. #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
  53. static struct platform_device bfin_fb_adv7393_device = {
  54. .name = "bfin-adv7393",
  55. };
  56. #endif
  57. /*
  58. * USB-LAN EzExtender board
  59. * Driver needs to know address, irq and flag pin.
  60. */
  61. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  62. static struct resource smc91x_resources[] = {
  63. {
  64. .name = "smc91x-regs",
  65. .start = 0x20310300,
  66. .end = 0x20310300 + 16,
  67. .flags = IORESOURCE_MEM,
  68. }, {
  69. .start = IRQ_PF9,
  70. .end = IRQ_PF9,
  71. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  72. },
  73. };
  74. static struct platform_device smc91x_device = {
  75. .name = "smc91x",
  76. .id = 0,
  77. .num_resources = ARRAY_SIZE(smc91x_resources),
  78. .resource = smc91x_resources,
  79. };
  80. #endif
  81. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  82. /* all SPI peripherals info goes here */
  83. #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
  84. static struct mtd_partition bfin_spi_flash_partitions[] = {
  85. {
  86. .name = "bootloader",
  87. .size = 0x00020000,
  88. .offset = 0,
  89. .mask_flags = MTD_CAP_ROM
  90. }, {
  91. .name = "kernel",
  92. .size = 0xe0000,
  93. .offset = 0x20000
  94. }, {
  95. .name = "file system",
  96. .size = 0x700000,
  97. .offset = 0x00100000,
  98. }
  99. };
  100. static struct flash_platform_data bfin_spi_flash_data = {
  101. .name = "m25p80",
  102. .parts = bfin_spi_flash_partitions,
  103. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  104. .type = "m25p64",
  105. };
  106. /* SPI flash chip (m25p64) */
  107. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  108. .enable_dma = 0, /* use dma transfer with this chip*/
  109. .bits_per_word = 8,
  110. };
  111. #endif
  112. #if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
  113. /* SPI ADC chip */
  114. static struct bfin5xx_spi_chip spi_adc_chip_info = {
  115. .enable_dma = 1, /* use dma transfer with this chip*/
  116. .bits_per_word = 16,
  117. };
  118. #endif
  119. #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  120. static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
  121. .enable_dma = 0,
  122. .bits_per_word = 16,
  123. };
  124. #endif
  125. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  126. static struct bfin5xx_spi_chip spidev_chip_info = {
  127. .enable_dma = 0,
  128. .bits_per_word = 8,
  129. };
  130. #endif
  131. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  132. #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
  133. {
  134. /* the modalias must be the same as spi device driver name */
  135. .modalias = "m25p80", /* Name of spi_driver for this device */
  136. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  137. .bus_num = 0, /* Framework bus number */
  138. .chip_select = 2, /* Framework chip select. On STAMP537 it is SPISSEL2*/
  139. .platform_data = &bfin_spi_flash_data,
  140. .controller_data = &spi_flash_chip_info,
  141. .mode = SPI_MODE_3,
  142. },
  143. #endif
  144. #if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
  145. {
  146. .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
  147. .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
  148. .bus_num = 0, /* Framework bus number */
  149. .chip_select = 1, /* Framework chip select. */
  150. .platform_data = NULL, /* No spi_driver specific config */
  151. .controller_data = &spi_adc_chip_info,
  152. },
  153. #endif
  154. #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  155. {
  156. .modalias = "ad1836-spi",
  157. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  158. .bus_num = 0,
  159. .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
  160. .controller_data = &ad1836_spi_chip_info,
  161. },
  162. #endif
  163. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  164. {
  165. .modalias = "spidev",
  166. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  167. .bus_num = 0,
  168. .chip_select = 1,
  169. .controller_data = &spidev_chip_info,
  170. },
  171. #endif
  172. };
  173. /* SPI (0) */
  174. static struct resource bfin_spi0_resource[] = {
  175. [0] = {
  176. .start = SPI0_REGBASE,
  177. .end = SPI0_REGBASE + 0xFF,
  178. .flags = IORESOURCE_MEM,
  179. },
  180. [1] = {
  181. .start = CH_SPI,
  182. .end = CH_SPI,
  183. .flags = IORESOURCE_IRQ,
  184. }
  185. };
  186. /* SPI controller data */
  187. static struct bfin5xx_spi_master bfin_spi0_info = {
  188. .num_chipselect = 8,
  189. .enable_dma = 1, /* master has the ability to do dma transfer */
  190. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  191. };
  192. static struct platform_device bfin_spi0_device = {
  193. .name = "bfin-spi",
  194. .id = 0, /* Bus number */
  195. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  196. .resource = bfin_spi0_resource,
  197. .dev = {
  198. .platform_data = &bfin_spi0_info, /* Passed to driver */
  199. },
  200. };
  201. #endif /* spi master and devices */
  202. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  203. static struct resource bfin_uart_resources[] = {
  204. {
  205. .start = 0xFFC00400,
  206. .end = 0xFFC004FF,
  207. .flags = IORESOURCE_MEM,
  208. },
  209. };
  210. static struct platform_device bfin_uart_device = {
  211. .name = "bfin-uart",
  212. .id = 1,
  213. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  214. .resource = bfin_uart_resources,
  215. };
  216. #endif
  217. #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
  218. #define PATA_INT 55
  219. static struct pata_platform_info bfin_pata_platform_data = {
  220. .ioport_shift = 1,
  221. .irq_type = IRQF_TRIGGER_HIGH | IRQF_DISABLED,
  222. };
  223. static struct resource bfin_pata_resources[] = {
  224. {
  225. .start = 0x20314020,
  226. .end = 0x2031403F,
  227. .flags = IORESOURCE_MEM,
  228. },
  229. {
  230. .start = 0x2031401C,
  231. .end = 0x2031401F,
  232. .flags = IORESOURCE_MEM,
  233. },
  234. {
  235. .start = PATA_INT,
  236. .end = PATA_INT,
  237. .flags = IORESOURCE_IRQ,
  238. },
  239. };
  240. static struct platform_device bfin_pata_device = {
  241. .name = "pata_platform",
  242. .id = -1,
  243. .num_resources = ARRAY_SIZE(bfin_pata_resources),
  244. .resource = bfin_pata_resources,
  245. .dev = {
  246. .platform_data = &bfin_pata_platform_data,
  247. }
  248. };
  249. #endif
  250. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  251. #include <linux/input.h>
  252. #include <linux/gpio_keys.h>
  253. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  254. {BTN_0, GPIO_PF7, 1, "gpio-keys: BTN0"},
  255. {BTN_1, GPIO_PF8, 1, "gpio-keys: BTN1"},
  256. {BTN_2, GPIO_PF9, 1, "gpio-keys: BTN2"},
  257. {BTN_3, GPIO_PF10, 1, "gpio-keys: BTN3"},
  258. };
  259. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  260. .buttons = bfin_gpio_keys_table,
  261. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  262. };
  263. static struct platform_device bfin_device_gpiokeys = {
  264. .name = "gpio-keys",
  265. .dev = {
  266. .platform_data = &bfin_gpio_keys_data,
  267. },
  268. };
  269. #endif
  270. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  271. #include <linux/i2c-gpio.h>
  272. static struct i2c_gpio_platform_data i2c_gpio_data = {
  273. .sda_pin = 1,
  274. .scl_pin = 0,
  275. .sda_is_open_drain = 0,
  276. .scl_is_open_drain = 0,
  277. .udelay = 40,
  278. };
  279. static struct platform_device i2c_gpio_device = {
  280. .name = "i2c-gpio",
  281. .id = 0,
  282. .dev = {
  283. .platform_data = &i2c_gpio_data,
  284. },
  285. };
  286. #endif
  287. static struct platform_device *ezkit_devices[] __initdata = {
  288. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  289. &smc91x_device,
  290. #endif
  291. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  292. &bfin_spi0_device,
  293. #endif
  294. #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
  295. &bfin_fb_adv7393_device,
  296. #endif
  297. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  298. &rtc_device,
  299. #endif
  300. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  301. &bfin_uart_device,
  302. #endif
  303. #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
  304. &bfin_pata_device,
  305. #endif
  306. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  307. &bfin_device_gpiokeys,
  308. #endif
  309. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  310. &i2c_gpio_device,
  311. #endif
  312. };
  313. static int __init ezkit_init(void)
  314. {
  315. printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
  316. platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
  317. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  318. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  319. #endif
  320. #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
  321. irq_desc[PATA_INT].status |= IRQ_NOAUTOEN;
  322. #endif
  323. return 0;
  324. }
  325. arch_initcall(ezkit_init);