1 /* 2 * Copyright (c) 2012-2014 NVIDIA CORPORATION. All rights reserved. 3 * 4 * This program is free software; you can redistribute it and/or modify it 5 * under the terms and conditions of the GNU General Public License, 6 * version 2, as published by the Free Software Foundation. 7 * 8 * This program is distributed in the hope it will be useful, but WITHOUT 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 * more details. 12 * 13 * You should have received a copy of the GNU General Public License 14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 15 */ 16 17 #include <linux/io.h> 18 #include <linux/clk.h> 19 #include <linux/clk-provider.h> 20 #include <linux/clkdev.h> 21 #include <linux/of.h> 22 #include <linux/of_address.h> 23 #include <linux/delay.h> 24 #include <linux/export.h> 25 #include <linux/clk/tegra.h> 26 #include <dt-bindings/clock/tegra210-car.h> 27 28 #include "clk.h" 29 #include "clk-id.h" 30 31 /* 32 * TEGRA210_CAR_BANK_COUNT: the number of peripheral clock register 33 * banks present in the Tegra210 CAR IP block. The banks are 34 * identified by single letters, e.g.: L, H, U, V, W, X, Y. See 35 * periph_regs[] in drivers/clk/tegra/clk.c 36 */ 37 #define TEGRA210_CAR_BANK_COUNT 7 38 39 #define CLK_SOURCE_CSITE 0x1d4 40 #define CLK_SOURCE_EMC 0x19c 41 42 #define PLLC_BASE 0x80 43 #define PLLC_OUT 0x84 44 #define PLLC_MISC0 0x88 45 #define PLLC_MISC1 0x8c 46 #define PLLC_MISC2 0x5d0 47 #define PLLC_MISC3 0x5d4 48 49 #define PLLC2_BASE 0x4e8 50 #define PLLC2_MISC0 0x4ec 51 #define PLLC2_MISC1 0x4f0 52 #define PLLC2_MISC2 0x4f4 53 #define PLLC2_MISC3 0x4f8 54 55 #define PLLC3_BASE 0x4fc 56 #define PLLC3_MISC0 0x500 57 #define PLLC3_MISC1 0x504 58 #define PLLC3_MISC2 0x508 59 #define PLLC3_MISC3 0x50c 60 61 #define PLLM_BASE 0x90 62 #define PLLM_MISC1 0x98 63 #define PLLM_MISC2 0x9c 64 #define PLLP_BASE 0xa0 65 #define PLLP_MISC0 0xac 66 #define PLLP_MISC1 0x680 67 #define PLLA_BASE 0xb0 68 #define PLLA_MISC0 0xbc 69 #define PLLA_MISC1 0xb8 70 #define PLLA_MISC2 0x5d8 71 #define PLLD_BASE 0xd0 72 #define PLLD_MISC0 0xdc 73 #define PLLD_MISC1 0xd8 74 #define PLLU_BASE 0xc0 75 #define PLLU_OUTA 0xc4 76 #define PLLU_MISC0 0xcc 77 #define PLLU_MISC1 0xc8 78 #define PLLX_BASE 0xe0 79 #define PLLX_MISC0 0xe4 80 #define PLLX_MISC1 0x510 81 #define PLLX_MISC2 0x514 82 #define PLLX_MISC3 0x518 83 #define PLLX_MISC4 0x5f0 84 #define PLLX_MISC5 0x5f4 85 #define PLLE_BASE 0xe8 86 #define PLLE_MISC0 0xec 87 #define PLLD2_BASE 0x4b8 88 #define PLLD2_MISC0 0x4bc 89 #define PLLD2_MISC1 0x570 90 #define PLLD2_MISC2 0x574 91 #define PLLD2_MISC3 0x578 92 #define PLLE_AUX 0x48c 93 #define PLLRE_BASE 0x4c4 94 #define PLLRE_MISC0 0x4c8 95 #define PLLDP_BASE 0x590 96 #define PLLDP_MISC 0x594 97 98 #define PLLC4_BASE 0x5a4 99 #define PLLC4_MISC0 0x5a8 100 #define PLLC4_OUT 0x5e4 101 #define PLLMB_BASE 0x5e8 102 #define PLLMB_MISC1 0x5ec 103 #define PLLA1_BASE 0x6a4 104 #define PLLA1_MISC0 0x6a8 105 #define PLLA1_MISC1 0x6ac 106 #define PLLA1_MISC2 0x6b0 107 #define PLLA1_MISC3 0x6b4 108 109 #define PLLU_IDDQ_BIT 31 110 #define PLLCX_IDDQ_BIT 27 111 #define PLLRE_IDDQ_BIT 24 112 #define PLLA_IDDQ_BIT 25 113 #define PLLD_IDDQ_BIT 20 114 #define PLLSS_IDDQ_BIT 18 115 #define PLLM_IDDQ_BIT 5 116 #define PLLMB_IDDQ_BIT 17 117 #define PLLXP_IDDQ_BIT 3 118 119 #define PLLCX_RESET_BIT 30 120 121 #define PLL_BASE_LOCK BIT(27) 122 #define PLLCX_BASE_LOCK BIT(26) 123 #define PLLE_MISC_LOCK BIT(11) 124 #define PLLRE_MISC_LOCK BIT(27) 125 126 #define PLL_MISC_LOCK_ENABLE 18 127 #define PLLC_MISC_LOCK_ENABLE 24 128 #define PLLDU_MISC_LOCK_ENABLE 22 129 #define PLLU_MISC_LOCK_ENABLE 29 130 #define PLLE_MISC_LOCK_ENABLE 9 131 #define PLLRE_MISC_LOCK_ENABLE 30 132 #define PLLSS_MISC_LOCK_ENABLE 30 133 #define PLLP_MISC_LOCK_ENABLE 18 134 #define PLLM_MISC_LOCK_ENABLE 4 135 #define PLLMB_MISC_LOCK_ENABLE 16 136 #define PLLA_MISC_LOCK_ENABLE 28 137 #define PLLU_MISC_LOCK_ENABLE 29 138 #define PLLD_MISC_LOCK_ENABLE 18 139 140 #define PLLA_SDM_DIN_MASK 0xffff 141 #define PLLA_SDM_EN_MASK BIT(26) 142 143 #define PLLD_SDM_EN_MASK BIT(16) 144 145 #define PLLD2_SDM_EN_MASK BIT(31) 146 #define PLLD2_SSC_EN_MASK BIT(30) 147 148 #define PLLDP_SS_CFG 0x598 149 #define PLLDP_SDM_EN_MASK BIT(31) 150 #define PLLDP_SSC_EN_MASK BIT(30) 151 #define PLLDP_SS_CTRL1 0x59c 152 #define PLLDP_SS_CTRL2 0x5a0 153 154 #define PMC_PLLM_WB0_OVERRIDE 0x1dc 155 #define PMC_PLLM_WB0_OVERRIDE_2 0x2b0 156 157 #define UTMIP_PLL_CFG2 0x488 158 #define UTMIP_PLL_CFG2_STABLE_COUNT(x) (((x) & 0xfff) << 6) 159 #define UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(x) (((x) & 0x3f) << 18) 160 #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_A_POWERDOWN BIT(0) 161 #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_A_POWERUP BIT(1) 162 #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_B_POWERDOWN BIT(2) 163 #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_B_POWERUP BIT(3) 164 #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_C_POWERDOWN BIT(4) 165 #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_C_POWERUP BIT(5) 166 #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_D_POWERDOWN BIT(24) 167 #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_D_POWERUP BIT(25) 168 169 #define UTMIP_PLL_CFG1 0x484 170 #define UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(x) (((x) & 0x1f) << 27) 171 #define UTMIP_PLL_CFG1_XTAL_FREQ_COUNT(x) (((x) & 0xfff) << 0) 172 #define UTMIP_PLL_CFG1_FORCE_PLLU_POWERUP BIT(17) 173 #define UTMIP_PLL_CFG1_FORCE_PLLU_POWERDOWN BIT(16) 174 #define UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERUP BIT(15) 175 #define UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERDOWN BIT(14) 176 #define UTMIP_PLL_CFG1_FORCE_PLL_ACTIVE_POWERDOWN BIT(12) 177 178 #define UTMIPLL_HW_PWRDN_CFG0 0x52c 179 #define UTMIPLL_HW_PWRDN_CFG0_UTMIPLL_LOCK BIT(31) 180 #define UTMIPLL_HW_PWRDN_CFG0_SEQ_START_STATE BIT(25) 181 #define UTMIPLL_HW_PWRDN_CFG0_SEQ_ENABLE BIT(24) 182 #define UTMIPLL_HW_PWRDN_CFG0_IDDQ_PD_INCLUDE BIT(7) 183 #define UTMIPLL_HW_PWRDN_CFG0_USE_LOCKDET BIT(6) 184 #define UTMIPLL_HW_PWRDN_CFG0_SEQ_RESET_INPUT_VALUE BIT(5) 185 #define UTMIPLL_HW_PWRDN_CFG0_SEQ_IN_SWCTL BIT(4) 186 #define UTMIPLL_HW_PWRDN_CFG0_CLK_ENABLE_SWCTL BIT(2) 187 #define UTMIPLL_HW_PWRDN_CFG0_IDDQ_OVERRIDE BIT(1) 188 #define UTMIPLL_HW_PWRDN_CFG0_IDDQ_SWCTL BIT(0) 189 190 #define PLLU_HW_PWRDN_CFG0 0x530 191 #define PLLU_HW_PWRDN_CFG0_IDDQ_PD_INCLUDE BIT(28) 192 #define PLLU_HW_PWRDN_CFG0_SEQ_ENABLE BIT(24) 193 #define PLLU_HW_PWRDN_CFG0_USE_SWITCH_DETECT BIT(7) 194 #define PLLU_HW_PWRDN_CFG0_USE_LOCKDET BIT(6) 195 #define PLLU_HW_PWRDN_CFG0_CLK_ENABLE_SWCTL BIT(2) 196 #define PLLU_HW_PWRDN_CFG0_CLK_SWITCH_SWCTL BIT(0) 197 198 #define XUSB_PLL_CFG0 0x534 199 #define XUSB_PLL_CFG0_UTMIPLL_LOCK_DLY 0x3ff 200 #define XUSB_PLL_CFG0_PLLU_LOCK_DLY_MASK (0x3ff << 14) 201 202 #define SPARE_REG0 0x55c 203 #define CLK_M_DIVISOR_SHIFT 2 204 #define CLK_M_DIVISOR_MASK 0x3 205 206 /* 207 * SDM fractional divisor is 16-bit 2's complement signed number within 208 * (-2^12 ... 2^12-1) range. Represented in PLL data structure as unsigned 209 * 16-bit value, with "0" divisor mapped to 0xFFFF. Data "0" is used to 210 * indicate that SDM is disabled. 211 * 212 * Effective ndiv value when SDM is enabled: ndiv + 1/2 + sdm_din/2^13 213 */ 214 #define PLL_SDM_COEFF BIT(13) 215 #define sdin_din_to_data(din) ((u16)((din) ? : 0xFFFFU)) 216 #define sdin_data_to_din(dat) (((dat) == 0xFFFFU) ? 0 : (s16)dat) 217 218 /* Tegra CPU clock and reset control regs */ 219 #define CLK_RST_CONTROLLER_CPU_CMPLX_STATUS 0x470 220 221 #ifdef CONFIG_PM_SLEEP 222 static struct cpu_clk_suspend_context { 223 u32 clk_csite_src; 224 } tegra210_cpu_clk_sctx; 225 #endif 226 227 static void __iomem *clk_base; 228 static void __iomem *pmc_base; 229 230 static unsigned long osc_freq; 231 static unsigned long pll_ref_freq; 232 233 static DEFINE_SPINLOCK(pll_d_lock); 234 static DEFINE_SPINLOCK(pll_e_lock); 235 static DEFINE_SPINLOCK(pll_re_lock); 236 static DEFINE_SPINLOCK(pll_u_lock); 237 static DEFINE_SPINLOCK(emc_lock); 238 239 /* possible OSC frequencies in Hz */ 240 static unsigned long tegra210_input_freq[] = { 241 [5] = 38400000, 242 [8] = 12000000, 243 }; 244 245 static const char *mux_pllmcp_clkm[] = { 246 "pll_m", "pll_c", "pll_p", "clk_m", "pll_m_ud", "pll_c2", "pll_c3", 247 }; 248 #define mux_pllmcp_clkm_idx NULL 249 250 #define PLL_ENABLE (1 << 30) 251 252 #define PLLCX_MISC1_IDDQ (1 << 27) 253 #define PLLCX_MISC0_RESET (1 << 30) 254 255 #define PLLCX_MISC0_DEFAULT_VALUE 0x40080000 256 #define PLLCX_MISC0_WRITE_MASK 0x400ffffb 257 #define PLLCX_MISC1_DEFAULT_VALUE 0x08000000 258 #define PLLCX_MISC1_WRITE_MASK 0x08003cff 259 #define PLLCX_MISC2_DEFAULT_VALUE 0x1f720f05 260 #define PLLCX_MISC2_WRITE_MASK 0xffffff17 261 #define PLLCX_MISC3_DEFAULT_VALUE 0x000000c4 262 #define PLLCX_MISC3_WRITE_MASK 0x00ffffff 263 264 /* PLLA */ 265 #define PLLA_BASE_IDDQ (1 << 25) 266 #define PLLA_BASE_LOCK (1 << 27) 267 268 #define PLLA_MISC0_LOCK_ENABLE (1 << 28) 269 #define PLLA_MISC0_LOCK_OVERRIDE (1 << 27) 270 271 #define PLLA_MISC2_EN_SDM (1 << 26) 272 #define PLLA_MISC2_EN_DYNRAMP (1 << 25) 273 274 #define PLLA_MISC0_DEFAULT_VALUE 0x12000020 275 #define PLLA_MISC0_WRITE_MASK 0x7fffffff 276 #define PLLA_MISC2_DEFAULT_VALUE 0x0 277 #define PLLA_MISC2_WRITE_MASK 0x06ffffff 278 279 /* PLLD */ 280 #define PLLD_MISC0_EN_SDM (1 << 16) 281 #define PLLD_MISC0_LOCK_OVERRIDE (1 << 17) 282 #define PLLD_MISC0_LOCK_ENABLE (1 << 18) 283 #define PLLD_MISC0_IDDQ (1 << 20) 284 #define PLLD_MISC0_DSI_CLKENABLE (1 << 21) 285 286 #define PLLD_MISC0_DEFAULT_VALUE 0x00140000 287 #define PLLD_MISC0_WRITE_MASK 0x3ff7ffff 288 #define PLLD_MISC1_DEFAULT_VALUE 0x20 289 #define PLLD_MISC1_WRITE_MASK 0x00ffffff 290 291 /* PLLD2 and PLLDP and PLLC4 */ 292 #define PLLDSS_BASE_LOCK (1 << 27) 293 #define PLLDSS_BASE_LOCK_OVERRIDE (1 << 24) 294 #define PLLDSS_BASE_IDDQ (1 << 18) 295 #define PLLDSS_BASE_REF_SEL_SHIFT 25 296 #define PLLDSS_BASE_REF_SEL_MASK (0x3 << PLLDSS_BASE_REF_SEL_SHIFT) 297 298 #define PLLDSS_MISC0_LOCK_ENABLE (1 << 30) 299 300 #define PLLDSS_MISC1_CFG_EN_SDM (1 << 31) 301 #define PLLDSS_MISC1_CFG_EN_SSC (1 << 30) 302 303 #define PLLD2_MISC0_DEFAULT_VALUE 0x40000020 304 #define PLLD2_MISC1_CFG_DEFAULT_VALUE 0x10000000 305 #define PLLD2_MISC2_CTRL1_DEFAULT_VALUE 0x0 306 #define PLLD2_MISC3_CTRL2_DEFAULT_VALUE 0x0 307 308 #define PLLDP_MISC0_DEFAULT_VALUE 0x40000020 309 #define PLLDP_MISC1_CFG_DEFAULT_VALUE 0xc0000000 310 #define PLLDP_MISC2_CTRL1_DEFAULT_VALUE 0xf400f0da 311 #define PLLDP_MISC3_CTRL2_DEFAULT_VALUE 0x2004f400 312 313 #define PLLDSS_MISC0_WRITE_MASK 0x47ffffff 314 #define PLLDSS_MISC1_CFG_WRITE_MASK 0xf8000000 315 #define PLLDSS_MISC2_CTRL1_WRITE_MASK 0xffffffff 316 #define PLLDSS_MISC3_CTRL2_WRITE_MASK 0xffffffff 317 318 #define PLLC4_MISC0_DEFAULT_VALUE 0x40000000 319 320 /* PLLRE */ 321 #define PLLRE_MISC0_LOCK_ENABLE (1 << 30) 322 #define PLLRE_MISC0_LOCK_OVERRIDE (1 << 29) 323 #define PLLRE_MISC0_LOCK (1 << 27) 324 #define PLLRE_MISC0_IDDQ (1 << 24) 325 326 #define PLLRE_BASE_DEFAULT_VALUE 0x0 327 #define PLLRE_MISC0_DEFAULT_VALUE 0x41000000 328 329 #define PLLRE_BASE_DEFAULT_MASK 0x1c000000 330 #define PLLRE_MISC0_WRITE_MASK 0x67ffffff 331 332 /* PLLX */ 333 #define PLLX_USE_DYN_RAMP 1 334 #define PLLX_BASE_LOCK (1 << 27) 335 336 #define PLLX_MISC0_FO_G_DISABLE (0x1 << 28) 337 #define PLLX_MISC0_LOCK_ENABLE (0x1 << 18) 338 339 #define PLLX_MISC2_DYNRAMP_STEPB_SHIFT 24 340 #define PLLX_MISC2_DYNRAMP_STEPB_MASK (0xFF << PLLX_MISC2_DYNRAMP_STEPB_SHIFT) 341 #define PLLX_MISC2_DYNRAMP_STEPA_SHIFT 16 342 #define PLLX_MISC2_DYNRAMP_STEPA_MASK (0xFF << PLLX_MISC2_DYNRAMP_STEPA_SHIFT) 343 #define PLLX_MISC2_NDIV_NEW_SHIFT 8 344 #define PLLX_MISC2_NDIV_NEW_MASK (0xFF << PLLX_MISC2_NDIV_NEW_SHIFT) 345 #define PLLX_MISC2_LOCK_OVERRIDE (0x1 << 4) 346 #define PLLX_MISC2_DYNRAMP_DONE (0x1 << 2) 347 #define PLLX_MISC2_EN_DYNRAMP (0x1 << 0) 348 349 #define PLLX_MISC3_IDDQ (0x1 << 3) 350 351 #define PLLX_MISC0_DEFAULT_VALUE PLLX_MISC0_LOCK_ENABLE 352 #define PLLX_MISC0_WRITE_MASK 0x10c40000 353 #define PLLX_MISC1_DEFAULT_VALUE 0x20 354 #define PLLX_MISC1_WRITE_MASK 0x00ffffff 355 #define PLLX_MISC2_DEFAULT_VALUE 0x0 356 #define PLLX_MISC2_WRITE_MASK 0xffffff11 357 #define PLLX_MISC3_DEFAULT_VALUE PLLX_MISC3_IDDQ 358 #define PLLX_MISC3_WRITE_MASK 0x01ff0f0f 359 #define PLLX_MISC4_DEFAULT_VALUE 0x0 360 #define PLLX_MISC4_WRITE_MASK 0x8000ffff 361 #define PLLX_MISC5_DEFAULT_VALUE 0x0 362 #define PLLX_MISC5_WRITE_MASK 0x0000ffff 363 364 #define PLLX_HW_CTRL_CFG 0x548 365 #define PLLX_HW_CTRL_CFG_SWCTRL (0x1 << 0) 366 367 /* PLLMB */ 368 #define PLLMB_BASE_LOCK (1 << 27) 369 370 #define PLLMB_MISC1_LOCK_OVERRIDE (1 << 18) 371 #define PLLMB_MISC1_IDDQ (1 << 17) 372 #define PLLMB_MISC1_LOCK_ENABLE (1 << 16) 373 374 #define PLLMB_MISC1_DEFAULT_VALUE 0x00030000 375 #define PLLMB_MISC1_WRITE_MASK 0x0007ffff 376 377 /* PLLP */ 378 #define PLLP_BASE_OVERRIDE (1 << 28) 379 #define PLLP_BASE_LOCK (1 << 27) 380 381 #define PLLP_MISC0_LOCK_ENABLE (1 << 18) 382 #define PLLP_MISC0_LOCK_OVERRIDE (1 << 17) 383 #define PLLP_MISC0_IDDQ (1 << 3) 384 385 #define PLLP_MISC1_HSIO_EN_SHIFT 29 386 #define PLLP_MISC1_HSIO_EN (1 << PLLP_MISC1_HSIO_EN_SHIFT) 387 #define PLLP_MISC1_XUSB_EN_SHIFT 28 388 #define PLLP_MISC1_XUSB_EN (1 << PLLP_MISC1_XUSB_EN_SHIFT) 389 390 #define PLLP_MISC0_DEFAULT_VALUE 0x00040008 391 #define PLLP_MISC1_DEFAULT_VALUE 0x0 392 393 #define PLLP_MISC0_WRITE_MASK 0xdc6000f 394 #define PLLP_MISC1_WRITE_MASK 0x70ffffff 395 396 /* PLLU */ 397 #define PLLU_BASE_LOCK (1 << 27) 398 #define PLLU_BASE_OVERRIDE (1 << 24) 399 #define PLLU_BASE_CLKENABLE_USB (1 << 21) 400 #define PLLU_BASE_CLKENABLE_HSIC (1 << 22) 401 #define PLLU_BASE_CLKENABLE_ICUSB (1 << 23) 402 #define PLLU_BASE_CLKENABLE_48M (1 << 25) 403 #define PLLU_BASE_CLKENABLE_ALL (PLLU_BASE_CLKENABLE_USB |\ 404 PLLU_BASE_CLKENABLE_HSIC |\ 405 PLLU_BASE_CLKENABLE_ICUSB |\ 406 PLLU_BASE_CLKENABLE_48M) 407 408 #define PLLU_MISC0_IDDQ (1 << 31) 409 #define PLLU_MISC0_LOCK_ENABLE (1 << 29) 410 #define PLLU_MISC1_LOCK_OVERRIDE (1 << 0) 411 412 #define PLLU_MISC0_DEFAULT_VALUE 0xa0000000 413 #define PLLU_MISC1_DEFAULT_VALUE 0x0 414 415 #define PLLU_MISC0_WRITE_MASK 0xbfffffff 416 #define PLLU_MISC1_WRITE_MASK 0x00000007 417 418 static inline void _pll_misc_chk_default(void __iomem *base, 419 struct tegra_clk_pll_params *params, 420 u8 misc_num, u32 default_val, u32 mask) 421 { 422 u32 boot_val = readl_relaxed(base + params->ext_misc_reg[misc_num]); 423 424 boot_val &= mask; 425 default_val &= mask; 426 if (boot_val != default_val) { 427 pr_warn("boot misc%d 0x%x: expected 0x%x\n", 428 misc_num, boot_val, default_val); 429 pr_warn(" (comparison mask = 0x%x)\n", mask); 430 params->defaults_set = false; 431 } 432 } 433 434 /* 435 * PLLCX: PLLC, PLLC2, PLLC3, PLLA1 436 * Hybrid PLLs with dynamic ramp. Dynamic ramp is allowed for any transition 437 * that changes NDIV only, while PLL is already locked. 438 */ 439 static void pllcx_check_defaults(struct tegra_clk_pll_params *params) 440 { 441 u32 default_val; 442 443 default_val = PLLCX_MISC0_DEFAULT_VALUE & (~PLLCX_MISC0_RESET); 444 _pll_misc_chk_default(clk_base, params, 0, default_val, 445 PLLCX_MISC0_WRITE_MASK); 446 447 default_val = PLLCX_MISC1_DEFAULT_VALUE & (~PLLCX_MISC1_IDDQ); 448 _pll_misc_chk_default(clk_base, params, 1, default_val, 449 PLLCX_MISC1_WRITE_MASK); 450 451 default_val = PLLCX_MISC2_DEFAULT_VALUE; 452 _pll_misc_chk_default(clk_base, params, 2, default_val, 453 PLLCX_MISC2_WRITE_MASK); 454 455 default_val = PLLCX_MISC3_DEFAULT_VALUE; 456 _pll_misc_chk_default(clk_base, params, 3, default_val, 457 PLLCX_MISC3_WRITE_MASK); 458 } 459 460 void tegra210_pllcx_set_defaults(const char *name, struct tegra_clk_pll *pllcx) 461 { 462 pllcx->params->defaults_set = true; 463 464 if (readl_relaxed(clk_base + pllcx->params->base_reg) & 465 PLL_ENABLE) { 466 /* PLL is ON: only check if defaults already set */ 467 pllcx_check_defaults(pllcx->params); 468 pr_warn("%s already enabled. Postponing set full defaults\n", 469 name); 470 return; 471 } 472 473 /* Defaults assert PLL reset, and set IDDQ */ 474 writel_relaxed(PLLCX_MISC0_DEFAULT_VALUE, 475 clk_base + pllcx->params->ext_misc_reg[0]); 476 writel_relaxed(PLLCX_MISC1_DEFAULT_VALUE, 477 clk_base + pllcx->params->ext_misc_reg[1]); 478 writel_relaxed(PLLCX_MISC2_DEFAULT_VALUE, 479 clk_base + pllcx->params->ext_misc_reg[2]); 480 writel_relaxed(PLLCX_MISC3_DEFAULT_VALUE, 481 clk_base + pllcx->params->ext_misc_reg[3]); 482 udelay(1); 483 } 484 485 void _pllc_set_defaults(struct tegra_clk_pll *pllcx) 486 { 487 tegra210_pllcx_set_defaults("PLL_C", pllcx); 488 } 489 490 void _pllc2_set_defaults(struct tegra_clk_pll *pllcx) 491 { 492 tegra210_pllcx_set_defaults("PLL_C2", pllcx); 493 } 494 495 void _pllc3_set_defaults(struct tegra_clk_pll *pllcx) 496 { 497 tegra210_pllcx_set_defaults("PLL_C3", pllcx); 498 } 499 500 void _plla1_set_defaults(struct tegra_clk_pll *pllcx) 501 { 502 tegra210_pllcx_set_defaults("PLL_A1", pllcx); 503 } 504 505 /* 506 * PLLA 507 * PLL with dynamic ramp and fractional SDM. Dynamic ramp is not used. 508 * Fractional SDM is allowed to provide exact audio rates. 509 */ 510 void tegra210_plla_set_defaults(struct tegra_clk_pll *plla) 511 { 512 u32 mask; 513 u32 val = readl_relaxed(clk_base + plla->params->base_reg); 514 515 plla->params->defaults_set = true; 516 517 if (val & PLL_ENABLE) { 518 /* 519 * PLL is ON: check if defaults already set, then set those 520 * that can be updated in flight. 521 */ 522 if (val & PLLA_BASE_IDDQ) { 523 pr_warn("PLL_A boot enabled with IDDQ set\n"); 524 plla->params->defaults_set = false; 525 } 526 527 pr_warn("PLL_A already enabled. Postponing set full defaults\n"); 528 529 val = PLLA_MISC0_DEFAULT_VALUE; /* ignore lock enable */ 530 mask = PLLA_MISC0_LOCK_ENABLE | PLLA_MISC0_LOCK_OVERRIDE; 531 _pll_misc_chk_default(clk_base, plla->params, 0, val, 532 ~mask & PLLA_MISC0_WRITE_MASK); 533 534 val = PLLA_MISC2_DEFAULT_VALUE; /* ignore all but control bit */ 535 _pll_misc_chk_default(clk_base, plla->params, 2, val, 536 PLLA_MISC2_EN_DYNRAMP); 537 538 /* Enable lock detect */ 539 val = readl_relaxed(clk_base + plla->params->ext_misc_reg[0]); 540 val &= ~mask; 541 val |= PLLA_MISC0_DEFAULT_VALUE & mask; 542 writel_relaxed(val, clk_base + plla->params->ext_misc_reg[0]); 543 udelay(1); 544 545 return; 546 } 547 548 /* set IDDQ, enable lock detect, disable dynamic ramp and SDM */ 549 val |= PLLA_BASE_IDDQ; 550 writel_relaxed(val, clk_base + plla->params->base_reg); 551 writel_relaxed(PLLA_MISC0_DEFAULT_VALUE, 552 clk_base + plla->params->ext_misc_reg[0]); 553 writel_relaxed(PLLA_MISC2_DEFAULT_VALUE, 554 clk_base + plla->params->ext_misc_reg[2]); 555 udelay(1); 556 } 557 558 /* 559 * PLLD 560 * PLL with fractional SDM. 561 */ 562 void tegra210_plld_set_defaults(struct tegra_clk_pll *plld) 563 { 564 u32 val; 565 u32 mask = 0xffff; 566 567 plld->params->defaults_set = true; 568 569 if (readl_relaxed(clk_base + plld->params->base_reg) & 570 PLL_ENABLE) { 571 pr_warn("PLL_D already enabled. Postponing set full defaults\n"); 572 573 /* 574 * PLL is ON: check if defaults already set, then set those 575 * that can be updated in flight. 576 */ 577 val = PLLD_MISC1_DEFAULT_VALUE; 578 _pll_misc_chk_default(clk_base, plld->params, 1, 579 val, PLLD_MISC1_WRITE_MASK); 580 581 /* ignore lock, DSI and SDM controls, make sure IDDQ not set */ 582 val = PLLD_MISC0_DEFAULT_VALUE & (~PLLD_MISC0_IDDQ); 583 mask |= PLLD_MISC0_DSI_CLKENABLE | PLLD_MISC0_LOCK_ENABLE | 584 PLLD_MISC0_LOCK_OVERRIDE | PLLD_MISC0_EN_SDM; 585 _pll_misc_chk_default(clk_base, plld->params, 0, val, 586 ~mask & PLLD_MISC0_WRITE_MASK); 587 588 /* Enable lock detect */ 589 mask = PLLD_MISC0_LOCK_ENABLE | PLLD_MISC0_LOCK_OVERRIDE; 590 val = readl_relaxed(clk_base + plld->params->ext_misc_reg[0]); 591 val &= ~mask; 592 val |= PLLD_MISC0_DEFAULT_VALUE & mask; 593 writel_relaxed(val, clk_base + plld->params->ext_misc_reg[0]); 594 udelay(1); 595 596 return; 597 } 598 599 val = readl_relaxed(clk_base + plld->params->ext_misc_reg[0]); 600 val &= PLLD_MISC0_DSI_CLKENABLE; 601 val |= PLLD_MISC0_DEFAULT_VALUE; 602 /* set IDDQ, enable lock detect, disable SDM */ 603 writel_relaxed(val, clk_base + plld->params->ext_misc_reg[0]); 604 writel_relaxed(PLLD_MISC1_DEFAULT_VALUE, clk_base + 605 plld->params->ext_misc_reg[1]); 606 udelay(1); 607 } 608 609 /* 610 * PLLD2, PLLDP 611 * PLL with fractional SDM and Spread Spectrum (SDM is a must if SSC is used). 612 */ 613 static void plldss_defaults(const char *pll_name, struct tegra_clk_pll *plldss, 614 u32 misc0_val, u32 misc1_val, u32 misc2_val, u32 misc3_val) 615 { 616 u32 default_val; 617 u32 val = readl_relaxed(clk_base + plldss->params->base_reg); 618 619 plldss->params->defaults_set = true; 620 621 if (val & PLL_ENABLE) { 622 pr_warn("%s already enabled. Postponing set full defaults\n", 623 pll_name); 624 625 /* 626 * PLL is ON: check if defaults already set, then set those 627 * that can be updated in flight. 628 */ 629 if (val & PLLDSS_BASE_IDDQ) { 630 pr_warn("plldss boot enabled with IDDQ set\n"); 631 plldss->params->defaults_set = false; 632 } 633 634 /* ignore lock enable */ 635 default_val = misc0_val; 636 _pll_misc_chk_default(clk_base, plldss->params, 0, default_val, 637 PLLDSS_MISC0_WRITE_MASK & 638 (~PLLDSS_MISC0_LOCK_ENABLE)); 639 640 /* 641 * If SSC is used, check all settings, otherwise just confirm 642 * that SSC is not used on boot as well. Do nothing when using 643 * this function for PLLC4 that has only MISC0. 644 */ 645 if (plldss->params->ssc_ctrl_en_mask) { 646 default_val = misc1_val; 647 _pll_misc_chk_default(clk_base, plldss->params, 1, 648 default_val, PLLDSS_MISC1_CFG_WRITE_MASK); 649 default_val = misc2_val; 650 _pll_misc_chk_default(clk_base, plldss->params, 2, 651 default_val, PLLDSS_MISC2_CTRL1_WRITE_MASK); 652 default_val = misc3_val; 653 _pll_misc_chk_default(clk_base, plldss->params, 3, 654 default_val, PLLDSS_MISC3_CTRL2_WRITE_MASK); 655 } else if (plldss->params->ext_misc_reg[1]) { 656 default_val = misc1_val; 657 _pll_misc_chk_default(clk_base, plldss->params, 1, 658 default_val, PLLDSS_MISC1_CFG_WRITE_MASK & 659 (~PLLDSS_MISC1_CFG_EN_SDM)); 660 } 661 662 /* Enable lock detect */ 663 if (val & PLLDSS_BASE_LOCK_OVERRIDE) { 664 val &= ~PLLDSS_BASE_LOCK_OVERRIDE; 665 writel_relaxed(val, clk_base + 666 plldss->params->base_reg); 667 } 668 669 val = readl_relaxed(clk_base + plldss->params->ext_misc_reg[0]); 670 val &= ~PLLDSS_MISC0_LOCK_ENABLE; 671 val |= misc0_val & PLLDSS_MISC0_LOCK_ENABLE; 672 writel_relaxed(val, clk_base + plldss->params->ext_misc_reg[0]); 673 udelay(1); 674 675 return; 676 } 677 678 /* set IDDQ, enable lock detect, configure SDM/SSC */ 679 val |= PLLDSS_BASE_IDDQ; 680 val &= ~PLLDSS_BASE_LOCK_OVERRIDE; 681 writel_relaxed(val, clk_base + plldss->params->base_reg); 682 683 /* When using this function for PLLC4 exit here */ 684 if (!plldss->params->ext_misc_reg[1]) { 685 writel_relaxed(misc0_val, clk_base + 686 plldss->params->ext_misc_reg[0]); 687 udelay(1); 688 return; 689 } 690 691 writel_relaxed(misc0_val, clk_base + 692 plldss->params->ext_misc_reg[0]); 693 /* if SSC used set by 1st enable */ 694 writel_relaxed(misc1_val & (~PLLDSS_MISC1_CFG_EN_SSC), 695 clk_base + plldss->params->ext_misc_reg[1]); 696 writel_relaxed(misc2_val, clk_base + plldss->params->ext_misc_reg[2]); 697 writel_relaxed(misc3_val, clk_base + plldss->params->ext_misc_reg[3]); 698 udelay(1); 699 } 700 701 void tegra210_plld2_set_defaults(struct tegra_clk_pll *plld2) 702 { 703 plldss_defaults("PLL_D2", plld2, PLLD2_MISC0_DEFAULT_VALUE, 704 PLLD2_MISC1_CFG_DEFAULT_VALUE, 705 PLLD2_MISC2_CTRL1_DEFAULT_VALUE, 706 PLLD2_MISC3_CTRL2_DEFAULT_VALUE); 707 } 708 709 void tegra210_plldp_set_defaults(struct tegra_clk_pll *plldp) 710 { 711 plldss_defaults("PLL_DP", plldp, PLLDP_MISC0_DEFAULT_VALUE, 712 PLLDP_MISC1_CFG_DEFAULT_VALUE, 713 PLLDP_MISC2_CTRL1_DEFAULT_VALUE, 714 PLLDP_MISC3_CTRL2_DEFAULT_VALUE); 715 } 716 717 /* 718 * PLLC4 719 * Base and misc0 layout is the same as PLLD2/PLLDP, but no SDM/SSC support. 720 * VCO is exposed to the clock tree via fixed 1/3 and 1/5 dividers. 721 */ 722 void tegra210_pllc4_set_defaults(struct tegra_clk_pll *pllc4) 723 { 724 plldss_defaults("PLL_C4", pllc4, PLLC4_MISC0_DEFAULT_VALUE, 0, 0, 0); 725 } 726 727 /* 728 * PLLRE 729 * VCO is exposed to the clock tree directly along with post-divider output 730 */ 731 void tegra210_pllre_set_defaults(struct tegra_clk_pll *pllre) 732 { 733 u32 mask; 734 u32 val = readl_relaxed(clk_base + pllre->params->base_reg); 735 736 pllre->params->defaults_set = true; 737 738 if (val & PLL_ENABLE) { 739 pr_warn("PLL_RE already enabled. Postponing set full defaults\n"); 740 741 /* 742 * PLL is ON: check if defaults already set, then set those 743 * that can be updated in flight. 744 */ 745 val &= PLLRE_BASE_DEFAULT_MASK; 746 if (val != PLLRE_BASE_DEFAULT_VALUE) { 747 pr_warn("pllre boot base 0x%x : expected 0x%x\n", 748 val, PLLRE_BASE_DEFAULT_VALUE); 749 pr_warn("(comparison mask = 0x%x)\n", 750 PLLRE_BASE_DEFAULT_MASK); 751 pllre->params->defaults_set = false; 752 } 753 754 /* Ignore lock enable */ 755 val = PLLRE_MISC0_DEFAULT_VALUE & (~PLLRE_MISC0_IDDQ); 756 mask = PLLRE_MISC0_LOCK_ENABLE | PLLRE_MISC0_LOCK_OVERRIDE; 757 _pll_misc_chk_default(clk_base, pllre->params, 0, val, 758 ~mask & PLLRE_MISC0_WRITE_MASK); 759 760 /* Enable lock detect */ 761 val = readl_relaxed(clk_base + pllre->params->ext_misc_reg[0]); 762 val &= ~mask; 763 val |= PLLRE_MISC0_DEFAULT_VALUE & mask; 764 writel_relaxed(val, clk_base + pllre->params->ext_misc_reg[0]); 765 udelay(1); 766 767 return; 768 } 769 770 /* set IDDQ, enable lock detect */ 771 val &= ~PLLRE_BASE_DEFAULT_MASK; 772 val |= PLLRE_BASE_DEFAULT_VALUE & PLLRE_BASE_DEFAULT_MASK; 773 writel_relaxed(val, clk_base + pllre->params->base_reg); 774 writel_relaxed(PLLRE_MISC0_DEFAULT_VALUE, 775 clk_base + pllre->params->ext_misc_reg[0]); 776 udelay(1); 777 } 778 779 static void pllx_get_dyn_steps(struct clk_hw *hw, u32 *step_a, u32 *step_b) 780 { 781 unsigned long input_rate; 782 783 /* cf rate */ 784 if (!IS_ERR_OR_NULL(hw->clk)) 785 input_rate = clk_hw_get_rate(clk_hw_get_parent(hw)); 786 else 787 input_rate = 38400000; 788 789 input_rate /= tegra_pll_get_fixed_mdiv(hw, input_rate); 790 791 switch (input_rate) { 792 case 12000000: 793 case 12800000: 794 case 13000000: 795 *step_a = 0x2B; 796 *step_b = 0x0B; 797 return; 798 case 19200000: 799 *step_a = 0x12; 800 *step_b = 0x08; 801 return; 802 case 38400000: 803 *step_a = 0x04; 804 *step_b = 0x05; 805 return; 806 default: 807 pr_err("%s: Unexpected reference rate %lu\n", 808 __func__, input_rate); 809 BUG(); 810 } 811 } 812 813 static void pllx_check_defaults(struct tegra_clk_pll *pll) 814 { 815 u32 default_val; 816 817 default_val = PLLX_MISC0_DEFAULT_VALUE; 818 /* ignore lock enable */ 819 _pll_misc_chk_default(clk_base, pll->params, 0, default_val, 820 PLLX_MISC0_WRITE_MASK & (~PLLX_MISC0_LOCK_ENABLE)); 821 822 default_val = PLLX_MISC1_DEFAULT_VALUE; 823 _pll_misc_chk_default(clk_base, pll->params, 1, default_val, 824 PLLX_MISC1_WRITE_MASK); 825 826 /* ignore all but control bit */ 827 default_val = PLLX_MISC2_DEFAULT_VALUE; 828 _pll_misc_chk_default(clk_base, pll->params, 2, 829 default_val, PLLX_MISC2_EN_DYNRAMP); 830 831 default_val = PLLX_MISC3_DEFAULT_VALUE & (~PLLX_MISC3_IDDQ); 832 _pll_misc_chk_default(clk_base, pll->params, 3, default_val, 833 PLLX_MISC3_WRITE_MASK); 834 835 default_val = PLLX_MISC4_DEFAULT_VALUE; 836 _pll_misc_chk_default(clk_base, pll->params, 4, default_val, 837 PLLX_MISC4_WRITE_MASK); 838 839 default_val = PLLX_MISC5_DEFAULT_VALUE; 840 _pll_misc_chk_default(clk_base, pll->params, 5, default_val, 841 PLLX_MISC5_WRITE_MASK); 842 } 843 844 void tegra210_pllx_set_defaults(struct tegra_clk_pll *pllx) 845 { 846 u32 val; 847 u32 step_a, step_b; 848 849 pllx->params->defaults_set = true; 850 851 /* Get ready dyn ramp state machine settings */ 852 pllx_get_dyn_steps(&pllx->hw, &step_a, &step_b); 853 val = PLLX_MISC2_DEFAULT_VALUE & (~PLLX_MISC2_DYNRAMP_STEPA_MASK) & 854 (~PLLX_MISC2_DYNRAMP_STEPB_MASK); 855 val |= step_a << PLLX_MISC2_DYNRAMP_STEPA_SHIFT; 856 val |= step_b << PLLX_MISC2_DYNRAMP_STEPB_SHIFT; 857 858 if (readl_relaxed(clk_base + pllx->params->base_reg) & PLL_ENABLE) { 859 pr_warn("PLL_X already enabled. Postponing set full defaults\n"); 860 861 /* 862 * PLL is ON: check if defaults already set, then set those 863 * that can be updated in flight. 864 */ 865 pllx_check_defaults(pllx); 866 867 /* Configure dyn ramp, disable lock override */ 868 writel_relaxed(val, clk_base + pllx->params->ext_misc_reg[2]); 869 870 /* Enable lock detect */ 871 val = readl_relaxed(clk_base + pllx->params->ext_misc_reg[0]); 872 val &= ~PLLX_MISC0_LOCK_ENABLE; 873 val |= PLLX_MISC0_DEFAULT_VALUE & PLLX_MISC0_LOCK_ENABLE; 874 writel_relaxed(val, clk_base + pllx->params->ext_misc_reg[0]); 875 udelay(1); 876 877 return; 878 } 879 880 /* Enable lock detect and CPU output */ 881 writel_relaxed(PLLX_MISC0_DEFAULT_VALUE, clk_base + 882 pllx->params->ext_misc_reg[0]); 883 884 /* Setup */ 885 writel_relaxed(PLLX_MISC1_DEFAULT_VALUE, clk_base + 886 pllx->params->ext_misc_reg[1]); 887 888 /* Configure dyn ramp state machine, disable lock override */ 889 writel_relaxed(val, clk_base + pllx->params->ext_misc_reg[2]); 890 891 /* Set IDDQ */ 892 writel_relaxed(PLLX_MISC3_DEFAULT_VALUE, clk_base + 893 pllx->params->ext_misc_reg[3]); 894 895 /* Disable SDM */ 896 writel_relaxed(PLLX_MISC4_DEFAULT_VALUE, clk_base + 897 pllx->params->ext_misc_reg[4]); 898 writel_relaxed(PLLX_MISC5_DEFAULT_VALUE, clk_base + 899 pllx->params->ext_misc_reg[5]); 900 udelay(1); 901 } 902 903 /* PLLMB */ 904 void tegra210_pllmb_set_defaults(struct tegra_clk_pll *pllmb) 905 { 906 u32 mask, val = readl_relaxed(clk_base + pllmb->params->base_reg); 907 908 pllmb->params->defaults_set = true; 909 910 if (val & PLL_ENABLE) { 911 pr_warn("PLL_MB already enabled. Postponing set full defaults\n"); 912 913 /* 914 * PLL is ON: check if defaults already set, then set those 915 * that can be updated in flight. 916 */ 917 val = PLLMB_MISC1_DEFAULT_VALUE & (~PLLMB_MISC1_IDDQ); 918 mask = PLLMB_MISC1_LOCK_ENABLE | PLLMB_MISC1_LOCK_OVERRIDE; 919 _pll_misc_chk_default(clk_base, pllmb->params, 0, val, 920 ~mask & PLLMB_MISC1_WRITE_MASK); 921 922 /* Enable lock detect */ 923 val = readl_relaxed(clk_base + pllmb->params->ext_misc_reg[0]); 924 val &= ~mask; 925 val |= PLLMB_MISC1_DEFAULT_VALUE & mask; 926 writel_relaxed(val, clk_base + pllmb->params->ext_misc_reg[0]); 927 udelay(1); 928 929 return; 930 } 931 932 /* set IDDQ, enable lock detect */ 933 writel_relaxed(PLLMB_MISC1_DEFAULT_VALUE, 934 clk_base + pllmb->params->ext_misc_reg[0]); 935 udelay(1); 936 } 937 938 /* 939 * PLLP 940 * VCO is exposed to the clock tree directly along with post-divider output. 941 * Both VCO and post-divider output rates are fixed at 408MHz and 204MHz, 942 * respectively. 943 */ 944 static void pllp_check_defaults(struct tegra_clk_pll *pll, bool enabled) 945 { 946 u32 val, mask; 947 948 /* Ignore lock enable (will be set), make sure not in IDDQ if enabled */ 949 val = PLLP_MISC0_DEFAULT_VALUE & (~PLLP_MISC0_IDDQ); 950 mask = PLLP_MISC0_LOCK_ENABLE | PLLP_MISC0_LOCK_OVERRIDE; 951 if (!enabled) 952 mask |= PLLP_MISC0_IDDQ; 953 _pll_misc_chk_default(clk_base, pll->params, 0, val, 954 ~mask & PLLP_MISC0_WRITE_MASK); 955 956 /* Ignore branch controls */ 957 val = PLLP_MISC1_DEFAULT_VALUE; 958 mask = PLLP_MISC1_HSIO_EN | PLLP_MISC1_XUSB_EN; 959 _pll_misc_chk_default(clk_base, pll->params, 1, val, 960 ~mask & PLLP_MISC1_WRITE_MASK); 961 } 962 963 void tegra210_pllp_set_defaults(struct tegra_clk_pll *pllp) 964 { 965 u32 mask; 966 u32 val = readl_relaxed(clk_base + pllp->params->base_reg); 967 968 pllp->params->defaults_set = true; 969 970 if (val & PLL_ENABLE) { 971 pr_warn("PLL_P already enabled. Postponing set full defaults\n"); 972 973 /* 974 * PLL is ON: check if defaults already set, then set those 975 * that can be updated in flight. 976 */ 977 pllp_check_defaults(pllp, true); 978 979 /* Enable lock detect */ 980 val = readl_relaxed(clk_base + pllp->params->ext_misc_reg[0]); 981 mask = PLLP_MISC0_LOCK_ENABLE | PLLP_MISC0_LOCK_OVERRIDE; 982 val &= ~mask; 983 val |= PLLP_MISC0_DEFAULT_VALUE & mask; 984 writel_relaxed(val, clk_base + pllp->params->ext_misc_reg[0]); 985 udelay(1); 986 987 return; 988 } 989 990 /* set IDDQ, enable lock detect */ 991 writel_relaxed(PLLP_MISC0_DEFAULT_VALUE, 992 clk_base + pllp->params->ext_misc_reg[0]); 993 994 /* Preserve branch control */ 995 val = readl_relaxed(clk_base + pllp->params->ext_misc_reg[1]); 996 mask = PLLP_MISC1_HSIO_EN | PLLP_MISC1_XUSB_EN; 997 val &= mask; 998 val |= ~mask & PLLP_MISC1_DEFAULT_VALUE; 999 writel_relaxed(val, clk_base + pllp->params->ext_misc_reg[1]); 1000 udelay(1); 1001 } 1002 1003 /* 1004 * PLLU 1005 * VCO is exposed to the clock tree directly along with post-divider output. 1006 * Both VCO and post-divider output rates are fixed at 480MHz and 240MHz, 1007 * respectively. 1008 */ 1009 static void pllu_check_defaults(struct tegra_clk_pll *pll, bool hw_control) 1010 { 1011 u32 val, mask; 1012 1013 /* Ignore lock enable (will be set) and IDDQ if under h/w control */ 1014 val = PLLU_MISC0_DEFAULT_VALUE & (~PLLU_MISC0_IDDQ); 1015 mask = PLLU_MISC0_LOCK_ENABLE | (hw_control ? PLLU_MISC0_IDDQ : 0); 1016 _pll_misc_chk_default(clk_base, pll->params, 0, val, 1017 ~mask & PLLU_MISC0_WRITE_MASK); 1018 1019 val = PLLU_MISC1_DEFAULT_VALUE; 1020 mask = PLLU_MISC1_LOCK_OVERRIDE; 1021 _pll_misc_chk_default(clk_base, pll->params, 1, val, 1022 ~mask & PLLU_MISC1_WRITE_MASK); 1023 } 1024 1025 void tegra210_pllu_set_defaults(struct tegra_clk_pll *pllu) 1026 { 1027 u32 val = readl_relaxed(clk_base + pllu->params->base_reg); 1028 1029 pllu->params->defaults_set = true; 1030 1031 if (val & PLL_ENABLE) { 1032 pr_warn("PLL_U already enabled. Postponing set full defaults\n"); 1033 1034 /* 1035 * PLL is ON: check if defaults already set, then set those 1036 * that can be updated in flight. 1037 */ 1038 pllu_check_defaults(pllu, false); 1039 1040 /* Enable lock detect */ 1041 val = readl_relaxed(clk_base + pllu->params->ext_misc_reg[0]); 1042 val &= ~PLLU_MISC0_LOCK_ENABLE; 1043 val |= PLLU_MISC0_DEFAULT_VALUE & PLLU_MISC0_LOCK_ENABLE; 1044 writel_relaxed(val, clk_base + pllu->params->ext_misc_reg[0]); 1045 1046 val = readl_relaxed(clk_base + pllu->params->ext_misc_reg[1]); 1047 val &= ~PLLU_MISC1_LOCK_OVERRIDE; 1048 val |= PLLU_MISC1_DEFAULT_VALUE & PLLU_MISC1_LOCK_OVERRIDE; 1049 writel_relaxed(val, clk_base + pllu->params->ext_misc_reg[1]); 1050 udelay(1); 1051 1052 return; 1053 } 1054 1055 /* set IDDQ, enable lock detect */ 1056 writel_relaxed(PLLU_MISC0_DEFAULT_VALUE, 1057 clk_base + pllu->params->ext_misc_reg[0]); 1058 writel_relaxed(PLLU_MISC1_DEFAULT_VALUE, 1059 clk_base + pllu->params->ext_misc_reg[1]); 1060 udelay(1); 1061 } 1062 1063 #define mask(w) ((1 << (w)) - 1) 1064 #define divm_mask(p) mask(p->params->div_nmp->divm_width) 1065 #define divn_mask(p) mask(p->params->div_nmp->divn_width) 1066 #define divp_mask(p) (p->params->flags & TEGRA_PLLU ? PLLU_POST_DIVP_MASK :\ 1067 mask(p->params->div_nmp->divp_width)) 1068 1069 #define divm_shift(p) ((p)->params->div_nmp->divm_shift) 1070 #define divn_shift(p) ((p)->params->div_nmp->divn_shift) 1071 #define divp_shift(p) ((p)->params->div_nmp->divp_shift) 1072 1073 #define divm_mask_shifted(p) (divm_mask(p) << divm_shift(p)) 1074 #define divn_mask_shifted(p) (divn_mask(p) << divn_shift(p)) 1075 #define divp_mask_shifted(p) (divp_mask(p) << divp_shift(p)) 1076 1077 #define PLL_LOCKDET_DELAY 2 /* Lock detection safety delays */ 1078 static int tegra210_wait_for_mask(struct tegra_clk_pll *pll, 1079 u32 reg, u32 mask) 1080 { 1081 int i; 1082 u32 val = 0; 1083 1084 for (i = 0; i < pll->params->lock_delay / PLL_LOCKDET_DELAY + 1; i++) { 1085 udelay(PLL_LOCKDET_DELAY); 1086 val = readl_relaxed(clk_base + reg); 1087 if ((val & mask) == mask) { 1088 udelay(PLL_LOCKDET_DELAY); 1089 return 0; 1090 } 1091 } 1092 return -ETIMEDOUT; 1093 } 1094 1095 static int tegra210_pllx_dyn_ramp(struct tegra_clk_pll *pllx, 1096 struct tegra_clk_pll_freq_table *cfg) 1097 { 1098 u32 val, base, ndiv_new_mask; 1099 1100 ndiv_new_mask = (divn_mask(pllx) >> pllx->params->div_nmp->divn_shift) 1101 << PLLX_MISC2_NDIV_NEW_SHIFT; 1102 1103 val = readl_relaxed(clk_base + pllx->params->ext_misc_reg[2]); 1104 val &= (~ndiv_new_mask); 1105 val |= cfg->n << PLLX_MISC2_NDIV_NEW_SHIFT; 1106 writel_relaxed(val, clk_base + pllx->params->ext_misc_reg[2]); 1107 udelay(1); 1108 1109 val = readl_relaxed(clk_base + pllx->params->ext_misc_reg[2]); 1110 val |= PLLX_MISC2_EN_DYNRAMP; 1111 writel_relaxed(val, clk_base + pllx->params->ext_misc_reg[2]); 1112 udelay(1); 1113 1114 tegra210_wait_for_mask(pllx, pllx->params->ext_misc_reg[2], 1115 PLLX_MISC2_DYNRAMP_DONE); 1116 1117 base = readl_relaxed(clk_base + pllx->params->base_reg) & 1118 (~divn_mask_shifted(pllx)); 1119 base |= cfg->n << pllx->params->div_nmp->divn_shift; 1120 writel_relaxed(base, clk_base + pllx->params->base_reg); 1121 udelay(1); 1122 1123 val &= ~PLLX_MISC2_EN_DYNRAMP; 1124 writel_relaxed(val, clk_base + pllx->params->ext_misc_reg[2]); 1125 udelay(1); 1126 1127 pr_debug("%s: dynamic ramp to m = %u n = %u p = %u, Fout = %lu kHz\n", 1128 __clk_get_name(pllx->hw.clk), cfg->m, cfg->n, cfg->p, 1129 cfg->input_rate / cfg->m * cfg->n / 1130 pllx->params->pdiv_tohw[cfg->p].pdiv / 1000); 1131 1132 return 0; 1133 } 1134 1135 /* 1136 * Common configuration for PLLs with fixed input divider policy: 1137 * - always set fixed M-value based on the reference rate 1138 * - always set P-value value 1:1 for output rates above VCO minimum, and 1139 * choose minimum necessary P-value for output rates below VCO maximum 1140 * - calculate N-value based on selected M and P 1141 * - calculate SDM_DIN fractional part 1142 */ 1143 static int tegra210_pll_fixed_mdiv_cfg(struct clk_hw *hw, 1144 struct tegra_clk_pll_freq_table *cfg, 1145 unsigned long rate, unsigned long input_rate) 1146 { 1147 struct tegra_clk_pll *pll = to_clk_pll(hw); 1148 struct tegra_clk_pll_params *params = pll->params; 1149 int p; 1150 unsigned long cf, p_rate; 1151 u32 pdiv; 1152 1153 if (!rate) 1154 return -EINVAL; 1155 1156 if (!(params->flags & TEGRA_PLL_VCO_OUT)) { 1157 p = DIV_ROUND_UP(params->vco_min, rate); 1158 p = params->round_p_to_pdiv(p, &pdiv); 1159 } else { 1160 p = rate >= params->vco_min ? 1 : -EINVAL; 1161 } 1162 1163 if (IS_ERR_VALUE(p)) 1164 return -EINVAL; 1165 1166 cfg->m = tegra_pll_get_fixed_mdiv(hw, input_rate); 1167 cfg->p = p; 1168 1169 /* Store P as HW value, as that is what is expected */ 1170 cfg->p = tegra_pll_p_div_to_hw(pll, cfg->p); 1171 1172 p_rate = rate * p; 1173 if (p_rate > params->vco_max) 1174 p_rate = params->vco_max; 1175 cf = input_rate / cfg->m; 1176 cfg->n = p_rate / cf; 1177 1178 cfg->sdm_data = 0; 1179 if (params->sdm_ctrl_reg) { 1180 unsigned long rem = p_rate - cf * cfg->n; 1181 /* If ssc is enabled SDM enabled as well, even for integer n */ 1182 if (rem || params->ssc_ctrl_reg) { 1183 u64 s = rem * PLL_SDM_COEFF; 1184 1185 do_div(s, cf); 1186 s -= PLL_SDM_COEFF / 2; 1187 cfg->sdm_data = sdin_din_to_data(s); 1188 } 1189 } 1190 1191 cfg->input_rate = input_rate; 1192 cfg->output_rate = rate; 1193 1194 return 0; 1195 } 1196 1197 /* 1198 * clk_pll_set_gain - set gain to m, n to calculate correct VCO rate 1199 * 1200 * @cfg: struct tegra_clk_pll_freq_table * cfg 1201 * 1202 * For Normal mode: 1203 * Fvco = Fref * NDIV / MDIV 1204 * 1205 * For fractional mode: 1206 * Fvco = Fref * (NDIV + 0.5 + SDM_DIN / PLL_SDM_COEFF) / MDIV 1207 */ 1208 static void tegra210_clk_pll_set_gain(struct tegra_clk_pll_freq_table *cfg) 1209 { 1210 cfg->n = cfg->n * PLL_SDM_COEFF + PLL_SDM_COEFF/2 + 1211 sdin_data_to_din(cfg->sdm_data); 1212 cfg->m *= PLL_SDM_COEFF; 1213 } 1214 1215 unsigned long tegra210_clk_adjust_vco_min(struct tegra_clk_pll_params *params, 1216 unsigned long parent_rate) 1217 { 1218 unsigned long vco_min = params->vco_min; 1219 1220 params->vco_min += DIV_ROUND_UP(parent_rate, PLL_SDM_COEFF); 1221 vco_min = min(vco_min, params->vco_min); 1222 1223 return vco_min; 1224 } 1225 1226 static struct div_nmp pllx_nmp = { 1227 .divm_shift = 0, 1228 .divm_width = 8, 1229 .divn_shift = 8, 1230 .divn_width = 8, 1231 .divp_shift = 20, 1232 .divp_width = 5, 1233 }; 1234 /* 1235 * PLL post divider maps - two types: quasi-linear and exponential 1236 * post divider. 1237 */ 1238 #define PLL_QLIN_PDIV_MAX 16 1239 static const struct pdiv_map pll_qlin_pdiv_to_hw[] = { 1240 { .pdiv = 1, .hw_val = 0 }, 1241 { .pdiv = 2, .hw_val = 1 }, 1242 { .pdiv = 3, .hw_val = 2 }, 1243 { .pdiv = 4, .hw_val = 3 }, 1244 { .pdiv = 5, .hw_val = 4 }, 1245 { .pdiv = 6, .hw_val = 5 }, 1246 { .pdiv = 8, .hw_val = 6 }, 1247 { .pdiv = 9, .hw_val = 7 }, 1248 { .pdiv = 10, .hw_val = 8 }, 1249 { .pdiv = 12, .hw_val = 9 }, 1250 { .pdiv = 15, .hw_val = 10 }, 1251 { .pdiv = 16, .hw_val = 11 }, 1252 { .pdiv = 18, .hw_val = 12 }, 1253 { .pdiv = 20, .hw_val = 13 }, 1254 { .pdiv = 24, .hw_val = 14 }, 1255 { .pdiv = 30, .hw_val = 15 }, 1256 { .pdiv = 32, .hw_val = 16 }, 1257 }; 1258 1259 static u32 pll_qlin_p_to_pdiv(u32 p, u32 *pdiv) 1260 { 1261 int i; 1262 1263 if (p) { 1264 for (i = 0; i <= PLL_QLIN_PDIV_MAX; i++) { 1265 if (p <= pll_qlin_pdiv_to_hw[i].pdiv) { 1266 if (pdiv) 1267 *pdiv = i; 1268 return pll_qlin_pdiv_to_hw[i].pdiv; 1269 } 1270 } 1271 } 1272 1273 return -EINVAL; 1274 } 1275 1276 #define PLL_EXPO_PDIV_MAX 7 1277 static const struct pdiv_map pll_expo_pdiv_to_hw[] = { 1278 { .pdiv = 1, .hw_val = 0 }, 1279 { .pdiv = 2, .hw_val = 1 }, 1280 { .pdiv = 4, .hw_val = 2 }, 1281 { .pdiv = 8, .hw_val = 3 }, 1282 { .pdiv = 16, .hw_val = 4 }, 1283 { .pdiv = 32, .hw_val = 5 }, 1284 { .pdiv = 64, .hw_val = 6 }, 1285 { .pdiv = 128, .hw_val = 7 }, 1286 }; 1287 1288 static u32 pll_expo_p_to_pdiv(u32 p, u32 *pdiv) 1289 { 1290 if (p) { 1291 u32 i = fls(p); 1292 1293 if (i == ffs(p)) 1294 i--; 1295 1296 if (i <= PLL_EXPO_PDIV_MAX) { 1297 if (pdiv) 1298 *pdiv = i; 1299 return 1 << i; 1300 } 1301 } 1302 return -EINVAL; 1303 } 1304 1305 static struct tegra_clk_pll_freq_table pll_x_freq_table[] = { 1306 /* 1 GHz */ 1307 { 12000000, 1000000000, 166, 1, 1, 0 }, /* actual: 996.0 MHz */ 1308 { 13000000, 1000000000, 153, 1, 1, 0 }, /* actual: 994.0 MHz */ 1309 { 38400000, 1000000000, 156, 3, 1, 0 }, /* actual: 998.4 MHz */ 1310 { 0, 0, 0, 0, 0, 0 }, 1311 }; 1312 1313 static struct tegra_clk_pll_params pll_x_params = { 1314 .input_min = 12000000, 1315 .input_max = 800000000, 1316 .cf_min = 12000000, 1317 .cf_max = 38400000, 1318 .vco_min = 1350000000, 1319 .vco_max = 3000000000UL, 1320 .base_reg = PLLX_BASE, 1321 .misc_reg = PLLX_MISC0, 1322 .lock_mask = PLL_BASE_LOCK, 1323 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE, 1324 .lock_delay = 300, 1325 .ext_misc_reg[0] = PLLX_MISC0, 1326 .ext_misc_reg[1] = PLLX_MISC1, 1327 .ext_misc_reg[2] = PLLX_MISC2, 1328 .ext_misc_reg[3] = PLLX_MISC3, 1329 .ext_misc_reg[4] = PLLX_MISC4, 1330 .ext_misc_reg[5] = PLLX_MISC5, 1331 .iddq_reg = PLLX_MISC3, 1332 .iddq_bit_idx = PLLXP_IDDQ_BIT, 1333 .max_p = PLL_QLIN_PDIV_MAX, 1334 .mdiv_default = 2, 1335 .dyn_ramp_reg = PLLX_MISC2, 1336 .stepa_shift = 16, 1337 .stepb_shift = 24, 1338 .round_p_to_pdiv = pll_qlin_p_to_pdiv, 1339 .pdiv_tohw = pll_qlin_pdiv_to_hw, 1340 .div_nmp = &pllx_nmp, 1341 .freq_table = pll_x_freq_table, 1342 .flags = TEGRA_PLL_USE_LOCK | TEGRA_PLL_HAS_LOCK_ENABLE, 1343 .dyn_ramp = tegra210_pllx_dyn_ramp, 1344 .set_defaults = tegra210_pllx_set_defaults, 1345 .calc_rate = tegra210_pll_fixed_mdiv_cfg, 1346 }; 1347 1348 static struct div_nmp pllc_nmp = { 1349 .divm_shift = 0, 1350 .divm_width = 8, 1351 .divn_shift = 10, 1352 .divn_width = 8, 1353 .divp_shift = 20, 1354 .divp_width = 5, 1355 }; 1356 1357 static struct tegra_clk_pll_freq_table pll_cx_freq_table[] = { 1358 { 12000000, 510000000, 85, 1, 1, 0 }, 1359 { 13000000, 510000000, 78, 1, 1, 0 }, /* actual: 507.0 MHz */ 1360 { 38400000, 510000000, 79, 3, 1, 0 }, /* actual: 505.6 MHz */ 1361 { 0, 0, 0, 0, 0, 0 }, 1362 }; 1363 1364 static struct tegra_clk_pll_params pll_c_params = { 1365 .input_min = 12000000, 1366 .input_max = 700000000, 1367 .cf_min = 12000000, 1368 .cf_max = 50000000, 1369 .vco_min = 600000000, 1370 .vco_max = 1200000000, 1371 .base_reg = PLLC_BASE, 1372 .misc_reg = PLLC_MISC0, 1373 .lock_mask = PLL_BASE_LOCK, 1374 .lock_delay = 300, 1375 .iddq_reg = PLLC_MISC1, 1376 .iddq_bit_idx = PLLCX_IDDQ_BIT, 1377 .reset_reg = PLLC_MISC0, 1378 .reset_bit_idx = PLLCX_RESET_BIT, 1379 .max_p = PLL_QLIN_PDIV_MAX, 1380 .ext_misc_reg[0] = PLLC_MISC0, 1381 .ext_misc_reg[1] = PLLC_MISC1, 1382 .ext_misc_reg[2] = PLLC_MISC2, 1383 .ext_misc_reg[3] = PLLC_MISC3, 1384 .round_p_to_pdiv = pll_qlin_p_to_pdiv, 1385 .pdiv_tohw = pll_qlin_pdiv_to_hw, 1386 .mdiv_default = 3, 1387 .div_nmp = &pllc_nmp, 1388 .freq_table = pll_cx_freq_table, 1389 .flags = TEGRA_PLL_USE_LOCK, 1390 .set_defaults = _pllc_set_defaults, 1391 .calc_rate = tegra210_pll_fixed_mdiv_cfg, 1392 }; 1393 1394 static struct div_nmp pllcx_nmp = { 1395 .divm_shift = 0, 1396 .divm_width = 8, 1397 .divn_shift = 10, 1398 .divn_width = 8, 1399 .divp_shift = 20, 1400 .divp_width = 5, 1401 }; 1402 1403 static struct tegra_clk_pll_params pll_c2_params = { 1404 .input_min = 12000000, 1405 .input_max = 700000000, 1406 .cf_min = 12000000, 1407 .cf_max = 50000000, 1408 .vco_min = 600000000, 1409 .vco_max = 1200000000, 1410 .base_reg = PLLC2_BASE, 1411 .misc_reg = PLLC2_MISC0, 1412 .iddq_reg = PLLC2_MISC1, 1413 .iddq_bit_idx = PLLCX_IDDQ_BIT, 1414 .reset_reg = PLLC2_MISC0, 1415 .reset_bit_idx = PLLCX_RESET_BIT, 1416 .lock_mask = PLLCX_BASE_LOCK, 1417 .lock_delay = 300, 1418 .round_p_to_pdiv = pll_qlin_p_to_pdiv, 1419 .pdiv_tohw = pll_qlin_pdiv_to_hw, 1420 .mdiv_default = 3, 1421 .div_nmp = &pllcx_nmp, 1422 .max_p = PLL_QLIN_PDIV_MAX, 1423 .ext_misc_reg[0] = PLLC2_MISC0, 1424 .ext_misc_reg[1] = PLLC2_MISC1, 1425 .ext_misc_reg[2] = PLLC2_MISC2, 1426 .ext_misc_reg[3] = PLLC2_MISC3, 1427 .freq_table = pll_cx_freq_table, 1428 .flags = TEGRA_PLL_USE_LOCK, 1429 .set_defaults = _pllc2_set_defaults, 1430 .calc_rate = tegra210_pll_fixed_mdiv_cfg, 1431 }; 1432 1433 static struct tegra_clk_pll_params pll_c3_params = { 1434 .input_min = 12000000, 1435 .input_max = 700000000, 1436 .cf_min = 12000000, 1437 .cf_max = 50000000, 1438 .vco_min = 600000000, 1439 .vco_max = 1200000000, 1440 .base_reg = PLLC3_BASE, 1441 .misc_reg = PLLC3_MISC0, 1442 .lock_mask = PLLCX_BASE_LOCK, 1443 .lock_delay = 300, 1444 .iddq_reg = PLLC3_MISC1, 1445 .iddq_bit_idx = PLLCX_IDDQ_BIT, 1446 .reset_reg = PLLC3_MISC0, 1447 .reset_bit_idx = PLLCX_RESET_BIT, 1448 .round_p_to_pdiv = pll_qlin_p_to_pdiv, 1449 .pdiv_tohw = pll_qlin_pdiv_to_hw, 1450 .mdiv_default = 3, 1451 .div_nmp = &pllcx_nmp, 1452 .max_p = PLL_QLIN_PDIV_MAX, 1453 .ext_misc_reg[0] = PLLC3_MISC0, 1454 .ext_misc_reg[1] = PLLC3_MISC1, 1455 .ext_misc_reg[2] = PLLC3_MISC2, 1456 .ext_misc_reg[3] = PLLC3_MISC3, 1457 .freq_table = pll_cx_freq_table, 1458 .flags = TEGRA_PLL_USE_LOCK, 1459 .set_defaults = _pllc3_set_defaults, 1460 .calc_rate = tegra210_pll_fixed_mdiv_cfg, 1461 }; 1462 1463 static struct div_nmp pllss_nmp = { 1464 .divm_shift = 0, 1465 .divm_width = 8, 1466 .divn_shift = 8, 1467 .divn_width = 8, 1468 .divp_shift = 19, 1469 .divp_width = 5, 1470 }; 1471 1472 static struct tegra_clk_pll_freq_table pll_c4_vco_freq_table[] = { 1473 { 12000000, 600000000, 50, 1, 0, 0 }, 1474 { 13000000, 600000000, 46, 1, 0, 0 }, /* actual: 598.0 MHz */ 1475 { 38400000, 600000000, 62, 4, 0, 0 }, /* actual: 595.2 MHz */ 1476 { 0, 0, 0, 0, 0, 0 }, 1477 }; 1478 1479 static const struct clk_div_table pll_vco_post_div_table[] = { 1480 { .val = 0, .div = 1 }, 1481 { .val = 1, .div = 2 }, 1482 { .val = 2, .div = 3 }, 1483 { .val = 3, .div = 4 }, 1484 { .val = 4, .div = 5 }, 1485 { .val = 5, .div = 6 }, 1486 { .val = 6, .div = 8 }, 1487 { .val = 7, .div = 10 }, 1488 { .val = 8, .div = 12 }, 1489 { .val = 9, .div = 16 }, 1490 { .val = 10, .div = 12 }, 1491 { .val = 11, .div = 16 }, 1492 { .val = 12, .div = 20 }, 1493 { .val = 13, .div = 24 }, 1494 { .val = 14, .div = 32 }, 1495 { .val = 0, .div = 0 }, 1496 }; 1497 1498 static struct tegra_clk_pll_params pll_c4_vco_params = { 1499 .input_min = 9600000, 1500 .input_max = 800000000, 1501 .cf_min = 9600000, 1502 .cf_max = 19200000, 1503 .vco_min = 500000000, 1504 .vco_max = 1080000000, 1505 .base_reg = PLLC4_BASE, 1506 .misc_reg = PLLC4_MISC0, 1507 .lock_mask = PLL_BASE_LOCK, 1508 .lock_delay = 300, 1509 .max_p = PLL_QLIN_PDIV_MAX, 1510 .ext_misc_reg[0] = PLLC4_MISC0, 1511 .iddq_reg = PLLC4_BASE, 1512 .iddq_bit_idx = PLLSS_IDDQ_BIT, 1513 .round_p_to_pdiv = pll_qlin_p_to_pdiv, 1514 .pdiv_tohw = pll_qlin_pdiv_to_hw, 1515 .mdiv_default = 3, 1516 .div_nmp = &pllss_nmp, 1517 .freq_table = pll_c4_vco_freq_table, 1518 .set_defaults = tegra210_pllc4_set_defaults, 1519 .flags = TEGRA_PLL_USE_LOCK | TEGRA_PLL_VCO_OUT, 1520 .calc_rate = tegra210_pll_fixed_mdiv_cfg, 1521 }; 1522 1523 static struct tegra_clk_pll_freq_table pll_m_freq_table[] = { 1524 { 12000000, 800000000, 66, 1, 0, 0 }, /* actual: 792.0 MHz */ 1525 { 13000000, 800000000, 61, 1, 0, 0 }, /* actual: 793.0 MHz */ 1526 { 38400000, 297600000, 93, 4, 2, 0 }, 1527 { 38400000, 400000000, 125, 4, 2, 0 }, 1528 { 38400000, 532800000, 111, 4, 1, 0 }, 1529 { 38400000, 665600000, 104, 3, 1, 0 }, 1530 { 38400000, 800000000, 125, 3, 1, 0 }, 1531 { 38400000, 931200000, 97, 4, 0, 0 }, 1532 { 38400000, 1065600000, 111, 4, 0, 0 }, 1533 { 38400000, 1200000000, 125, 4, 0, 0 }, 1534 { 38400000, 1331200000, 104, 3, 0, 0 }, 1535 { 38400000, 1459200000, 76, 2, 0, 0 }, 1536 { 38400000, 1600000000, 125, 3, 0, 0 }, 1537 { 0, 0, 0, 0, 0, 0 }, 1538 }; 1539 1540 static struct div_nmp pllm_nmp = { 1541 .divm_shift = 0, 1542 .divm_width = 8, 1543 .override_divm_shift = 0, 1544 .divn_shift = 8, 1545 .divn_width = 8, 1546 .override_divn_shift = 8, 1547 .divp_shift = 20, 1548 .divp_width = 5, 1549 .override_divp_shift = 27, 1550 }; 1551 1552 static struct tegra_clk_pll_params pll_m_params = { 1553 .input_min = 9600000, 1554 .input_max = 500000000, 1555 .cf_min = 9600000, 1556 .cf_max = 19200000, 1557 .vco_min = 800000000, 1558 .vco_max = 1866000000, 1559 .base_reg = PLLM_BASE, 1560 .misc_reg = PLLM_MISC2, 1561 .lock_mask = PLL_BASE_LOCK, 1562 .lock_enable_bit_idx = PLLM_MISC_LOCK_ENABLE, 1563 .lock_delay = 300, 1564 .iddq_reg = PLLM_MISC2, 1565 .iddq_bit_idx = PLLM_IDDQ_BIT, 1566 .max_p = PLL_QLIN_PDIV_MAX, 1567 .ext_misc_reg[0] = PLLM_MISC2, 1568 .ext_misc_reg[0] = PLLM_MISC1, 1569 .round_p_to_pdiv = pll_qlin_p_to_pdiv, 1570 .pdiv_tohw = pll_qlin_pdiv_to_hw, 1571 .div_nmp = &pllm_nmp, 1572 .pmc_divnm_reg = PMC_PLLM_WB0_OVERRIDE, 1573 .pmc_divp_reg = PMC_PLLM_WB0_OVERRIDE_2, 1574 .freq_table = pll_m_freq_table, 1575 .flags = TEGRA_PLL_USE_LOCK | TEGRA_PLL_HAS_LOCK_ENABLE, 1576 .calc_rate = tegra210_pll_fixed_mdiv_cfg, 1577 }; 1578 1579 static struct tegra_clk_pll_params pll_mb_params = { 1580 .input_min = 9600000, 1581 .input_max = 500000000, 1582 .cf_min = 9600000, 1583 .cf_max = 19200000, 1584 .vco_min = 800000000, 1585 .vco_max = 1866000000, 1586 .base_reg = PLLMB_BASE, 1587 .misc_reg = PLLMB_MISC1, 1588 .lock_mask = PLL_BASE_LOCK, 1589 .lock_delay = 300, 1590 .iddq_reg = PLLMB_MISC1, 1591 .iddq_bit_idx = PLLMB_IDDQ_BIT, 1592 .max_p = PLL_QLIN_PDIV_MAX, 1593 .ext_misc_reg[0] = PLLMB_MISC1, 1594 .round_p_to_pdiv = pll_qlin_p_to_pdiv, 1595 .pdiv_tohw = pll_qlin_pdiv_to_hw, 1596 .div_nmp = &pllm_nmp, 1597 .freq_table = pll_m_freq_table, 1598 .flags = TEGRA_PLL_USE_LOCK, 1599 .set_defaults = tegra210_pllmb_set_defaults, 1600 .calc_rate = tegra210_pll_fixed_mdiv_cfg, 1601 }; 1602 1603 1604 static struct tegra_clk_pll_freq_table pll_e_freq_table[] = { 1605 /* PLLE special case: use cpcon field to store cml divider value */ 1606 { 672000000, 100000000, 125, 42, 0, 13 }, 1607 { 624000000, 100000000, 125, 39, 0, 13 }, 1608 { 336000000, 100000000, 125, 21, 0, 13 }, 1609 { 312000000, 100000000, 200, 26, 0, 14 }, 1610 { 38400000, 100000000, 125, 2, 0, 14 }, 1611 { 12000000, 100000000, 200, 1, 0, 14 }, 1612 { 0, 0, 0, 0, 0, 0 }, 1613 }; 1614 1615 static struct div_nmp plle_nmp = { 1616 .divm_shift = 0, 1617 .divm_width = 8, 1618 .divn_shift = 8, 1619 .divn_width = 8, 1620 .divp_shift = 24, 1621 .divp_width = 5, 1622 }; 1623 1624 static struct tegra_clk_pll_params pll_e_params = { 1625 .input_min = 12000000, 1626 .input_max = 800000000, 1627 .cf_min = 12000000, 1628 .cf_max = 38400000, 1629 .vco_min = 1600000000, 1630 .vco_max = 2500000000U, 1631 .base_reg = PLLE_BASE, 1632 .misc_reg = PLLE_MISC0, 1633 .aux_reg = PLLE_AUX, 1634 .lock_mask = PLLE_MISC_LOCK, 1635 .lock_enable_bit_idx = PLLE_MISC_LOCK_ENABLE, 1636 .lock_delay = 300, 1637 .div_nmp = &plle_nmp, 1638 .freq_table = pll_e_freq_table, 1639 .flags = TEGRA_PLL_FIXED | TEGRA_PLL_LOCK_MISC | TEGRA_PLL_USE_LOCK | 1640 TEGRA_PLL_HAS_LOCK_ENABLE, 1641 .fixed_rate = 100000000, 1642 .calc_rate = tegra210_pll_fixed_mdiv_cfg, 1643 }; 1644 1645 static struct tegra_clk_pll_freq_table pll_re_vco_freq_table[] = { 1646 { 12000000, 672000000, 56, 1, 0, 0 }, 1647 { 13000000, 672000000, 51, 1, 0, 0 }, /* actual: 663.0 MHz */ 1648 { 38400000, 672000000, 70, 4, 0, 0 }, 1649 { 0, 0, 0, 0, 0, 0 }, 1650 }; 1651 1652 static struct div_nmp pllre_nmp = { 1653 .divm_shift = 0, 1654 .divm_width = 8, 1655 .divn_shift = 8, 1656 .divn_width = 8, 1657 .divp_shift = 16, 1658 .divp_width = 5, 1659 }; 1660 1661 static struct tegra_clk_pll_params pll_re_vco_params = { 1662 .input_min = 9600000, 1663 .input_max = 800000000, 1664 .cf_min = 9600000, 1665 .cf_max = 19200000, 1666 .vco_min = 350000000, 1667 .vco_max = 700000000, 1668 .base_reg = PLLRE_BASE, 1669 .misc_reg = PLLRE_MISC0, 1670 .lock_mask = PLLRE_MISC_LOCK, 1671 .lock_delay = 300, 1672 .max_p = PLL_QLIN_PDIV_MAX, 1673 .ext_misc_reg[0] = PLLRE_MISC0, 1674 .iddq_reg = PLLRE_MISC0, 1675 .iddq_bit_idx = PLLRE_IDDQ_BIT, 1676 .round_p_to_pdiv = pll_qlin_p_to_pdiv, 1677 .pdiv_tohw = pll_qlin_pdiv_to_hw, 1678 .div_nmp = &pllre_nmp, 1679 .freq_table = pll_re_vco_freq_table, 1680 .flags = TEGRA_PLL_USE_LOCK | TEGRA_PLL_LOCK_MISC | TEGRA_PLL_VCO_OUT, 1681 .set_defaults = tegra210_pllre_set_defaults, 1682 .calc_rate = tegra210_pll_fixed_mdiv_cfg, 1683 }; 1684 1685 static struct div_nmp pllp_nmp = { 1686 .divm_shift = 0, 1687 .divm_width = 8, 1688 .divn_shift = 10, 1689 .divn_width = 8, 1690 .divp_shift = 20, 1691 .divp_width = 5, 1692 }; 1693 1694 static struct tegra_clk_pll_freq_table pll_p_freq_table[] = { 1695 { 12000000, 408000000, 34, 1, 0, 0 }, 1696 { 38400000, 408000000, 85, 8, 0, 0 }, /* cf = 4.8MHz, allowed exception */ 1697 { 0, 0, 0, 0, 0, 0 }, 1698 }; 1699 1700 static struct tegra_clk_pll_params pll_p_params = { 1701 .input_min = 9600000, 1702 .input_max = 800000000, 1703 .cf_min = 9600000, 1704 .cf_max = 19200000, 1705 .vco_min = 350000000, 1706 .vco_max = 700000000, 1707 .base_reg = PLLP_BASE, 1708 .misc_reg = PLLP_MISC0, 1709 .lock_mask = PLL_BASE_LOCK, 1710 .lock_delay = 300, 1711 .iddq_reg = PLLP_MISC0, 1712 .iddq_bit_idx = PLLXP_IDDQ_BIT, 1713 .ext_misc_reg[0] = PLLP_MISC0, 1714 .ext_misc_reg[1] = PLLP_MISC1, 1715 .div_nmp = &pllp_nmp, 1716 .freq_table = pll_p_freq_table, 1717 .fixed_rate = 408000000, 1718 .flags = TEGRA_PLL_FIXED | TEGRA_PLL_USE_LOCK | TEGRA_PLL_VCO_OUT, 1719 .set_defaults = tegra210_pllp_set_defaults, 1720 .calc_rate = tegra210_pll_fixed_mdiv_cfg, 1721 }; 1722 1723 static struct tegra_clk_pll_params pll_a1_params = { 1724 .input_min = 12000000, 1725 .input_max = 700000000, 1726 .cf_min = 12000000, 1727 .cf_max = 50000000, 1728 .vco_min = 600000000, 1729 .vco_max = 1200000000, 1730 .base_reg = PLLA1_BASE, 1731 .misc_reg = PLLA1_MISC0, 1732 .lock_mask = PLLCX_BASE_LOCK, 1733 .lock_delay = 300, 1734 .iddq_reg = PLLA1_MISC0, 1735 .iddq_bit_idx = PLLCX_IDDQ_BIT, 1736 .reset_reg = PLLA1_MISC0, 1737 .reset_bit_idx = PLLCX_RESET_BIT, 1738 .round_p_to_pdiv = pll_qlin_p_to_pdiv, 1739 .pdiv_tohw = pll_qlin_pdiv_to_hw, 1740 .div_nmp = &pllc_nmp, 1741 .ext_misc_reg[0] = PLLA1_MISC0, 1742 .ext_misc_reg[1] = PLLA1_MISC1, 1743 .ext_misc_reg[2] = PLLA1_MISC2, 1744 .ext_misc_reg[3] = PLLA1_MISC3, 1745 .freq_table = pll_cx_freq_table, 1746 .flags = TEGRA_PLL_USE_LOCK, 1747 .set_defaults = _plla1_set_defaults, 1748 .calc_rate = tegra210_pll_fixed_mdiv_cfg, 1749 }; 1750 1751 static struct div_nmp plla_nmp = { 1752 .divm_shift = 0, 1753 .divm_width = 8, 1754 .divn_shift = 8, 1755 .divn_width = 8, 1756 .divp_shift = 20, 1757 .divp_width = 5, 1758 }; 1759 1760 static struct tegra_clk_pll_freq_table pll_a_freq_table[] = { 1761 { 12000000, 282240000, 47, 1, 1, 1, 0xf148 }, /* actual: 282240234 */ 1762 { 12000000, 368640000, 61, 1, 1, 1, 0xfe15 }, /* actual: 368640381 */ 1763 { 12000000, 240000000, 60, 1, 2, 1, 0 }, 1764 { 13000000, 282240000, 43, 1, 1, 1, 0xfd7d }, /* actual: 282239807 */ 1765 { 13000000, 368640000, 56, 1, 1, 1, 0x06d8 }, /* actual: 368640137 */ 1766 { 13000000, 240000000, 55, 1, 2, 1, 0 }, /* actual: 238.3 MHz */ 1767 { 38400000, 282240000, 44, 3, 1, 1, 0xf333 }, /* actual: 282239844 */ 1768 { 38400000, 368640000, 57, 3, 1, 1, 0x0333 }, /* actual: 368639844 */ 1769 { 38400000, 240000000, 75, 3, 3, 1, 0 }, 1770 { 0, 0, 0, 0, 0, 0, 0 }, 1771 }; 1772 1773 static struct tegra_clk_pll_params pll_a_params = { 1774 .input_min = 12000000, 1775 .input_max = 800000000, 1776 .cf_min = 12000000, 1777 .cf_max = 19200000, 1778 .vco_min = 500000000, 1779 .vco_max = 1000000000, 1780 .base_reg = PLLA_BASE, 1781 .misc_reg = PLLA_MISC0, 1782 .lock_mask = PLL_BASE_LOCK, 1783 .lock_delay = 300, 1784 .round_p_to_pdiv = pll_qlin_p_to_pdiv, 1785 .pdiv_tohw = pll_qlin_pdiv_to_hw, 1786 .iddq_reg = PLLA_BASE, 1787 .iddq_bit_idx = PLLA_IDDQ_BIT, 1788 .div_nmp = &plla_nmp, 1789 .sdm_din_reg = PLLA_MISC1, 1790 .sdm_din_mask = PLLA_SDM_DIN_MASK, 1791 .sdm_ctrl_reg = PLLA_MISC2, 1792 .sdm_ctrl_en_mask = PLLA_SDM_EN_MASK, 1793 .ext_misc_reg[0] = PLLA_MISC0, 1794 .ext_misc_reg[1] = PLLA_MISC1, 1795 .ext_misc_reg[2] = PLLA_MISC2, 1796 .freq_table = pll_a_freq_table, 1797 .flags = TEGRA_PLL_USE_LOCK | TEGRA_MDIV_NEW, 1798 .set_defaults = tegra210_plla_set_defaults, 1799 .calc_rate = tegra210_pll_fixed_mdiv_cfg, 1800 .set_gain = tegra210_clk_pll_set_gain, 1801 .adjust_vco = tegra210_clk_adjust_vco_min, 1802 }; 1803 1804 static struct div_nmp plld_nmp = { 1805 .divm_shift = 0, 1806 .divm_width = 8, 1807 .divn_shift = 11, 1808 .divn_width = 8, 1809 .divp_shift = 20, 1810 .divp_width = 3, 1811 }; 1812 1813 static struct tegra_clk_pll_freq_table pll_d_freq_table[] = { 1814 { 12000000, 594000000, 99, 1, 1, 0, 0 }, 1815 { 13000000, 594000000, 91, 1, 1, 0, 0xfc4f }, /* actual: 594000183 */ 1816 { 38400000, 594000000, 30, 1, 1, 0, 0x0e00 }, 1817 { 0, 0, 0, 0, 0, 0, 0 }, 1818 }; 1819 1820 static struct tegra_clk_pll_params pll_d_params = { 1821 .input_min = 12000000, 1822 .input_max = 800000000, 1823 .cf_min = 12000000, 1824 .cf_max = 38400000, 1825 .vco_min = 750000000, 1826 .vco_max = 1500000000, 1827 .base_reg = PLLD_BASE, 1828 .misc_reg = PLLD_MISC0, 1829 .lock_mask = PLL_BASE_LOCK, 1830 .lock_delay = 1000, 1831 .iddq_reg = PLLD_MISC0, 1832 .iddq_bit_idx = PLLD_IDDQ_BIT, 1833 .round_p_to_pdiv = pll_expo_p_to_pdiv, 1834 .pdiv_tohw = pll_expo_pdiv_to_hw, 1835 .div_nmp = &plld_nmp, 1836 .sdm_din_reg = PLLD_MISC0, 1837 .sdm_din_mask = PLLA_SDM_DIN_MASK, 1838 .sdm_ctrl_reg = PLLD_MISC0, 1839 .sdm_ctrl_en_mask = PLLD_SDM_EN_MASK, 1840 .ext_misc_reg[0] = PLLD_MISC0, 1841 .ext_misc_reg[1] = PLLD_MISC1, 1842 .freq_table = pll_d_freq_table, 1843 .flags = TEGRA_PLL_USE_LOCK, 1844 .mdiv_default = 1, 1845 .set_defaults = tegra210_plld_set_defaults, 1846 .calc_rate = tegra210_pll_fixed_mdiv_cfg, 1847 .set_gain = tegra210_clk_pll_set_gain, 1848 .adjust_vco = tegra210_clk_adjust_vco_min, 1849 }; 1850 1851 static struct tegra_clk_pll_freq_table tegra210_pll_d2_freq_table[] = { 1852 { 12000000, 594000000, 99, 1, 1, 0, 0xf000 }, 1853 { 13000000, 594000000, 91, 1, 1, 0, 0xfc4f }, /* actual: 594000183 */ 1854 { 38400000, 594000000, 30, 1, 1, 0, 0x0e00 }, 1855 { 0, 0, 0, 0, 0, 0, 0 }, 1856 }; 1857 1858 /* s/w policy, always tegra_pll_ref */ 1859 static struct tegra_clk_pll_params pll_d2_params = { 1860 .input_min = 12000000, 1861 .input_max = 800000000, 1862 .cf_min = 12000000, 1863 .cf_max = 38400000, 1864 .vco_min = 750000000, 1865 .vco_max = 1500000000, 1866 .base_reg = PLLD2_BASE, 1867 .misc_reg = PLLD2_MISC0, 1868 .lock_mask = PLL_BASE_LOCK, 1869 .lock_delay = 300, 1870 .iddq_reg = PLLD2_BASE, 1871 .iddq_bit_idx = PLLSS_IDDQ_BIT, 1872 .sdm_din_reg = PLLD2_MISC3, 1873 .sdm_din_mask = PLLA_SDM_DIN_MASK, 1874 .sdm_ctrl_reg = PLLD2_MISC1, 1875 .sdm_ctrl_en_mask = PLLD2_SDM_EN_MASK, 1876 .ssc_ctrl_reg = PLLD2_MISC1, 1877 .ssc_ctrl_en_mask = PLLD2_SSC_EN_MASK, 1878 .round_p_to_pdiv = pll_qlin_p_to_pdiv, 1879 .pdiv_tohw = pll_qlin_pdiv_to_hw, 1880 .div_nmp = &pllss_nmp, 1881 .ext_misc_reg[0] = PLLD2_MISC0, 1882 .ext_misc_reg[1] = PLLD2_MISC1, 1883 .ext_misc_reg[2] = PLLD2_MISC2, 1884 .ext_misc_reg[3] = PLLD2_MISC3, 1885 .max_p = PLL_QLIN_PDIV_MAX, 1886 .mdiv_default = 1, 1887 .freq_table = tegra210_pll_d2_freq_table, 1888 .set_defaults = tegra210_plld2_set_defaults, 1889 .flags = TEGRA_PLL_USE_LOCK, 1890 .calc_rate = tegra210_pll_fixed_mdiv_cfg, 1891 .set_gain = tegra210_clk_pll_set_gain, 1892 .adjust_vco = tegra210_clk_adjust_vco_min, 1893 }; 1894 1895 static struct tegra_clk_pll_freq_table pll_dp_freq_table[] = { 1896 { 12000000, 270000000, 90, 1, 3, 0, 0xf000 }, 1897 { 13000000, 270000000, 83, 1, 3, 0, 0xf000 }, /* actual: 269.8 MHz */ 1898 { 38400000, 270000000, 28, 1, 3, 0, 0xf400 }, 1899 { 0, 0, 0, 0, 0, 0, 0 }, 1900 }; 1901 1902 static struct tegra_clk_pll_params pll_dp_params = { 1903 .input_min = 12000000, 1904 .input_max = 800000000, 1905 .cf_min = 12000000, 1906 .cf_max = 38400000, 1907 .vco_min = 750000000, 1908 .vco_max = 1500000000, 1909 .base_reg = PLLDP_BASE, 1910 .misc_reg = PLLDP_MISC, 1911 .lock_mask = PLL_BASE_LOCK, 1912 .lock_delay = 300, 1913 .iddq_reg = PLLDP_BASE, 1914 .iddq_bit_idx = PLLSS_IDDQ_BIT, 1915 .sdm_din_reg = PLLDP_SS_CTRL2, 1916 .sdm_din_mask = PLLA_SDM_DIN_MASK, 1917 .sdm_ctrl_reg = PLLDP_SS_CFG, 1918 .sdm_ctrl_en_mask = PLLDP_SDM_EN_MASK, 1919 .ssc_ctrl_reg = PLLDP_SS_CFG, 1920 .ssc_ctrl_en_mask = PLLDP_SSC_EN_MASK, 1921 .round_p_to_pdiv = pll_qlin_p_to_pdiv, 1922 .pdiv_tohw = pll_qlin_pdiv_to_hw, 1923 .div_nmp = &pllss_nmp, 1924 .ext_misc_reg[0] = PLLDP_MISC, 1925 .ext_misc_reg[1] = PLLDP_SS_CFG, 1926 .ext_misc_reg[2] = PLLDP_SS_CTRL1, 1927 .ext_misc_reg[3] = PLLDP_SS_CTRL2, 1928 .max_p = PLL_QLIN_PDIV_MAX, 1929 .mdiv_default = 1, 1930 .freq_table = pll_dp_freq_table, 1931 .set_defaults = tegra210_plldp_set_defaults, 1932 .flags = TEGRA_PLL_USE_LOCK, 1933 .calc_rate = tegra210_pll_fixed_mdiv_cfg, 1934 .set_gain = tegra210_clk_pll_set_gain, 1935 .adjust_vco = tegra210_clk_adjust_vco_min, 1936 }; 1937 1938 static struct div_nmp pllu_nmp = { 1939 .divm_shift = 0, 1940 .divm_width = 8, 1941 .divn_shift = 8, 1942 .divn_width = 8, 1943 .divp_shift = 16, 1944 .divp_width = 5, 1945 }; 1946 1947 static struct tegra_clk_pll_freq_table pll_u_freq_table[] = { 1948 { 12000000, 480000000, 40, 1, 0, 0 }, 1949 { 13000000, 480000000, 36, 1, 0, 0 }, /* actual: 468.0 MHz */ 1950 { 38400000, 480000000, 25, 2, 0, 0 }, 1951 { 0, 0, 0, 0, 0, 0 }, 1952 }; 1953 1954 static struct tegra_clk_pll_params pll_u_vco_params = { 1955 .input_min = 9600000, 1956 .input_max = 800000000, 1957 .cf_min = 9600000, 1958 .cf_max = 19200000, 1959 .vco_min = 350000000, 1960 .vco_max = 700000000, 1961 .base_reg = PLLU_BASE, 1962 .misc_reg = PLLU_MISC0, 1963 .lock_mask = PLL_BASE_LOCK, 1964 .lock_delay = 1000, 1965 .iddq_reg = PLLU_MISC0, 1966 .iddq_bit_idx = PLLU_IDDQ_BIT, 1967 .ext_misc_reg[0] = PLLU_MISC0, 1968 .ext_misc_reg[1] = PLLU_MISC1, 1969 .round_p_to_pdiv = pll_qlin_p_to_pdiv, 1970 .pdiv_tohw = pll_qlin_pdiv_to_hw, 1971 .div_nmp = &pllu_nmp, 1972 .freq_table = pll_u_freq_table, 1973 .flags = TEGRA_PLLU | TEGRA_PLL_USE_LOCK | TEGRA_PLL_VCO_OUT, 1974 .set_defaults = tegra210_pllu_set_defaults, 1975 .calc_rate = tegra210_pll_fixed_mdiv_cfg, 1976 }; 1977 1978 struct utmi_clk_param { 1979 /* Oscillator Frequency in KHz */ 1980 u32 osc_frequency; 1981 /* UTMIP PLL Enable Delay Count */ 1982 u8 enable_delay_count; 1983 /* UTMIP PLL Stable count */ 1984 u16 stable_count; 1985 /* UTMIP PLL Active delay count */ 1986 u8 active_delay_count; 1987 /* UTMIP PLL Xtal frequency count */ 1988 u16 xtal_freq_count; 1989 }; 1990 1991 static const struct utmi_clk_param utmi_parameters[] = { 1992 { 1993 .osc_frequency = 38400000, .enable_delay_count = 0x0, 1994 .stable_count = 0x0, .active_delay_count = 0x6, 1995 .xtal_freq_count = 0x80 1996 }, { 1997 .osc_frequency = 13000000, .enable_delay_count = 0x02, 1998 .stable_count = 0x33, .active_delay_count = 0x05, 1999 .xtal_freq_count = 0x7f 2000 }, { 2001 .osc_frequency = 19200000, .enable_delay_count = 0x03, 2002 .stable_count = 0x4b, .active_delay_count = 0x06, 2003 .xtal_freq_count = 0xbb 2004 }, { 2005 .osc_frequency = 12000000, .enable_delay_count = 0x02, 2006 .stable_count = 0x2f, .active_delay_count = 0x08, 2007 .xtal_freq_count = 0x76 2008 }, { 2009 .osc_frequency = 26000000, .enable_delay_count = 0x04, 2010 .stable_count = 0x66, .active_delay_count = 0x09, 2011 .xtal_freq_count = 0xfe 2012 }, { 2013 .osc_frequency = 16800000, .enable_delay_count = 0x03, 2014 .stable_count = 0x41, .active_delay_count = 0x0a, 2015 .xtal_freq_count = 0xa4 2016 }, 2017 }; 2018 2019 static struct tegra_clk tegra210_clks[tegra_clk_max] __initdata = { 2020 [tegra_clk_ispb] = { .dt_id = TEGRA210_CLK_ISPB, .present = true }, 2021 [tegra_clk_rtc] = { .dt_id = TEGRA210_CLK_RTC, .present = true }, 2022 [tegra_clk_timer] = { .dt_id = TEGRA210_CLK_TIMER, .present = true }, 2023 [tegra_clk_uarta_8] = { .dt_id = TEGRA210_CLK_UARTA, .present = true }, 2024 [tegra_clk_sdmmc2_9] = { .dt_id = TEGRA210_CLK_SDMMC2, .present = true }, 2025 [tegra_clk_i2s1] = { .dt_id = TEGRA210_CLK_I2S1, .present = true }, 2026 [tegra_clk_i2c1] = { .dt_id = TEGRA210_CLK_I2C1, .present = true }, 2027 [tegra_clk_sdmmc1_9] = { .dt_id = TEGRA210_CLK_SDMMC1, .present = true }, 2028 [tegra_clk_sdmmc4_9] = { .dt_id = TEGRA210_CLK_SDMMC4, .present = true }, 2029 [tegra_clk_pwm] = { .dt_id = TEGRA210_CLK_PWM, .present = true }, 2030 [tegra_clk_i2s2] = { .dt_id = TEGRA210_CLK_I2S2, .present = true }, 2031 [tegra_clk_usbd] = { .dt_id = TEGRA210_CLK_USBD, .present = true }, 2032 [tegra_clk_isp_9] = { .dt_id = TEGRA210_CLK_ISP, .present = true }, 2033 [tegra_clk_disp2_8] = { .dt_id = TEGRA210_CLK_DISP2, .present = true }, 2034 [tegra_clk_disp1_8] = { .dt_id = TEGRA210_CLK_DISP1, .present = true }, 2035 [tegra_clk_host1x_9] = { .dt_id = TEGRA210_CLK_HOST1X, .present = true }, 2036 [tegra_clk_i2s0] = { .dt_id = TEGRA210_CLK_I2S0, .present = true }, 2037 [tegra_clk_apbdma] = { .dt_id = TEGRA210_CLK_APBDMA, .present = true }, 2038 [tegra_clk_kfuse] = { .dt_id = TEGRA210_CLK_KFUSE, .present = true }, 2039 [tegra_clk_sbc1_9] = { .dt_id = TEGRA210_CLK_SBC1, .present = true }, 2040 [tegra_clk_sbc2_9] = { .dt_id = TEGRA210_CLK_SBC2, .present = true }, 2041 [tegra_clk_sbc3_9] = { .dt_id = TEGRA210_CLK_SBC3, .present = true }, 2042 [tegra_clk_i2c5] = { .dt_id = TEGRA210_CLK_I2C5, .present = true }, 2043 [tegra_clk_csi] = { .dt_id = TEGRA210_CLK_CSI, .present = true }, 2044 [tegra_clk_i2c2] = { .dt_id = TEGRA210_CLK_I2C2, .present = true }, 2045 [tegra_clk_uartc_8] = { .dt_id = TEGRA210_CLK_UARTC, .present = true }, 2046 [tegra_clk_mipi_cal] = { .dt_id = TEGRA210_CLK_MIPI_CAL, .present = true }, 2047 [tegra_clk_emc] = { .dt_id = TEGRA210_CLK_EMC, .present = true }, 2048 [tegra_clk_usb2] = { .dt_id = TEGRA210_CLK_USB2, .present = true }, 2049 [tegra_clk_bsev] = { .dt_id = TEGRA210_CLK_BSEV, .present = true }, 2050 [tegra_clk_uartd_8] = { .dt_id = TEGRA210_CLK_UARTD, .present = true }, 2051 [tegra_clk_i2c3] = { .dt_id = TEGRA210_CLK_I2C3, .present = true }, 2052 [tegra_clk_sbc4_9] = { .dt_id = TEGRA210_CLK_SBC4, .present = true }, 2053 [tegra_clk_sdmmc3_9] = { .dt_id = TEGRA210_CLK_SDMMC3, .present = true }, 2054 [tegra_clk_pcie] = { .dt_id = TEGRA210_CLK_PCIE, .present = true }, 2055 [tegra_clk_owr_8] = { .dt_id = TEGRA210_CLK_OWR, .present = true }, 2056 [tegra_clk_afi] = { .dt_id = TEGRA210_CLK_AFI, .present = true }, 2057 [tegra_clk_csite_8] = { .dt_id = TEGRA210_CLK_CSITE, .present = true }, 2058 [tegra_clk_soc_therm_8] = { .dt_id = TEGRA210_CLK_SOC_THERM, .present = true }, 2059 [tegra_clk_dtv] = { .dt_id = TEGRA210_CLK_DTV, .present = true }, 2060 [tegra_clk_i2cslow] = { .dt_id = TEGRA210_CLK_I2CSLOW, .present = true }, 2061 [tegra_clk_tsec_8] = { .dt_id = TEGRA210_CLK_TSEC, .present = true }, 2062 [tegra_clk_xusb_host] = { .dt_id = TEGRA210_CLK_XUSB_HOST, .present = true }, 2063 [tegra_clk_csus] = { .dt_id = TEGRA210_CLK_CSUS, .present = true }, 2064 [tegra_clk_mselect] = { .dt_id = TEGRA210_CLK_MSELECT, .present = true }, 2065 [tegra_clk_tsensor] = { .dt_id = TEGRA210_CLK_TSENSOR, .present = true }, 2066 [tegra_clk_i2s3] = { .dt_id = TEGRA210_CLK_I2S3, .present = true }, 2067 [tegra_clk_i2s4] = { .dt_id = TEGRA210_CLK_I2S4, .present = true }, 2068 [tegra_clk_i2c4] = { .dt_id = TEGRA210_CLK_I2C4, .present = true }, 2069 [tegra_clk_d_audio] = { .dt_id = TEGRA210_CLK_D_AUDIO, .present = true }, 2070 [tegra_clk_hda2codec_2x_8] = { .dt_id = TEGRA210_CLK_HDA2CODEC_2X, .present = true }, 2071 [tegra_clk_spdif_2x] = { .dt_id = TEGRA210_CLK_SPDIF_2X, .present = true }, 2072 [tegra_clk_actmon] = { .dt_id = TEGRA210_CLK_ACTMON, .present = true }, 2073 [tegra_clk_extern1] = { .dt_id = TEGRA210_CLK_EXTERN1, .present = true }, 2074 [tegra_clk_extern2] = { .dt_id = TEGRA210_CLK_EXTERN2, .present = true }, 2075 [tegra_clk_extern3] = { .dt_id = TEGRA210_CLK_EXTERN3, .present = true }, 2076 [tegra_clk_sata_oob_8] = { .dt_id = TEGRA210_CLK_SATA_OOB, .present = true }, 2077 [tegra_clk_sata_8] = { .dt_id = TEGRA210_CLK_SATA, .present = true }, 2078 [tegra_clk_hda_8] = { .dt_id = TEGRA210_CLK_HDA, .present = true }, 2079 [tegra_clk_hda2hdmi] = { .dt_id = TEGRA210_CLK_HDA2HDMI, .present = true }, 2080 [tegra_clk_cilab] = { .dt_id = TEGRA210_CLK_CILAB, .present = true }, 2081 [tegra_clk_cilcd] = { .dt_id = TEGRA210_CLK_CILCD, .present = true }, 2082 [tegra_clk_cile] = { .dt_id = TEGRA210_CLK_CILE, .present = true }, 2083 [tegra_clk_dsialp] = { .dt_id = TEGRA210_CLK_DSIALP, .present = true }, 2084 [tegra_clk_dsiblp] = { .dt_id = TEGRA210_CLK_DSIBLP, .present = true }, 2085 [tegra_clk_entropy_8] = { .dt_id = TEGRA210_CLK_ENTROPY, .present = true }, 2086 [tegra_clk_xusb_ss] = { .dt_id = TEGRA210_CLK_XUSB_SS, .present = true }, 2087 [tegra_clk_i2c6] = { .dt_id = TEGRA210_CLK_I2C6, .present = true }, 2088 [tegra_clk_vim2_clk] = { .dt_id = TEGRA210_CLK_VIM2_CLK, .present = true }, 2089 [tegra_clk_clk72Mhz_8] = { .dt_id = TEGRA210_CLK_CLK72MHZ, .present = true }, 2090 [tegra_clk_vic03_8] = { .dt_id = TEGRA210_CLK_VIC03, .present = true }, 2091 [tegra_clk_dpaux] = { .dt_id = TEGRA210_CLK_DPAUX, .present = true }, 2092 [tegra_clk_sor0] = { .dt_id = TEGRA210_CLK_SOR0, .present = true }, 2093 [tegra_clk_sor0_lvds] = { .dt_id = TEGRA210_CLK_SOR0_LVDS, .present = true }, 2094 [tegra_clk_gpu] = { .dt_id = TEGRA210_CLK_GPU, .present = true }, 2095 [tegra_clk_pll_g_ref] = { .dt_id = TEGRA210_CLK_PLL_G_REF, .present = true, }, 2096 [tegra_clk_uartb_8] = { .dt_id = TEGRA210_CLK_UARTB, .present = true }, 2097 [tegra_clk_vfir] = { .dt_id = TEGRA210_CLK_VFIR, .present = true }, 2098 [tegra_clk_spdif_in_8] = { .dt_id = TEGRA210_CLK_SPDIF_IN, .present = true }, 2099 [tegra_clk_spdif_out] = { .dt_id = TEGRA210_CLK_SPDIF_OUT, .present = true }, 2100 [tegra_clk_vi_10] = { .dt_id = TEGRA210_CLK_VI, .present = true }, 2101 [tegra_clk_vi_sensor_8] = { .dt_id = TEGRA210_CLK_VI_SENSOR, .present = true }, 2102 [tegra_clk_fuse] = { .dt_id = TEGRA210_CLK_FUSE, .present = true }, 2103 [tegra_clk_fuse_burn] = { .dt_id = TEGRA210_CLK_FUSE_BURN, .present = true }, 2104 [tegra_clk_clk_32k] = { .dt_id = TEGRA210_CLK_CLK_32K, .present = true }, 2105 [tegra_clk_clk_m] = { .dt_id = TEGRA210_CLK_CLK_M, .present = true }, 2106 [tegra_clk_clk_m_div2] = { .dt_id = TEGRA210_CLK_CLK_M_DIV2, .present = true }, 2107 [tegra_clk_clk_m_div4] = { .dt_id = TEGRA210_CLK_CLK_M_DIV4, .present = true }, 2108 [tegra_clk_pll_ref] = { .dt_id = TEGRA210_CLK_PLL_REF, .present = true }, 2109 [tegra_clk_pll_c] = { .dt_id = TEGRA210_CLK_PLL_C, .present = true }, 2110 [tegra_clk_pll_c_out1] = { .dt_id = TEGRA210_CLK_PLL_C_OUT1, .present = true }, 2111 [tegra_clk_pll_c2] = { .dt_id = TEGRA210_CLK_PLL_C2, .present = true }, 2112 [tegra_clk_pll_c3] = { .dt_id = TEGRA210_CLK_PLL_C3, .present = true }, 2113 [tegra_clk_pll_m] = { .dt_id = TEGRA210_CLK_PLL_M, .present = true }, 2114 [tegra_clk_pll_m_out1] = { .dt_id = TEGRA210_CLK_PLL_M_OUT1, .present = true }, 2115 [tegra_clk_pll_p] = { .dt_id = TEGRA210_CLK_PLL_P, .present = true }, 2116 [tegra_clk_pll_p_out1] = { .dt_id = TEGRA210_CLK_PLL_P_OUT1, .present = true }, 2117 [tegra_clk_pll_p_out3] = { .dt_id = TEGRA210_CLK_PLL_P_OUT3, .present = true }, 2118 [tegra_clk_pll_p_out4_cpu] = { .dt_id = TEGRA210_CLK_PLL_P_OUT4, .present = true }, 2119 [tegra_clk_pll_p_out_hsio] = { .dt_id = TEGRA210_CLK_PLL_P_OUT_HSIO, .present = true }, 2120 [tegra_clk_pll_p_out_xusb] = { .dt_id = TEGRA210_CLK_PLL_P_OUT_XUSB, .present = true }, 2121 [tegra_clk_pll_p_out_cpu] = { .dt_id = TEGRA210_CLK_PLL_P_OUT_CPU, .present = true }, 2122 [tegra_clk_pll_p_out_adsp] = { .dt_id = TEGRA210_CLK_PLL_P_OUT_ADSP, .present = true }, 2123 [tegra_clk_pll_a] = { .dt_id = TEGRA210_CLK_PLL_A, .present = true }, 2124 [tegra_clk_pll_a_out0] = { .dt_id = TEGRA210_CLK_PLL_A_OUT0, .present = true }, 2125 [tegra_clk_pll_d] = { .dt_id = TEGRA210_CLK_PLL_D, .present = true }, 2126 [tegra_clk_pll_d_out0] = { .dt_id = TEGRA210_CLK_PLL_D_OUT0, .present = true }, 2127 [tegra_clk_pll_d2] = { .dt_id = TEGRA210_CLK_PLL_D2, .present = true }, 2128 [tegra_clk_pll_d2_out0] = { .dt_id = TEGRA210_CLK_PLL_D2_OUT0, .present = true }, 2129 [tegra_clk_pll_u] = { .dt_id = TEGRA210_CLK_PLL_U, .present = true }, 2130 [tegra_clk_pll_u_out] = { .dt_id = TEGRA210_CLK_PLL_U_OUT, .present = true }, 2131 [tegra_clk_pll_u_out1] = { .dt_id = TEGRA210_CLK_PLL_U_OUT1, .present = true }, 2132 [tegra_clk_pll_u_out2] = { .dt_id = TEGRA210_CLK_PLL_U_OUT2, .present = true }, 2133 [tegra_clk_pll_u_480m] = { .dt_id = TEGRA210_CLK_PLL_U_480M, .present = true }, 2134 [tegra_clk_pll_u_60m] = { .dt_id = TEGRA210_CLK_PLL_U_60M, .present = true }, 2135 [tegra_clk_pll_u_48m] = { .dt_id = TEGRA210_CLK_PLL_U_48M, .present = true }, 2136 [tegra_clk_pll_x] = { .dt_id = TEGRA210_CLK_PLL_X, .present = true }, 2137 [tegra_clk_pll_x_out0] = { .dt_id = TEGRA210_CLK_PLL_X_OUT0, .present = true }, 2138 [tegra_clk_pll_re_vco] = { .dt_id = TEGRA210_CLK_PLL_RE_VCO, .present = true }, 2139 [tegra_clk_pll_re_out] = { .dt_id = TEGRA210_CLK_PLL_RE_OUT, .present = true }, 2140 [tegra_clk_spdif_in_sync] = { .dt_id = TEGRA210_CLK_SPDIF_IN_SYNC, .present = true }, 2141 [tegra_clk_i2s0_sync] = { .dt_id = TEGRA210_CLK_I2S0_SYNC, .present = true }, 2142 [tegra_clk_i2s1_sync] = { .dt_id = TEGRA210_CLK_I2S1_SYNC, .present = true }, 2143 [tegra_clk_i2s2_sync] = { .dt_id = TEGRA210_CLK_I2S2_SYNC, .present = true }, 2144 [tegra_clk_i2s3_sync] = { .dt_id = TEGRA210_CLK_I2S3_SYNC, .present = true }, 2145 [tegra_clk_i2s4_sync] = { .dt_id = TEGRA210_CLK_I2S4_SYNC, .present = true }, 2146 [tegra_clk_vimclk_sync] = { .dt_id = TEGRA210_CLK_VIMCLK_SYNC, .present = true }, 2147 [tegra_clk_audio0] = { .dt_id = TEGRA210_CLK_AUDIO0, .present = true }, 2148 [tegra_clk_audio1] = { .dt_id = TEGRA210_CLK_AUDIO1, .present = true }, 2149 [tegra_clk_audio2] = { .dt_id = TEGRA210_CLK_AUDIO2, .present = true }, 2150 [tegra_clk_audio3] = { .dt_id = TEGRA210_CLK_AUDIO3, .present = true }, 2151 [tegra_clk_audio4] = { .dt_id = TEGRA210_CLK_AUDIO4, .present = true }, 2152 [tegra_clk_spdif] = { .dt_id = TEGRA210_CLK_SPDIF, .present = true }, 2153 [tegra_clk_clk_out_1] = { .dt_id = TEGRA210_CLK_CLK_OUT_1, .present = true }, 2154 [tegra_clk_clk_out_2] = { .dt_id = TEGRA210_CLK_CLK_OUT_2, .present = true }, 2155 [tegra_clk_clk_out_3] = { .dt_id = TEGRA210_CLK_CLK_OUT_3, .present = true }, 2156 [tegra_clk_blink] = { .dt_id = TEGRA210_CLK_BLINK, .present = true }, 2157 [tegra_clk_xusb_gate] = { .dt_id = TEGRA210_CLK_XUSB_GATE, .present = true }, 2158 [tegra_clk_xusb_host_src_8] = { .dt_id = TEGRA210_CLK_XUSB_HOST_SRC, .present = true }, 2159 [tegra_clk_xusb_falcon_src_8] = { .dt_id = TEGRA210_CLK_XUSB_FALCON_SRC, .present = true }, 2160 [tegra_clk_xusb_fs_src] = { .dt_id = TEGRA210_CLK_XUSB_FS_SRC, .present = true }, 2161 [tegra_clk_xusb_ss_src_8] = { .dt_id = TEGRA210_CLK_XUSB_SS_SRC, .present = true }, 2162 [tegra_clk_xusb_ss_div2] = { .dt_id = TEGRA210_CLK_XUSB_SS_DIV2, .present = true }, 2163 [tegra_clk_xusb_dev_src_8] = { .dt_id = TEGRA210_CLK_XUSB_DEV_SRC, .present = true }, 2164 [tegra_clk_xusb_dev] = { .dt_id = TEGRA210_CLK_XUSB_DEV, .present = true }, 2165 [tegra_clk_xusb_hs_src_4] = { .dt_id = TEGRA210_CLK_XUSB_HS_SRC, .present = true }, 2166 [tegra_clk_xusb_ssp_src] = { .dt_id = TEGRA210_CLK_XUSB_SSP_SRC, .present = true }, 2167 [tegra_clk_usb2_hsic_trk] = { .dt_id = TEGRA210_CLK_USB2_HSIC_TRK, .present = true }, 2168 [tegra_clk_hsic_trk] = { .dt_id = TEGRA210_CLK_HSIC_TRK, .present = true }, 2169 [tegra_clk_usb2_trk] = { .dt_id = TEGRA210_CLK_USB2_TRK, .present = true }, 2170 [tegra_clk_sclk] = { .dt_id = TEGRA210_CLK_SCLK, .present = true }, 2171 [tegra_clk_sclk_mux] = { .dt_id = TEGRA210_CLK_SCLK_MUX, .present = true }, 2172 [tegra_clk_hclk] = { .dt_id = TEGRA210_CLK_HCLK, .present = true }, 2173 [tegra_clk_pclk] = { .dt_id = TEGRA210_CLK_PCLK, .present = true }, 2174 [tegra_clk_cclk_g] = { .dt_id = TEGRA210_CLK_CCLK_G, .present = true }, 2175 [tegra_clk_cclk_lp] = { .dt_id = TEGRA210_CLK_CCLK_LP, .present = true }, 2176 [tegra_clk_dfll_ref] = { .dt_id = TEGRA210_CLK_DFLL_REF, .present = true }, 2177 [tegra_clk_dfll_soc] = { .dt_id = TEGRA210_CLK_DFLL_SOC, .present = true }, 2178 [tegra_clk_vi_sensor2_8] = { .dt_id = TEGRA210_CLK_VI_SENSOR2, .present = true }, 2179 [tegra_clk_pll_p_out5] = { .dt_id = TEGRA210_CLK_PLL_P_OUT5, .present = true }, 2180 [tegra_clk_pll_c4] = { .dt_id = TEGRA210_CLK_PLL_C4, .present = true }, 2181 [tegra_clk_pll_dp] = { .dt_id = TEGRA210_CLK_PLL_DP, .present = true }, 2182 [tegra_clk_audio0_mux] = { .dt_id = TEGRA210_CLK_AUDIO0_MUX, .present = true }, 2183 [tegra_clk_audio1_mux] = { .dt_id = TEGRA210_CLK_AUDIO1_MUX, .present = true }, 2184 [tegra_clk_audio2_mux] = { .dt_id = TEGRA210_CLK_AUDIO2_MUX, .present = true }, 2185 [tegra_clk_audio3_mux] = { .dt_id = TEGRA210_CLK_AUDIO3_MUX, .present = true }, 2186 [tegra_clk_audio4_mux] = { .dt_id = TEGRA210_CLK_AUDIO4_MUX, .present = true }, 2187 [tegra_clk_spdif_mux] = { .dt_id = TEGRA210_CLK_SPDIF_MUX, .present = true }, 2188 [tegra_clk_clk_out_1_mux] = { .dt_id = TEGRA210_CLK_CLK_OUT_1_MUX, .present = true }, 2189 [tegra_clk_clk_out_2_mux] = { .dt_id = TEGRA210_CLK_CLK_OUT_2_MUX, .present = true }, 2190 [tegra_clk_clk_out_3_mux] = { .dt_id = TEGRA210_CLK_CLK_OUT_3_MUX, .present = true }, 2191 [tegra_clk_maud] = { .dt_id = TEGRA210_CLK_MAUD, .present = true }, 2192 [tegra_clk_mipibif] = { .dt_id = TEGRA210_CLK_MIPIBIF, .present = true }, 2193 [tegra_clk_qspi] = { .dt_id = TEGRA210_CLK_QSPI, .present = true }, 2194 [tegra_clk_sdmmc_legacy] = { .dt_id = TEGRA210_CLK_SDMMC_LEGACY, .present = true }, 2195 [tegra_clk_tsecb] = { .dt_id = TEGRA210_CLK_TSECB, .present = true }, 2196 [tegra_clk_uartape] = { .dt_id = TEGRA210_CLK_UARTAPE, .present = true }, 2197 [tegra_clk_vi_i2c] = { .dt_id = TEGRA210_CLK_VI_I2C, .present = true }, 2198 [tegra_clk_ape] = { .dt_id = TEGRA210_CLK_APE, .present = true }, 2199 [tegra_clk_dbgapb] = { .dt_id = TEGRA210_CLK_DBGAPB, .present = true }, 2200 [tegra_clk_nvdec] = { .dt_id = TEGRA210_CLK_NVDEC, .present = true }, 2201 [tegra_clk_nvenc] = { .dt_id = TEGRA210_CLK_NVENC, .present = true }, 2202 [tegra_clk_nvjpg] = { .dt_id = TEGRA210_CLK_NVJPG, .present = true }, 2203 [tegra_clk_pll_c4_out0] = { .dt_id = TEGRA210_CLK_PLL_C4_OUT0, .present = true }, 2204 [tegra_clk_pll_c4_out1] = { .dt_id = TEGRA210_CLK_PLL_C4_OUT1, .present = true }, 2205 [tegra_clk_pll_c4_out2] = { .dt_id = TEGRA210_CLK_PLL_C4_OUT2, .present = true }, 2206 [tegra_clk_pll_c4_out3] = { .dt_id = TEGRA210_CLK_PLL_C4_OUT3, .present = true }, 2207 }; 2208 2209 static struct tegra_devclk devclks[] __initdata = { 2210 { .con_id = "clk_m", .dt_id = TEGRA210_CLK_CLK_M }, 2211 { .con_id = "pll_ref", .dt_id = TEGRA210_CLK_PLL_REF }, 2212 { .con_id = "clk_32k", .dt_id = TEGRA210_CLK_CLK_32K }, 2213 { .con_id = "clk_m_div2", .dt_id = TEGRA210_CLK_CLK_M_DIV2 }, 2214 { .con_id = "clk_m_div4", .dt_id = TEGRA210_CLK_CLK_M_DIV4 }, 2215 { .con_id = "pll_c", .dt_id = TEGRA210_CLK_PLL_C }, 2216 { .con_id = "pll_c_out1", .dt_id = TEGRA210_CLK_PLL_C_OUT1 }, 2217 { .con_id = "pll_c2", .dt_id = TEGRA210_CLK_PLL_C2 }, 2218 { .con_id = "pll_c3", .dt_id = TEGRA210_CLK_PLL_C3 }, 2219 { .con_id = "pll_p", .dt_id = TEGRA210_CLK_PLL_P }, 2220 { .con_id = "pll_p_out1", .dt_id = TEGRA210_CLK_PLL_P_OUT1 }, 2221 { .con_id = "pll_p_out2", .dt_id = TEGRA210_CLK_PLL_P_OUT2 }, 2222 { .con_id = "pll_p_out3", .dt_id = TEGRA210_CLK_PLL_P_OUT3 }, 2223 { .con_id = "pll_p_out4", .dt_id = TEGRA210_CLK_PLL_P_OUT4 }, 2224 { .con_id = "pll_m", .dt_id = TEGRA210_CLK_PLL_M }, 2225 { .con_id = "pll_m_out1", .dt_id = TEGRA210_CLK_PLL_M_OUT1 }, 2226 { .con_id = "pll_x", .dt_id = TEGRA210_CLK_PLL_X }, 2227 { .con_id = "pll_x_out0", .dt_id = TEGRA210_CLK_PLL_X_OUT0 }, 2228 { .con_id = "pll_u", .dt_id = TEGRA210_CLK_PLL_U }, 2229 { .con_id = "pll_u_out", .dt_id = TEGRA210_CLK_PLL_U_OUT }, 2230 { .con_id = "pll_u_out1", .dt_id = TEGRA210_CLK_PLL_U_OUT1 }, 2231 { .con_id = "pll_u_out2", .dt_id = TEGRA210_CLK_PLL_U_OUT2 }, 2232 { .con_id = "pll_u_480M", .dt_id = TEGRA210_CLK_PLL_U_480M }, 2233 { .con_id = "pll_u_60M", .dt_id = TEGRA210_CLK_PLL_U_60M }, 2234 { .con_id = "pll_u_48M", .dt_id = TEGRA210_CLK_PLL_U_48M }, 2235 { .con_id = "pll_d", .dt_id = TEGRA210_CLK_PLL_D }, 2236 { .con_id = "pll_d_out0", .dt_id = TEGRA210_CLK_PLL_D_OUT0 }, 2237 { .con_id = "pll_d2", .dt_id = TEGRA210_CLK_PLL_D2 }, 2238 { .con_id = "pll_d2_out0", .dt_id = TEGRA210_CLK_PLL_D2_OUT0 }, 2239 { .con_id = "pll_a", .dt_id = TEGRA210_CLK_PLL_A }, 2240 { .con_id = "pll_a_out0", .dt_id = TEGRA210_CLK_PLL_A_OUT0 }, 2241 { .con_id = "pll_re_vco", .dt_id = TEGRA210_CLK_PLL_RE_VCO }, 2242 { .con_id = "pll_re_out", .dt_id = TEGRA210_CLK_PLL_RE_OUT }, 2243 { .con_id = "spdif_in_sync", .dt_id = TEGRA210_CLK_SPDIF_IN_SYNC }, 2244 { .con_id = "i2s0_sync", .dt_id = TEGRA210_CLK_I2S0_SYNC }, 2245 { .con_id = "i2s1_sync", .dt_id = TEGRA210_CLK_I2S1_SYNC }, 2246 { .con_id = "i2s2_sync", .dt_id = TEGRA210_CLK_I2S2_SYNC }, 2247 { .con_id = "i2s3_sync", .dt_id = TEGRA210_CLK_I2S3_SYNC }, 2248 { .con_id = "i2s4_sync", .dt_id = TEGRA210_CLK_I2S4_SYNC }, 2249 { .con_id = "vimclk_sync", .dt_id = TEGRA210_CLK_VIMCLK_SYNC }, 2250 { .con_id = "audio0", .dt_id = TEGRA210_CLK_AUDIO0 }, 2251 { .con_id = "audio1", .dt_id = TEGRA210_CLK_AUDIO1 }, 2252 { .con_id = "audio2", .dt_id = TEGRA210_CLK_AUDIO2 }, 2253 { .con_id = "audio3", .dt_id = TEGRA210_CLK_AUDIO3 }, 2254 { .con_id = "audio4", .dt_id = TEGRA210_CLK_AUDIO4 }, 2255 { .con_id = "spdif", .dt_id = TEGRA210_CLK_SPDIF }, 2256 { .con_id = "spdif_2x", .dt_id = TEGRA210_CLK_SPDIF_2X }, 2257 { .con_id = "extern1", .dev_id = "clk_out_1", .dt_id = TEGRA210_CLK_EXTERN1 }, 2258 { .con_id = "extern2", .dev_id = "clk_out_2", .dt_id = TEGRA210_CLK_EXTERN2 }, 2259 { .con_id = "extern3", .dev_id = "clk_out_3", .dt_id = TEGRA210_CLK_EXTERN3 }, 2260 { .con_id = "blink", .dt_id = TEGRA210_CLK_BLINK }, 2261 { .con_id = "cclk_g", .dt_id = TEGRA210_CLK_CCLK_G }, 2262 { .con_id = "cclk_lp", .dt_id = TEGRA210_CLK_CCLK_LP }, 2263 { .con_id = "sclk", .dt_id = TEGRA210_CLK_SCLK }, 2264 { .con_id = "hclk", .dt_id = TEGRA210_CLK_HCLK }, 2265 { .con_id = "pclk", .dt_id = TEGRA210_CLK_PCLK }, 2266 { .con_id = "fuse", .dt_id = TEGRA210_CLK_FUSE }, 2267 { .dev_id = "rtc-tegra", .dt_id = TEGRA210_CLK_RTC }, 2268 { .dev_id = "timer", .dt_id = TEGRA210_CLK_TIMER }, 2269 { .con_id = "pll_c4_out0", .dt_id = TEGRA210_CLK_PLL_C4_OUT0 }, 2270 { .con_id = "pll_c4_out1", .dt_id = TEGRA210_CLK_PLL_C4_OUT1 }, 2271 { .con_id = "pll_c4_out2", .dt_id = TEGRA210_CLK_PLL_C4_OUT2 }, 2272 { .con_id = "pll_c4_out3", .dt_id = TEGRA210_CLK_PLL_C4_OUT3 }, 2273 { .con_id = "dpaux", .dt_id = TEGRA210_CLK_DPAUX }, 2274 { .con_id = "sor0", .dt_id = TEGRA210_CLK_SOR0 }, 2275 }; 2276 2277 static struct tegra_audio_clk_info tegra210_audio_plls[] = { 2278 { "pll_a", &pll_a_params, tegra_clk_pll_a, "pll_ref" }, 2279 { "pll_a1", &pll_a1_params, tegra_clk_pll_a1, "pll_ref" }, 2280 }; 2281 2282 static struct clk **clks; 2283 2284 static void tegra210_utmi_param_configure(void __iomem *clk_base) 2285 { 2286 u32 reg; 2287 int i; 2288 2289 for (i = 0; i < ARRAY_SIZE(utmi_parameters); i++) { 2290 if (osc_freq == utmi_parameters[i].osc_frequency) 2291 break; 2292 } 2293 2294 if (i >= ARRAY_SIZE(utmi_parameters)) { 2295 pr_err("%s: Unexpected oscillator freq %lu\n", __func__, 2296 osc_freq); 2297 return; 2298 } 2299 2300 reg = readl_relaxed(clk_base + PLLU_HW_PWRDN_CFG0); 2301 reg |= PLLU_HW_PWRDN_CFG0_IDDQ_PD_INCLUDE | 2302 PLLU_HW_PWRDN_CFG0_USE_SWITCH_DETECT | 2303 PLLU_HW_PWRDN_CFG0_USE_LOCKDET; 2304 reg &= ~(PLLU_HW_PWRDN_CFG0_CLK_ENABLE_SWCTL | 2305 PLLU_HW_PWRDN_CFG0_CLK_SWITCH_SWCTL); 2306 writel_relaxed(reg, clk_base + PLLU_HW_PWRDN_CFG0); 2307 2308 reg = readl_relaxed(clk_base + PLLU_HW_PWRDN_CFG0); 2309 reg |= PLLU_HW_PWRDN_CFG0_SEQ_ENABLE; 2310 writel_relaxed(reg, clk_base + PLLU_HW_PWRDN_CFG0); 2311 udelay(1); 2312 2313 reg = readl_relaxed(clk_base + PLLU_BASE); 2314 reg &= ~PLLU_BASE_CLKENABLE_USB; 2315 writel_relaxed(reg, clk_base + PLLU_BASE); 2316 2317 reg = readl_relaxed(clk_base + UTMIPLL_HW_PWRDN_CFG0); 2318 reg &= ~UTMIPLL_HW_PWRDN_CFG0_IDDQ_OVERRIDE; 2319 writel_relaxed(reg, clk_base + UTMIPLL_HW_PWRDN_CFG0); 2320 2321 udelay(10); 2322 2323 reg = readl_relaxed(clk_base + UTMIP_PLL_CFG2); 2324 2325 /* Program UTMIP PLL stable and active counts */ 2326 /* [FIXME] arclk_rst.h says WRONG! This should be 1ms -> 0x50 Check! */ 2327 reg &= ~UTMIP_PLL_CFG2_STABLE_COUNT(~0); 2328 reg |= UTMIP_PLL_CFG2_STABLE_COUNT(utmi_parameters[i].stable_count); 2329 2330 reg &= ~UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(~0); 2331 2332 reg |= UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(utmi_parameters[i]. 2333 active_delay_count); 2334 writel_relaxed(reg, clk_base + UTMIP_PLL_CFG2); 2335 2336 /* Program UTMIP PLL delay and oscillator frequency counts */ 2337 reg = readl_relaxed(clk_base + UTMIP_PLL_CFG1); 2338 reg &= ~UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(~0); 2339 2340 reg |= UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(utmi_parameters[i]. 2341 enable_delay_count); 2342 2343 reg &= ~UTMIP_PLL_CFG1_XTAL_FREQ_COUNT(~0); 2344 reg |= UTMIP_PLL_CFG1_XTAL_FREQ_COUNT(utmi_parameters[i]. 2345 xtal_freq_count); 2346 2347 reg |= UTMIP_PLL_CFG1_FORCE_PLLU_POWERDOWN; 2348 writel_relaxed(reg, clk_base + UTMIP_PLL_CFG1); 2349 2350 /* Remove power downs from UTMIP PLL control bits */ 2351 reg = readl_relaxed(clk_base + UTMIP_PLL_CFG1); 2352 reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERDOWN; 2353 reg |= UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERUP; 2354 writel_relaxed(reg, clk_base + UTMIP_PLL_CFG1); 2355 udelay(1); 2356 2357 /* Enable samplers for SNPS, XUSB_HOST, XUSB_DEV */ 2358 reg = readl_relaxed(clk_base + UTMIP_PLL_CFG2); 2359 reg |= UTMIP_PLL_CFG2_FORCE_PD_SAMP_A_POWERUP; 2360 reg |= UTMIP_PLL_CFG2_FORCE_PD_SAMP_B_POWERUP; 2361 reg |= UTMIP_PLL_CFG2_FORCE_PD_SAMP_D_POWERUP; 2362 reg &= ~UTMIP_PLL_CFG2_FORCE_PD_SAMP_A_POWERDOWN; 2363 reg &= ~UTMIP_PLL_CFG2_FORCE_PD_SAMP_B_POWERDOWN; 2364 reg &= ~UTMIP_PLL_CFG2_FORCE_PD_SAMP_D_POWERDOWN; 2365 writel_relaxed(reg, clk_base + UTMIP_PLL_CFG2); 2366 2367 /* Setup HW control of UTMIPLL */ 2368 reg = readl_relaxed(clk_base + UTMIP_PLL_CFG1); 2369 reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERDOWN; 2370 reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERUP; 2371 writel_relaxed(reg, clk_base + UTMIP_PLL_CFG1); 2372 2373 reg = readl_relaxed(clk_base + UTMIPLL_HW_PWRDN_CFG0); 2374 reg |= UTMIPLL_HW_PWRDN_CFG0_USE_LOCKDET; 2375 reg &= ~UTMIPLL_HW_PWRDN_CFG0_CLK_ENABLE_SWCTL; 2376 writel_relaxed(reg, clk_base + UTMIPLL_HW_PWRDN_CFG0); 2377 2378 udelay(1); 2379 2380 reg = readl_relaxed(clk_base + XUSB_PLL_CFG0); 2381 reg &= ~XUSB_PLL_CFG0_UTMIPLL_LOCK_DLY; 2382 writel_relaxed(reg, clk_base + XUSB_PLL_CFG0); 2383 2384 udelay(1); 2385 2386 /* Enable HW control UTMIPLL */ 2387 reg = readl_relaxed(clk_base + UTMIPLL_HW_PWRDN_CFG0); 2388 reg |= UTMIPLL_HW_PWRDN_CFG0_SEQ_ENABLE; 2389 writel_relaxed(reg, clk_base + UTMIPLL_HW_PWRDN_CFG0); 2390 } 2391 2392 static __init void tegra210_periph_clk_init(void __iomem *clk_base, 2393 void __iomem *pmc_base) 2394 { 2395 struct clk *clk; 2396 2397 /* xusb_ss_div2 */ 2398 clk = clk_register_fixed_factor(NULL, "xusb_ss_div2", "xusb_ss_src", 0, 2399 1, 2); 2400 clks[TEGRA210_CLK_XUSB_SS_DIV2] = clk; 2401 2402 /* pll_d_dsi_out */ 2403 clk = clk_register_gate(NULL, "pll_d_dsi_out", "pll_d_out0", 0, 2404 clk_base + PLLD_MISC0, 21, 0, &pll_d_lock); 2405 clks[TEGRA210_CLK_PLL_D_DSI_OUT] = clk; 2406 2407 /* dsia */ 2408 clk = tegra_clk_register_periph_gate("dsia", "pll_d_dsi_out", 0, 2409 clk_base, 0, 48, 2410 periph_clk_enb_refcnt); 2411 clks[TEGRA210_CLK_DSIA] = clk; 2412 2413 /* dsib */ 2414 clk = tegra_clk_register_periph_gate("dsib", "pll_d_dsi_out", 0, 2415 clk_base, 0, 82, 2416 periph_clk_enb_refcnt); 2417 clks[TEGRA210_CLK_DSIB] = clk; 2418 2419 /* emc mux */ 2420 clk = clk_register_mux(NULL, "emc_mux", mux_pllmcp_clkm, 2421 ARRAY_SIZE(mux_pllmcp_clkm), 0, 2422 clk_base + CLK_SOURCE_EMC, 2423 29, 3, 0, &emc_lock); 2424 2425 clk = tegra_clk_register_mc("mc", "emc_mux", clk_base + CLK_SOURCE_EMC, 2426 &emc_lock); 2427 clks[TEGRA210_CLK_MC] = clk; 2428 2429 /* cml0 */ 2430 clk = clk_register_gate(NULL, "cml0", "pll_e", 0, clk_base + PLLE_AUX, 2431 0, 0, &pll_e_lock); 2432 clk_register_clkdev(clk, "cml0", NULL); 2433 clks[TEGRA210_CLK_CML0] = clk; 2434 2435 /* cml1 */ 2436 clk = clk_register_gate(NULL, "cml1", "pll_e", 0, clk_base + PLLE_AUX, 2437 1, 0, &pll_e_lock); 2438 clk_register_clkdev(clk, "cml1", NULL); 2439 clks[TEGRA210_CLK_CML1] = clk; 2440 2441 tegra_periph_clk_init(clk_base, pmc_base, tegra210_clks, &pll_p_params); 2442 } 2443 2444 static void __init tegra210_pll_init(void __iomem *clk_base, 2445 void __iomem *pmc) 2446 { 2447 u32 val; 2448 struct clk *clk; 2449 2450 /* PLLC */ 2451 clk = tegra_clk_register_pllxc_tegra210("pll_c", "pll_ref", clk_base, 2452 pmc, 0, &pll_c_params, NULL); 2453 if (!WARN_ON(IS_ERR(clk))) 2454 clk_register_clkdev(clk, "pll_c", NULL); 2455 clks[TEGRA210_CLK_PLL_C] = clk; 2456 2457 /* PLLC_OUT1 */ 2458 clk = tegra_clk_register_divider("pll_c_out1_div", "pll_c", 2459 clk_base + PLLC_OUT, 0, TEGRA_DIVIDER_ROUND_UP, 2460 8, 8, 1, NULL); 2461 clk = tegra_clk_register_pll_out("pll_c_out1", "pll_c_out1_div", 2462 clk_base + PLLC_OUT, 1, 0, 2463 CLK_SET_RATE_PARENT, 0, NULL); 2464 clk_register_clkdev(clk, "pll_c_out1", NULL); 2465 clks[TEGRA210_CLK_PLL_C_OUT1] = clk; 2466 2467 /* PLLC_UD */ 2468 clk = clk_register_fixed_factor(NULL, "pll_c_ud", "pll_c", 2469 CLK_SET_RATE_PARENT, 1, 1); 2470 clk_register_clkdev(clk, "pll_c_ud", NULL); 2471 clks[TEGRA210_CLK_PLL_C_UD] = clk; 2472 2473 /* PLLC2 */ 2474 clk = tegra_clk_register_pllc_tegra210("pll_c2", "pll_ref", clk_base, 2475 pmc, 0, &pll_c2_params, NULL); 2476 clk_register_clkdev(clk, "pll_c2", NULL); 2477 clks[TEGRA210_CLK_PLL_C2] = clk; 2478 2479 /* PLLC3 */ 2480 clk = tegra_clk_register_pllc_tegra210("pll_c3", "pll_ref", clk_base, 2481 pmc, 0, &pll_c3_params, NULL); 2482 clk_register_clkdev(clk, "pll_c3", NULL); 2483 clks[TEGRA210_CLK_PLL_C3] = clk; 2484 2485 /* PLLM */ 2486 clk = tegra_clk_register_pllm("pll_m", "osc", clk_base, pmc, 2487 CLK_SET_RATE_GATE, &pll_m_params, NULL); 2488 clk_register_clkdev(clk, "pll_m", NULL); 2489 clks[TEGRA210_CLK_PLL_M] = clk; 2490 2491 /* PLLMB */ 2492 clk = tegra_clk_register_pllmb("pll_mb", "osc", clk_base, pmc, 2493 CLK_SET_RATE_GATE, &pll_mb_params, NULL); 2494 clk_register_clkdev(clk, "pll_mb", NULL); 2495 clks[TEGRA210_CLK_PLL_MB] = clk; 2496 2497 clk_register_clkdev(clk, "pll_m_out1", NULL); 2498 clks[TEGRA210_CLK_PLL_M_OUT1] = clk; 2499 2500 /* PLLM_UD */ 2501 clk = clk_register_fixed_factor(NULL, "pll_m_ud", "pll_m", 2502 CLK_SET_RATE_PARENT, 1, 1); 2503 clk_register_clkdev(clk, "pll_m_ud", NULL); 2504 clks[TEGRA210_CLK_PLL_M_UD] = clk; 2505 2506 /* PLLU_VCO */ 2507 val = readl(clk_base + pll_u_vco_params.base_reg); 2508 val &= ~BIT(24); /* disable PLLU_OVERRIDE */ 2509 writel(val, clk_base + pll_u_vco_params.base_reg); 2510 2511 clk = tegra_clk_register_pllre("pll_u_vco", "pll_ref", clk_base, pmc, 2512 0, &pll_u_vco_params, &pll_u_lock, pll_ref_freq); 2513 clk_register_clkdev(clk, "pll_u_vco", NULL); 2514 clks[TEGRA210_CLK_PLL_U] = clk; 2515 2516 /* PLLU_OUT */ 2517 clk = clk_register_divider_table(NULL, "pll_u_out", "pll_u_vco", 0, 2518 clk_base + PLLU_BASE, 16, 4, 0, 2519 pll_vco_post_div_table, NULL); 2520 clk_register_clkdev(clk, "pll_u_out", NULL); 2521 clks[TEGRA210_CLK_PLL_U_OUT] = clk; 2522 2523 /* PLLU_OUT1 */ 2524 clk = tegra_clk_register_divider("pll_u_out1_div", "pll_u_out", 2525 clk_base + PLLU_OUTA, 0, 2526 TEGRA_DIVIDER_ROUND_UP, 2527 8, 8, 1, &pll_u_lock); 2528 clk = tegra_clk_register_pll_out("pll_u_out1", "pll_u_out1_div", 2529 clk_base + PLLU_OUTA, 1, 0, 2530 CLK_SET_RATE_PARENT, 0, &pll_u_lock); 2531 clk_register_clkdev(clk, "pll_u_out1", NULL); 2532 clks[TEGRA210_CLK_PLL_U_OUT1] = clk; 2533 2534 /* PLLU_OUT2 */ 2535 clk = tegra_clk_register_divider("pll_u_out2_div", "pll_u_out", 2536 clk_base + PLLU_OUTA, 0, 2537 TEGRA_DIVIDER_ROUND_UP, 2538 24, 8, 1, &pll_u_lock); 2539 clk = tegra_clk_register_pll_out("pll_u_out2", "pll_u_out2_div", 2540 clk_base + PLLU_OUTA, 17, 16, 2541 CLK_SET_RATE_PARENT, 0, &pll_u_lock); 2542 clk_register_clkdev(clk, "pll_u_out2", NULL); 2543 clks[TEGRA210_CLK_PLL_U_OUT2] = clk; 2544 2545 tegra210_utmi_param_configure(clk_base); 2546 2547 /* PLLU_480M */ 2548 clk = clk_register_gate(NULL, "pll_u_480M", "pll_u_vco", 2549 CLK_SET_RATE_PARENT, clk_base + PLLU_BASE, 2550 22, 0, &pll_u_lock); 2551 clk_register_clkdev(clk, "pll_u_480M", NULL); 2552 clks[TEGRA210_CLK_PLL_U_480M] = clk; 2553 2554 /* PLLU_60M */ 2555 clk = clk_register_gate(NULL, "pll_u_60M", "pll_u_out2", 2556 CLK_SET_RATE_PARENT, clk_base + PLLU_BASE, 2557 23, 0, NULL); 2558 clk_register_clkdev(clk, "pll_u_60M", NULL); 2559 clks[TEGRA210_CLK_PLL_U_60M] = clk; 2560 2561 /* PLLU_48M */ 2562 clk = clk_register_gate(NULL, "pll_u_48M", "pll_u_out1", 2563 CLK_SET_RATE_PARENT, clk_base + PLLU_BASE, 2564 25, 0, NULL); 2565 clk_register_clkdev(clk, "pll_u_48M", NULL); 2566 clks[TEGRA210_CLK_PLL_U_48M] = clk; 2567 2568 /* PLLD */ 2569 clk = tegra_clk_register_pll("pll_d", "pll_ref", clk_base, pmc, 0, 2570 &pll_d_params, &pll_d_lock); 2571 clk_register_clkdev(clk, "pll_d", NULL); 2572 clks[TEGRA210_CLK_PLL_D] = clk; 2573 2574 /* PLLD_OUT0 */ 2575 clk = clk_register_fixed_factor(NULL, "pll_d_out0", "pll_d", 2576 CLK_SET_RATE_PARENT, 1, 2); 2577 clk_register_clkdev(clk, "pll_d_out0", NULL); 2578 clks[TEGRA210_CLK_PLL_D_OUT0] = clk; 2579 2580 /* PLLRE */ 2581 clk = tegra_clk_register_pllre("pll_re_vco", "pll_ref", clk_base, pmc, 2582 0, &pll_re_vco_params, &pll_re_lock, pll_ref_freq); 2583 clk_register_clkdev(clk, "pll_re_vco", NULL); 2584 clks[TEGRA210_CLK_PLL_RE_VCO] = clk; 2585 2586 clk = clk_register_divider_table(NULL, "pll_re_out", "pll_re_vco", 0, 2587 clk_base + PLLRE_BASE, 16, 5, 0, 2588 pll_vco_post_div_table, &pll_re_lock); 2589 clk_register_clkdev(clk, "pll_re_out", NULL); 2590 clks[TEGRA210_CLK_PLL_RE_OUT] = clk; 2591 2592 /* PLLE */ 2593 clk = tegra_clk_register_plle_tegra210("pll_e", "pll_ref", 2594 clk_base, 0, &pll_e_params, NULL); 2595 clk_register_clkdev(clk, "pll_e", NULL); 2596 clks[TEGRA210_CLK_PLL_E] = clk; 2597 2598 /* PLLC4 */ 2599 clk = tegra_clk_register_pllre("pll_c4_vco", "pll_ref", clk_base, pmc, 2600 0, &pll_c4_vco_params, NULL, pll_ref_freq); 2601 clk_register_clkdev(clk, "pll_c4_vco", NULL); 2602 clks[TEGRA210_CLK_PLL_C4] = clk; 2603 2604 /* PLLC4_OUT0 */ 2605 clk = clk_register_divider_table(NULL, "pll_c4_out0", "pll_c4_vco", 0, 2606 clk_base + PLLC4_BASE, 19, 4, 0, 2607 pll_vco_post_div_table, NULL); 2608 clk_register_clkdev(clk, "pll_c4_out0", NULL); 2609 clks[TEGRA210_CLK_PLL_C4_OUT0] = clk; 2610 2611 /* PLLC4_OUT1 */ 2612 clk = clk_register_fixed_factor(NULL, "pll_c4_out1", "pll_c4_vco", 2613 CLK_SET_RATE_PARENT, 1, 3); 2614 clk_register_clkdev(clk, "pll_c4_out1", NULL); 2615 clks[TEGRA210_CLK_PLL_C4_OUT1] = clk; 2616 2617 /* PLLC4_OUT2 */ 2618 clk = clk_register_fixed_factor(NULL, "pll_c4_out2", "pll_c4_vco", 2619 CLK_SET_RATE_PARENT, 1, 5); 2620 clk_register_clkdev(clk, "pll_c4_out2", NULL); 2621 clks[TEGRA210_CLK_PLL_C4_OUT2] = clk; 2622 2623 /* PLLC4_OUT3 */ 2624 clk = tegra_clk_register_divider("pll_c4_out3_div", "pll_c4_out0", 2625 clk_base + PLLC4_OUT, 0, TEGRA_DIVIDER_ROUND_UP, 2626 8, 8, 1, NULL); 2627 clk = tegra_clk_register_pll_out("pll_c4_out3", "pll_c4_out3_div", 2628 clk_base + PLLC4_OUT, 1, 0, 2629 CLK_SET_RATE_PARENT, 0, NULL); 2630 clk_register_clkdev(clk, "pll_c4_out3", NULL); 2631 clks[TEGRA210_CLK_PLL_C4_OUT3] = clk; 2632 2633 /* PLLDP */ 2634 clk = tegra_clk_register_pllss_tegra210("pll_dp", "pll_ref", clk_base, 2635 0, &pll_dp_params, NULL); 2636 clk_register_clkdev(clk, "pll_dp", NULL); 2637 clks[TEGRA210_CLK_PLL_DP] = clk; 2638 2639 /* PLLD2 */ 2640 clk = tegra_clk_register_pllss_tegra210("pll_d2", "pll_ref", clk_base, 2641 0, &pll_d2_params, NULL); 2642 clk_register_clkdev(clk, "pll_d2", NULL); 2643 clks[TEGRA210_CLK_PLL_D2] = clk; 2644 2645 /* PLLD2_OUT0 */ 2646 clk = clk_register_fixed_factor(NULL, "pll_d2_out0", "pll_d2", 2647 CLK_SET_RATE_PARENT, 1, 1); 2648 clk_register_clkdev(clk, "pll_d2_out0", NULL); 2649 clks[TEGRA210_CLK_PLL_D2_OUT0] = clk; 2650 2651 /* PLLP_OUT2 */ 2652 clk = clk_register_fixed_factor(NULL, "pll_p_out2", "pll_p", 2653 CLK_SET_RATE_PARENT, 1, 2); 2654 clk_register_clkdev(clk, "pll_p_out2", NULL); 2655 clks[TEGRA210_CLK_PLL_P_OUT2] = clk; 2656 2657 } 2658 2659 /* Tegra210 CPU clock and reset control functions */ 2660 static void tegra210_wait_cpu_in_reset(u32 cpu) 2661 { 2662 unsigned int reg; 2663 2664 do { 2665 reg = readl(clk_base + CLK_RST_CONTROLLER_CPU_CMPLX_STATUS); 2666 cpu_relax(); 2667 } while (!(reg & (1 << cpu))); /* check CPU been reset or not */ 2668 } 2669 2670 static void tegra210_disable_cpu_clock(u32 cpu) 2671 { 2672 /* flow controller would take care in the power sequence. */ 2673 } 2674 2675 #ifdef CONFIG_PM_SLEEP 2676 static void tegra210_cpu_clock_suspend(void) 2677 { 2678 /* switch coresite to clk_m, save off original source */ 2679 tegra210_cpu_clk_sctx.clk_csite_src = 2680 readl(clk_base + CLK_SOURCE_CSITE); 2681 writel(3 << 30, clk_base + CLK_SOURCE_CSITE); 2682 } 2683 2684 static void tegra210_cpu_clock_resume(void) 2685 { 2686 writel(tegra210_cpu_clk_sctx.clk_csite_src, 2687 clk_base + CLK_SOURCE_CSITE); 2688 } 2689 #endif 2690 2691 static struct tegra_cpu_car_ops tegra210_cpu_car_ops = { 2692 .wait_for_reset = tegra210_wait_cpu_in_reset, 2693 .disable_clock = tegra210_disable_cpu_clock, 2694 #ifdef CONFIG_PM_SLEEP 2695 .suspend = tegra210_cpu_clock_suspend, 2696 .resume = tegra210_cpu_clock_resume, 2697 #endif 2698 }; 2699 2700 static const struct of_device_id pmc_match[] __initconst = { 2701 { .compatible = "nvidia,tegra210-pmc" }, 2702 { }, 2703 }; 2704 2705 static struct tegra_clk_init_table init_table[] __initdata = { 2706 { TEGRA210_CLK_UARTA, TEGRA210_CLK_PLL_P, 408000000, 0 }, 2707 { TEGRA210_CLK_UARTB, TEGRA210_CLK_PLL_P, 408000000, 0 }, 2708 { TEGRA210_CLK_UARTC, TEGRA210_CLK_PLL_P, 408000000, 0 }, 2709 { TEGRA210_CLK_UARTD, TEGRA210_CLK_PLL_P, 408000000, 0 }, 2710 { TEGRA210_CLK_PLL_A, TEGRA210_CLK_CLK_MAX, 564480000, 1 }, 2711 { TEGRA210_CLK_PLL_A_OUT0, TEGRA210_CLK_CLK_MAX, 11289600, 1 }, 2712 { TEGRA210_CLK_EXTERN1, TEGRA210_CLK_PLL_A_OUT0, 0, 1 }, 2713 { TEGRA210_CLK_CLK_OUT_1_MUX, TEGRA210_CLK_EXTERN1, 0, 1 }, 2714 { TEGRA210_CLK_CLK_OUT_1, TEGRA210_CLK_CLK_MAX, 0, 1 }, 2715 { TEGRA210_CLK_I2S0, TEGRA210_CLK_PLL_A_OUT0, 11289600, 0 }, 2716 { TEGRA210_CLK_I2S1, TEGRA210_CLK_PLL_A_OUT0, 11289600, 0 }, 2717 { TEGRA210_CLK_I2S2, TEGRA210_CLK_PLL_A_OUT0, 11289600, 0 }, 2718 { TEGRA210_CLK_I2S3, TEGRA210_CLK_PLL_A_OUT0, 11289600, 0 }, 2719 { TEGRA210_CLK_I2S4, TEGRA210_CLK_PLL_A_OUT0, 11289600, 0 }, 2720 { TEGRA210_CLK_HOST1X, TEGRA210_CLK_PLL_P, 136000000, 1 }, 2721 { TEGRA210_CLK_SCLK_MUX, TEGRA210_CLK_PLL_P, 0, 1 }, 2722 { TEGRA210_CLK_SCLK, TEGRA210_CLK_CLK_MAX, 102000000, 1 }, 2723 { TEGRA210_CLK_DFLL_SOC, TEGRA210_CLK_PLL_P, 51000000, 1 }, 2724 { TEGRA210_CLK_DFLL_REF, TEGRA210_CLK_PLL_P, 51000000, 1 }, 2725 { TEGRA210_CLK_SBC4, TEGRA210_CLK_PLL_P, 12000000, 1 }, 2726 { TEGRA210_CLK_PLL_RE_VCO, TEGRA210_CLK_CLK_MAX, 672000000, 1 }, 2727 { TEGRA210_CLK_PLL_U_OUT1, TEGRA210_CLK_CLK_MAX, 48000000, 1 }, 2728 { TEGRA210_CLK_PLL_U_OUT2, TEGRA210_CLK_CLK_MAX, 60000000, 1 }, 2729 { TEGRA210_CLK_XUSB_GATE, TEGRA210_CLK_CLK_MAX, 0, 1 }, 2730 { TEGRA210_CLK_XUSB_SS_SRC, TEGRA210_CLK_PLL_U_480M, 120000000, 0 }, 2731 { TEGRA210_CLK_XUSB_FS_SRC, TEGRA210_CLK_PLL_U_48M, 48000000, 0 }, 2732 { TEGRA210_CLK_XUSB_HS_SRC, TEGRA210_CLK_XUSB_SS_SRC, 120000000, 0 }, 2733 { TEGRA210_CLK_XUSB_SSP_SRC, TEGRA210_CLK_XUSB_SS_SRC, 120000000, 0 }, 2734 { TEGRA210_CLK_XUSB_FALCON_SRC, TEGRA210_CLK_PLL_P_OUT_XUSB, 204000000, 0 }, 2735 { TEGRA210_CLK_XUSB_HOST_SRC, TEGRA210_CLK_PLL_P_OUT_XUSB, 102000000, 0 }, 2736 { TEGRA210_CLK_XUSB_DEV_SRC, TEGRA210_CLK_PLL_P_OUT_XUSB, 102000000, 0 }, 2737 { TEGRA210_CLK_SATA, TEGRA210_CLK_PLL_P, 104000000, 0 }, 2738 { TEGRA210_CLK_SATA_OOB, TEGRA210_CLK_PLL_P, 204000000, 0 }, 2739 { TEGRA210_CLK_EMC, TEGRA210_CLK_CLK_MAX, 0, 1 }, 2740 { TEGRA210_CLK_MSELECT, TEGRA210_CLK_CLK_MAX, 0, 1 }, 2741 { TEGRA210_CLK_CSITE, TEGRA210_CLK_CLK_MAX, 0, 1 }, 2742 { TEGRA210_CLK_TSENSOR, TEGRA210_CLK_CLK_M, 400000, 0 }, 2743 { TEGRA210_CLK_I2C1, TEGRA210_CLK_PLL_P, 0, 0 }, 2744 { TEGRA210_CLK_I2C2, TEGRA210_CLK_PLL_P, 0, 0 }, 2745 { TEGRA210_CLK_I2C3, TEGRA210_CLK_PLL_P, 0, 0 }, 2746 { TEGRA210_CLK_I2C4, TEGRA210_CLK_PLL_P, 0, 0 }, 2747 { TEGRA210_CLK_I2C5, TEGRA210_CLK_PLL_P, 0, 0 }, 2748 { TEGRA210_CLK_I2C6, TEGRA210_CLK_PLL_P, 0, 0 }, 2749 { TEGRA210_CLK_PLL_DP, TEGRA210_CLK_CLK_MAX, 270000000, 0 }, 2750 { TEGRA210_CLK_SOC_THERM, TEGRA210_CLK_PLL_P, 51000000, 0 }, 2751 { TEGRA210_CLK_CCLK_G, TEGRA210_CLK_CLK_MAX, 0, 1 }, 2752 /* This MUST be the last entry. */ 2753 { TEGRA210_CLK_CLK_MAX, TEGRA210_CLK_CLK_MAX, 0, 0 }, 2754 }; 2755 2756 /** 2757 * tegra210_clock_apply_init_table - initialize clocks on Tegra210 SoCs 2758 * 2759 * Program an initial clock rate and enable or disable clocks needed 2760 * by the rest of the kernel, for Tegra210 SoCs. It is intended to be 2761 * called by assigning a pointer to it to tegra_clk_apply_init_table - 2762 * this will be called as an arch_initcall. No return value. 2763 */ 2764 static void __init tegra210_clock_apply_init_table(void) 2765 { 2766 tegra_init_from_table(init_table, clks, TEGRA210_CLK_CLK_MAX); 2767 } 2768 2769 /** 2770 * tegra210_clock_init - Tegra210-specific clock initialization 2771 * @np: struct device_node * of the DT node for the SoC CAR IP block 2772 * 2773 * Register most SoC clocks for the Tegra210 system-on-chip. Intended 2774 * to be called by the OF init code when a DT node with the 2775 * "nvidia,tegra210-car" string is encountered, and declared with 2776 * CLK_OF_DECLARE. No return value. 2777 */ 2778 static void __init tegra210_clock_init(struct device_node *np) 2779 { 2780 struct device_node *node; 2781 u32 value, clk_m_div; 2782 2783 clk_base = of_iomap(np, 0); 2784 if (!clk_base) { 2785 pr_err("ioremap tegra210 CAR failed\n"); 2786 return; 2787 } 2788 2789 node = of_find_matching_node(NULL, pmc_match); 2790 if (!node) { 2791 pr_err("Failed to find pmc node\n"); 2792 WARN_ON(1); 2793 return; 2794 } 2795 2796 pmc_base = of_iomap(node, 0); 2797 if (!pmc_base) { 2798 pr_err("Can't map pmc registers\n"); 2799 WARN_ON(1); 2800 return; 2801 } 2802 2803 clks = tegra_clk_init(clk_base, TEGRA210_CLK_CLK_MAX, 2804 TEGRA210_CAR_BANK_COUNT); 2805 if (!clks) 2806 return; 2807 2808 value = clk_readl(clk_base + SPARE_REG0) >> CLK_M_DIVISOR_SHIFT; 2809 clk_m_div = (value & CLK_M_DIVISOR_MASK) + 1; 2810 2811 if (tegra_osc_clk_init(clk_base, tegra210_clks, tegra210_input_freq, 2812 ARRAY_SIZE(tegra210_input_freq), clk_m_div, 2813 &osc_freq, &pll_ref_freq) < 0) 2814 return; 2815 2816 tegra_fixed_clk_init(tegra210_clks); 2817 tegra210_pll_init(clk_base, pmc_base); 2818 tegra210_periph_clk_init(clk_base, pmc_base); 2819 tegra_audio_clk_init(clk_base, pmc_base, tegra210_clks, 2820 tegra210_audio_plls, 2821 ARRAY_SIZE(tegra210_audio_plls)); 2822 tegra_pmc_clk_init(pmc_base, tegra210_clks); 2823 2824 /* For Tegra210, PLLD is the only source for DSIA & DSIB */ 2825 value = clk_readl(clk_base + PLLD_BASE); 2826 value &= ~BIT(25); 2827 clk_writel(value, clk_base + PLLD_BASE); 2828 2829 tegra_clk_apply_init_table = tegra210_clock_apply_init_table; 2830 2831 tegra_super_clk_gen5_init(clk_base, pmc_base, tegra210_clks, 2832 &pll_x_params); 2833 tegra_add_of_provider(np); 2834 tegra_register_devclks(devclks, ARRAY_SIZE(devclks)); 2835 2836 tegra_cpu_car_ops = &tegra210_cpu_car_ops; 2837 } 2838 CLK_OF_DECLARE(tegra210, "nvidia,tegra210-car", tegra210_clock_init); 2839