edb93xx.c 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  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/i2c.h>
  30. #include <linux/spi/spi.h>
  31. #include <sound/cs4271.h>
  32. #include <mach/hardware.h>
  33. #include <linux/platform_data/video-ep93xx.h>
  34. #include <linux/platform_data/spi-ep93xx.h>
  35. #include <mach/gpio-ep93xx.h>
  36. #include <asm/mach-types.h>
  37. #include <asm/mach/arch.h>
  38. #include "soc.h"
  39. static void __init edb93xx_register_flash(void)
  40. {
  41. if (machine_is_edb9307() || machine_is_edb9312() ||
  42. machine_is_edb9315()) {
  43. ep93xx_register_flash(4, EP93XX_CS6_PHYS_BASE, SZ_32M);
  44. } else {
  45. ep93xx_register_flash(2, EP93XX_CS6_PHYS_BASE, SZ_16M);
  46. }
  47. }
  48. static struct ep93xx_eth_data __initdata edb93xx_eth_data = {
  49. .phy_id = 1,
  50. };
  51. /*************************************************************************
  52. * EDB93xx i2c peripheral handling
  53. *************************************************************************/
  54. static struct i2c_board_info __initdata edb93xxa_i2c_board_info[] = {
  55. {
  56. I2C_BOARD_INFO("isl1208", 0x6f),
  57. },
  58. };
  59. static struct i2c_board_info __initdata edb93xx_i2c_board_info[] = {
  60. {
  61. I2C_BOARD_INFO("ds1337", 0x68),
  62. },
  63. };
  64. static void __init edb93xx_register_i2c(void)
  65. {
  66. if (machine_is_edb9302a() || machine_is_edb9307a() ||
  67. machine_is_edb9315a()) {
  68. ep93xx_register_i2c(edb93xxa_i2c_board_info,
  69. ARRAY_SIZE(edb93xxa_i2c_board_info));
  70. } else if (machine_is_edb9302() || machine_is_edb9307()
  71. || machine_is_edb9312() || machine_is_edb9315()) {
  72. ep93xx_register_i2c(edb93xx_i2c_board_info,
  73. ARRAY_SIZE(edb93xx_i2c_board_info));
  74. }
  75. }
  76. /*************************************************************************
  77. * EDB93xx SPI peripheral handling
  78. *************************************************************************/
  79. static struct cs4271_platform_data edb93xx_cs4271_data = {
  80. .gpio_nreset = -EINVAL, /* filled in later */
  81. };
  82. static struct spi_board_info edb93xx_spi_board_info[] __initdata = {
  83. {
  84. .modalias = "cs4271",
  85. .platform_data = &edb93xx_cs4271_data,
  86. .max_speed_hz = 6000000,
  87. .bus_num = 0,
  88. .chip_select = 0,
  89. .mode = SPI_MODE_3,
  90. },
  91. };
  92. static int edb93xx_spi_chipselects[] __initdata = {
  93. EP93XX_GPIO_LINE_EGPIO6,
  94. };
  95. static struct ep93xx_spi_info edb93xx_spi_info __initdata = {
  96. .chipselect = edb93xx_spi_chipselects,
  97. .num_chipselect = ARRAY_SIZE(edb93xx_spi_chipselects),
  98. };
  99. static void __init edb93xx_register_spi(void)
  100. {
  101. if (machine_is_edb9301() || machine_is_edb9302())
  102. edb93xx_cs4271_data.gpio_nreset = EP93XX_GPIO_LINE_EGPIO1;
  103. else if (machine_is_edb9302a() || machine_is_edb9307a())
  104. edb93xx_cs4271_data.gpio_nreset = EP93XX_GPIO_LINE_H(2);
  105. else if (machine_is_edb9315a())
  106. edb93xx_cs4271_data.gpio_nreset = EP93XX_GPIO_LINE_EGPIO14;
  107. ep93xx_register_spi(&edb93xx_spi_info, edb93xx_spi_board_info,
  108. ARRAY_SIZE(edb93xx_spi_board_info));
  109. }
  110. /*************************************************************************
  111. * EDB93xx I2S
  112. *************************************************************************/
  113. static struct platform_device edb93xx_audio_device = {
  114. .name = "edb93xx-audio",
  115. .id = -1,
  116. };
  117. static int __init edb93xx_has_audio(void)
  118. {
  119. return (machine_is_edb9301() || machine_is_edb9302() ||
  120. machine_is_edb9302a() || machine_is_edb9307a() ||
  121. machine_is_edb9315a());
  122. }
  123. static void __init edb93xx_register_i2s(void)
  124. {
  125. if (edb93xx_has_audio()) {
  126. ep93xx_register_i2s();
  127. platform_device_register(&edb93xx_audio_device);
  128. }
  129. }
  130. /*************************************************************************
  131. * EDB93xx pwm
  132. *************************************************************************/
  133. static void __init edb93xx_register_pwm(void)
  134. {
  135. if (machine_is_edb9301() ||
  136. machine_is_edb9302() || machine_is_edb9302a()) {
  137. /* EP9301 and EP9302 only have pwm.1 (EGPIO14) */
  138. ep93xx_register_pwm(0, 1);
  139. } else if (machine_is_edb9307() || machine_is_edb9307a()) {
  140. /* EP9307 only has pwm.0 (PWMOUT) */
  141. ep93xx_register_pwm(1, 0);
  142. } else {
  143. /* EP9312 and EP9315 have both */
  144. ep93xx_register_pwm(1, 1);
  145. }
  146. }
  147. /*************************************************************************
  148. * EDB93xx framebuffer
  149. *************************************************************************/
  150. static struct ep93xxfb_mach_info __initdata edb93xxfb_info = {
  151. .flags = 0,
  152. };
  153. static int __init edb93xx_has_fb(void)
  154. {
  155. /* These platforms have an ep93xx with video capability */
  156. return machine_is_edb9307() || machine_is_edb9307a() ||
  157. machine_is_edb9312() || machine_is_edb9315() ||
  158. machine_is_edb9315a();
  159. }
  160. static void __init edb93xx_register_fb(void)
  161. {
  162. if (!edb93xx_has_fb())
  163. return;
  164. if (machine_is_edb9307a() || machine_is_edb9315a())
  165. edb93xxfb_info.flags |= EP93XXFB_USE_SDCSN0;
  166. else
  167. edb93xxfb_info.flags |= EP93XXFB_USE_SDCSN3;
  168. ep93xx_register_fb(&edb93xxfb_info);
  169. }
  170. /*************************************************************************
  171. * EDB93xx IDE
  172. *************************************************************************/
  173. static int __init edb93xx_has_ide(void)
  174. {
  175. /*
  176. * Although EDB9312 and EDB9315 do have IDE capability, they have
  177. * INTRQ line wired as pull-up, which makes using IDE interface
  178. * problematic.
  179. */
  180. return machine_is_edb9312() || machine_is_edb9315() ||
  181. machine_is_edb9315a();
  182. }
  183. static void __init edb93xx_register_ide(void)
  184. {
  185. if (!edb93xx_has_ide())
  186. return;
  187. ep93xx_register_ide();
  188. }
  189. static void __init edb93xx_init_machine(void)
  190. {
  191. ep93xx_init_devices();
  192. edb93xx_register_flash();
  193. ep93xx_register_eth(&edb93xx_eth_data, 1);
  194. edb93xx_register_i2c();
  195. edb93xx_register_spi();
  196. edb93xx_register_i2s();
  197. edb93xx_register_pwm();
  198. edb93xx_register_fb();
  199. edb93xx_register_ide();
  200. ep93xx_register_adc();
  201. }
  202. #ifdef CONFIG_MACH_EDB9301
  203. MACHINE_START(EDB9301, "Cirrus Logic EDB9301 Evaluation Board")
  204. /* Maintainer: H Hartley Sweeten <hsweeten@visionengravers.com> */
  205. .atag_offset = 0x100,
  206. .map_io = ep93xx_map_io,
  207. .init_irq = ep93xx_init_irq,
  208. .init_time = ep93xx_timer_init,
  209. .init_machine = edb93xx_init_machine,
  210. .init_late = ep93xx_init_late,
  211. .restart = ep93xx_restart,
  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. .atag_offset = 0x100,
  218. .map_io = ep93xx_map_io,
  219. .init_irq = ep93xx_init_irq,
  220. .init_time = ep93xx_timer_init,
  221. .init_machine = edb93xx_init_machine,
  222. .init_late = ep93xx_init_late,
  223. .restart = ep93xx_restart,
  224. MACHINE_END
  225. #endif
  226. #ifdef CONFIG_MACH_EDB9302A
  227. MACHINE_START(EDB9302A, "Cirrus Logic EDB9302A Evaluation Board")
  228. /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
  229. .atag_offset = 0x100,
  230. .map_io = ep93xx_map_io,
  231. .init_irq = ep93xx_init_irq,
  232. .init_time = ep93xx_timer_init,
  233. .init_machine = edb93xx_init_machine,
  234. .init_late = ep93xx_init_late,
  235. .restart = ep93xx_restart,
  236. MACHINE_END
  237. #endif
  238. #ifdef CONFIG_MACH_EDB9307
  239. MACHINE_START(EDB9307, "Cirrus Logic EDB9307 Evaluation Board")
  240. /* Maintainer: Herbert Valerio Riedel <hvr@gnu.org> */
  241. .atag_offset = 0x100,
  242. .map_io = ep93xx_map_io,
  243. .init_irq = ep93xx_init_irq,
  244. .init_time = ep93xx_timer_init,
  245. .init_machine = edb93xx_init_machine,
  246. .init_late = ep93xx_init_late,
  247. .restart = ep93xx_restart,
  248. MACHINE_END
  249. #endif
  250. #ifdef CONFIG_MACH_EDB9307A
  251. MACHINE_START(EDB9307A, "Cirrus Logic EDB9307A Evaluation Board")
  252. /* Maintainer: H Hartley Sweeten <hsweeten@visionengravers.com> */
  253. .atag_offset = 0x100,
  254. .map_io = ep93xx_map_io,
  255. .init_irq = ep93xx_init_irq,
  256. .init_time = ep93xx_timer_init,
  257. .init_machine = edb93xx_init_machine,
  258. .init_late = ep93xx_init_late,
  259. .restart = ep93xx_restart,
  260. MACHINE_END
  261. #endif
  262. #ifdef CONFIG_MACH_EDB9312
  263. MACHINE_START(EDB9312, "Cirrus Logic EDB9312 Evaluation Board")
  264. /* Maintainer: Toufeeq Hussain <toufeeq_hussain@infosys.com> */
  265. .atag_offset = 0x100,
  266. .map_io = ep93xx_map_io,
  267. .init_irq = ep93xx_init_irq,
  268. .init_time = ep93xx_timer_init,
  269. .init_machine = edb93xx_init_machine,
  270. .init_late = ep93xx_init_late,
  271. .restart = ep93xx_restart,
  272. MACHINE_END
  273. #endif
  274. #ifdef CONFIG_MACH_EDB9315
  275. MACHINE_START(EDB9315, "Cirrus Logic EDB9315 Evaluation Board")
  276. /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
  277. .atag_offset = 0x100,
  278. .map_io = ep93xx_map_io,
  279. .init_irq = ep93xx_init_irq,
  280. .init_time = ep93xx_timer_init,
  281. .init_machine = edb93xx_init_machine,
  282. .init_late = ep93xx_init_late,
  283. .restart = ep93xx_restart,
  284. MACHINE_END
  285. #endif
  286. #ifdef CONFIG_MACH_EDB9315A
  287. MACHINE_START(EDB9315A, "Cirrus Logic EDB9315A Evaluation Board")
  288. /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
  289. .atag_offset = 0x100,
  290. .map_io = ep93xx_map_io,
  291. .init_irq = ep93xx_init_irq,
  292. .init_time = ep93xx_timer_init,
  293. .init_machine = edb93xx_init_machine,
  294. .init_late = ep93xx_init_late,
  295. .restart = ep93xx_restart,
  296. MACHINE_END
  297. #endif