Masahiro Yamada | 1f3d9c7 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 1 | /* |
Masahiro Yamada | e59ed19 | 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 | 1f3d9c7 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 5 | * |
| 6 | * SPDX-License-Identifier: GPL-2.0+ |
| 7 | */ |
| 8 | |
Masahiro Yamada | 2480256 | 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 | efdf340 | 2016-01-09 01:51:13 +0900 | [diff] [blame] | 13 | #include "init.h" |
| 14 | #include "micro-support-card.h" |
Masahiro Yamada | 011fd5b | 2016-09-17 03:33:07 +0900 | [diff] [blame] | 15 | #include "sg-regs.h" |
Masahiro Yamada | efdf340 | 2016-01-09 01:51:13 +0900 | [diff] [blame] | 16 | #include "soc-info.h" |
Masahiro Yamada | 1f3d9c7 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 17 | |
Masahiro Yamada | 2480256 | 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; |
Masahiro Yamada | 5e05c4d | 2017-06-22 16:42:04 +0900 | [diff] [blame] | 24 | const fdt32_t *val; |
Masahiro Yamada | 2480256 | 2016-06-29 19:39:03 +0900 | [diff] [blame] | 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 | 266111c | 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 | c21e19a | 2016-09-17 03:33:04 +0900 | [diff] [blame] | 53 | { |
Masahiro Yamada | 266111c | 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); |
Masahiro Yamada | c21e19a | 2016-09-17 03:33:04 +0900 | [diff] [blame] | 58 | } |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 59 | #endif |
Masahiro Yamada | c21e19a | 2016-09-17 03:33:04 +0900 | [diff] [blame] | 60 | |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 61 | #ifdef CONFIG_ARCH_UNIPHIER_LD20 |
| 62 | static void uniphier_ld20_misc_init(void) |
Masahiro Yamada | 1f3d9c7 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 63 | { |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 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 | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 76 | } |
| 77 | #endif |
Masahiro Yamada | 1f3d9c7 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 78 | |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 79 | struct uniphier_initdata { |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 80 | unsigned int soc_id; |
Masahiro Yamada | 0cc46ad | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 81 | void (*sbc_init)(void); |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 82 | void (*pll_init)(void); |
| 83 | void (*clk_init)(void); |
| 84 | void (*misc_init)(void); |
| 85 | }; |
| 86 | |
Masahiro Yamada | f17e598 | 2017-01-21 18:05:21 +0900 | [diff] [blame] | 87 | static const struct uniphier_initdata uniphier_initdata[] = { |
Masahiro Yamada | 53c59ae | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 88 | #if defined(CONFIG_ARCH_UNIPHIER_LD4) |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 89 | { |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 90 | .soc_id = UNIPHIER_LD4_ID, |
Masahiro Yamada | 0cc46ad | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 91 | .sbc_init = uniphier_ld4_sbc_init, |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 92 | .pll_init = uniphier_ld4_pll_init, |
| 93 | .clk_init = uniphier_ld4_clk_init, |
| 94 | }, |
Masahiro Yamada | 75f16f8 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 95 | #endif |
Masahiro Yamada | 53c59ae | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 96 | #if defined(CONFIG_ARCH_UNIPHIER_PRO4) |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 97 | { |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 98 | .soc_id = UNIPHIER_PRO4_ID, |
Masahiro Yamada | 0cc46ad | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 99 | .sbc_init = uniphier_sbc_init_savepin, |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 100 | .pll_init = uniphier_pro4_pll_init, |
| 101 | .clk_init = uniphier_pro4_clk_init, |
| 102 | }, |
Masahiro Yamada | 75f16f8 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 103 | #endif |
Masahiro Yamada | 53c59ae | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 104 | #if defined(CONFIG_ARCH_UNIPHIER_SLD8) |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 105 | { |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 106 | .soc_id = UNIPHIER_SLD8_ID, |
Masahiro Yamada | 0cc46ad | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 107 | .sbc_init = uniphier_ld4_sbc_init, |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 108 | .pll_init = uniphier_ld4_pll_init, |
| 109 | .clk_init = uniphier_ld4_clk_init, |
| 110 | }, |
Masahiro Yamada | 75f16f8 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 111 | #endif |
Masahiro Yamada | 53c59ae | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 112 | #if defined(CONFIG_ARCH_UNIPHIER_PRO5) |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 113 | { |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 114 | .soc_id = UNIPHIER_PRO5_ID, |
Masahiro Yamada | 0cc46ad | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 115 | .sbc_init = uniphier_sbc_init_savepin, |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 116 | .clk_init = uniphier_pro5_clk_init, |
| 117 | }, |
Masahiro Yamada | d5167d5 | 2015-09-22 00:27:40 +0900 | [diff] [blame] | 118 | #endif |
Masahiro Yamada | 53c59ae | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 119 | #if defined(CONFIG_ARCH_UNIPHIER_PXS2) |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 120 | { |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 121 | .soc_id = UNIPHIER_PXS2_ID, |
Masahiro Yamada | 0cc46ad | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 122 | .sbc_init = uniphier_pxs2_sbc_init, |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 123 | .clk_init = uniphier_pxs2_clk_init, |
| 124 | }, |
Masahiro Yamada | 1fe65d3 | 2015-09-22 00:27:41 +0900 | [diff] [blame] | 125 | #endif |
Masahiro Yamada | 53c59ae | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 126 | #if defined(CONFIG_ARCH_UNIPHIER_LD6B) |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 127 | { |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 128 | .soc_id = UNIPHIER_LD6B_ID, |
Masahiro Yamada | 0cc46ad | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 129 | .sbc_init = uniphier_pxs2_sbc_init, |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 130 | .clk_init = uniphier_pxs2_clk_init, |
| 131 | }, |
Masahiro Yamada | 1fe65d3 | 2015-09-22 00:27:41 +0900 | [diff] [blame] | 132 | #endif |
Masahiro Yamada | 8bbbcbd | 2016-05-24 21:14:01 +0900 | [diff] [blame] | 133 | #if defined(CONFIG_ARCH_UNIPHIER_LD11) |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 134 | { |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 135 | .soc_id = UNIPHIER_LD11_ID, |
Masahiro Yamada | 0cc46ad | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 136 | .sbc_init = uniphier_ld11_sbc_init, |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 137 | .pll_init = uniphier_ld11_pll_init, |
| 138 | .clk_init = uniphier_ld11_clk_init, |
| 139 | .misc_init = uniphier_ld11_misc_init, |
| 140 | }, |
Masahiro Yamada | 8bbbcbd | 2016-05-24 21:14:01 +0900 | [diff] [blame] | 141 | #endif |
Masahiro Yamada | 063eb1e | 2016-04-21 14:43:18 +0900 | [diff] [blame] | 142 | #if defined(CONFIG_ARCH_UNIPHIER_LD20) |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 143 | { |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 144 | .soc_id = UNIPHIER_LD20_ID, |
Masahiro Yamada | 0cc46ad | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 145 | .sbc_init = uniphier_ld11_sbc_init, |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 146 | .pll_init = uniphier_ld20_pll_init, |
Masahiro Yamada | b3b1bb7 | 2017-02-17 16:17:22 +0900 | [diff] [blame] | 147 | .clk_init = uniphier_ld20_clk_init, |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 148 | .misc_init = uniphier_ld20_misc_init, |
| 149 | }, |
Masahiro Yamada | 063eb1e | 2016-04-21 14:43:18 +0900 | [diff] [blame] | 150 | #endif |
Masahiro Yamada | 133b126 | 2017-01-21 18:05:31 +0900 | [diff] [blame] | 151 | #if defined(CONFIG_ARCH_UNIPHIER_PXS3) |
| 152 | { |
| 153 | .soc_id = UNIPHIER_PXS3_ID, |
Masahiro Yamada | 133b126 | 2017-01-21 18:05:31 +0900 | [diff] [blame] | 154 | .sbc_init = uniphier_pxs2_sbc_init, |
| 155 | .pll_init = uniphier_pxs3_pll_init, |
Masahiro Yamada | 8e0a450 | 2017-05-15 14:26:33 +0900 | [diff] [blame] | 156 | .clk_init = uniphier_pxs3_clk_init, |
Masahiro Yamada | 133b126 | 2017-01-21 18:05:31 +0900 | [diff] [blame] | 157 | }, |
| 158 | #endif |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 159 | }; |
Masahiro Yamada | 1b81898 | 2017-01-21 18:05:27 +0900 | [diff] [blame] | 160 | UNIPHIER_DEFINE_SOCDATA_FUNC(uniphier_get_initdata, uniphier_initdata) |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 161 | |
| 162 | int board_init(void) |
| 163 | { |
Masahiro Yamada | f17e598 | 2017-01-21 18:05:21 +0900 | [diff] [blame] | 164 | const struct uniphier_initdata *initdata; |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 165 | |
| 166 | led_puts("U0"); |
| 167 | |
Masahiro Yamada | 1b81898 | 2017-01-21 18:05:27 +0900 | [diff] [blame] | 168 | initdata = uniphier_get_initdata(); |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 169 | if (!initdata) { |
Masahiro Yamada | 1b81898 | 2017-01-21 18:05:27 +0900 | [diff] [blame] | 170 | pr_err("unsupported SoC\n"); |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 171 | return -EINVAL; |
| 172 | } |
| 173 | |
Masahiro Yamada | 0cc46ad | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 174 | initdata->sbc_init(); |
| 175 | |
| 176 | support_card_init(); |
| 177 | |
| 178 | led_puts("U0"); |
| 179 | |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 180 | if (initdata->pll_init) |
| 181 | initdata->pll_init(); |
Masahiro Yamada | 2480256 | 2016-06-29 19:39:03 +0900 | [diff] [blame] | 182 | |
Masahiro Yamada | 285ceed | 2017-08-26 17:58:03 +0900 | [diff] [blame] | 183 | led_puts("U1"); |
Masahiro Yamada | c04368f | 2015-02-27 02:26:51 +0900 | [diff] [blame] | 184 | |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 185 | if (initdata->clk_init) |
| 186 | initdata->clk_init(); |
Masahiro Yamada | e59ed19 | 2016-09-14 01:06:08 +0900 | [diff] [blame] | 187 | |
Masahiro Yamada | 285ceed | 2017-08-26 17:58:03 +0900 | [diff] [blame] | 188 | led_puts("U2"); |
Masahiro Yamada | e59ed19 | 2016-09-14 01:06:08 +0900 | [diff] [blame] | 189 | |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 190 | if (initdata->misc_init) |
| 191 | initdata->misc_init(); |
| 192 | |
Masahiro Yamada | 285ceed | 2017-08-26 17:58:03 +0900 | [diff] [blame] | 193 | led_puts("U3"); |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 194 | |
| 195 | uniphier_setup_xirq(); |
| 196 | |
Masahiro Yamada | 285ceed | 2017-08-26 17:58:03 +0900 | [diff] [blame] | 197 | led_puts("U4"); |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 198 | |
| 199 | support_card_late_init(); |
| 200 | |
Masahiro Yamada | e59ed19 | 2016-09-14 01:06:08 +0900 | [diff] [blame] | 201 | led_puts("Uboo"); |
| 202 | |
Masahiro Yamada | 1f3d9c7 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 203 | return 0; |
| 204 | } |