ezkit.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  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. #include <asm/dpmc.h>
  45. /*
  46. * Name the Board for the /proc/cpuinfo
  47. */
  48. const char bfin_board_name[] = "ADDS-BF533-EZKIT";
  49. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  50. static struct platform_device rtc_device = {
  51. .name = "rtc-bfin",
  52. .id = -1,
  53. };
  54. #endif
  55. #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
  56. static struct platform_device bfin_fb_adv7393_device = {
  57. .name = "bfin-adv7393",
  58. };
  59. #endif
  60. /*
  61. * USB-LAN EzExtender board
  62. * Driver needs to know address, irq and flag pin.
  63. */
  64. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  65. static struct resource smc91x_resources[] = {
  66. {
  67. .name = "smc91x-regs",
  68. .start = 0x20310300,
  69. .end = 0x20310300 + 16,
  70. .flags = IORESOURCE_MEM,
  71. }, {
  72. .start = IRQ_PF9,
  73. .end = IRQ_PF9,
  74. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  75. },
  76. };
  77. static struct platform_device smc91x_device = {
  78. .name = "smc91x",
  79. .id = 0,
  80. .num_resources = ARRAY_SIZE(smc91x_resources),
  81. .resource = smc91x_resources,
  82. };
  83. #endif
  84. #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
  85. static struct mtd_partition bfin_spi_flash_partitions[] = {
  86. {
  87. .name = "bootloader",
  88. .size = 0x00020000,
  89. .offset = 0,
  90. .mask_flags = MTD_CAP_ROM
  91. }, {
  92. .name = "kernel",
  93. .size = 0xe0000,
  94. .offset = MTDPART_OFS_APPEND,
  95. }, {
  96. .name = "file system",
  97. .size = MTDPART_SIZ_FULL,
  98. .offset = MTDPART_OFS_APPEND,
  99. }
  100. };
  101. static struct flash_platform_data bfin_spi_flash_data = {
  102. .name = "m25p80",
  103. .parts = bfin_spi_flash_partitions,
  104. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  105. .type = "m25p64",
  106. };
  107. /* SPI flash chip (m25p64) */
  108. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  109. .enable_dma = 0, /* use dma transfer with this chip*/
  110. .bits_per_word = 8,
  111. };
  112. #endif
  113. #if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
  114. /* SPI ADC chip */
  115. static struct bfin5xx_spi_chip spi_adc_chip_info = {
  116. .enable_dma = 1, /* use dma transfer with this chip*/
  117. .bits_per_word = 16,
  118. };
  119. #endif
  120. #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  121. static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
  122. .enable_dma = 0,
  123. .bits_per_word = 16,
  124. };
  125. #endif
  126. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  127. static struct bfin5xx_spi_chip spidev_chip_info = {
  128. .enable_dma = 0,
  129. .bits_per_word = 8,
  130. };
  131. #endif
  132. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  133. #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
  134. {
  135. /* the modalias must be the same as spi device driver name */
  136. .modalias = "m25p80", /* Name of spi_driver for this device */
  137. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  138. .bus_num = 0, /* Framework bus number */
  139. .chip_select = 2, /* Framework chip select. On STAMP537 it is SPISSEL2*/
  140. .platform_data = &bfin_spi_flash_data,
  141. .controller_data = &spi_flash_chip_info,
  142. .mode = SPI_MODE_3,
  143. },
  144. #endif
  145. #if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
  146. {
  147. .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
  148. .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
  149. .bus_num = 0, /* Framework bus number */
  150. .chip_select = 1, /* Framework chip select. */
  151. .platform_data = NULL, /* No spi_driver specific config */
  152. .controller_data = &spi_adc_chip_info,
  153. },
  154. #endif
  155. #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  156. {
  157. .modalias = "ad1836-spi",
  158. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  159. .bus_num = 0,
  160. .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
  161. .controller_data = &ad1836_spi_chip_info,
  162. },
  163. #endif
  164. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  165. {
  166. .modalias = "spidev",
  167. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  168. .bus_num = 0,
  169. .chip_select = 1,
  170. .controller_data = &spidev_chip_info,
  171. },
  172. #endif
  173. };
  174. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  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_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  220. static struct resource bfin_sir_resources[] = {
  221. #ifdef CONFIG_BFIN_SIR0
  222. {
  223. .start = 0xFFC00400,
  224. .end = 0xFFC004FF,
  225. .flags = IORESOURCE_MEM,
  226. },
  227. #endif
  228. };
  229. static struct platform_device bfin_sir_device = {
  230. .name = "bfin_sir",
  231. .id = 0,
  232. .num_resources = ARRAY_SIZE(bfin_sir_resources),
  233. .resource = bfin_sir_resources,
  234. };
  235. #endif
  236. #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
  237. #define PATA_INT 55
  238. static struct pata_platform_info bfin_pata_platform_data = {
  239. .ioport_shift = 1,
  240. .irq_type = IRQF_TRIGGER_HIGH | IRQF_DISABLED,
  241. };
  242. static struct resource bfin_pata_resources[] = {
  243. {
  244. .start = 0x20314020,
  245. .end = 0x2031403F,
  246. .flags = IORESOURCE_MEM,
  247. },
  248. {
  249. .start = 0x2031401C,
  250. .end = 0x2031401F,
  251. .flags = IORESOURCE_MEM,
  252. },
  253. {
  254. .start = PATA_INT,
  255. .end = PATA_INT,
  256. .flags = IORESOURCE_IRQ,
  257. },
  258. };
  259. static struct platform_device bfin_pata_device = {
  260. .name = "pata_platform",
  261. .id = -1,
  262. .num_resources = ARRAY_SIZE(bfin_pata_resources),
  263. .resource = bfin_pata_resources,
  264. .dev = {
  265. .platform_data = &bfin_pata_platform_data,
  266. }
  267. };
  268. #endif
  269. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  270. #include <linux/input.h>
  271. #include <linux/gpio_keys.h>
  272. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  273. {BTN_0, GPIO_PF7, 1, "gpio-keys: BTN0"},
  274. {BTN_1, GPIO_PF8, 1, "gpio-keys: BTN1"},
  275. {BTN_2, GPIO_PF9, 1, "gpio-keys: BTN2"},
  276. {BTN_3, GPIO_PF10, 1, "gpio-keys: BTN3"},
  277. };
  278. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  279. .buttons = bfin_gpio_keys_table,
  280. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  281. };
  282. static struct platform_device bfin_device_gpiokeys = {
  283. .name = "gpio-keys",
  284. .dev = {
  285. .platform_data = &bfin_gpio_keys_data,
  286. },
  287. };
  288. #endif
  289. static struct resource bfin_gpios_resources = {
  290. .start = 0,
  291. .end = MAX_BLACKFIN_GPIOS - 1,
  292. .flags = IORESOURCE_IRQ,
  293. };
  294. static struct platform_device bfin_gpios_device = {
  295. .name = "simple-gpio",
  296. .id = -1,
  297. .num_resources = 1,
  298. .resource = &bfin_gpios_resources,
  299. };
  300. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  301. #include <linux/i2c-gpio.h>
  302. static struct i2c_gpio_platform_data i2c_gpio_data = {
  303. .sda_pin = 1,
  304. .scl_pin = 0,
  305. .sda_is_open_drain = 0,
  306. .scl_is_open_drain = 0,
  307. .udelay = 40,
  308. };
  309. static struct platform_device i2c_gpio_device = {
  310. .name = "i2c-gpio",
  311. .id = 0,
  312. .dev = {
  313. .platform_data = &i2c_gpio_data,
  314. },
  315. };
  316. #endif
  317. static const unsigned int cclk_vlev_datasheet[] =
  318. {
  319. VRPAIR(VLEV_085, 250000000),
  320. VRPAIR(VLEV_090, 376000000),
  321. VRPAIR(VLEV_095, 426000000),
  322. VRPAIR(VLEV_100, 426000000),
  323. VRPAIR(VLEV_105, 476000000),
  324. VRPAIR(VLEV_110, 476000000),
  325. VRPAIR(VLEV_115, 476000000),
  326. VRPAIR(VLEV_120, 600000000),
  327. VRPAIR(VLEV_125, 600000000),
  328. VRPAIR(VLEV_130, 600000000),
  329. };
  330. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  331. .tuple_tab = cclk_vlev_datasheet,
  332. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  333. .vr_settling_time = 25 /* us */,
  334. };
  335. static struct platform_device bfin_dpmc = {
  336. .name = "bfin dpmc",
  337. .dev = {
  338. .platform_data = &bfin_dmpc_vreg_data,
  339. },
  340. };
  341. static struct platform_device *ezkit_devices[] __initdata = {
  342. &bfin_dpmc,
  343. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  344. &smc91x_device,
  345. #endif
  346. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  347. &bfin_spi0_device,
  348. #endif
  349. #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
  350. &bfin_fb_adv7393_device,
  351. #endif
  352. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  353. &rtc_device,
  354. #endif
  355. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  356. &bfin_uart_device,
  357. #endif
  358. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  359. &bfin_sir_device,
  360. #endif
  361. #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
  362. &bfin_pata_device,
  363. #endif
  364. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  365. &bfin_device_gpiokeys,
  366. #endif
  367. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  368. &i2c_gpio_device,
  369. #endif
  370. &bfin_gpios_device,
  371. };
  372. static int __init ezkit_init(void)
  373. {
  374. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  375. platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
  376. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  377. #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
  378. irq_desc[PATA_INT].status |= IRQ_NOAUTOEN;
  379. #endif
  380. return 0;
  381. }
  382. arch_initcall(ezkit_init);