board_init.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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. cci500_init(2);
  64. }
  65. #endif
  66. struct uniphier_initdata {
  67. enum uniphier_soc_id soc_id;
  68. bool nand_2cs;
  69. void (*sbc_init)(void);
  70. void (*pll_init)(void);
  71. void (*clk_init)(void);
  72. void (*misc_init)(void);
  73. };
  74. static const struct uniphier_initdata uniphier_initdata[] = {
  75. #if defined(CONFIG_ARCH_UNIPHIER_SLD3)
  76. {
  77. .soc_id = SOC_UNIPHIER_SLD3,
  78. .nand_2cs = true,
  79. .sbc_init = uniphier_sbc_init_admulti,
  80. .pll_init = uniphier_sld3_pll_init,
  81. .clk_init = uniphier_ld4_clk_init,
  82. },
  83. #endif
  84. #if defined(CONFIG_ARCH_UNIPHIER_LD4)
  85. {
  86. .soc_id = SOC_UNIPHIER_LD4,
  87. .nand_2cs = true,
  88. .sbc_init = uniphier_ld4_sbc_init,
  89. .pll_init = uniphier_ld4_pll_init,
  90. .clk_init = uniphier_ld4_clk_init,
  91. },
  92. #endif
  93. #if defined(CONFIG_ARCH_UNIPHIER_PRO4)
  94. {
  95. .soc_id = SOC_UNIPHIER_PRO4,
  96. .nand_2cs = false,
  97. .sbc_init = uniphier_sbc_init_savepin,
  98. .pll_init = uniphier_pro4_pll_init,
  99. .clk_init = uniphier_pro4_clk_init,
  100. },
  101. #endif
  102. #if defined(CONFIG_ARCH_UNIPHIER_SLD8)
  103. {
  104. .soc_id = SOC_UNIPHIER_SLD8,
  105. .nand_2cs = true,
  106. .sbc_init = uniphier_ld4_sbc_init,
  107. .pll_init = uniphier_ld4_pll_init,
  108. .clk_init = uniphier_ld4_clk_init,
  109. },
  110. #endif
  111. #if defined(CONFIG_ARCH_UNIPHIER_PRO5)
  112. {
  113. .soc_id = SOC_UNIPHIER_PRO5,
  114. .nand_2cs = true,
  115. .sbc_init = uniphier_sbc_init_savepin,
  116. .clk_init = uniphier_pro5_clk_init,
  117. },
  118. #endif
  119. #if defined(CONFIG_ARCH_UNIPHIER_PXS2)
  120. {
  121. .soc_id = SOC_UNIPHIER_PXS2,
  122. .nand_2cs = true,
  123. .sbc_init = uniphier_pxs2_sbc_init,
  124. .clk_init = uniphier_pxs2_clk_init,
  125. },
  126. #endif
  127. #if defined(CONFIG_ARCH_UNIPHIER_LD6B)
  128. {
  129. .soc_id = SOC_UNIPHIER_LD6B,
  130. .nand_2cs = true,
  131. .sbc_init = uniphier_pxs2_sbc_init,
  132. .clk_init = uniphier_pxs2_clk_init,
  133. },
  134. #endif
  135. #if defined(CONFIG_ARCH_UNIPHIER_LD11)
  136. {
  137. .soc_id = SOC_UNIPHIER_LD11,
  138. .nand_2cs = false,
  139. .sbc_init = uniphier_ld11_sbc_init,
  140. .pll_init = uniphier_ld11_pll_init,
  141. .clk_init = uniphier_ld11_clk_init,
  142. .misc_init = uniphier_ld11_misc_init,
  143. },
  144. #endif
  145. #if defined(CONFIG_ARCH_UNIPHIER_LD20)
  146. {
  147. .soc_id = SOC_UNIPHIER_LD20,
  148. .nand_2cs = false,
  149. .sbc_init = uniphier_ld11_sbc_init,
  150. .pll_init = uniphier_ld20_pll_init,
  151. .misc_init = uniphier_ld20_misc_init,
  152. },
  153. #endif
  154. };
  155. static const struct uniphier_initdata *uniphier_get_initdata(
  156. enum uniphier_soc_id soc_id)
  157. {
  158. int i;
  159. for (i = 0; i < ARRAY_SIZE(uniphier_initdata); i++) {
  160. if (uniphier_initdata[i].soc_id == soc_id)
  161. return &uniphier_initdata[i];
  162. }
  163. return NULL;
  164. }
  165. int board_init(void)
  166. {
  167. const struct uniphier_initdata *initdata;
  168. enum uniphier_soc_id soc_id;
  169. int ret;
  170. led_puts("U0");
  171. soc_id = uniphier_get_soc_type();
  172. initdata = uniphier_get_initdata(soc_id);
  173. if (!initdata) {
  174. pr_err("unsupported board\n");
  175. return -EINVAL;
  176. }
  177. initdata->sbc_init();
  178. support_card_init();
  179. led_puts("U0");
  180. if (IS_ENABLED(CONFIG_NAND_DENALI)) {
  181. ret = uniphier_pin_init(initdata->nand_2cs ?
  182. "nand2cs_grp" : "nand_grp");
  183. if (ret)
  184. pr_err("failed to init NAND pins\n");
  185. }
  186. led_puts("U1");
  187. if (initdata->pll_init)
  188. initdata->pll_init();
  189. led_puts("U2");
  190. if (initdata->clk_init)
  191. initdata->clk_init();
  192. led_puts("U3");
  193. if (initdata->misc_init)
  194. initdata->misc_init();
  195. led_puts("U4");
  196. uniphier_setup_xirq();
  197. led_puts("U5");
  198. support_card_late_init();
  199. led_puts("U6");
  200. #ifdef CONFIG_ARM64
  201. uniphier_smp_kick_all_cpus();
  202. #endif
  203. led_puts("Uboo");
  204. return 0;
  205. }