edb93xx.c 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. /*
  2. * arch/arm/mach-ep93xx/edb93xx.c
  3. * Cirrus Logic EDB93xx Development Board support.
  4. *
  5. * EDB93XX, EDB9301, EDB9307A
  6. * Copyright (C) 2008-2009 H Hartley Sweeten <hsweeten@visionengravers.com>
  7. *
  8. * EDB9302
  9. * Copyright (C) 2006 George Kashperko <george@chas.com.ua>
  10. *
  11. * EDB9302A, EDB9315, EDB9315A
  12. * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
  13. *
  14. * EDB9307
  15. * Copyright (C) 2007 Herbert Valerio Riedel <hvr@gnu.org>
  16. *
  17. * EDB9312
  18. * Copyright (C) 2006 Infosys Technologies Limited
  19. * Toufeeq Hussain <toufeeq_hussain@infosys.com>
  20. *
  21. * This program is free software; you can redistribute it and/or modify
  22. * it under the terms of the GNU General Public License as published by
  23. * the Free Software Foundation; either version 2 of the License, or (at
  24. * your option) any later version.
  25. */
  26. #include <linux/kernel.h>
  27. #include <linux/init.h>
  28. #include <linux/platform_device.h>
  29. #include <linux/gpio.h>
  30. #include <linux/i2c.h>
  31. #include <linux/i2c-gpio.h>
  32. #include <linux/spi/spi.h>
  33. #include <sound/cs4271.h>
  34. #include <mach/hardware.h>
  35. #include <mach/fb.h>
  36. #include <mach/ep93xx_spi.h>
  37. #include <mach/gpio-ep93xx.h>
  38. #include <asm/mach-types.h>
  39. #include <asm/mach/arch.h>
  40. static void __init edb93xx_register_flash(void)
  41. {
  42. if (machine_is_edb9307() || machine_is_edb9312() ||
  43. machine_is_edb9315()) {
  44. ep93xx_register_flash(4, EP93XX_CS6_PHYS_BASE, SZ_32M);
  45. } else {
  46. ep93xx_register_flash(2, EP93XX_CS6_PHYS_BASE, SZ_16M);
  47. }
  48. }
  49. static struct ep93xx_eth_data __initdata edb93xx_eth_data = {
  50. .phy_id = 1,
  51. };
  52. /*************************************************************************
  53. * EDB93xx i2c peripheral handling
  54. *************************************************************************/
  55. static struct i2c_gpio_platform_data __initdata edb93xx_i2c_gpio_data = {
  56. .sda_pin = EP93XX_GPIO_LINE_EEDAT,
  57. .sda_is_open_drain = 0,
  58. .scl_pin = EP93XX_GPIO_LINE_EECLK,
  59. .scl_is_open_drain = 0,
  60. .udelay = 0, /* default to 100 kHz */
  61. .timeout = 0, /* default to 100 ms */
  62. };
  63. static struct i2c_board_info __initdata edb93xxa_i2c_board_info[] = {
  64. {
  65. I2C_BOARD_INFO("isl1208", 0x6f),
  66. },
  67. };
  68. static struct i2c_board_info __initdata edb93xx_i2c_board_info[] = {
  69. {
  70. I2C_BOARD_INFO("ds1337", 0x68),
  71. },
  72. };
  73. static void __init edb93xx_register_i2c(void)
  74. {
  75. if (machine_is_edb9302a() || machine_is_edb9307a() ||
  76. machine_is_edb9315a()) {
  77. ep93xx_register_i2c(&edb93xx_i2c_gpio_data,
  78. edb93xxa_i2c_board_info,
  79. ARRAY_SIZE(edb93xxa_i2c_board_info));
  80. } else if (machine_is_edb9307() || machine_is_edb9312() ||
  81. machine_is_edb9315()) {
  82. ep93xx_register_i2c(&edb93xx_i2c_gpio_data,
  83. edb93xx_i2c_board_info,
  84. ARRAY_SIZE(edb93xx_i2c_board_info));
  85. }
  86. }
  87. /*************************************************************************
  88. * EDB93xx SPI peripheral handling
  89. *************************************************************************/
  90. static struct cs4271_platform_data edb93xx_cs4271_data = {
  91. .gpio_nreset = -EINVAL, /* filled in later */
  92. };
  93. static int edb93xx_cs4271_hw_setup(struct spi_device *spi)
  94. {
  95. return gpio_request_one(EP93XX_GPIO_LINE_EGPIO6,
  96. GPIOF_OUT_INIT_HIGH, spi->modalias);
  97. }
  98. static void edb93xx_cs4271_hw_cleanup(struct spi_device *spi)
  99. {
  100. gpio_free(EP93XX_GPIO_LINE_EGPIO6);
  101. }
  102. static void edb93xx_cs4271_hw_cs_control(struct spi_device *spi, int value)
  103. {
  104. gpio_set_value(EP93XX_GPIO_LINE_EGPIO6, value);
  105. }
  106. static struct ep93xx_spi_chip_ops edb93xx_cs4271_hw = {
  107. .setup = edb93xx_cs4271_hw_setup,
  108. .cleanup = edb93xx_cs4271_hw_cleanup,
  109. .cs_control = edb93xx_cs4271_hw_cs_control,
  110. };
  111. static struct spi_board_info edb93xx_spi_board_info[] __initdata = {
  112. {
  113. .modalias = "cs4271",
  114. .platform_data = &edb93xx_cs4271_data,
  115. .controller_data = &edb93xx_cs4271_hw,
  116. .max_speed_hz = 6000000,
  117. .bus_num = 0,
  118. .chip_select = 0,
  119. .mode = SPI_MODE_3,
  120. },
  121. };
  122. static struct ep93xx_spi_info edb93xx_spi_info __initdata = {
  123. .num_chipselect = ARRAY_SIZE(edb93xx_spi_board_info),
  124. };
  125. static void __init edb93xx_register_spi(void)
  126. {
  127. if (machine_is_edb9301() || machine_is_edb9302())
  128. edb93xx_cs4271_data.gpio_nreset = EP93XX_GPIO_LINE_EGPIO1;
  129. else if (machine_is_edb9302a() || machine_is_edb9307a())
  130. edb93xx_cs4271_data.gpio_nreset = EP93XX_GPIO_LINE_H(2);
  131. else if (machine_is_edb9315a())
  132. edb93xx_cs4271_data.gpio_nreset = EP93XX_GPIO_LINE_EGPIO14;
  133. ep93xx_register_spi(&edb93xx_spi_info, edb93xx_spi_board_info,
  134. ARRAY_SIZE(edb93xx_spi_board_info));
  135. }
  136. /*************************************************************************
  137. * EDB93xx I2S
  138. *************************************************************************/
  139. static int __init edb93xx_has_audio(void)
  140. {
  141. return (machine_is_edb9301() || machine_is_edb9302() ||
  142. machine_is_edb9302a() || machine_is_edb9307a() ||
  143. machine_is_edb9315a());
  144. }
  145. static void __init edb93xx_register_i2s(void)
  146. {
  147. if (edb93xx_has_audio()) {
  148. ep93xx_register_i2s();
  149. }
  150. }
  151. /*************************************************************************
  152. * EDB93xx pwm
  153. *************************************************************************/
  154. static void __init edb93xx_register_pwm(void)
  155. {
  156. if (machine_is_edb9301() ||
  157. machine_is_edb9302() || machine_is_edb9302a()) {
  158. /* EP9301 and EP9302 only have pwm.1 (EGPIO14) */
  159. ep93xx_register_pwm(0, 1);
  160. } else if (machine_is_edb9307() || machine_is_edb9307a()) {
  161. /* EP9307 only has pwm.0 (PWMOUT) */
  162. ep93xx_register_pwm(1, 0);
  163. } else {
  164. /* EP9312 and EP9315 have both */
  165. ep93xx_register_pwm(1, 1);
  166. }
  167. }
  168. /*************************************************************************
  169. * EDB93xx framebuffer
  170. *************************************************************************/
  171. static struct ep93xxfb_mach_info __initdata edb93xxfb_info = {
  172. .num_modes = EP93XXFB_USE_MODEDB,
  173. .bpp = 16,
  174. .flags = 0,
  175. };
  176. static int __init edb93xx_has_fb(void)
  177. {
  178. /* These platforms have an ep93xx with video capability */
  179. return machine_is_edb9307() || machine_is_edb9307a() ||
  180. machine_is_edb9312() || machine_is_edb9315() ||
  181. machine_is_edb9315a();
  182. }
  183. static void __init edb93xx_register_fb(void)
  184. {
  185. if (!edb93xx_has_fb())
  186. return;
  187. if (machine_is_edb9307a() || machine_is_edb9315a())
  188. edb93xxfb_info.flags |= EP93XXFB_USE_SDCSN0;
  189. else
  190. edb93xxfb_info.flags |= EP93XXFB_USE_SDCSN3;
  191. ep93xx_register_fb(&edb93xxfb_info);
  192. }
  193. static void __init edb93xx_init_machine(void)
  194. {
  195. ep93xx_init_devices();
  196. edb93xx_register_flash();
  197. ep93xx_register_eth(&edb93xx_eth_data, 1);
  198. edb93xx_register_i2c();
  199. edb93xx_register_spi();
  200. edb93xx_register_i2s();
  201. edb93xx_register_pwm();
  202. edb93xx_register_fb();
  203. }
  204. #ifdef CONFIG_MACH_EDB9301
  205. MACHINE_START(EDB9301, "Cirrus Logic EDB9301 Evaluation Board")
  206. /* Maintainer: H Hartley Sweeten <hsweeten@visionengravers.com> */
  207. .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100,
  208. .map_io = ep93xx_map_io,
  209. .init_irq = ep93xx_init_irq,
  210. .timer = &ep93xx_timer,
  211. .init_machine = edb93xx_init_machine,
  212. MACHINE_END
  213. #endif
  214. #ifdef CONFIG_MACH_EDB9302
  215. MACHINE_START(EDB9302, "Cirrus Logic EDB9302 Evaluation Board")
  216. /* Maintainer: George Kashperko <george@chas.com.ua> */
  217. .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100,
  218. .map_io = ep93xx_map_io,
  219. .init_irq = ep93xx_init_irq,
  220. .timer = &ep93xx_timer,
  221. .init_machine = edb93xx_init_machine,
  222. MACHINE_END
  223. #endif
  224. #ifdef CONFIG_MACH_EDB9302A
  225. MACHINE_START(EDB9302A, "Cirrus Logic EDB9302A Evaluation Board")
  226. /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
  227. .boot_params = EP93XX_SDCE0_PHYS_BASE + 0x100,
  228. .map_io = ep93xx_map_io,
  229. .init_irq = ep93xx_init_irq,
  230. .timer = &ep93xx_timer,
  231. .init_machine = edb93xx_init_machine,
  232. MACHINE_END
  233. #endif
  234. #ifdef CONFIG_MACH_EDB9307
  235. MACHINE_START(EDB9307, "Cirrus Logic EDB9307 Evaluation Board")
  236. /* Maintainer: Herbert Valerio Riedel <hvr@gnu.org> */
  237. .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100,
  238. .map_io = ep93xx_map_io,
  239. .init_irq = ep93xx_init_irq,
  240. .timer = &ep93xx_timer,
  241. .init_machine = edb93xx_init_machine,
  242. MACHINE_END
  243. #endif
  244. #ifdef CONFIG_MACH_EDB9307A
  245. MACHINE_START(EDB9307A, "Cirrus Logic EDB9307A Evaluation Board")
  246. /* Maintainer: H Hartley Sweeten <hsweeten@visionengravers.com> */
  247. .boot_params = EP93XX_SDCE0_PHYS_BASE + 0x100,
  248. .map_io = ep93xx_map_io,
  249. .init_irq = ep93xx_init_irq,
  250. .timer = &ep93xx_timer,
  251. .init_machine = edb93xx_init_machine,
  252. MACHINE_END
  253. #endif
  254. #ifdef CONFIG_MACH_EDB9312
  255. MACHINE_START(EDB9312, "Cirrus Logic EDB9312 Evaluation Board")
  256. /* Maintainer: Toufeeq Hussain <toufeeq_hussain@infosys.com> */
  257. .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100,
  258. .map_io = ep93xx_map_io,
  259. .init_irq = ep93xx_init_irq,
  260. .timer = &ep93xx_timer,
  261. .init_machine = edb93xx_init_machine,
  262. MACHINE_END
  263. #endif
  264. #ifdef CONFIG_MACH_EDB9315
  265. MACHINE_START(EDB9315, "Cirrus Logic EDB9315 Evaluation Board")
  266. /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
  267. .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100,
  268. .map_io = ep93xx_map_io,
  269. .init_irq = ep93xx_init_irq,
  270. .timer = &ep93xx_timer,
  271. .init_machine = edb93xx_init_machine,
  272. MACHINE_END
  273. #endif
  274. #ifdef CONFIG_MACH_EDB9315A
  275. MACHINE_START(EDB9315A, "Cirrus Logic EDB9315A Evaluation Board")
  276. /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
  277. .boot_params = EP93XX_SDCE0_PHYS_BASE + 0x100,
  278. .map_io = ep93xx_map_io,
  279. .init_irq = ep93xx_init_irq,
  280. .timer = &ep93xx_timer,
  281. .init_machine = edb93xx_init_machine,
  282. MACHINE_END
  283. #endif