xref: /rk3399_rockchip-uboot/arch/arm/mach-uniphier/board_init.c (revision 5ac9dfbe9d9a19b04ddb306e7d6833861f9b6f72)
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 
9 #include <common.h>
10 #include <libfdt.h>
11 #include <linux/io.h>
12 
13 #include "init.h"
14 #include "micro-support-card.h"
15 #include "soc-info.h"
16 
17 DECLARE_GLOBAL_DATA_PTR;
18 
19 static void uniphier_setup_xirq(void)
20 {
21 	const void *fdt = gd->fdt_blob;
22 	int soc_node, aidet_node;
23 	const u32 *val;
24 	unsigned long aidet_base;
25 	u32 tmp;
26 
27 	soc_node = fdt_path_offset(fdt, "/soc");
28 	if (soc_node < 0)
29 		return;
30 
31 	aidet_node = fdt_subnode_offset_namelen(fdt, soc_node, "aidet", 5);
32 	if (aidet_node < 0)
33 		return;
34 
35 	val = fdt_getprop(fdt, aidet_node, "reg", NULL);
36 	if (!val)
37 		return;
38 
39 	aidet_base = fdt32_to_cpu(*val);
40 
41 	tmp = readl(aidet_base + 8);	/* AIDET DETCONFR2 */
42 	tmp |= 0x00ff0000;		/* Set XIRQ0-7 low active */
43 	writel(tmp, aidet_base + 8);
44 
45 	tmp = readl(0x55000090);	/* IRQCTL */
46 	tmp |= 0x000000ff;
47 	writel(tmp, 0x55000090);
48 }
49 
50 static void uniphier_nand_pin_init(bool cs2)
51 {
52 #ifdef CONFIG_NAND_DENALI
53 	if (uniphier_pin_init(cs2 ? "nand2cs_grp" : "nand_grp"))
54 		pr_err("failed to init NAND pins\n");
55 #endif
56 }
57 
58 int board_init(void)
59 {
60 	led_puts("U0");
61 
62 	switch (uniphier_get_soc_type()) {
63 #if defined(CONFIG_ARCH_UNIPHIER_SLD3)
64 	case SOC_UNIPHIER_SLD3:
65 		uniphier_nand_pin_init(true);
66 		led_puts("U1");
67 		uniphier_ld4_clk_init();
68 		break;
69 #endif
70 #if defined(CONFIG_ARCH_UNIPHIER_LD4)
71 	case SOC_UNIPHIER_LD4:
72 		uniphier_nand_pin_init(true);
73 		led_puts("U1");
74 		uniphier_ld4_clk_init();
75 		break;
76 #endif
77 #if defined(CONFIG_ARCH_UNIPHIER_PRO4)
78 	case SOC_UNIPHIER_PRO4:
79 		uniphier_nand_pin_init(false);
80 		led_puts("U1");
81 		uniphier_pro4_clk_init();
82 		break;
83 #endif
84 #if defined(CONFIG_ARCH_UNIPHIER_SLD8)
85 	case SOC_UNIPHIER_SLD8:
86 		uniphier_nand_pin_init(true);
87 		led_puts("U1");
88 		uniphier_ld4_clk_init();
89 		break;
90 #endif
91 #if defined(CONFIG_ARCH_UNIPHIER_PRO5)
92 	case SOC_UNIPHIER_PRO5:
93 		uniphier_nand_pin_init(true);
94 		led_puts("U1");
95 		uniphier_pro5_clk_init();
96 		break;
97 #endif
98 #if defined(CONFIG_ARCH_UNIPHIER_PXS2)
99 	case SOC_UNIPHIER_PXS2:
100 		uniphier_nand_pin_init(true);
101 		led_puts("U1");
102 		uniphier_pxs2_clk_init();
103 		break;
104 #endif
105 #if defined(CONFIG_ARCH_UNIPHIER_LD6B)
106 	case SOC_UNIPHIER_LD6B:
107 		uniphier_nand_pin_init(true);
108 		led_puts("U1");
109 		uniphier_pxs2_clk_init();
110 		break;
111 #endif
112 #if defined(CONFIG_ARCH_UNIPHIER_LD11)
113 	case SOC_UNIPHIER_LD11:
114 		uniphier_nand_pin_init(false);
115 		uniphier_ld20_pin_init();
116 		led_puts("U1");
117 		uniphier_ld11_clk_init();
118 		break;
119 #endif
120 #if defined(CONFIG_ARCH_UNIPHIER_LD20)
121 	case SOC_UNIPHIER_LD20:
122 		uniphier_nand_pin_init(false);
123 		uniphier_ld20_pin_init();
124 		led_puts("U1");
125 		uniphier_ld20_clk_init();
126 		cci500_init(2);
127 		break;
128 #endif
129 	default:
130 		break;
131 	}
132 
133 	uniphier_setup_xirq();
134 
135 	led_puts("U2");
136 
137 	support_card_late_init();
138 
139 	led_puts("U3");
140 
141 #ifdef CONFIG_ARM64
142 	uniphier_smp_kick_all_cpus();
143 #endif
144 
145 	led_puts("Uboo");
146 
147 	return 0;
148 }
149