board-armadillo800eva-reference.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /*
  2. * armadillo 800 eva board support
  3. *
  4. * Copyright (C) 2012 Renesas Solutions Corp.
  5. * Copyright (C) 2012 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; version 2 of the License.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. *
  20. */
  21. #include <linux/clk.h>
  22. #include <linux/err.h>
  23. #include <linux/kernel.h>
  24. #include <linux/gpio.h>
  25. #include <linux/io.h>
  26. #include <mach/common.h>
  27. #include <mach/r8a7740.h>
  28. #include <asm/mach/arch.h>
  29. #include <asm/hardware/cache-l2x0.h>
  30. /*
  31. * CON1 Camera Module
  32. * CON2 Extension Bus
  33. * CON3 HDMI Output
  34. * CON4 Composite Video Output
  35. * CON5 H-UDI JTAG
  36. * CON6 ARM JTAG
  37. * CON7 SD1
  38. * CON8 SD2
  39. * CON9 RTC BackUp
  40. * CON10 Monaural Mic Input
  41. * CON11 Stereo Headphone Output
  42. * CON12 Audio Line Output(L)
  43. * CON13 Audio Line Output(R)
  44. * CON14 AWL13 Module
  45. * CON15 Extension
  46. * CON16 LCD1
  47. * CON17 LCD2
  48. * CON19 Power Input
  49. * CON20 USB1
  50. * CON21 USB2
  51. * CON22 Serial
  52. * CON23 LAN
  53. * CON24 USB3
  54. * LED1 Camera LED(Yellow)
  55. * LED2 Power LED (Green)
  56. * ED3-LED6 User LED(Yellow)
  57. * LED7 LAN link LED(Green)
  58. * LED8 LAN activity LED(Yellow)
  59. */
  60. /*
  61. * DipSwitch
  62. *
  63. * SW1
  64. *
  65. * -12345678-+---------------+----------------------------
  66. * 1 | boot | hermit
  67. * 0 | boot | OS auto boot
  68. * -12345678-+---------------+----------------------------
  69. * 00 | boot device | eMMC
  70. * 10 | boot device | SDHI0 (CON7)
  71. * 01 | boot device | -
  72. * 11 | boot device | Extension Buss (CS0)
  73. * -12345678-+---------------+----------------------------
  74. * 0 | Extension Bus | D8-D15 disable, eMMC enable
  75. * 1 | Extension Bus | D8-D15 enable, eMMC disable
  76. * -12345678-+---------------+----------------------------
  77. * 0 | SDHI1 | COM8 disable, COM14 enable
  78. * 1 | SDHI1 | COM8 enable, COM14 disable
  79. * -12345678-+---------------+----------------------------
  80. * 0 | USB0 | COM20 enable, COM24 disable
  81. * 1 | USB0 | COM20 disable, COM24 enable
  82. * -12345678-+---------------+----------------------------
  83. * 00 | JTAG | SH-X2
  84. * 10 | JTAG | ARM
  85. * 01 | JTAG | -
  86. * 11 | JTAG | Boundary Scan
  87. *-----------+---------------+----------------------------
  88. */
  89. /*
  90. * FSI-WM8978
  91. *
  92. * this command is required when playback.
  93. *
  94. * # amixer set "Headphone" 50
  95. *
  96. * this command is required when capture.
  97. *
  98. * # amixer set "Input PGA" 15
  99. * # amixer set "Left Input Mixer MicP" on
  100. * # amixer set "Left Input Mixer MicN" on
  101. * # amixer set "Right Input Mixer MicN" on
  102. * # amixer set "Right Input Mixer MicP" on
  103. */
  104. /*
  105. * USB function
  106. *
  107. * When you use USB Function,
  108. * set SW1.6 ON, and connect cable to CN24.
  109. *
  110. * USBF needs workaround on R8A7740 chip.
  111. * These are a little bit complex.
  112. * see
  113. * usbhsf_power_ctrl()
  114. */
  115. static void __init eva_clock_init(void)
  116. {
  117. struct clk *system = clk_get(NULL, "system_clk");
  118. struct clk *xtal1 = clk_get(NULL, "extal1");
  119. struct clk *usb24s = clk_get(NULL, "usb24s");
  120. struct clk *fsibck = clk_get(NULL, "fsibck");
  121. if (IS_ERR(system) ||
  122. IS_ERR(xtal1) ||
  123. IS_ERR(usb24s) ||
  124. IS_ERR(fsibck)) {
  125. pr_err("armadillo800eva board clock init failed\n");
  126. goto clock_error;
  127. }
  128. /* armadillo 800 eva extal1 is 24MHz */
  129. clk_set_rate(xtal1, 24000000);
  130. /* usb24s use extal1 (= system) clock (= 24MHz) */
  131. clk_set_parent(usb24s, system);
  132. /* FSIBCK is 12.288MHz, and it is parent of FSI-B */
  133. clk_set_rate(fsibck, 12288000);
  134. clock_error:
  135. if (!IS_ERR(system))
  136. clk_put(system);
  137. if (!IS_ERR(xtal1))
  138. clk_put(xtal1);
  139. if (!IS_ERR(usb24s))
  140. clk_put(usb24s);
  141. if (!IS_ERR(fsibck))
  142. clk_put(fsibck);
  143. }
  144. /*
  145. * board init
  146. */
  147. static void __init eva_init(void)
  148. {
  149. r8a7740_clock_init(MD_CK0 | MD_CK2);
  150. eva_clock_init();
  151. r8a7740_meram_workaround();
  152. #ifdef CONFIG_CACHE_L2X0
  153. /* Early BRESP enable, Shared attribute override enable, 32K*8way */
  154. l2x0_init(IOMEM(0xf0002000), 0x40440000, 0x82000fff);
  155. #endif
  156. r8a7740_add_standard_devices_dt();
  157. r8a7740_pm_init();
  158. }
  159. #define RESCNT2 IOMEM(0xe6188020)
  160. static void eva_restart(enum reboot_mode mode, const char *cmd)
  161. {
  162. /* Do soft power on reset */
  163. writel(1 << 31, RESCNT2);
  164. }
  165. static const char *eva_boards_compat_dt[] __initdata = {
  166. "renesas,armadillo800eva-reference",
  167. NULL,
  168. };
  169. DT_MACHINE_START(ARMADILLO800EVA_DT, "armadillo800eva-reference")
  170. .map_io = r8a7740_map_io,
  171. .init_early = r8a7740_init_delay,
  172. .init_irq = r8a7740_init_irq_of,
  173. .init_machine = eva_init,
  174. .init_late = shmobile_init_late,
  175. .dt_compat = eva_boards_compat_dt,
  176. .restart = eva_restart,
  177. MACHINE_END