board_init.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. /*
  2. * Copyright (C) 2012-2015 Panasonic Corporation
  3. * Copyright (C) 2015-2016 Socionext Inc.
  4. * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #include <common.h>
  9. #include <libfdt.h>
  10. #include <linux/io.h>
  11. #include "init.h"
  12. #include "micro-support-card.h"
  13. #include "sg-regs.h"
  14. #include "soc-info.h"
  15. DECLARE_GLOBAL_DATA_PTR;
  16. static void uniphier_setup_xirq(void)
  17. {
  18. const void *fdt = gd->fdt_blob;
  19. int soc_node, aidet_node;
  20. const u32 *val;
  21. unsigned long aidet_base;
  22. u32 tmp;
  23. soc_node = fdt_path_offset(fdt, "/soc");
  24. if (soc_node < 0)
  25. return;
  26. aidet_node = fdt_subnode_offset_namelen(fdt, soc_node, "aidet", 5);
  27. if (aidet_node < 0)
  28. return;
  29. val = fdt_getprop(fdt, aidet_node, "reg", NULL);
  30. if (!val)
  31. return;
  32. aidet_base = fdt32_to_cpu(*val);
  33. tmp = readl(aidet_base + 8); /* AIDET DETCONFR2 */
  34. tmp |= 0x00ff0000; /* Set XIRQ0-7 low active */
  35. writel(tmp, aidet_base + 8);
  36. tmp = readl(0x55000090); /* IRQCTL */
  37. tmp |= 0x000000ff;
  38. writel(tmp, 0x55000090);
  39. }
  40. #ifdef CONFIG_ARCH_UNIPHIER_LD11
  41. static void uniphier_ld11_misc_init(void)
  42. {
  43. sg_set_pinsel(149, 14, 8, 4); /* XIRQ0 -> XIRQ0 */
  44. sg_set_iectrl(149);
  45. sg_set_pinsel(153, 14, 8, 4); /* XIRQ4 -> XIRQ4 */
  46. sg_set_iectrl(153);
  47. }
  48. #endif
  49. #ifdef CONFIG_ARCH_UNIPHIER_LD20
  50. static void uniphier_ld20_misc_init(void)
  51. {
  52. sg_set_pinsel(149, 14, 8, 4); /* XIRQ0 -> XIRQ0 */
  53. sg_set_iectrl(149);
  54. sg_set_pinsel(153, 14, 8, 4); /* XIRQ4 -> XIRQ4 */
  55. sg_set_iectrl(153);
  56. /* ES1 errata: increase VDD09 supply to suppress VBO noise */
  57. if (uniphier_get_soc_revision() == 1) {
  58. writel(0x00000003, 0x6184e004);
  59. writel(0x00000100, 0x6184e040);
  60. writel(0x0000b500, 0x6184e024);
  61. writel(0x00000001, 0x6184e000);
  62. }
  63. #ifdef CONFIG_ARMV8_MULTIENTRY
  64. cci500_init(2);
  65. #endif
  66. }
  67. #endif
  68. struct uniphier_initdata {
  69. unsigned int soc_id;
  70. bool nand_2cs;
  71. void (*sbc_init)(void);
  72. void (*pll_init)(void);
  73. void (*clk_init)(void);
  74. void (*misc_init)(void);
  75. };
  76. static const struct uniphier_initdata uniphier_initdata[] = {
  77. #if defined(CONFIG_ARCH_UNIPHIER_SLD3)
  78. {
  79. .soc_id = UNIPHIER_SLD3_ID,
  80. .nand_2cs = true,
  81. .sbc_init = uniphier_sbc_init_admulti,
  82. .pll_init = uniphier_sld3_pll_init,
  83. .clk_init = uniphier_ld4_clk_init,
  84. },
  85. #endif
  86. #if defined(CONFIG_ARCH_UNIPHIER_LD4)
  87. {
  88. .soc_id = UNIPHIER_LD4_ID,
  89. .nand_2cs = true,
  90. .sbc_init = uniphier_ld4_sbc_init,
  91. .pll_init = uniphier_ld4_pll_init,
  92. .clk_init = uniphier_ld4_clk_init,
  93. },
  94. #endif
  95. #if defined(CONFIG_ARCH_UNIPHIER_PRO4)
  96. {
  97. .soc_id = UNIPHIER_PRO4_ID,
  98. .nand_2cs = false,
  99. .sbc_init = uniphier_sbc_init_savepin,
  100. .pll_init = uniphier_pro4_pll_init,
  101. .clk_init = uniphier_pro4_clk_init,
  102. },
  103. #endif
  104. #if defined(CONFIG_ARCH_UNIPHIER_SLD8)
  105. {
  106. .soc_id = UNIPHIER_SLD8_ID,
  107. .nand_2cs = true,
  108. .sbc_init = uniphier_ld4_sbc_init,
  109. .pll_init = uniphier_ld4_pll_init,
  110. .clk_init = uniphier_ld4_clk_init,
  111. },
  112. #endif
  113. #if defined(CONFIG_ARCH_UNIPHIER_PRO5)
  114. {
  115. .soc_id = UNIPHIER_PRO5_ID,
  116. .nand_2cs = true,
  117. .sbc_init = uniphier_sbc_init_savepin,
  118. .clk_init = uniphier_pro5_clk_init,
  119. },
  120. #endif
  121. #if defined(CONFIG_ARCH_UNIPHIER_PXS2)
  122. {
  123. .soc_id = UNIPHIER_PXS2_ID,
  124. .nand_2cs = true,
  125. .sbc_init = uniphier_pxs2_sbc_init,
  126. .clk_init = uniphier_pxs2_clk_init,
  127. },
  128. #endif
  129. #if defined(CONFIG_ARCH_UNIPHIER_LD6B)
  130. {
  131. .soc_id = UNIPHIER_LD6B_ID,
  132. .nand_2cs = true,
  133. .sbc_init = uniphier_pxs2_sbc_init,
  134. .clk_init = uniphier_pxs2_clk_init,
  135. },
  136. #endif
  137. #if defined(CONFIG_ARCH_UNIPHIER_LD11)
  138. {
  139. .soc_id = UNIPHIER_LD11_ID,
  140. .nand_2cs = false,
  141. .sbc_init = uniphier_ld11_sbc_init,
  142. .pll_init = uniphier_ld11_pll_init,
  143. .clk_init = uniphier_ld11_clk_init,
  144. .misc_init = uniphier_ld11_misc_init,
  145. },
  146. #endif
  147. #if defined(CONFIG_ARCH_UNIPHIER_LD20)
  148. {
  149. .soc_id = UNIPHIER_LD20_ID,
  150. .nand_2cs = false,
  151. .sbc_init = uniphier_ld11_sbc_init,
  152. .pll_init = uniphier_ld20_pll_init,
  153. .clk_init = uniphier_ld20_clk_init,
  154. .misc_init = uniphier_ld20_misc_init,
  155. },
  156. #endif
  157. #if defined(CONFIG_ARCH_UNIPHIER_PXS3)
  158. {
  159. .soc_id = UNIPHIER_PXS3_ID,
  160. .nand_2cs = false,
  161. .sbc_init = uniphier_pxs2_sbc_init,
  162. .pll_init = uniphier_pxs3_pll_init,
  163. .clk_init = uniphier_pxs3_clk_init,
  164. },
  165. #endif
  166. };
  167. UNIPHIER_DEFINE_SOCDATA_FUNC(uniphier_get_initdata, uniphier_initdata)
  168. int board_init(void)
  169. {
  170. const struct uniphier_initdata *initdata;
  171. int ret;
  172. led_puts("U0");
  173. initdata = uniphier_get_initdata();
  174. if (!initdata) {
  175. pr_err("unsupported SoC\n");
  176. return -EINVAL;
  177. }
  178. initdata->sbc_init();
  179. support_card_init();
  180. led_puts("U0");
  181. if (IS_ENABLED(CONFIG_NAND_DENALI)) {
  182. ret = uniphier_pin_init(initdata->nand_2cs ?
  183. "nand2cs_grp" : "nand_grp");
  184. if (ret)
  185. pr_err("failed to init NAND pins\n");
  186. }
  187. led_puts("U1");
  188. if (initdata->pll_init)
  189. initdata->pll_init();
  190. led_puts("U2");
  191. if (initdata->clk_init)
  192. initdata->clk_init();
  193. led_puts("U3");
  194. if (initdata->misc_init)
  195. initdata->misc_init();
  196. led_puts("U4");
  197. uniphier_setup_xirq();
  198. led_puts("U5");
  199. support_card_late_init();
  200. led_puts("U6");
  201. #ifdef CONFIG_ARMV8_MULTIENTRY
  202. uniphier_smp_kick_all_cpus();
  203. #endif
  204. led_puts("Uboo");
  205. return 0;
  206. }