blob: 8c7864cb85d5dd9d9379de60ab828e610390102b [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 Yamadac21e19a2016-09-17 03:33:04 +090051static void uniphier_nand_pin_init(bool cs2)
52{
53#ifdef CONFIG_NAND_DENALI
54 if (uniphier_pin_init(cs2 ? "nand2cs_grp" : "nand_grp"))
55 pr_err("failed to init NAND pins\n");
56#endif
57}
58
Masahiro Yamadae59ed192016-09-14 01:06:08 +090059int board_init(void)
Masahiro Yamada1f3d9c72015-02-05 14:42:54 +090060{
Masahiro Yamadad11b0b72016-09-17 03:33:11 +090061 const struct uniphier_board_data *bd;
62
Masahiro Yamada4e5d28d2015-09-22 00:27:31 +090063 led_puts("U0");
Masahiro Yamada1f3d9c72015-02-05 14:42:54 +090064
Masahiro Yamadad11b0b72016-09-17 03:33:11 +090065 bd = uniphier_get_board_param();
66 if (!bd)
67 return -ENODEV;
68
Masahiro Yamada75f16f82015-09-22 00:27:39 +090069 switch (uniphier_get_soc_type()) {
Masahiro Yamada53c59ae2016-03-18 16:41:43 +090070#if defined(CONFIG_ARCH_UNIPHIER_SLD3)
71 case SOC_UNIPHIER_SLD3:
Masahiro Yamadac21e19a2016-09-17 03:33:04 +090072 uniphier_nand_pin_init(true);
Masahiro Yamada75f16f82015-09-22 00:27:39 +090073 led_puts("U1");
Masahiro Yamada9d6652c2016-09-17 03:33:09 +090074 uniphier_sld3_pll_init();
Masahiro Yamada98905692016-03-30 20:17:02 +090075 uniphier_ld4_clk_init();
Masahiro Yamada75f16f82015-09-22 00:27:39 +090076 break;
77#endif
Masahiro Yamada53c59ae2016-03-18 16:41:43 +090078#if defined(CONFIG_ARCH_UNIPHIER_LD4)
79 case SOC_UNIPHIER_LD4:
Masahiro Yamadac21e19a2016-09-17 03:33:04 +090080 uniphier_nand_pin_init(true);
Masahiro Yamada75f16f82015-09-22 00:27:39 +090081 led_puts("U1");
Masahiro Yamada9d6652c2016-09-17 03:33:09 +090082 uniphier_ld4_pll_init();
Masahiro Yamada98905692016-03-30 20:17:02 +090083 uniphier_ld4_clk_init();
Masahiro Yamada75f16f82015-09-22 00:27:39 +090084 break;
85#endif
Masahiro Yamada53c59ae2016-03-18 16:41:43 +090086#if defined(CONFIG_ARCH_UNIPHIER_PRO4)
87 case SOC_UNIPHIER_PRO4:
Masahiro Yamadac21e19a2016-09-17 03:33:04 +090088 uniphier_nand_pin_init(false);
Masahiro Yamada75f16f82015-09-22 00:27:39 +090089 led_puts("U1");
Masahiro Yamada9d6652c2016-09-17 03:33:09 +090090 uniphier_pro4_pll_init();
Masahiro Yamada98905692016-03-30 20:17:02 +090091 uniphier_pro4_clk_init();
Masahiro Yamada75f16f82015-09-22 00:27:39 +090092 break;
93#endif
Masahiro Yamada53c59ae2016-03-18 16:41:43 +090094#if defined(CONFIG_ARCH_UNIPHIER_SLD8)
95 case SOC_UNIPHIER_SLD8:
Masahiro Yamadac21e19a2016-09-17 03:33:04 +090096 uniphier_nand_pin_init(true);
Masahiro Yamada75f16f82015-09-22 00:27:39 +090097 led_puts("U1");
Masahiro Yamada9d6652c2016-09-17 03:33:09 +090098 uniphier_ld4_pll_init();
Masahiro Yamada98905692016-03-30 20:17:02 +090099 uniphier_ld4_clk_init();
Masahiro Yamada75f16f82015-09-22 00:27:39 +0900100 break;
101#endif
Masahiro Yamada53c59ae2016-03-18 16:41:43 +0900102#if defined(CONFIG_ARCH_UNIPHIER_PRO5)
103 case SOC_UNIPHIER_PRO5:
Masahiro Yamadac21e19a2016-09-17 03:33:04 +0900104 uniphier_nand_pin_init(true);
Masahiro Yamadad5167d52015-09-22 00:27:40 +0900105 led_puts("U1");
Masahiro Yamada98905692016-03-30 20:17:02 +0900106 uniphier_pro5_clk_init();
Masahiro Yamadad5167d52015-09-22 00:27:40 +0900107 break;
108#endif
Masahiro Yamada53c59ae2016-03-18 16:41:43 +0900109#if defined(CONFIG_ARCH_UNIPHIER_PXS2)
110 case SOC_UNIPHIER_PXS2:
Masahiro Yamadac21e19a2016-09-17 03:33:04 +0900111 uniphier_nand_pin_init(true);
Masahiro Yamada1fe65d32015-09-22 00:27:41 +0900112 led_puts("U1");
Masahiro Yamada98905692016-03-30 20:17:02 +0900113 uniphier_pxs2_clk_init();
Masahiro Yamada1fe65d32015-09-22 00:27:41 +0900114 break;
115#endif
Masahiro Yamada53c59ae2016-03-18 16:41:43 +0900116#if defined(CONFIG_ARCH_UNIPHIER_LD6B)
117 case SOC_UNIPHIER_LD6B:
Masahiro Yamadac21e19a2016-09-17 03:33:04 +0900118 uniphier_nand_pin_init(true);
Masahiro Yamada1fe65d32015-09-22 00:27:41 +0900119 led_puts("U1");
Masahiro Yamada98905692016-03-30 20:17:02 +0900120 uniphier_pxs2_clk_init();
Masahiro Yamada1fe65d32015-09-22 00:27:41 +0900121 break;
122#endif
Masahiro Yamada8bbbcbd2016-05-24 21:14:01 +0900123#if defined(CONFIG_ARCH_UNIPHIER_LD11)
124 case SOC_UNIPHIER_LD11:
Masahiro Yamadac21e19a2016-09-17 03:33:04 +0900125 uniphier_nand_pin_init(false);
Masahiro Yamada011fd5b2016-09-17 03:33:07 +0900126 sg_set_pinsel(149, 14, 8, 4); /* XIRQ0 -> XIRQ0 */
127 sg_set_iectrl(149);
128 sg_set_pinsel(153, 14, 8, 4); /* XIRQ4 -> XIRQ4 */
129 sg_set_iectrl(153);
Masahiro Yamada8bbbcbd2016-05-24 21:14:01 +0900130 led_puts("U1");
Masahiro Yamada090785d2016-09-22 07:42:19 +0900131 uniphier_ld11_pll_init();
Masahiro Yamada8bbbcbd2016-05-24 21:14:01 +0900132 uniphier_ld11_clk_init();
133 break;
134#endif
Masahiro Yamada063eb1e2016-04-21 14:43:18 +0900135#if defined(CONFIG_ARCH_UNIPHIER_LD20)
136 case SOC_UNIPHIER_LD20:
Masahiro Yamada7b505882016-10-08 13:25:25 +0900137 /* ES1 errata: increase VDD09 supply to suppress VBO noise */
138 if (uniphier_get_soc_revision() == 1) {
139 writel(0x00000003, 0x6184e004);
140 writel(0x00000100, 0x6184e040);
141 writel(0x0000b500, 0x6184e024);
142 writel(0x00000001, 0x6184e000);
143 }
Masahiro Yamadac21e19a2016-09-17 03:33:04 +0900144 uniphier_nand_pin_init(false);
Masahiro Yamada011fd5b2016-09-17 03:33:07 +0900145 sg_set_pinsel(149, 14, 8, 4); /* XIRQ0 -> XIRQ0 */
146 sg_set_iectrl(149);
147 sg_set_pinsel(153, 14, 8, 4); /* XIRQ4 -> XIRQ4 */
148 sg_set_iectrl(153);
Masahiro Yamada063eb1e2016-04-21 14:43:18 +0900149 led_puts("U1");
Masahiro Yamadad11b0b72016-09-17 03:33:11 +0900150 uniphier_ld20_pll_init(bd);
Masahiro Yamada063eb1e2016-04-21 14:43:18 +0900151 uniphier_ld20_clk_init();
152 cci500_init(2);
153 break;
154#endif
Masahiro Yamada75f16f82015-09-22 00:27:39 +0900155 default:
156 break;
157 }
Masahiro Yamadac04368f2015-02-27 02:26:51 +0900158
Masahiro Yamada24802562016-06-29 19:39:03 +0900159 uniphier_setup_xirq();
160
Masahiro Yamada4e5d28d2015-09-22 00:27:31 +0900161 led_puts("U2");
Masahiro Yamadac04368f2015-02-27 02:26:51 +0900162
Masahiro Yamadae59ed192016-09-14 01:06:08 +0900163 support_card_late_init();
164
165 led_puts("U3");
166
167#ifdef CONFIG_ARM64
168 uniphier_smp_kick_all_cpus();
169#endif
170
171 led_puts("Uboo");
172
Masahiro Yamada1f3d9c72015-02-05 14:42:54 +0900173 return 0;
174}