Masahiro Yamada | 84ccd79 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 1 | /* |
Masahiro Yamada | b291671 | 2016-09-14 01:06:08 +0900 | [diff] [blame] | 2 | * Copyright (C) 2012-2015 Panasonic Corporation |
| 3 | * Copyright (C) 2015-2016 Socionext Inc. |
| 4 | * Author: Masahiro Yamada <yamada.masahiro@socionext.com> |
Masahiro Yamada | 84ccd79 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 5 | * |
| 6 | * SPDX-License-Identifier: GPL-2.0+ |
| 7 | */ |
| 8 | |
Masahiro Yamada | e64a6b1 | 2016-06-29 19:39:03 +0900 | [diff] [blame] | 9 | #include <common.h> |
| 10 | #include <libfdt.h> |
| 11 | #include <linux/io.h> |
| 12 | |
Masahiro Yamada | 107b3fb | 2016-01-09 01:51:13 +0900 | [diff] [blame] | 13 | #include "init.h" |
| 14 | #include "micro-support-card.h" |
Masahiro Yamada | b78ffc5 | 2016-09-17 03:33:07 +0900 | [diff] [blame] | 15 | #include "sg-regs.h" |
Masahiro Yamada | 107b3fb | 2016-01-09 01:51:13 +0900 | [diff] [blame] | 16 | #include "soc-info.h" |
Masahiro Yamada | 84ccd79 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 17 | |
Masahiro Yamada | e64a6b1 | 2016-06-29 19:39:03 +0900 | [diff] [blame] | 18 | DECLARE_GLOBAL_DATA_PTR; |
| 19 | |
| 20 | static 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 Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 51 | #ifdef CONFIG_ARCH_UNIPHIER_LD11 |
| 52 | static void uniphier_ld11_misc_init(void) |
Masahiro Yamada | 5ac9dfb | 2016-09-17 03:33:04 +0900 | [diff] [blame] | 53 | { |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 54 | 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); |
| 58 | } |
Masahiro Yamada | 5ac9dfb | 2016-09-17 03:33:04 +0900 | [diff] [blame] | 59 | #endif |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 60 | |
| 61 | #ifdef CONFIG_ARCH_UNIPHIER_LD20 |
| 62 | static void uniphier_ld20_misc_init(void) |
| 63 | { |
| 64 | 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 Yamada | 561ca64 | 2017-01-21 18:05:22 +0900 | [diff] [blame] | 76 | #ifdef CONFIG_ARMV8_MULTIENTRY |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 77 | cci500_init(2); |
Masahiro Yamada | 561ca64 | 2017-01-21 18:05:22 +0900 | [diff] [blame] | 78 | #endif |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 79 | } |
| 80 | #endif |
| 81 | |
| 82 | struct uniphier_initdata { |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 83 | unsigned int soc_id; |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 84 | bool nand_2cs; |
Masahiro Yamada | 26b09c0 | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 85 | void (*sbc_init)(void); |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 86 | void (*pll_init)(void); |
| 87 | void (*clk_init)(void); |
| 88 | void (*misc_init)(void); |
| 89 | }; |
| 90 | |
Masahiro Yamada | 7a37bd6 | 2017-01-21 18:05:21 +0900 | [diff] [blame] | 91 | static const struct uniphier_initdata uniphier_initdata[] = { |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 92 | #if defined(CONFIG_ARCH_UNIPHIER_SLD3) |
| 93 | { |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 94 | .soc_id = UNIPHIER_SLD3_ID, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 95 | .nand_2cs = true, |
Masahiro Yamada | 26b09c0 | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 96 | .sbc_init = uniphier_sbc_init_admulti, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 97 | .pll_init = uniphier_sld3_pll_init, |
| 98 | .clk_init = uniphier_ld4_clk_init, |
| 99 | }, |
| 100 | #endif |
| 101 | #if defined(CONFIG_ARCH_UNIPHIER_LD4) |
| 102 | { |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 103 | .soc_id = UNIPHIER_LD4_ID, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 104 | .nand_2cs = true, |
Masahiro Yamada | 26b09c0 | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 105 | .sbc_init = uniphier_ld4_sbc_init, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 106 | .pll_init = uniphier_ld4_pll_init, |
| 107 | .clk_init = uniphier_ld4_clk_init, |
| 108 | }, |
| 109 | #endif |
| 110 | #if defined(CONFIG_ARCH_UNIPHIER_PRO4) |
| 111 | { |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 112 | .soc_id = UNIPHIER_PRO4_ID, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 113 | .nand_2cs = false, |
Masahiro Yamada | 26b09c0 | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 114 | .sbc_init = uniphier_sbc_init_savepin, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 115 | .pll_init = uniphier_pro4_pll_init, |
| 116 | .clk_init = uniphier_pro4_clk_init, |
| 117 | }, |
| 118 | #endif |
| 119 | #if defined(CONFIG_ARCH_UNIPHIER_SLD8) |
| 120 | { |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 121 | .soc_id = UNIPHIER_SLD8_ID, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 122 | .nand_2cs = true, |
Masahiro Yamada | 26b09c0 | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 123 | .sbc_init = uniphier_ld4_sbc_init, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 124 | .pll_init = uniphier_ld4_pll_init, |
| 125 | .clk_init = uniphier_ld4_clk_init, |
| 126 | }, |
| 127 | #endif |
| 128 | #if defined(CONFIG_ARCH_UNIPHIER_PRO5) |
| 129 | { |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 130 | .soc_id = UNIPHIER_PRO5_ID, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 131 | .nand_2cs = true, |
Masahiro Yamada | 26b09c0 | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 132 | .sbc_init = uniphier_sbc_init_savepin, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 133 | .clk_init = uniphier_pro5_clk_init, |
| 134 | }, |
| 135 | #endif |
| 136 | #if defined(CONFIG_ARCH_UNIPHIER_PXS2) |
| 137 | { |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 138 | .soc_id = UNIPHIER_PXS2_ID, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 139 | .nand_2cs = true, |
Masahiro Yamada | 26b09c0 | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 140 | .sbc_init = uniphier_pxs2_sbc_init, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 141 | .clk_init = uniphier_pxs2_clk_init, |
| 142 | }, |
| 143 | #endif |
| 144 | #if defined(CONFIG_ARCH_UNIPHIER_LD6B) |
| 145 | { |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 146 | .soc_id = UNIPHIER_LD6B_ID, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 147 | .nand_2cs = true, |
Masahiro Yamada | 26b09c0 | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 148 | .sbc_init = uniphier_pxs2_sbc_init, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 149 | .clk_init = uniphier_pxs2_clk_init, |
| 150 | }, |
| 151 | #endif |
| 152 | #if defined(CONFIG_ARCH_UNIPHIER_LD11) |
| 153 | { |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 154 | .soc_id = UNIPHIER_LD11_ID, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 155 | .nand_2cs = false, |
Masahiro Yamada | 26b09c0 | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 156 | .sbc_init = uniphier_ld11_sbc_init, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 157 | .pll_init = uniphier_ld11_pll_init, |
| 158 | .clk_init = uniphier_ld11_clk_init, |
| 159 | .misc_init = uniphier_ld11_misc_init, |
| 160 | }, |
| 161 | #endif |
| 162 | #if defined(CONFIG_ARCH_UNIPHIER_LD20) |
| 163 | { |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 164 | .soc_id = UNIPHIER_LD20_ID, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 165 | .nand_2cs = false, |
Masahiro Yamada | 26b09c0 | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 166 | .sbc_init = uniphier_ld11_sbc_init, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 167 | .pll_init = uniphier_ld20_pll_init, |
| 168 | .misc_init = uniphier_ld20_misc_init, |
| 169 | }, |
| 170 | #endif |
Masahiro Yamada | 2c2ab3d | 2017-01-21 18:05:31 +0900 | [diff] [blame] | 171 | #if defined(CONFIG_ARCH_UNIPHIER_PXS3) |
| 172 | { |
| 173 | .soc_id = UNIPHIER_PXS3_ID, |
| 174 | .nand_2cs = false, |
| 175 | .sbc_init = uniphier_pxs2_sbc_init, |
| 176 | .pll_init = uniphier_pxs3_pll_init, |
| 177 | }, |
| 178 | #endif |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 179 | }; |
Masahiro Yamada | ee8ef5a | 2017-01-21 18:05:27 +0900 | [diff] [blame] | 180 | UNIPHIER_DEFINE_SOCDATA_FUNC(uniphier_get_initdata, uniphier_initdata) |
Masahiro Yamada | 5ac9dfb | 2016-09-17 03:33:04 +0900 | [diff] [blame] | 181 | |
Masahiro Yamada | b291671 | 2016-09-14 01:06:08 +0900 | [diff] [blame] | 182 | int board_init(void) |
Masahiro Yamada | 84ccd79 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 183 | { |
Masahiro Yamada | 7a37bd6 | 2017-01-21 18:05:21 +0900 | [diff] [blame] | 184 | const struct uniphier_initdata *initdata; |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 185 | int ret; |
| 186 | |
Masahiro Yamada | 8469700 | 2015-09-22 00:27:31 +0900 | [diff] [blame] | 187 | led_puts("U0"); |
Masahiro Yamada | 84ccd79 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 188 | |
Masahiro Yamada | ee8ef5a | 2017-01-21 18:05:27 +0900 | [diff] [blame] | 189 | initdata = uniphier_get_initdata(); |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 190 | if (!initdata) { |
Masahiro Yamada | ee8ef5a | 2017-01-21 18:05:27 +0900 | [diff] [blame] | 191 | pr_err("unsupported SoC\n"); |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 192 | return -EINVAL; |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 193 | } |
Masahiro Yamada | 198a97a | 2015-02-27 02:26:51 +0900 | [diff] [blame] | 194 | |
Masahiro Yamada | 26b09c0 | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 195 | initdata->sbc_init(); |
| 196 | |
| 197 | support_card_init(); |
| 198 | |
| 199 | led_puts("U0"); |
| 200 | |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 201 | if (IS_ENABLED(CONFIG_NAND_DENALI)) { |
| 202 | ret = uniphier_pin_init(initdata->nand_2cs ? |
| 203 | "nand2cs_grp" : "nand_grp"); |
| 204 | if (ret) |
| 205 | pr_err("failed to init NAND pins\n"); |
| 206 | } |
| 207 | |
| 208 | led_puts("U1"); |
| 209 | |
| 210 | if (initdata->pll_init) |
| 211 | initdata->pll_init(); |
Masahiro Yamada | e64a6b1 | 2016-06-29 19:39:03 +0900 | [diff] [blame] | 212 | |
Masahiro Yamada | 8469700 | 2015-09-22 00:27:31 +0900 | [diff] [blame] | 213 | led_puts("U2"); |
Masahiro Yamada | 198a97a | 2015-02-27 02:26:51 +0900 | [diff] [blame] | 214 | |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 215 | if (initdata->clk_init) |
| 216 | initdata->clk_init(); |
Masahiro Yamada | b291671 | 2016-09-14 01:06:08 +0900 | [diff] [blame] | 217 | |
| 218 | led_puts("U3"); |
| 219 | |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 220 | if (initdata->misc_init) |
| 221 | initdata->misc_init(); |
| 222 | |
| 223 | led_puts("U4"); |
| 224 | |
| 225 | uniphier_setup_xirq(); |
| 226 | |
| 227 | led_puts("U5"); |
| 228 | |
| 229 | support_card_late_init(); |
| 230 | |
| 231 | led_puts("U6"); |
| 232 | |
Masahiro Yamada | 561ca64 | 2017-01-21 18:05:22 +0900 | [diff] [blame] | 233 | #ifdef CONFIG_ARMV8_MULTIENTRY |
Masahiro Yamada | b291671 | 2016-09-14 01:06:08 +0900 | [diff] [blame] | 234 | uniphier_smp_kick_all_cpus(); |
| 235 | #endif |
| 236 | |
| 237 | led_puts("Uboo"); |
| 238 | |
Masahiro Yamada | 84ccd79 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 239 | return 0; |
| 240 | } |