riscv: sbi: Move sbi_probe_extension() out of CONFIG_SBI_V01
[oweals/u-boot.git] / arch / arm / mach-uniphier / board_init.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2012-2015 Panasonic Corporation
4  * Copyright (C) 2015-2016 Socionext Inc.
5  *   Author: Masahiro Yamada <yamada.masahiro@socionext.com>
6  */
7
8 #include <linux/errno.h>
9 #include <linux/io.h>
10 #include <linux/printk.h>
11
12 #include "init.h"
13 #include "micro-support-card.h"
14 #include "soc-info.h"
15
16 #ifdef CONFIG_ARCH_UNIPHIER_LD20
17 static void uniphier_ld20_misc_init(void)
18 {
19         /* ES1 errata: increase VDD09 supply to suppress VBO noise */
20         if (uniphier_get_soc_revision() == 1) {
21                 writel(0x00000003, 0x6184e004);
22                 writel(0x00000100, 0x6184e040);
23                 writel(0x0000b500, 0x6184e024);
24                 writel(0x00000001, 0x6184e000);
25         }
26 }
27 #endif
28
29 struct uniphier_initdata {
30         unsigned int soc_id;
31         void (*sbc_init)(void);
32         void (*pll_init)(void);
33         void (*clk_init)(void);
34         void (*misc_init)(void);
35 };
36
37 static const struct uniphier_initdata uniphier_initdata[] = {
38 #if defined(CONFIG_ARCH_UNIPHIER_LD4)
39         {
40                 .soc_id = UNIPHIER_LD4_ID,
41                 .sbc_init = uniphier_ld4_sbc_init,
42                 .pll_init = uniphier_ld4_pll_init,
43         },
44 #endif
45 #if defined(CONFIG_ARCH_UNIPHIER_PRO4)
46         {
47                 .soc_id = UNIPHIER_PRO4_ID,
48                 .sbc_init = uniphier_sbc_init_savepin,
49                 .pll_init = uniphier_pro4_pll_init,
50                 .clk_init = uniphier_pro4_clk_init,
51         },
52 #endif
53 #if defined(CONFIG_ARCH_UNIPHIER_SLD8)
54         {
55                 .soc_id = UNIPHIER_SLD8_ID,
56                 .sbc_init = uniphier_ld4_sbc_init,
57                 .pll_init = uniphier_ld4_pll_init,
58         },
59 #endif
60 #if defined(CONFIG_ARCH_UNIPHIER_PRO5)
61         {
62                 .soc_id = UNIPHIER_PRO5_ID,
63                 .sbc_init = uniphier_sbc_init_savepin,
64                 .clk_init = uniphier_pro5_clk_init,
65         },
66 #endif
67 #if defined(CONFIG_ARCH_UNIPHIER_PXS2)
68         {
69                 .soc_id = UNIPHIER_PXS2_ID,
70                 .sbc_init = uniphier_pxs2_sbc_init,
71                 .clk_init = uniphier_pxs2_clk_init,
72         },
73 #endif
74 #if defined(CONFIG_ARCH_UNIPHIER_LD6B)
75         {
76                 .soc_id = UNIPHIER_LD6B_ID,
77                 .sbc_init = uniphier_pxs2_sbc_init,
78                 .clk_init = uniphier_pxs2_clk_init,
79         },
80 #endif
81 #if defined(CONFIG_ARCH_UNIPHIER_LD11)
82         {
83                 .soc_id = UNIPHIER_LD11_ID,
84                 .sbc_init = uniphier_ld11_sbc_init,
85                 .pll_init = uniphier_ld11_pll_init,
86                 .clk_init = uniphier_ld11_clk_init,
87         },
88 #endif
89 #if defined(CONFIG_ARCH_UNIPHIER_LD20)
90         {
91                 .soc_id = UNIPHIER_LD20_ID,
92                 .sbc_init = uniphier_ld11_sbc_init,
93                 .pll_init = uniphier_ld20_pll_init,
94                 .clk_init = uniphier_ld20_clk_init,
95                 .misc_init = uniphier_ld20_misc_init,
96         },
97 #endif
98 #if defined(CONFIG_ARCH_UNIPHIER_PXS3)
99         {
100                 .soc_id = UNIPHIER_PXS3_ID,
101                 .sbc_init = uniphier_pxs2_sbc_init,
102                 .pll_init = uniphier_pxs3_pll_init,
103                 .clk_init = uniphier_pxs3_clk_init,
104         },
105 #endif
106 };
107 UNIPHIER_DEFINE_SOCDATA_FUNC(uniphier_get_initdata, uniphier_initdata)
108
109 int board_init(void)
110 {
111         const struct uniphier_initdata *initdata;
112
113         led_puts("U0");
114
115         initdata = uniphier_get_initdata();
116         if (!initdata) {
117                 pr_err("unsupported SoC\n");
118                 return -EINVAL;
119         }
120
121         initdata->sbc_init();
122
123         support_card_init();
124
125         led_puts("U0");
126
127         if (initdata->pll_init)
128                 initdata->pll_init();
129
130         led_puts("U1");
131
132         if (initdata->clk_init)
133                 initdata->clk_init();
134
135         led_puts("U2");
136
137         if (initdata->misc_init)
138                 initdata->misc_init();
139
140         led_puts("U3");
141
142         support_card_late_init();
143
144         led_puts("U4");
145
146         uniphier_nand_reset_assert();
147
148         led_puts("Uboo");
149
150         return 0;
151 }