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