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