ezkit.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  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_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  85. /* all SPI peripherals info goes here */
  86. #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
  87. static struct mtd_partition bfin_spi_flash_partitions[] = {
  88. {
  89. .name = "bootloader",
  90. .size = 0x00020000,
  91. .offset = 0,
  92. .mask_flags = MTD_CAP_ROM
  93. }, {
  94. .name = "kernel",
  95. .size = 0xe0000,
  96. .offset = MTDPART_OFS_APPEND,
  97. }, {
  98. .name = "file system",
  99. .size = MTDPART_SIZ_FULL,
  100. .offset = MTDPART_OFS_APPEND,
  101. }
  102. };
  103. static struct flash_platform_data bfin_spi_flash_data = {
  104. .name = "m25p80",
  105. .parts = bfin_spi_flash_partitions,
  106. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  107. .type = "m25p64",
  108. };
  109. /* SPI flash chip (m25p64) */
  110. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  111. .enable_dma = 0, /* use dma transfer with this chip*/
  112. .bits_per_word = 8,
  113. };
  114. #endif
  115. #if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
  116. /* SPI ADC chip */
  117. static struct bfin5xx_spi_chip spi_adc_chip_info = {
  118. .enable_dma = 1, /* use dma transfer with this chip*/
  119. .bits_per_word = 16,
  120. };
  121. #endif
  122. #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  123. static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
  124. .enable_dma = 0,
  125. .bits_per_word = 16,
  126. };
  127. #endif
  128. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  129. static struct bfin5xx_spi_chip spidev_chip_info = {
  130. .enable_dma = 0,
  131. .bits_per_word = 8,
  132. };
  133. #endif
  134. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  135. #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
  136. {
  137. /* the modalias must be the same as spi device driver name */
  138. .modalias = "m25p80", /* Name of spi_driver for this device */
  139. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  140. .bus_num = 0, /* Framework bus number */
  141. .chip_select = 2, /* Framework chip select. On STAMP537 it is SPISSEL2*/
  142. .platform_data = &bfin_spi_flash_data,
  143. .controller_data = &spi_flash_chip_info,
  144. .mode = SPI_MODE_3,
  145. },
  146. #endif
  147. #if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
  148. {
  149. .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
  150. .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
  151. .bus_num = 0, /* Framework bus number */
  152. .chip_select = 1, /* Framework chip select. */
  153. .platform_data = NULL, /* No spi_driver specific config */
  154. .controller_data = &spi_adc_chip_info,
  155. },
  156. #endif
  157. #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  158. {
  159. .modalias = "ad1836-spi",
  160. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  161. .bus_num = 0,
  162. .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
  163. .controller_data = &ad1836_spi_chip_info,
  164. },
  165. #endif
  166. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  167. {
  168. .modalias = "spidev",
  169. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  170. .bus_num = 0,
  171. .chip_select = 1,
  172. .controller_data = &spidev_chip_info,
  173. },
  174. #endif
  175. };
  176. /* SPI (0) */
  177. static struct resource bfin_spi0_resource[] = {
  178. [0] = {
  179. .start = SPI0_REGBASE,
  180. .end = SPI0_REGBASE + 0xFF,
  181. .flags = IORESOURCE_MEM,
  182. },
  183. [1] = {
  184. .start = CH_SPI,
  185. .end = CH_SPI,
  186. .flags = IORESOURCE_IRQ,
  187. }
  188. };
  189. /* SPI controller data */
  190. static struct bfin5xx_spi_master bfin_spi0_info = {
  191. .num_chipselect = 8,
  192. .enable_dma = 1, /* master has the ability to do dma transfer */
  193. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  194. };
  195. static struct platform_device bfin_spi0_device = {
  196. .name = "bfin-spi",
  197. .id = 0, /* Bus number */
  198. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  199. .resource = bfin_spi0_resource,
  200. .dev = {
  201. .platform_data = &bfin_spi0_info, /* Passed to driver */
  202. },
  203. };
  204. #endif /* spi master and devices */
  205. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  206. static struct resource bfin_uart_resources[] = {
  207. {
  208. .start = 0xFFC00400,
  209. .end = 0xFFC004FF,
  210. .flags = IORESOURCE_MEM,
  211. },
  212. };
  213. static struct platform_device bfin_uart_device = {
  214. .name = "bfin-uart",
  215. .id = 1,
  216. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  217. .resource = bfin_uart_resources,
  218. };
  219. #endif
  220. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  221. static struct resource bfin_sir_resources[] = {
  222. #ifdef CONFIG_BFIN_SIR0
  223. {
  224. .start = 0xFFC00400,
  225. .end = 0xFFC004FF,
  226. .flags = IORESOURCE_MEM,
  227. },
  228. #endif
  229. };
  230. static struct platform_device bfin_sir_device = {
  231. .name = "bfin_sir",
  232. .id = 0,
  233. .num_resources = ARRAY_SIZE(bfin_sir_resources),
  234. .resource = bfin_sir_resources,
  235. };
  236. #endif
  237. #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
  238. #define PATA_INT 55
  239. static struct pata_platform_info bfin_pata_platform_data = {
  240. .ioport_shift = 1,
  241. .irq_type = IRQF_TRIGGER_HIGH | IRQF_DISABLED,
  242. };
  243. static struct resource bfin_pata_resources[] = {
  244. {
  245. .start = 0x20314020,
  246. .end = 0x2031403F,
  247. .flags = IORESOURCE_MEM,
  248. },
  249. {
  250. .start = 0x2031401C,
  251. .end = 0x2031401F,
  252. .flags = IORESOURCE_MEM,
  253. },
  254. {
  255. .start = PATA_INT,
  256. .end = PATA_INT,
  257. .flags = IORESOURCE_IRQ,
  258. },
  259. };
  260. static struct platform_device bfin_pata_device = {
  261. .name = "pata_platform",
  262. .id = -1,
  263. .num_resources = ARRAY_SIZE(bfin_pata_resources),
  264. .resource = bfin_pata_resources,
  265. .dev = {
  266. .platform_data = &bfin_pata_platform_data,
  267. }
  268. };
  269. #endif
  270. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  271. #include <linux/input.h>
  272. #include <linux/gpio_keys.h>
  273. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  274. {BTN_0, GPIO_PF7, 1, "gpio-keys: BTN0"},
  275. {BTN_1, GPIO_PF8, 1, "gpio-keys: BTN1"},
  276. {BTN_2, GPIO_PF9, 1, "gpio-keys: BTN2"},
  277. {BTN_3, GPIO_PF10, 1, "gpio-keys: BTN3"},
  278. };
  279. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  280. .buttons = bfin_gpio_keys_table,
  281. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  282. };
  283. static struct platform_device bfin_device_gpiokeys = {
  284. .name = "gpio-keys",
  285. .dev = {
  286. .platform_data = &bfin_gpio_keys_data,
  287. },
  288. };
  289. #endif
  290. static struct resource bfin_gpios_resources = {
  291. .start = 0,
  292. .end = MAX_BLACKFIN_GPIOS - 1,
  293. .flags = IORESOURCE_IRQ,
  294. };
  295. static struct platform_device bfin_gpios_device = {
  296. .name = "simple-gpio",
  297. .id = -1,
  298. .num_resources = 1,
  299. .resource = &bfin_gpios_resources,
  300. };
  301. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  302. #include <linux/i2c-gpio.h>
  303. static struct i2c_gpio_platform_data i2c_gpio_data = {
  304. .sda_pin = 1,
  305. .scl_pin = 0,
  306. .sda_is_open_drain = 0,
  307. .scl_is_open_drain = 0,
  308. .udelay = 40,
  309. };
  310. static struct platform_device i2c_gpio_device = {
  311. .name = "i2c-gpio",
  312. .id = 0,
  313. .dev = {
  314. .platform_data = &i2c_gpio_data,
  315. },
  316. };
  317. #endif
  318. static const unsigned int cclk_vlev_datasheet[] =
  319. {
  320. VRPAIR(VLEV_085, 250000000),
  321. VRPAIR(VLEV_090, 376000000),
  322. VRPAIR(VLEV_095, 426000000),
  323. VRPAIR(VLEV_100, 426000000),
  324. VRPAIR(VLEV_105, 476000000),
  325. VRPAIR(VLEV_110, 476000000),
  326. VRPAIR(VLEV_115, 476000000),
  327. VRPAIR(VLEV_120, 600000000),
  328. VRPAIR(VLEV_125, 600000000),
  329. VRPAIR(VLEV_130, 600000000),
  330. };
  331. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  332. .tuple_tab = cclk_vlev_datasheet,
  333. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  334. .vr_settling_time = 25 /* us */,
  335. };
  336. static struct platform_device bfin_dpmc = {
  337. .name = "bfin dpmc",
  338. .dev = {
  339. .platform_data = &bfin_dmpc_vreg_data,
  340. },
  341. };
  342. static struct platform_device *ezkit_devices[] __initdata = {
  343. &bfin_dpmc,
  344. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  345. &smc91x_device,
  346. #endif
  347. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  348. &bfin_spi0_device,
  349. #endif
  350. #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
  351. &bfin_fb_adv7393_device,
  352. #endif
  353. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  354. &rtc_device,
  355. #endif
  356. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  357. &bfin_uart_device,
  358. #endif
  359. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  360. &bfin_sir_device,
  361. #endif
  362. #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
  363. &bfin_pata_device,
  364. #endif
  365. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  366. &bfin_device_gpiokeys,
  367. #endif
  368. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  369. &i2c_gpio_device,
  370. #endif
  371. &bfin_gpios_device,
  372. };
  373. static int __init ezkit_init(void)
  374. {
  375. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  376. platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
  377. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  378. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  379. #endif
  380. #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
  381. irq_desc[PATA_INT].status |= IRQ_NOAUTOEN;
  382. #endif
  383. return 0;
  384. }
  385. arch_initcall(ezkit_init);