ezkit.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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/irq.h>
  40. #include <asm/dma.h>
  41. #include <asm/bfin5xx_spi.h>
  42. #include <asm/portmux.h>
  43. #include <asm/dpmc.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_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
  84. static struct mtd_partition bfin_spi_flash_partitions[] = {
  85. {
  86. .name = "bootloader(spi)",
  87. .size = 0x00020000,
  88. .offset = 0,
  89. .mask_flags = MTD_CAP_ROM
  90. }, {
  91. .name = "linux kernel(spi)",
  92. .size = 0xe0000,
  93. .offset = MTDPART_OFS_APPEND,
  94. }, {
  95. .name = "file system(spi)",
  96. .size = MTDPART_SIZ_FULL,
  97. .offset = MTDPART_OFS_APPEND,
  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. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  174. /* SPI (0) */
  175. static struct resource bfin_spi0_resource[] = {
  176. [0] = {
  177. .start = SPI0_REGBASE,
  178. .end = SPI0_REGBASE + 0xFF,
  179. .flags = IORESOURCE_MEM,
  180. },
  181. [1] = {
  182. .start = CH_SPI,
  183. .end = CH_SPI,
  184. .flags = IORESOURCE_IRQ,
  185. }
  186. };
  187. /* SPI controller data */
  188. static struct bfin5xx_spi_master bfin_spi0_info = {
  189. .num_chipselect = 8,
  190. .enable_dma = 1, /* master has the ability to do dma transfer */
  191. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  192. };
  193. static struct platform_device bfin_spi0_device = {
  194. .name = "bfin-spi",
  195. .id = 0, /* Bus number */
  196. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  197. .resource = bfin_spi0_resource,
  198. .dev = {
  199. .platform_data = &bfin_spi0_info, /* Passed to driver */
  200. },
  201. };
  202. #endif /* spi master and devices */
  203. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  204. static struct resource bfin_uart_resources[] = {
  205. {
  206. .start = 0xFFC00400,
  207. .end = 0xFFC004FF,
  208. .flags = IORESOURCE_MEM,
  209. },
  210. };
  211. static struct platform_device bfin_uart_device = {
  212. .name = "bfin-uart",
  213. .id = 1,
  214. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  215. .resource = bfin_uart_resources,
  216. };
  217. #endif
  218. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  219. static struct resource bfin_sir_resources[] = {
  220. #ifdef CONFIG_BFIN_SIR0
  221. {
  222. .start = 0xFFC00400,
  223. .end = 0xFFC004FF,
  224. .flags = IORESOURCE_MEM,
  225. },
  226. #endif
  227. };
  228. static struct platform_device bfin_sir_device = {
  229. .name = "bfin_sir",
  230. .id = 0,
  231. .num_resources = ARRAY_SIZE(bfin_sir_resources),
  232. .resource = bfin_sir_resources,
  233. };
  234. #endif
  235. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  236. #include <linux/input.h>
  237. #include <linux/gpio_keys.h>
  238. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  239. {BTN_0, GPIO_PF7, 1, "gpio-keys: BTN0"},
  240. {BTN_1, GPIO_PF8, 1, "gpio-keys: BTN1"},
  241. {BTN_2, GPIO_PF9, 1, "gpio-keys: BTN2"},
  242. {BTN_3, GPIO_PF10, 1, "gpio-keys: BTN3"},
  243. };
  244. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  245. .buttons = bfin_gpio_keys_table,
  246. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  247. };
  248. static struct platform_device bfin_device_gpiokeys = {
  249. .name = "gpio-keys",
  250. .dev = {
  251. .platform_data = &bfin_gpio_keys_data,
  252. },
  253. };
  254. #endif
  255. static struct resource bfin_gpios_resources = {
  256. .start = 0,
  257. .end = MAX_BLACKFIN_GPIOS - 1,
  258. .flags = IORESOURCE_IRQ,
  259. };
  260. static struct platform_device bfin_gpios_device = {
  261. .name = "simple-gpio",
  262. .id = -1,
  263. .num_resources = 1,
  264. .resource = &bfin_gpios_resources,
  265. };
  266. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  267. #include <linux/i2c-gpio.h>
  268. static struct i2c_gpio_platform_data i2c_gpio_data = {
  269. .sda_pin = 1,
  270. .scl_pin = 0,
  271. .sda_is_open_drain = 0,
  272. .scl_is_open_drain = 0,
  273. .udelay = 40,
  274. };
  275. static struct platform_device i2c_gpio_device = {
  276. .name = "i2c-gpio",
  277. .id = 0,
  278. .dev = {
  279. .platform_data = &i2c_gpio_data,
  280. },
  281. };
  282. #endif
  283. static const unsigned int cclk_vlev_datasheet[] =
  284. {
  285. VRPAIR(VLEV_085, 250000000),
  286. VRPAIR(VLEV_090, 376000000),
  287. VRPAIR(VLEV_095, 426000000),
  288. VRPAIR(VLEV_100, 426000000),
  289. VRPAIR(VLEV_105, 476000000),
  290. VRPAIR(VLEV_110, 476000000),
  291. VRPAIR(VLEV_115, 476000000),
  292. VRPAIR(VLEV_120, 600000000),
  293. VRPAIR(VLEV_125, 600000000),
  294. VRPAIR(VLEV_130, 600000000),
  295. };
  296. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  297. .tuple_tab = cclk_vlev_datasheet,
  298. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  299. .vr_settling_time = 25 /* us */,
  300. };
  301. static struct platform_device bfin_dpmc = {
  302. .name = "bfin dpmc",
  303. .dev = {
  304. .platform_data = &bfin_dmpc_vreg_data,
  305. },
  306. };
  307. static struct platform_device *ezkit_devices[] __initdata = {
  308. &bfin_dpmc,
  309. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  310. &smc91x_device,
  311. #endif
  312. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  313. &bfin_spi0_device,
  314. #endif
  315. #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
  316. &bfin_fb_adv7393_device,
  317. #endif
  318. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  319. &rtc_device,
  320. #endif
  321. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  322. &bfin_uart_device,
  323. #endif
  324. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  325. &bfin_sir_device,
  326. #endif
  327. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  328. &bfin_device_gpiokeys,
  329. #endif
  330. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  331. &i2c_gpio_device,
  332. #endif
  333. &bfin_gpios_device,
  334. };
  335. static int __init ezkit_init(void)
  336. {
  337. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  338. platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
  339. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  340. return 0;
  341. }
  342. arch_initcall(ezkit_init);