edb93xx.c 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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 struct platform_device edb93xx_audio_device = {
  140. .name = "edb93xx-audio",
  141. .id = -1,
  142. };
  143. static int __init edb93xx_has_audio(void)
  144. {
  145. return (machine_is_edb9301() || machine_is_edb9302() ||
  146. machine_is_edb9302a() || machine_is_edb9307a() ||
  147. machine_is_edb9315a());
  148. }
  149. static void __init edb93xx_register_i2s(void)
  150. {
  151. if (edb93xx_has_audio()) {
  152. ep93xx_register_i2s();
  153. platform_device_register(&edb93xx_audio_device);
  154. }
  155. }
  156. /*************************************************************************
  157. * EDB93xx pwm
  158. *************************************************************************/
  159. static void __init edb93xx_register_pwm(void)
  160. {
  161. if (machine_is_edb9301() ||
  162. machine_is_edb9302() || machine_is_edb9302a()) {
  163. /* EP9301 and EP9302 only have pwm.1 (EGPIO14) */
  164. ep93xx_register_pwm(0, 1);
  165. } else if (machine_is_edb9307() || machine_is_edb9307a()) {
  166. /* EP9307 only has pwm.0 (PWMOUT) */
  167. ep93xx_register_pwm(1, 0);
  168. } else {
  169. /* EP9312 and EP9315 have both */
  170. ep93xx_register_pwm(1, 1);
  171. }
  172. }
  173. /*************************************************************************
  174. * EDB93xx framebuffer
  175. *************************************************************************/
  176. static struct ep93xxfb_mach_info __initdata edb93xxfb_info = {
  177. .num_modes = EP93XXFB_USE_MODEDB,
  178. .bpp = 16,
  179. .flags = 0,
  180. };
  181. static int __init edb93xx_has_fb(void)
  182. {
  183. /* These platforms have an ep93xx with video capability */
  184. return machine_is_edb9307() || machine_is_edb9307a() ||
  185. machine_is_edb9312() || machine_is_edb9315() ||
  186. machine_is_edb9315a();
  187. }
  188. static void __init edb93xx_register_fb(void)
  189. {
  190. if (!edb93xx_has_fb())
  191. return;
  192. if (machine_is_edb9307a() || machine_is_edb9315a())
  193. edb93xxfb_info.flags |= EP93XXFB_USE_SDCSN0;
  194. else
  195. edb93xxfb_info.flags |= EP93XXFB_USE_SDCSN3;
  196. ep93xx_register_fb(&edb93xxfb_info);
  197. }
  198. static void __init edb93xx_init_machine(void)
  199. {
  200. ep93xx_init_devices();
  201. edb93xx_register_flash();
  202. ep93xx_register_eth(&edb93xx_eth_data, 1);
  203. edb93xx_register_i2c();
  204. edb93xx_register_spi();
  205. edb93xx_register_i2s();
  206. edb93xx_register_pwm();
  207. edb93xx_register_fb();
  208. }
  209. #ifdef CONFIG_MACH_EDB9301
  210. MACHINE_START(EDB9301, "Cirrus Logic EDB9301 Evaluation Board")
  211. /* Maintainer: H Hartley Sweeten <hsweeten@visionengravers.com> */
  212. .atag_offset = 0x100,
  213. .map_io = ep93xx_map_io,
  214. .init_irq = ep93xx_init_irq,
  215. .timer = &ep93xx_timer,
  216. .init_machine = edb93xx_init_machine,
  217. MACHINE_END
  218. #endif
  219. #ifdef CONFIG_MACH_EDB9302
  220. MACHINE_START(EDB9302, "Cirrus Logic EDB9302 Evaluation Board")
  221. /* Maintainer: George Kashperko <george@chas.com.ua> */
  222. .atag_offset = 0x100,
  223. .map_io = ep93xx_map_io,
  224. .init_irq = ep93xx_init_irq,
  225. .timer = &ep93xx_timer,
  226. .init_machine = edb93xx_init_machine,
  227. MACHINE_END
  228. #endif
  229. #ifdef CONFIG_MACH_EDB9302A
  230. MACHINE_START(EDB9302A, "Cirrus Logic EDB9302A Evaluation Board")
  231. /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
  232. .atag_offset = 0x100,
  233. .map_io = ep93xx_map_io,
  234. .init_irq = ep93xx_init_irq,
  235. .timer = &ep93xx_timer,
  236. .init_machine = edb93xx_init_machine,
  237. MACHINE_END
  238. #endif
  239. #ifdef CONFIG_MACH_EDB9307
  240. MACHINE_START(EDB9307, "Cirrus Logic EDB9307 Evaluation Board")
  241. /* Maintainer: Herbert Valerio Riedel <hvr@gnu.org> */
  242. .atag_offset = 0x100,
  243. .map_io = ep93xx_map_io,
  244. .init_irq = ep93xx_init_irq,
  245. .timer = &ep93xx_timer,
  246. .init_machine = edb93xx_init_machine,
  247. MACHINE_END
  248. #endif
  249. #ifdef CONFIG_MACH_EDB9307A
  250. MACHINE_START(EDB9307A, "Cirrus Logic EDB9307A Evaluation Board")
  251. /* Maintainer: H Hartley Sweeten <hsweeten@visionengravers.com> */
  252. .atag_offset = 0x100,
  253. .map_io = ep93xx_map_io,
  254. .init_irq = ep93xx_init_irq,
  255. .timer = &ep93xx_timer,
  256. .init_machine = edb93xx_init_machine,
  257. MACHINE_END
  258. #endif
  259. #ifdef CONFIG_MACH_EDB9312
  260. MACHINE_START(EDB9312, "Cirrus Logic EDB9312 Evaluation Board")
  261. /* Maintainer: Toufeeq Hussain <toufeeq_hussain@infosys.com> */
  262. .atag_offset = 0x100,
  263. .map_io = ep93xx_map_io,
  264. .init_irq = ep93xx_init_irq,
  265. .timer = &ep93xx_timer,
  266. .init_machine = edb93xx_init_machine,
  267. MACHINE_END
  268. #endif
  269. #ifdef CONFIG_MACH_EDB9315
  270. MACHINE_START(EDB9315, "Cirrus Logic EDB9315 Evaluation Board")
  271. /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
  272. .atag_offset = 0x100,
  273. .map_io = ep93xx_map_io,
  274. .init_irq = ep93xx_init_irq,
  275. .timer = &ep93xx_timer,
  276. .init_machine = edb93xx_init_machine,
  277. MACHINE_END
  278. #endif
  279. #ifdef CONFIG_MACH_EDB9315A
  280. MACHINE_START(EDB9315A, "Cirrus Logic EDB9315A Evaluation Board")
  281. /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
  282. .atag_offset = 0x100,
  283. .map_io = ep93xx_map_io,
  284. .init_irq = ep93xx_init_irq,
  285. .timer = &ep93xx_timer,
  286. .init_machine = edb93xx_init_machine,
  287. MACHINE_END
  288. #endif