edb93xx.c 9.6 KB

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