Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2007 |
| 4 | * Sascha Hauer, Pengutronix |
| 5 | * |
| 6 | * (C) Copyright 2009 Freescale Semiconductor, Inc. |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <common.h> |
Simon Glass | a7b5130 | 2019-11-14 12:57:46 -0700 | [diff] [blame] | 10 | #include <init.h> |
Masahiro Yamada | 56a931c | 2016-09-21 11:28:55 +0900 | [diff] [blame] | 11 | #include <linux/errno.h> |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 12 | #include <asm/io.h> |
| 13 | #include <asm/arch/imx-regs.h> |
| 14 | #include <asm/arch/clock.h> |
| 15 | #include <asm/arch/sys_proto.h> |
Diego Dorta | 3a5bf53 | 2017-09-27 13:12:37 -0300 | [diff] [blame] | 16 | #include <asm/bootm.h> |
Stefano Babic | 33731bc | 2017-06-29 10:16:06 +0200 | [diff] [blame] | 17 | #include <asm/mach-imx/boot_mode.h> |
| 18 | #include <asm/mach-imx/dma.h> |
| 19 | #include <asm/mach-imx/hab.h> |
Fabio Estevam | 48e65b0 | 2013-02-07 06:45:23 +0000 | [diff] [blame] | 20 | #include <stdbool.h> |
Pardeep Kumar Singla | c1fa130 | 2013-07-25 12:12:13 -0500 | [diff] [blame] | 21 | #include <asm/arch/mxc_hdmi.h> |
| 22 | #include <asm/arch/crm_regs.h> |
Ye.Li | f19692c | 2014-11-20 21:14:14 +0800 | [diff] [blame] | 23 | #include <dm.h> |
| 24 | #include <imx_thermal.h> |
Soeren Moch | bc177f1 | 2016-02-04 14:41:15 +0100 | [diff] [blame] | 25 | #include <mmc.h> |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 26 | |
Fabio Estevam | a47ec52 | 2013-12-26 14:51:33 -0200 | [diff] [blame] | 27 | enum ldo_reg { |
| 28 | LDO_ARM, |
| 29 | LDO_SOC, |
| 30 | LDO_PU, |
| 31 | }; |
| 32 | |
Troy Kisky | 5839493 | 2012-10-23 10:57:46 +0000 | [diff] [blame] | 33 | struct scu_regs { |
| 34 | u32 ctrl; |
| 35 | u32 config; |
| 36 | u32 status; |
| 37 | u32 invalidate; |
| 38 | u32 fpga_rev; |
| 39 | }; |
| 40 | |
Adrian Alonso | ce08c36 | 2015-09-02 13:54:13 -0500 | [diff] [blame] | 41 | #if defined(CONFIG_IMX_THERMAL) |
Ye.Li | f19692c | 2014-11-20 21:14:14 +0800 | [diff] [blame] | 42 | static const struct imx_thermal_plat imx6_thermal_plat = { |
| 43 | .regs = (void *)ANATOP_BASE_ADDR, |
| 44 | .fuse_bank = 1, |
| 45 | .fuse_word = 6, |
| 46 | }; |
| 47 | |
| 48 | U_BOOT_DEVICE(imx6_thermal) = { |
| 49 | .name = "imx_thermal", |
| 50 | .platdata = &imx6_thermal_plat, |
| 51 | }; |
| 52 | #endif |
| 53 | |
Stefano Babic | f8b509b | 2019-09-20 08:47:53 +0200 | [diff] [blame] | 54 | #if defined(CONFIG_IMX_HAB) |
Adrian Alonso | 6ec8d84 | 2015-10-12 13:48:12 -0500 | [diff] [blame] | 55 | struct imx_sec_config_fuse_t const imx_sec_config_fuse = { |
| 56 | .bank = 0, |
| 57 | .word = 6, |
| 58 | }; |
| 59 | #endif |
| 60 | |
Gabriel Huau | 170ceaf | 2014-07-26 11:35:43 -0700 | [diff] [blame] | 61 | u32 get_nr_cpus(void) |
| 62 | { |
| 63 | struct scu_regs *scu = (struct scu_regs *)SCU_BASE_ADDR; |
| 64 | return readl(&scu->config) & 3; |
| 65 | } |
| 66 | |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 67 | u32 get_cpu_rev(void) |
| 68 | { |
Fabio Estevam | 46e9733 | 2012-03-20 04:21:45 +0000 | [diff] [blame] | 69 | struct anatop_regs *anatop = (struct anatop_regs *)ANATOP_BASE_ADDR; |
Troy Kisky | 5839493 | 2012-10-23 10:57:46 +0000 | [diff] [blame] | 70 | u32 reg = readl(&anatop->digprog_sololite); |
| 71 | u32 type = ((reg >> 16) & 0xff); |
Peng Fan | 5f24792 | 2015-07-11 11:38:42 +0800 | [diff] [blame] | 72 | u32 major, cfg = 0; |
Fabio Estevam | 46e9733 | 2012-03-20 04:21:45 +0000 | [diff] [blame] | 73 | |
Troy Kisky | 5839493 | 2012-10-23 10:57:46 +0000 | [diff] [blame] | 74 | if (type != MXC_CPU_MX6SL) { |
| 75 | reg = readl(&anatop->digprog); |
Fabio Estevam | f3d5a2c | 2014-01-26 15:06:41 -0200 | [diff] [blame] | 76 | struct scu_regs *scu = (struct scu_regs *)SCU_BASE_ADDR; |
Peng Fan | 5f24792 | 2015-07-11 11:38:42 +0800 | [diff] [blame] | 77 | cfg = readl(&scu->config) & 3; |
Troy Kisky | 5839493 | 2012-10-23 10:57:46 +0000 | [diff] [blame] | 78 | type = ((reg >> 16) & 0xff); |
| 79 | if (type == MXC_CPU_MX6DL) { |
Troy Kisky | 5839493 | 2012-10-23 10:57:46 +0000 | [diff] [blame] | 80 | if (!cfg) |
| 81 | type = MXC_CPU_MX6SOLO; |
| 82 | } |
Fabio Estevam | f3d5a2c | 2014-01-26 15:06:41 -0200 | [diff] [blame] | 83 | |
| 84 | if (type == MXC_CPU_MX6Q) { |
| 85 | if (cfg == 1) |
| 86 | type = MXC_CPU_MX6D; |
| 87 | } |
| 88 | |
Peng Fan | c53d0c9 | 2019-08-08 09:55:52 +0000 | [diff] [blame] | 89 | if (type == MXC_CPU_MX6ULL) { |
| 90 | if (readl(SRC_BASE_ADDR + 0x1c) & (1 << 6)) |
| 91 | type = MXC_CPU_MX6ULZ; |
| 92 | } |
Troy Kisky | 5839493 | 2012-10-23 10:57:46 +0000 | [diff] [blame] | 93 | } |
Peng Fan | 8838323 | 2015-06-11 18:30:36 +0800 | [diff] [blame] | 94 | major = ((reg >> 8) & 0xff); |
Peng Fan | 5f24792 | 2015-07-11 11:38:42 +0800 | [diff] [blame] | 95 | if ((major >= 1) && |
| 96 | ((type == MXC_CPU_MX6Q) || (type == MXC_CPU_MX6D))) { |
| 97 | major--; |
| 98 | type = MXC_CPU_MX6QP; |
| 99 | if (cfg == 1) |
| 100 | type = MXC_CPU_MX6DP; |
| 101 | } |
Troy Kisky | 5839493 | 2012-10-23 10:57:46 +0000 | [diff] [blame] | 102 | reg &= 0xff; /* mx6 silicon revision */ |
Ye Li | 10f19c7 | 2019-07-10 10:38:37 +0000 | [diff] [blame] | 103 | |
| 104 | /* For 6DQ, the value 0x00630005 is Silicon revision 1.3*/ |
| 105 | if (((type == MXC_CPU_MX6Q) || (type == MXC_CPU_MX6D)) && (reg == 0x5)) |
| 106 | reg = 0x3; |
| 107 | |
Peng Fan | 8838323 | 2015-06-11 18:30:36 +0800 | [diff] [blame] | 108 | return (type << 12) | (reg + (0x10 * (major + 1))); |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 109 | } |
| 110 | |
Tim Harvey | 258d046 | 2015-05-18 07:02:24 -0700 | [diff] [blame] | 111 | /* |
| 112 | * OCOTP_CFG3[17:16] (see Fusemap Description Table offset 0x440) |
| 113 | * defines a 2-bit SPEED_GRADING |
| 114 | */ |
| 115 | #define OCOTP_CFG3_SPEED_SHIFT 16 |
| 116 | #define OCOTP_CFG3_SPEED_800MHZ 0 |
| 117 | #define OCOTP_CFG3_SPEED_850MHZ 1 |
| 118 | #define OCOTP_CFG3_SPEED_1GHZ 2 |
| 119 | #define OCOTP_CFG3_SPEED_1P2GHZ 3 |
| 120 | |
Peng Fan | 441e905 | 2016-05-03 11:13:04 +0800 | [diff] [blame] | 121 | /* |
| 122 | * For i.MX6UL |
| 123 | */ |
| 124 | #define OCOTP_CFG3_SPEED_528MHZ 1 |
| 125 | #define OCOTP_CFG3_SPEED_696MHZ 2 |
| 126 | |
Sébastien Szymanski | b130c8a | 2017-08-02 17:05:27 +0200 | [diff] [blame] | 127 | /* |
| 128 | * For i.MX6ULL |
| 129 | */ |
| 130 | #define OCOTP_CFG3_SPEED_792MHZ 2 |
| 131 | #define OCOTP_CFG3_SPEED_900MHZ 3 |
| 132 | |
Tim Harvey | 258d046 | 2015-05-18 07:02:24 -0700 | [diff] [blame] | 133 | u32 get_cpu_speed_grade_hz(void) |
| 134 | { |
| 135 | struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR; |
| 136 | struct fuse_bank *bank = &ocotp->bank[0]; |
| 137 | struct fuse_bank0_regs *fuse = |
| 138 | (struct fuse_bank0_regs *)bank->fuse_regs; |
| 139 | uint32_t val; |
| 140 | |
| 141 | val = readl(&fuse->cfg3); |
| 142 | val >>= OCOTP_CFG3_SPEED_SHIFT; |
| 143 | val &= 0x3; |
| 144 | |
Sébastien Szymanski | b130c8a | 2017-08-02 17:05:27 +0200 | [diff] [blame] | 145 | if (is_mx6ul()) { |
Peng Fan | 441e905 | 2016-05-03 11:13:04 +0800 | [diff] [blame] | 146 | if (val == OCOTP_CFG3_SPEED_528MHZ) |
| 147 | return 528000000; |
| 148 | else if (val == OCOTP_CFG3_SPEED_696MHZ) |
Sébastien Szymanski | 415c7ce | 2017-08-02 17:05:26 +0200 | [diff] [blame] | 149 | return 696000000; |
Peng Fan | 441e905 | 2016-05-03 11:13:04 +0800 | [diff] [blame] | 150 | else |
| 151 | return 0; |
| 152 | } |
| 153 | |
Sébastien Szymanski | b130c8a | 2017-08-02 17:05:27 +0200 | [diff] [blame] | 154 | if (is_mx6ull()) { |
| 155 | if (val == OCOTP_CFG3_SPEED_528MHZ) |
| 156 | return 528000000; |
| 157 | else if (val == OCOTP_CFG3_SPEED_792MHZ) |
| 158 | return 792000000; |
| 159 | else if (val == OCOTP_CFG3_SPEED_900MHZ) |
| 160 | return 900000000; |
| 161 | else |
| 162 | return 0; |
| 163 | } |
| 164 | |
Tim Harvey | 258d046 | 2015-05-18 07:02:24 -0700 | [diff] [blame] | 165 | switch (val) { |
| 166 | /* Valid for IMX6DQ */ |
| 167 | case OCOTP_CFG3_SPEED_1P2GHZ: |
Peng Fan | 6c4f76f | 2016-05-23 18:35:58 +0800 | [diff] [blame] | 168 | if (is_mx6dq() || is_mx6dqp()) |
Tim Harvey | 258d046 | 2015-05-18 07:02:24 -0700 | [diff] [blame] | 169 | return 1200000000; |
| 170 | /* Valid for IMX6SX/IMX6SDL/IMX6DQ */ |
| 171 | case OCOTP_CFG3_SPEED_1GHZ: |
| 172 | return 996000000; |
| 173 | /* Valid for IMX6DQ */ |
| 174 | case OCOTP_CFG3_SPEED_850MHZ: |
Peng Fan | 6c4f76f | 2016-05-23 18:35:58 +0800 | [diff] [blame] | 175 | if (is_mx6dq() || is_mx6dqp()) |
Tim Harvey | 258d046 | 2015-05-18 07:02:24 -0700 | [diff] [blame] | 176 | return 852000000; |
| 177 | /* Valid for IMX6SX/IMX6SDL/IMX6DQ */ |
| 178 | case OCOTP_CFG3_SPEED_800MHZ: |
| 179 | return 792000000; |
| 180 | } |
| 181 | return 0; |
| 182 | } |
| 183 | |
Tim Harvey | 5e0e193 | 2015-05-18 06:56:45 -0700 | [diff] [blame] | 184 | /* |
| 185 | * OCOTP_MEM0[7:6] (see Fusemap Description Table offset 0x480) |
| 186 | * defines a 2-bit Temperature Grade |
| 187 | * |
Fabio Estevam | a24859c | 2017-06-22 10:50:05 -0300 | [diff] [blame] | 188 | * return temperature grade and min/max temperature in Celsius |
Tim Harvey | 5e0e193 | 2015-05-18 06:56:45 -0700 | [diff] [blame] | 189 | */ |
| 190 | #define OCOTP_MEM0_TEMP_SHIFT 6 |
| 191 | |
| 192 | u32 get_cpu_temp_grade(int *minc, int *maxc) |
| 193 | { |
| 194 | struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR; |
| 195 | struct fuse_bank *bank = &ocotp->bank[1]; |
| 196 | struct fuse_bank1_regs *fuse = |
| 197 | (struct fuse_bank1_regs *)bank->fuse_regs; |
| 198 | uint32_t val; |
| 199 | |
| 200 | val = readl(&fuse->mem0); |
| 201 | val >>= OCOTP_MEM0_TEMP_SHIFT; |
| 202 | val &= 0x3; |
| 203 | |
| 204 | if (minc && maxc) { |
| 205 | if (val == TEMP_AUTOMOTIVE) { |
| 206 | *minc = -40; |
| 207 | *maxc = 125; |
| 208 | } else if (val == TEMP_INDUSTRIAL) { |
| 209 | *minc = -40; |
| 210 | *maxc = 105; |
| 211 | } else if (val == TEMP_EXTCOMMERCIAL) { |
| 212 | *minc = -20; |
| 213 | *maxc = 105; |
| 214 | } else { |
| 215 | *minc = 0; |
| 216 | *maxc = 95; |
| 217 | } |
| 218 | } |
| 219 | return val; |
| 220 | } |
| 221 | |
Fabio Estevam | 435998b | 2013-03-27 07:36:55 +0000 | [diff] [blame] | 222 | #ifdef CONFIG_REVISION_TAG |
| 223 | u32 __weak get_board_rev(void) |
| 224 | { |
| 225 | u32 cpurev = get_cpu_rev(); |
| 226 | u32 type = ((cpurev >> 12) & 0xff); |
| 227 | if (type == MXC_CPU_MX6SOLO) |
| 228 | cpurev = (MXC_CPU_MX6DL) << 12 | (cpurev & 0xFFF); |
| 229 | |
Fabio Estevam | f3d5a2c | 2014-01-26 15:06:41 -0200 | [diff] [blame] | 230 | if (type == MXC_CPU_MX6D) |
| 231 | cpurev = (MXC_CPU_MX6Q) << 12 | (cpurev & 0xFFF); |
| 232 | |
Fabio Estevam | 435998b | 2013-03-27 07:36:55 +0000 | [diff] [blame] | 233 | return cpurev; |
| 234 | } |
| 235 | #endif |
| 236 | |
Fabio Estevam | cf621ff | 2013-12-26 14:51:31 -0200 | [diff] [blame] | 237 | static void clear_ldo_ramp(void) |
| 238 | { |
| 239 | struct anatop_regs *anatop = (struct anatop_regs *)ANATOP_BASE_ADDR; |
| 240 | int reg; |
| 241 | |
| 242 | /* ROM may modify LDO ramp up time according to fuse setting, so in |
| 243 | * order to be in the safe side we neeed to reset these settings to |
| 244 | * match the reset value: 0'b00 |
| 245 | */ |
| 246 | reg = readl(&anatop->ana_misc2); |
| 247 | reg &= ~(0x3f << 24); |
| 248 | writel(reg, &anatop->ana_misc2); |
| 249 | } |
| 250 | |
Dirk Behme | 8c46594 | 2012-05-02 02:12:17 +0000 | [diff] [blame] | 251 | /* |
Fabio Estevam | 2e95fe1 | 2014-06-13 01:42:37 -0300 | [diff] [blame] | 252 | * Set the PMU_REG_CORE register |
Dirk Behme | 8c46594 | 2012-05-02 02:12:17 +0000 | [diff] [blame] | 253 | * |
Fabio Estevam | 2e95fe1 | 2014-06-13 01:42:37 -0300 | [diff] [blame] | 254 | * Set LDO_SOC/PU/ARM regulators to the specified millivolt level. |
Dirk Behme | 8c46594 | 2012-05-02 02:12:17 +0000 | [diff] [blame] | 255 | * Possible values are from 0.725V to 1.450V in steps of |
| 256 | * 0.025V (25mV). |
| 257 | */ |
Fabio Estevam | a47ec52 | 2013-12-26 14:51:33 -0200 | [diff] [blame] | 258 | static int set_ldo_voltage(enum ldo_reg ldo, u32 mv) |
Dirk Behme | 8c46594 | 2012-05-02 02:12:17 +0000 | [diff] [blame] | 259 | { |
| 260 | struct anatop_regs *anatop = (struct anatop_regs *)ANATOP_BASE_ADDR; |
Fabio Estevam | 99b370b | 2013-12-26 14:51:34 -0200 | [diff] [blame] | 261 | u32 val, step, old, reg = readl(&anatop->reg_core); |
Fabio Estevam | a47ec52 | 2013-12-26 14:51:33 -0200 | [diff] [blame] | 262 | u8 shift; |
Dirk Behme | 8c46594 | 2012-05-02 02:12:17 +0000 | [diff] [blame] | 263 | |
Peng Fan | 81224c4 | 2017-08-08 16:21:35 +0800 | [diff] [blame] | 264 | /* No LDO_SOC/PU/ARM */ |
| 265 | if (is_mx6sll()) |
| 266 | return 0; |
| 267 | |
Dirk Behme | 8c46594 | 2012-05-02 02:12:17 +0000 | [diff] [blame] | 268 | if (mv < 725) |
| 269 | val = 0x00; /* Power gated off */ |
| 270 | else if (mv > 1450) |
| 271 | val = 0x1F; /* Power FET switched full on. No regulation */ |
| 272 | else |
| 273 | val = (mv - 700) / 25; |
| 274 | |
Fabio Estevam | cf621ff | 2013-12-26 14:51:31 -0200 | [diff] [blame] | 275 | clear_ldo_ramp(); |
| 276 | |
Fabio Estevam | a47ec52 | 2013-12-26 14:51:33 -0200 | [diff] [blame] | 277 | switch (ldo) { |
| 278 | case LDO_SOC: |
| 279 | shift = 18; |
| 280 | break; |
| 281 | case LDO_PU: |
| 282 | shift = 9; |
| 283 | break; |
| 284 | case LDO_ARM: |
| 285 | shift = 0; |
| 286 | break; |
| 287 | default: |
| 288 | return -EINVAL; |
| 289 | } |
| 290 | |
Fabio Estevam | 99b370b | 2013-12-26 14:51:34 -0200 | [diff] [blame] | 291 | old = (reg & (0x1F << shift)) >> shift; |
| 292 | step = abs(val - old); |
| 293 | if (step == 0) |
| 294 | return 0; |
| 295 | |
Fabio Estevam | a47ec52 | 2013-12-26 14:51:33 -0200 | [diff] [blame] | 296 | reg = (reg & ~(0x1F << shift)) | (val << shift); |
Dirk Behme | 8c46594 | 2012-05-02 02:12:17 +0000 | [diff] [blame] | 297 | writel(reg, &anatop->reg_core); |
Fabio Estevam | a47ec52 | 2013-12-26 14:51:33 -0200 | [diff] [blame] | 298 | |
Fabio Estevam | 99b370b | 2013-12-26 14:51:34 -0200 | [diff] [blame] | 299 | /* |
| 300 | * The LDO ramp-up is based on 64 clock cycles of 24 MHz = 2.6 us per |
| 301 | * step |
| 302 | */ |
| 303 | udelay(3 * step); |
| 304 | |
Fabio Estevam | a47ec52 | 2013-12-26 14:51:33 -0200 | [diff] [blame] | 305 | return 0; |
Dirk Behme | 8c46594 | 2012-05-02 02:12:17 +0000 | [diff] [blame] | 306 | } |
| 307 | |
Anson Huang | 05a464f | 2014-01-23 14:00:18 +0800 | [diff] [blame] | 308 | static void set_ahb_rate(u32 val) |
| 309 | { |
| 310 | struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR; |
| 311 | u32 reg, div; |
| 312 | |
| 313 | div = get_periph_clk() / val - 1; |
| 314 | reg = readl(&mxc_ccm->cbcdr); |
| 315 | |
| 316 | writel((reg & (~MXC_CCM_CBCDR_AHB_PODF_MASK)) | |
| 317 | (div << MXC_CCM_CBCDR_AHB_PODF_OFFSET), &mxc_ccm->cbcdr); |
| 318 | } |
| 319 | |
Anson Huang | 9a149bc | 2014-01-23 14:00:19 +0800 | [diff] [blame] | 320 | static void clear_mmdc_ch_mask(void) |
| 321 | { |
| 322 | struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR; |
Peng Fan | 53f3c9e | 2015-07-11 11:38:43 +0800 | [diff] [blame] | 323 | u32 reg; |
| 324 | reg = readl(&mxc_ccm->ccdr); |
Anson Huang | 9a149bc | 2014-01-23 14:00:19 +0800 | [diff] [blame] | 325 | |
| 326 | /* Clear MMDC channel mask */ |
Peng Fan | 81224c4 | 2017-08-08 16:21:35 +0800 | [diff] [blame] | 327 | if (is_mx6sx() || is_mx6ul() || is_mx6ull() || is_mx6sl() || is_mx6sll()) |
Ye Li | 64cef44 | 2016-03-09 16:13:48 +0800 | [diff] [blame] | 328 | reg &= ~(MXC_CCM_CCDR_MMDC_CH1_HS_MASK); |
| 329 | else |
| 330 | reg &= ~(MXC_CCM_CCDR_MMDC_CH1_HS_MASK | MXC_CCM_CCDR_MMDC_CH0_HS_MASK); |
Peng Fan | 53f3c9e | 2015-07-11 11:38:43 +0800 | [diff] [blame] | 331 | writel(reg, &mxc_ccm->ccdr); |
Anson Huang | 9a149bc | 2014-01-23 14:00:19 +0800 | [diff] [blame] | 332 | } |
| 333 | |
Peng Fan | 656d233 | 2016-10-08 17:03:00 +0800 | [diff] [blame] | 334 | #define OCOTP_MEM0_REFTOP_TRIM_SHIFT 8 |
| 335 | |
Peng Fan | c0e0ebf | 2015-01-15 14:22:32 +0800 | [diff] [blame] | 336 | static void init_bandgap(void) |
| 337 | { |
| 338 | struct anatop_regs *anatop = (struct anatop_regs *)ANATOP_BASE_ADDR; |
Peng Fan | 656d233 | 2016-10-08 17:03:00 +0800 | [diff] [blame] | 339 | struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR; |
| 340 | struct fuse_bank *bank = &ocotp->bank[1]; |
| 341 | struct fuse_bank1_regs *fuse = |
| 342 | (struct fuse_bank1_regs *)bank->fuse_regs; |
| 343 | uint32_t val; |
| 344 | |
Peng Fan | c0e0ebf | 2015-01-15 14:22:32 +0800 | [diff] [blame] | 345 | /* |
| 346 | * Ensure the bandgap has stabilized. |
| 347 | */ |
| 348 | while (!(readl(&anatop->ana_misc0) & 0x80)) |
| 349 | ; |
| 350 | /* |
| 351 | * For best noise performance of the analog blocks using the |
| 352 | * outputs of the bandgap, the reftop_selfbiasoff bit should |
| 353 | * be set. |
| 354 | */ |
| 355 | writel(BM_ANADIG_ANA_MISC0_REFTOP_SELBIASOFF, &anatop->ana_misc0_set); |
Peng Fan | 6b98935 | 2016-08-11 14:02:50 +0800 | [diff] [blame] | 356 | /* |
Peng Fan | 656d233 | 2016-10-08 17:03:00 +0800 | [diff] [blame] | 357 | * On i.MX6ULL,we need to set VBGADJ bits according to the |
| 358 | * REFTOP_TRIM[3:0] in fuse table |
| 359 | * 000 - set REFTOP_VBGADJ[2:0] to 3b'110, |
| 360 | * 110 - set REFTOP_VBGADJ[2:0] to 3b'000, |
| 361 | * 001 - set REFTOP_VBGADJ[2:0] to 3b'001, |
| 362 | * 010 - set REFTOP_VBGADJ[2:0] to 3b'010, |
| 363 | * 011 - set REFTOP_VBGADJ[2:0] to 3b'011, |
| 364 | * 100 - set REFTOP_VBGADJ[2:0] to 3b'100, |
| 365 | * 101 - set REFTOP_VBGADJ[2:0] to 3b'101, |
| 366 | * 111 - set REFTOP_VBGADJ[2:0] to 3b'111, |
Peng Fan | 6b98935 | 2016-08-11 14:02:50 +0800 | [diff] [blame] | 367 | */ |
Peng Fan | 656d233 | 2016-10-08 17:03:00 +0800 | [diff] [blame] | 368 | if (is_mx6ull()) { |
| 369 | val = readl(&fuse->mem0); |
| 370 | val >>= OCOTP_MEM0_REFTOP_TRIM_SHIFT; |
| 371 | val &= 0x7; |
Peng Fan | c0e0ebf | 2015-01-15 14:22:32 +0800 | [diff] [blame] | 372 | |
Peng Fan | 656d233 | 2016-10-08 17:03:00 +0800 | [diff] [blame] | 373 | writel(val << BM_ANADIG_ANA_MISC0_REFTOP_VBGADJ_SHIFT, |
| 374 | &anatop->ana_misc0_set); |
| 375 | } |
| 376 | } |
Peng Fan | c0e0ebf | 2015-01-15 14:22:32 +0800 | [diff] [blame] | 377 | |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 378 | int arch_cpu_init(void) |
| 379 | { |
Peng Fan | 946333d | 2017-08-08 16:21:38 +0800 | [diff] [blame] | 380 | struct mxc_ccm_reg *ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR; |
| 381 | |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 382 | init_aips(); |
| 383 | |
Anson Huang | 9a149bc | 2014-01-23 14:00:19 +0800 | [diff] [blame] | 384 | /* Need to clear MMDC_CHx_MASK to make warm reset work. */ |
| 385 | clear_mmdc_ch_mask(); |
| 386 | |
Anson Huang | 05a464f | 2014-01-23 14:00:18 +0800 | [diff] [blame] | 387 | /* |
Peng Fan | c0e0ebf | 2015-01-15 14:22:32 +0800 | [diff] [blame] | 388 | * Disable self-bias circuit in the analog bandap. |
| 389 | * The self-bias circuit is used by the bandgap during startup. |
| 390 | * This bit should be set after the bandgap has initialized. |
| 391 | */ |
| 392 | init_bandgap(); |
| 393 | |
Peng Fan | ae86e3f | 2016-08-11 14:02:43 +0800 | [diff] [blame] | 394 | if (!is_mx6ul() && !is_mx6ull()) { |
Peng Fan | f60137e | 2016-03-09 16:44:36 +0800 | [diff] [blame] | 395 | /* |
| 396 | * When low freq boot is enabled, ROM will not set AHB |
| 397 | * freq, so we need to ensure AHB freq is 132MHz in such |
| 398 | * scenario. |
| 399 | * |
| 400 | * To i.MX6UL, when power up, default ARM core and |
| 401 | * AHB rate is 396M and 132M. |
| 402 | */ |
| 403 | if (mxc_get_clock(MXC_ARM_CLK) == 396000000) |
| 404 | set_ahb_rate(132000000); |
| 405 | } |
Anson Huang | 05a464f | 2014-01-23 14:00:18 +0800 | [diff] [blame] | 406 | |
Peng Fan | 2b990ea | 2016-09-28 09:40:27 +0800 | [diff] [blame] | 407 | if (is_mx6ul()) { |
| 408 | if (is_soc_rev(CHIP_REV_1_0) == 0) { |
| 409 | /* |
| 410 | * According to the design team's requirement on |
| 411 | * i.MX6UL,the PMIC_STBY_REQ PAD should be configured |
| 412 | * as open drain 100K (0x0000b8a0). |
| 413 | * Only exists on TO1.0 |
| 414 | */ |
| 415 | writel(0x0000b8a0, IOMUXC_BASE_ADDR + 0x29c); |
| 416 | } else { |
| 417 | /* |
| 418 | * From TO1.1, SNVS adds internal pull up control |
| 419 | * for POR_B, the register filed is GPBIT[1:0], |
| 420 | * after system boot up, it can be set to 2b'01 |
| 421 | * to disable internal pull up.It can save about |
| 422 | * 30uA power in SNVS mode. |
| 423 | */ |
| 424 | writel((readl(MX6UL_SNVS_LP_BASE_ADDR + 0x10) & |
| 425 | (~0x1400)) | 0x400, |
| 426 | MX6UL_SNVS_LP_BASE_ADDR + 0x10); |
| 427 | } |
Peng Fan | a2cba65 | 2016-03-09 16:44:37 +0800 | [diff] [blame] | 428 | } |
| 429 | |
Peng Fan | b64bf0b | 2016-08-11 14:02:46 +0800 | [diff] [blame] | 430 | if (is_mx6ull()) { |
| 431 | /* |
| 432 | * GPBIT[1:0] is suggested to set to 2'b11: |
| 433 | * 2'b00 : always PUP100K |
| 434 | * 2'b01 : PUP100K when PMIC_ON_REQ or SOC_NOT_FAIL |
| 435 | * 2'b10 : always disable PUP100K |
| 436 | * 2'b11 : PDN100K when SOC_FAIL, PUP100K when SOC_NOT_FAIL |
| 437 | * register offset is different from i.MX6UL, since |
| 438 | * i.MX6UL is fixed by ECO. |
| 439 | */ |
| 440 | writel(readl(MX6UL_SNVS_LP_BASE_ADDR) | |
| 441 | 0x3, MX6UL_SNVS_LP_BASE_ADDR); |
| 442 | } |
| 443 | |
Peng Fan | a2cba65 | 2016-03-09 16:44:37 +0800 | [diff] [blame] | 444 | /* Set perclk to source from OSC 24MHz */ |
Peng Fan | fe7052a | 2017-08-08 16:21:39 +0800 | [diff] [blame] | 445 | if (is_mx6sl()) |
| 446 | setbits_le32(&ccm->cscmr1, MXC_CCM_CSCMR1_PER_CLK_SEL_MASK); |
Ye.Li | 622dfbd | 2014-10-30 18:20:58 +0800 | [diff] [blame] | 447 | |
Fabio Estevam | 5f79d46 | 2017-11-23 10:55:33 -0200 | [diff] [blame] | 448 | imx_wdog_disable_powerdown(); /* Disable PDE bit of WMCR register */ |
Stefan Roese | 8338d1d | 2013-04-15 21:14:12 +0000 | [diff] [blame] | 449 | |
Peng Fan | 946333d | 2017-08-08 16:21:38 +0800 | [diff] [blame] | 450 | if (is_mx6sx()) |
| 451 | setbits_le32(&ccm->cscdr1, MXC_CCM_CSCDR1_UART_CLK_SEL); |
| 452 | |
Dirk Behme | 0adb215 | 2015-03-09 14:48:48 +0100 | [diff] [blame] | 453 | init_src(); |
| 454 | |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 455 | return 0; |
| 456 | } |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 457 | |
Peng Fan | 850dbca | 2016-01-28 16:51:26 +0800 | [diff] [blame] | 458 | #ifdef CONFIG_ENV_IS_IN_MMC |
| 459 | __weak int board_mmc_get_env_dev(int devno) |
| 460 | { |
| 461 | return CONFIG_SYS_MMC_ENV_DEV; |
| 462 | } |
| 463 | |
Soeren Moch | bc177f1 | 2016-02-04 14:41:15 +0100 | [diff] [blame] | 464 | static int mmc_get_boot_dev(void) |
Peng Fan | 850dbca | 2016-01-28 16:51:26 +0800 | [diff] [blame] | 465 | { |
| 466 | struct src *src_regs = (struct src *)SRC_BASE_ADDR; |
| 467 | u32 soc_sbmr = readl(&src_regs->sbmr1); |
| 468 | u32 bootsel; |
| 469 | int devno; |
| 470 | |
| 471 | /* |
| 472 | * Refer to |
| 473 | * "i.MX 6Dual/6Quad Applications Processor Reference Manual" |
| 474 | * Chapter "8.5.3.1 Expansion Device eFUSE Configuration" |
| 475 | * i.MX6SL/SX/UL has same layout. |
| 476 | */ |
| 477 | bootsel = (soc_sbmr & 0x000000FF) >> 6; |
| 478 | |
Soeren Moch | bc177f1 | 2016-02-04 14:41:15 +0100 | [diff] [blame] | 479 | /* No boot from sd/mmc */ |
Peng Fan | 850dbca | 2016-01-28 16:51:26 +0800 | [diff] [blame] | 480 | if (bootsel != 1) |
Soeren Moch | bc177f1 | 2016-02-04 14:41:15 +0100 | [diff] [blame] | 481 | return -1; |
Peng Fan | 850dbca | 2016-01-28 16:51:26 +0800 | [diff] [blame] | 482 | |
| 483 | /* BOOT_CFG2[3] and BOOT_CFG2[4] */ |
| 484 | devno = (soc_sbmr & 0x00001800) >> 11; |
| 485 | |
Soeren Moch | bc177f1 | 2016-02-04 14:41:15 +0100 | [diff] [blame] | 486 | return devno; |
| 487 | } |
| 488 | |
| 489 | int mmc_get_env_dev(void) |
| 490 | { |
| 491 | int devno = mmc_get_boot_dev(); |
| 492 | |
| 493 | /* If not boot from sd/mmc, use default value */ |
| 494 | if (devno < 0) |
| 495 | return CONFIG_SYS_MMC_ENV_DEV; |
| 496 | |
Peng Fan | 850dbca | 2016-01-28 16:51:26 +0800 | [diff] [blame] | 497 | return board_mmc_get_env_dev(devno); |
| 498 | } |
Soeren Moch | bc177f1 | 2016-02-04 14:41:15 +0100 | [diff] [blame] | 499 | |
| 500 | #ifdef CONFIG_SYS_MMC_ENV_PART |
| 501 | __weak int board_mmc_get_env_part(int devno) |
| 502 | { |
| 503 | return CONFIG_SYS_MMC_ENV_PART; |
| 504 | } |
| 505 | |
| 506 | uint mmc_get_env_part(struct mmc *mmc) |
| 507 | { |
| 508 | int devno = mmc_get_boot_dev(); |
| 509 | |
| 510 | /* If not boot from sd/mmc, use default value */ |
| 511 | if (devno < 0) |
| 512 | return CONFIG_SYS_MMC_ENV_PART; |
| 513 | |
| 514 | return board_mmc_get_env_part(devno); |
| 515 | } |
| 516 | #endif |
Peng Fan | 850dbca | 2016-01-28 16:51:26 +0800 | [diff] [blame] | 517 | #endif |
| 518 | |
Fabio Estevam | 99b370b | 2013-12-26 14:51:34 -0200 | [diff] [blame] | 519 | int board_postclk_init(void) |
| 520 | { |
Peng Fan | 81224c4 | 2017-08-08 16:21:35 +0800 | [diff] [blame] | 521 | /* NO LDO SOC on i.MX6SLL */ |
| 522 | if (is_mx6sll()) |
| 523 | return 0; |
| 524 | |
Fabio Estevam | 99b370b | 2013-12-26 14:51:34 -0200 | [diff] [blame] | 525 | set_ldo_voltage(LDO_SOC, 1175); /* Set VDDSOC to 1.175V */ |
| 526 | |
| 527 | return 0; |
| 528 | } |
| 529 | |
Anatolij Gustschin | 938734e | 2017-08-28 17:51:33 +0200 | [diff] [blame] | 530 | #ifndef CONFIG_SPL_BUILD |
Troy Kisky | 0ca618c | 2012-08-15 10:31:20 +0000 | [diff] [blame] | 531 | /* |
| 532 | * cfg_val will be used for |
| 533 | * Boot_cfg4[7:0]:Boot_cfg3[7:0]:Boot_cfg2[7:0]:Boot_cfg1[7:0] |
Nikita Kiryanov | 9fba842 | 2014-10-29 19:28:33 +0200 | [diff] [blame] | 534 | * After reset, if GPR10[28] is 1, ROM will use GPR9[25:0] |
| 535 | * instead of SBMR1 to determine the boot device. |
Troy Kisky | 0ca618c | 2012-08-15 10:31:20 +0000 | [diff] [blame] | 536 | */ |
| 537 | const struct boot_mode soc_boot_modes[] = { |
| 538 | {"normal", MAKE_CFGVAL(0x00, 0x00, 0x00, 0x00)}, |
| 539 | /* reserved value should start rom usb */ |
Stefan Agner | 6b46c46 | 2017-06-09 13:13:12 -0700 | [diff] [blame] | 540 | #if defined(CONFIG_MX6UL) || defined(CONFIG_MX6ULL) |
| 541 | {"usb", MAKE_CFGVAL(0x20, 0x00, 0x00, 0x00)}, |
| 542 | #else |
Stefan Agner | eb4b62b | 2016-09-15 15:04:39 -0700 | [diff] [blame] | 543 | {"usb", MAKE_CFGVAL(0x10, 0x00, 0x00, 0x00)}, |
Stefan Agner | 6b46c46 | 2017-06-09 13:13:12 -0700 | [diff] [blame] | 544 | #endif |
Troy Kisky | 0ca618c | 2012-08-15 10:31:20 +0000 | [diff] [blame] | 545 | {"sata", MAKE_CFGVAL(0x20, 0x00, 0x00, 0x00)}, |
Nikolay Dimitrov | 284d901 | 2014-08-10 20:03:07 +0300 | [diff] [blame] | 546 | {"ecspi1:0", MAKE_CFGVAL(0x30, 0x00, 0x00, 0x08)}, |
| 547 | {"ecspi1:1", MAKE_CFGVAL(0x30, 0x00, 0x00, 0x18)}, |
| 548 | {"ecspi1:2", MAKE_CFGVAL(0x30, 0x00, 0x00, 0x28)}, |
| 549 | {"ecspi1:3", MAKE_CFGVAL(0x30, 0x00, 0x00, 0x38)}, |
Troy Kisky | 0ca618c | 2012-08-15 10:31:20 +0000 | [diff] [blame] | 550 | /* 4 bit bus width */ |
| 551 | {"esdhc1", MAKE_CFGVAL(0x40, 0x20, 0x00, 0x00)}, |
| 552 | {"esdhc2", MAKE_CFGVAL(0x40, 0x28, 0x00, 0x00)}, |
| 553 | {"esdhc3", MAKE_CFGVAL(0x40, 0x30, 0x00, 0x00)}, |
| 554 | {"esdhc4", MAKE_CFGVAL(0x40, 0x38, 0x00, 0x00)}, |
| 555 | {NULL, 0}, |
| 556 | }; |
Anatolij Gustschin | 938734e | 2017-08-28 17:51:33 +0200 | [diff] [blame] | 557 | #endif |
Stephen Warren | 57ab23f | 2013-02-26 12:28:29 +0000 | [diff] [blame] | 558 | |
Peng Fan | 92683e6 | 2015-10-29 15:54:50 +0800 | [diff] [blame] | 559 | void reset_misc(void) |
| 560 | { |
Michael Trimarchi | c41042a | 2018-06-20 23:27:54 +0200 | [diff] [blame] | 561 | #ifndef CONFIG_SPL_BUILD |
Igor Opaniuk | a2ac2aa | 2019-06-19 11:47:08 +0300 | [diff] [blame] | 562 | #if defined(CONFIG_VIDEO_MXS) && !defined(CONFIG_DM_VIDEO) |
Peng Fan | 92683e6 | 2015-10-29 15:54:50 +0800 | [diff] [blame] | 563 | lcdif_power_down(); |
| 564 | #endif |
Michael Trimarchi | c41042a | 2018-06-20 23:27:54 +0200 | [diff] [blame] | 565 | #endif |
Peng Fan | 92683e6 | 2015-10-29 15:54:50 +0800 | [diff] [blame] | 566 | } |
| 567 | |
Stephen Warren | 57ab23f | 2013-02-26 12:28:29 +0000 | [diff] [blame] | 568 | void s_init(void) |
| 569 | { |
Eric Nelson | 2c37d3b | 2013-08-29 12:41:46 -0700 | [diff] [blame] | 570 | struct anatop_regs *anatop = (struct anatop_regs *)ANATOP_BASE_ADDR; |
Ye.Li | 2987687 | 2014-09-09 10:17:00 +0800 | [diff] [blame] | 571 | struct mxc_ccm_reg *ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR; |
Eric Nelson | 2c37d3b | 2013-08-29 12:41:46 -0700 | [diff] [blame] | 572 | u32 mask480; |
| 573 | u32 mask528; |
Ye.Li | 2987687 | 2014-09-09 10:17:00 +0800 | [diff] [blame] | 574 | u32 reg, periph1, periph2; |
Fabio Estevam | 6633e3f | 2014-07-09 16:13:29 -0300 | [diff] [blame] | 575 | |
Peng Fan | 81224c4 | 2017-08-08 16:21:35 +0800 | [diff] [blame] | 576 | if (is_mx6sx() || is_mx6ul() || is_mx6ull() || is_mx6sll()) |
Fabio Estevam | 6633e3f | 2014-07-09 16:13:29 -0300 | [diff] [blame] | 577 | return; |
| 578 | |
Eric Nelson | 2c37d3b | 2013-08-29 12:41:46 -0700 | [diff] [blame] | 579 | /* Due to hardware limitation, on MX6Q we need to gate/ungate all PFDs |
| 580 | * to make sure PFD is working right, otherwise, PFDs may |
| 581 | * not output clock after reset, MX6DL and MX6SL have added 396M pfd |
| 582 | * workaround in ROM code, as bus clock need it |
| 583 | */ |
| 584 | |
| 585 | mask480 = ANATOP_PFD_CLKGATE_MASK(0) | |
| 586 | ANATOP_PFD_CLKGATE_MASK(1) | |
| 587 | ANATOP_PFD_CLKGATE_MASK(2) | |
| 588 | ANATOP_PFD_CLKGATE_MASK(3); |
Ye.Li | 2987687 | 2014-09-09 10:17:00 +0800 | [diff] [blame] | 589 | mask528 = ANATOP_PFD_CLKGATE_MASK(1) | |
Eric Nelson | 2c37d3b | 2013-08-29 12:41:46 -0700 | [diff] [blame] | 590 | ANATOP_PFD_CLKGATE_MASK(3); |
| 591 | |
Ye.Li | 2987687 | 2014-09-09 10:17:00 +0800 | [diff] [blame] | 592 | reg = readl(&ccm->cbcmr); |
| 593 | periph2 = ((reg & MXC_CCM_CBCMR_PRE_PERIPH2_CLK_SEL_MASK) |
| 594 | >> MXC_CCM_CBCMR_PRE_PERIPH2_CLK_SEL_OFFSET); |
| 595 | periph1 = ((reg & MXC_CCM_CBCMR_PRE_PERIPH_CLK_SEL_MASK) |
| 596 | >> MXC_CCM_CBCMR_PRE_PERIPH_CLK_SEL_OFFSET); |
| 597 | |
| 598 | /* Checking if PLL2 PFD0 or PLL2 PFD2 is using for periph clock */ |
| 599 | if ((periph2 != 0x2) && (periph1 != 0x2)) |
| 600 | mask528 |= ANATOP_PFD_CLKGATE_MASK(0); |
| 601 | |
| 602 | if ((periph2 != 0x1) && (periph1 != 0x1) && |
| 603 | (periph2 != 0x3) && (periph1 != 0x3)) |
Eric Nelson | 2c37d3b | 2013-08-29 12:41:46 -0700 | [diff] [blame] | 604 | mask528 |= ANATOP_PFD_CLKGATE_MASK(2); |
Ye.Li | 2987687 | 2014-09-09 10:17:00 +0800 | [diff] [blame] | 605 | |
Eric Nelson | 2c37d3b | 2013-08-29 12:41:46 -0700 | [diff] [blame] | 606 | writel(mask480, &anatop->pfd_480_set); |
| 607 | writel(mask528, &anatop->pfd_528_set); |
| 608 | writel(mask480, &anatop->pfd_480_clr); |
| 609 | writel(mask528, &anatop->pfd_528_clr); |
Stephen Warren | 57ab23f | 2013-02-26 12:28:29 +0000 | [diff] [blame] | 610 | } |
Pardeep Kumar Singla | c1fa130 | 2013-07-25 12:12:13 -0500 | [diff] [blame] | 611 | |
| 612 | #ifdef CONFIG_IMX_HDMI |
| 613 | void imx_enable_hdmi_phy(void) |
| 614 | { |
| 615 | struct hdmi_regs *hdmi = (struct hdmi_regs *)HDMI_ARB_BASE_ADDR; |
| 616 | u8 reg; |
| 617 | reg = readb(&hdmi->phy_conf0); |
| 618 | reg |= HDMI_PHY_CONF0_PDZ_MASK; |
| 619 | writeb(reg, &hdmi->phy_conf0); |
| 620 | udelay(3000); |
| 621 | reg |= HDMI_PHY_CONF0_ENTMDS_MASK; |
| 622 | writeb(reg, &hdmi->phy_conf0); |
| 623 | udelay(3000); |
| 624 | reg |= HDMI_PHY_CONF0_GEN2_TXPWRON_MASK; |
| 625 | writeb(reg, &hdmi->phy_conf0); |
| 626 | writeb(HDMI_MC_PHYRSTZ_ASSERT, &hdmi->mc_phyrstz); |
| 627 | } |
| 628 | |
| 629 | void imx_setup_hdmi(void) |
| 630 | { |
| 631 | struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR; |
| 632 | struct hdmi_regs *hdmi = (struct hdmi_regs *)HDMI_ARB_BASE_ADDR; |
Peng Fan | 95ae612 | 2016-03-09 16:07:23 +0800 | [diff] [blame] | 633 | int reg, count; |
| 634 | u8 val; |
Pardeep Kumar Singla | c1fa130 | 2013-07-25 12:12:13 -0500 | [diff] [blame] | 635 | |
| 636 | /* Turn on HDMI PHY clock */ |
| 637 | reg = readl(&mxc_ccm->CCGR2); |
| 638 | reg |= MXC_CCM_CCGR2_HDMI_TX_IAHBCLK_MASK| |
| 639 | MXC_CCM_CCGR2_HDMI_TX_ISFRCLK_MASK; |
| 640 | writel(reg, &mxc_ccm->CCGR2); |
| 641 | writeb(HDMI_MC_PHYRSTZ_DEASSERT, &hdmi->mc_phyrstz); |
| 642 | reg = readl(&mxc_ccm->chsccdr); |
| 643 | reg &= ~(MXC_CCM_CHSCCDR_IPU1_DI0_PRE_CLK_SEL_MASK| |
| 644 | MXC_CCM_CHSCCDR_IPU1_DI0_PODF_MASK| |
| 645 | MXC_CCM_CHSCCDR_IPU1_DI0_CLK_SEL_MASK); |
| 646 | reg |= (CHSCCDR_PODF_DIVIDE_BY_3 |
| 647 | << MXC_CCM_CHSCCDR_IPU1_DI0_PODF_OFFSET) |
| 648 | |(CHSCCDR_IPU_PRE_CLK_540M_PFD |
| 649 | << MXC_CCM_CHSCCDR_IPU1_DI0_PRE_CLK_SEL_OFFSET); |
| 650 | writel(reg, &mxc_ccm->chsccdr); |
Peng Fan | 95ae612 | 2016-03-09 16:07:23 +0800 | [diff] [blame] | 651 | |
| 652 | /* Clear the overflow condition */ |
| 653 | if (readb(&hdmi->ih_fc_stat2) & HDMI_IH_FC_STAT2_OVERFLOW_MASK) { |
| 654 | /* TMDS software reset */ |
| 655 | writeb((u8)~HDMI_MC_SWRSTZ_TMDSSWRST_REQ, &hdmi->mc_swrstz); |
| 656 | val = readb(&hdmi->fc_invidconf); |
| 657 | /* Need minimum 3 times to write to clear the register */ |
| 658 | for (count = 0 ; count < 5 ; count++) |
| 659 | writeb(val, &hdmi->fc_invidconf); |
| 660 | } |
Pardeep Kumar Singla | c1fa130 | 2013-07-25 12:12:13 -0500 | [diff] [blame] | 661 | } |
| 662 | #endif |
Peng Fan | fb3a3b7 | 2016-01-28 16:55:05 +0800 | [diff] [blame] | 663 | |
Michael Trimarchi | d9de3f8 | 2018-06-23 16:10:06 +0200 | [diff] [blame] | 664 | |
| 665 | /* |
| 666 | * gpr_init() function is common for boards using MX6S, MX6DL, MX6D, |
| 667 | * MX6Q and MX6QP processors |
| 668 | */ |
Breno Lima | f22b109 | 2017-08-24 10:00:16 -0300 | [diff] [blame] | 669 | void gpr_init(void) |
| 670 | { |
| 671 | struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR; |
| 672 | |
Christoph Niedermaier | 2082ebf | 2018-10-19 17:40:54 +0200 | [diff] [blame] | 673 | /* |
| 674 | * If this function is used in a common MX6 spl implementation |
| 675 | * we have to ensure that it is only called for suitable cpu types, |
| 676 | * otherwise it breaks hardware parts like enet1, can1, can2, etc. |
| 677 | */ |
| 678 | if (!is_mx6dqp() && !is_mx6dq() && !is_mx6sdl()) |
| 679 | return; |
| 680 | |
Breno Lima | f22b109 | 2017-08-24 10:00:16 -0300 | [diff] [blame] | 681 | /* enable AXI cache for VDOA/VPU/IPU */ |
| 682 | writel(0xF00000CF, &iomux->gpr[4]); |
| 683 | if (is_mx6dqp()) { |
| 684 | /* set IPU AXI-id1 Qos=0x1 AXI-id0/2/3 Qos=0x7 */ |
| 685 | writel(0x77177717, &iomux->gpr[6]); |
| 686 | writel(0x77177717, &iomux->gpr[7]); |
| 687 | } else { |
| 688 | /* set IPU AXI-id0 Qos=0xf(bypass) AXI-id1 Qos=0x7 */ |
| 689 | writel(0x007F007F, &iomux->gpr[6]); |
| 690 | writel(0x007F007F, &iomux->gpr[7]); |
| 691 | } |
| 692 | } |