edb93xx.c 9.3 KB

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