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