edb93xx.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  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 <linux/platform_data/video-ep93xx.h>
  36. #include <linux/platform_data/spi-ep93xx.h>
  37. #include <mach/gpio-ep93xx.h>
  38. #include <asm/mach-types.h>
  39. #include <asm/mach/arch.h>
  40. #include "soc.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_edb9302() || machine_is_edb9307()
  82. || machine_is_edb9312() || 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. .flags = 0,
  179. };
  180. static int __init edb93xx_has_fb(void)
  181. {
  182. /* These platforms have an ep93xx with video capability */
  183. return machine_is_edb9307() || machine_is_edb9307a() ||
  184. machine_is_edb9312() || machine_is_edb9315() ||
  185. machine_is_edb9315a();
  186. }
  187. static void __init edb93xx_register_fb(void)
  188. {
  189. if (!edb93xx_has_fb())
  190. return;
  191. if (machine_is_edb9307a() || machine_is_edb9315a())
  192. edb93xxfb_info.flags |= EP93XXFB_USE_SDCSN0;
  193. else
  194. edb93xxfb_info.flags |= EP93XXFB_USE_SDCSN3;
  195. ep93xx_register_fb(&edb93xxfb_info);
  196. }
  197. /*************************************************************************
  198. * EDB93xx IDE
  199. *************************************************************************/
  200. static int __init edb93xx_has_ide(void)
  201. {
  202. /*
  203. * Although EDB9312 and EDB9315 do have IDE capability, they have
  204. * INTRQ line wired as pull-up, which makes using IDE interface
  205. * problematic.
  206. */
  207. return machine_is_edb9312() || machine_is_edb9315() ||
  208. machine_is_edb9315a();
  209. }
  210. static void __init edb93xx_register_ide(void)
  211. {
  212. if (!edb93xx_has_ide())
  213. return;
  214. ep93xx_register_ide();
  215. }
  216. static void __init edb93xx_init_machine(void)
  217. {
  218. ep93xx_init_devices();
  219. edb93xx_register_flash();
  220. ep93xx_register_eth(&edb93xx_eth_data, 1);
  221. edb93xx_register_i2c();
  222. edb93xx_register_spi();
  223. edb93xx_register_i2s();
  224. edb93xx_register_pwm();
  225. edb93xx_register_fb();
  226. edb93xx_register_ide();
  227. }
  228. #ifdef CONFIG_MACH_EDB9301
  229. MACHINE_START(EDB9301, "Cirrus Logic EDB9301 Evaluation Board")
  230. /* Maintainer: H Hartley Sweeten <hsweeten@visionengravers.com> */
  231. .atag_offset = 0x100,
  232. .map_io = ep93xx_map_io,
  233. .init_irq = ep93xx_init_irq,
  234. .init_time = ep93xx_timer_init,
  235. .init_machine = edb93xx_init_machine,
  236. .init_late = ep93xx_init_late,
  237. .restart = ep93xx_restart,
  238. MACHINE_END
  239. #endif
  240. #ifdef CONFIG_MACH_EDB9302
  241. MACHINE_START(EDB9302, "Cirrus Logic EDB9302 Evaluation Board")
  242. /* Maintainer: George Kashperko <george@chas.com.ua> */
  243. .atag_offset = 0x100,
  244. .map_io = ep93xx_map_io,
  245. .init_irq = ep93xx_init_irq,
  246. .init_time = ep93xx_timer_init,
  247. .init_machine = edb93xx_init_machine,
  248. .init_late = ep93xx_init_late,
  249. .restart = ep93xx_restart,
  250. MACHINE_END
  251. #endif
  252. #ifdef CONFIG_MACH_EDB9302A
  253. MACHINE_START(EDB9302A, "Cirrus Logic EDB9302A Evaluation Board")
  254. /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
  255. .atag_offset = 0x100,
  256. .map_io = ep93xx_map_io,
  257. .init_irq = ep93xx_init_irq,
  258. .init_time = ep93xx_timer_init,
  259. .init_machine = edb93xx_init_machine,
  260. .init_late = ep93xx_init_late,
  261. .restart = ep93xx_restart,
  262. MACHINE_END
  263. #endif
  264. #ifdef CONFIG_MACH_EDB9307
  265. MACHINE_START(EDB9307, "Cirrus Logic EDB9307 Evaluation Board")
  266. /* Maintainer: Herbert Valerio Riedel <hvr@gnu.org> */
  267. .atag_offset = 0x100,
  268. .map_io = ep93xx_map_io,
  269. .init_irq = ep93xx_init_irq,
  270. .init_time = ep93xx_timer_init,
  271. .init_machine = edb93xx_init_machine,
  272. .init_late = ep93xx_init_late,
  273. .restart = ep93xx_restart,
  274. MACHINE_END
  275. #endif
  276. #ifdef CONFIG_MACH_EDB9307A
  277. MACHINE_START(EDB9307A, "Cirrus Logic EDB9307A Evaluation Board")
  278. /* Maintainer: H Hartley Sweeten <hsweeten@visionengravers.com> */
  279. .atag_offset = 0x100,
  280. .map_io = ep93xx_map_io,
  281. .init_irq = ep93xx_init_irq,
  282. .init_time = ep93xx_timer_init,
  283. .init_machine = edb93xx_init_machine,
  284. .init_late = ep93xx_init_late,
  285. .restart = ep93xx_restart,
  286. MACHINE_END
  287. #endif
  288. #ifdef CONFIG_MACH_EDB9312
  289. MACHINE_START(EDB9312, "Cirrus Logic EDB9312 Evaluation Board")
  290. /* Maintainer: Toufeeq Hussain <toufeeq_hussain@infosys.com> */
  291. .atag_offset = 0x100,
  292. .map_io = ep93xx_map_io,
  293. .init_irq = ep93xx_init_irq,
  294. .init_time = ep93xx_timer_init,
  295. .init_machine = edb93xx_init_machine,
  296. .init_late = ep93xx_init_late,
  297. .restart = ep93xx_restart,
  298. MACHINE_END
  299. #endif
  300. #ifdef CONFIG_MACH_EDB9315
  301. MACHINE_START(EDB9315, "Cirrus Logic EDB9315 Evaluation Board")
  302. /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
  303. .atag_offset = 0x100,
  304. .map_io = ep93xx_map_io,
  305. .init_irq = ep93xx_init_irq,
  306. .init_time = ep93xx_timer_init,
  307. .init_machine = edb93xx_init_machine,
  308. .init_late = ep93xx_init_late,
  309. .restart = ep93xx_restart,
  310. MACHINE_END
  311. #endif
  312. #ifdef CONFIG_MACH_EDB9315A
  313. MACHINE_START(EDB9315A, "Cirrus Logic EDB9315A Evaluation Board")
  314. /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
  315. .atag_offset = 0x100,
  316. .map_io = ep93xx_map_io,
  317. .init_irq = ep93xx_init_irq,
  318. .init_time = ep93xx_timer_init,
  319. .init_machine = edb93xx_init_machine,
  320. .init_late = ep93xx_init_late,
  321. .restart = ep93xx_restart,
  322. MACHINE_END
  323. #endif