edb93xx.c 9.6 KB

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