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