Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Adrian Alonso | 2b3d961 | 2015-09-02 13:54:19 -0500 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2015 Freescale Semiconductor, Inc. |
Adrian Alonso | 2b3d961 | 2015-09-02 13:54:19 -0500 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 7 | #include <init.h> |
Adrian Alonso | 2b3d961 | 2015-09-02 13:54:19 -0500 | [diff] [blame] | 8 | #include <asm/io.h> |
| 9 | #include <asm/arch/imx-regs.h> |
| 10 | #include <asm/arch/clock.h> |
| 11 | #include <asm/arch/sys_proto.h> |
Stefano Babic | 33731bc | 2017-06-29 10:16:06 +0200 | [diff] [blame] | 12 | #include <asm/mach-imx/dma.h> |
| 13 | #include <asm/mach-imx/hab.h> |
| 14 | #include <asm/mach-imx/rdc-sema.h> |
Peng Fan | 4784249 | 2016-01-28 16:55:09 +0800 | [diff] [blame] | 15 | #include <asm/arch/imx-rdc.h> |
Adrian Alonso | 2b3d961 | 2015-09-02 13:54:19 -0500 | [diff] [blame] | 16 | #include <asm/arch/crm_regs.h> |
| 17 | #include <dm.h> |
Simon Glass | 5e6201b | 2019-08-01 09:46:51 -0600 | [diff] [blame] | 18 | #include <env.h> |
Adrian Alonso | 2b3d961 | 2015-09-02 13:54:19 -0500 | [diff] [blame] | 19 | #include <imx_thermal.h> |
Bryan O'Donoghue | 1ec9d9d | 2018-01-26 16:27:58 +0000 | [diff] [blame] | 20 | #include <fsl_sec.h> |
Bryan O'Donoghue | 0cdded8 | 2018-03-26 15:27:32 +0100 | [diff] [blame] | 21 | #include <asm/setup.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 22 | #include <linux/delay.h> |
Adrian Alonso | 2b3d961 | 2015-09-02 13:54:19 -0500 | [diff] [blame] | 23 | |
Anson Huang | 9d61854 | 2018-08-08 09:17:49 +0800 | [diff] [blame] | 24 | #define IOMUXC_GPR1 0x4 |
| 25 | #define BM_IOMUXC_GPR1_IRQ 0x1000 |
| 26 | |
| 27 | #define GPC_LPCR_A7_BSC 0x0 |
| 28 | #define GPC_LPCR_M4 0x8 |
| 29 | #define GPC_SLPCR 0x14 |
| 30 | #define GPC_PGC_ACK_SEL_A7 0x24 |
| 31 | #define GPC_IMR1_CORE0 0x30 |
| 32 | #define GPC_IMR1_CORE1 0x40 |
| 33 | #define GPC_IMR1_M4 0x50 |
| 34 | #define GPC_PGC_CPU_MAPPING 0xec |
| 35 | #define GPC_PGC_C0_PUPSCR 0x804 |
| 36 | #define GPC_PGC_SCU_TIMING 0x890 |
| 37 | #define GPC_PGC_C1_PUPSCR 0x844 |
| 38 | |
| 39 | #define BM_LPCR_A7_BSC_IRQ_SRC_A7_WAKEUP 0x70000000 |
| 40 | #define BM_LPCR_A7_BSC_CPU_CLK_ON_LPM 0x4000 |
| 41 | #define BM_LPCR_M4_MASK_DSM_TRIGGER 0x80000000 |
| 42 | #define BM_SLPCR_EN_DSM 0x80000000 |
| 43 | #define BM_SLPCR_RBC_EN 0x40000000 |
| 44 | #define BM_SLPCR_REG_BYPASS_COUNT 0x3f000000 |
| 45 | #define BM_SLPCR_VSTBY 0x4 |
| 46 | #define BM_SLPCR_SBYOS 0x2 |
| 47 | #define BM_SLPCR_BYPASS_PMIC_READY 0x1 |
| 48 | #define BM_SLPCR_EN_A7_FASTWUP_WAIT_MODE 0x10000 |
| 49 | |
| 50 | #define BM_GPC_PGC_ACK_SEL_A7_DUMMY_PUP_ACK 0x80000000 |
| 51 | #define BM_GPC_PGC_ACK_SEL_A7_DUMMY_PDN_ACK 0x8000 |
| 52 | |
| 53 | #define BM_GPC_PGC_CORE_PUPSCR 0x7fff80 |
| 54 | |
Adrian Alonso | 2b3d961 | 2015-09-02 13:54:19 -0500 | [diff] [blame] | 55 | #if defined(CONFIG_IMX_THERMAL) |
| 56 | static const struct imx_thermal_plat imx7_thermal_plat = { |
| 57 | .regs = (void *)ANATOP_BASE_ADDR, |
| 58 | .fuse_bank = 3, |
| 59 | .fuse_word = 3, |
| 60 | }; |
| 61 | |
| 62 | U_BOOT_DEVICE(imx7_thermal) = { |
| 63 | .name = "imx_thermal", |
| 64 | .platdata = &imx7_thermal_plat, |
| 65 | }; |
| 66 | #endif |
| 67 | |
Peng Fan | 77d3aeb | 2017-08-12 22:10:57 +0800 | [diff] [blame] | 68 | #if CONFIG_IS_ENABLED(IMX_RDC) |
Peng Fan | 4784249 | 2016-01-28 16:55:09 +0800 | [diff] [blame] | 69 | /* |
| 70 | * In current design, if any peripheral was assigned to both A7 and M4, |
| 71 | * it will receive ipg_stop or ipg_wait when any of the 2 platforms enter |
| 72 | * low power mode. So M4 sleep will cause some peripherals fail to work |
| 73 | * at A7 core side. At default, all resources are in domain 0 - 3. |
| 74 | * |
| 75 | * There are 26 peripherals impacted by this IC issue: |
| 76 | * SIM2(sim2/emvsim2) |
| 77 | * SIM1(sim1/emvsim1) |
| 78 | * UART1/UART2/UART3/UART4/UART5/UART6/UART7 |
| 79 | * SAI1/SAI2/SAI3 |
| 80 | * WDOG1/WDOG2/WDOG3/WDOG4 |
| 81 | * GPT1/GPT2/GPT3/GPT4 |
| 82 | * PWM1/PWM2/PWM3/PWM4 |
| 83 | * ENET1/ENET2 |
| 84 | * Software Workaround: |
| 85 | * Here we setup some resources to domain 0 where M4 codes will move |
| 86 | * the M4 out of this domain. Then M4 is not able to access them any longer. |
| 87 | * This is a workaround for ic issue. So the peripherals are not shared |
| 88 | * by them. This way requires the uboot implemented the RDC driver and |
| 89 | * set the 26 IPs above to domain 0 only. M4 code will assign resource |
| 90 | * to its own domain, if it want to use the resource. |
| 91 | */ |
| 92 | static rdc_peri_cfg_t const resources[] = { |
| 93 | (RDC_PER_SIM1 | RDC_DOMAIN(0)), |
| 94 | (RDC_PER_SIM2 | RDC_DOMAIN(0)), |
| 95 | (RDC_PER_UART1 | RDC_DOMAIN(0)), |
| 96 | (RDC_PER_UART2 | RDC_DOMAIN(0)), |
| 97 | (RDC_PER_UART3 | RDC_DOMAIN(0)), |
| 98 | (RDC_PER_UART4 | RDC_DOMAIN(0)), |
| 99 | (RDC_PER_UART5 | RDC_DOMAIN(0)), |
| 100 | (RDC_PER_UART6 | RDC_DOMAIN(0)), |
| 101 | (RDC_PER_UART7 | RDC_DOMAIN(0)), |
| 102 | (RDC_PER_SAI1 | RDC_DOMAIN(0)), |
| 103 | (RDC_PER_SAI2 | RDC_DOMAIN(0)), |
| 104 | (RDC_PER_SAI3 | RDC_DOMAIN(0)), |
| 105 | (RDC_PER_WDOG1 | RDC_DOMAIN(0)), |
| 106 | (RDC_PER_WDOG2 | RDC_DOMAIN(0)), |
| 107 | (RDC_PER_WDOG3 | RDC_DOMAIN(0)), |
| 108 | (RDC_PER_WDOG4 | RDC_DOMAIN(0)), |
| 109 | (RDC_PER_GPT1 | RDC_DOMAIN(0)), |
| 110 | (RDC_PER_GPT2 | RDC_DOMAIN(0)), |
| 111 | (RDC_PER_GPT3 | RDC_DOMAIN(0)), |
| 112 | (RDC_PER_GPT4 | RDC_DOMAIN(0)), |
| 113 | (RDC_PER_PWM1 | RDC_DOMAIN(0)), |
| 114 | (RDC_PER_PWM2 | RDC_DOMAIN(0)), |
| 115 | (RDC_PER_PWM3 | RDC_DOMAIN(0)), |
| 116 | (RDC_PER_PWM4 | RDC_DOMAIN(0)), |
| 117 | (RDC_PER_ENET1 | RDC_DOMAIN(0)), |
| 118 | (RDC_PER_ENET2 | RDC_DOMAIN(0)), |
| 119 | }; |
| 120 | |
| 121 | static void isolate_resource(void) |
| 122 | { |
| 123 | imx_rdc_setup_peripherals(resources, ARRAY_SIZE(resources)); |
| 124 | } |
| 125 | #endif |
| 126 | |
Stefano Babic | f8b509b | 2019-09-20 08:47:53 +0200 | [diff] [blame] | 127 | #if defined(CONFIG_IMX_HAB) |
Adrian Alonso | fcc8cb3 | 2015-10-12 13:48:13 -0500 | [diff] [blame] | 128 | struct imx_sec_config_fuse_t const imx_sec_config_fuse = { |
| 129 | .bank = 1, |
| 130 | .word = 3, |
| 131 | }; |
| 132 | #endif |
| 133 | |
Fabio Estevam | f6ced1b | 2016-02-28 12:33:17 -0300 | [diff] [blame] | 134 | static bool is_mx7d(void) |
| 135 | { |
| 136 | struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR; |
| 137 | struct fuse_bank *bank = &ocotp->bank[1]; |
| 138 | struct fuse_bank1_regs *fuse = |
| 139 | (struct fuse_bank1_regs *)bank->fuse_regs; |
| 140 | int val; |
| 141 | |
| 142 | val = readl(&fuse->tester4); |
| 143 | if (val & 1) |
| 144 | return false; |
| 145 | else |
| 146 | return true; |
| 147 | } |
| 148 | |
Adrian Alonso | 2b3d961 | 2015-09-02 13:54:19 -0500 | [diff] [blame] | 149 | u32 get_cpu_rev(void) |
| 150 | { |
| 151 | struct mxc_ccm_anatop_reg *ccm_anatop = (struct mxc_ccm_anatop_reg *) |
| 152 | ANATOP_BASE_ADDR; |
| 153 | u32 reg = readl(&ccm_anatop->digprog); |
| 154 | u32 type = (reg >> 16) & 0xff; |
| 155 | |
Fabio Estevam | f6ced1b | 2016-02-28 12:33:17 -0300 | [diff] [blame] | 156 | if (!is_mx7d()) |
| 157 | type = MXC_CPU_MX7S; |
| 158 | |
Adrian Alonso | 2b3d961 | 2015-09-02 13:54:19 -0500 | [diff] [blame] | 159 | reg &= 0xff; |
| 160 | return (type << 12) | reg; |
| 161 | } |
| 162 | |
| 163 | #ifdef CONFIG_REVISION_TAG |
| 164 | u32 __weak get_board_rev(void) |
| 165 | { |
| 166 | return get_cpu_rev(); |
| 167 | } |
| 168 | #endif |
| 169 | |
Peng Fan | eb518d5 | 2016-01-04 13:16:41 +0800 | [diff] [blame] | 170 | static void imx_enet_mdio_fixup(void) |
| 171 | { |
| 172 | struct iomuxc_gpr_base_regs *gpr_regs = |
| 173 | (struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR; |
| 174 | |
| 175 | /* |
| 176 | * The management data input/output (MDIO) requires open-drain, |
| 177 | * i.MX7D TO1.0 ENET MDIO pin has no open drain, but TO1.1 supports |
| 178 | * this feature. So to TO1.1, need to enable open drain by setting |
| 179 | * bits GPR0[8:7]. |
| 180 | */ |
| 181 | |
| 182 | if (soc_rev() >= CHIP_REV_1_1) { |
| 183 | setbits_le32(&gpr_regs->gpr[0], |
| 184 | IOMUXC_GPR_GPR0_ENET_MDIO_OPEN_DRAIN_MASK); |
| 185 | } |
| 186 | } |
| 187 | |
Jun Nie | 9b1c85a | 2019-05-08 14:38:30 +0800 | [diff] [blame] | 188 | static void init_cpu_basic(void) |
| 189 | { |
| 190 | imx_enet_mdio_fixup(); |
| 191 | |
| 192 | #ifdef CONFIG_APBH_DMA |
| 193 | /* Start APBH DMA */ |
| 194 | mxs_dma_init(); |
| 195 | #endif |
| 196 | } |
| 197 | |
Igor Opaniuk | b65af98 | 2019-12-30 13:56:44 +0200 | [diff] [blame] | 198 | #ifdef CONFIG_IMX_BOOTAUX |
| 199 | /* |
| 200 | * Table of mappings of physical mem regions in both |
| 201 | * Cortex-A7 and Cortex-M4 address spaces. |
| 202 | * |
| 203 | * For additional details check sections 2.1.2 and 2.1.3 in |
| 204 | * i.MX7Dual Applications Processor Reference Manual |
| 205 | * |
| 206 | */ |
| 207 | const struct rproc_att hostmap[] = { |
| 208 | /* aux core , host core, size */ |
| 209 | { 0x00000000, 0x00180000, 0x8000 }, /* OCRAM_S */ |
| 210 | { 0x00180000, 0x00180000, 0x8000 }, /* OCRAM_S */ |
| 211 | { 0x20180000, 0x00180000, 0x8000 }, /* OCRAM_S */ |
| 212 | { 0x1fff8000, 0x007f8000, 0x8000 }, /* TCML */ |
| 213 | { 0x20000000, 0x00800000, 0x8000 }, /* TCMU */ |
| 214 | { 0x00900000, 0x00900000, 0x20000 }, /* OCRAM_128KB */ |
| 215 | { 0x20200000, 0x00900000, 0x20000 }, /* OCRAM_128KB */ |
| 216 | { 0x00920000, 0x00920000, 0x20000 }, /* OCRAM_EPDC */ |
| 217 | { 0x20220000, 0x00920000, 0x20000 }, /* OCRAM_EPDC */ |
| 218 | { 0x00940000, 0x00940000, 0x20000 }, /* OCRAM_PXP */ |
| 219 | { 0x20240000, 0x00940000, 0x20000 }, /* OCRAM_PXP */ |
| 220 | { 0x10000000, 0x80000000, 0x0fff0000 }, /* DDR Code alias */ |
Igor Opaniuk | 02239e2 | 2020-07-15 13:30:52 +0300 | [diff] [blame] | 221 | { 0x80000000, 0x80000000, 0x60000000 }, /* DDRC */ |
Igor Opaniuk | b65af98 | 2019-12-30 13:56:44 +0200 | [diff] [blame] | 222 | { /* sentinel */ } |
| 223 | }; |
| 224 | #endif |
| 225 | |
Jun Nie | 9b1c85a | 2019-05-08 14:38:30 +0800 | [diff] [blame] | 226 | #ifndef CONFIG_SKIP_LOWLEVEL_INIT |
| 227 | /* enable all periherial can be accessed in nosec mode */ |
| 228 | static void init_csu(void) |
| 229 | { |
| 230 | int i = 0; |
| 231 | |
| 232 | for (i = 0; i < CSU_NUM_REGS; i++) |
| 233 | writel(CSU_INIT_SEC_LEVEL0, CSU_IPS_BASE_ADDR + i * 4); |
| 234 | } |
| 235 | |
Anson Huang | 9d61854 | 2018-08-08 09:17:49 +0800 | [diff] [blame] | 236 | static void imx_gpcv2_init(void) |
| 237 | { |
| 238 | u32 val, i; |
| 239 | |
| 240 | /* |
| 241 | * Force IOMUXC irq pending, so that the interrupt to GPC can be |
| 242 | * used to deassert dsm_request signal when the signal gets |
| 243 | * asserted unexpectedly. |
| 244 | */ |
| 245 | val = readl(IOMUXC_GPR_BASE_ADDR + IOMUXC_GPR1); |
| 246 | val |= BM_IOMUXC_GPR1_IRQ; |
| 247 | writel(val, IOMUXC_GPR_BASE_ADDR + IOMUXC_GPR1); |
| 248 | |
| 249 | /* Initially mask all interrupts */ |
| 250 | for (i = 0; i < 4; i++) { |
| 251 | writel(~0, GPC_IPS_BASE_ADDR + GPC_IMR1_CORE0 + i * 4); |
| 252 | writel(~0, GPC_IPS_BASE_ADDR + GPC_IMR1_CORE1 + i * 4); |
| 253 | writel(~0, GPC_IPS_BASE_ADDR + GPC_IMR1_M4 + i * 4); |
| 254 | } |
| 255 | |
| 256 | /* set SCU timing */ |
| 257 | writel((0x59 << 10) | 0x5B | (0x2 << 20), |
| 258 | GPC_IPS_BASE_ADDR + GPC_PGC_SCU_TIMING); |
| 259 | |
| 260 | /* only external IRQs to wake up LPM and core 0/1 */ |
| 261 | val = readl(GPC_IPS_BASE_ADDR + GPC_LPCR_A7_BSC); |
| 262 | val |= BM_LPCR_A7_BSC_IRQ_SRC_A7_WAKEUP; |
| 263 | writel(val, GPC_IPS_BASE_ADDR + GPC_LPCR_A7_BSC); |
| 264 | |
| 265 | /* set C0 power up timming per design requirement */ |
| 266 | val = readl(GPC_IPS_BASE_ADDR + GPC_PGC_C0_PUPSCR); |
| 267 | val &= ~BM_GPC_PGC_CORE_PUPSCR; |
| 268 | val |= (0x1A << 7); |
| 269 | writel(val, GPC_IPS_BASE_ADDR + GPC_PGC_C0_PUPSCR); |
| 270 | |
| 271 | /* set C1 power up timming per design requirement */ |
| 272 | val = readl(GPC_IPS_BASE_ADDR + GPC_PGC_C1_PUPSCR); |
| 273 | val &= ~BM_GPC_PGC_CORE_PUPSCR; |
| 274 | val |= (0x1A << 7); |
| 275 | writel(val, GPC_IPS_BASE_ADDR + GPC_PGC_C1_PUPSCR); |
| 276 | |
| 277 | /* dummy ack for time slot by default */ |
| 278 | writel(BM_GPC_PGC_ACK_SEL_A7_DUMMY_PUP_ACK | |
| 279 | BM_GPC_PGC_ACK_SEL_A7_DUMMY_PDN_ACK, |
| 280 | GPC_IPS_BASE_ADDR + GPC_PGC_ACK_SEL_A7); |
| 281 | |
| 282 | /* mask M4 DSM trigger */ |
| 283 | writel(readl(GPC_IPS_BASE_ADDR + GPC_LPCR_M4) | |
| 284 | BM_LPCR_M4_MASK_DSM_TRIGGER, |
| 285 | GPC_IPS_BASE_ADDR + GPC_LPCR_M4); |
| 286 | |
| 287 | /* set mega/fast mix in A7 domain */ |
| 288 | writel(0x1, GPC_IPS_BASE_ADDR + GPC_PGC_CPU_MAPPING); |
| 289 | |
| 290 | /* DSM related settings */ |
| 291 | val = readl(GPC_IPS_BASE_ADDR + GPC_SLPCR); |
| 292 | val &= ~(BM_SLPCR_EN_DSM | BM_SLPCR_VSTBY | BM_SLPCR_RBC_EN | |
| 293 | BM_SLPCR_SBYOS | BM_SLPCR_BYPASS_PMIC_READY | |
| 294 | BM_SLPCR_REG_BYPASS_COUNT); |
| 295 | val |= BM_SLPCR_EN_A7_FASTWUP_WAIT_MODE; |
| 296 | writel(val, GPC_IPS_BASE_ADDR + GPC_SLPCR); |
| 297 | |
| 298 | /* |
| 299 | * disabling RBC need to delay at least 2 cycles of CKIL(32K) |
| 300 | * due to hardware design requirement, which is |
| 301 | * ~61us, here we use 65us for safe |
| 302 | */ |
| 303 | udelay(65); |
| 304 | } |
| 305 | |
Adrian Alonso | 2b3d961 | 2015-09-02 13:54:19 -0500 | [diff] [blame] | 306 | int arch_cpu_init(void) |
| 307 | { |
| 308 | init_aips(); |
| 309 | |
Peng Fan | fcd53ce | 2015-10-23 10:13:04 +0800 | [diff] [blame] | 310 | init_csu(); |
Adrian Alonso | 2b3d961 | 2015-09-02 13:54:19 -0500 | [diff] [blame] | 311 | /* Disable PDE bit of WMCR register */ |
Fabio Estevam | 5f79d46 | 2017-11-23 10:55:33 -0200 | [diff] [blame] | 312 | imx_wdog_disable_powerdown(); |
Adrian Alonso | 2b3d961 | 2015-09-02 13:54:19 -0500 | [diff] [blame] | 313 | |
Jun Nie | 9b1c85a | 2019-05-08 14:38:30 +0800 | [diff] [blame] | 314 | init_cpu_basic(); |
Adrian Alonso | 2b3d961 | 2015-09-02 13:54:19 -0500 | [diff] [blame] | 315 | |
Peng Fan | 77d3aeb | 2017-08-12 22:10:57 +0800 | [diff] [blame] | 316 | #if CONFIG_IS_ENABLED(IMX_RDC) |
| 317 | isolate_resource(); |
| 318 | #endif |
Peng Fan | 4784249 | 2016-01-28 16:55:09 +0800 | [diff] [blame] | 319 | |
Bryan O'Donoghue | 0290ea0 | 2018-04-05 19:46:06 +0100 | [diff] [blame] | 320 | init_snvs(); |
| 321 | |
Anson Huang | 9d61854 | 2018-08-08 09:17:49 +0800 | [diff] [blame] | 322 | imx_gpcv2_init(); |
| 323 | |
Adrian Alonso | 2b3d961 | 2015-09-02 13:54:19 -0500 | [diff] [blame] | 324 | return 0; |
| 325 | } |
Jun Nie | 9b1c85a | 2019-05-08 14:38:30 +0800 | [diff] [blame] | 326 | #else |
| 327 | int arch_cpu_init(void) |
| 328 | { |
| 329 | init_cpu_basic(); |
| 330 | |
| 331 | return 0; |
| 332 | } |
Rui Miguel Silva | d1bb7a0 | 2018-09-05 11:56:05 +0100 | [diff] [blame] | 333 | #endif |
Adrian Alonso | 2b3d961 | 2015-09-02 13:54:19 -0500 | [diff] [blame] | 334 | |
Stefan Agner | 42dac20 | 2016-07-13 00:25:39 -0700 | [diff] [blame] | 335 | #ifdef CONFIG_ARCH_MISC_INIT |
| 336 | int arch_misc_init(void) |
| 337 | { |
| 338 | #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG |
| 339 | if (is_mx7d()) |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 340 | env_set("soc", "imx7d"); |
Stefan Agner | 42dac20 | 2016-07-13 00:25:39 -0700 | [diff] [blame] | 341 | else |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 342 | env_set("soc", "imx7s"); |
Stefan Agner | 42dac20 | 2016-07-13 00:25:39 -0700 | [diff] [blame] | 343 | #endif |
| 344 | |
Bryan O'Donoghue | 1ec9d9d | 2018-01-26 16:27:58 +0000 | [diff] [blame] | 345 | #ifdef CONFIG_FSL_CAAM |
| 346 | sec_init(); |
| 347 | #endif |
| 348 | |
Stefan Agner | 42dac20 | 2016-07-13 00:25:39 -0700 | [diff] [blame] | 349 | return 0; |
| 350 | } |
| 351 | #endif |
| 352 | |
Adrian Alonso | 2b3d961 | 2015-09-02 13:54:19 -0500 | [diff] [blame] | 353 | #ifdef CONFIG_SERIAL_TAG |
Bryan O'Donoghue | 3031d43 | 2018-03-26 15:27:33 +0100 | [diff] [blame] | 354 | /* |
| 355 | * OCOTP_TESTER |
| 356 | * i.MX 7Solo Applications Processor Reference Manual, Rev. 0.1, 08/2016 |
| 357 | * OCOTP_TESTER describes a unique ID based on silicon wafer |
| 358 | * and die X/Y position |
| 359 | * |
| 360 | * OCOTOP_TESTER offset 0x410 |
| 361 | * 31:0 fuse 0 |
| 362 | * FSL-wide unique, encoded LOT ID STD II/SJC CHALLENGE/ Unique ID |
| 363 | * |
| 364 | * OCOTP_TESTER1 offset 0x420 |
| 365 | * 31:24 fuse 1 |
| 366 | * The X-coordinate of the die location on the wafer/SJC CHALLENGE/ Unique ID |
| 367 | * 23:16 fuse 1 |
| 368 | * The Y-coordinate of the die location on the wafer/SJC CHALLENGE/ Unique ID |
| 369 | * 15:11 fuse 1 |
| 370 | * The wafer number of the wafer on which the device was fabricated/SJC |
| 371 | * CHALLENGE/ Unique ID |
| 372 | * 10:0 fuse 1 |
| 373 | * FSL-wide unique, encoded LOT ID STD II/SJC CHALLENGE/ Unique ID |
| 374 | */ |
Adrian Alonso | 2b3d961 | 2015-09-02 13:54:19 -0500 | [diff] [blame] | 375 | void get_board_serial(struct tag_serialnr *serialnr) |
| 376 | { |
| 377 | struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR; |
| 378 | struct fuse_bank *bank = &ocotp->bank[0]; |
| 379 | struct fuse_bank0_regs *fuse = |
| 380 | (struct fuse_bank0_regs *)bank->fuse_regs; |
| 381 | |
| 382 | serialnr->low = fuse->tester0; |
| 383 | serialnr->high = fuse->tester1; |
| 384 | } |
| 385 | #endif |
| 386 | |
Adrian Alonso | 2b3d961 | 2015-09-02 13:54:19 -0500 | [diff] [blame] | 387 | void set_wdog_reset(struct wdog_regs *wdog) |
| 388 | { |
| 389 | u32 reg = readw(&wdog->wcr); |
| 390 | /* |
| 391 | * Output WDOG_B signal to reset external pmic or POR_B decided by |
| 392 | * the board desgin. Without external reset, the peripherals/DDR/ |
| 393 | * PMIC are not reset, that may cause system working abnormal. |
| 394 | */ |
| 395 | reg = readw(&wdog->wcr); |
| 396 | reg |= 1 << 3; |
| 397 | /* |
| 398 | * WDZST bit is write-once only bit. Align this bit in kernel, |
| 399 | * otherwise kernel code will have no chance to set this bit. |
| 400 | */ |
| 401 | reg |= 1 << 0; |
| 402 | writew(reg, &wdog->wcr); |
| 403 | } |
| 404 | |
Adrian Alonso | 2b3d961 | 2015-09-02 13:54:19 -0500 | [diff] [blame] | 405 | void s_init(void) |
| 406 | { |
Adrian Alonso | 2b3d961 | 2015-09-02 13:54:19 -0500 | [diff] [blame] | 407 | /* clock configuration. */ |
| 408 | clock_init(); |
| 409 | |
| 410 | return; |
| 411 | } |
Peng Fan | 99c874b | 2016-05-19 13:02:16 +0800 | [diff] [blame] | 412 | |
| 413 | void reset_misc(void) |
| 414 | { |
Fabio Estevam | ad5fbe0 | 2018-12-11 16:40:37 -0200 | [diff] [blame] | 415 | #ifndef CONFIG_SPL_BUILD |
Igor Opaniuk | f5abe40 | 2019-06-04 00:05:59 +0300 | [diff] [blame] | 416 | #if defined(CONFIG_VIDEO_MXS) && !defined(CONFIG_DM_VIDEO) |
Peng Fan | 99c874b | 2016-05-19 13:02:16 +0800 | [diff] [blame] | 417 | lcdif_power_down(); |
| 418 | #endif |
Fabio Estevam | ad5fbe0 | 2018-12-11 16:40:37 -0200 | [diff] [blame] | 419 | #endif |
Peng Fan | 99c874b | 2016-05-19 13:02:16 +0800 | [diff] [blame] | 420 | } |
| 421 | |