Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 2 | /* |
| 3 | * board/renesas/blanche/blanche.c |
| 4 | * This file is blanche board support. |
| 5 | * |
| 6 | * Copyright (C) 2016 Renesas Electronics Corporation |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <common.h> |
Simon Glass | afb0215 | 2019-12-28 10:45:01 -0700 | [diff] [blame] | 10 | #include <cpu_func.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 11 | #include <init.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 12 | #include <net.h> |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 13 | #include <asm/arch/mmc.h> |
| 14 | #include <asm/arch/rcar-mstp.h> |
| 15 | #include <asm/arch/rmobile.h> |
| 16 | #include <asm/arch/sh_sdhi.h> |
| 17 | #include <asm/arch/sys_proto.h> |
| 18 | #include <asm/gpio.h> |
| 19 | #include <asm/io.h> |
| 20 | #include <asm/mach-types.h> |
| 21 | #include <asm/processor.h> |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 22 | #include <dm.h> |
| 23 | #include <dm/platform_data/serial_sh.h> |
Simon Glass | 5e6201b | 2019-08-01 09:46:51 -0600 | [diff] [blame] | 24 | #include <env.h> |
Marek Vasut | 24700a2 | 2020-03-21 16:57:58 +0100 | [diff] [blame] | 25 | #include <hang.h> |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 26 | #include <i2c.h> |
Simon Glass | 4dcacfc | 2020-05-10 11:40:13 -0600 | [diff] [blame] | 27 | #include <linux/bitops.h> |
Masahiro Yamada | 56a931c | 2016-09-21 11:28:55 +0900 | [diff] [blame] | 28 | #include <linux/errno.h> |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 29 | #include <malloc.h> |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 30 | #include <miiphy.h> |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 31 | #include <mmc.h> |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 32 | #include <netdev.h> |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 33 | #include "qos.h" |
| 34 | |
| 35 | DECLARE_GLOBAL_DATA_PTR; |
| 36 | |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 37 | #define CPG_PLL1CR 0xE6150028 |
| 38 | #define CPG_PLL3CR 0xE61500DC |
| 39 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 40 | #define TMU0_MSTP125 BIT(25) |
| 41 | #define QSPI_MSTP917 BIT(17) |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 42 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 43 | struct reg_config { |
| 44 | u16 off; |
| 45 | u32 val; |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 46 | }; |
| 47 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 48 | static void blanche_init_sys(void) |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 49 | { |
| 50 | struct rcar_rwdt *rwdt = (struct rcar_rwdt *)RWDT_BASE; |
| 51 | struct rcar_swdt *swdt = (struct rcar_swdt *)SWDT_BASE; |
| 52 | u32 cpu_type; |
| 53 | |
| 54 | cpu_type = rmobile_get_cpu_type(); |
| 55 | if (cpu_type == 0x4A) { |
| 56 | writel(0x4D000000, CPG_PLL1CR); |
| 57 | writel(0x4F000000, CPG_PLL3CR); |
| 58 | } |
| 59 | |
| 60 | /* Watchdog init */ |
| 61 | writel(0xA5A5A500, &rwdt->rwtcsra); |
| 62 | writel(0xA5A5A500, &swdt->swtcsra); |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 63 | } |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 64 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 65 | static void blanche_init_pfc(void) |
| 66 | { |
| 67 | static const struct reg_config pfc_with_unlock[] = { |
| 68 | { 0x0004, 0x0bffffff }, |
| 69 | { 0x0008, 0x002fffff }, |
| 70 | { 0x0014, 0x00000fff }, |
| 71 | { 0x0018, 0x00010fff }, |
| 72 | { 0x001c, 0x00010fff }, |
| 73 | { 0x0020, 0x00010fff }, |
| 74 | { 0x0024, 0x00010fff }, |
| 75 | { 0x0028, 0x00010fff }, |
| 76 | { 0x002c, 0x04006000 }, |
| 77 | { 0x0030, 0x303fefe0 }, |
| 78 | { 0x0058, 0x0002000e }, |
| 79 | }; |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 80 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 81 | static const struct reg_config pfc_without_unlock[] = { |
| 82 | { 0x0108, 0x00000000 }, |
| 83 | { 0x010c, 0x0803FF40 }, |
| 84 | { 0x0110, 0x0000FFFF }, |
| 85 | { 0x0114, 0x00010FFF }, |
| 86 | { 0x011c, 0x0001AFFF }, |
| 87 | { 0x0124, 0x0001CFFF }, |
| 88 | { 0x0128, 0xC0438001 }, |
| 89 | { 0x012c, 0x0FC00007 }, |
| 90 | }; |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 91 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 92 | static const u32 pfc_base = 0xe6060000; |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 93 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 94 | unsigned int i; |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 95 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 96 | for (i = 0; i < ARRAY_SIZE(pfc_with_unlock); i++) { |
| 97 | writel(~pfc_with_unlock[i].val, pfc_base); |
| 98 | writel(pfc_with_unlock[i].val, |
| 99 | pfc_base | pfc_with_unlock[i].off); |
| 100 | } |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 101 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 102 | for (i = 0; i < ARRAY_SIZE(pfc_without_unlock); i++) |
| 103 | writel(pfc_without_unlock[i].val, |
| 104 | pfc_base | pfc_without_unlock[i].off); |
| 105 | } |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 106 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 107 | static void blanche_init_lbsc(void) |
| 108 | { |
| 109 | static const struct reg_config lbsc_config[] = { |
| 110 | { 0x00, 0x00000020 }, |
| 111 | { 0x08, 0x00002020 }, |
| 112 | { 0x30, 0x2a103320 }, |
| 113 | { 0x38, 0x19102110 }, |
| 114 | }; |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 115 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 116 | static const u32 lbsc_base = 0xfec00200; |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 117 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 118 | unsigned int i; |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 119 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 120 | for (i = 0; i < ARRAY_SIZE(lbsc_config); i++) { |
| 121 | writel(lbsc_config[i].val, |
| 122 | lbsc_base | lbsc_config[i].off); |
| 123 | writel(lbsc_config[i].val, |
| 124 | lbsc_base | (lbsc_config[i].off + 4)); |
| 125 | } |
| 126 | } |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 127 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 128 | #if defined(CONFIG_MTD_NOR_FLASH) |
| 129 | static void dbsc_wait(u16 reg) |
| 130 | { |
| 131 | static const u32 dbsc3_0_base = DBSC3_0_BASE; |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 132 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 133 | while (!(readl(dbsc3_0_base + reg) & BIT(0))) |
| 134 | ; |
| 135 | } |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 136 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 137 | static void blanche_init_dbsc(void) |
| 138 | { |
| 139 | static const struct reg_config dbsc_config1[] = { |
| 140 | { 0x0280, 0x0000a55a }, |
| 141 | { 0x0018, 0x21000000 }, |
| 142 | { 0x0018, 0x11000000 }, |
| 143 | { 0x0018, 0x10000000 }, |
| 144 | { 0x0290, 0x00000001 }, |
| 145 | { 0x02a0, 0x80000000 }, |
| 146 | { 0x0290, 0x00000004 }, |
| 147 | }; |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 148 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 149 | static const struct reg_config dbsc_config2[] = { |
| 150 | { 0x0290, 0x00000006 }, |
| 151 | { 0x02a0, 0x0001c000 }, |
| 152 | }; |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 153 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 154 | static const struct reg_config dbsc_config4[] = { |
| 155 | { 0x0290, 0x0000000f }, |
| 156 | { 0x02a0, 0x00181ee4 }, |
| 157 | { 0x0290, 0x00000010 }, |
| 158 | { 0x02a0, 0xf00464db }, |
| 159 | { 0x0290, 0x00000061 }, |
| 160 | { 0x02a0, 0x0000008d }, |
| 161 | { 0x0290, 0x00000001 }, |
| 162 | { 0x02a0, 0x00000073 }, |
| 163 | { 0x0020, 0x00000007 }, |
| 164 | { 0x0024, 0x0f030a02 }, |
| 165 | { 0x0030, 0x00000001 }, |
| 166 | { 0x00b0, 0x00000000 }, |
| 167 | { 0x0040, 0x0000000b }, |
| 168 | { 0x0044, 0x00000008 }, |
| 169 | { 0x0048, 0x00000000 }, |
| 170 | { 0x0050, 0x0000000b }, |
| 171 | { 0x0054, 0x000c000b }, |
| 172 | { 0x0058, 0x00000027 }, |
| 173 | { 0x005c, 0x0000001c }, |
| 174 | { 0x0060, 0x00000006 }, |
| 175 | { 0x0064, 0x00000020 }, |
| 176 | { 0x0068, 0x00000008 }, |
| 177 | { 0x006c, 0x0000000c }, |
| 178 | { 0x0070, 0x00000009 }, |
| 179 | { 0x0074, 0x00000012 }, |
| 180 | { 0x0078, 0x000000d0 }, |
| 181 | { 0x007c, 0x00140005 }, |
| 182 | { 0x0080, 0x00050004 }, |
| 183 | { 0x0084, 0x70233005 }, |
| 184 | { 0x0088, 0x000c0000 }, |
| 185 | { 0x008c, 0x00000300 }, |
| 186 | { 0x0090, 0x00000040 }, |
| 187 | { 0x0100, 0x00000001 }, |
| 188 | { 0x00c0, 0x00020001 }, |
| 189 | { 0x00c8, 0x20082004 }, |
| 190 | { 0x0380, 0x00020002 }, |
| 191 | { 0x0390, 0x0000001f }, |
| 192 | }; |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 193 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 194 | static const struct reg_config dbsc_config5[] = { |
| 195 | { 0x0244, 0x00000011 }, |
| 196 | { 0x0290, 0x00000003 }, |
| 197 | { 0x02a0, 0x0300c4e1 }, |
| 198 | { 0x0290, 0x00000023 }, |
| 199 | { 0x02a0, 0x00fcdb60 }, |
| 200 | { 0x0290, 0x00000011 }, |
| 201 | { 0x02a0, 0x1000040b }, |
| 202 | { 0x0290, 0x00000012 }, |
| 203 | { 0x02a0, 0x9d9cbb66 }, |
| 204 | { 0x0290, 0x00000013 }, |
| 205 | { 0x02a0, 0x1a868400 }, |
| 206 | { 0x0290, 0x00000014 }, |
| 207 | { 0x02a0, 0x300214d8 }, |
| 208 | { 0x0290, 0x00000015 }, |
| 209 | { 0x02a0, 0x00000d70 }, |
| 210 | { 0x0290, 0x00000016 }, |
| 211 | { 0x02a0, 0x00000004 }, |
| 212 | { 0x0290, 0x00000017 }, |
| 213 | { 0x02a0, 0x00000018 }, |
| 214 | { 0x0290, 0x0000001a }, |
| 215 | { 0x02a0, 0x910035c7 }, |
| 216 | { 0x0290, 0x00000004 }, |
| 217 | }; |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 218 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 219 | static const struct reg_config dbsc_config6[] = { |
| 220 | { 0x0290, 0x00000001 }, |
| 221 | { 0x02a0, 0x00000181 }, |
| 222 | { 0x0018, 0x11000000 }, |
| 223 | { 0x0290, 0x00000004 }, |
| 224 | }; |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 225 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 226 | static const struct reg_config dbsc_config7[] = { |
| 227 | { 0x0290, 0x00000001 }, |
| 228 | { 0x02a0, 0x0000fe01 }, |
| 229 | { 0x0304, 0x00000000 }, |
| 230 | { 0x00f4, 0x01004c20 }, |
| 231 | { 0x00f8, 0x014000aa }, |
| 232 | { 0x00e0, 0x00000140 }, |
| 233 | { 0x00e4, 0x00081860 }, |
| 234 | { 0x00e8, 0x00010000 }, |
| 235 | { 0x0290, 0x00000004 }, |
| 236 | }; |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 237 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 238 | static const struct reg_config dbsc_config8[] = { |
| 239 | { 0x0014, 0x00000001 }, |
| 240 | { 0x0010, 0x00000001 }, |
| 241 | { 0x0280, 0x00000000 }, |
| 242 | }; |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 243 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 244 | static const u32 dbsc3_0_base = DBSC3_0_BASE; |
| 245 | unsigned int i; |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 246 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 247 | for (i = 0; i < ARRAY_SIZE(dbsc_config1); i++) |
| 248 | writel(dbsc_config1[i].val, dbsc3_0_base | dbsc_config1[i].off); |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 249 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 250 | dbsc_wait(0x2a0); |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 251 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 252 | for (i = 0; i < ARRAY_SIZE(dbsc_config2); i++) |
| 253 | writel(dbsc_config2[i].val, dbsc3_0_base | dbsc_config2[i].off); |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 254 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 255 | for (i = 0; i < ARRAY_SIZE(dbsc_config4); i++) |
| 256 | writel(dbsc_config4[i].val, dbsc3_0_base | dbsc_config4[i].off); |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 257 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 258 | dbsc_wait(0x240); |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 259 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 260 | for (i = 0; i < ARRAY_SIZE(dbsc_config5); i++) |
| 261 | writel(dbsc_config5[i].val, dbsc3_0_base | dbsc_config5[i].off); |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 262 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 263 | dbsc_wait(0x2a0); |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 264 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 265 | for (i = 0; i < ARRAY_SIZE(dbsc_config6); i++) |
| 266 | writel(dbsc_config6[i].val, dbsc3_0_base | dbsc_config6[i].off); |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 267 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 268 | dbsc_wait(0x2a0); |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 269 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 270 | for (i = 0; i < ARRAY_SIZE(dbsc_config7); i++) |
| 271 | writel(dbsc_config7[i].val, dbsc3_0_base | dbsc_config7[i].off); |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 272 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 273 | dbsc_wait(0x2a0); |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 274 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 275 | for (i = 0; i < ARRAY_SIZE(dbsc_config8); i++) |
| 276 | writel(dbsc_config8[i].val, dbsc3_0_base | dbsc_config8[i].off); |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 277 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 278 | } |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 279 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 280 | static void s_init_wait(volatile unsigned int cnt) |
| 281 | { |
| 282 | volatile u32 i = cnt * 0x10000; |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 283 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 284 | while (i-- > 0) |
| 285 | ; |
| 286 | } |
| 287 | #endif |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 288 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 289 | void s_init(void) |
| 290 | { |
| 291 | blanche_init_sys(); |
| 292 | qos_init(); |
| 293 | blanche_init_pfc(); |
| 294 | blanche_init_lbsc(); |
| 295 | #if defined(CONFIG_MTD_NOR_FLASH) |
| 296 | s_init_wait(10); |
| 297 | blanche_init_dbsc(); |
Masahiro Yamada | 8cea9b5 | 2017-02-11 22:43:54 +0900 | [diff] [blame] | 298 | #endif /* CONFIG_MTD_NOR_FLASH */ |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 299 | } |
| 300 | |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 301 | int board_early_init_f(void) |
| 302 | { |
| 303 | /* TMU0 */ |
| 304 | mstp_clrbits_le32(MSTPSR1, SMSTPCR1, TMU0_MSTP125); |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 305 | /* QSPI */ |
| 306 | mstp_clrbits_le32(MSTPSR9, SMSTPCR9, QSPI_MSTP917); |
| 307 | |
| 308 | return 0; |
| 309 | } |
| 310 | |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 311 | int board_init(void) |
| 312 | { |
| 313 | /* adress of boot parameters */ |
| 314 | gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100; |
| 315 | |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 316 | return 0; |
| 317 | } |
| 318 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 319 | /* Added for BLANCHE(R-CarV2H board) */ |
Marek Vasut | 9169145 | 2020-03-21 17:38:57 +0100 | [diff] [blame] | 320 | #ifndef CONFIG_DM_ETH |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 321 | int board_eth_init(struct bd_info *bis) |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 322 | { |
| 323 | int rc = 0; |
| 324 | |
| 325 | #ifdef CONFIG_SMC911X |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 326 | struct eth_device *dev; |
| 327 | uchar eth_addr[6]; |
| 328 | |
| 329 | rc = smc911x_initialize(0, CONFIG_SMC911X_BASE); |
| 330 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 331 | if (!eth_env_get_enetaddr("ethaddr", eth_addr)) { |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 332 | dev = eth_get_dev_by_index(0); |
| 333 | if (dev) { |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 334 | eth_env_set_enetaddr("ethaddr", dev->enetaddr); |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 335 | } else { |
| 336 | printf("blanche: Couldn't get eth device\n"); |
| 337 | rc = -1; |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | #endif |
| 342 | |
| 343 | return rc; |
| 344 | } |
Marek Vasut | 9169145 | 2020-03-21 17:38:57 +0100 | [diff] [blame] | 345 | #endif |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 346 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 347 | int dram_init(void) |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 348 | { |
Siva Durga Prasad Paladugu | b3d55ea | 2018-07-16 15:56:11 +0530 | [diff] [blame] | 349 | if (fdtdec_setup_mem_size_base() != 0) |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 350 | return -EINVAL; |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 351 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 352 | return 0; |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 353 | } |
| 354 | |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 355 | int dram_init_banksize(void) |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 356 | { |
Marek Vasut | 927b1e3 | 2018-04-30 14:10:36 +0200 | [diff] [blame] | 357 | fdtdec_setup_memory_banksize(); |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 358 | |
| 359 | return 0; |
| 360 | } |
| 361 | |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 362 | void reset_cpu(ulong addr) |
| 363 | { |
Marek Vasut | 24700a2 | 2020-03-21 16:57:58 +0100 | [diff] [blame] | 364 | struct udevice *dev; |
| 365 | const u8 pmic_bus = 6; |
| 366 | const u8 pmic_addr = 0x58; |
| 367 | u8 data; |
| 368 | int ret; |
| 369 | |
| 370 | ret = i2c_get_chip_for_busnum(pmic_bus, pmic_addr, 1, &dev); |
| 371 | if (ret) |
| 372 | hang(); |
| 373 | |
| 374 | ret = dm_i2c_read(dev, 0x13, &data, 1); |
| 375 | if (ret) |
| 376 | hang(); |
| 377 | |
| 378 | data |= BIT(1); |
| 379 | |
| 380 | ret = dm_i2c_write(dev, 0x13, &data, 1); |
| 381 | if (ret) |
| 382 | hang(); |
masakazu.mochizuki.wd@hitachi.com | 9d0e937 | 2016-04-12 17:11:41 +0900 | [diff] [blame] | 383 | } |