ARM: uniphier: merge board init functions into board_init()
[platform/kernel/u-boot.git] / arch / arm / mach-uniphier / board_init.c
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 int board_init(void)
51 {
52         led_puts("U0");
53
54         switch (uniphier_get_soc_type()) {
55 #if defined(CONFIG_ARCH_UNIPHIER_SLD3)
56         case SOC_UNIPHIER_SLD3:
57                 uniphier_sld3_pin_init();
58                 led_puts("U1");
59                 uniphier_ld4_clk_init();
60                 break;
61 #endif
62 #if defined(CONFIG_ARCH_UNIPHIER_LD4)
63         case SOC_UNIPHIER_LD4:
64                 uniphier_ld4_pin_init();
65                 led_puts("U1");
66                 uniphier_ld4_clk_init();
67                 break;
68 #endif
69 #if defined(CONFIG_ARCH_UNIPHIER_PRO4)
70         case SOC_UNIPHIER_PRO4:
71                 uniphier_pro4_pin_init();
72                 led_puts("U1");
73                 uniphier_pro4_clk_init();
74                 break;
75 #endif
76 #if defined(CONFIG_ARCH_UNIPHIER_SLD8)
77         case SOC_UNIPHIER_SLD8:
78                 uniphier_sld8_pin_init();
79                 led_puts("U1");
80                 uniphier_ld4_clk_init();
81                 break;
82 #endif
83 #if defined(CONFIG_ARCH_UNIPHIER_PRO5)
84         case SOC_UNIPHIER_PRO5:
85                 uniphier_pro5_pin_init();
86                 led_puts("U1");
87                 uniphier_pro5_clk_init();
88                 break;
89 #endif
90 #if defined(CONFIG_ARCH_UNIPHIER_PXS2)
91         case SOC_UNIPHIER_PXS2:
92                 uniphier_pxs2_pin_init();
93                 led_puts("U1");
94                 uniphier_pxs2_clk_init();
95                 break;
96 #endif
97 #if defined(CONFIG_ARCH_UNIPHIER_LD6B)
98         case SOC_UNIPHIER_LD6B:
99                 uniphier_ld6b_pin_init();
100                 led_puts("U1");
101                 uniphier_pxs2_clk_init();
102                 break;
103 #endif
104 #if defined(CONFIG_ARCH_UNIPHIER_LD11)
105         case SOC_UNIPHIER_LD11:
106                 uniphier_ld20_pin_init();
107                 led_puts("U1");
108                 uniphier_ld11_clk_init();
109                 break;
110 #endif
111 #if defined(CONFIG_ARCH_UNIPHIER_LD20)
112         case SOC_UNIPHIER_LD20:
113                 uniphier_ld20_pin_init();
114                 led_puts("U1");
115                 uniphier_ld20_clk_init();
116                 cci500_init(2);
117                 break;
118 #endif
119         default:
120                 break;
121         }
122
123         uniphier_setup_xirq();
124
125         led_puts("U2");
126
127         support_card_late_init();
128
129         led_puts("U3");
130
131 #ifdef CONFIG_ARM64
132         uniphier_smp_kick_all_cpus();
133 #endif
134
135         led_puts("Uboo");
136
137         return 0;
138 }