blob: 2564a02a62305cc2fb8e75cf4507b9e62e6cfcf8 [file] [log] [blame]
Masahiro Yamada1f3d9c72015-02-05 14:42:54 +09001/*
Masahiro Yamadae59ed192016-09-14 01:06:08 +09002 * Copyright (C) 2012-2015 Panasonic Corporation
3 * Copyright (C) 2015-2016 Socionext Inc.
4 * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
Masahiro Yamada1f3d9c72015-02-05 14:42:54 +09005 *
6 * SPDX-License-Identifier: GPL-2.0+
7 */
8
Masahiro Yamada24802562016-06-29 19:39:03 +09009#include <common.h>
10#include <libfdt.h>
11#include <linux/io.h>
12
Masahiro Yamadaefdf3402016-01-09 01:51:13 +090013#include "init.h"
14#include "micro-support-card.h"
Masahiro Yamada011fd5b2016-09-17 03:33:07 +090015#include "sg-regs.h"
Masahiro Yamadaefdf3402016-01-09 01:51:13 +090016#include "soc-info.h"
Masahiro Yamada1f3d9c72015-02-05 14:42:54 +090017
Masahiro Yamada24802562016-06-29 19:39:03 +090018DECLARE_GLOBAL_DATA_PTR;
19
20static void uniphier_setup_xirq(void)
21{
22 const void *fdt = gd->fdt_blob;
23 int soc_node, aidet_node;
24 const u32 *val;
25 unsigned long aidet_base;
26 u32 tmp;
27
28 soc_node = fdt_path_offset(fdt, "/soc");
29 if (soc_node < 0)
30 return;
31
32 aidet_node = fdt_subnode_offset_namelen(fdt, soc_node, "aidet", 5);
33 if (aidet_node < 0)
34 return;
35
36 val = fdt_getprop(fdt, aidet_node, "reg", NULL);
37 if (!val)
38 return;
39
40 aidet_base = fdt32_to_cpu(*val);
41
42 tmp = readl(aidet_base + 8); /* AIDET DETCONFR2 */
43 tmp |= 0x00ff0000; /* Set XIRQ0-7 low active */
44 writel(tmp, aidet_base + 8);
45
46 tmp = readl(0x55000090); /* IRQCTL */
47 tmp |= 0x000000ff;
48 writel(tmp, 0x55000090);
49}
50
Masahiro Yamada266111c2017-01-15 14:59:08 +090051#ifdef CONFIG_ARCH_UNIPHIER_LD11
52static void uniphier_ld11_misc_init(void)
Masahiro Yamadac21e19a2016-09-17 03:33:04 +090053{
Masahiro Yamada266111c2017-01-15 14:59:08 +090054 sg_set_pinsel(149, 14, 8, 4); /* XIRQ0 -> XIRQ0 */
55 sg_set_iectrl(149);
56 sg_set_pinsel(153, 14, 8, 4); /* XIRQ4 -> XIRQ4 */
57 sg_set_iectrl(153);
Masahiro Yamadac21e19a2016-09-17 03:33:04 +090058}
Masahiro Yamada266111c2017-01-15 14:59:08 +090059#endif
Masahiro Yamadac21e19a2016-09-17 03:33:04 +090060
Masahiro Yamada266111c2017-01-15 14:59:08 +090061#ifdef CONFIG_ARCH_UNIPHIER_LD20
62static void uniphier_ld20_misc_init(void)
Masahiro Yamada1f3d9c72015-02-05 14:42:54 +090063{
Masahiro Yamada266111c2017-01-15 14:59:08 +090064 sg_set_pinsel(149, 14, 8, 4); /* XIRQ0 -> XIRQ0 */
65 sg_set_iectrl(149);
66 sg_set_pinsel(153, 14, 8, 4); /* XIRQ4 -> XIRQ4 */
67 sg_set_iectrl(153);
68
69 /* ES1 errata: increase VDD09 supply to suppress VBO noise */
70 if (uniphier_get_soc_revision() == 1) {
71 writel(0x00000003, 0x6184e004);
72 writel(0x00000100, 0x6184e040);
73 writel(0x0000b500, 0x6184e024);
74 writel(0x00000001, 0x6184e000);
75 }
Masahiro Yamadadabee242017-01-21 18:05:22 +090076#ifdef CONFIG_ARMV8_MULTIENTRY
Masahiro Yamada266111c2017-01-15 14:59:08 +090077 cci500_init(2);
Masahiro Yamadadabee242017-01-21 18:05:22 +090078#endif
Masahiro Yamada266111c2017-01-15 14:59:08 +090079}
80#endif
Masahiro Yamada1f3d9c72015-02-05 14:42:54 +090081
Masahiro Yamada266111c2017-01-15 14:59:08 +090082struct uniphier_initdata {
Masahiro Yamada31649052017-01-21 18:05:26 +090083 unsigned int soc_id;
Masahiro Yamada266111c2017-01-15 14:59:08 +090084 bool nand_2cs;
Masahiro Yamada0cc46ad2017-01-15 14:59:10 +090085 void (*sbc_init)(void);
Masahiro Yamada266111c2017-01-15 14:59:08 +090086 void (*pll_init)(void);
87 void (*clk_init)(void);
88 void (*misc_init)(void);
89};
90
Masahiro Yamadaf17e5982017-01-21 18:05:21 +090091static const struct uniphier_initdata uniphier_initdata[] = {
Masahiro Yamada53c59ae2016-03-18 16:41:43 +090092#if defined(CONFIG_ARCH_UNIPHIER_SLD3)
Masahiro Yamada266111c2017-01-15 14:59:08 +090093 {
Masahiro Yamada31649052017-01-21 18:05:26 +090094 .soc_id = UNIPHIER_SLD3_ID,
Masahiro Yamada266111c2017-01-15 14:59:08 +090095 .nand_2cs = true,
Masahiro Yamada0cc46ad2017-01-15 14:59:10 +090096 .sbc_init = uniphier_sbc_init_admulti,
Masahiro Yamada266111c2017-01-15 14:59:08 +090097 .pll_init = uniphier_sld3_pll_init,
98 .clk_init = uniphier_ld4_clk_init,
99 },
Masahiro Yamada75f16f82015-09-22 00:27:39 +0900100#endif
Masahiro Yamada53c59ae2016-03-18 16:41:43 +0900101#if defined(CONFIG_ARCH_UNIPHIER_LD4)
Masahiro Yamada266111c2017-01-15 14:59:08 +0900102 {
Masahiro Yamada31649052017-01-21 18:05:26 +0900103 .soc_id = UNIPHIER_LD4_ID,
Masahiro Yamada266111c2017-01-15 14:59:08 +0900104 .nand_2cs = true,
Masahiro Yamada0cc46ad2017-01-15 14:59:10 +0900105 .sbc_init = uniphier_ld4_sbc_init,
Masahiro Yamada266111c2017-01-15 14:59:08 +0900106 .pll_init = uniphier_ld4_pll_init,
107 .clk_init = uniphier_ld4_clk_init,
108 },
Masahiro Yamada75f16f82015-09-22 00:27:39 +0900109#endif
Masahiro Yamada53c59ae2016-03-18 16:41:43 +0900110#if defined(CONFIG_ARCH_UNIPHIER_PRO4)
Masahiro Yamada266111c2017-01-15 14:59:08 +0900111 {
Masahiro Yamada31649052017-01-21 18:05:26 +0900112 .soc_id = UNIPHIER_PRO4_ID,
Masahiro Yamada266111c2017-01-15 14:59:08 +0900113 .nand_2cs = false,
Masahiro Yamada0cc46ad2017-01-15 14:59:10 +0900114 .sbc_init = uniphier_sbc_init_savepin,
Masahiro Yamada266111c2017-01-15 14:59:08 +0900115 .pll_init = uniphier_pro4_pll_init,
116 .clk_init = uniphier_pro4_clk_init,
117 },
Masahiro Yamada75f16f82015-09-22 00:27:39 +0900118#endif
Masahiro Yamada53c59ae2016-03-18 16:41:43 +0900119#if defined(CONFIG_ARCH_UNIPHIER_SLD8)
Masahiro Yamada266111c2017-01-15 14:59:08 +0900120 {
Masahiro Yamada31649052017-01-21 18:05:26 +0900121 .soc_id = UNIPHIER_SLD8_ID,
Masahiro Yamada266111c2017-01-15 14:59:08 +0900122 .nand_2cs = true,
Masahiro Yamada0cc46ad2017-01-15 14:59:10 +0900123 .sbc_init = uniphier_ld4_sbc_init,
Masahiro Yamada266111c2017-01-15 14:59:08 +0900124 .pll_init = uniphier_ld4_pll_init,
125 .clk_init = uniphier_ld4_clk_init,
126 },
Masahiro Yamada75f16f82015-09-22 00:27:39 +0900127#endif
Masahiro Yamada53c59ae2016-03-18 16:41:43 +0900128#if defined(CONFIG_ARCH_UNIPHIER_PRO5)
Masahiro Yamada266111c2017-01-15 14:59:08 +0900129 {
Masahiro Yamada31649052017-01-21 18:05:26 +0900130 .soc_id = UNIPHIER_PRO5_ID,
Masahiro Yamada266111c2017-01-15 14:59:08 +0900131 .nand_2cs = true,
Masahiro Yamada0cc46ad2017-01-15 14:59:10 +0900132 .sbc_init = uniphier_sbc_init_savepin,
Masahiro Yamada266111c2017-01-15 14:59:08 +0900133 .clk_init = uniphier_pro5_clk_init,
134 },
Masahiro Yamadad5167d52015-09-22 00:27:40 +0900135#endif
Masahiro Yamada53c59ae2016-03-18 16:41:43 +0900136#if defined(CONFIG_ARCH_UNIPHIER_PXS2)
Masahiro Yamada266111c2017-01-15 14:59:08 +0900137 {
Masahiro Yamada31649052017-01-21 18:05:26 +0900138 .soc_id = UNIPHIER_PXS2_ID,
Masahiro Yamada266111c2017-01-15 14:59:08 +0900139 .nand_2cs = true,
Masahiro Yamada0cc46ad2017-01-15 14:59:10 +0900140 .sbc_init = uniphier_pxs2_sbc_init,
Masahiro Yamada266111c2017-01-15 14:59:08 +0900141 .clk_init = uniphier_pxs2_clk_init,
142 },
Masahiro Yamada1fe65d32015-09-22 00:27:41 +0900143#endif
Masahiro Yamada53c59ae2016-03-18 16:41:43 +0900144#if defined(CONFIG_ARCH_UNIPHIER_LD6B)
Masahiro Yamada266111c2017-01-15 14:59:08 +0900145 {
Masahiro Yamada31649052017-01-21 18:05:26 +0900146 .soc_id = UNIPHIER_LD6B_ID,
Masahiro Yamada266111c2017-01-15 14:59:08 +0900147 .nand_2cs = true,
Masahiro Yamada0cc46ad2017-01-15 14:59:10 +0900148 .sbc_init = uniphier_pxs2_sbc_init,
Masahiro Yamada266111c2017-01-15 14:59:08 +0900149 .clk_init = uniphier_pxs2_clk_init,
150 },
Masahiro Yamada1fe65d32015-09-22 00:27:41 +0900151#endif
Masahiro Yamada8bbbcbd2016-05-24 21:14:01 +0900152#if defined(CONFIG_ARCH_UNIPHIER_LD11)
Masahiro Yamada266111c2017-01-15 14:59:08 +0900153 {
Masahiro Yamada31649052017-01-21 18:05:26 +0900154 .soc_id = UNIPHIER_LD11_ID,
Masahiro Yamada266111c2017-01-15 14:59:08 +0900155 .nand_2cs = false,
Masahiro Yamada0cc46ad2017-01-15 14:59:10 +0900156 .sbc_init = uniphier_ld11_sbc_init,
Masahiro Yamada266111c2017-01-15 14:59:08 +0900157 .pll_init = uniphier_ld11_pll_init,
158 .clk_init = uniphier_ld11_clk_init,
159 .misc_init = uniphier_ld11_misc_init,
160 },
Masahiro Yamada8bbbcbd2016-05-24 21:14:01 +0900161#endif
Masahiro Yamada063eb1e2016-04-21 14:43:18 +0900162#if defined(CONFIG_ARCH_UNIPHIER_LD20)
Masahiro Yamada266111c2017-01-15 14:59:08 +0900163 {
Masahiro Yamada31649052017-01-21 18:05:26 +0900164 .soc_id = UNIPHIER_LD20_ID,
Masahiro Yamada266111c2017-01-15 14:59:08 +0900165 .nand_2cs = false,
Masahiro Yamada0cc46ad2017-01-15 14:59:10 +0900166 .sbc_init = uniphier_ld11_sbc_init,
Masahiro Yamada266111c2017-01-15 14:59:08 +0900167 .pll_init = uniphier_ld20_pll_init,
Masahiro Yamadab3b1bb72017-02-17 16:17:22 +0900168 .clk_init = uniphier_ld20_clk_init,
Masahiro Yamada266111c2017-01-15 14:59:08 +0900169 .misc_init = uniphier_ld20_misc_init,
170 },
Masahiro Yamada063eb1e2016-04-21 14:43:18 +0900171#endif
Masahiro Yamada133b1262017-01-21 18:05:31 +0900172#if defined(CONFIG_ARCH_UNIPHIER_PXS3)
173 {
174 .soc_id = UNIPHIER_PXS3_ID,
175 .nand_2cs = false,
176 .sbc_init = uniphier_pxs2_sbc_init,
177 .pll_init = uniphier_pxs3_pll_init,
178 },
179#endif
Masahiro Yamada266111c2017-01-15 14:59:08 +0900180};
Masahiro Yamada1b818982017-01-21 18:05:27 +0900181UNIPHIER_DEFINE_SOCDATA_FUNC(uniphier_get_initdata, uniphier_initdata)
Masahiro Yamada266111c2017-01-15 14:59:08 +0900182
183int board_init(void)
184{
Masahiro Yamadaf17e5982017-01-21 18:05:21 +0900185 const struct uniphier_initdata *initdata;
Masahiro Yamada266111c2017-01-15 14:59:08 +0900186 int ret;
187
188 led_puts("U0");
189
Masahiro Yamada1b818982017-01-21 18:05:27 +0900190 initdata = uniphier_get_initdata();
Masahiro Yamada266111c2017-01-15 14:59:08 +0900191 if (!initdata) {
Masahiro Yamada1b818982017-01-21 18:05:27 +0900192 pr_err("unsupported SoC\n");
Masahiro Yamada266111c2017-01-15 14:59:08 +0900193 return -EINVAL;
194 }
195
Masahiro Yamada0cc46ad2017-01-15 14:59:10 +0900196 initdata->sbc_init();
197
198 support_card_init();
199
200 led_puts("U0");
201
Masahiro Yamada266111c2017-01-15 14:59:08 +0900202 if (IS_ENABLED(CONFIG_NAND_DENALI)) {
203 ret = uniphier_pin_init(initdata->nand_2cs ?
204 "nand2cs_grp" : "nand_grp");
205 if (ret)
206 pr_err("failed to init NAND pins\n");
207 }
208
209 led_puts("U1");
210
211 if (initdata->pll_init)
212 initdata->pll_init();
Masahiro Yamada24802562016-06-29 19:39:03 +0900213
Masahiro Yamada4e5d28d2015-09-22 00:27:31 +0900214 led_puts("U2");
Masahiro Yamadac04368f2015-02-27 02:26:51 +0900215
Masahiro Yamada266111c2017-01-15 14:59:08 +0900216 if (initdata->clk_init)
217 initdata->clk_init();
Masahiro Yamadae59ed192016-09-14 01:06:08 +0900218
219 led_puts("U3");
220
Masahiro Yamada266111c2017-01-15 14:59:08 +0900221 if (initdata->misc_init)
222 initdata->misc_init();
223
224 led_puts("U4");
225
226 uniphier_setup_xirq();
227
228 led_puts("U5");
229
230 support_card_late_init();
231
232 led_puts("U6");
233
Masahiro Yamadadabee242017-01-21 18:05:22 +0900234#ifdef CONFIG_ARMV8_MULTIENTRY
Masahiro Yamadae59ed192016-09-14 01:06:08 +0900235 uniphier_smp_kick_all_cpus();
236#endif
237
238 led_puts("Uboo");
239
Masahiro Yamada1f3d9c72015-02-05 14:42:54 +0900240 return 0;
241}