board-armadillo800eva-reference.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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 <linux/pinctrl/machine.h>
  27. #include <mach/common.h>
  28. #include <mach/r8a7740.h>
  29. #include <asm/mach/arch.h>
  30. #include <asm/hardware/cache-l2x0.h>
  31. /*
  32. * CON1 Camera Module
  33. * CON2 Extension Bus
  34. * CON3 HDMI Output
  35. * CON4 Composite Video Output
  36. * CON5 H-UDI JTAG
  37. * CON6 ARM JTAG
  38. * CON7 SD1
  39. * CON8 SD2
  40. * CON9 RTC BackUp
  41. * CON10 Monaural Mic Input
  42. * CON11 Stereo Headphone Output
  43. * CON12 Audio Line Output(L)
  44. * CON13 Audio Line Output(R)
  45. * CON14 AWL13 Module
  46. * CON15 Extension
  47. * CON16 LCD1
  48. * CON17 LCD2
  49. * CON19 Power Input
  50. * CON20 USB1
  51. * CON21 USB2
  52. * CON22 Serial
  53. * CON23 LAN
  54. * CON24 USB3
  55. * LED1 Camera LED(Yellow)
  56. * LED2 Power LED (Green)
  57. * ED3-LED6 User LED(Yellow)
  58. * LED7 LAN link LED(Green)
  59. * LED8 LAN activity LED(Yellow)
  60. */
  61. /*
  62. * DipSwitch
  63. *
  64. * SW1
  65. *
  66. * -12345678-+---------------+----------------------------
  67. * 1 | boot | hermit
  68. * 0 | boot | OS auto boot
  69. * -12345678-+---------------+----------------------------
  70. * 00 | boot device | eMMC
  71. * 10 | boot device | SDHI0 (CON7)
  72. * 01 | boot device | -
  73. * 11 | boot device | Extension Buss (CS0)
  74. * -12345678-+---------------+----------------------------
  75. * 0 | Extension Bus | D8-D15 disable, eMMC enable
  76. * 1 | Extension Bus | D8-D15 enable, eMMC disable
  77. * -12345678-+---------------+----------------------------
  78. * 0 | SDHI1 | COM8 disable, COM14 enable
  79. * 1 | SDHI1 | COM8 enable, COM14 disable
  80. * -12345678-+---------------+----------------------------
  81. * 0 | USB0 | COM20 enable, COM24 disable
  82. * 1 | USB0 | COM20 disable, COM24 enable
  83. * -12345678-+---------------+----------------------------
  84. * 00 | JTAG | SH-X2
  85. * 10 | JTAG | ARM
  86. * 01 | JTAG | -
  87. * 11 | JTAG | Boundary Scan
  88. *-----------+---------------+----------------------------
  89. */
  90. /*
  91. * FSI-WM8978
  92. *
  93. * this command is required when playback.
  94. *
  95. * # amixer set "Headphone" 50
  96. *
  97. * this command is required when capture.
  98. *
  99. * # amixer set "Input PGA" 15
  100. * # amixer set "Left Input Mixer MicP" on
  101. * # amixer set "Left Input Mixer MicN" on
  102. * # amixer set "Right Input Mixer MicN" on
  103. * # amixer set "Right Input Mixer MicP" on
  104. */
  105. /*
  106. * USB function
  107. *
  108. * When you use USB Function,
  109. * set SW1.6 ON, and connect cable to CN24.
  110. *
  111. * USBF needs workaround on R8A7740 chip.
  112. * These are a little bit complex.
  113. * see
  114. * usbhsf_power_ctrl()
  115. */
  116. static const struct pinctrl_map eva_pinctrl_map[] = {
  117. /* SCIFA1 */
  118. PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.1", "pfc-r8a7740",
  119. "scifa1_data", "scifa1"),
  120. };
  121. static void __init eva_clock_init(void)
  122. {
  123. struct clk *system = clk_get(NULL, "system_clk");
  124. struct clk *xtal1 = clk_get(NULL, "extal1");
  125. struct clk *usb24s = clk_get(NULL, "usb24s");
  126. struct clk *fsibck = clk_get(NULL, "fsibck");
  127. if (IS_ERR(system) ||
  128. IS_ERR(xtal1) ||
  129. IS_ERR(usb24s) ||
  130. IS_ERR(fsibck)) {
  131. pr_err("armadillo800eva board clock init failed\n");
  132. goto clock_error;
  133. }
  134. /* armadillo 800 eva extal1 is 24MHz */
  135. clk_set_rate(xtal1, 24000000);
  136. /* usb24s use extal1 (= system) clock (= 24MHz) */
  137. clk_set_parent(usb24s, system);
  138. /* FSIBCK is 12.288MHz, and it is parent of FSI-B */
  139. clk_set_rate(fsibck, 12288000);
  140. clock_error:
  141. if (!IS_ERR(system))
  142. clk_put(system);
  143. if (!IS_ERR(xtal1))
  144. clk_put(xtal1);
  145. if (!IS_ERR(usb24s))
  146. clk_put(usb24s);
  147. if (!IS_ERR(fsibck))
  148. clk_put(fsibck);
  149. }
  150. /*
  151. * board init
  152. */
  153. static void __init eva_init(void)
  154. {
  155. r8a7740_clock_init(MD_CK0 | MD_CK2);
  156. eva_clock_init();
  157. pinctrl_register_mappings(eva_pinctrl_map, ARRAY_SIZE(eva_pinctrl_map));
  158. r8a7740_pinmux_init();
  159. r8a7740_meram_workaround();
  160. /*
  161. * Touchscreen
  162. * TODO: Move reset GPIO over to .dts when we can reference it
  163. */
  164. gpio_request_one(166, GPIOF_OUT_INIT_HIGH, NULL); /* TP_RST_B */
  165. #ifdef CONFIG_CACHE_L2X0
  166. /* Early BRESP enable, Shared attribute override enable, 32K*8way */
  167. l2x0_init(IOMEM(0xf0002000), 0x40440000, 0x82000fff);
  168. #endif
  169. r8a7740_add_standard_devices_dt();
  170. r8a7740_pm_init();
  171. }
  172. #define RESCNT2 IOMEM(0xe6188020)
  173. static void eva_restart(char mode, const char *cmd)
  174. {
  175. /* Do soft power on reset */
  176. writel((1 << 31), RESCNT2);
  177. }
  178. static const char *eva_boards_compat_dt[] __initdata = {
  179. "renesas,armadillo800eva-reference",
  180. NULL,
  181. };
  182. DT_MACHINE_START(ARMADILLO800EVA_DT, "armadillo800eva-reference")
  183. .map_io = r8a7740_map_io,
  184. .init_early = r8a7740_init_delay,
  185. .init_irq = r8a7740_init_irq_of,
  186. .init_machine = eva_init,
  187. .init_time = shmobile_timer_init,
  188. .init_late = shmobile_init_late,
  189. .dt_compat = eva_boards_compat_dt,
  190. .restart = eva_restart,
  191. MACHINE_END