19952f691SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only 26b301a05SRhyland Klein /* 36b301a05SRhyland Klein * Copyright (c) 2012-2014 NVIDIA CORPORATION. All rights reserved. 46b301a05SRhyland Klein */ 56b301a05SRhyland Klein 66b301a05SRhyland Klein #include <linux/io.h> 76b301a05SRhyland Klein #include <linux/clk.h> 86b301a05SRhyland Klein #include <linux/clk-provider.h> 96b301a05SRhyland Klein #include <linux/clkdev.h> 106b301a05SRhyland Klein #include <linux/of.h> 116b301a05SRhyland Klein #include <linux/of_address.h> 126b301a05SRhyland Klein #include <linux/delay.h> 136b301a05SRhyland Klein #include <linux/export.h> 14e403d005SPeter De Schrijver #include <linux/mutex.h> 156b301a05SRhyland Klein #include <linux/clk/tegra.h> 166b301a05SRhyland Klein #include <dt-bindings/clock/tegra210-car.h> 1768d724ceSPeter De Schrijver #include <dt-bindings/reset/tegra210-car.h> 18e745f992SPeter De Schrijver #include <linux/iopoll.h> 19c8da78e8SStephen Boyd #include <linux/sizes.h> 20e403d005SPeter De Schrijver #include <soc/tegra/pmc.h> 216b301a05SRhyland Klein 226b301a05SRhyland Klein #include "clk.h" 236b301a05SRhyland Klein #include "clk-id.h" 246b301a05SRhyland Klein 256b301a05SRhyland Klein /* 266b301a05SRhyland Klein * TEGRA210_CAR_BANK_COUNT: the number of peripheral clock register 276b301a05SRhyland Klein * banks present in the Tegra210 CAR IP block. The banks are 286b301a05SRhyland Klein * identified by single letters, e.g.: L, H, U, V, W, X, Y. See 296b301a05SRhyland Klein * periph_regs[] in drivers/clk/tegra/clk.c 306b301a05SRhyland Klein */ 316b301a05SRhyland Klein #define TEGRA210_CAR_BANK_COUNT 7 326b301a05SRhyland Klein 336b301a05SRhyland Klein #define CLK_SOURCE_CSITE 0x1d4 346b301a05SRhyland Klein #define CLK_SOURCE_EMC 0x19c 35bc2e4d29SThierry Reding #define CLK_SOURCE_SOR1 0x410 3605308d7eSThierry Reding #define CLK_SOURCE_SOR0 0x414 3789e423c3SPeter De Schrijver #define CLK_SOURCE_LA 0x1f8 38c76a69e4SPeter De-Schrijver #define CLK_SOURCE_SDMMC2 0x154 39c76a69e4SPeter De-Schrijver #define CLK_SOURCE_SDMMC4 0x164 406b301a05SRhyland Klein 416b301a05SRhyland Klein #define PLLC_BASE 0x80 426b301a05SRhyland Klein #define PLLC_OUT 0x84 436b301a05SRhyland Klein #define PLLC_MISC0 0x88 446b301a05SRhyland Klein #define PLLC_MISC1 0x8c 456b301a05SRhyland Klein #define PLLC_MISC2 0x5d0 466b301a05SRhyland Klein #define PLLC_MISC3 0x5d4 476b301a05SRhyland Klein 486b301a05SRhyland Klein #define PLLC2_BASE 0x4e8 496b301a05SRhyland Klein #define PLLC2_MISC0 0x4ec 506b301a05SRhyland Klein #define PLLC2_MISC1 0x4f0 516b301a05SRhyland Klein #define PLLC2_MISC2 0x4f4 526b301a05SRhyland Klein #define PLLC2_MISC3 0x4f8 536b301a05SRhyland Klein 546b301a05SRhyland Klein #define PLLC3_BASE 0x4fc 556b301a05SRhyland Klein #define PLLC3_MISC0 0x500 566b301a05SRhyland Klein #define PLLC3_MISC1 0x504 576b301a05SRhyland Klein #define PLLC3_MISC2 0x508 586b301a05SRhyland Klein #define PLLC3_MISC3 0x50c 596b301a05SRhyland Klein 606b301a05SRhyland Klein #define PLLM_BASE 0x90 616b301a05SRhyland Klein #define PLLM_MISC1 0x98 62474f2ba2SRhyland Klein #define PLLM_MISC2 0x9c 636b301a05SRhyland Klein #define PLLP_BASE 0xa0 646b301a05SRhyland Klein #define PLLP_MISC0 0xac 656b301a05SRhyland Klein #define PLLP_MISC1 0x680 666b301a05SRhyland Klein #define PLLA_BASE 0xb0 676b301a05SRhyland Klein #define PLLA_MISC0 0xbc 686b301a05SRhyland Klein #define PLLA_MISC1 0xb8 696b301a05SRhyland Klein #define PLLA_MISC2 0x5d8 706b301a05SRhyland Klein #define PLLD_BASE 0xd0 716b301a05SRhyland Klein #define PLLD_MISC0 0xdc 726b301a05SRhyland Klein #define PLLD_MISC1 0xd8 736b301a05SRhyland Klein #define PLLU_BASE 0xc0 746b301a05SRhyland Klein #define PLLU_OUTA 0xc4 756b301a05SRhyland Klein #define PLLU_MISC0 0xcc 766b301a05SRhyland Klein #define PLLU_MISC1 0xc8 776b301a05SRhyland Klein #define PLLX_BASE 0xe0 786b301a05SRhyland Klein #define PLLX_MISC0 0xe4 796b301a05SRhyland Klein #define PLLX_MISC1 0x510 806b301a05SRhyland Klein #define PLLX_MISC2 0x514 816b301a05SRhyland Klein #define PLLX_MISC3 0x518 826b301a05SRhyland Klein #define PLLX_MISC4 0x5f0 836b301a05SRhyland Klein #define PLLX_MISC5 0x5f4 846b301a05SRhyland Klein #define PLLE_BASE 0xe8 856b301a05SRhyland Klein #define PLLE_MISC0 0xec 866b301a05SRhyland Klein #define PLLD2_BASE 0x4b8 876b301a05SRhyland Klein #define PLLD2_MISC0 0x4bc 886b301a05SRhyland Klein #define PLLD2_MISC1 0x570 896b301a05SRhyland Klein #define PLLD2_MISC2 0x574 906b301a05SRhyland Klein #define PLLD2_MISC3 0x578 916b301a05SRhyland Klein #define PLLE_AUX 0x48c 926b301a05SRhyland Klein #define PLLRE_BASE 0x4c4 936b301a05SRhyland Klein #define PLLRE_MISC0 0x4c8 94926655f9SRhyland Klein #define PLLRE_OUT1 0x4cc 956b301a05SRhyland Klein #define PLLDP_BASE 0x590 966b301a05SRhyland Klein #define PLLDP_MISC 0x594 976b301a05SRhyland Klein 986b301a05SRhyland Klein #define PLLC4_BASE 0x5a4 996b301a05SRhyland Klein #define PLLC4_MISC0 0x5a8 1006b301a05SRhyland Klein #define PLLC4_OUT 0x5e4 1016b301a05SRhyland Klein #define PLLMB_BASE 0x5e8 102474f2ba2SRhyland Klein #define PLLMB_MISC1 0x5ec 1036b301a05SRhyland Klein #define PLLA1_BASE 0x6a4 1046b301a05SRhyland Klein #define PLLA1_MISC0 0x6a8 1056b301a05SRhyland Klein #define PLLA1_MISC1 0x6ac 1066b301a05SRhyland Klein #define PLLA1_MISC2 0x6b0 1076b301a05SRhyland Klein #define PLLA1_MISC3 0x6b4 1086b301a05SRhyland Klein 1096b301a05SRhyland Klein #define PLLU_IDDQ_BIT 31 1106b301a05SRhyland Klein #define PLLCX_IDDQ_BIT 27 1116b301a05SRhyland Klein #define PLLRE_IDDQ_BIT 24 1126b301a05SRhyland Klein #define PLLA_IDDQ_BIT 25 1136b301a05SRhyland Klein #define PLLD_IDDQ_BIT 20 1146b301a05SRhyland Klein #define PLLSS_IDDQ_BIT 18 1156b301a05SRhyland Klein #define PLLM_IDDQ_BIT 5 1166b301a05SRhyland Klein #define PLLMB_IDDQ_BIT 17 1176b301a05SRhyland Klein #define PLLXP_IDDQ_BIT 3 1186b301a05SRhyland Klein 1196b301a05SRhyland Klein #define PLLCX_RESET_BIT 30 1206b301a05SRhyland Klein 1216b301a05SRhyland Klein #define PLL_BASE_LOCK BIT(27) 1226b301a05SRhyland Klein #define PLLCX_BASE_LOCK BIT(26) 1236b301a05SRhyland Klein #define PLLE_MISC_LOCK BIT(11) 1246b301a05SRhyland Klein #define PLLRE_MISC_LOCK BIT(27) 1256b301a05SRhyland Klein 1266b301a05SRhyland Klein #define PLL_MISC_LOCK_ENABLE 18 1276b301a05SRhyland Klein #define PLLC_MISC_LOCK_ENABLE 24 1286b301a05SRhyland Klein #define PLLDU_MISC_LOCK_ENABLE 22 1296b301a05SRhyland Klein #define PLLU_MISC_LOCK_ENABLE 29 1306b301a05SRhyland Klein #define PLLE_MISC_LOCK_ENABLE 9 1316b301a05SRhyland Klein #define PLLRE_MISC_LOCK_ENABLE 30 1326b301a05SRhyland Klein #define PLLSS_MISC_LOCK_ENABLE 30 1336b301a05SRhyland Klein #define PLLP_MISC_LOCK_ENABLE 18 1346b301a05SRhyland Klein #define PLLM_MISC_LOCK_ENABLE 4 1356b301a05SRhyland Klein #define PLLMB_MISC_LOCK_ENABLE 16 1366b301a05SRhyland Klein #define PLLA_MISC_LOCK_ENABLE 28 1376b301a05SRhyland Klein #define PLLU_MISC_LOCK_ENABLE 29 1386b301a05SRhyland Klein #define PLLD_MISC_LOCK_ENABLE 18 1396b301a05SRhyland Klein 1406b301a05SRhyland Klein #define PLLA_SDM_DIN_MASK 0xffff 1416b301a05SRhyland Klein #define PLLA_SDM_EN_MASK BIT(26) 1426b301a05SRhyland Klein 1436b301a05SRhyland Klein #define PLLD_SDM_EN_MASK BIT(16) 1446b301a05SRhyland Klein 1456b301a05SRhyland Klein #define PLLD2_SDM_EN_MASK BIT(31) 146030999feSPeter De Schrijver #define PLLD2_SSC_EN_MASK 0 1476b301a05SRhyland Klein 1486b301a05SRhyland Klein #define PLLDP_SS_CFG 0x598 1496b301a05SRhyland Klein #define PLLDP_SDM_EN_MASK BIT(31) 1506b301a05SRhyland Klein #define PLLDP_SSC_EN_MASK BIT(30) 1516b301a05SRhyland Klein #define PLLDP_SS_CTRL1 0x59c 1526b301a05SRhyland Klein #define PLLDP_SS_CTRL2 0x5a0 1536b301a05SRhyland Klein 1546b301a05SRhyland Klein #define PMC_PLLM_WB0_OVERRIDE 0x1dc 1556b301a05SRhyland Klein #define PMC_PLLM_WB0_OVERRIDE_2 0x2b0 1566b301a05SRhyland Klein 157e745f992SPeter De Schrijver #define UTMIP_PLL_CFG2 0x488 158e745f992SPeter De Schrijver #define UTMIP_PLL_CFG2_STABLE_COUNT(x) (((x) & 0xfff) << 6) 159e745f992SPeter De Schrijver #define UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(x) (((x) & 0x3f) << 18) 160e745f992SPeter De Schrijver #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_A_POWERDOWN BIT(0) 161e745f992SPeter De Schrijver #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_A_POWERUP BIT(1) 162e745f992SPeter De Schrijver #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_B_POWERDOWN BIT(2) 163e745f992SPeter De Schrijver #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_B_POWERUP BIT(3) 164e745f992SPeter De Schrijver #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_C_POWERDOWN BIT(4) 165e745f992SPeter De Schrijver #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_C_POWERUP BIT(5) 166e745f992SPeter De Schrijver #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_D_POWERDOWN BIT(24) 167e745f992SPeter De Schrijver #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_D_POWERUP BIT(25) 168e745f992SPeter De Schrijver 169e745f992SPeter De Schrijver #define UTMIP_PLL_CFG1 0x484 170e745f992SPeter De Schrijver #define UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(x) (((x) & 0x1f) << 27) 171e745f992SPeter De Schrijver #define UTMIP_PLL_CFG1_XTAL_FREQ_COUNT(x) (((x) & 0xfff) << 0) 172e745f992SPeter De Schrijver #define UTMIP_PLL_CFG1_FORCE_PLLU_POWERUP BIT(17) 173e745f992SPeter De Schrijver #define UTMIP_PLL_CFG1_FORCE_PLLU_POWERDOWN BIT(16) 174e745f992SPeter De Schrijver #define UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERUP BIT(15) 175e745f992SPeter De Schrijver #define UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERDOWN BIT(14) 176e745f992SPeter De Schrijver #define UTMIP_PLL_CFG1_FORCE_PLL_ACTIVE_POWERDOWN BIT(12) 177e745f992SPeter De Schrijver 1783358d2d9SAndrew Bresticker #define SATA_PLL_CFG0 0x490 1793358d2d9SAndrew Bresticker #define SATA_PLL_CFG0_PADPLL_RESET_SWCTL BIT(0) 1803358d2d9SAndrew Bresticker #define SATA_PLL_CFG0_PADPLL_USE_LOCKDET BIT(2) 18159af78d7SPeter De Schrijver #define SATA_PLL_CFG0_SATA_SEQ_IN_SWCTL BIT(4) 18259af78d7SPeter De Schrijver #define SATA_PLL_CFG0_SATA_SEQ_RESET_INPUT_VALUE BIT(5) 18359af78d7SPeter De Schrijver #define SATA_PLL_CFG0_SATA_SEQ_LANE_PD_INPUT_VALUE BIT(6) 18459af78d7SPeter De Schrijver #define SATA_PLL_CFG0_SATA_SEQ_PADPLL_PD_INPUT_VALUE BIT(7) 18559af78d7SPeter De Schrijver 1863358d2d9SAndrew Bresticker #define SATA_PLL_CFG0_PADPLL_SLEEP_IDDQ BIT(13) 1873358d2d9SAndrew Bresticker #define SATA_PLL_CFG0_SEQ_ENABLE BIT(24) 1883358d2d9SAndrew Bresticker 1893358d2d9SAndrew Bresticker #define XUSBIO_PLL_CFG0 0x51c 1903358d2d9SAndrew Bresticker #define XUSBIO_PLL_CFG0_PADPLL_RESET_SWCTL BIT(0) 1913358d2d9SAndrew Bresticker #define XUSBIO_PLL_CFG0_CLK_ENABLE_SWCTL BIT(2) 1923358d2d9SAndrew Bresticker #define XUSBIO_PLL_CFG0_PADPLL_USE_LOCKDET BIT(6) 1933358d2d9SAndrew Bresticker #define XUSBIO_PLL_CFG0_PADPLL_SLEEP_IDDQ BIT(13) 1943358d2d9SAndrew Bresticker #define XUSBIO_PLL_CFG0_SEQ_ENABLE BIT(24) 1953358d2d9SAndrew Bresticker 1966b301a05SRhyland Klein #define UTMIPLL_HW_PWRDN_CFG0 0x52c 1976b301a05SRhyland Klein #define UTMIPLL_HW_PWRDN_CFG0_UTMIPLL_LOCK BIT(31) 1986b301a05SRhyland Klein #define UTMIPLL_HW_PWRDN_CFG0_SEQ_START_STATE BIT(25) 1996b301a05SRhyland Klein #define UTMIPLL_HW_PWRDN_CFG0_SEQ_ENABLE BIT(24) 2006b301a05SRhyland Klein #define UTMIPLL_HW_PWRDN_CFG0_IDDQ_PD_INCLUDE BIT(7) 2016b301a05SRhyland Klein #define UTMIPLL_HW_PWRDN_CFG0_USE_LOCKDET BIT(6) 2026b301a05SRhyland Klein #define UTMIPLL_HW_PWRDN_CFG0_SEQ_RESET_INPUT_VALUE BIT(5) 2036b301a05SRhyland Klein #define UTMIPLL_HW_PWRDN_CFG0_SEQ_IN_SWCTL BIT(4) 2046b301a05SRhyland Klein #define UTMIPLL_HW_PWRDN_CFG0_CLK_ENABLE_SWCTL BIT(2) 2056b301a05SRhyland Klein #define UTMIPLL_HW_PWRDN_CFG0_IDDQ_OVERRIDE BIT(1) 2066b301a05SRhyland Klein #define UTMIPLL_HW_PWRDN_CFG0_IDDQ_SWCTL BIT(0) 2076b301a05SRhyland Klein 2086b301a05SRhyland Klein #define PLLU_HW_PWRDN_CFG0 0x530 2096b301a05SRhyland Klein #define PLLU_HW_PWRDN_CFG0_IDDQ_PD_INCLUDE BIT(28) 2106b301a05SRhyland Klein #define PLLU_HW_PWRDN_CFG0_SEQ_ENABLE BIT(24) 2116b301a05SRhyland Klein #define PLLU_HW_PWRDN_CFG0_USE_SWITCH_DETECT BIT(7) 2126b301a05SRhyland Klein #define PLLU_HW_PWRDN_CFG0_USE_LOCKDET BIT(6) 2136b301a05SRhyland Klein #define PLLU_HW_PWRDN_CFG0_CLK_ENABLE_SWCTL BIT(2) 2146b301a05SRhyland Klein #define PLLU_HW_PWRDN_CFG0_CLK_SWITCH_SWCTL BIT(0) 2156b301a05SRhyland Klein 2166b301a05SRhyland Klein #define XUSB_PLL_CFG0 0x534 2176b301a05SRhyland Klein #define XUSB_PLL_CFG0_UTMIPLL_LOCK_DLY 0x3ff 2186b301a05SRhyland Klein #define XUSB_PLL_CFG0_PLLU_LOCK_DLY_MASK (0x3ff << 14) 2196b301a05SRhyland Klein 2206b301a05SRhyland Klein #define SPARE_REG0 0x55c 2216b301a05SRhyland Klein #define CLK_M_DIVISOR_SHIFT 2 2226b301a05SRhyland Klein #define CLK_M_DIVISOR_MASK 0x3 2236b301a05SRhyland Klein 22468d724ceSPeter De Schrijver #define RST_DFLL_DVCO 0x2f4 22568d724ceSPeter De Schrijver #define DVFS_DFLL_RESET_SHIFT 0 22668d724ceSPeter De Schrijver 22768d724ceSPeter De Schrijver #define CLK_RST_CONTROLLER_RST_DEV_Y_SET 0x2a8 22868d724ceSPeter De Schrijver #define CLK_RST_CONTROLLER_RST_DEV_Y_CLR 0x2ac 22968d724ceSPeter De Schrijver 230e403d005SPeter De Schrijver #define LVL2_CLK_GATE_OVRA 0xf8 231e403d005SPeter De Schrijver #define LVL2_CLK_GATE_OVRC 0x3a0 232e403d005SPeter De Schrijver #define LVL2_CLK_GATE_OVRD 0x3a4 233e403d005SPeter De Schrijver #define LVL2_CLK_GATE_OVRE 0x554 234e403d005SPeter De Schrijver 235e403d005SPeter De Schrijver /* I2S registers to handle during APE MBIST WAR */ 236e403d005SPeter De Schrijver #define TEGRA210_I2S_BASE 0x1000 237e403d005SPeter De Schrijver #define TEGRA210_I2S_SIZE 0x100 238e403d005SPeter De Schrijver #define TEGRA210_I2S_CTRLS 5 239e403d005SPeter De Schrijver #define TEGRA210_I2S_CG 0x88 240e403d005SPeter De Schrijver #define TEGRA210_I2S_CTRL 0xa0 241e403d005SPeter De Schrijver 242e403d005SPeter De Schrijver /* DISPA registers to handle during MBIST WAR */ 243e403d005SPeter De Schrijver #define DC_CMD_DISPLAY_COMMAND 0xc8 244e403d005SPeter De Schrijver #define DC_COM_DSC_TOP_CTL 0xcf8 245e403d005SPeter De Schrijver 246e403d005SPeter De Schrijver /* VIC register to handle during MBIST WAR */ 247e403d005SPeter De Schrijver #define NV_PVIC_THI_SLCG_OVERRIDE_LOW 0x8c 248e403d005SPeter De Schrijver 249e403d005SPeter De Schrijver /* APE, DISPA and VIC base addesses needed for MBIST WAR */ 250e403d005SPeter De Schrijver #define TEGRA210_AHUB_BASE 0x702d0000 251e403d005SPeter De Schrijver #define TEGRA210_DISPA_BASE 0x54200000 252e403d005SPeter De Schrijver #define TEGRA210_VIC_BASE 0x54340000 253e403d005SPeter De Schrijver 2546b301a05SRhyland Klein /* 2556b301a05SRhyland Klein * SDM fractional divisor is 16-bit 2's complement signed number within 2566b301a05SRhyland Klein * (-2^12 ... 2^12-1) range. Represented in PLL data structure as unsigned 2576b301a05SRhyland Klein * 16-bit value, with "0" divisor mapped to 0xFFFF. Data "0" is used to 2586b301a05SRhyland Klein * indicate that SDM is disabled. 2596b301a05SRhyland Klein * 2606b301a05SRhyland Klein * Effective ndiv value when SDM is enabled: ndiv + 1/2 + sdm_din/2^13 2616b301a05SRhyland Klein */ 2626b301a05SRhyland Klein #define PLL_SDM_COEFF BIT(13) 2636b301a05SRhyland Klein #define sdin_din_to_data(din) ((u16)((din) ? : 0xFFFFU)) 2646b301a05SRhyland Klein #define sdin_data_to_din(dat) (((dat) == 0xFFFFU) ? 0 : (s16)dat) 265a851ea2bSAlex Frid /* This macro returns ndiv effective scaled to SDM range */ 266a851ea2bSAlex Frid #define sdin_get_n_eff(cfg) ((cfg)->n * PLL_SDM_COEFF + ((cfg)->sdm_data ? \ 267a851ea2bSAlex Frid (PLL_SDM_COEFF/2 + sdin_data_to_din((cfg)->sdm_data)) : 0)) 2686b301a05SRhyland Klein 2696b301a05SRhyland Klein /* Tegra CPU clock and reset control regs */ 2706b301a05SRhyland Klein #define CLK_RST_CONTROLLER_CPU_CMPLX_STATUS 0x470 2716b301a05SRhyland Klein 2726b301a05SRhyland Klein #ifdef CONFIG_PM_SLEEP 2736b301a05SRhyland Klein static struct cpu_clk_suspend_context { 2746b301a05SRhyland Klein u32 clk_csite_src; 2756b301a05SRhyland Klein } tegra210_cpu_clk_sctx; 2766b301a05SRhyland Klein #endif 2776b301a05SRhyland Klein 278e403d005SPeter De Schrijver struct tegra210_domain_mbist_war { 279e403d005SPeter De Schrijver void (*handle_lvl2_ovr)(struct tegra210_domain_mbist_war *mbist); 280e403d005SPeter De Schrijver const u32 lvl2_offset; 281e403d005SPeter De Schrijver const u32 lvl2_mask; 282e403d005SPeter De Schrijver const unsigned int num_clks; 283e403d005SPeter De Schrijver const unsigned int *clk_init_data; 284e403d005SPeter De Schrijver struct clk_bulk_data *clks; 285e403d005SPeter De Schrijver }; 286e403d005SPeter De Schrijver 287e403d005SPeter De Schrijver static struct clk **clks; 288e403d005SPeter De Schrijver 2896b301a05SRhyland Klein static void __iomem *clk_base; 2906b301a05SRhyland Klein static void __iomem *pmc_base; 291e403d005SPeter De Schrijver static void __iomem *ahub_base; 292e403d005SPeter De Schrijver static void __iomem *dispa_base; 293e403d005SPeter De Schrijver static void __iomem *vic_base; 2946b301a05SRhyland Klein 2956b301a05SRhyland Klein static unsigned long osc_freq; 2966b301a05SRhyland Klein static unsigned long pll_ref_freq; 2976b301a05SRhyland Klein 2986b301a05SRhyland Klein static DEFINE_SPINLOCK(pll_d_lock); 2996b301a05SRhyland Klein static DEFINE_SPINLOCK(pll_e_lock); 3006b301a05SRhyland Klein static DEFINE_SPINLOCK(pll_re_lock); 3016b301a05SRhyland Klein static DEFINE_SPINLOCK(pll_u_lock); 30205308d7eSThierry Reding static DEFINE_SPINLOCK(sor0_lock); 303bc2e4d29SThierry Reding static DEFINE_SPINLOCK(sor1_lock); 3046b301a05SRhyland Klein static DEFINE_SPINLOCK(emc_lock); 305e403d005SPeter De Schrijver static DEFINE_MUTEX(lvl2_ovr_lock); 3066b301a05SRhyland Klein 3076b301a05SRhyland Klein /* possible OSC frequencies in Hz */ 3086b301a05SRhyland Klein static unsigned long tegra210_input_freq[] = { 3096b301a05SRhyland Klein [5] = 38400000, 3106b301a05SRhyland Klein [8] = 12000000, 3116b301a05SRhyland Klein }; 3126b301a05SRhyland Klein 3136b301a05SRhyland Klein static const char *mux_pllmcp_clkm[] = { 3144f8d4440SJon Hunter "pll_m", "pll_c", "pll_p", "clk_m", "pll_m_ud", "pll_mb", "pll_mb", 3154f8d4440SJon Hunter "pll_p", 3166b301a05SRhyland Klein }; 3176b301a05SRhyland Klein #define mux_pllmcp_clkm_idx NULL 3186b301a05SRhyland Klein 3196b301a05SRhyland Klein #define PLL_ENABLE (1 << 30) 3206b301a05SRhyland Klein 3216b301a05SRhyland Klein #define PLLCX_MISC1_IDDQ (1 << 27) 3226b301a05SRhyland Klein #define PLLCX_MISC0_RESET (1 << 30) 3236b301a05SRhyland Klein 3246b301a05SRhyland Klein #define PLLCX_MISC0_DEFAULT_VALUE 0x40080000 3256b301a05SRhyland Klein #define PLLCX_MISC0_WRITE_MASK 0x400ffffb 3266b301a05SRhyland Klein #define PLLCX_MISC1_DEFAULT_VALUE 0x08000000 3276b301a05SRhyland Klein #define PLLCX_MISC1_WRITE_MASK 0x08003cff 3286b301a05SRhyland Klein #define PLLCX_MISC2_DEFAULT_VALUE 0x1f720f05 3296b301a05SRhyland Klein #define PLLCX_MISC2_WRITE_MASK 0xffffff17 3306b301a05SRhyland Klein #define PLLCX_MISC3_DEFAULT_VALUE 0x000000c4 3316b301a05SRhyland Klein #define PLLCX_MISC3_WRITE_MASK 0x00ffffff 3326b301a05SRhyland Klein 3336b301a05SRhyland Klein /* PLLA */ 3346b301a05SRhyland Klein #define PLLA_BASE_IDDQ (1 << 25) 3356b301a05SRhyland Klein #define PLLA_BASE_LOCK (1 << 27) 3366b301a05SRhyland Klein 3376b301a05SRhyland Klein #define PLLA_MISC0_LOCK_ENABLE (1 << 28) 3386b301a05SRhyland Klein #define PLLA_MISC0_LOCK_OVERRIDE (1 << 27) 3396b301a05SRhyland Klein 3406b301a05SRhyland Klein #define PLLA_MISC2_EN_SDM (1 << 26) 3416b301a05SRhyland Klein #define PLLA_MISC2_EN_DYNRAMP (1 << 25) 3426b301a05SRhyland Klein 3436b301a05SRhyland Klein #define PLLA_MISC0_DEFAULT_VALUE 0x12000020 3446b301a05SRhyland Klein #define PLLA_MISC0_WRITE_MASK 0x7fffffff 3456b301a05SRhyland Klein #define PLLA_MISC2_DEFAULT_VALUE 0x0 3466b301a05SRhyland Klein #define PLLA_MISC2_WRITE_MASK 0x06ffffff 3476b301a05SRhyland Klein 3486b301a05SRhyland Klein /* PLLD */ 349e403d005SPeter De Schrijver #define PLLD_BASE_CSI_CLKSOURCE (1 << 23) 350e403d005SPeter De Schrijver 3516b301a05SRhyland Klein #define PLLD_MISC0_EN_SDM (1 << 16) 3526b301a05SRhyland Klein #define PLLD_MISC0_LOCK_OVERRIDE (1 << 17) 3536b301a05SRhyland Klein #define PLLD_MISC0_LOCK_ENABLE (1 << 18) 3546b301a05SRhyland Klein #define PLLD_MISC0_IDDQ (1 << 20) 3556b301a05SRhyland Klein #define PLLD_MISC0_DSI_CLKENABLE (1 << 21) 3566b301a05SRhyland Klein 3576b301a05SRhyland Klein #define PLLD_MISC0_DEFAULT_VALUE 0x00140000 3586b301a05SRhyland Klein #define PLLD_MISC0_WRITE_MASK 0x3ff7ffff 3596b301a05SRhyland Klein #define PLLD_MISC1_DEFAULT_VALUE 0x20 3606b301a05SRhyland Klein #define PLLD_MISC1_WRITE_MASK 0x00ffffff 3616b301a05SRhyland Klein 3626b301a05SRhyland Klein /* PLLD2 and PLLDP and PLLC4 */ 3636b301a05SRhyland Klein #define PLLDSS_BASE_LOCK (1 << 27) 3646b301a05SRhyland Klein #define PLLDSS_BASE_LOCK_OVERRIDE (1 << 24) 3656b301a05SRhyland Klein #define PLLDSS_BASE_IDDQ (1 << 18) 3666b301a05SRhyland Klein #define PLLDSS_BASE_REF_SEL_SHIFT 25 3676b301a05SRhyland Klein #define PLLDSS_BASE_REF_SEL_MASK (0x3 << PLLDSS_BASE_REF_SEL_SHIFT) 3686b301a05SRhyland Klein 3696b301a05SRhyland Klein #define PLLDSS_MISC0_LOCK_ENABLE (1 << 30) 3706b301a05SRhyland Klein 3716b301a05SRhyland Klein #define PLLDSS_MISC1_CFG_EN_SDM (1 << 31) 3726b301a05SRhyland Klein #define PLLDSS_MISC1_CFG_EN_SSC (1 << 30) 3736b301a05SRhyland Klein 3746b301a05SRhyland Klein #define PLLD2_MISC0_DEFAULT_VALUE 0x40000020 3756b301a05SRhyland Klein #define PLLD2_MISC1_CFG_DEFAULT_VALUE 0x10000000 3766b301a05SRhyland Klein #define PLLD2_MISC2_CTRL1_DEFAULT_VALUE 0x0 3776b301a05SRhyland Klein #define PLLD2_MISC3_CTRL2_DEFAULT_VALUE 0x0 3786b301a05SRhyland Klein 3796b301a05SRhyland Klein #define PLLDP_MISC0_DEFAULT_VALUE 0x40000020 3806b301a05SRhyland Klein #define PLLDP_MISC1_CFG_DEFAULT_VALUE 0xc0000000 3816b301a05SRhyland Klein #define PLLDP_MISC2_CTRL1_DEFAULT_VALUE 0xf400f0da 3826b301a05SRhyland Klein #define PLLDP_MISC3_CTRL2_DEFAULT_VALUE 0x2004f400 3836b301a05SRhyland Klein 3846b301a05SRhyland Klein #define PLLDSS_MISC0_WRITE_MASK 0x47ffffff 3856b301a05SRhyland Klein #define PLLDSS_MISC1_CFG_WRITE_MASK 0xf8000000 3866b301a05SRhyland Klein #define PLLDSS_MISC2_CTRL1_WRITE_MASK 0xffffffff 3876b301a05SRhyland Klein #define PLLDSS_MISC3_CTRL2_WRITE_MASK 0xffffffff 3886b301a05SRhyland Klein 3896b301a05SRhyland Klein #define PLLC4_MISC0_DEFAULT_VALUE 0x40000000 3906b301a05SRhyland Klein 3916b301a05SRhyland Klein /* PLLRE */ 3926b301a05SRhyland Klein #define PLLRE_MISC0_LOCK_ENABLE (1 << 30) 3936b301a05SRhyland Klein #define PLLRE_MISC0_LOCK_OVERRIDE (1 << 29) 3946b301a05SRhyland Klein #define PLLRE_MISC0_LOCK (1 << 27) 3956b301a05SRhyland Klein #define PLLRE_MISC0_IDDQ (1 << 24) 3966b301a05SRhyland Klein 3976b301a05SRhyland Klein #define PLLRE_BASE_DEFAULT_VALUE 0x0 3986b301a05SRhyland Klein #define PLLRE_MISC0_DEFAULT_VALUE 0x41000000 3996b301a05SRhyland Klein 4006b301a05SRhyland Klein #define PLLRE_BASE_DEFAULT_MASK 0x1c000000 4016b301a05SRhyland Klein #define PLLRE_MISC0_WRITE_MASK 0x67ffffff 4026b301a05SRhyland Klein 4036b301a05SRhyland Klein /* PLLX */ 4046b301a05SRhyland Klein #define PLLX_USE_DYN_RAMP 1 4056b301a05SRhyland Klein #define PLLX_BASE_LOCK (1 << 27) 4066b301a05SRhyland Klein 4076b301a05SRhyland Klein #define PLLX_MISC0_FO_G_DISABLE (0x1 << 28) 4086b301a05SRhyland Klein #define PLLX_MISC0_LOCK_ENABLE (0x1 << 18) 4096b301a05SRhyland Klein 4106b301a05SRhyland Klein #define PLLX_MISC2_DYNRAMP_STEPB_SHIFT 24 4116b301a05SRhyland Klein #define PLLX_MISC2_DYNRAMP_STEPB_MASK (0xFF << PLLX_MISC2_DYNRAMP_STEPB_SHIFT) 4126b301a05SRhyland Klein #define PLLX_MISC2_DYNRAMP_STEPA_SHIFT 16 4136b301a05SRhyland Klein #define PLLX_MISC2_DYNRAMP_STEPA_MASK (0xFF << PLLX_MISC2_DYNRAMP_STEPA_SHIFT) 4146b301a05SRhyland Klein #define PLLX_MISC2_NDIV_NEW_SHIFT 8 4156b301a05SRhyland Klein #define PLLX_MISC2_NDIV_NEW_MASK (0xFF << PLLX_MISC2_NDIV_NEW_SHIFT) 4166b301a05SRhyland Klein #define PLLX_MISC2_LOCK_OVERRIDE (0x1 << 4) 4176b301a05SRhyland Klein #define PLLX_MISC2_DYNRAMP_DONE (0x1 << 2) 4186b301a05SRhyland Klein #define PLLX_MISC2_EN_DYNRAMP (0x1 << 0) 4196b301a05SRhyland Klein 4206b301a05SRhyland Klein #define PLLX_MISC3_IDDQ (0x1 << 3) 4216b301a05SRhyland Klein 4226b301a05SRhyland Klein #define PLLX_MISC0_DEFAULT_VALUE PLLX_MISC0_LOCK_ENABLE 4236b301a05SRhyland Klein #define PLLX_MISC0_WRITE_MASK 0x10c40000 4246b301a05SRhyland Klein #define PLLX_MISC1_DEFAULT_VALUE 0x20 4256b301a05SRhyland Klein #define PLLX_MISC1_WRITE_MASK 0x00ffffff 4266b301a05SRhyland Klein #define PLLX_MISC2_DEFAULT_VALUE 0x0 4276b301a05SRhyland Klein #define PLLX_MISC2_WRITE_MASK 0xffffff11 4286b301a05SRhyland Klein #define PLLX_MISC3_DEFAULT_VALUE PLLX_MISC3_IDDQ 4296b301a05SRhyland Klein #define PLLX_MISC3_WRITE_MASK 0x01ff0f0f 4306b301a05SRhyland Klein #define PLLX_MISC4_DEFAULT_VALUE 0x0 4316b301a05SRhyland Klein #define PLLX_MISC4_WRITE_MASK 0x8000ffff 4326b301a05SRhyland Klein #define PLLX_MISC5_DEFAULT_VALUE 0x0 4336b301a05SRhyland Klein #define PLLX_MISC5_WRITE_MASK 0x0000ffff 4346b301a05SRhyland Klein 4356b301a05SRhyland Klein #define PLLX_HW_CTRL_CFG 0x548 4366b301a05SRhyland Klein #define PLLX_HW_CTRL_CFG_SWCTRL (0x1 << 0) 4376b301a05SRhyland Klein 4386b301a05SRhyland Klein /* PLLMB */ 4396b301a05SRhyland Klein #define PLLMB_BASE_LOCK (1 << 27) 4406b301a05SRhyland Klein 441474f2ba2SRhyland Klein #define PLLMB_MISC1_LOCK_OVERRIDE (1 << 18) 442474f2ba2SRhyland Klein #define PLLMB_MISC1_IDDQ (1 << 17) 443474f2ba2SRhyland Klein #define PLLMB_MISC1_LOCK_ENABLE (1 << 16) 4446b301a05SRhyland Klein 445474f2ba2SRhyland Klein #define PLLMB_MISC1_DEFAULT_VALUE 0x00030000 446474f2ba2SRhyland Klein #define PLLMB_MISC1_WRITE_MASK 0x0007ffff 4476b301a05SRhyland Klein 4486b301a05SRhyland Klein /* PLLP */ 4496b301a05SRhyland Klein #define PLLP_BASE_OVERRIDE (1 << 28) 4506b301a05SRhyland Klein #define PLLP_BASE_LOCK (1 << 27) 4516b301a05SRhyland Klein 4526b301a05SRhyland Klein #define PLLP_MISC0_LOCK_ENABLE (1 << 18) 4536b301a05SRhyland Klein #define PLLP_MISC0_LOCK_OVERRIDE (1 << 17) 4546b301a05SRhyland Klein #define PLLP_MISC0_IDDQ (1 << 3) 4556b301a05SRhyland Klein 4566b301a05SRhyland Klein #define PLLP_MISC1_HSIO_EN_SHIFT 29 4576b301a05SRhyland Klein #define PLLP_MISC1_HSIO_EN (1 << PLLP_MISC1_HSIO_EN_SHIFT) 4586b301a05SRhyland Klein #define PLLP_MISC1_XUSB_EN_SHIFT 28 4596b301a05SRhyland Klein #define PLLP_MISC1_XUSB_EN (1 << PLLP_MISC1_XUSB_EN_SHIFT) 4606b301a05SRhyland Klein 4616b301a05SRhyland Klein #define PLLP_MISC0_DEFAULT_VALUE 0x00040008 4626b301a05SRhyland Klein #define PLLP_MISC1_DEFAULT_VALUE 0x0 4636b301a05SRhyland Klein 4646b301a05SRhyland Klein #define PLLP_MISC0_WRITE_MASK 0xdc6000f 4656b301a05SRhyland Klein #define PLLP_MISC1_WRITE_MASK 0x70ffffff 4666b301a05SRhyland Klein 4676b301a05SRhyland Klein /* PLLU */ 4686b301a05SRhyland Klein #define PLLU_BASE_LOCK (1 << 27) 4696b301a05SRhyland Klein #define PLLU_BASE_OVERRIDE (1 << 24) 4706b301a05SRhyland Klein #define PLLU_BASE_CLKENABLE_USB (1 << 21) 4716b301a05SRhyland Klein #define PLLU_BASE_CLKENABLE_HSIC (1 << 22) 4726b301a05SRhyland Klein #define PLLU_BASE_CLKENABLE_ICUSB (1 << 23) 4736b301a05SRhyland Klein #define PLLU_BASE_CLKENABLE_48M (1 << 25) 4746b301a05SRhyland Klein #define PLLU_BASE_CLKENABLE_ALL (PLLU_BASE_CLKENABLE_USB |\ 4756b301a05SRhyland Klein PLLU_BASE_CLKENABLE_HSIC |\ 4766b301a05SRhyland Klein PLLU_BASE_CLKENABLE_ICUSB |\ 4776b301a05SRhyland Klein PLLU_BASE_CLKENABLE_48M) 4786b301a05SRhyland Klein 4796b301a05SRhyland Klein #define PLLU_MISC0_IDDQ (1 << 31) 4806b301a05SRhyland Klein #define PLLU_MISC0_LOCK_ENABLE (1 << 29) 4816b301a05SRhyland Klein #define PLLU_MISC1_LOCK_OVERRIDE (1 << 0) 4826b301a05SRhyland Klein 4836b301a05SRhyland Klein #define PLLU_MISC0_DEFAULT_VALUE 0xa0000000 4846b301a05SRhyland Klein #define PLLU_MISC1_DEFAULT_VALUE 0x0 4856b301a05SRhyland Klein 4866b301a05SRhyland Klein #define PLLU_MISC0_WRITE_MASK 0xbfffffff 4876b301a05SRhyland Klein #define PLLU_MISC1_WRITE_MASK 0x00000007 4886b301a05SRhyland Klein 4893358d2d9SAndrew Bresticker void tegra210_xusb_pll_hw_control_enable(void) 4903358d2d9SAndrew Bresticker { 4913358d2d9SAndrew Bresticker u32 val; 4923358d2d9SAndrew Bresticker 4933358d2d9SAndrew Bresticker val = readl_relaxed(clk_base + XUSBIO_PLL_CFG0); 4943358d2d9SAndrew Bresticker val &= ~(XUSBIO_PLL_CFG0_CLK_ENABLE_SWCTL | 4953358d2d9SAndrew Bresticker XUSBIO_PLL_CFG0_PADPLL_RESET_SWCTL); 4963358d2d9SAndrew Bresticker val |= XUSBIO_PLL_CFG0_PADPLL_USE_LOCKDET | 4973358d2d9SAndrew Bresticker XUSBIO_PLL_CFG0_PADPLL_SLEEP_IDDQ; 4983358d2d9SAndrew Bresticker writel_relaxed(val, clk_base + XUSBIO_PLL_CFG0); 4993358d2d9SAndrew Bresticker } 5003358d2d9SAndrew Bresticker EXPORT_SYMBOL_GPL(tegra210_xusb_pll_hw_control_enable); 5013358d2d9SAndrew Bresticker 5023358d2d9SAndrew Bresticker void tegra210_xusb_pll_hw_sequence_start(void) 5033358d2d9SAndrew Bresticker { 5043358d2d9SAndrew Bresticker u32 val; 5053358d2d9SAndrew Bresticker 5063358d2d9SAndrew Bresticker val = readl_relaxed(clk_base + XUSBIO_PLL_CFG0); 5073358d2d9SAndrew Bresticker val |= XUSBIO_PLL_CFG0_SEQ_ENABLE; 5083358d2d9SAndrew Bresticker writel_relaxed(val, clk_base + XUSBIO_PLL_CFG0); 5093358d2d9SAndrew Bresticker } 5103358d2d9SAndrew Bresticker EXPORT_SYMBOL_GPL(tegra210_xusb_pll_hw_sequence_start); 5113358d2d9SAndrew Bresticker 5123358d2d9SAndrew Bresticker void tegra210_sata_pll_hw_control_enable(void) 5133358d2d9SAndrew Bresticker { 5143358d2d9SAndrew Bresticker u32 val; 5153358d2d9SAndrew Bresticker 5163358d2d9SAndrew Bresticker val = readl_relaxed(clk_base + SATA_PLL_CFG0); 5173358d2d9SAndrew Bresticker val &= ~SATA_PLL_CFG0_PADPLL_RESET_SWCTL; 5183358d2d9SAndrew Bresticker val |= SATA_PLL_CFG0_PADPLL_USE_LOCKDET | 5193358d2d9SAndrew Bresticker SATA_PLL_CFG0_PADPLL_SLEEP_IDDQ; 5203358d2d9SAndrew Bresticker writel_relaxed(val, clk_base + SATA_PLL_CFG0); 5213358d2d9SAndrew Bresticker } 5223358d2d9SAndrew Bresticker EXPORT_SYMBOL_GPL(tegra210_sata_pll_hw_control_enable); 5233358d2d9SAndrew Bresticker 5243358d2d9SAndrew Bresticker void tegra210_sata_pll_hw_sequence_start(void) 5253358d2d9SAndrew Bresticker { 5263358d2d9SAndrew Bresticker u32 val; 5273358d2d9SAndrew Bresticker 5283358d2d9SAndrew Bresticker val = readl_relaxed(clk_base + SATA_PLL_CFG0); 5293358d2d9SAndrew Bresticker val |= SATA_PLL_CFG0_SEQ_ENABLE; 5303358d2d9SAndrew Bresticker writel_relaxed(val, clk_base + SATA_PLL_CFG0); 5313358d2d9SAndrew Bresticker } 5323358d2d9SAndrew Bresticker EXPORT_SYMBOL_GPL(tegra210_sata_pll_hw_sequence_start); 5333358d2d9SAndrew Bresticker 53459af78d7SPeter De Schrijver void tegra210_set_sata_pll_seq_sw(bool state) 53559af78d7SPeter De Schrijver { 53659af78d7SPeter De Schrijver u32 val; 53759af78d7SPeter De Schrijver 53859af78d7SPeter De Schrijver val = readl_relaxed(clk_base + SATA_PLL_CFG0); 53959af78d7SPeter De Schrijver if (state) { 54059af78d7SPeter De Schrijver val |= SATA_PLL_CFG0_SATA_SEQ_IN_SWCTL; 54159af78d7SPeter De Schrijver val |= SATA_PLL_CFG0_SATA_SEQ_RESET_INPUT_VALUE; 54259af78d7SPeter De Schrijver val |= SATA_PLL_CFG0_SATA_SEQ_LANE_PD_INPUT_VALUE; 54359af78d7SPeter De Schrijver val |= SATA_PLL_CFG0_SATA_SEQ_PADPLL_PD_INPUT_VALUE; 54459af78d7SPeter De Schrijver } else { 54559af78d7SPeter De Schrijver val &= ~SATA_PLL_CFG0_SATA_SEQ_IN_SWCTL; 54659af78d7SPeter De Schrijver val &= ~SATA_PLL_CFG0_SATA_SEQ_RESET_INPUT_VALUE; 54759af78d7SPeter De Schrijver val &= ~SATA_PLL_CFG0_SATA_SEQ_LANE_PD_INPUT_VALUE; 54859af78d7SPeter De Schrijver val &= ~SATA_PLL_CFG0_SATA_SEQ_PADPLL_PD_INPUT_VALUE; 54959af78d7SPeter De Schrijver } 55059af78d7SPeter De Schrijver writel_relaxed(val, clk_base + SATA_PLL_CFG0); 55159af78d7SPeter De Schrijver } 55259af78d7SPeter De Schrijver EXPORT_SYMBOL_GPL(tegra210_set_sata_pll_seq_sw); 55359af78d7SPeter De Schrijver 554e403d005SPeter De Schrijver static void tegra210_generic_mbist_war(struct tegra210_domain_mbist_war *mbist) 555e403d005SPeter De Schrijver { 556e403d005SPeter De Schrijver u32 val; 557e403d005SPeter De Schrijver 558e403d005SPeter De Schrijver val = readl_relaxed(clk_base + mbist->lvl2_offset); 559e403d005SPeter De Schrijver writel_relaxed(val | mbist->lvl2_mask, clk_base + mbist->lvl2_offset); 560e403d005SPeter De Schrijver fence_udelay(1, clk_base); 561e403d005SPeter De Schrijver writel_relaxed(val, clk_base + mbist->lvl2_offset); 562e403d005SPeter De Schrijver fence_udelay(1, clk_base); 563e403d005SPeter De Schrijver } 564e403d005SPeter De Schrijver 565e403d005SPeter De Schrijver static void tegra210_venc_mbist_war(struct tegra210_domain_mbist_war *mbist) 566e403d005SPeter De Schrijver { 567e403d005SPeter De Schrijver u32 csi_src, ovra, ovre; 568e403d005SPeter De Schrijver unsigned long flags = 0; 569e403d005SPeter De Schrijver 570e403d005SPeter De Schrijver spin_lock_irqsave(&pll_d_lock, flags); 571e403d005SPeter De Schrijver 572e403d005SPeter De Schrijver csi_src = readl_relaxed(clk_base + PLLD_BASE); 573e403d005SPeter De Schrijver writel_relaxed(csi_src | PLLD_BASE_CSI_CLKSOURCE, clk_base + PLLD_BASE); 574e403d005SPeter De Schrijver fence_udelay(1, clk_base); 575e403d005SPeter De Schrijver 576e403d005SPeter De Schrijver ovra = readl_relaxed(clk_base + LVL2_CLK_GATE_OVRA); 577e403d005SPeter De Schrijver writel_relaxed(ovra | BIT(15), clk_base + LVL2_CLK_GATE_OVRA); 578e403d005SPeter De Schrijver ovre = readl_relaxed(clk_base + LVL2_CLK_GATE_OVRE); 579e403d005SPeter De Schrijver writel_relaxed(ovre | BIT(3), clk_base + LVL2_CLK_GATE_OVRE); 580e403d005SPeter De Schrijver fence_udelay(1, clk_base); 581e403d005SPeter De Schrijver 582e403d005SPeter De Schrijver writel_relaxed(ovra, clk_base + LVL2_CLK_GATE_OVRA); 583e403d005SPeter De Schrijver writel_relaxed(ovre, clk_base + LVL2_CLK_GATE_OVRE); 584e403d005SPeter De Schrijver writel_relaxed(csi_src, clk_base + PLLD_BASE); 585e403d005SPeter De Schrijver fence_udelay(1, clk_base); 586e403d005SPeter De Schrijver 587e403d005SPeter De Schrijver spin_unlock_irqrestore(&pll_d_lock, flags); 588e403d005SPeter De Schrijver } 589e403d005SPeter De Schrijver 590e403d005SPeter De Schrijver static void tegra210_disp_mbist_war(struct tegra210_domain_mbist_war *mbist) 591e403d005SPeter De Schrijver { 592e403d005SPeter De Schrijver u32 ovra, dsc_top_ctrl; 593e403d005SPeter De Schrijver 594e403d005SPeter De Schrijver ovra = readl_relaxed(clk_base + LVL2_CLK_GATE_OVRA); 595e403d005SPeter De Schrijver writel_relaxed(ovra | BIT(1), clk_base + LVL2_CLK_GATE_OVRA); 596e403d005SPeter De Schrijver fence_udelay(1, clk_base); 597e403d005SPeter De Schrijver 598e403d005SPeter De Schrijver dsc_top_ctrl = readl_relaxed(dispa_base + DC_COM_DSC_TOP_CTL); 599e403d005SPeter De Schrijver writel_relaxed(dsc_top_ctrl | BIT(2), dispa_base + DC_COM_DSC_TOP_CTL); 600e403d005SPeter De Schrijver readl_relaxed(dispa_base + DC_CMD_DISPLAY_COMMAND); 601e403d005SPeter De Schrijver writel_relaxed(dsc_top_ctrl, dispa_base + DC_COM_DSC_TOP_CTL); 602e403d005SPeter De Schrijver readl_relaxed(dispa_base + DC_CMD_DISPLAY_COMMAND); 603e403d005SPeter De Schrijver 604e403d005SPeter De Schrijver writel_relaxed(ovra, clk_base + LVL2_CLK_GATE_OVRA); 605e403d005SPeter De Schrijver fence_udelay(1, clk_base); 606e403d005SPeter De Schrijver } 607e403d005SPeter De Schrijver 608e403d005SPeter De Schrijver static void tegra210_vic_mbist_war(struct tegra210_domain_mbist_war *mbist) 609e403d005SPeter De Schrijver { 610e403d005SPeter De Schrijver u32 ovre, val; 611e403d005SPeter De Schrijver 612e403d005SPeter De Schrijver ovre = readl_relaxed(clk_base + LVL2_CLK_GATE_OVRE); 613e403d005SPeter De Schrijver writel_relaxed(ovre | BIT(5), clk_base + LVL2_CLK_GATE_OVRE); 614e403d005SPeter De Schrijver fence_udelay(1, clk_base); 615e403d005SPeter De Schrijver 616e403d005SPeter De Schrijver val = readl_relaxed(vic_base + NV_PVIC_THI_SLCG_OVERRIDE_LOW); 617e403d005SPeter De Schrijver writel_relaxed(val | BIT(0) | GENMASK(7, 2) | BIT(24), 618e403d005SPeter De Schrijver vic_base + NV_PVIC_THI_SLCG_OVERRIDE_LOW); 619e403d005SPeter De Schrijver fence_udelay(1, vic_base + NV_PVIC_THI_SLCG_OVERRIDE_LOW); 620e403d005SPeter De Schrijver 621e403d005SPeter De Schrijver writel_relaxed(val, vic_base + NV_PVIC_THI_SLCG_OVERRIDE_LOW); 622e403d005SPeter De Schrijver readl(vic_base + NV_PVIC_THI_SLCG_OVERRIDE_LOW); 623e403d005SPeter De Schrijver 624e403d005SPeter De Schrijver writel_relaxed(ovre, clk_base + LVL2_CLK_GATE_OVRE); 625e403d005SPeter De Schrijver fence_udelay(1, clk_base); 626e403d005SPeter De Schrijver } 627e403d005SPeter De Schrijver 628e403d005SPeter De Schrijver static void tegra210_ape_mbist_war(struct tegra210_domain_mbist_war *mbist) 629e403d005SPeter De Schrijver { 630e403d005SPeter De Schrijver void __iomem *i2s_base; 631e403d005SPeter De Schrijver unsigned int i; 632e403d005SPeter De Schrijver u32 ovrc, ovre; 633e403d005SPeter De Schrijver 634e403d005SPeter De Schrijver ovrc = readl_relaxed(clk_base + LVL2_CLK_GATE_OVRC); 635e403d005SPeter De Schrijver ovre = readl_relaxed(clk_base + LVL2_CLK_GATE_OVRE); 636e403d005SPeter De Schrijver writel_relaxed(ovrc | BIT(1), clk_base + LVL2_CLK_GATE_OVRC); 637e403d005SPeter De Schrijver writel_relaxed(ovre | BIT(10) | BIT(11), 638e403d005SPeter De Schrijver clk_base + LVL2_CLK_GATE_OVRE); 639e403d005SPeter De Schrijver fence_udelay(1, clk_base); 640e403d005SPeter De Schrijver 641e403d005SPeter De Schrijver i2s_base = ahub_base + TEGRA210_I2S_BASE; 642e403d005SPeter De Schrijver 643e403d005SPeter De Schrijver for (i = 0; i < TEGRA210_I2S_CTRLS; i++) { 644e403d005SPeter De Schrijver u32 i2s_ctrl; 645e403d005SPeter De Schrijver 646e403d005SPeter De Schrijver i2s_ctrl = readl_relaxed(i2s_base + TEGRA210_I2S_CTRL); 647e403d005SPeter De Schrijver writel_relaxed(i2s_ctrl | BIT(10), 648e403d005SPeter De Schrijver i2s_base + TEGRA210_I2S_CTRL); 649e403d005SPeter De Schrijver writel_relaxed(0, i2s_base + TEGRA210_I2S_CG); 650e403d005SPeter De Schrijver readl(i2s_base + TEGRA210_I2S_CG); 651e403d005SPeter De Schrijver writel_relaxed(1, i2s_base + TEGRA210_I2S_CG); 652e403d005SPeter De Schrijver writel_relaxed(i2s_ctrl, i2s_base + TEGRA210_I2S_CTRL); 653e403d005SPeter De Schrijver readl(i2s_base + TEGRA210_I2S_CTRL); 654e403d005SPeter De Schrijver 655e403d005SPeter De Schrijver i2s_base += TEGRA210_I2S_SIZE; 656e403d005SPeter De Schrijver } 657e403d005SPeter De Schrijver 658e403d005SPeter De Schrijver writel_relaxed(ovrc, clk_base + LVL2_CLK_GATE_OVRC); 659e403d005SPeter De Schrijver writel_relaxed(ovre, clk_base + LVL2_CLK_GATE_OVRE); 660e403d005SPeter De Schrijver fence_udelay(1, clk_base); 661e403d005SPeter De Schrijver } 662e403d005SPeter De Schrijver 6636b301a05SRhyland Klein static inline void _pll_misc_chk_default(void __iomem *base, 6646b301a05SRhyland Klein struct tegra_clk_pll_params *params, 6656b301a05SRhyland Klein u8 misc_num, u32 default_val, u32 mask) 6666b301a05SRhyland Klein { 6676b301a05SRhyland Klein u32 boot_val = readl_relaxed(base + params->ext_misc_reg[misc_num]); 6686b301a05SRhyland Klein 6696b301a05SRhyland Klein boot_val &= mask; 6706b301a05SRhyland Klein default_val &= mask; 6716b301a05SRhyland Klein if (boot_val != default_val) { 6726b301a05SRhyland Klein pr_warn("boot misc%d 0x%x: expected 0x%x\n", 6736b301a05SRhyland Klein misc_num, boot_val, default_val); 6746b301a05SRhyland Klein pr_warn(" (comparison mask = 0x%x)\n", mask); 6756b301a05SRhyland Klein params->defaults_set = false; 6766b301a05SRhyland Klein } 6776b301a05SRhyland Klein } 6786b301a05SRhyland Klein 6796b301a05SRhyland Klein /* 6806b301a05SRhyland Klein * PLLCX: PLLC, PLLC2, PLLC3, PLLA1 6816b301a05SRhyland Klein * Hybrid PLLs with dynamic ramp. Dynamic ramp is allowed for any transition 6826b301a05SRhyland Klein * that changes NDIV only, while PLL is already locked. 6836b301a05SRhyland Klein */ 6846b301a05SRhyland Klein static void pllcx_check_defaults(struct tegra_clk_pll_params *params) 6856b301a05SRhyland Klein { 6866b301a05SRhyland Klein u32 default_val; 6876b301a05SRhyland Klein 6886b301a05SRhyland Klein default_val = PLLCX_MISC0_DEFAULT_VALUE & (~PLLCX_MISC0_RESET); 6896b301a05SRhyland Klein _pll_misc_chk_default(clk_base, params, 0, default_val, 6906b301a05SRhyland Klein PLLCX_MISC0_WRITE_MASK); 6916b301a05SRhyland Klein 6926b301a05SRhyland Klein default_val = PLLCX_MISC1_DEFAULT_VALUE & (~PLLCX_MISC1_IDDQ); 6936b301a05SRhyland Klein _pll_misc_chk_default(clk_base, params, 1, default_val, 6946b301a05SRhyland Klein PLLCX_MISC1_WRITE_MASK); 6956b301a05SRhyland Klein 6966b301a05SRhyland Klein default_val = PLLCX_MISC2_DEFAULT_VALUE; 6976b301a05SRhyland Klein _pll_misc_chk_default(clk_base, params, 2, default_val, 6986b301a05SRhyland Klein PLLCX_MISC2_WRITE_MASK); 6996b301a05SRhyland Klein 7006b301a05SRhyland Klein default_val = PLLCX_MISC3_DEFAULT_VALUE; 7016b301a05SRhyland Klein _pll_misc_chk_default(clk_base, params, 3, default_val, 7026b301a05SRhyland Klein PLLCX_MISC3_WRITE_MASK); 7036b301a05SRhyland Klein } 7046b301a05SRhyland Klein 705fd360e20SJon Hunter static void tegra210_pllcx_set_defaults(const char *name, 706fd360e20SJon Hunter struct tegra_clk_pll *pllcx) 7076b301a05SRhyland Klein { 7086b301a05SRhyland Klein pllcx->params->defaults_set = true; 7096b301a05SRhyland Klein 7101116d5a7SJon Hunter if (readl_relaxed(clk_base + pllcx->params->base_reg) & PLL_ENABLE) { 7116b301a05SRhyland Klein /* PLL is ON: only check if defaults already set */ 7126b301a05SRhyland Klein pllcx_check_defaults(pllcx->params); 7131116d5a7SJon Hunter if (!pllcx->params->defaults_set) 7146b301a05SRhyland Klein pr_warn("%s already enabled. Postponing set full defaults\n", 7156b301a05SRhyland Klein name); 7166b301a05SRhyland Klein return; 7176b301a05SRhyland Klein } 7186b301a05SRhyland Klein 7196b301a05SRhyland Klein /* Defaults assert PLL reset, and set IDDQ */ 7206b301a05SRhyland Klein writel_relaxed(PLLCX_MISC0_DEFAULT_VALUE, 7216b301a05SRhyland Klein clk_base + pllcx->params->ext_misc_reg[0]); 7226b301a05SRhyland Klein writel_relaxed(PLLCX_MISC1_DEFAULT_VALUE, 7236b301a05SRhyland Klein clk_base + pllcx->params->ext_misc_reg[1]); 7246b301a05SRhyland Klein writel_relaxed(PLLCX_MISC2_DEFAULT_VALUE, 7256b301a05SRhyland Klein clk_base + pllcx->params->ext_misc_reg[2]); 7266b301a05SRhyland Klein writel_relaxed(PLLCX_MISC3_DEFAULT_VALUE, 7276b301a05SRhyland Klein clk_base + pllcx->params->ext_misc_reg[3]); 7286b301a05SRhyland Klein udelay(1); 7296b301a05SRhyland Klein } 7306b301a05SRhyland Klein 731fd360e20SJon Hunter static void _pllc_set_defaults(struct tegra_clk_pll *pllcx) 7326b301a05SRhyland Klein { 7336b301a05SRhyland Klein tegra210_pllcx_set_defaults("PLL_C", pllcx); 7346b301a05SRhyland Klein } 7356b301a05SRhyland Klein 736fd360e20SJon Hunter static void _pllc2_set_defaults(struct tegra_clk_pll *pllcx) 7376b301a05SRhyland Klein { 7386b301a05SRhyland Klein tegra210_pllcx_set_defaults("PLL_C2", pllcx); 7396b301a05SRhyland Klein } 7406b301a05SRhyland Klein 741fd360e20SJon Hunter static void _pllc3_set_defaults(struct tegra_clk_pll *pllcx) 7426b301a05SRhyland Klein { 7436b301a05SRhyland Klein tegra210_pllcx_set_defaults("PLL_C3", pllcx); 7446b301a05SRhyland Klein } 7456b301a05SRhyland Klein 746fd360e20SJon Hunter static void _plla1_set_defaults(struct tegra_clk_pll *pllcx) 7476b301a05SRhyland Klein { 7486b301a05SRhyland Klein tegra210_pllcx_set_defaults("PLL_A1", pllcx); 7496b301a05SRhyland Klein } 7506b301a05SRhyland Klein 7516b301a05SRhyland Klein /* 7526b301a05SRhyland Klein * PLLA 7536b301a05SRhyland Klein * PLL with dynamic ramp and fractional SDM. Dynamic ramp is not used. 7546b301a05SRhyland Klein * Fractional SDM is allowed to provide exact audio rates. 7556b301a05SRhyland Klein */ 756fd360e20SJon Hunter static void tegra210_plla_set_defaults(struct tegra_clk_pll *plla) 7576b301a05SRhyland Klein { 7586b301a05SRhyland Klein u32 mask; 7596b301a05SRhyland Klein u32 val = readl_relaxed(clk_base + plla->params->base_reg); 7606b301a05SRhyland Klein 7616b301a05SRhyland Klein plla->params->defaults_set = true; 7626b301a05SRhyland Klein 7636b301a05SRhyland Klein if (val & PLL_ENABLE) { 7646b301a05SRhyland Klein /* 7656b301a05SRhyland Klein * PLL is ON: check if defaults already set, then set those 7666b301a05SRhyland Klein * that can be updated in flight. 7676b301a05SRhyland Klein */ 7686b301a05SRhyland Klein if (val & PLLA_BASE_IDDQ) { 7696b301a05SRhyland Klein pr_warn("PLL_A boot enabled with IDDQ set\n"); 7706b301a05SRhyland Klein plla->params->defaults_set = false; 7716b301a05SRhyland Klein } 7726b301a05SRhyland Klein 7736b301a05SRhyland Klein pr_warn("PLL_A already enabled. Postponing set full defaults\n"); 7746b301a05SRhyland Klein 7756b301a05SRhyland Klein val = PLLA_MISC0_DEFAULT_VALUE; /* ignore lock enable */ 7766b301a05SRhyland Klein mask = PLLA_MISC0_LOCK_ENABLE | PLLA_MISC0_LOCK_OVERRIDE; 7776b301a05SRhyland Klein _pll_misc_chk_default(clk_base, plla->params, 0, val, 7786b301a05SRhyland Klein ~mask & PLLA_MISC0_WRITE_MASK); 7796b301a05SRhyland Klein 7806b301a05SRhyland Klein val = PLLA_MISC2_DEFAULT_VALUE; /* ignore all but control bit */ 7816b301a05SRhyland Klein _pll_misc_chk_default(clk_base, plla->params, 2, val, 7826b301a05SRhyland Klein PLLA_MISC2_EN_DYNRAMP); 7836b301a05SRhyland Klein 7846b301a05SRhyland Klein /* Enable lock detect */ 7856b301a05SRhyland Klein val = readl_relaxed(clk_base + plla->params->ext_misc_reg[0]); 7866b301a05SRhyland Klein val &= ~mask; 7876b301a05SRhyland Klein val |= PLLA_MISC0_DEFAULT_VALUE & mask; 7886b301a05SRhyland Klein writel_relaxed(val, clk_base + plla->params->ext_misc_reg[0]); 7896b301a05SRhyland Klein udelay(1); 7906b301a05SRhyland Klein 7916b301a05SRhyland Klein return; 7926b301a05SRhyland Klein } 7936b301a05SRhyland Klein 7946b301a05SRhyland Klein /* set IDDQ, enable lock detect, disable dynamic ramp and SDM */ 7956b301a05SRhyland Klein val |= PLLA_BASE_IDDQ; 7966b301a05SRhyland Klein writel_relaxed(val, clk_base + plla->params->base_reg); 7976b301a05SRhyland Klein writel_relaxed(PLLA_MISC0_DEFAULT_VALUE, 7986b301a05SRhyland Klein clk_base + plla->params->ext_misc_reg[0]); 7996b301a05SRhyland Klein writel_relaxed(PLLA_MISC2_DEFAULT_VALUE, 8006b301a05SRhyland Klein clk_base + plla->params->ext_misc_reg[2]); 8016b301a05SRhyland Klein udelay(1); 8026b301a05SRhyland Klein } 8036b301a05SRhyland Klein 8046b301a05SRhyland Klein /* 8056b301a05SRhyland Klein * PLLD 8066b301a05SRhyland Klein * PLL with fractional SDM. 8076b301a05SRhyland Klein */ 808fd360e20SJon Hunter static void tegra210_plld_set_defaults(struct tegra_clk_pll *plld) 8096b301a05SRhyland Klein { 8106b301a05SRhyland Klein u32 val; 8116b301a05SRhyland Klein u32 mask = 0xffff; 8126b301a05SRhyland Klein 8136b301a05SRhyland Klein plld->params->defaults_set = true; 8146b301a05SRhyland Klein 8156b301a05SRhyland Klein if (readl_relaxed(clk_base + plld->params->base_reg) & 8166b301a05SRhyland Klein PLL_ENABLE) { 8176b301a05SRhyland Klein 8186b301a05SRhyland Klein /* 8196b301a05SRhyland Klein * PLL is ON: check if defaults already set, then set those 8206b301a05SRhyland Klein * that can be updated in flight. 8216b301a05SRhyland Klein */ 8226b301a05SRhyland Klein val = PLLD_MISC1_DEFAULT_VALUE; 8236b301a05SRhyland Klein _pll_misc_chk_default(clk_base, plld->params, 1, 8246b301a05SRhyland Klein val, PLLD_MISC1_WRITE_MASK); 8256b301a05SRhyland Klein 8266b301a05SRhyland Klein /* ignore lock, DSI and SDM controls, make sure IDDQ not set */ 8276b301a05SRhyland Klein val = PLLD_MISC0_DEFAULT_VALUE & (~PLLD_MISC0_IDDQ); 8286b301a05SRhyland Klein mask |= PLLD_MISC0_DSI_CLKENABLE | PLLD_MISC0_LOCK_ENABLE | 8296b301a05SRhyland Klein PLLD_MISC0_LOCK_OVERRIDE | PLLD_MISC0_EN_SDM; 8306b301a05SRhyland Klein _pll_misc_chk_default(clk_base, plld->params, 0, val, 8316b301a05SRhyland Klein ~mask & PLLD_MISC0_WRITE_MASK); 8326b301a05SRhyland Klein 8338dce89a1SPeter De Schrijver if (!plld->params->defaults_set) 8348dce89a1SPeter De Schrijver pr_warn("PLL_D already enabled. Postponing set full defaults\n"); 8358dce89a1SPeter De Schrijver 8366b301a05SRhyland Klein /* Enable lock detect */ 8376b301a05SRhyland Klein mask = PLLD_MISC0_LOCK_ENABLE | PLLD_MISC0_LOCK_OVERRIDE; 8386b301a05SRhyland Klein val = readl_relaxed(clk_base + plld->params->ext_misc_reg[0]); 8396b301a05SRhyland Klein val &= ~mask; 8406b301a05SRhyland Klein val |= PLLD_MISC0_DEFAULT_VALUE & mask; 8416b301a05SRhyland Klein writel_relaxed(val, clk_base + plld->params->ext_misc_reg[0]); 8426b301a05SRhyland Klein udelay(1); 8436b301a05SRhyland Klein 8446b301a05SRhyland Klein return; 8456b301a05SRhyland Klein } 8466b301a05SRhyland Klein 8476b301a05SRhyland Klein val = readl_relaxed(clk_base + plld->params->ext_misc_reg[0]); 8486b301a05SRhyland Klein val &= PLLD_MISC0_DSI_CLKENABLE; 8496b301a05SRhyland Klein val |= PLLD_MISC0_DEFAULT_VALUE; 8506b301a05SRhyland Klein /* set IDDQ, enable lock detect, disable SDM */ 8516b301a05SRhyland Klein writel_relaxed(val, clk_base + plld->params->ext_misc_reg[0]); 8526b301a05SRhyland Klein writel_relaxed(PLLD_MISC1_DEFAULT_VALUE, clk_base + 8536b301a05SRhyland Klein plld->params->ext_misc_reg[1]); 8546b301a05SRhyland Klein udelay(1); 8556b301a05SRhyland Klein } 8566b301a05SRhyland Klein 8576b301a05SRhyland Klein /* 8586b301a05SRhyland Klein * PLLD2, PLLDP 8596b301a05SRhyland Klein * PLL with fractional SDM and Spread Spectrum (SDM is a must if SSC is used). 8606b301a05SRhyland Klein */ 8616b301a05SRhyland Klein static void plldss_defaults(const char *pll_name, struct tegra_clk_pll *plldss, 8626b301a05SRhyland Klein u32 misc0_val, u32 misc1_val, u32 misc2_val, u32 misc3_val) 8636b301a05SRhyland Klein { 8646b301a05SRhyland Klein u32 default_val; 8656b301a05SRhyland Klein u32 val = readl_relaxed(clk_base + plldss->params->base_reg); 8666b301a05SRhyland Klein 8676b301a05SRhyland Klein plldss->params->defaults_set = true; 8686b301a05SRhyland Klein 8696b301a05SRhyland Klein if (val & PLL_ENABLE) { 8706b301a05SRhyland Klein 8716b301a05SRhyland Klein /* 8726b301a05SRhyland Klein * PLL is ON: check if defaults already set, then set those 8736b301a05SRhyland Klein * that can be updated in flight. 8746b301a05SRhyland Klein */ 8756b301a05SRhyland Klein if (val & PLLDSS_BASE_IDDQ) { 8766b301a05SRhyland Klein pr_warn("plldss boot enabled with IDDQ set\n"); 8776b301a05SRhyland Klein plldss->params->defaults_set = false; 8786b301a05SRhyland Klein } 8796b301a05SRhyland Klein 8806b301a05SRhyland Klein /* ignore lock enable */ 8816b301a05SRhyland Klein default_val = misc0_val; 8826b301a05SRhyland Klein _pll_misc_chk_default(clk_base, plldss->params, 0, default_val, 8836b301a05SRhyland Klein PLLDSS_MISC0_WRITE_MASK & 8846b301a05SRhyland Klein (~PLLDSS_MISC0_LOCK_ENABLE)); 8856b301a05SRhyland Klein 8866b301a05SRhyland Klein /* 8876b301a05SRhyland Klein * If SSC is used, check all settings, otherwise just confirm 8886b301a05SRhyland Klein * that SSC is not used on boot as well. Do nothing when using 8896b301a05SRhyland Klein * this function for PLLC4 that has only MISC0. 8906b301a05SRhyland Klein */ 8916b301a05SRhyland Klein if (plldss->params->ssc_ctrl_en_mask) { 8926b301a05SRhyland Klein default_val = misc1_val; 8936b301a05SRhyland Klein _pll_misc_chk_default(clk_base, plldss->params, 1, 8946b301a05SRhyland Klein default_val, PLLDSS_MISC1_CFG_WRITE_MASK); 8956b301a05SRhyland Klein default_val = misc2_val; 8966b301a05SRhyland Klein _pll_misc_chk_default(clk_base, plldss->params, 2, 8976b301a05SRhyland Klein default_val, PLLDSS_MISC2_CTRL1_WRITE_MASK); 8986b301a05SRhyland Klein default_val = misc3_val; 8996b301a05SRhyland Klein _pll_misc_chk_default(clk_base, plldss->params, 3, 9006b301a05SRhyland Klein default_val, PLLDSS_MISC3_CTRL2_WRITE_MASK); 9016b301a05SRhyland Klein } else if (plldss->params->ext_misc_reg[1]) { 9026b301a05SRhyland Klein default_val = misc1_val; 9036b301a05SRhyland Klein _pll_misc_chk_default(clk_base, plldss->params, 1, 9046b301a05SRhyland Klein default_val, PLLDSS_MISC1_CFG_WRITE_MASK & 9056b301a05SRhyland Klein (~PLLDSS_MISC1_CFG_EN_SDM)); 9066b301a05SRhyland Klein } 9076b301a05SRhyland Klein 9081934ffd0SPeter De Schrijver if (!plldss->params->defaults_set) 9091934ffd0SPeter De Schrijver pr_warn("%s already enabled. Postponing set full defaults\n", 9101934ffd0SPeter De Schrijver pll_name); 9111934ffd0SPeter De Schrijver 9126b301a05SRhyland Klein /* Enable lock detect */ 9136b301a05SRhyland Klein if (val & PLLDSS_BASE_LOCK_OVERRIDE) { 9146b301a05SRhyland Klein val &= ~PLLDSS_BASE_LOCK_OVERRIDE; 9156b301a05SRhyland Klein writel_relaxed(val, clk_base + 9166b301a05SRhyland Klein plldss->params->base_reg); 9176b301a05SRhyland Klein } 9186b301a05SRhyland Klein 9196b301a05SRhyland Klein val = readl_relaxed(clk_base + plldss->params->ext_misc_reg[0]); 9206b301a05SRhyland Klein val &= ~PLLDSS_MISC0_LOCK_ENABLE; 9216b301a05SRhyland Klein val |= misc0_val & PLLDSS_MISC0_LOCK_ENABLE; 9226b301a05SRhyland Klein writel_relaxed(val, clk_base + plldss->params->ext_misc_reg[0]); 9236b301a05SRhyland Klein udelay(1); 9246b301a05SRhyland Klein 9256b301a05SRhyland Klein return; 9266b301a05SRhyland Klein } 9276b301a05SRhyland Klein 9286b301a05SRhyland Klein /* set IDDQ, enable lock detect, configure SDM/SSC */ 9296b301a05SRhyland Klein val |= PLLDSS_BASE_IDDQ; 9306b301a05SRhyland Klein val &= ~PLLDSS_BASE_LOCK_OVERRIDE; 9316b301a05SRhyland Klein writel_relaxed(val, clk_base + plldss->params->base_reg); 9326b301a05SRhyland Klein 9336b301a05SRhyland Klein /* When using this function for PLLC4 exit here */ 9346b301a05SRhyland Klein if (!plldss->params->ext_misc_reg[1]) { 9356b301a05SRhyland Klein writel_relaxed(misc0_val, clk_base + 9366b301a05SRhyland Klein plldss->params->ext_misc_reg[0]); 9376b301a05SRhyland Klein udelay(1); 9386b301a05SRhyland Klein return; 9396b301a05SRhyland Klein } 9406b301a05SRhyland Klein 9416b301a05SRhyland Klein writel_relaxed(misc0_val, clk_base + 9426b301a05SRhyland Klein plldss->params->ext_misc_reg[0]); 9436b301a05SRhyland Klein /* if SSC used set by 1st enable */ 9446b301a05SRhyland Klein writel_relaxed(misc1_val & (~PLLDSS_MISC1_CFG_EN_SSC), 9456b301a05SRhyland Klein clk_base + plldss->params->ext_misc_reg[1]); 9466b301a05SRhyland Klein writel_relaxed(misc2_val, clk_base + plldss->params->ext_misc_reg[2]); 9476b301a05SRhyland Klein writel_relaxed(misc3_val, clk_base + plldss->params->ext_misc_reg[3]); 9486b301a05SRhyland Klein udelay(1); 9496b301a05SRhyland Klein } 9506b301a05SRhyland Klein 951fd360e20SJon Hunter static void tegra210_plld2_set_defaults(struct tegra_clk_pll *plld2) 9526b301a05SRhyland Klein { 9536b301a05SRhyland Klein plldss_defaults("PLL_D2", plld2, PLLD2_MISC0_DEFAULT_VALUE, 9546b301a05SRhyland Klein PLLD2_MISC1_CFG_DEFAULT_VALUE, 9556b301a05SRhyland Klein PLLD2_MISC2_CTRL1_DEFAULT_VALUE, 9566b301a05SRhyland Klein PLLD2_MISC3_CTRL2_DEFAULT_VALUE); 9576b301a05SRhyland Klein } 9586b301a05SRhyland Klein 959fd360e20SJon Hunter static void tegra210_plldp_set_defaults(struct tegra_clk_pll *plldp) 9606b301a05SRhyland Klein { 9616b301a05SRhyland Klein plldss_defaults("PLL_DP", plldp, PLLDP_MISC0_DEFAULT_VALUE, 9626b301a05SRhyland Klein PLLDP_MISC1_CFG_DEFAULT_VALUE, 9636b301a05SRhyland Klein PLLDP_MISC2_CTRL1_DEFAULT_VALUE, 9646b301a05SRhyland Klein PLLDP_MISC3_CTRL2_DEFAULT_VALUE); 9656b301a05SRhyland Klein } 9666b301a05SRhyland Klein 9676b301a05SRhyland Klein /* 9686b301a05SRhyland Klein * PLLC4 9696b301a05SRhyland Klein * Base and misc0 layout is the same as PLLD2/PLLDP, but no SDM/SSC support. 9706b301a05SRhyland Klein * VCO is exposed to the clock tree via fixed 1/3 and 1/5 dividers. 9716b301a05SRhyland Klein */ 972fd360e20SJon Hunter static void tegra210_pllc4_set_defaults(struct tegra_clk_pll *pllc4) 9736b301a05SRhyland Klein { 9746b301a05SRhyland Klein plldss_defaults("PLL_C4", pllc4, PLLC4_MISC0_DEFAULT_VALUE, 0, 0, 0); 9756b301a05SRhyland Klein } 9766b301a05SRhyland Klein 9776b301a05SRhyland Klein /* 9786b301a05SRhyland Klein * PLLRE 9796b301a05SRhyland Klein * VCO is exposed to the clock tree directly along with post-divider output 9806b301a05SRhyland Klein */ 981fd360e20SJon Hunter static void tegra210_pllre_set_defaults(struct tegra_clk_pll *pllre) 9826b301a05SRhyland Klein { 9836b301a05SRhyland Klein u32 mask; 9846b301a05SRhyland Klein u32 val = readl_relaxed(clk_base + pllre->params->base_reg); 9856b301a05SRhyland Klein 9866b301a05SRhyland Klein pllre->params->defaults_set = true; 9876b301a05SRhyland Klein 9886b301a05SRhyland Klein if (val & PLL_ENABLE) { 9896b301a05SRhyland Klein /* 9906b301a05SRhyland Klein * PLL is ON: check if defaults already set, then set those 9916b301a05SRhyland Klein * that can be updated in flight. 9926b301a05SRhyland Klein */ 9936b301a05SRhyland Klein val &= PLLRE_BASE_DEFAULT_MASK; 9946b301a05SRhyland Klein if (val != PLLRE_BASE_DEFAULT_VALUE) { 9956b301a05SRhyland Klein pr_warn("pllre boot base 0x%x : expected 0x%x\n", 9966b301a05SRhyland Klein val, PLLRE_BASE_DEFAULT_VALUE); 9976b301a05SRhyland Klein pr_warn("(comparison mask = 0x%x)\n", 9986b301a05SRhyland Klein PLLRE_BASE_DEFAULT_MASK); 9996b301a05SRhyland Klein pllre->params->defaults_set = false; 10006b301a05SRhyland Klein } 10016b301a05SRhyland Klein 10026b301a05SRhyland Klein /* Ignore lock enable */ 10036b301a05SRhyland Klein val = PLLRE_MISC0_DEFAULT_VALUE & (~PLLRE_MISC0_IDDQ); 10046b301a05SRhyland Klein mask = PLLRE_MISC0_LOCK_ENABLE | PLLRE_MISC0_LOCK_OVERRIDE; 10056b301a05SRhyland Klein _pll_misc_chk_default(clk_base, pllre->params, 0, val, 10066b301a05SRhyland Klein ~mask & PLLRE_MISC0_WRITE_MASK); 10076b301a05SRhyland Klein 1008c1139d20SThierry Reding /* The PLL doesn't work if it's in IDDQ. */ 10096b301a05SRhyland Klein val = readl_relaxed(clk_base + pllre->params->ext_misc_reg[0]); 1010c1139d20SThierry Reding if (val & PLLRE_MISC0_IDDQ) 1011c1139d20SThierry Reding pr_warn("unexpected IDDQ bit set for enabled clock\n"); 1012c1139d20SThierry Reding 1013c1139d20SThierry Reding /* Enable lock detect */ 10146b301a05SRhyland Klein val &= ~mask; 10156b301a05SRhyland Klein val |= PLLRE_MISC0_DEFAULT_VALUE & mask; 10166b301a05SRhyland Klein writel_relaxed(val, clk_base + pllre->params->ext_misc_reg[0]); 10176b301a05SRhyland Klein udelay(1); 10186b301a05SRhyland Klein 101920675070SThierry Reding if (!pllre->params->defaults_set) 102020675070SThierry Reding pr_warn("PLL_RE already enabled. Postponing set full defaults\n"); 102120675070SThierry Reding 10226b301a05SRhyland Klein return; 10236b301a05SRhyland Klein } 10246b301a05SRhyland Klein 10256b301a05SRhyland Klein /* set IDDQ, enable lock detect */ 10266b301a05SRhyland Klein val &= ~PLLRE_BASE_DEFAULT_MASK; 10276b301a05SRhyland Klein val |= PLLRE_BASE_DEFAULT_VALUE & PLLRE_BASE_DEFAULT_MASK; 10286b301a05SRhyland Klein writel_relaxed(val, clk_base + pllre->params->base_reg); 10296b301a05SRhyland Klein writel_relaxed(PLLRE_MISC0_DEFAULT_VALUE, 10306b301a05SRhyland Klein clk_base + pllre->params->ext_misc_reg[0]); 10316b301a05SRhyland Klein udelay(1); 10326b301a05SRhyland Klein } 10336b301a05SRhyland Klein 10346b301a05SRhyland Klein static void pllx_get_dyn_steps(struct clk_hw *hw, u32 *step_a, u32 *step_b) 10356b301a05SRhyland Klein { 10366b301a05SRhyland Klein unsigned long input_rate; 10376b301a05SRhyland Klein 10386b301a05SRhyland Klein /* cf rate */ 10393dad5c5fSRhyland Klein if (!IS_ERR_OR_NULL(hw->clk)) 10403dad5c5fSRhyland Klein input_rate = clk_hw_get_rate(clk_hw_get_parent(hw)); 10413dad5c5fSRhyland Klein else 10426b301a05SRhyland Klein input_rate = 38400000; 10433dad5c5fSRhyland Klein 10443dad5c5fSRhyland Klein input_rate /= tegra_pll_get_fixed_mdiv(hw, input_rate); 10456b301a05SRhyland Klein 10466b301a05SRhyland Klein switch (input_rate) { 10476b301a05SRhyland Klein case 12000000: 10486b301a05SRhyland Klein case 12800000: 10496b301a05SRhyland Klein case 13000000: 10506b301a05SRhyland Klein *step_a = 0x2B; 10516b301a05SRhyland Klein *step_b = 0x0B; 10526b301a05SRhyland Klein return; 10536b301a05SRhyland Klein case 19200000: 10546b301a05SRhyland Klein *step_a = 0x12; 10556b301a05SRhyland Klein *step_b = 0x08; 10566b301a05SRhyland Klein return; 10576b301a05SRhyland Klein case 38400000: 10586b301a05SRhyland Klein *step_a = 0x04; 10596b301a05SRhyland Klein *step_b = 0x05; 10606b301a05SRhyland Klein return; 10616b301a05SRhyland Klein default: 10626b301a05SRhyland Klein pr_err("%s: Unexpected reference rate %lu\n", 10636b301a05SRhyland Klein __func__, input_rate); 10646b301a05SRhyland Klein BUG(); 10656b301a05SRhyland Klein } 10666b301a05SRhyland Klein } 10676b301a05SRhyland Klein 10686b301a05SRhyland Klein static void pllx_check_defaults(struct tegra_clk_pll *pll) 10696b301a05SRhyland Klein { 10706b301a05SRhyland Klein u32 default_val; 10716b301a05SRhyland Klein 10726b301a05SRhyland Klein default_val = PLLX_MISC0_DEFAULT_VALUE; 10736b301a05SRhyland Klein /* ignore lock enable */ 10746b301a05SRhyland Klein _pll_misc_chk_default(clk_base, pll->params, 0, default_val, 10756b301a05SRhyland Klein PLLX_MISC0_WRITE_MASK & (~PLLX_MISC0_LOCK_ENABLE)); 10766b301a05SRhyland Klein 10776b301a05SRhyland Klein default_val = PLLX_MISC1_DEFAULT_VALUE; 10786b301a05SRhyland Klein _pll_misc_chk_default(clk_base, pll->params, 1, default_val, 10796b301a05SRhyland Klein PLLX_MISC1_WRITE_MASK); 10806b301a05SRhyland Klein 10816b301a05SRhyland Klein /* ignore all but control bit */ 10826b301a05SRhyland Klein default_val = PLLX_MISC2_DEFAULT_VALUE; 10836b301a05SRhyland Klein _pll_misc_chk_default(clk_base, pll->params, 2, 10846b301a05SRhyland Klein default_val, PLLX_MISC2_EN_DYNRAMP); 10856b301a05SRhyland Klein 10866b301a05SRhyland Klein default_val = PLLX_MISC3_DEFAULT_VALUE & (~PLLX_MISC3_IDDQ); 10876b301a05SRhyland Klein _pll_misc_chk_default(clk_base, pll->params, 3, default_val, 10886b301a05SRhyland Klein PLLX_MISC3_WRITE_MASK); 10896b301a05SRhyland Klein 10906b301a05SRhyland Klein default_val = PLLX_MISC4_DEFAULT_VALUE; 10916b301a05SRhyland Klein _pll_misc_chk_default(clk_base, pll->params, 4, default_val, 10926b301a05SRhyland Klein PLLX_MISC4_WRITE_MASK); 10936b301a05SRhyland Klein 10946b301a05SRhyland Klein default_val = PLLX_MISC5_DEFAULT_VALUE; 10956b301a05SRhyland Klein _pll_misc_chk_default(clk_base, pll->params, 5, default_val, 10966b301a05SRhyland Klein PLLX_MISC5_WRITE_MASK); 10976b301a05SRhyland Klein } 10986b301a05SRhyland Klein 1099fd360e20SJon Hunter static void tegra210_pllx_set_defaults(struct tegra_clk_pll *pllx) 11006b301a05SRhyland Klein { 11016b301a05SRhyland Klein u32 val; 11026b301a05SRhyland Klein u32 step_a, step_b; 11036b301a05SRhyland Klein 11046b301a05SRhyland Klein pllx->params->defaults_set = true; 11056b301a05SRhyland Klein 11066b301a05SRhyland Klein /* Get ready dyn ramp state machine settings */ 11076b301a05SRhyland Klein pllx_get_dyn_steps(&pllx->hw, &step_a, &step_b); 11086b301a05SRhyland Klein val = PLLX_MISC2_DEFAULT_VALUE & (~PLLX_MISC2_DYNRAMP_STEPA_MASK) & 11096b301a05SRhyland Klein (~PLLX_MISC2_DYNRAMP_STEPB_MASK); 11106b301a05SRhyland Klein val |= step_a << PLLX_MISC2_DYNRAMP_STEPA_SHIFT; 11116b301a05SRhyland Klein val |= step_b << PLLX_MISC2_DYNRAMP_STEPB_SHIFT; 11126b301a05SRhyland Klein 11136b301a05SRhyland Klein if (readl_relaxed(clk_base + pllx->params->base_reg) & PLL_ENABLE) { 11146b301a05SRhyland Klein 11156b301a05SRhyland Klein /* 11166b301a05SRhyland Klein * PLL is ON: check if defaults already set, then set those 11176b301a05SRhyland Klein * that can be updated in flight. 11186b301a05SRhyland Klein */ 11196b301a05SRhyland Klein pllx_check_defaults(pllx); 11206b301a05SRhyland Klein 11218dce89a1SPeter De Schrijver if (!pllx->params->defaults_set) 11228dce89a1SPeter De Schrijver pr_warn("PLL_X already enabled. Postponing set full defaults\n"); 11236b301a05SRhyland Klein /* Configure dyn ramp, disable lock override */ 11246b301a05SRhyland Klein writel_relaxed(val, clk_base + pllx->params->ext_misc_reg[2]); 11256b301a05SRhyland Klein 11266b301a05SRhyland Klein /* Enable lock detect */ 11276b301a05SRhyland Klein val = readl_relaxed(clk_base + pllx->params->ext_misc_reg[0]); 11286b301a05SRhyland Klein val &= ~PLLX_MISC0_LOCK_ENABLE; 11296b301a05SRhyland Klein val |= PLLX_MISC0_DEFAULT_VALUE & PLLX_MISC0_LOCK_ENABLE; 11306b301a05SRhyland Klein writel_relaxed(val, clk_base + pllx->params->ext_misc_reg[0]); 11316b301a05SRhyland Klein udelay(1); 11326b301a05SRhyland Klein 11336b301a05SRhyland Klein return; 11346b301a05SRhyland Klein } 11356b301a05SRhyland Klein 11366b301a05SRhyland Klein /* Enable lock detect and CPU output */ 11376b301a05SRhyland Klein writel_relaxed(PLLX_MISC0_DEFAULT_VALUE, clk_base + 11386b301a05SRhyland Klein pllx->params->ext_misc_reg[0]); 11396b301a05SRhyland Klein 11406b301a05SRhyland Klein /* Setup */ 11416b301a05SRhyland Klein writel_relaxed(PLLX_MISC1_DEFAULT_VALUE, clk_base + 11426b301a05SRhyland Klein pllx->params->ext_misc_reg[1]); 11436b301a05SRhyland Klein 11446b301a05SRhyland Klein /* Configure dyn ramp state machine, disable lock override */ 11456b301a05SRhyland Klein writel_relaxed(val, clk_base + pllx->params->ext_misc_reg[2]); 11466b301a05SRhyland Klein 11476b301a05SRhyland Klein /* Set IDDQ */ 11486b301a05SRhyland Klein writel_relaxed(PLLX_MISC3_DEFAULT_VALUE, clk_base + 11496b301a05SRhyland Klein pllx->params->ext_misc_reg[3]); 11506b301a05SRhyland Klein 11516b301a05SRhyland Klein /* Disable SDM */ 11526b301a05SRhyland Klein writel_relaxed(PLLX_MISC4_DEFAULT_VALUE, clk_base + 11536b301a05SRhyland Klein pllx->params->ext_misc_reg[4]); 11546b301a05SRhyland Klein writel_relaxed(PLLX_MISC5_DEFAULT_VALUE, clk_base + 11556b301a05SRhyland Klein pllx->params->ext_misc_reg[5]); 11566b301a05SRhyland Klein udelay(1); 11576b301a05SRhyland Klein } 11586b301a05SRhyland Klein 11596b301a05SRhyland Klein /* PLLMB */ 1160fd360e20SJon Hunter static void tegra210_pllmb_set_defaults(struct tegra_clk_pll *pllmb) 11616b301a05SRhyland Klein { 11626b301a05SRhyland Klein u32 mask, val = readl_relaxed(clk_base + pllmb->params->base_reg); 11636b301a05SRhyland Klein 11646b301a05SRhyland Klein pllmb->params->defaults_set = true; 11656b301a05SRhyland Klein 11666b301a05SRhyland Klein if (val & PLL_ENABLE) { 11676b301a05SRhyland Klein 11686b301a05SRhyland Klein /* 11696b301a05SRhyland Klein * PLL is ON: check if defaults already set, then set those 11706b301a05SRhyland Klein * that can be updated in flight. 11716b301a05SRhyland Klein */ 1172474f2ba2SRhyland Klein val = PLLMB_MISC1_DEFAULT_VALUE & (~PLLMB_MISC1_IDDQ); 1173474f2ba2SRhyland Klein mask = PLLMB_MISC1_LOCK_ENABLE | PLLMB_MISC1_LOCK_OVERRIDE; 11746b301a05SRhyland Klein _pll_misc_chk_default(clk_base, pllmb->params, 0, val, 1175474f2ba2SRhyland Klein ~mask & PLLMB_MISC1_WRITE_MASK); 11766b301a05SRhyland Klein 11778dce89a1SPeter De Schrijver if (!pllmb->params->defaults_set) 11788dce89a1SPeter De Schrijver pr_warn("PLL_MB already enabled. Postponing set full defaults\n"); 11796b301a05SRhyland Klein /* Enable lock detect */ 11806b301a05SRhyland Klein val = readl_relaxed(clk_base + pllmb->params->ext_misc_reg[0]); 11816b301a05SRhyland Klein val &= ~mask; 1182474f2ba2SRhyland Klein val |= PLLMB_MISC1_DEFAULT_VALUE & mask; 11836b301a05SRhyland Klein writel_relaxed(val, clk_base + pllmb->params->ext_misc_reg[0]); 11846b301a05SRhyland Klein udelay(1); 11856b301a05SRhyland Klein 11866b301a05SRhyland Klein return; 11876b301a05SRhyland Klein } 11886b301a05SRhyland Klein 11896b301a05SRhyland Klein /* set IDDQ, enable lock detect */ 1190474f2ba2SRhyland Klein writel_relaxed(PLLMB_MISC1_DEFAULT_VALUE, 11916b301a05SRhyland Klein clk_base + pllmb->params->ext_misc_reg[0]); 11926b301a05SRhyland Klein udelay(1); 11936b301a05SRhyland Klein } 11946b301a05SRhyland Klein 11956b301a05SRhyland Klein /* 11966b301a05SRhyland Klein * PLLP 11976b301a05SRhyland Klein * VCO is exposed to the clock tree directly along with post-divider output. 11986b301a05SRhyland Klein * Both VCO and post-divider output rates are fixed at 408MHz and 204MHz, 11996b301a05SRhyland Klein * respectively. 12006b301a05SRhyland Klein */ 12016b301a05SRhyland Klein static void pllp_check_defaults(struct tegra_clk_pll *pll, bool enabled) 12026b301a05SRhyland Klein { 12036b301a05SRhyland Klein u32 val, mask; 12046b301a05SRhyland Klein 12056b301a05SRhyland Klein /* Ignore lock enable (will be set), make sure not in IDDQ if enabled */ 12066b301a05SRhyland Klein val = PLLP_MISC0_DEFAULT_VALUE & (~PLLP_MISC0_IDDQ); 12076b301a05SRhyland Klein mask = PLLP_MISC0_LOCK_ENABLE | PLLP_MISC0_LOCK_OVERRIDE; 12086b301a05SRhyland Klein if (!enabled) 12096b301a05SRhyland Klein mask |= PLLP_MISC0_IDDQ; 12106b301a05SRhyland Klein _pll_misc_chk_default(clk_base, pll->params, 0, val, 12116b301a05SRhyland Klein ~mask & PLLP_MISC0_WRITE_MASK); 12126b301a05SRhyland Klein 12136b301a05SRhyland Klein /* Ignore branch controls */ 12146b301a05SRhyland Klein val = PLLP_MISC1_DEFAULT_VALUE; 12156b301a05SRhyland Klein mask = PLLP_MISC1_HSIO_EN | PLLP_MISC1_XUSB_EN; 12166b301a05SRhyland Klein _pll_misc_chk_default(clk_base, pll->params, 1, val, 12176b301a05SRhyland Klein ~mask & PLLP_MISC1_WRITE_MASK); 12186b301a05SRhyland Klein } 12196b301a05SRhyland Klein 1220fd360e20SJon Hunter static void tegra210_pllp_set_defaults(struct tegra_clk_pll *pllp) 12216b301a05SRhyland Klein { 12226b301a05SRhyland Klein u32 mask; 12236b301a05SRhyland Klein u32 val = readl_relaxed(clk_base + pllp->params->base_reg); 12246b301a05SRhyland Klein 12256b301a05SRhyland Klein pllp->params->defaults_set = true; 12266b301a05SRhyland Klein 12276b301a05SRhyland Klein if (val & PLL_ENABLE) { 12286b301a05SRhyland Klein 12296b301a05SRhyland Klein /* 12306b301a05SRhyland Klein * PLL is ON: check if defaults already set, then set those 12316b301a05SRhyland Klein * that can be updated in flight. 12326b301a05SRhyland Klein */ 12336b301a05SRhyland Klein pllp_check_defaults(pllp, true); 12348dce89a1SPeter De Schrijver if (!pllp->params->defaults_set) 12358dce89a1SPeter De Schrijver pr_warn("PLL_P already enabled. Postponing set full defaults\n"); 12366b301a05SRhyland Klein 12376b301a05SRhyland Klein /* Enable lock detect */ 12386b301a05SRhyland Klein val = readl_relaxed(clk_base + pllp->params->ext_misc_reg[0]); 12396b301a05SRhyland Klein mask = PLLP_MISC0_LOCK_ENABLE | PLLP_MISC0_LOCK_OVERRIDE; 12406b301a05SRhyland Klein val &= ~mask; 12416b301a05SRhyland Klein val |= PLLP_MISC0_DEFAULT_VALUE & mask; 12426b301a05SRhyland Klein writel_relaxed(val, clk_base + pllp->params->ext_misc_reg[0]); 12436b301a05SRhyland Klein udelay(1); 12446b301a05SRhyland Klein 12456b301a05SRhyland Klein return; 12466b301a05SRhyland Klein } 12476b301a05SRhyland Klein 12486b301a05SRhyland Klein /* set IDDQ, enable lock detect */ 12496b301a05SRhyland Klein writel_relaxed(PLLP_MISC0_DEFAULT_VALUE, 12506b301a05SRhyland Klein clk_base + pllp->params->ext_misc_reg[0]); 12516b301a05SRhyland Klein 12526b301a05SRhyland Klein /* Preserve branch control */ 12536b301a05SRhyland Klein val = readl_relaxed(clk_base + pllp->params->ext_misc_reg[1]); 12546b301a05SRhyland Klein mask = PLLP_MISC1_HSIO_EN | PLLP_MISC1_XUSB_EN; 12556b301a05SRhyland Klein val &= mask; 12566b301a05SRhyland Klein val |= ~mask & PLLP_MISC1_DEFAULT_VALUE; 12576b301a05SRhyland Klein writel_relaxed(val, clk_base + pllp->params->ext_misc_reg[1]); 12586b301a05SRhyland Klein udelay(1); 12596b301a05SRhyland Klein } 12606b301a05SRhyland Klein 12616b301a05SRhyland Klein /* 12626b301a05SRhyland Klein * PLLU 12636b301a05SRhyland Klein * VCO is exposed to the clock tree directly along with post-divider output. 12646b301a05SRhyland Klein * Both VCO and post-divider output rates are fixed at 480MHz and 240MHz, 12656b301a05SRhyland Klein * respectively. 12666b301a05SRhyland Klein */ 1267e745f992SPeter De Schrijver static void pllu_check_defaults(struct tegra_clk_pll_params *params, 1268e745f992SPeter De Schrijver bool hw_control) 12696b301a05SRhyland Klein { 12706b301a05SRhyland Klein u32 val, mask; 12716b301a05SRhyland Klein 12726b301a05SRhyland Klein /* Ignore lock enable (will be set) and IDDQ if under h/w control */ 12736b301a05SRhyland Klein val = PLLU_MISC0_DEFAULT_VALUE & (~PLLU_MISC0_IDDQ); 12746b301a05SRhyland Klein mask = PLLU_MISC0_LOCK_ENABLE | (hw_control ? PLLU_MISC0_IDDQ : 0); 1275e745f992SPeter De Schrijver _pll_misc_chk_default(clk_base, params, 0, val, 12766b301a05SRhyland Klein ~mask & PLLU_MISC0_WRITE_MASK); 12776b301a05SRhyland Klein 12786b301a05SRhyland Klein val = PLLU_MISC1_DEFAULT_VALUE; 12796b301a05SRhyland Klein mask = PLLU_MISC1_LOCK_OVERRIDE; 1280e745f992SPeter De Schrijver _pll_misc_chk_default(clk_base, params, 1, val, 12816b301a05SRhyland Klein ~mask & PLLU_MISC1_WRITE_MASK); 12826b301a05SRhyland Klein } 12836b301a05SRhyland Klein 1284e745f992SPeter De Schrijver static void tegra210_pllu_set_defaults(struct tegra_clk_pll_params *pllu) 12856b301a05SRhyland Klein { 1286e745f992SPeter De Schrijver u32 val = readl_relaxed(clk_base + pllu->base_reg); 12876b301a05SRhyland Klein 1288e745f992SPeter De Schrijver pllu->defaults_set = true; 12896b301a05SRhyland Klein 12906b301a05SRhyland Klein if (val & PLL_ENABLE) { 12916b301a05SRhyland Klein 12926b301a05SRhyland Klein /* 12936b301a05SRhyland Klein * PLL is ON: check if defaults already set, then set those 12946b301a05SRhyland Klein * that can be updated in flight. 12956b301a05SRhyland Klein */ 12966b301a05SRhyland Klein pllu_check_defaults(pllu, false); 1297e745f992SPeter De Schrijver if (!pllu->defaults_set) 12988dce89a1SPeter De Schrijver pr_warn("PLL_U already enabled. Postponing set full defaults\n"); 12996b301a05SRhyland Klein 13006b301a05SRhyland Klein /* Enable lock detect */ 1301e745f992SPeter De Schrijver val = readl_relaxed(clk_base + pllu->ext_misc_reg[0]); 13026b301a05SRhyland Klein val &= ~PLLU_MISC0_LOCK_ENABLE; 13036b301a05SRhyland Klein val |= PLLU_MISC0_DEFAULT_VALUE & PLLU_MISC0_LOCK_ENABLE; 1304e745f992SPeter De Schrijver writel_relaxed(val, clk_base + pllu->ext_misc_reg[0]); 13056b301a05SRhyland Klein 1306e745f992SPeter De Schrijver val = readl_relaxed(clk_base + pllu->ext_misc_reg[1]); 13076b301a05SRhyland Klein val &= ~PLLU_MISC1_LOCK_OVERRIDE; 13086b301a05SRhyland Klein val |= PLLU_MISC1_DEFAULT_VALUE & PLLU_MISC1_LOCK_OVERRIDE; 1309e745f992SPeter De Schrijver writel_relaxed(val, clk_base + pllu->ext_misc_reg[1]); 13106b301a05SRhyland Klein udelay(1); 13116b301a05SRhyland Klein 13126b301a05SRhyland Klein return; 13136b301a05SRhyland Klein } 13146b301a05SRhyland Klein 13156b301a05SRhyland Klein /* set IDDQ, enable lock detect */ 13166b301a05SRhyland Klein writel_relaxed(PLLU_MISC0_DEFAULT_VALUE, 1317e745f992SPeter De Schrijver clk_base + pllu->ext_misc_reg[0]); 13186b301a05SRhyland Klein writel_relaxed(PLLU_MISC1_DEFAULT_VALUE, 1319e745f992SPeter De Schrijver clk_base + pllu->ext_misc_reg[1]); 13206b301a05SRhyland Klein udelay(1); 13216b301a05SRhyland Klein } 13226b301a05SRhyland Klein 13236b301a05SRhyland Klein #define mask(w) ((1 << (w)) - 1) 13246b301a05SRhyland Klein #define divm_mask(p) mask(p->params->div_nmp->divm_width) 13256b301a05SRhyland Klein #define divn_mask(p) mask(p->params->div_nmp->divn_width) 13266b301a05SRhyland Klein #define divp_mask(p) (p->params->flags & TEGRA_PLLU ? PLLU_POST_DIVP_MASK :\ 13276b301a05SRhyland Klein mask(p->params->div_nmp->divp_width)) 13286b301a05SRhyland Klein 13296b301a05SRhyland Klein #define divm_shift(p) ((p)->params->div_nmp->divm_shift) 13306b301a05SRhyland Klein #define divn_shift(p) ((p)->params->div_nmp->divn_shift) 13316b301a05SRhyland Klein #define divp_shift(p) ((p)->params->div_nmp->divp_shift) 13326b301a05SRhyland Klein 13336b301a05SRhyland Klein #define divm_mask_shifted(p) (divm_mask(p) << divm_shift(p)) 13346b301a05SRhyland Klein #define divn_mask_shifted(p) (divn_mask(p) << divn_shift(p)) 13356b301a05SRhyland Klein #define divp_mask_shifted(p) (divp_mask(p) << divp_shift(p)) 13366b301a05SRhyland Klein 13376b301a05SRhyland Klein #define PLL_LOCKDET_DELAY 2 /* Lock detection safety delays */ 13386b301a05SRhyland Klein static int tegra210_wait_for_mask(struct tegra_clk_pll *pll, 13396b301a05SRhyland Klein u32 reg, u32 mask) 13406b301a05SRhyland Klein { 13416b301a05SRhyland Klein int i; 13426b301a05SRhyland Klein u32 val = 0; 13436b301a05SRhyland Klein 13446b301a05SRhyland Klein for (i = 0; i < pll->params->lock_delay / PLL_LOCKDET_DELAY + 1; i++) { 13456b301a05SRhyland Klein udelay(PLL_LOCKDET_DELAY); 13466b301a05SRhyland Klein val = readl_relaxed(clk_base + reg); 13476b301a05SRhyland Klein if ((val & mask) == mask) { 13486b301a05SRhyland Klein udelay(PLL_LOCKDET_DELAY); 13496b301a05SRhyland Klein return 0; 13506b301a05SRhyland Klein } 13516b301a05SRhyland Klein } 13526b301a05SRhyland Klein return -ETIMEDOUT; 13536b301a05SRhyland Klein } 13546b301a05SRhyland Klein 13556b301a05SRhyland Klein static int tegra210_pllx_dyn_ramp(struct tegra_clk_pll *pllx, 13566b301a05SRhyland Klein struct tegra_clk_pll_freq_table *cfg) 13576b301a05SRhyland Klein { 13586b301a05SRhyland Klein u32 val, base, ndiv_new_mask; 13596b301a05SRhyland Klein 13606b301a05SRhyland Klein ndiv_new_mask = (divn_mask(pllx) >> pllx->params->div_nmp->divn_shift) 13616b301a05SRhyland Klein << PLLX_MISC2_NDIV_NEW_SHIFT; 13626b301a05SRhyland Klein 13636b301a05SRhyland Klein val = readl_relaxed(clk_base + pllx->params->ext_misc_reg[2]); 13646b301a05SRhyland Klein val &= (~ndiv_new_mask); 13656b301a05SRhyland Klein val |= cfg->n << PLLX_MISC2_NDIV_NEW_SHIFT; 13666b301a05SRhyland Klein writel_relaxed(val, clk_base + pllx->params->ext_misc_reg[2]); 13676b301a05SRhyland Klein udelay(1); 13686b301a05SRhyland Klein 13696b301a05SRhyland Klein val = readl_relaxed(clk_base + pllx->params->ext_misc_reg[2]); 13706b301a05SRhyland Klein val |= PLLX_MISC2_EN_DYNRAMP; 13716b301a05SRhyland Klein writel_relaxed(val, clk_base + pllx->params->ext_misc_reg[2]); 13726b301a05SRhyland Klein udelay(1); 13736b301a05SRhyland Klein 13746b301a05SRhyland Klein tegra210_wait_for_mask(pllx, pllx->params->ext_misc_reg[2], 13756b301a05SRhyland Klein PLLX_MISC2_DYNRAMP_DONE); 13766b301a05SRhyland Klein 13776b301a05SRhyland Klein base = readl_relaxed(clk_base + pllx->params->base_reg) & 13786b301a05SRhyland Klein (~divn_mask_shifted(pllx)); 13796b301a05SRhyland Klein base |= cfg->n << pllx->params->div_nmp->divn_shift; 13806b301a05SRhyland Klein writel_relaxed(base, clk_base + pllx->params->base_reg); 13816b301a05SRhyland Klein udelay(1); 13826b301a05SRhyland Klein 13836b301a05SRhyland Klein val &= ~PLLX_MISC2_EN_DYNRAMP; 13846b301a05SRhyland Klein writel_relaxed(val, clk_base + pllx->params->ext_misc_reg[2]); 13856b301a05SRhyland Klein udelay(1); 13866b301a05SRhyland Klein 13876b301a05SRhyland Klein pr_debug("%s: dynamic ramp to m = %u n = %u p = %u, Fout = %lu kHz\n", 13886b301a05SRhyland Klein __clk_get_name(pllx->hw.clk), cfg->m, cfg->n, cfg->p, 13896b301a05SRhyland Klein cfg->input_rate / cfg->m * cfg->n / 13906b301a05SRhyland Klein pllx->params->pdiv_tohw[cfg->p].pdiv / 1000); 13916b301a05SRhyland Klein 13926b301a05SRhyland Klein return 0; 13936b301a05SRhyland Klein } 13946b301a05SRhyland Klein 13956b301a05SRhyland Klein /* 13966b301a05SRhyland Klein * Common configuration for PLLs with fixed input divider policy: 13976b301a05SRhyland Klein * - always set fixed M-value based on the reference rate 13986b301a05SRhyland Klein * - always set P-value value 1:1 for output rates above VCO minimum, and 13996b301a05SRhyland Klein * choose minimum necessary P-value for output rates below VCO maximum 14006b301a05SRhyland Klein * - calculate N-value based on selected M and P 14016b301a05SRhyland Klein * - calculate SDM_DIN fractional part 14026b301a05SRhyland Klein */ 14036b301a05SRhyland Klein static int tegra210_pll_fixed_mdiv_cfg(struct clk_hw *hw, 14046b301a05SRhyland Klein struct tegra_clk_pll_freq_table *cfg, 14056b301a05SRhyland Klein unsigned long rate, unsigned long input_rate) 14066b301a05SRhyland Klein { 14076b301a05SRhyland Klein struct tegra_clk_pll *pll = to_clk_pll(hw); 14086b301a05SRhyland Klein struct tegra_clk_pll_params *params = pll->params; 14096b301a05SRhyland Klein int p; 14106b301a05SRhyland Klein unsigned long cf, p_rate; 14116b301a05SRhyland Klein u32 pdiv; 14126b301a05SRhyland Klein 14136b301a05SRhyland Klein if (!rate) 14146b301a05SRhyland Klein return -EINVAL; 14156b301a05SRhyland Klein 14166b301a05SRhyland Klein if (!(params->flags & TEGRA_PLL_VCO_OUT)) { 14176b301a05SRhyland Klein p = DIV_ROUND_UP(params->vco_min, rate); 14186b301a05SRhyland Klein p = params->round_p_to_pdiv(p, &pdiv); 14196b301a05SRhyland Klein } else { 14206b301a05SRhyland Klein p = rate >= params->vco_min ? 1 : -EINVAL; 14216b301a05SRhyland Klein } 14226b301a05SRhyland Klein 1423287980e4SArnd Bergmann if (p < 0) 14246b301a05SRhyland Klein return -EINVAL; 14256b301a05SRhyland Klein 14266b301a05SRhyland Klein cfg->m = tegra_pll_get_fixed_mdiv(hw, input_rate); 14276b301a05SRhyland Klein cfg->p = p; 14286b301a05SRhyland Klein 14296b301a05SRhyland Klein /* Store P as HW value, as that is what is expected */ 14306b301a05SRhyland Klein cfg->p = tegra_pll_p_div_to_hw(pll, cfg->p); 14316b301a05SRhyland Klein 14326b301a05SRhyland Klein p_rate = rate * p; 14336b301a05SRhyland Klein if (p_rate > params->vco_max) 14346b301a05SRhyland Klein p_rate = params->vco_max; 14356b301a05SRhyland Klein cf = input_rate / cfg->m; 14366b301a05SRhyland Klein cfg->n = p_rate / cf; 14376b301a05SRhyland Klein 14386b301a05SRhyland Klein cfg->sdm_data = 0; 1439ef6ed2b9SPeter De Schrijver cfg->output_rate = input_rate; 14406b301a05SRhyland Klein if (params->sdm_ctrl_reg) { 14416b301a05SRhyland Klein unsigned long rem = p_rate - cf * cfg->n; 14426b301a05SRhyland Klein /* If ssc is enabled SDM enabled as well, even for integer n */ 14436b301a05SRhyland Klein if (rem || params->ssc_ctrl_reg) { 14446b301a05SRhyland Klein u64 s = rem * PLL_SDM_COEFF; 14456b301a05SRhyland Klein 14466b301a05SRhyland Klein do_div(s, cf); 14476b301a05SRhyland Klein s -= PLL_SDM_COEFF / 2; 14486b301a05SRhyland Klein cfg->sdm_data = sdin_din_to_data(s); 14496b301a05SRhyland Klein } 1450a851ea2bSAlex Frid cfg->output_rate *= sdin_get_n_eff(cfg); 1451ef6ed2b9SPeter De Schrijver cfg->output_rate /= p * cfg->m * PLL_SDM_COEFF; 1452ef6ed2b9SPeter De Schrijver } else { 1453ef6ed2b9SPeter De Schrijver cfg->output_rate *= cfg->n; 1454ef6ed2b9SPeter De Schrijver cfg->output_rate /= p * cfg->m; 14556b301a05SRhyland Klein } 14566b301a05SRhyland Klein 14576b301a05SRhyland Klein cfg->input_rate = input_rate; 14586b301a05SRhyland Klein 14596b301a05SRhyland Klein return 0; 14606b301a05SRhyland Klein } 14616b301a05SRhyland Klein 14626b301a05SRhyland Klein /* 14636b301a05SRhyland Klein * clk_pll_set_gain - set gain to m, n to calculate correct VCO rate 14646b301a05SRhyland Klein * 14656b301a05SRhyland Klein * @cfg: struct tegra_clk_pll_freq_table * cfg 14666b301a05SRhyland Klein * 14676b301a05SRhyland Klein * For Normal mode: 14686b301a05SRhyland Klein * Fvco = Fref * NDIV / MDIV 14696b301a05SRhyland Klein * 14706b301a05SRhyland Klein * For fractional mode: 14716b301a05SRhyland Klein * Fvco = Fref * (NDIV + 0.5 + SDM_DIN / PLL_SDM_COEFF) / MDIV 14726b301a05SRhyland Klein */ 14736b301a05SRhyland Klein static void tegra210_clk_pll_set_gain(struct tegra_clk_pll_freq_table *cfg) 14746b301a05SRhyland Klein { 1475a851ea2bSAlex Frid cfg->n = sdin_get_n_eff(cfg); 14766b301a05SRhyland Klein cfg->m *= PLL_SDM_COEFF; 14776b301a05SRhyland Klein } 14786b301a05SRhyland Klein 1479fd360e20SJon Hunter static unsigned long 1480fd360e20SJon Hunter tegra210_clk_adjust_vco_min(struct tegra_clk_pll_params *params, 14816b301a05SRhyland Klein unsigned long parent_rate) 14826b301a05SRhyland Klein { 14836b301a05SRhyland Klein unsigned long vco_min = params->vco_min; 14846b301a05SRhyland Klein 14856b301a05SRhyland Klein params->vco_min += DIV_ROUND_UP(parent_rate, PLL_SDM_COEFF); 14866b301a05SRhyland Klein vco_min = min(vco_min, params->vco_min); 14876b301a05SRhyland Klein 14886b301a05SRhyland Klein return vco_min; 14896b301a05SRhyland Klein } 14906b301a05SRhyland Klein 14916b301a05SRhyland Klein static struct div_nmp pllx_nmp = { 14926b301a05SRhyland Klein .divm_shift = 0, 14936b301a05SRhyland Klein .divm_width = 8, 14946b301a05SRhyland Klein .divn_shift = 8, 14956b301a05SRhyland Klein .divn_width = 8, 14966b301a05SRhyland Klein .divp_shift = 20, 14976b301a05SRhyland Klein .divp_width = 5, 14986b301a05SRhyland Klein }; 14996b301a05SRhyland Klein /* 15006b301a05SRhyland Klein * PLL post divider maps - two types: quasi-linear and exponential 15016b301a05SRhyland Klein * post divider. 15026b301a05SRhyland Klein */ 15036b301a05SRhyland Klein #define PLL_QLIN_PDIV_MAX 16 15046b301a05SRhyland Klein static const struct pdiv_map pll_qlin_pdiv_to_hw[] = { 15056b301a05SRhyland Klein { .pdiv = 1, .hw_val = 0 }, 15066b301a05SRhyland Klein { .pdiv = 2, .hw_val = 1 }, 15076b301a05SRhyland Klein { .pdiv = 3, .hw_val = 2 }, 15086b301a05SRhyland Klein { .pdiv = 4, .hw_val = 3 }, 15096b301a05SRhyland Klein { .pdiv = 5, .hw_val = 4 }, 15106b301a05SRhyland Klein { .pdiv = 6, .hw_val = 5 }, 15116b301a05SRhyland Klein { .pdiv = 8, .hw_val = 6 }, 15126b301a05SRhyland Klein { .pdiv = 9, .hw_val = 7 }, 15136b301a05SRhyland Klein { .pdiv = 10, .hw_val = 8 }, 15146b301a05SRhyland Klein { .pdiv = 12, .hw_val = 9 }, 15156b301a05SRhyland Klein { .pdiv = 15, .hw_val = 10 }, 15166b301a05SRhyland Klein { .pdiv = 16, .hw_val = 11 }, 15176b301a05SRhyland Klein { .pdiv = 18, .hw_val = 12 }, 15186b301a05SRhyland Klein { .pdiv = 20, .hw_val = 13 }, 15196b301a05SRhyland Klein { .pdiv = 24, .hw_val = 14 }, 15206b301a05SRhyland Klein { .pdiv = 30, .hw_val = 15 }, 15216b301a05SRhyland Klein { .pdiv = 32, .hw_val = 16 }, 15226b301a05SRhyland Klein }; 15236b301a05SRhyland Klein 15246b301a05SRhyland Klein static u32 pll_qlin_p_to_pdiv(u32 p, u32 *pdiv) 15256b301a05SRhyland Klein { 15266b301a05SRhyland Klein int i; 15276b301a05SRhyland Klein 15286b301a05SRhyland Klein if (p) { 15296b301a05SRhyland Klein for (i = 0; i <= PLL_QLIN_PDIV_MAX; i++) { 15306b301a05SRhyland Klein if (p <= pll_qlin_pdiv_to_hw[i].pdiv) { 15316b301a05SRhyland Klein if (pdiv) 15326b301a05SRhyland Klein *pdiv = i; 15336b301a05SRhyland Klein return pll_qlin_pdiv_to_hw[i].pdiv; 15346b301a05SRhyland Klein } 15356b301a05SRhyland Klein } 15366b301a05SRhyland Klein } 15376b301a05SRhyland Klein 15386b301a05SRhyland Klein return -EINVAL; 15396b301a05SRhyland Klein } 15406b301a05SRhyland Klein 15416b301a05SRhyland Klein #define PLL_EXPO_PDIV_MAX 7 15426b301a05SRhyland Klein static const struct pdiv_map pll_expo_pdiv_to_hw[] = { 15436b301a05SRhyland Klein { .pdiv = 1, .hw_val = 0 }, 15446b301a05SRhyland Klein { .pdiv = 2, .hw_val = 1 }, 15456b301a05SRhyland Klein { .pdiv = 4, .hw_val = 2 }, 15466b301a05SRhyland Klein { .pdiv = 8, .hw_val = 3 }, 15476b301a05SRhyland Klein { .pdiv = 16, .hw_val = 4 }, 15486b301a05SRhyland Klein { .pdiv = 32, .hw_val = 5 }, 15496b301a05SRhyland Klein { .pdiv = 64, .hw_val = 6 }, 15506b301a05SRhyland Klein { .pdiv = 128, .hw_val = 7 }, 15516b301a05SRhyland Klein }; 15526b301a05SRhyland Klein 15536b301a05SRhyland Klein static u32 pll_expo_p_to_pdiv(u32 p, u32 *pdiv) 15546b301a05SRhyland Klein { 15556b301a05SRhyland Klein if (p) { 15566b301a05SRhyland Klein u32 i = fls(p); 15576b301a05SRhyland Klein 15586b301a05SRhyland Klein if (i == ffs(p)) 15596b301a05SRhyland Klein i--; 15606b301a05SRhyland Klein 15616b301a05SRhyland Klein if (i <= PLL_EXPO_PDIV_MAX) { 15626b301a05SRhyland Klein if (pdiv) 15636b301a05SRhyland Klein *pdiv = i; 15646b301a05SRhyland Klein return 1 << i; 15656b301a05SRhyland Klein } 15666b301a05SRhyland Klein } 15676b301a05SRhyland Klein return -EINVAL; 15686b301a05SRhyland Klein } 15696b301a05SRhyland Klein 15706b301a05SRhyland Klein static struct tegra_clk_pll_freq_table pll_x_freq_table[] = { 15716b301a05SRhyland Klein /* 1 GHz */ 1572eddb65e7SThierry Reding { 12000000, 1000000000, 166, 1, 2, 0 }, /* actual: 996.0 MHz */ 1573eddb65e7SThierry Reding { 13000000, 1000000000, 153, 1, 2, 0 }, /* actual: 994.0 MHz */ 1574eddb65e7SThierry Reding { 38400000, 1000000000, 156, 3, 2, 0 }, /* actual: 998.4 MHz */ 15756b301a05SRhyland Klein { 0, 0, 0, 0, 0, 0 }, 15766b301a05SRhyland Klein }; 15776b301a05SRhyland Klein 15786b301a05SRhyland Klein static struct tegra_clk_pll_params pll_x_params = { 15796b301a05SRhyland Klein .input_min = 12000000, 15806b301a05SRhyland Klein .input_max = 800000000, 15816b301a05SRhyland Klein .cf_min = 12000000, 15826b301a05SRhyland Klein .cf_max = 38400000, 15836b301a05SRhyland Klein .vco_min = 1350000000, 15846b301a05SRhyland Klein .vco_max = 3000000000UL, 15856b301a05SRhyland Klein .base_reg = PLLX_BASE, 15866b301a05SRhyland Klein .misc_reg = PLLX_MISC0, 15876b301a05SRhyland Klein .lock_mask = PLL_BASE_LOCK, 15886b301a05SRhyland Klein .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE, 15896b301a05SRhyland Klein .lock_delay = 300, 15906b301a05SRhyland Klein .ext_misc_reg[0] = PLLX_MISC0, 15916b301a05SRhyland Klein .ext_misc_reg[1] = PLLX_MISC1, 15926b301a05SRhyland Klein .ext_misc_reg[2] = PLLX_MISC2, 15936b301a05SRhyland Klein .ext_misc_reg[3] = PLLX_MISC3, 15946b301a05SRhyland Klein .ext_misc_reg[4] = PLLX_MISC4, 15956b301a05SRhyland Klein .ext_misc_reg[5] = PLLX_MISC5, 15966b301a05SRhyland Klein .iddq_reg = PLLX_MISC3, 15976b301a05SRhyland Klein .iddq_bit_idx = PLLXP_IDDQ_BIT, 15986b301a05SRhyland Klein .max_p = PLL_QLIN_PDIV_MAX, 15996b301a05SRhyland Klein .mdiv_default = 2, 16006b301a05SRhyland Klein .dyn_ramp_reg = PLLX_MISC2, 16016b301a05SRhyland Klein .stepa_shift = 16, 16026b301a05SRhyland Klein .stepb_shift = 24, 16036b301a05SRhyland Klein .round_p_to_pdiv = pll_qlin_p_to_pdiv, 16046b301a05SRhyland Klein .pdiv_tohw = pll_qlin_pdiv_to_hw, 16056b301a05SRhyland Klein .div_nmp = &pllx_nmp, 16066b301a05SRhyland Klein .freq_table = pll_x_freq_table, 16076b301a05SRhyland Klein .flags = TEGRA_PLL_USE_LOCK | TEGRA_PLL_HAS_LOCK_ENABLE, 16086b301a05SRhyland Klein .dyn_ramp = tegra210_pllx_dyn_ramp, 16096b301a05SRhyland Klein .set_defaults = tegra210_pllx_set_defaults, 16106b301a05SRhyland Klein .calc_rate = tegra210_pll_fixed_mdiv_cfg, 16116b301a05SRhyland Klein }; 16126b301a05SRhyland Klein 16136b301a05SRhyland Klein static struct div_nmp pllc_nmp = { 16146b301a05SRhyland Klein .divm_shift = 0, 16156b301a05SRhyland Klein .divm_width = 8, 16166b301a05SRhyland Klein .divn_shift = 10, 16176b301a05SRhyland Klein .divn_width = 8, 16186b301a05SRhyland Klein .divp_shift = 20, 16196b301a05SRhyland Klein .divp_width = 5, 16206b301a05SRhyland Klein }; 16216b301a05SRhyland Klein 16226b301a05SRhyland Klein static struct tegra_clk_pll_freq_table pll_cx_freq_table[] = { 1623eddb65e7SThierry Reding { 12000000, 510000000, 85, 1, 2, 0 }, 1624eddb65e7SThierry Reding { 13000000, 510000000, 78, 1, 2, 0 }, /* actual: 507.0 MHz */ 1625eddb65e7SThierry Reding { 38400000, 510000000, 79, 3, 2, 0 }, /* actual: 505.6 MHz */ 16266b301a05SRhyland Klein { 0, 0, 0, 0, 0, 0 }, 16276b301a05SRhyland Klein }; 16286b301a05SRhyland Klein 16296b301a05SRhyland Klein static struct tegra_clk_pll_params pll_c_params = { 16306b301a05SRhyland Klein .input_min = 12000000, 16316b301a05SRhyland Klein .input_max = 700000000, 16326b301a05SRhyland Klein .cf_min = 12000000, 16336b301a05SRhyland Klein .cf_max = 50000000, 16346b301a05SRhyland Klein .vco_min = 600000000, 16356b301a05SRhyland Klein .vco_max = 1200000000, 16366b301a05SRhyland Klein .base_reg = PLLC_BASE, 16376b301a05SRhyland Klein .misc_reg = PLLC_MISC0, 16386b301a05SRhyland Klein .lock_mask = PLL_BASE_LOCK, 16396b301a05SRhyland Klein .lock_delay = 300, 16406b301a05SRhyland Klein .iddq_reg = PLLC_MISC1, 16416b301a05SRhyland Klein .iddq_bit_idx = PLLCX_IDDQ_BIT, 16426b301a05SRhyland Klein .reset_reg = PLLC_MISC0, 16436b301a05SRhyland Klein .reset_bit_idx = PLLCX_RESET_BIT, 16446b301a05SRhyland Klein .max_p = PLL_QLIN_PDIV_MAX, 16456b301a05SRhyland Klein .ext_misc_reg[0] = PLLC_MISC0, 16466b301a05SRhyland Klein .ext_misc_reg[1] = PLLC_MISC1, 16476b301a05SRhyland Klein .ext_misc_reg[2] = PLLC_MISC2, 16486b301a05SRhyland Klein .ext_misc_reg[3] = PLLC_MISC3, 16496b301a05SRhyland Klein .round_p_to_pdiv = pll_qlin_p_to_pdiv, 16506b301a05SRhyland Klein .pdiv_tohw = pll_qlin_pdiv_to_hw, 16516b301a05SRhyland Klein .mdiv_default = 3, 16526b301a05SRhyland Klein .div_nmp = &pllc_nmp, 16536b301a05SRhyland Klein .freq_table = pll_cx_freq_table, 165414050118SRhyland Klein .flags = TEGRA_PLL_USE_LOCK, 16556b301a05SRhyland Klein .set_defaults = _pllc_set_defaults, 16566b301a05SRhyland Klein .calc_rate = tegra210_pll_fixed_mdiv_cfg, 16576b301a05SRhyland Klein }; 16586b301a05SRhyland Klein 16596b301a05SRhyland Klein static struct div_nmp pllcx_nmp = { 16606b301a05SRhyland Klein .divm_shift = 0, 16616b301a05SRhyland Klein .divm_width = 8, 16626b301a05SRhyland Klein .divn_shift = 10, 16636b301a05SRhyland Klein .divn_width = 8, 16646b301a05SRhyland Klein .divp_shift = 20, 16656b301a05SRhyland Klein .divp_width = 5, 16666b301a05SRhyland Klein }; 16676b301a05SRhyland Klein 16686b301a05SRhyland Klein static struct tegra_clk_pll_params pll_c2_params = { 16696b301a05SRhyland Klein .input_min = 12000000, 16706b301a05SRhyland Klein .input_max = 700000000, 16716b301a05SRhyland Klein .cf_min = 12000000, 16726b301a05SRhyland Klein .cf_max = 50000000, 16736b301a05SRhyland Klein .vco_min = 600000000, 16746b301a05SRhyland Klein .vco_max = 1200000000, 16756b301a05SRhyland Klein .base_reg = PLLC2_BASE, 16766b301a05SRhyland Klein .misc_reg = PLLC2_MISC0, 16776b301a05SRhyland Klein .iddq_reg = PLLC2_MISC1, 16786b301a05SRhyland Klein .iddq_bit_idx = PLLCX_IDDQ_BIT, 16796b301a05SRhyland Klein .reset_reg = PLLC2_MISC0, 16806b301a05SRhyland Klein .reset_bit_idx = PLLCX_RESET_BIT, 16816b301a05SRhyland Klein .lock_mask = PLLCX_BASE_LOCK, 16826b301a05SRhyland Klein .lock_delay = 300, 16836b301a05SRhyland Klein .round_p_to_pdiv = pll_qlin_p_to_pdiv, 16846b301a05SRhyland Klein .pdiv_tohw = pll_qlin_pdiv_to_hw, 16856b301a05SRhyland Klein .mdiv_default = 3, 16866b301a05SRhyland Klein .div_nmp = &pllcx_nmp, 16876b301a05SRhyland Klein .max_p = PLL_QLIN_PDIV_MAX, 16886b301a05SRhyland Klein .ext_misc_reg[0] = PLLC2_MISC0, 16896b301a05SRhyland Klein .ext_misc_reg[1] = PLLC2_MISC1, 16906b301a05SRhyland Klein .ext_misc_reg[2] = PLLC2_MISC2, 16916b301a05SRhyland Klein .ext_misc_reg[3] = PLLC2_MISC3, 16926b301a05SRhyland Klein .freq_table = pll_cx_freq_table, 169314050118SRhyland Klein .flags = TEGRA_PLL_USE_LOCK, 16946b301a05SRhyland Klein .set_defaults = _pllc2_set_defaults, 16956b301a05SRhyland Klein .calc_rate = tegra210_pll_fixed_mdiv_cfg, 16966b301a05SRhyland Klein }; 16976b301a05SRhyland Klein 16986b301a05SRhyland Klein static struct tegra_clk_pll_params pll_c3_params = { 16996b301a05SRhyland Klein .input_min = 12000000, 17006b301a05SRhyland Klein .input_max = 700000000, 17016b301a05SRhyland Klein .cf_min = 12000000, 17026b301a05SRhyland Klein .cf_max = 50000000, 17036b301a05SRhyland Klein .vco_min = 600000000, 17046b301a05SRhyland Klein .vco_max = 1200000000, 17056b301a05SRhyland Klein .base_reg = PLLC3_BASE, 17066b301a05SRhyland Klein .misc_reg = PLLC3_MISC0, 17076b301a05SRhyland Klein .lock_mask = PLLCX_BASE_LOCK, 17086b301a05SRhyland Klein .lock_delay = 300, 17096b301a05SRhyland Klein .iddq_reg = PLLC3_MISC1, 17106b301a05SRhyland Klein .iddq_bit_idx = PLLCX_IDDQ_BIT, 17116b301a05SRhyland Klein .reset_reg = PLLC3_MISC0, 17126b301a05SRhyland Klein .reset_bit_idx = PLLCX_RESET_BIT, 17136b301a05SRhyland Klein .round_p_to_pdiv = pll_qlin_p_to_pdiv, 17146b301a05SRhyland Klein .pdiv_tohw = pll_qlin_pdiv_to_hw, 17156b301a05SRhyland Klein .mdiv_default = 3, 17166b301a05SRhyland Klein .div_nmp = &pllcx_nmp, 17176b301a05SRhyland Klein .max_p = PLL_QLIN_PDIV_MAX, 17186b301a05SRhyland Klein .ext_misc_reg[0] = PLLC3_MISC0, 17196b301a05SRhyland Klein .ext_misc_reg[1] = PLLC3_MISC1, 17206b301a05SRhyland Klein .ext_misc_reg[2] = PLLC3_MISC2, 17216b301a05SRhyland Klein .ext_misc_reg[3] = PLLC3_MISC3, 17226b301a05SRhyland Klein .freq_table = pll_cx_freq_table, 172314050118SRhyland Klein .flags = TEGRA_PLL_USE_LOCK, 17246b301a05SRhyland Klein .set_defaults = _pllc3_set_defaults, 17256b301a05SRhyland Klein .calc_rate = tegra210_pll_fixed_mdiv_cfg, 17266b301a05SRhyland Klein }; 17276b301a05SRhyland Klein 17286b301a05SRhyland Klein static struct div_nmp pllss_nmp = { 17296b301a05SRhyland Klein .divm_shift = 0, 17306b301a05SRhyland Klein .divm_width = 8, 17316b301a05SRhyland Klein .divn_shift = 8, 17326b301a05SRhyland Klein .divn_width = 8, 17336b301a05SRhyland Klein .divp_shift = 19, 17346b301a05SRhyland Klein .divp_width = 5, 17356b301a05SRhyland Klein }; 17366b301a05SRhyland Klein 17376b301a05SRhyland Klein static struct tegra_clk_pll_freq_table pll_c4_vco_freq_table[] = { 1738eddb65e7SThierry Reding { 12000000, 600000000, 50, 1, 1, 0 }, 1739eddb65e7SThierry Reding { 13000000, 600000000, 46, 1, 1, 0 }, /* actual: 598.0 MHz */ 1740eddb65e7SThierry Reding { 38400000, 600000000, 62, 4, 1, 0 }, /* actual: 595.2 MHz */ 17416b301a05SRhyland Klein { 0, 0, 0, 0, 0, 0 }, 17426b301a05SRhyland Klein }; 17436b301a05SRhyland Klein 17446b301a05SRhyland Klein static const struct clk_div_table pll_vco_post_div_table[] = { 17456b301a05SRhyland Klein { .val = 0, .div = 1 }, 17466b301a05SRhyland Klein { .val = 1, .div = 2 }, 17476b301a05SRhyland Klein { .val = 2, .div = 3 }, 17486b301a05SRhyland Klein { .val = 3, .div = 4 }, 17496b301a05SRhyland Klein { .val = 4, .div = 5 }, 17506b301a05SRhyland Klein { .val = 5, .div = 6 }, 17516b301a05SRhyland Klein { .val = 6, .div = 8 }, 17526b301a05SRhyland Klein { .val = 7, .div = 10 }, 17536b301a05SRhyland Klein { .val = 8, .div = 12 }, 17546b301a05SRhyland Klein { .val = 9, .div = 16 }, 17556b301a05SRhyland Klein { .val = 10, .div = 12 }, 17566b301a05SRhyland Klein { .val = 11, .div = 16 }, 17576b301a05SRhyland Klein { .val = 12, .div = 20 }, 17586b301a05SRhyland Klein { .val = 13, .div = 24 }, 17596b301a05SRhyland Klein { .val = 14, .div = 32 }, 17606b301a05SRhyland Klein { .val = 0, .div = 0 }, 17616b301a05SRhyland Klein }; 17626b301a05SRhyland Klein 17636b301a05SRhyland Klein static struct tegra_clk_pll_params pll_c4_vco_params = { 17646b301a05SRhyland Klein .input_min = 9600000, 17656b301a05SRhyland Klein .input_max = 800000000, 17666b301a05SRhyland Klein .cf_min = 9600000, 17676b301a05SRhyland Klein .cf_max = 19200000, 17686b301a05SRhyland Klein .vco_min = 500000000, 17696b301a05SRhyland Klein .vco_max = 1080000000, 17706b301a05SRhyland Klein .base_reg = PLLC4_BASE, 17716b301a05SRhyland Klein .misc_reg = PLLC4_MISC0, 17726b301a05SRhyland Klein .lock_mask = PLL_BASE_LOCK, 17736b301a05SRhyland Klein .lock_delay = 300, 17746b301a05SRhyland Klein .max_p = PLL_QLIN_PDIV_MAX, 17756b301a05SRhyland Klein .ext_misc_reg[0] = PLLC4_MISC0, 17766b301a05SRhyland Klein .iddq_reg = PLLC4_BASE, 17776b301a05SRhyland Klein .iddq_bit_idx = PLLSS_IDDQ_BIT, 17786b301a05SRhyland Klein .round_p_to_pdiv = pll_qlin_p_to_pdiv, 17796b301a05SRhyland Klein .pdiv_tohw = pll_qlin_pdiv_to_hw, 17806b301a05SRhyland Klein .mdiv_default = 3, 17816b301a05SRhyland Klein .div_nmp = &pllss_nmp, 17826b301a05SRhyland Klein .freq_table = pll_c4_vco_freq_table, 17836b301a05SRhyland Klein .set_defaults = tegra210_pllc4_set_defaults, 178414050118SRhyland Klein .flags = TEGRA_PLL_USE_LOCK | TEGRA_PLL_VCO_OUT, 17856b301a05SRhyland Klein .calc_rate = tegra210_pll_fixed_mdiv_cfg, 17866b301a05SRhyland Klein }; 17876b301a05SRhyland Klein 17886b301a05SRhyland Klein static struct tegra_clk_pll_freq_table pll_m_freq_table[] = { 1789eddb65e7SThierry Reding { 12000000, 800000000, 66, 1, 1, 0 }, /* actual: 792.0 MHz */ 1790eddb65e7SThierry Reding { 13000000, 800000000, 61, 1, 1, 0 }, /* actual: 793.0 MHz */ 1791eddb65e7SThierry Reding { 38400000, 297600000, 93, 4, 3, 0 }, 1792eddb65e7SThierry Reding { 38400000, 400000000, 125, 4, 3, 0 }, 1793eddb65e7SThierry Reding { 38400000, 532800000, 111, 4, 2, 0 }, 1794eddb65e7SThierry Reding { 38400000, 665600000, 104, 3, 2, 0 }, 1795eddb65e7SThierry Reding { 38400000, 800000000, 125, 3, 2, 0 }, 1796eddb65e7SThierry Reding { 38400000, 931200000, 97, 4, 1, 0 }, 1797eddb65e7SThierry Reding { 38400000, 1065600000, 111, 4, 1, 0 }, 1798eddb65e7SThierry Reding { 38400000, 1200000000, 125, 4, 1, 0 }, 1799eddb65e7SThierry Reding { 38400000, 1331200000, 104, 3, 1, 0 }, 1800eddb65e7SThierry Reding { 38400000, 1459200000, 76, 2, 1, 0 }, 1801eddb65e7SThierry Reding { 38400000, 1600000000, 125, 3, 1, 0 }, 18026b301a05SRhyland Klein { 0, 0, 0, 0, 0, 0 }, 18036b301a05SRhyland Klein }; 18046b301a05SRhyland Klein 18056b301a05SRhyland Klein static struct div_nmp pllm_nmp = { 18066b301a05SRhyland Klein .divm_shift = 0, 18076b301a05SRhyland Klein .divm_width = 8, 18086b301a05SRhyland Klein .override_divm_shift = 0, 18096b301a05SRhyland Klein .divn_shift = 8, 18106b301a05SRhyland Klein .divn_width = 8, 18116b301a05SRhyland Klein .override_divn_shift = 8, 18126b301a05SRhyland Klein .divp_shift = 20, 18136b301a05SRhyland Klein .divp_width = 5, 18146b301a05SRhyland Klein .override_divp_shift = 27, 18156b301a05SRhyland Klein }; 18166b301a05SRhyland Klein 18176b301a05SRhyland Klein static struct tegra_clk_pll_params pll_m_params = { 18186b301a05SRhyland Klein .input_min = 9600000, 18196b301a05SRhyland Klein .input_max = 500000000, 18206b301a05SRhyland Klein .cf_min = 9600000, 18216b301a05SRhyland Klein .cf_max = 19200000, 18226b301a05SRhyland Klein .vco_min = 800000000, 18236b301a05SRhyland Klein .vco_max = 1866000000, 18246b301a05SRhyland Klein .base_reg = PLLM_BASE, 1825474f2ba2SRhyland Klein .misc_reg = PLLM_MISC2, 18266b301a05SRhyland Klein .lock_mask = PLL_BASE_LOCK, 18276b301a05SRhyland Klein .lock_enable_bit_idx = PLLM_MISC_LOCK_ENABLE, 18286b301a05SRhyland Klein .lock_delay = 300, 1829474f2ba2SRhyland Klein .iddq_reg = PLLM_MISC2, 18306b301a05SRhyland Klein .iddq_bit_idx = PLLM_IDDQ_BIT, 18316b301a05SRhyland Klein .max_p = PLL_QLIN_PDIV_MAX, 1832474f2ba2SRhyland Klein .ext_misc_reg[0] = PLLM_MISC2, 1833d9e65791SJon Hunter .ext_misc_reg[1] = PLLM_MISC1, 18346b301a05SRhyland Klein .round_p_to_pdiv = pll_qlin_p_to_pdiv, 18356b301a05SRhyland Klein .pdiv_tohw = pll_qlin_pdiv_to_hw, 18366b301a05SRhyland Klein .div_nmp = &pllm_nmp, 18376b301a05SRhyland Klein .pmc_divnm_reg = PMC_PLLM_WB0_OVERRIDE, 18386b301a05SRhyland Klein .pmc_divp_reg = PMC_PLLM_WB0_OVERRIDE_2, 18396b301a05SRhyland Klein .freq_table = pll_m_freq_table, 18406b301a05SRhyland Klein .flags = TEGRA_PLL_USE_LOCK | TEGRA_PLL_HAS_LOCK_ENABLE, 18416b301a05SRhyland Klein .calc_rate = tegra210_pll_fixed_mdiv_cfg, 18426b301a05SRhyland Klein }; 18436b301a05SRhyland Klein 18446b301a05SRhyland Klein static struct tegra_clk_pll_params pll_mb_params = { 18456b301a05SRhyland Klein .input_min = 9600000, 18466b301a05SRhyland Klein .input_max = 500000000, 18476b301a05SRhyland Klein .cf_min = 9600000, 18486b301a05SRhyland Klein .cf_max = 19200000, 18496b301a05SRhyland Klein .vco_min = 800000000, 18506b301a05SRhyland Klein .vco_max = 1866000000, 18516b301a05SRhyland Klein .base_reg = PLLMB_BASE, 1852474f2ba2SRhyland Klein .misc_reg = PLLMB_MISC1, 18536b301a05SRhyland Klein .lock_mask = PLL_BASE_LOCK, 18546b301a05SRhyland Klein .lock_delay = 300, 1855474f2ba2SRhyland Klein .iddq_reg = PLLMB_MISC1, 18566b301a05SRhyland Klein .iddq_bit_idx = PLLMB_IDDQ_BIT, 18576b301a05SRhyland Klein .max_p = PLL_QLIN_PDIV_MAX, 1858474f2ba2SRhyland Klein .ext_misc_reg[0] = PLLMB_MISC1, 18596b301a05SRhyland Klein .round_p_to_pdiv = pll_qlin_p_to_pdiv, 18606b301a05SRhyland Klein .pdiv_tohw = pll_qlin_pdiv_to_hw, 18616b301a05SRhyland Klein .div_nmp = &pllm_nmp, 18626b301a05SRhyland Klein .freq_table = pll_m_freq_table, 186314050118SRhyland Klein .flags = TEGRA_PLL_USE_LOCK, 18646b301a05SRhyland Klein .set_defaults = tegra210_pllmb_set_defaults, 18656b301a05SRhyland Klein .calc_rate = tegra210_pll_fixed_mdiv_cfg, 18666b301a05SRhyland Klein }; 18676b301a05SRhyland Klein 18686b301a05SRhyland Klein 18696b301a05SRhyland Klein static struct tegra_clk_pll_freq_table pll_e_freq_table[] = { 18706b301a05SRhyland Klein /* PLLE special case: use cpcon field to store cml divider value */ 18716b301a05SRhyland Klein { 672000000, 100000000, 125, 42, 0, 13 }, 18726b301a05SRhyland Klein { 624000000, 100000000, 125, 39, 0, 13 }, 18736b301a05SRhyland Klein { 336000000, 100000000, 125, 21, 0, 13 }, 18746b301a05SRhyland Klein { 312000000, 100000000, 200, 26, 0, 14 }, 18756b301a05SRhyland Klein { 38400000, 100000000, 125, 2, 0, 14 }, 18766b301a05SRhyland Klein { 12000000, 100000000, 200, 1, 0, 14 }, 18776b301a05SRhyland Klein { 0, 0, 0, 0, 0, 0 }, 18786b301a05SRhyland Klein }; 18796b301a05SRhyland Klein 18806b301a05SRhyland Klein static struct div_nmp plle_nmp = { 18816b301a05SRhyland Klein .divm_shift = 0, 18826b301a05SRhyland Klein .divm_width = 8, 18836b301a05SRhyland Klein .divn_shift = 8, 18846b301a05SRhyland Klein .divn_width = 8, 18856b301a05SRhyland Klein .divp_shift = 24, 18866b301a05SRhyland Klein .divp_width = 5, 18876b301a05SRhyland Klein }; 18886b301a05SRhyland Klein 18896b301a05SRhyland Klein static struct tegra_clk_pll_params pll_e_params = { 18906b301a05SRhyland Klein .input_min = 12000000, 18916b301a05SRhyland Klein .input_max = 800000000, 18926b301a05SRhyland Klein .cf_min = 12000000, 18936b301a05SRhyland Klein .cf_max = 38400000, 18946b301a05SRhyland Klein .vco_min = 1600000000, 18956b301a05SRhyland Klein .vco_max = 2500000000U, 18966b301a05SRhyland Klein .base_reg = PLLE_BASE, 18976b301a05SRhyland Klein .misc_reg = PLLE_MISC0, 18986b301a05SRhyland Klein .aux_reg = PLLE_AUX, 18996b301a05SRhyland Klein .lock_mask = PLLE_MISC_LOCK, 19006b301a05SRhyland Klein .lock_enable_bit_idx = PLLE_MISC_LOCK_ENABLE, 19016b301a05SRhyland Klein .lock_delay = 300, 19026b301a05SRhyland Klein .div_nmp = &plle_nmp, 19036b301a05SRhyland Klein .freq_table = pll_e_freq_table, 19046b301a05SRhyland Klein .flags = TEGRA_PLL_FIXED | TEGRA_PLL_LOCK_MISC | TEGRA_PLL_USE_LOCK | 19056b301a05SRhyland Klein TEGRA_PLL_HAS_LOCK_ENABLE, 19066b301a05SRhyland Klein .fixed_rate = 100000000, 19076b301a05SRhyland Klein .calc_rate = tegra210_pll_fixed_mdiv_cfg, 19086b301a05SRhyland Klein }; 19096b301a05SRhyland Klein 19106b301a05SRhyland Klein static struct tegra_clk_pll_freq_table pll_re_vco_freq_table[] = { 1911eddb65e7SThierry Reding { 12000000, 672000000, 56, 1, 1, 0 }, 1912eddb65e7SThierry Reding { 13000000, 672000000, 51, 1, 1, 0 }, /* actual: 663.0 MHz */ 1913eddb65e7SThierry Reding { 38400000, 672000000, 70, 4, 1, 0 }, 19146b301a05SRhyland Klein { 0, 0, 0, 0, 0, 0 }, 19156b301a05SRhyland Klein }; 19166b301a05SRhyland Klein 19176b301a05SRhyland Klein static struct div_nmp pllre_nmp = { 19186b301a05SRhyland Klein .divm_shift = 0, 19196b301a05SRhyland Klein .divm_width = 8, 19206b301a05SRhyland Klein .divn_shift = 8, 19216b301a05SRhyland Klein .divn_width = 8, 19226b301a05SRhyland Klein .divp_shift = 16, 19236b301a05SRhyland Klein .divp_width = 5, 19246b301a05SRhyland Klein }; 19256b301a05SRhyland Klein 19266b301a05SRhyland Klein static struct tegra_clk_pll_params pll_re_vco_params = { 19276b301a05SRhyland Klein .input_min = 9600000, 19286b301a05SRhyland Klein .input_max = 800000000, 19296b301a05SRhyland Klein .cf_min = 9600000, 19306b301a05SRhyland Klein .cf_max = 19200000, 19316b301a05SRhyland Klein .vco_min = 350000000, 19326b301a05SRhyland Klein .vco_max = 700000000, 19336b301a05SRhyland Klein .base_reg = PLLRE_BASE, 19346b301a05SRhyland Klein .misc_reg = PLLRE_MISC0, 19356b301a05SRhyland Klein .lock_mask = PLLRE_MISC_LOCK, 19366b301a05SRhyland Klein .lock_delay = 300, 19376b301a05SRhyland Klein .max_p = PLL_QLIN_PDIV_MAX, 19386b301a05SRhyland Klein .ext_misc_reg[0] = PLLRE_MISC0, 19396b301a05SRhyland Klein .iddq_reg = PLLRE_MISC0, 19406b301a05SRhyland Klein .iddq_bit_idx = PLLRE_IDDQ_BIT, 19416b301a05SRhyland Klein .round_p_to_pdiv = pll_qlin_p_to_pdiv, 19426b301a05SRhyland Klein .pdiv_tohw = pll_qlin_pdiv_to_hw, 19436b301a05SRhyland Klein .div_nmp = &pllre_nmp, 19446b301a05SRhyland Klein .freq_table = pll_re_vco_freq_table, 194514050118SRhyland Klein .flags = TEGRA_PLL_USE_LOCK | TEGRA_PLL_LOCK_MISC | TEGRA_PLL_VCO_OUT, 19466b301a05SRhyland Klein .set_defaults = tegra210_pllre_set_defaults, 19476b301a05SRhyland Klein .calc_rate = tegra210_pll_fixed_mdiv_cfg, 19486b301a05SRhyland Klein }; 19496b301a05SRhyland Klein 19506b301a05SRhyland Klein static struct div_nmp pllp_nmp = { 19516b301a05SRhyland Klein .divm_shift = 0, 19526b301a05SRhyland Klein .divm_width = 8, 19536b301a05SRhyland Klein .divn_shift = 10, 19546b301a05SRhyland Klein .divn_width = 8, 19556b301a05SRhyland Klein .divp_shift = 20, 19566b301a05SRhyland Klein .divp_width = 5, 19576b301a05SRhyland Klein }; 19586b301a05SRhyland Klein 19596b301a05SRhyland Klein static struct tegra_clk_pll_freq_table pll_p_freq_table[] = { 1960eddb65e7SThierry Reding { 12000000, 408000000, 34, 1, 1, 0 }, 1961eddb65e7SThierry Reding { 38400000, 408000000, 85, 8, 1, 0 }, /* cf = 4.8MHz, allowed exception */ 19626b301a05SRhyland Klein { 0, 0, 0, 0, 0, 0 }, 19636b301a05SRhyland Klein }; 19646b301a05SRhyland Klein 19656b301a05SRhyland Klein static struct tegra_clk_pll_params pll_p_params = { 19666b301a05SRhyland Klein .input_min = 9600000, 19676b301a05SRhyland Klein .input_max = 800000000, 19686b301a05SRhyland Klein .cf_min = 9600000, 19696b301a05SRhyland Klein .cf_max = 19200000, 19706b301a05SRhyland Klein .vco_min = 350000000, 19716b301a05SRhyland Klein .vco_max = 700000000, 19726b301a05SRhyland Klein .base_reg = PLLP_BASE, 19736b301a05SRhyland Klein .misc_reg = PLLP_MISC0, 19746b301a05SRhyland Klein .lock_mask = PLL_BASE_LOCK, 19756b301a05SRhyland Klein .lock_delay = 300, 19766b301a05SRhyland Klein .iddq_reg = PLLP_MISC0, 19776b301a05SRhyland Klein .iddq_bit_idx = PLLXP_IDDQ_BIT, 19786b301a05SRhyland Klein .ext_misc_reg[0] = PLLP_MISC0, 19796b301a05SRhyland Klein .ext_misc_reg[1] = PLLP_MISC1, 19806b301a05SRhyland Klein .div_nmp = &pllp_nmp, 19816b301a05SRhyland Klein .freq_table = pll_p_freq_table, 19826b301a05SRhyland Klein .fixed_rate = 408000000, 198314050118SRhyland Klein .flags = TEGRA_PLL_FIXED | TEGRA_PLL_USE_LOCK | TEGRA_PLL_VCO_OUT, 19846b301a05SRhyland Klein .set_defaults = tegra210_pllp_set_defaults, 19856b301a05SRhyland Klein .calc_rate = tegra210_pll_fixed_mdiv_cfg, 19866b301a05SRhyland Klein }; 19876b301a05SRhyland Klein 19886b301a05SRhyland Klein static struct tegra_clk_pll_params pll_a1_params = { 19896b301a05SRhyland Klein .input_min = 12000000, 19906b301a05SRhyland Klein .input_max = 700000000, 19916b301a05SRhyland Klein .cf_min = 12000000, 19926b301a05SRhyland Klein .cf_max = 50000000, 19936b301a05SRhyland Klein .vco_min = 600000000, 19946b301a05SRhyland Klein .vco_max = 1200000000, 19956b301a05SRhyland Klein .base_reg = PLLA1_BASE, 19966b301a05SRhyland Klein .misc_reg = PLLA1_MISC0, 19976b301a05SRhyland Klein .lock_mask = PLLCX_BASE_LOCK, 19986b301a05SRhyland Klein .lock_delay = 300, 19999326947fSPeter De Schrijver .iddq_reg = PLLA1_MISC1, 20006b301a05SRhyland Klein .iddq_bit_idx = PLLCX_IDDQ_BIT, 20016b301a05SRhyland Klein .reset_reg = PLLA1_MISC0, 20026b301a05SRhyland Klein .reset_bit_idx = PLLCX_RESET_BIT, 20036b301a05SRhyland Klein .round_p_to_pdiv = pll_qlin_p_to_pdiv, 20046b301a05SRhyland Klein .pdiv_tohw = pll_qlin_pdiv_to_hw, 20056b301a05SRhyland Klein .div_nmp = &pllc_nmp, 20066b301a05SRhyland Klein .ext_misc_reg[0] = PLLA1_MISC0, 20076b301a05SRhyland Klein .ext_misc_reg[1] = PLLA1_MISC1, 20086b301a05SRhyland Klein .ext_misc_reg[2] = PLLA1_MISC2, 20096b301a05SRhyland Klein .ext_misc_reg[3] = PLLA1_MISC3, 20106b301a05SRhyland Klein .freq_table = pll_cx_freq_table, 201114050118SRhyland Klein .flags = TEGRA_PLL_USE_LOCK, 20126b301a05SRhyland Klein .set_defaults = _plla1_set_defaults, 20136b301a05SRhyland Klein .calc_rate = tegra210_pll_fixed_mdiv_cfg, 20146b301a05SRhyland Klein }; 20156b301a05SRhyland Klein 20166b301a05SRhyland Klein static struct div_nmp plla_nmp = { 20176b301a05SRhyland Klein .divm_shift = 0, 20186b301a05SRhyland Klein .divm_width = 8, 20196b301a05SRhyland Klein .divn_shift = 8, 20206b301a05SRhyland Klein .divn_width = 8, 20216b301a05SRhyland Klein .divp_shift = 20, 20226b301a05SRhyland Klein .divp_width = 5, 20236b301a05SRhyland Klein }; 20246b301a05SRhyland Klein 20256b301a05SRhyland Klein static struct tegra_clk_pll_freq_table pll_a_freq_table[] = { 2026eddb65e7SThierry Reding { 12000000, 282240000, 47, 1, 2, 1, 0xf148 }, /* actual: 282240234 */ 2027eddb65e7SThierry Reding { 12000000, 368640000, 61, 1, 2, 1, 0xfe15 }, /* actual: 368640381 */ 2028eddb65e7SThierry Reding { 12000000, 240000000, 60, 1, 3, 1, 0 }, 2029eddb65e7SThierry Reding { 13000000, 282240000, 43, 1, 2, 1, 0xfd7d }, /* actual: 282239807 */ 2030eddb65e7SThierry Reding { 13000000, 368640000, 56, 1, 2, 1, 0x06d8 }, /* actual: 368640137 */ 2031eddb65e7SThierry Reding { 13000000, 240000000, 55, 1, 3, 1, 0 }, /* actual: 238.3 MHz */ 2032eddb65e7SThierry Reding { 38400000, 282240000, 44, 3, 2, 1, 0xf333 }, /* actual: 282239844 */ 2033eddb65e7SThierry Reding { 38400000, 368640000, 57, 3, 2, 1, 0x0333 }, /* actual: 368639844 */ 20346b301a05SRhyland Klein { 38400000, 240000000, 75, 3, 3, 1, 0 }, 20356b301a05SRhyland Klein { 0, 0, 0, 0, 0, 0, 0 }, 20366b301a05SRhyland Klein }; 20376b301a05SRhyland Klein 20386b301a05SRhyland Klein static struct tegra_clk_pll_params pll_a_params = { 20396b301a05SRhyland Klein .input_min = 12000000, 20406b301a05SRhyland Klein .input_max = 800000000, 20416b301a05SRhyland Klein .cf_min = 12000000, 20426b301a05SRhyland Klein .cf_max = 19200000, 20436b301a05SRhyland Klein .vco_min = 500000000, 20446b301a05SRhyland Klein .vco_max = 1000000000, 20456b301a05SRhyland Klein .base_reg = PLLA_BASE, 20466b301a05SRhyland Klein .misc_reg = PLLA_MISC0, 20476b301a05SRhyland Klein .lock_mask = PLL_BASE_LOCK, 20486b301a05SRhyland Klein .lock_delay = 300, 20496b301a05SRhyland Klein .round_p_to_pdiv = pll_qlin_p_to_pdiv, 20506b301a05SRhyland Klein .pdiv_tohw = pll_qlin_pdiv_to_hw, 20516b301a05SRhyland Klein .iddq_reg = PLLA_BASE, 20526b301a05SRhyland Klein .iddq_bit_idx = PLLA_IDDQ_BIT, 20536b301a05SRhyland Klein .div_nmp = &plla_nmp, 20546b301a05SRhyland Klein .sdm_din_reg = PLLA_MISC1, 20556b301a05SRhyland Klein .sdm_din_mask = PLLA_SDM_DIN_MASK, 20566b301a05SRhyland Klein .sdm_ctrl_reg = PLLA_MISC2, 20576b301a05SRhyland Klein .sdm_ctrl_en_mask = PLLA_SDM_EN_MASK, 20586b301a05SRhyland Klein .ext_misc_reg[0] = PLLA_MISC0, 20596b301a05SRhyland Klein .ext_misc_reg[1] = PLLA_MISC1, 20606b301a05SRhyland Klein .ext_misc_reg[2] = PLLA_MISC2, 20616b301a05SRhyland Klein .freq_table = pll_a_freq_table, 206214050118SRhyland Klein .flags = TEGRA_PLL_USE_LOCK | TEGRA_MDIV_NEW, 20636b301a05SRhyland Klein .set_defaults = tegra210_plla_set_defaults, 20646b301a05SRhyland Klein .calc_rate = tegra210_pll_fixed_mdiv_cfg, 20656b301a05SRhyland Klein .set_gain = tegra210_clk_pll_set_gain, 20666b301a05SRhyland Klein .adjust_vco = tegra210_clk_adjust_vco_min, 20676b301a05SRhyland Klein }; 20686b301a05SRhyland Klein 20696b301a05SRhyland Klein static struct div_nmp plld_nmp = { 20706b301a05SRhyland Klein .divm_shift = 0, 20716b301a05SRhyland Klein .divm_width = 8, 20726b301a05SRhyland Klein .divn_shift = 11, 20736b301a05SRhyland Klein .divn_width = 8, 20746b301a05SRhyland Klein .divp_shift = 20, 20756b301a05SRhyland Klein .divp_width = 3, 20766b301a05SRhyland Klein }; 20776b301a05SRhyland Klein 20786b301a05SRhyland Klein static struct tegra_clk_pll_freq_table pll_d_freq_table[] = { 2079eddb65e7SThierry Reding { 12000000, 594000000, 99, 1, 2, 0, 0 }, 2080eddb65e7SThierry Reding { 13000000, 594000000, 91, 1, 2, 0, 0xfc4f }, /* actual: 594000183 */ 2081eddb65e7SThierry Reding { 38400000, 594000000, 30, 1, 2, 0, 0x0e00 }, 20826b301a05SRhyland Klein { 0, 0, 0, 0, 0, 0, 0 }, 20836b301a05SRhyland Klein }; 20846b301a05SRhyland Klein 20856b301a05SRhyland Klein static struct tegra_clk_pll_params pll_d_params = { 20866b301a05SRhyland Klein .input_min = 12000000, 20876b301a05SRhyland Klein .input_max = 800000000, 20886b301a05SRhyland Klein .cf_min = 12000000, 20896b301a05SRhyland Klein .cf_max = 38400000, 20906b301a05SRhyland Klein .vco_min = 750000000, 20916b301a05SRhyland Klein .vco_max = 1500000000, 20926b301a05SRhyland Klein .base_reg = PLLD_BASE, 20936b301a05SRhyland Klein .misc_reg = PLLD_MISC0, 20946b301a05SRhyland Klein .lock_mask = PLL_BASE_LOCK, 20956b301a05SRhyland Klein .lock_delay = 1000, 20966b301a05SRhyland Klein .iddq_reg = PLLD_MISC0, 20976b301a05SRhyland Klein .iddq_bit_idx = PLLD_IDDQ_BIT, 20986b301a05SRhyland Klein .round_p_to_pdiv = pll_expo_p_to_pdiv, 20996b301a05SRhyland Klein .pdiv_tohw = pll_expo_pdiv_to_hw, 21006b301a05SRhyland Klein .div_nmp = &plld_nmp, 21016b301a05SRhyland Klein .sdm_din_reg = PLLD_MISC0, 21026b301a05SRhyland Klein .sdm_din_mask = PLLA_SDM_DIN_MASK, 21036b301a05SRhyland Klein .sdm_ctrl_reg = PLLD_MISC0, 21046b301a05SRhyland Klein .sdm_ctrl_en_mask = PLLD_SDM_EN_MASK, 21056b301a05SRhyland Klein .ext_misc_reg[0] = PLLD_MISC0, 21066b301a05SRhyland Klein .ext_misc_reg[1] = PLLD_MISC1, 21076b301a05SRhyland Klein .freq_table = pll_d_freq_table, 210814050118SRhyland Klein .flags = TEGRA_PLL_USE_LOCK, 21096b301a05SRhyland Klein .mdiv_default = 1, 21106b301a05SRhyland Klein .set_defaults = tegra210_plld_set_defaults, 21116b301a05SRhyland Klein .calc_rate = tegra210_pll_fixed_mdiv_cfg, 21126b301a05SRhyland Klein .set_gain = tegra210_clk_pll_set_gain, 21136b301a05SRhyland Klein .adjust_vco = tegra210_clk_adjust_vco_min, 21146b301a05SRhyland Klein }; 21156b301a05SRhyland Klein 21166b301a05SRhyland Klein static struct tegra_clk_pll_freq_table tegra210_pll_d2_freq_table[] = { 2117eddb65e7SThierry Reding { 12000000, 594000000, 99, 1, 2, 0, 0xf000 }, 2118eddb65e7SThierry Reding { 13000000, 594000000, 91, 1, 2, 0, 0xfc4f }, /* actual: 594000183 */ 2119eddb65e7SThierry Reding { 38400000, 594000000, 30, 1, 2, 0, 0x0e00 }, 21206b301a05SRhyland Klein { 0, 0, 0, 0, 0, 0, 0 }, 21216b301a05SRhyland Klein }; 21226b301a05SRhyland Klein 21236b301a05SRhyland Klein /* s/w policy, always tegra_pll_ref */ 21246b301a05SRhyland Klein static struct tegra_clk_pll_params pll_d2_params = { 21256b301a05SRhyland Klein .input_min = 12000000, 21266b301a05SRhyland Klein .input_max = 800000000, 21276b301a05SRhyland Klein .cf_min = 12000000, 21286b301a05SRhyland Klein .cf_max = 38400000, 21296b301a05SRhyland Klein .vco_min = 750000000, 21306b301a05SRhyland Klein .vco_max = 1500000000, 21316b301a05SRhyland Klein .base_reg = PLLD2_BASE, 21326b301a05SRhyland Klein .misc_reg = PLLD2_MISC0, 21336b301a05SRhyland Klein .lock_mask = PLL_BASE_LOCK, 21346b301a05SRhyland Klein .lock_delay = 300, 21356b301a05SRhyland Klein .iddq_reg = PLLD2_BASE, 21366b301a05SRhyland Klein .iddq_bit_idx = PLLSS_IDDQ_BIT, 21376b301a05SRhyland Klein .sdm_din_reg = PLLD2_MISC3, 21386b301a05SRhyland Klein .sdm_din_mask = PLLA_SDM_DIN_MASK, 21396b301a05SRhyland Klein .sdm_ctrl_reg = PLLD2_MISC1, 21406b301a05SRhyland Klein .sdm_ctrl_en_mask = PLLD2_SDM_EN_MASK, 2141e2f71656SThierry Reding /* disable spread-spectrum for pll_d2 */ 2142e2f71656SThierry Reding .ssc_ctrl_reg = 0, 2143e2f71656SThierry Reding .ssc_ctrl_en_mask = 0, 21446b301a05SRhyland Klein .round_p_to_pdiv = pll_qlin_p_to_pdiv, 21456b301a05SRhyland Klein .pdiv_tohw = pll_qlin_pdiv_to_hw, 21466b301a05SRhyland Klein .div_nmp = &pllss_nmp, 21476b301a05SRhyland Klein .ext_misc_reg[0] = PLLD2_MISC0, 21486b301a05SRhyland Klein .ext_misc_reg[1] = PLLD2_MISC1, 21496b301a05SRhyland Klein .ext_misc_reg[2] = PLLD2_MISC2, 21506b301a05SRhyland Klein .ext_misc_reg[3] = PLLD2_MISC3, 21516b301a05SRhyland Klein .max_p = PLL_QLIN_PDIV_MAX, 21526b301a05SRhyland Klein .mdiv_default = 1, 21536b301a05SRhyland Klein .freq_table = tegra210_pll_d2_freq_table, 21546b301a05SRhyland Klein .set_defaults = tegra210_plld2_set_defaults, 215514050118SRhyland Klein .flags = TEGRA_PLL_USE_LOCK, 21566b301a05SRhyland Klein .calc_rate = tegra210_pll_fixed_mdiv_cfg, 21576b301a05SRhyland Klein .set_gain = tegra210_clk_pll_set_gain, 21586b301a05SRhyland Klein .adjust_vco = tegra210_clk_adjust_vco_min, 21596b301a05SRhyland Klein }; 21606b301a05SRhyland Klein 21616b301a05SRhyland Klein static struct tegra_clk_pll_freq_table pll_dp_freq_table[] = { 2162eddb65e7SThierry Reding { 12000000, 270000000, 90, 1, 4, 0, 0xf000 }, 2163eddb65e7SThierry Reding { 13000000, 270000000, 83, 1, 4, 0, 0xf000 }, /* actual: 269.8 MHz */ 2164eddb65e7SThierry Reding { 38400000, 270000000, 28, 1, 4, 0, 0xf400 }, 21656b301a05SRhyland Klein { 0, 0, 0, 0, 0, 0, 0 }, 21666b301a05SRhyland Klein }; 21676b301a05SRhyland Klein 21686b301a05SRhyland Klein static struct tegra_clk_pll_params pll_dp_params = { 21696b301a05SRhyland Klein .input_min = 12000000, 21706b301a05SRhyland Klein .input_max = 800000000, 21716b301a05SRhyland Klein .cf_min = 12000000, 21726b301a05SRhyland Klein .cf_max = 38400000, 21736b301a05SRhyland Klein .vco_min = 750000000, 21746b301a05SRhyland Klein .vco_max = 1500000000, 21756b301a05SRhyland Klein .base_reg = PLLDP_BASE, 21766b301a05SRhyland Klein .misc_reg = PLLDP_MISC, 21776b301a05SRhyland Klein .lock_mask = PLL_BASE_LOCK, 21786b301a05SRhyland Klein .lock_delay = 300, 21796b301a05SRhyland Klein .iddq_reg = PLLDP_BASE, 21806b301a05SRhyland Klein .iddq_bit_idx = PLLSS_IDDQ_BIT, 21816b301a05SRhyland Klein .sdm_din_reg = PLLDP_SS_CTRL2, 21826b301a05SRhyland Klein .sdm_din_mask = PLLA_SDM_DIN_MASK, 21836b301a05SRhyland Klein .sdm_ctrl_reg = PLLDP_SS_CFG, 21846b301a05SRhyland Klein .sdm_ctrl_en_mask = PLLDP_SDM_EN_MASK, 21856b301a05SRhyland Klein .ssc_ctrl_reg = PLLDP_SS_CFG, 21866b301a05SRhyland Klein .ssc_ctrl_en_mask = PLLDP_SSC_EN_MASK, 21876b301a05SRhyland Klein .round_p_to_pdiv = pll_qlin_p_to_pdiv, 21886b301a05SRhyland Klein .pdiv_tohw = pll_qlin_pdiv_to_hw, 21896b301a05SRhyland Klein .div_nmp = &pllss_nmp, 21906b301a05SRhyland Klein .ext_misc_reg[0] = PLLDP_MISC, 21916b301a05SRhyland Klein .ext_misc_reg[1] = PLLDP_SS_CFG, 21926b301a05SRhyland Klein .ext_misc_reg[2] = PLLDP_SS_CTRL1, 21936b301a05SRhyland Klein .ext_misc_reg[3] = PLLDP_SS_CTRL2, 21946b301a05SRhyland Klein .max_p = PLL_QLIN_PDIV_MAX, 21956b301a05SRhyland Klein .mdiv_default = 1, 21966b301a05SRhyland Klein .freq_table = pll_dp_freq_table, 21976b301a05SRhyland Klein .set_defaults = tegra210_plldp_set_defaults, 219814050118SRhyland Klein .flags = TEGRA_PLL_USE_LOCK, 21996b301a05SRhyland Klein .calc_rate = tegra210_pll_fixed_mdiv_cfg, 22006b301a05SRhyland Klein .set_gain = tegra210_clk_pll_set_gain, 22016b301a05SRhyland Klein .adjust_vco = tegra210_clk_adjust_vco_min, 22026b301a05SRhyland Klein }; 22036b301a05SRhyland Klein 22046b301a05SRhyland Klein static struct div_nmp pllu_nmp = { 22056b301a05SRhyland Klein .divm_shift = 0, 22066b301a05SRhyland Klein .divm_width = 8, 22076b301a05SRhyland Klein .divn_shift = 8, 22086b301a05SRhyland Klein .divn_width = 8, 22096b301a05SRhyland Klein .divp_shift = 16, 22106b301a05SRhyland Klein .divp_width = 5, 22116b301a05SRhyland Klein }; 22126b301a05SRhyland Klein 22136b301a05SRhyland Klein static struct tegra_clk_pll_freq_table pll_u_freq_table[] = { 22140d34dfbfSJC Kuo { 12000000, 480000000, 40, 1, 1, 0 }, 22150d34dfbfSJC Kuo { 13000000, 480000000, 36, 1, 1, 0 }, /* actual: 468.0 MHz */ 22160d34dfbfSJC Kuo { 38400000, 480000000, 25, 2, 1, 0 }, 22176b301a05SRhyland Klein { 0, 0, 0, 0, 0, 0 }, 22186b301a05SRhyland Klein }; 22196b301a05SRhyland Klein 22206b301a05SRhyland Klein static struct tegra_clk_pll_params pll_u_vco_params = { 22216b301a05SRhyland Klein .input_min = 9600000, 22226b301a05SRhyland Klein .input_max = 800000000, 22236b301a05SRhyland Klein .cf_min = 9600000, 22246b301a05SRhyland Klein .cf_max = 19200000, 22256b301a05SRhyland Klein .vco_min = 350000000, 22266b301a05SRhyland Klein .vco_max = 700000000, 22276b301a05SRhyland Klein .base_reg = PLLU_BASE, 22286b301a05SRhyland Klein .misc_reg = PLLU_MISC0, 22296b301a05SRhyland Klein .lock_mask = PLL_BASE_LOCK, 22306b301a05SRhyland Klein .lock_delay = 1000, 22316b301a05SRhyland Klein .iddq_reg = PLLU_MISC0, 22326b301a05SRhyland Klein .iddq_bit_idx = PLLU_IDDQ_BIT, 22336b301a05SRhyland Klein .ext_misc_reg[0] = PLLU_MISC0, 22346b301a05SRhyland Klein .ext_misc_reg[1] = PLLU_MISC1, 22356b301a05SRhyland Klein .round_p_to_pdiv = pll_qlin_p_to_pdiv, 22366b301a05SRhyland Klein .pdiv_tohw = pll_qlin_pdiv_to_hw, 22376b301a05SRhyland Klein .div_nmp = &pllu_nmp, 22386b301a05SRhyland Klein .freq_table = pll_u_freq_table, 223914050118SRhyland Klein .flags = TEGRA_PLLU | TEGRA_PLL_USE_LOCK | TEGRA_PLL_VCO_OUT, 2240e745f992SPeter De Schrijver }; 2241e745f992SPeter De Schrijver 2242e745f992SPeter De Schrijver struct utmi_clk_param { 2243e745f992SPeter De Schrijver /* Oscillator Frequency in KHz */ 2244e745f992SPeter De Schrijver u32 osc_frequency; 2245e745f992SPeter De Schrijver /* UTMIP PLL Enable Delay Count */ 2246e745f992SPeter De Schrijver u8 enable_delay_count; 2247e745f992SPeter De Schrijver /* UTMIP PLL Stable count */ 2248e745f992SPeter De Schrijver u16 stable_count; 2249e745f992SPeter De Schrijver /* UTMIP PLL Active delay count */ 2250e745f992SPeter De Schrijver u8 active_delay_count; 2251e745f992SPeter De Schrijver /* UTMIP PLL Xtal frequency count */ 2252e745f992SPeter De Schrijver u16 xtal_freq_count; 2253e745f992SPeter De Schrijver }; 2254e745f992SPeter De Schrijver 2255e745f992SPeter De Schrijver static const struct utmi_clk_param utmi_parameters[] = { 2256e745f992SPeter De Schrijver { 2257e745f992SPeter De Schrijver .osc_frequency = 38400000, .enable_delay_count = 0x0, 2258e745f992SPeter De Schrijver .stable_count = 0x0, .active_delay_count = 0x6, 2259e745f992SPeter De Schrijver .xtal_freq_count = 0x80 2260e745f992SPeter De Schrijver }, { 2261e745f992SPeter De Schrijver .osc_frequency = 13000000, .enable_delay_count = 0x02, 2262e745f992SPeter De Schrijver .stable_count = 0x33, .active_delay_count = 0x05, 2263e745f992SPeter De Schrijver .xtal_freq_count = 0x7f 2264e745f992SPeter De Schrijver }, { 2265e745f992SPeter De Schrijver .osc_frequency = 19200000, .enable_delay_count = 0x03, 2266e745f992SPeter De Schrijver .stable_count = 0x4b, .active_delay_count = 0x06, 2267e745f992SPeter De Schrijver .xtal_freq_count = 0xbb 2268e745f992SPeter De Schrijver }, { 2269e745f992SPeter De Schrijver .osc_frequency = 12000000, .enable_delay_count = 0x02, 2270e745f992SPeter De Schrijver .stable_count = 0x2f, .active_delay_count = 0x08, 2271e745f992SPeter De Schrijver .xtal_freq_count = 0x76 2272e745f992SPeter De Schrijver }, { 2273e745f992SPeter De Schrijver .osc_frequency = 26000000, .enable_delay_count = 0x04, 2274e745f992SPeter De Schrijver .stable_count = 0x66, .active_delay_count = 0x09, 2275e745f992SPeter De Schrijver .xtal_freq_count = 0xfe 2276e745f992SPeter De Schrijver }, { 2277e745f992SPeter De Schrijver .osc_frequency = 16800000, .enable_delay_count = 0x03, 2278e745f992SPeter De Schrijver .stable_count = 0x41, .active_delay_count = 0x0a, 2279e745f992SPeter De Schrijver .xtal_freq_count = 0xa4 2280e745f992SPeter De Schrijver }, 22816b301a05SRhyland Klein }; 22826b301a05SRhyland Klein 22836b301a05SRhyland Klein static struct tegra_clk tegra210_clks[tegra_clk_max] __initdata = { 22846b301a05SRhyland Klein [tegra_clk_ispb] = { .dt_id = TEGRA210_CLK_ISPB, .present = true }, 22856b301a05SRhyland Klein [tegra_clk_rtc] = { .dt_id = TEGRA210_CLK_RTC, .present = true }, 22866b301a05SRhyland Klein [tegra_clk_timer] = { .dt_id = TEGRA210_CLK_TIMER, .present = true }, 22876b301a05SRhyland Klein [tegra_clk_uarta_8] = { .dt_id = TEGRA210_CLK_UARTA, .present = true }, 22886b301a05SRhyland Klein [tegra_clk_i2s1] = { .dt_id = TEGRA210_CLK_I2S1, .present = true }, 22896b301a05SRhyland Klein [tegra_clk_i2c1] = { .dt_id = TEGRA210_CLK_I2C1, .present = true }, 22906b301a05SRhyland Klein [tegra_clk_sdmmc1_9] = { .dt_id = TEGRA210_CLK_SDMMC1, .present = true }, 22916b301a05SRhyland Klein [tegra_clk_pwm] = { .dt_id = TEGRA210_CLK_PWM, .present = true }, 22926b301a05SRhyland Klein [tegra_clk_i2s2] = { .dt_id = TEGRA210_CLK_I2S2, .present = true }, 22936b301a05SRhyland Klein [tegra_clk_usbd] = { .dt_id = TEGRA210_CLK_USBD, .present = true }, 22946b301a05SRhyland Klein [tegra_clk_isp_9] = { .dt_id = TEGRA210_CLK_ISP, .present = true }, 22956b301a05SRhyland Klein [tegra_clk_disp2_8] = { .dt_id = TEGRA210_CLK_DISP2, .present = true }, 22966b301a05SRhyland Klein [tegra_clk_disp1_8] = { .dt_id = TEGRA210_CLK_DISP1, .present = true }, 22976b301a05SRhyland Klein [tegra_clk_host1x_9] = { .dt_id = TEGRA210_CLK_HOST1X, .present = true }, 22986b301a05SRhyland Klein [tegra_clk_i2s0] = { .dt_id = TEGRA210_CLK_I2S0, .present = true }, 22996b301a05SRhyland Klein [tegra_clk_apbdma] = { .dt_id = TEGRA210_CLK_APBDMA, .present = true }, 23006b301a05SRhyland Klein [tegra_clk_kfuse] = { .dt_id = TEGRA210_CLK_KFUSE, .present = true }, 23016b301a05SRhyland Klein [tegra_clk_sbc1_9] = { .dt_id = TEGRA210_CLK_SBC1, .present = true }, 23026b301a05SRhyland Klein [tegra_clk_sbc2_9] = { .dt_id = TEGRA210_CLK_SBC2, .present = true }, 23036b301a05SRhyland Klein [tegra_clk_sbc3_9] = { .dt_id = TEGRA210_CLK_SBC3, .present = true }, 23046b301a05SRhyland Klein [tegra_clk_i2c5] = { .dt_id = TEGRA210_CLK_I2C5, .present = true }, 23056b301a05SRhyland Klein [tegra_clk_csi] = { .dt_id = TEGRA210_CLK_CSI, .present = true }, 23066b301a05SRhyland Klein [tegra_clk_i2c2] = { .dt_id = TEGRA210_CLK_I2C2, .present = true }, 23076b301a05SRhyland Klein [tegra_clk_uartc_8] = { .dt_id = TEGRA210_CLK_UARTC, .present = true }, 23086b301a05SRhyland Klein [tegra_clk_mipi_cal] = { .dt_id = TEGRA210_CLK_MIPI_CAL, .present = true }, 23096b301a05SRhyland Klein [tegra_clk_emc] = { .dt_id = TEGRA210_CLK_EMC, .present = true }, 23106b301a05SRhyland Klein [tegra_clk_usb2] = { .dt_id = TEGRA210_CLK_USB2, .present = true }, 23116b301a05SRhyland Klein [tegra_clk_bsev] = { .dt_id = TEGRA210_CLK_BSEV, .present = true }, 23126b301a05SRhyland Klein [tegra_clk_uartd_8] = { .dt_id = TEGRA210_CLK_UARTD, .present = true }, 23136b301a05SRhyland Klein [tegra_clk_i2c3] = { .dt_id = TEGRA210_CLK_I2C3, .present = true }, 23146b301a05SRhyland Klein [tegra_clk_sbc4_9] = { .dt_id = TEGRA210_CLK_SBC4, .present = true }, 23156b301a05SRhyland Klein [tegra_clk_sdmmc3_9] = { .dt_id = TEGRA210_CLK_SDMMC3, .present = true }, 23166b301a05SRhyland Klein [tegra_clk_pcie] = { .dt_id = TEGRA210_CLK_PCIE, .present = true }, 23176b301a05SRhyland Klein [tegra_clk_owr_8] = { .dt_id = TEGRA210_CLK_OWR, .present = true }, 23186b301a05SRhyland Klein [tegra_clk_afi] = { .dt_id = TEGRA210_CLK_AFI, .present = true }, 23196b301a05SRhyland Klein [tegra_clk_csite_8] = { .dt_id = TEGRA210_CLK_CSITE, .present = true }, 23206b301a05SRhyland Klein [tegra_clk_soc_therm_8] = { .dt_id = TEGRA210_CLK_SOC_THERM, .present = true }, 23216b301a05SRhyland Klein [tegra_clk_dtv] = { .dt_id = TEGRA210_CLK_DTV, .present = true }, 23226b301a05SRhyland Klein [tegra_clk_i2cslow] = { .dt_id = TEGRA210_CLK_I2CSLOW, .present = true }, 23236b301a05SRhyland Klein [tegra_clk_tsec_8] = { .dt_id = TEGRA210_CLK_TSEC, .present = true }, 23246b301a05SRhyland Klein [tegra_clk_xusb_host] = { .dt_id = TEGRA210_CLK_XUSB_HOST, .present = true }, 23256b301a05SRhyland Klein [tegra_clk_csus] = { .dt_id = TEGRA210_CLK_CSUS, .present = true }, 23266b301a05SRhyland Klein [tegra_clk_mselect] = { .dt_id = TEGRA210_CLK_MSELECT, .present = true }, 23276b301a05SRhyland Klein [tegra_clk_tsensor] = { .dt_id = TEGRA210_CLK_TSENSOR, .present = true }, 23286b301a05SRhyland Klein [tegra_clk_i2s3] = { .dt_id = TEGRA210_CLK_I2S3, .present = true }, 23296b301a05SRhyland Klein [tegra_clk_i2s4] = { .dt_id = TEGRA210_CLK_I2S4, .present = true }, 23306b301a05SRhyland Klein [tegra_clk_i2c4] = { .dt_id = TEGRA210_CLK_I2C4, .present = true }, 23316b301a05SRhyland Klein [tegra_clk_d_audio] = { .dt_id = TEGRA210_CLK_D_AUDIO, .present = true }, 23326b301a05SRhyland Klein [tegra_clk_hda2codec_2x_8] = { .dt_id = TEGRA210_CLK_HDA2CODEC_2X, .present = true }, 23336b301a05SRhyland Klein [tegra_clk_spdif_2x] = { .dt_id = TEGRA210_CLK_SPDIF_2X, .present = true }, 23346b301a05SRhyland Klein [tegra_clk_actmon] = { .dt_id = TEGRA210_CLK_ACTMON, .present = true }, 23356b301a05SRhyland Klein [tegra_clk_extern1] = { .dt_id = TEGRA210_CLK_EXTERN1, .present = true }, 23366b301a05SRhyland Klein [tegra_clk_extern2] = { .dt_id = TEGRA210_CLK_EXTERN2, .present = true }, 23376b301a05SRhyland Klein [tegra_clk_extern3] = { .dt_id = TEGRA210_CLK_EXTERN3, .present = true }, 23386b301a05SRhyland Klein [tegra_clk_sata_oob_8] = { .dt_id = TEGRA210_CLK_SATA_OOB, .present = true }, 23396b301a05SRhyland Klein [tegra_clk_sata_8] = { .dt_id = TEGRA210_CLK_SATA, .present = true }, 23406b301a05SRhyland Klein [tegra_clk_hda_8] = { .dt_id = TEGRA210_CLK_HDA, .present = true }, 23416b301a05SRhyland Klein [tegra_clk_hda2hdmi] = { .dt_id = TEGRA210_CLK_HDA2HDMI, .present = true }, 23426b301a05SRhyland Klein [tegra_clk_cilab] = { .dt_id = TEGRA210_CLK_CILAB, .present = true }, 23436b301a05SRhyland Klein [tegra_clk_cilcd] = { .dt_id = TEGRA210_CLK_CILCD, .present = true }, 23446b301a05SRhyland Klein [tegra_clk_cile] = { .dt_id = TEGRA210_CLK_CILE, .present = true }, 23456b301a05SRhyland Klein [tegra_clk_dsialp] = { .dt_id = TEGRA210_CLK_DSIALP, .present = true }, 23466b301a05SRhyland Klein [tegra_clk_dsiblp] = { .dt_id = TEGRA210_CLK_DSIBLP, .present = true }, 23476b301a05SRhyland Klein [tegra_clk_entropy_8] = { .dt_id = TEGRA210_CLK_ENTROPY, .present = true }, 23486b301a05SRhyland Klein [tegra_clk_xusb_ss] = { .dt_id = TEGRA210_CLK_XUSB_SS, .present = true }, 23496b301a05SRhyland Klein [tegra_clk_i2c6] = { .dt_id = TEGRA210_CLK_I2C6, .present = true }, 23506b301a05SRhyland Klein [tegra_clk_vim2_clk] = { .dt_id = TEGRA210_CLK_VIM2_CLK, .present = true }, 23516b301a05SRhyland Klein [tegra_clk_clk72Mhz_8] = { .dt_id = TEGRA210_CLK_CLK72MHZ, .present = true }, 23526b301a05SRhyland Klein [tegra_clk_vic03_8] = { .dt_id = TEGRA210_CLK_VIC03, .present = true }, 23536b301a05SRhyland Klein [tegra_clk_dpaux] = { .dt_id = TEGRA210_CLK_DPAUX, .present = true }, 235498c4b366SThierry Reding [tegra_clk_dpaux1] = { .dt_id = TEGRA210_CLK_DPAUX1, .present = true }, 23556b301a05SRhyland Klein [tegra_clk_sor0] = { .dt_id = TEGRA210_CLK_SOR0, .present = true }, 2356da8d1a35SThierry Reding [tegra_clk_sor0_out] = { .dt_id = TEGRA210_CLK_SOR0_OUT, .present = true }, 2357e452b818SThierry Reding [tegra_clk_sor1] = { .dt_id = TEGRA210_CLK_SOR1, .present = true }, 2358991a051eSThierry Reding [tegra_clk_sor1_out] = { .dt_id = TEGRA210_CLK_SOR1_OUT, .present = true }, 23596b301a05SRhyland Klein [tegra_clk_gpu] = { .dt_id = TEGRA210_CLK_GPU, .present = true }, 23606b301a05SRhyland Klein [tegra_clk_pll_g_ref] = { .dt_id = TEGRA210_CLK_PLL_G_REF, .present = true, }, 23616b301a05SRhyland Klein [tegra_clk_uartb_8] = { .dt_id = TEGRA210_CLK_UARTB, .present = true }, 23626b301a05SRhyland Klein [tegra_clk_spdif_in_8] = { .dt_id = TEGRA210_CLK_SPDIF_IN, .present = true }, 23636b301a05SRhyland Klein [tegra_clk_spdif_out] = { .dt_id = TEGRA210_CLK_SPDIF_OUT, .present = true }, 23646b301a05SRhyland Klein [tegra_clk_vi_10] = { .dt_id = TEGRA210_CLK_VI, .present = true }, 23656b301a05SRhyland Klein [tegra_clk_vi_sensor_8] = { .dt_id = TEGRA210_CLK_VI_SENSOR, .present = true }, 23666b301a05SRhyland Klein [tegra_clk_fuse] = { .dt_id = TEGRA210_CLK_FUSE, .present = true }, 23676b301a05SRhyland Klein [tegra_clk_fuse_burn] = { .dt_id = TEGRA210_CLK_FUSE_BURN, .present = true }, 23686b301a05SRhyland Klein [tegra_clk_clk_32k] = { .dt_id = TEGRA210_CLK_CLK_32K, .present = true }, 23696b301a05SRhyland Klein [tegra_clk_clk_m] = { .dt_id = TEGRA210_CLK_CLK_M, .present = true }, 23706b301a05SRhyland Klein [tegra_clk_clk_m_div2] = { .dt_id = TEGRA210_CLK_CLK_M_DIV2, .present = true }, 23716b301a05SRhyland Klein [tegra_clk_clk_m_div4] = { .dt_id = TEGRA210_CLK_CLK_M_DIV4, .present = true }, 23726b301a05SRhyland Klein [tegra_clk_pll_ref] = { .dt_id = TEGRA210_CLK_PLL_REF, .present = true }, 23736b301a05SRhyland Klein [tegra_clk_pll_c] = { .dt_id = TEGRA210_CLK_PLL_C, .present = true }, 23746b301a05SRhyland Klein [tegra_clk_pll_c_out1] = { .dt_id = TEGRA210_CLK_PLL_C_OUT1, .present = true }, 23756b301a05SRhyland Klein [tegra_clk_pll_c2] = { .dt_id = TEGRA210_CLK_PLL_C2, .present = true }, 23766b301a05SRhyland Klein [tegra_clk_pll_c3] = { .dt_id = TEGRA210_CLK_PLL_C3, .present = true }, 23776b301a05SRhyland Klein [tegra_clk_pll_m] = { .dt_id = TEGRA210_CLK_PLL_M, .present = true }, 23786b301a05SRhyland Klein [tegra_clk_pll_p] = { .dt_id = TEGRA210_CLK_PLL_P, .present = true }, 23796b301a05SRhyland Klein [tegra_clk_pll_p_out1] = { .dt_id = TEGRA210_CLK_PLL_P_OUT1, .present = true }, 23806b301a05SRhyland Klein [tegra_clk_pll_p_out3] = { .dt_id = TEGRA210_CLK_PLL_P_OUT3, .present = true }, 23816b301a05SRhyland Klein [tegra_clk_pll_p_out4_cpu] = { .dt_id = TEGRA210_CLK_PLL_P_OUT4, .present = true }, 23826b301a05SRhyland Klein [tegra_clk_pll_p_out_hsio] = { .dt_id = TEGRA210_CLK_PLL_P_OUT_HSIO, .present = true }, 23836b301a05SRhyland Klein [tegra_clk_pll_p_out_xusb] = { .dt_id = TEGRA210_CLK_PLL_P_OUT_XUSB, .present = true }, 23846b301a05SRhyland Klein [tegra_clk_pll_p_out_cpu] = { .dt_id = TEGRA210_CLK_PLL_P_OUT_CPU, .present = true }, 23856b301a05SRhyland Klein [tegra_clk_pll_p_out_adsp] = { .dt_id = TEGRA210_CLK_PLL_P_OUT_ADSP, .present = true }, 23866b301a05SRhyland Klein [tegra_clk_pll_a] = { .dt_id = TEGRA210_CLK_PLL_A, .present = true }, 23876b301a05SRhyland Klein [tegra_clk_pll_a_out0] = { .dt_id = TEGRA210_CLK_PLL_A_OUT0, .present = true }, 23886b301a05SRhyland Klein [tegra_clk_pll_d] = { .dt_id = TEGRA210_CLK_PLL_D, .present = true }, 23896b301a05SRhyland Klein [tegra_clk_pll_d_out0] = { .dt_id = TEGRA210_CLK_PLL_D_OUT0, .present = true }, 23906b301a05SRhyland Klein [tegra_clk_pll_d2] = { .dt_id = TEGRA210_CLK_PLL_D2, .present = true }, 23916b301a05SRhyland Klein [tegra_clk_pll_d2_out0] = { .dt_id = TEGRA210_CLK_PLL_D2_OUT0, .present = true }, 23926b301a05SRhyland Klein [tegra_clk_pll_u] = { .dt_id = TEGRA210_CLK_PLL_U, .present = true }, 23936b301a05SRhyland Klein [tegra_clk_pll_u_out] = { .dt_id = TEGRA210_CLK_PLL_U_OUT, .present = true }, 23946b301a05SRhyland Klein [tegra_clk_pll_u_out1] = { .dt_id = TEGRA210_CLK_PLL_U_OUT1, .present = true }, 23956b301a05SRhyland Klein [tegra_clk_pll_u_out2] = { .dt_id = TEGRA210_CLK_PLL_U_OUT2, .present = true }, 23966b301a05SRhyland Klein [tegra_clk_pll_u_480m] = { .dt_id = TEGRA210_CLK_PLL_U_480M, .present = true }, 23976b301a05SRhyland Klein [tegra_clk_pll_u_60m] = { .dt_id = TEGRA210_CLK_PLL_U_60M, .present = true }, 23986b301a05SRhyland Klein [tegra_clk_pll_u_48m] = { .dt_id = TEGRA210_CLK_PLL_U_48M, .present = true }, 23996b301a05SRhyland Klein [tegra_clk_pll_x] = { .dt_id = TEGRA210_CLK_PLL_X, .present = true }, 24006b301a05SRhyland Klein [tegra_clk_pll_x_out0] = { .dt_id = TEGRA210_CLK_PLL_X_OUT0, .present = true }, 24016b301a05SRhyland Klein [tegra_clk_pll_re_vco] = { .dt_id = TEGRA210_CLK_PLL_RE_VCO, .present = true }, 24026b301a05SRhyland Klein [tegra_clk_pll_re_out] = { .dt_id = TEGRA210_CLK_PLL_RE_OUT, .present = true }, 24036b301a05SRhyland Klein [tegra_clk_spdif_in_sync] = { .dt_id = TEGRA210_CLK_SPDIF_IN_SYNC, .present = true }, 24046b301a05SRhyland Klein [tegra_clk_i2s0_sync] = { .dt_id = TEGRA210_CLK_I2S0_SYNC, .present = true }, 24056b301a05SRhyland Klein [tegra_clk_i2s1_sync] = { .dt_id = TEGRA210_CLK_I2S1_SYNC, .present = true }, 24066b301a05SRhyland Klein [tegra_clk_i2s2_sync] = { .dt_id = TEGRA210_CLK_I2S2_SYNC, .present = true }, 24076b301a05SRhyland Klein [tegra_clk_i2s3_sync] = { .dt_id = TEGRA210_CLK_I2S3_SYNC, .present = true }, 24086b301a05SRhyland Klein [tegra_clk_i2s4_sync] = { .dt_id = TEGRA210_CLK_I2S4_SYNC, .present = true }, 24096b301a05SRhyland Klein [tegra_clk_vimclk_sync] = { .dt_id = TEGRA210_CLK_VIMCLK_SYNC, .present = true }, 24106b301a05SRhyland Klein [tegra_clk_audio0] = { .dt_id = TEGRA210_CLK_AUDIO0, .present = true }, 24116b301a05SRhyland Klein [tegra_clk_audio1] = { .dt_id = TEGRA210_CLK_AUDIO1, .present = true }, 24126b301a05SRhyland Klein [tegra_clk_audio2] = { .dt_id = TEGRA210_CLK_AUDIO2, .present = true }, 24136b301a05SRhyland Klein [tegra_clk_audio3] = { .dt_id = TEGRA210_CLK_AUDIO3, .present = true }, 24146b301a05SRhyland Klein [tegra_clk_audio4] = { .dt_id = TEGRA210_CLK_AUDIO4, .present = true }, 24156b301a05SRhyland Klein [tegra_clk_spdif] = { .dt_id = TEGRA210_CLK_SPDIF, .present = true }, 24166b301a05SRhyland Klein [tegra_clk_clk_out_1] = { .dt_id = TEGRA210_CLK_CLK_OUT_1, .present = true }, 24176b301a05SRhyland Klein [tegra_clk_clk_out_2] = { .dt_id = TEGRA210_CLK_CLK_OUT_2, .present = true }, 24186b301a05SRhyland Klein [tegra_clk_clk_out_3] = { .dt_id = TEGRA210_CLK_CLK_OUT_3, .present = true }, 24196b301a05SRhyland Klein [tegra_clk_blink] = { .dt_id = TEGRA210_CLK_BLINK, .present = true }, 24206b301a05SRhyland Klein [tegra_clk_xusb_gate] = { .dt_id = TEGRA210_CLK_XUSB_GATE, .present = true }, 24216b301a05SRhyland Klein [tegra_clk_xusb_host_src_8] = { .dt_id = TEGRA210_CLK_XUSB_HOST_SRC, .present = true }, 24226b301a05SRhyland Klein [tegra_clk_xusb_falcon_src_8] = { .dt_id = TEGRA210_CLK_XUSB_FALCON_SRC, .present = true }, 24236b301a05SRhyland Klein [tegra_clk_xusb_fs_src] = { .dt_id = TEGRA210_CLK_XUSB_FS_SRC, .present = true }, 24246b301a05SRhyland Klein [tegra_clk_xusb_ss_src_8] = { .dt_id = TEGRA210_CLK_XUSB_SS_SRC, .present = true }, 24256b301a05SRhyland Klein [tegra_clk_xusb_ss_div2] = { .dt_id = TEGRA210_CLK_XUSB_SS_DIV2, .present = true }, 24266b301a05SRhyland Klein [tegra_clk_xusb_dev_src_8] = { .dt_id = TEGRA210_CLK_XUSB_DEV_SRC, .present = true }, 24276b301a05SRhyland Klein [tegra_clk_xusb_dev] = { .dt_id = TEGRA210_CLK_XUSB_DEV, .present = true }, 24286b301a05SRhyland Klein [tegra_clk_xusb_hs_src_4] = { .dt_id = TEGRA210_CLK_XUSB_HS_SRC, .present = true }, 24296b301a05SRhyland Klein [tegra_clk_xusb_ssp_src] = { .dt_id = TEGRA210_CLK_XUSB_SSP_SRC, .present = true }, 24306b301a05SRhyland Klein [tegra_clk_usb2_hsic_trk] = { .dt_id = TEGRA210_CLK_USB2_HSIC_TRK, .present = true }, 24316b301a05SRhyland Klein [tegra_clk_hsic_trk] = { .dt_id = TEGRA210_CLK_HSIC_TRK, .present = true }, 24326b301a05SRhyland Klein [tegra_clk_usb2_trk] = { .dt_id = TEGRA210_CLK_USB2_TRK, .present = true }, 24336b301a05SRhyland Klein [tegra_clk_sclk] = { .dt_id = TEGRA210_CLK_SCLK, .present = true }, 24346b301a05SRhyland Klein [tegra_clk_sclk_mux] = { .dt_id = TEGRA210_CLK_SCLK_MUX, .present = true }, 24356b301a05SRhyland Klein [tegra_clk_hclk] = { .dt_id = TEGRA210_CLK_HCLK, .present = true }, 24366b301a05SRhyland Klein [tegra_clk_pclk] = { .dt_id = TEGRA210_CLK_PCLK, .present = true }, 24376b301a05SRhyland Klein [tegra_clk_cclk_g] = { .dt_id = TEGRA210_CLK_CCLK_G, .present = true }, 24386b301a05SRhyland Klein [tegra_clk_cclk_lp] = { .dt_id = TEGRA210_CLK_CCLK_LP, .present = true }, 24396b301a05SRhyland Klein [tegra_clk_dfll_ref] = { .dt_id = TEGRA210_CLK_DFLL_REF, .present = true }, 24406b301a05SRhyland Klein [tegra_clk_dfll_soc] = { .dt_id = TEGRA210_CLK_DFLL_SOC, .present = true }, 24416b301a05SRhyland Klein [tegra_clk_vi_sensor2_8] = { .dt_id = TEGRA210_CLK_VI_SENSOR2, .present = true }, 24426b301a05SRhyland Klein [tegra_clk_pll_p_out5] = { .dt_id = TEGRA210_CLK_PLL_P_OUT5, .present = true }, 24436b301a05SRhyland Klein [tegra_clk_pll_c4] = { .dt_id = TEGRA210_CLK_PLL_C4, .present = true }, 24446b301a05SRhyland Klein [tegra_clk_pll_dp] = { .dt_id = TEGRA210_CLK_PLL_DP, .present = true }, 24456b301a05SRhyland Klein [tegra_clk_audio0_mux] = { .dt_id = TEGRA210_CLK_AUDIO0_MUX, .present = true }, 24466b301a05SRhyland Klein [tegra_clk_audio1_mux] = { .dt_id = TEGRA210_CLK_AUDIO1_MUX, .present = true }, 24476b301a05SRhyland Klein [tegra_clk_audio2_mux] = { .dt_id = TEGRA210_CLK_AUDIO2_MUX, .present = true }, 24486b301a05SRhyland Klein [tegra_clk_audio3_mux] = { .dt_id = TEGRA210_CLK_AUDIO3_MUX, .present = true }, 24496b301a05SRhyland Klein [tegra_clk_audio4_mux] = { .dt_id = TEGRA210_CLK_AUDIO4_MUX, .present = true }, 24506b301a05SRhyland Klein [tegra_clk_spdif_mux] = { .dt_id = TEGRA210_CLK_SPDIF_MUX, .present = true }, 24516b301a05SRhyland Klein [tegra_clk_clk_out_1_mux] = { .dt_id = TEGRA210_CLK_CLK_OUT_1_MUX, .present = true }, 24526b301a05SRhyland Klein [tegra_clk_clk_out_2_mux] = { .dt_id = TEGRA210_CLK_CLK_OUT_2_MUX, .present = true }, 24536b301a05SRhyland Klein [tegra_clk_clk_out_3_mux] = { .dt_id = TEGRA210_CLK_CLK_OUT_3_MUX, .present = true }, 24546b301a05SRhyland Klein [tegra_clk_maud] = { .dt_id = TEGRA210_CLK_MAUD, .present = true }, 24556b301a05SRhyland Klein [tegra_clk_mipibif] = { .dt_id = TEGRA210_CLK_MIPIBIF, .present = true }, 24566b301a05SRhyland Klein [tegra_clk_qspi] = { .dt_id = TEGRA210_CLK_QSPI, .present = true }, 24576b301a05SRhyland Klein [tegra_clk_sdmmc_legacy] = { .dt_id = TEGRA210_CLK_SDMMC_LEGACY, .present = true }, 24586b301a05SRhyland Klein [tegra_clk_tsecb] = { .dt_id = TEGRA210_CLK_TSECB, .present = true }, 24596b301a05SRhyland Klein [tegra_clk_uartape] = { .dt_id = TEGRA210_CLK_UARTAPE, .present = true }, 24606b301a05SRhyland Klein [tegra_clk_vi_i2c] = { .dt_id = TEGRA210_CLK_VI_I2C, .present = true }, 24616b301a05SRhyland Klein [tegra_clk_ape] = { .dt_id = TEGRA210_CLK_APE, .present = true }, 24626b301a05SRhyland Klein [tegra_clk_dbgapb] = { .dt_id = TEGRA210_CLK_DBGAPB, .present = true }, 24636b301a05SRhyland Klein [tegra_clk_nvdec] = { .dt_id = TEGRA210_CLK_NVDEC, .present = true }, 24646b301a05SRhyland Klein [tegra_clk_nvenc] = { .dt_id = TEGRA210_CLK_NVENC, .present = true }, 24656b301a05SRhyland Klein [tegra_clk_nvjpg] = { .dt_id = TEGRA210_CLK_NVJPG, .present = true }, 24666b301a05SRhyland Klein [tegra_clk_pll_c4_out0] = { .dt_id = TEGRA210_CLK_PLL_C4_OUT0, .present = true }, 24676b301a05SRhyland Klein [tegra_clk_pll_c4_out1] = { .dt_id = TEGRA210_CLK_PLL_C4_OUT1, .present = true }, 24686b301a05SRhyland Klein [tegra_clk_pll_c4_out2] = { .dt_id = TEGRA210_CLK_PLL_C4_OUT2, .present = true }, 24696b301a05SRhyland Klein [tegra_clk_pll_c4_out3] = { .dt_id = TEGRA210_CLK_PLL_C4_OUT3, .present = true }, 247029569941SJon Hunter [tegra_clk_apb2ape] = { .dt_id = TEGRA210_CLK_APB2APE, .present = true }, 24719326947fSPeter De Schrijver [tegra_clk_pll_a1] = { .dt_id = TEGRA210_CLK_PLL_A1, .present = true }, 247234ac2c27SPeter De Schrijver [tegra_clk_ispa] = { .dt_id = TEGRA210_CLK_ISPA, .present = true }, 2473bfa34832SPeter De Schrijver [tegra_clk_cec] = { .dt_id = TEGRA210_CLK_CEC, .present = true }, 24746cfc8bc9SPeter De Schrijver [tegra_clk_dmic1] = { .dt_id = TEGRA210_CLK_DMIC1, .present = true }, 24756cfc8bc9SPeter De Schrijver [tegra_clk_dmic2] = { .dt_id = TEGRA210_CLK_DMIC2, .present = true }, 24766cfc8bc9SPeter De Schrijver [tegra_clk_dmic3] = { .dt_id = TEGRA210_CLK_DMIC3, .present = true }, 2477319af797SPeter De Schrijver [tegra_clk_dmic1_sync_clk] = { .dt_id = TEGRA210_CLK_DMIC1_SYNC_CLK, .present = true }, 2478319af797SPeter De Schrijver [tegra_clk_dmic2_sync_clk] = { .dt_id = TEGRA210_CLK_DMIC2_SYNC_CLK, .present = true }, 2479319af797SPeter De Schrijver [tegra_clk_dmic3_sync_clk] = { .dt_id = TEGRA210_CLK_DMIC3_SYNC_CLK, .present = true }, 2480319af797SPeter De Schrijver [tegra_clk_dmic1_sync_clk_mux] = { .dt_id = TEGRA210_CLK_DMIC1_SYNC_CLK_MUX, .present = true }, 2481319af797SPeter De Schrijver [tegra_clk_dmic2_sync_clk_mux] = { .dt_id = TEGRA210_CLK_DMIC2_SYNC_CLK_MUX, .present = true }, 2482319af797SPeter De Schrijver [tegra_clk_dmic3_sync_clk_mux] = { .dt_id = TEGRA210_CLK_DMIC3_SYNC_CLK_MUX, .present = true }, 248388da44c5SPeter De Schrijver [tegra_clk_dp2] = { .dt_id = TEGRA210_CLK_DP2, .present = true }, 248488da44c5SPeter De Schrijver [tegra_clk_iqc1] = { .dt_id = TEGRA210_CLK_IQC1, .present = true }, 248588da44c5SPeter De Schrijver [tegra_clk_iqc2] = { .dt_id = TEGRA210_CLK_IQC2, .present = true }, 248688da44c5SPeter De Schrijver [tegra_clk_pll_a_out_adsp] = { .dt_id = TEGRA210_CLK_PLL_A_OUT_ADSP, .present = true }, 248788da44c5SPeter De Schrijver [tegra_clk_pll_a_out0_out_adsp] = { .dt_id = TEGRA210_CLK_PLL_A_OUT0_OUT_ADSP, .present = true }, 248888da44c5SPeter De Schrijver [tegra_clk_adsp] = { .dt_id = TEGRA210_CLK_ADSP, .present = true }, 248988da44c5SPeter De Schrijver [tegra_clk_adsp_neon] = { .dt_id = TEGRA210_CLK_ADSP_NEON, .present = true }, 24906b301a05SRhyland Klein }; 24916b301a05SRhyland Klein 24926b301a05SRhyland Klein static struct tegra_devclk devclks[] __initdata = { 24936b301a05SRhyland Klein { .con_id = "clk_m", .dt_id = TEGRA210_CLK_CLK_M }, 24946b301a05SRhyland Klein { .con_id = "pll_ref", .dt_id = TEGRA210_CLK_PLL_REF }, 24956b301a05SRhyland Klein { .con_id = "clk_32k", .dt_id = TEGRA210_CLK_CLK_32K }, 24966b301a05SRhyland Klein { .con_id = "clk_m_div2", .dt_id = TEGRA210_CLK_CLK_M_DIV2 }, 24976b301a05SRhyland Klein { .con_id = "clk_m_div4", .dt_id = TEGRA210_CLK_CLK_M_DIV4 }, 24986b301a05SRhyland Klein { .con_id = "pll_c", .dt_id = TEGRA210_CLK_PLL_C }, 24996b301a05SRhyland Klein { .con_id = "pll_c_out1", .dt_id = TEGRA210_CLK_PLL_C_OUT1 }, 25006b301a05SRhyland Klein { .con_id = "pll_c2", .dt_id = TEGRA210_CLK_PLL_C2 }, 25016b301a05SRhyland Klein { .con_id = "pll_c3", .dt_id = TEGRA210_CLK_PLL_C3 }, 25026b301a05SRhyland Klein { .con_id = "pll_p", .dt_id = TEGRA210_CLK_PLL_P }, 25036b301a05SRhyland Klein { .con_id = "pll_p_out1", .dt_id = TEGRA210_CLK_PLL_P_OUT1 }, 25046b301a05SRhyland Klein { .con_id = "pll_p_out2", .dt_id = TEGRA210_CLK_PLL_P_OUT2 }, 25056b301a05SRhyland Klein { .con_id = "pll_p_out3", .dt_id = TEGRA210_CLK_PLL_P_OUT3 }, 25066b301a05SRhyland Klein { .con_id = "pll_p_out4", .dt_id = TEGRA210_CLK_PLL_P_OUT4 }, 25076b301a05SRhyland Klein { .con_id = "pll_m", .dt_id = TEGRA210_CLK_PLL_M }, 25086b301a05SRhyland Klein { .con_id = "pll_x", .dt_id = TEGRA210_CLK_PLL_X }, 25096b301a05SRhyland Klein { .con_id = "pll_x_out0", .dt_id = TEGRA210_CLK_PLL_X_OUT0 }, 25106b301a05SRhyland Klein { .con_id = "pll_u", .dt_id = TEGRA210_CLK_PLL_U }, 25116b301a05SRhyland Klein { .con_id = "pll_u_out", .dt_id = TEGRA210_CLK_PLL_U_OUT }, 25126b301a05SRhyland Klein { .con_id = "pll_u_out1", .dt_id = TEGRA210_CLK_PLL_U_OUT1 }, 25136b301a05SRhyland Klein { .con_id = "pll_u_out2", .dt_id = TEGRA210_CLK_PLL_U_OUT2 }, 25146b301a05SRhyland Klein { .con_id = "pll_u_480M", .dt_id = TEGRA210_CLK_PLL_U_480M }, 25156b301a05SRhyland Klein { .con_id = "pll_u_60M", .dt_id = TEGRA210_CLK_PLL_U_60M }, 25166b301a05SRhyland Klein { .con_id = "pll_u_48M", .dt_id = TEGRA210_CLK_PLL_U_48M }, 25176b301a05SRhyland Klein { .con_id = "pll_d", .dt_id = TEGRA210_CLK_PLL_D }, 25186b301a05SRhyland Klein { .con_id = "pll_d_out0", .dt_id = TEGRA210_CLK_PLL_D_OUT0 }, 25196b301a05SRhyland Klein { .con_id = "pll_d2", .dt_id = TEGRA210_CLK_PLL_D2 }, 25206b301a05SRhyland Klein { .con_id = "pll_d2_out0", .dt_id = TEGRA210_CLK_PLL_D2_OUT0 }, 25216b301a05SRhyland Klein { .con_id = "pll_a", .dt_id = TEGRA210_CLK_PLL_A }, 25226b301a05SRhyland Klein { .con_id = "pll_a_out0", .dt_id = TEGRA210_CLK_PLL_A_OUT0 }, 25236b301a05SRhyland Klein { .con_id = "pll_re_vco", .dt_id = TEGRA210_CLK_PLL_RE_VCO }, 25246b301a05SRhyland Klein { .con_id = "pll_re_out", .dt_id = TEGRA210_CLK_PLL_RE_OUT }, 25256b301a05SRhyland Klein { .con_id = "spdif_in_sync", .dt_id = TEGRA210_CLK_SPDIF_IN_SYNC }, 25266b301a05SRhyland Klein { .con_id = "i2s0_sync", .dt_id = TEGRA210_CLK_I2S0_SYNC }, 25276b301a05SRhyland Klein { .con_id = "i2s1_sync", .dt_id = TEGRA210_CLK_I2S1_SYNC }, 25286b301a05SRhyland Klein { .con_id = "i2s2_sync", .dt_id = TEGRA210_CLK_I2S2_SYNC }, 25296b301a05SRhyland Klein { .con_id = "i2s3_sync", .dt_id = TEGRA210_CLK_I2S3_SYNC }, 25306b301a05SRhyland Klein { .con_id = "i2s4_sync", .dt_id = TEGRA210_CLK_I2S4_SYNC }, 25316b301a05SRhyland Klein { .con_id = "vimclk_sync", .dt_id = TEGRA210_CLK_VIMCLK_SYNC }, 25326b301a05SRhyland Klein { .con_id = "audio0", .dt_id = TEGRA210_CLK_AUDIO0 }, 25336b301a05SRhyland Klein { .con_id = "audio1", .dt_id = TEGRA210_CLK_AUDIO1 }, 25346b301a05SRhyland Klein { .con_id = "audio2", .dt_id = TEGRA210_CLK_AUDIO2 }, 25356b301a05SRhyland Klein { .con_id = "audio3", .dt_id = TEGRA210_CLK_AUDIO3 }, 25366b301a05SRhyland Klein { .con_id = "audio4", .dt_id = TEGRA210_CLK_AUDIO4 }, 25376b301a05SRhyland Klein { .con_id = "spdif", .dt_id = TEGRA210_CLK_SPDIF }, 25386b301a05SRhyland Klein { .con_id = "spdif_2x", .dt_id = TEGRA210_CLK_SPDIF_2X }, 25396b301a05SRhyland Klein { .con_id = "extern1", .dev_id = "clk_out_1", .dt_id = TEGRA210_CLK_EXTERN1 }, 25406b301a05SRhyland Klein { .con_id = "extern2", .dev_id = "clk_out_2", .dt_id = TEGRA210_CLK_EXTERN2 }, 25416b301a05SRhyland Klein { .con_id = "extern3", .dev_id = "clk_out_3", .dt_id = TEGRA210_CLK_EXTERN3 }, 25426b301a05SRhyland Klein { .con_id = "blink", .dt_id = TEGRA210_CLK_BLINK }, 25436b301a05SRhyland Klein { .con_id = "cclk_g", .dt_id = TEGRA210_CLK_CCLK_G }, 25446b301a05SRhyland Klein { .con_id = "cclk_lp", .dt_id = TEGRA210_CLK_CCLK_LP }, 25456b301a05SRhyland Klein { .con_id = "sclk", .dt_id = TEGRA210_CLK_SCLK }, 25466b301a05SRhyland Klein { .con_id = "hclk", .dt_id = TEGRA210_CLK_HCLK }, 25476b301a05SRhyland Klein { .con_id = "pclk", .dt_id = TEGRA210_CLK_PCLK }, 25486b301a05SRhyland Klein { .con_id = "fuse", .dt_id = TEGRA210_CLK_FUSE }, 25496b301a05SRhyland Klein { .dev_id = "rtc-tegra", .dt_id = TEGRA210_CLK_RTC }, 25506b301a05SRhyland Klein { .dev_id = "timer", .dt_id = TEGRA210_CLK_TIMER }, 25516b301a05SRhyland Klein { .con_id = "pll_c4_out0", .dt_id = TEGRA210_CLK_PLL_C4_OUT0 }, 25526b301a05SRhyland Klein { .con_id = "pll_c4_out1", .dt_id = TEGRA210_CLK_PLL_C4_OUT1 }, 25536b301a05SRhyland Klein { .con_id = "pll_c4_out2", .dt_id = TEGRA210_CLK_PLL_C4_OUT2 }, 25546b301a05SRhyland Klein { .con_id = "pll_c4_out3", .dt_id = TEGRA210_CLK_PLL_C4_OUT3 }, 25556b301a05SRhyland Klein { .con_id = "dpaux", .dt_id = TEGRA210_CLK_DPAUX }, 25566b301a05SRhyland Klein }; 25576b301a05SRhyland Klein 25586b301a05SRhyland Klein static struct tegra_audio_clk_info tegra210_audio_plls[] = { 25596b301a05SRhyland Klein { "pll_a", &pll_a_params, tegra_clk_pll_a, "pll_ref" }, 25606b301a05SRhyland Klein { "pll_a1", &pll_a1_params, tegra_clk_pll_a1, "pll_ref" }, 25616b301a05SRhyland Klein }; 25626b301a05SRhyland Klein 256324c3ebefSPeter De Schrijver static const char * const aclk_parents[] = { 256424c3ebefSPeter De Schrijver "pll_a1", "pll_c", "pll_p", "pll_a_out0", "pll_c2", "pll_c3", 256524c3ebefSPeter De Schrijver "clk_m" 256624c3ebefSPeter De Schrijver }; 256724c3ebefSPeter De Schrijver 2568e403d005SPeter De Schrijver static const unsigned int nvjpg_slcg_clkids[] = { TEGRA210_CLK_NVDEC }; 2569e403d005SPeter De Schrijver static const unsigned int nvdec_slcg_clkids[] = { TEGRA210_CLK_NVJPG }; 2570e403d005SPeter De Schrijver static const unsigned int sor_slcg_clkids[] = { TEGRA210_CLK_HDA2CODEC_2X, 2571e403d005SPeter De Schrijver TEGRA210_CLK_HDA2HDMI, TEGRA210_CLK_DISP1, TEGRA210_CLK_DISP2 }; 2572e403d005SPeter De Schrijver static const unsigned int disp_slcg_clkids[] = { TEGRA210_CLK_LA, 2573e403d005SPeter De Schrijver TEGRA210_CLK_HOST1X}; 2574e403d005SPeter De Schrijver static const unsigned int xusba_slcg_clkids[] = { TEGRA210_CLK_XUSB_HOST, 2575e403d005SPeter De Schrijver TEGRA210_CLK_XUSB_DEV }; 2576e403d005SPeter De Schrijver static const unsigned int xusbb_slcg_clkids[] = { TEGRA210_CLK_XUSB_HOST, 2577e403d005SPeter De Schrijver TEGRA210_CLK_XUSB_SS }; 2578e403d005SPeter De Schrijver static const unsigned int xusbc_slcg_clkids[] = { TEGRA210_CLK_XUSB_DEV, 2579e403d005SPeter De Schrijver TEGRA210_CLK_XUSB_SS }; 2580e403d005SPeter De Schrijver static const unsigned int venc_slcg_clkids[] = { TEGRA210_CLK_HOST1X, 2581e403d005SPeter De Schrijver TEGRA210_CLK_PLL_D }; 2582e403d005SPeter De Schrijver static const unsigned int ape_slcg_clkids[] = { TEGRA210_CLK_ACLK, 2583e403d005SPeter De Schrijver TEGRA210_CLK_I2S0, TEGRA210_CLK_I2S1, TEGRA210_CLK_I2S2, 2584e403d005SPeter De Schrijver TEGRA210_CLK_I2S3, TEGRA210_CLK_I2S4, TEGRA210_CLK_SPDIF_OUT, 2585e403d005SPeter De Schrijver TEGRA210_CLK_D_AUDIO }; 2586e403d005SPeter De Schrijver static const unsigned int vic_slcg_clkids[] = { TEGRA210_CLK_HOST1X }; 2587e403d005SPeter De Schrijver 2588e403d005SPeter De Schrijver static struct tegra210_domain_mbist_war tegra210_pg_mbist_war[] = { 2589e403d005SPeter De Schrijver [TEGRA_POWERGATE_VENC] = { 2590e403d005SPeter De Schrijver .handle_lvl2_ovr = tegra210_venc_mbist_war, 2591e403d005SPeter De Schrijver .num_clks = ARRAY_SIZE(venc_slcg_clkids), 2592e403d005SPeter De Schrijver .clk_init_data = venc_slcg_clkids, 2593e403d005SPeter De Schrijver }, 2594e403d005SPeter De Schrijver [TEGRA_POWERGATE_SATA] = { 2595e403d005SPeter De Schrijver .handle_lvl2_ovr = tegra210_generic_mbist_war, 2596e403d005SPeter De Schrijver .lvl2_offset = LVL2_CLK_GATE_OVRC, 2597e403d005SPeter De Schrijver .lvl2_mask = BIT(0) | BIT(17) | BIT(19), 2598e403d005SPeter De Schrijver }, 2599e403d005SPeter De Schrijver [TEGRA_POWERGATE_MPE] = { 2600e403d005SPeter De Schrijver .handle_lvl2_ovr = tegra210_generic_mbist_war, 2601e403d005SPeter De Schrijver .lvl2_offset = LVL2_CLK_GATE_OVRE, 2602a4dbbceeSJoseph Lo .lvl2_mask = BIT(29), 2603e403d005SPeter De Schrijver }, 2604e403d005SPeter De Schrijver [TEGRA_POWERGATE_SOR] = { 2605e403d005SPeter De Schrijver .handle_lvl2_ovr = tegra210_generic_mbist_war, 2606e403d005SPeter De Schrijver .num_clks = ARRAY_SIZE(sor_slcg_clkids), 2607e403d005SPeter De Schrijver .clk_init_data = sor_slcg_clkids, 2608e403d005SPeter De Schrijver .lvl2_offset = LVL2_CLK_GATE_OVRA, 2609e403d005SPeter De Schrijver .lvl2_mask = BIT(1) | BIT(2), 2610e403d005SPeter De Schrijver }, 2611e403d005SPeter De Schrijver [TEGRA_POWERGATE_DIS] = { 2612e403d005SPeter De Schrijver .handle_lvl2_ovr = tegra210_disp_mbist_war, 2613e403d005SPeter De Schrijver .num_clks = ARRAY_SIZE(disp_slcg_clkids), 2614e403d005SPeter De Schrijver .clk_init_data = disp_slcg_clkids, 2615e403d005SPeter De Schrijver }, 2616e403d005SPeter De Schrijver [TEGRA_POWERGATE_DISB] = { 2617e403d005SPeter De Schrijver .num_clks = ARRAY_SIZE(disp_slcg_clkids), 2618e403d005SPeter De Schrijver .clk_init_data = disp_slcg_clkids, 2619e403d005SPeter De Schrijver .handle_lvl2_ovr = tegra210_generic_mbist_war, 2620e403d005SPeter De Schrijver .lvl2_offset = LVL2_CLK_GATE_OVRA, 2621e403d005SPeter De Schrijver .lvl2_mask = BIT(2), 2622e403d005SPeter De Schrijver }, 2623e403d005SPeter De Schrijver [TEGRA_POWERGATE_XUSBA] = { 2624e403d005SPeter De Schrijver .num_clks = ARRAY_SIZE(xusba_slcg_clkids), 2625e403d005SPeter De Schrijver .clk_init_data = xusba_slcg_clkids, 2626e403d005SPeter De Schrijver .handle_lvl2_ovr = tegra210_generic_mbist_war, 2627e403d005SPeter De Schrijver .lvl2_offset = LVL2_CLK_GATE_OVRC, 2628e403d005SPeter De Schrijver .lvl2_mask = BIT(30) | BIT(31), 2629e403d005SPeter De Schrijver }, 2630e403d005SPeter De Schrijver [TEGRA_POWERGATE_XUSBB] = { 2631e403d005SPeter De Schrijver .num_clks = ARRAY_SIZE(xusbb_slcg_clkids), 2632e403d005SPeter De Schrijver .clk_init_data = xusbb_slcg_clkids, 2633e403d005SPeter De Schrijver .handle_lvl2_ovr = tegra210_generic_mbist_war, 2634e403d005SPeter De Schrijver .lvl2_offset = LVL2_CLK_GATE_OVRC, 2635e403d005SPeter De Schrijver .lvl2_mask = BIT(30) | BIT(31), 2636e403d005SPeter De Schrijver }, 2637e403d005SPeter De Schrijver [TEGRA_POWERGATE_XUSBC] = { 2638e403d005SPeter De Schrijver .num_clks = ARRAY_SIZE(xusbc_slcg_clkids), 2639e403d005SPeter De Schrijver .clk_init_data = xusbc_slcg_clkids, 2640e403d005SPeter De Schrijver .handle_lvl2_ovr = tegra210_generic_mbist_war, 2641e403d005SPeter De Schrijver .lvl2_offset = LVL2_CLK_GATE_OVRC, 2642e403d005SPeter De Schrijver .lvl2_mask = BIT(30) | BIT(31), 2643e403d005SPeter De Schrijver }, 2644e403d005SPeter De Schrijver [TEGRA_POWERGATE_VIC] = { 2645e403d005SPeter De Schrijver .num_clks = ARRAY_SIZE(vic_slcg_clkids), 2646e403d005SPeter De Schrijver .clk_init_data = vic_slcg_clkids, 2647e403d005SPeter De Schrijver .handle_lvl2_ovr = tegra210_vic_mbist_war, 2648e403d005SPeter De Schrijver }, 2649e403d005SPeter De Schrijver [TEGRA_POWERGATE_NVDEC] = { 2650e403d005SPeter De Schrijver .num_clks = ARRAY_SIZE(nvdec_slcg_clkids), 2651e403d005SPeter De Schrijver .clk_init_data = nvdec_slcg_clkids, 2652e403d005SPeter De Schrijver .handle_lvl2_ovr = tegra210_generic_mbist_war, 2653a4dbbceeSJoseph Lo .lvl2_offset = LVL2_CLK_GATE_OVRE, 2654e403d005SPeter De Schrijver .lvl2_mask = BIT(9) | BIT(31), 2655e403d005SPeter De Schrijver }, 2656e403d005SPeter De Schrijver [TEGRA_POWERGATE_NVJPG] = { 2657e403d005SPeter De Schrijver .num_clks = ARRAY_SIZE(nvjpg_slcg_clkids), 2658e403d005SPeter De Schrijver .clk_init_data = nvjpg_slcg_clkids, 2659e403d005SPeter De Schrijver .handle_lvl2_ovr = tegra210_generic_mbist_war, 2660a4dbbceeSJoseph Lo .lvl2_offset = LVL2_CLK_GATE_OVRE, 2661e403d005SPeter De Schrijver .lvl2_mask = BIT(9) | BIT(31), 2662e403d005SPeter De Schrijver }, 2663e403d005SPeter De Schrijver [TEGRA_POWERGATE_AUD] = { 2664e403d005SPeter De Schrijver .num_clks = ARRAY_SIZE(ape_slcg_clkids), 2665e403d005SPeter De Schrijver .clk_init_data = ape_slcg_clkids, 2666e403d005SPeter De Schrijver .handle_lvl2_ovr = tegra210_ape_mbist_war, 2667e403d005SPeter De Schrijver }, 2668e403d005SPeter De Schrijver [TEGRA_POWERGATE_VE2] = { 2669e403d005SPeter De Schrijver .handle_lvl2_ovr = tegra210_generic_mbist_war, 2670e403d005SPeter De Schrijver .lvl2_offset = LVL2_CLK_GATE_OVRD, 2671e403d005SPeter De Schrijver .lvl2_mask = BIT(22), 2672e403d005SPeter De Schrijver }, 2673e403d005SPeter De Schrijver }; 2674e403d005SPeter De Schrijver 2675e403d005SPeter De Schrijver int tegra210_clk_handle_mbist_war(unsigned int id) 2676e403d005SPeter De Schrijver { 2677e403d005SPeter De Schrijver int err; 2678e403d005SPeter De Schrijver struct tegra210_domain_mbist_war *mbist_war; 2679e403d005SPeter De Schrijver 2680e403d005SPeter De Schrijver if (id >= ARRAY_SIZE(tegra210_pg_mbist_war)) { 2681e403d005SPeter De Schrijver WARN(1, "unknown domain id in MBIST WAR handler\n"); 2682e403d005SPeter De Schrijver return -EINVAL; 2683e403d005SPeter De Schrijver } 2684e403d005SPeter De Schrijver 2685e403d005SPeter De Schrijver mbist_war = &tegra210_pg_mbist_war[id]; 2686e403d005SPeter De Schrijver if (!mbist_war->handle_lvl2_ovr) 2687e403d005SPeter De Schrijver return 0; 2688e403d005SPeter De Schrijver 2689e403d005SPeter De Schrijver if (mbist_war->num_clks && !mbist_war->clks) 2690e403d005SPeter De Schrijver return -ENODEV; 2691e403d005SPeter De Schrijver 2692e403d005SPeter De Schrijver err = clk_bulk_prepare_enable(mbist_war->num_clks, mbist_war->clks); 2693e403d005SPeter De Schrijver if (err < 0) 2694e403d005SPeter De Schrijver return err; 2695e403d005SPeter De Schrijver 2696e403d005SPeter De Schrijver mutex_lock(&lvl2_ovr_lock); 2697e403d005SPeter De Schrijver 2698e403d005SPeter De Schrijver mbist_war->handle_lvl2_ovr(mbist_war); 2699e403d005SPeter De Schrijver 2700e403d005SPeter De Schrijver mutex_unlock(&lvl2_ovr_lock); 2701e403d005SPeter De Schrijver 2702e403d005SPeter De Schrijver clk_bulk_disable_unprepare(mbist_war->num_clks, mbist_war->clks); 2703e403d005SPeter De Schrijver 2704e403d005SPeter De Schrijver return 0; 2705e403d005SPeter De Schrijver } 2706e403d005SPeter De Schrijver 27073843832fSPeter De Schrijver void tegra210_put_utmipll_in_iddq(void) 27083843832fSPeter De Schrijver { 27093843832fSPeter De Schrijver u32 reg; 27103843832fSPeter De Schrijver 27113843832fSPeter De Schrijver reg = readl_relaxed(clk_base + UTMIPLL_HW_PWRDN_CFG0); 27123843832fSPeter De Schrijver 27133843832fSPeter De Schrijver if (reg & UTMIPLL_HW_PWRDN_CFG0_UTMIPLL_LOCK) { 27143843832fSPeter De Schrijver pr_err("trying to assert IDDQ while UTMIPLL is locked\n"); 27153843832fSPeter De Schrijver return; 27163843832fSPeter De Schrijver } 27173843832fSPeter De Schrijver 27183843832fSPeter De Schrijver reg |= UTMIPLL_HW_PWRDN_CFG0_IDDQ_OVERRIDE; 27193843832fSPeter De Schrijver writel_relaxed(reg, clk_base + UTMIPLL_HW_PWRDN_CFG0); 27203843832fSPeter De Schrijver } 27213843832fSPeter De Schrijver EXPORT_SYMBOL_GPL(tegra210_put_utmipll_in_iddq); 27223843832fSPeter De Schrijver 27233843832fSPeter De Schrijver void tegra210_put_utmipll_out_iddq(void) 27243843832fSPeter De Schrijver { 27253843832fSPeter De Schrijver u32 reg; 27263843832fSPeter De Schrijver 27273843832fSPeter De Schrijver reg = readl_relaxed(clk_base + UTMIPLL_HW_PWRDN_CFG0); 27283843832fSPeter De Schrijver reg &= ~UTMIPLL_HW_PWRDN_CFG0_IDDQ_OVERRIDE; 27293843832fSPeter De Schrijver writel_relaxed(reg, clk_base + UTMIPLL_HW_PWRDN_CFG0); 27303843832fSPeter De Schrijver } 27313843832fSPeter De Schrijver EXPORT_SYMBOL_GPL(tegra210_put_utmipll_out_iddq); 27323843832fSPeter De Schrijver 2733e745f992SPeter De Schrijver static void tegra210_utmi_param_configure(void) 2734e745f992SPeter De Schrijver { 2735e745f992SPeter De Schrijver u32 reg; 2736e745f992SPeter De Schrijver int i; 2737e745f992SPeter De Schrijver 2738e745f992SPeter De Schrijver for (i = 0; i < ARRAY_SIZE(utmi_parameters); i++) { 2739e745f992SPeter De Schrijver if (osc_freq == utmi_parameters[i].osc_frequency) 2740e745f992SPeter De Schrijver break; 2741e745f992SPeter De Schrijver } 2742e745f992SPeter De Schrijver 2743e745f992SPeter De Schrijver if (i >= ARRAY_SIZE(utmi_parameters)) { 2744e745f992SPeter De Schrijver pr_err("%s: Unexpected oscillator freq %lu\n", __func__, 2745e745f992SPeter De Schrijver osc_freq); 2746e745f992SPeter De Schrijver return; 2747e745f992SPeter De Schrijver } 2748e745f992SPeter De Schrijver 2749e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + UTMIPLL_HW_PWRDN_CFG0); 2750e745f992SPeter De Schrijver reg &= ~UTMIPLL_HW_PWRDN_CFG0_IDDQ_OVERRIDE; 2751e745f992SPeter De Schrijver writel_relaxed(reg, clk_base + UTMIPLL_HW_PWRDN_CFG0); 2752e745f992SPeter De Schrijver 2753e745f992SPeter De Schrijver udelay(10); 2754e745f992SPeter De Schrijver 2755e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + UTMIP_PLL_CFG2); 2756e745f992SPeter De Schrijver 2757e745f992SPeter De Schrijver /* Program UTMIP PLL stable and active counts */ 2758e745f992SPeter De Schrijver /* [FIXME] arclk_rst.h says WRONG! This should be 1ms -> 0x50 Check! */ 2759e745f992SPeter De Schrijver reg &= ~UTMIP_PLL_CFG2_STABLE_COUNT(~0); 2760e745f992SPeter De Schrijver reg |= UTMIP_PLL_CFG2_STABLE_COUNT(utmi_parameters[i].stable_count); 2761e745f992SPeter De Schrijver 2762e745f992SPeter De Schrijver reg &= ~UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(~0); 2763e745f992SPeter De Schrijver reg |= 2764e745f992SPeter De Schrijver UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(utmi_parameters[i].active_delay_count); 2765e745f992SPeter De Schrijver writel_relaxed(reg, clk_base + UTMIP_PLL_CFG2); 2766e745f992SPeter De Schrijver 2767e745f992SPeter De Schrijver /* Program UTMIP PLL delay and oscillator frequency counts */ 2768e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + UTMIP_PLL_CFG1); 2769e745f992SPeter De Schrijver 277071422dbbSAlex Frid reg &= ~UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(~0); 2771e745f992SPeter De Schrijver reg |= 2772e745f992SPeter De Schrijver UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(utmi_parameters[i].enable_delay_count); 2773e745f992SPeter De Schrijver 2774e745f992SPeter De Schrijver reg &= ~UTMIP_PLL_CFG1_XTAL_FREQ_COUNT(~0); 2775e745f992SPeter De Schrijver reg |= 2776e745f992SPeter De Schrijver UTMIP_PLL_CFG1_XTAL_FREQ_COUNT(utmi_parameters[i].xtal_freq_count); 2777e745f992SPeter De Schrijver 2778e745f992SPeter De Schrijver reg |= UTMIP_PLL_CFG1_FORCE_PLLU_POWERDOWN; 2779e745f992SPeter De Schrijver writel_relaxed(reg, clk_base + UTMIP_PLL_CFG1); 2780e745f992SPeter De Schrijver 2781e745f992SPeter De Schrijver /* Remove power downs from UTMIP PLL control bits */ 2782e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + UTMIP_PLL_CFG1); 2783e745f992SPeter De Schrijver reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERDOWN; 2784e745f992SPeter De Schrijver reg |= UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERUP; 2785e745f992SPeter De Schrijver writel_relaxed(reg, clk_base + UTMIP_PLL_CFG1); 278671422dbbSAlex Frid 278771422dbbSAlex Frid udelay(20); 2788e745f992SPeter De Schrijver 2789e745f992SPeter De Schrijver /* Enable samplers for SNPS, XUSB_HOST, XUSB_DEV */ 2790e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + UTMIP_PLL_CFG2); 2791e745f992SPeter De Schrijver reg |= UTMIP_PLL_CFG2_FORCE_PD_SAMP_A_POWERUP; 2792e745f992SPeter De Schrijver reg |= UTMIP_PLL_CFG2_FORCE_PD_SAMP_B_POWERUP; 2793e745f992SPeter De Schrijver reg |= UTMIP_PLL_CFG2_FORCE_PD_SAMP_D_POWERUP; 2794e745f992SPeter De Schrijver reg &= ~UTMIP_PLL_CFG2_FORCE_PD_SAMP_A_POWERDOWN; 2795e745f992SPeter De Schrijver reg &= ~UTMIP_PLL_CFG2_FORCE_PD_SAMP_B_POWERDOWN; 2796e745f992SPeter De Schrijver reg &= ~UTMIP_PLL_CFG2_FORCE_PD_SAMP_D_POWERDOWN; 2797e745f992SPeter De Schrijver writel_relaxed(reg, clk_base + UTMIP_PLL_CFG2); 2798e745f992SPeter De Schrijver 2799e745f992SPeter De Schrijver /* Setup HW control of UTMIPLL */ 2800e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + UTMIP_PLL_CFG1); 2801e745f992SPeter De Schrijver reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERDOWN; 2802e745f992SPeter De Schrijver reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERUP; 2803e745f992SPeter De Schrijver writel_relaxed(reg, clk_base + UTMIP_PLL_CFG1); 2804e745f992SPeter De Schrijver 2805e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + UTMIPLL_HW_PWRDN_CFG0); 2806e745f992SPeter De Schrijver reg |= UTMIPLL_HW_PWRDN_CFG0_USE_LOCKDET; 2807e745f992SPeter De Schrijver reg &= ~UTMIPLL_HW_PWRDN_CFG0_CLK_ENABLE_SWCTL; 2808e745f992SPeter De Schrijver writel_relaxed(reg, clk_base + UTMIPLL_HW_PWRDN_CFG0); 2809e745f992SPeter De Schrijver 2810e745f992SPeter De Schrijver udelay(1); 2811e745f992SPeter De Schrijver 2812e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + XUSB_PLL_CFG0); 2813e745f992SPeter De Schrijver reg &= ~XUSB_PLL_CFG0_UTMIPLL_LOCK_DLY; 2814e745f992SPeter De Schrijver writel_relaxed(reg, clk_base + XUSB_PLL_CFG0); 2815e745f992SPeter De Schrijver 2816e745f992SPeter De Schrijver udelay(1); 2817e745f992SPeter De Schrijver 2818e745f992SPeter De Schrijver /* Enable HW control UTMIPLL */ 2819e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + UTMIPLL_HW_PWRDN_CFG0); 2820e745f992SPeter De Schrijver reg |= UTMIPLL_HW_PWRDN_CFG0_SEQ_ENABLE; 2821e745f992SPeter De Schrijver writel_relaxed(reg, clk_base + UTMIPLL_HW_PWRDN_CFG0); 2822e745f992SPeter De Schrijver } 2823e745f992SPeter De Schrijver 2824e745f992SPeter De Schrijver static int tegra210_enable_pllu(void) 2825e745f992SPeter De Schrijver { 2826e745f992SPeter De Schrijver struct tegra_clk_pll_freq_table *fentry; 2827e745f992SPeter De Schrijver struct tegra_clk_pll pllu; 2828e745f992SPeter De Schrijver u32 reg; 2829e745f992SPeter De Schrijver 2830e745f992SPeter De Schrijver for (fentry = pll_u_freq_table; fentry->input_rate; fentry++) { 2831e745f992SPeter De Schrijver if (fentry->input_rate == pll_ref_freq) 2832e745f992SPeter De Schrijver break; 2833e745f992SPeter De Schrijver } 2834e745f992SPeter De Schrijver 2835e745f992SPeter De Schrijver if (!fentry->input_rate) { 2836e745f992SPeter De Schrijver pr_err("Unknown PLL_U reference frequency %lu\n", pll_ref_freq); 2837e745f992SPeter De Schrijver return -EINVAL; 2838e745f992SPeter De Schrijver } 2839e745f992SPeter De Schrijver 2840e745f992SPeter De Schrijver /* clear IDDQ bit */ 2841e745f992SPeter De Schrijver pllu.params = &pll_u_vco_params; 2842e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + pllu.params->ext_misc_reg[0]); 2843e745f992SPeter De Schrijver reg &= ~BIT(pllu.params->iddq_bit_idx); 2844e745f992SPeter De Schrijver writel_relaxed(reg, clk_base + pllu.params->ext_misc_reg[0]); 2845*f68cbb35SSowjanya Komatineni fence_udelay(5, clk_base); 2846e745f992SPeter De Schrijver 2847e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + PLLU_BASE); 2848e745f992SPeter De Schrijver reg &= ~GENMASK(20, 0); 2849e745f992SPeter De Schrijver reg |= fentry->m; 2850e745f992SPeter De Schrijver reg |= fentry->n << 8; 2851e745f992SPeter De Schrijver reg |= fentry->p << 16; 2852e745f992SPeter De Schrijver writel(reg, clk_base + PLLU_BASE); 2853*f68cbb35SSowjanya Komatineni fence_udelay(1, clk_base); 2854e745f992SPeter De Schrijver reg |= PLL_ENABLE; 2855e745f992SPeter De Schrijver writel(reg, clk_base + PLLU_BASE); 2856e745f992SPeter De Schrijver 285722ef01a2SNicolin Chen readl_relaxed_poll_timeout_atomic(clk_base + PLLU_BASE, reg, 2858e745f992SPeter De Schrijver reg & PLL_BASE_LOCK, 2, 1000); 2859e745f992SPeter De Schrijver if (!(reg & PLL_BASE_LOCK)) { 2860e745f992SPeter De Schrijver pr_err("Timed out waiting for PLL_U to lock\n"); 2861e745f992SPeter De Schrijver return -ETIMEDOUT; 2862e745f992SPeter De Schrijver } 2863e745f992SPeter De Schrijver 2864e745f992SPeter De Schrijver return 0; 2865e745f992SPeter De Schrijver } 2866e745f992SPeter De Schrijver 2867e745f992SPeter De Schrijver static int tegra210_init_pllu(void) 2868e745f992SPeter De Schrijver { 2869e745f992SPeter De Schrijver u32 reg; 2870e745f992SPeter De Schrijver int err; 2871e745f992SPeter De Schrijver 2872e745f992SPeter De Schrijver tegra210_pllu_set_defaults(&pll_u_vco_params); 2873e745f992SPeter De Schrijver /* skip initialization when pllu is in hw controlled mode */ 2874e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + PLLU_BASE); 2875e745f992SPeter De Schrijver if (reg & PLLU_BASE_OVERRIDE) { 2876e745f992SPeter De Schrijver if (!(reg & PLL_ENABLE)) { 2877e745f992SPeter De Schrijver err = tegra210_enable_pllu(); 2878e745f992SPeter De Schrijver if (err < 0) { 2879e745f992SPeter De Schrijver WARN_ON(1); 2880e745f992SPeter De Schrijver return err; 2881e745f992SPeter De Schrijver } 2882e745f992SPeter De Schrijver } 2883e745f992SPeter De Schrijver /* enable hw controlled mode */ 2884e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + PLLU_BASE); 2885e745f992SPeter De Schrijver reg &= ~PLLU_BASE_OVERRIDE; 2886e745f992SPeter De Schrijver writel(reg, clk_base + PLLU_BASE); 2887e745f992SPeter De Schrijver 2888e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + PLLU_HW_PWRDN_CFG0); 2889e745f992SPeter De Schrijver reg |= PLLU_HW_PWRDN_CFG0_IDDQ_PD_INCLUDE | 2890e745f992SPeter De Schrijver PLLU_HW_PWRDN_CFG0_USE_SWITCH_DETECT | 2891e745f992SPeter De Schrijver PLLU_HW_PWRDN_CFG0_USE_LOCKDET; 2892e745f992SPeter De Schrijver reg &= ~(PLLU_HW_PWRDN_CFG0_CLK_ENABLE_SWCTL | 2893e745f992SPeter De Schrijver PLLU_HW_PWRDN_CFG0_CLK_SWITCH_SWCTL); 2894e745f992SPeter De Schrijver writel_relaxed(reg, clk_base + PLLU_HW_PWRDN_CFG0); 2895e745f992SPeter De Schrijver 2896e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + XUSB_PLL_CFG0); 2897e745f992SPeter De Schrijver reg &= ~XUSB_PLL_CFG0_PLLU_LOCK_DLY_MASK; 2898e745f992SPeter De Schrijver writel_relaxed(reg, clk_base + XUSB_PLL_CFG0); 2899*f68cbb35SSowjanya Komatineni fence_udelay(1, clk_base); 2900e745f992SPeter De Schrijver 2901e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + PLLU_HW_PWRDN_CFG0); 2902e745f992SPeter De Schrijver reg |= PLLU_HW_PWRDN_CFG0_SEQ_ENABLE; 2903e745f992SPeter De Schrijver writel_relaxed(reg, clk_base + PLLU_HW_PWRDN_CFG0); 2904*f68cbb35SSowjanya Komatineni fence_udelay(1, clk_base); 2905e745f992SPeter De Schrijver 2906e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + PLLU_BASE); 2907e745f992SPeter De Schrijver reg &= ~PLLU_BASE_CLKENABLE_USB; 2908e745f992SPeter De Schrijver writel_relaxed(reg, clk_base + PLLU_BASE); 2909e745f992SPeter De Schrijver } 2910e745f992SPeter De Schrijver 2911e745f992SPeter De Schrijver /* enable UTMIPLL hw control if not yet done by the bootloader */ 2912e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + UTMIPLL_HW_PWRDN_CFG0); 2913e745f992SPeter De Schrijver if (!(reg & UTMIPLL_HW_PWRDN_CFG0_SEQ_ENABLE)) 2914e745f992SPeter De Schrijver tegra210_utmi_param_configure(); 2915e745f992SPeter De Schrijver 2916e745f992SPeter De Schrijver return 0; 2917e745f992SPeter De Schrijver } 2918e745f992SPeter De Schrijver 2919bc2e4d29SThierry Reding /* 292005308d7eSThierry Reding * The SOR hardware blocks are driven by two clocks: a module clock that is 292105308d7eSThierry Reding * used to access registers and a pixel clock that is sourced from the same 292205308d7eSThierry Reding * pixel clock that also drives the head attached to the SOR. The module 292305308d7eSThierry Reding * clock is typically called sorX (with X being the SOR instance) and the 292405308d7eSThierry Reding * pixel clock is called sorX_out. The source for the SOR pixel clock is 292505308d7eSThierry Reding * referred to as the "parent" clock. 292605308d7eSThierry Reding * 292705308d7eSThierry Reding * On Tegra186 and newer, clocks are provided by the BPMP. Unfortunately the 292805308d7eSThierry Reding * BPMP implementation for the SOR clocks doesn't exactly match the above in 292905308d7eSThierry Reding * some aspects. For example, the SOR module is really clocked by the pad or 293005308d7eSThierry Reding * sor_safe clocks, but BPMP models the sorX clock as being sourced by the 293105308d7eSThierry Reding * pixel clocks. Conversely the sorX_out clock is sourced by the sor_safe or 293205308d7eSThierry Reding * pad clocks on BPMP. 293305308d7eSThierry Reding * 293405308d7eSThierry Reding * In order to allow the display driver to deal with all SoC generations in 293505308d7eSThierry Reding * a unified way, implement the BPMP semantics in this driver. 2936bc2e4d29SThierry Reding */ 293705308d7eSThierry Reding 293805308d7eSThierry Reding static const char * const sor0_parents[] = { 293905308d7eSThierry Reding "pll_d_out0", 294005308d7eSThierry Reding }; 294105308d7eSThierry Reding 294205308d7eSThierry Reding static const char * const sor0_out_parents[] = { 294305308d7eSThierry Reding "sor_safe", "sor0_pad_clkout", 2944bc2e4d29SThierry Reding }; 2945bc2e4d29SThierry Reding 2946bc2e4d29SThierry Reding static const char * const sor1_parents[] = { 2947bc2e4d29SThierry Reding "pll_p", "pll_d_out0", "pll_d2_out0", "clk_m", 2948bc2e4d29SThierry Reding }; 2949bc2e4d29SThierry Reding 2950bc2e4d29SThierry Reding static u32 sor1_parents_idx[] = { 0, 2, 5, 6 }; 2951bc2e4d29SThierry Reding 295205308d7eSThierry Reding static const char * const sor1_out_parents[] = { 295305308d7eSThierry Reding /* 295405308d7eSThierry Reding * Bit 0 of the mux selects sor1_pad_clkout, irrespective of bit 1, so 295505308d7eSThierry Reding * the sor1_pad_clkout parent appears twice in the list below. This is 295605308d7eSThierry Reding * merely to support clk_get_parent() if firmware happened to set 295705308d7eSThierry Reding * these bits to 0b11. While not an invalid setting, code should 295805308d7eSThierry Reding * always set the bits to 0b01 to select sor1_pad_clkout. 295905308d7eSThierry Reding */ 296005308d7eSThierry Reding "sor_safe", "sor1_pad_clkout", "sor1_out", "sor1_pad_clkout", 296105308d7eSThierry Reding }; 296205308d7eSThierry Reding 2963bc2e4d29SThierry Reding static struct tegra_periph_init_data tegra210_periph[] = { 296405308d7eSThierry Reding /* 296505308d7eSThierry Reding * On Tegra210, the sor0 clock doesn't have a mux it bitfield 31:29, 296605308d7eSThierry Reding * but it is hardwired to the pll_d_out0 clock. 296705308d7eSThierry Reding */ 296805308d7eSThierry Reding TEGRA_INIT_DATA_TABLE("sor0", NULL, NULL, sor0_parents, 296905308d7eSThierry Reding CLK_SOURCE_SOR0, 29, 0x0, 0, 0, 0, 0, 297005308d7eSThierry Reding 0, 182, 0, tegra_clk_sor0, NULL, 0, 297105308d7eSThierry Reding &sor0_lock), 297205308d7eSThierry Reding TEGRA_INIT_DATA_TABLE("sor0_out", NULL, NULL, sor0_out_parents, 297305308d7eSThierry Reding CLK_SOURCE_SOR0, 14, 0x1, 0, 0, 0, 0, 297405308d7eSThierry Reding 0, 0, TEGRA_PERIPH_NO_GATE, tegra_clk_sor0_out, 297505308d7eSThierry Reding NULL, 0, &sor0_lock), 2976bc2e4d29SThierry Reding TEGRA_INIT_DATA_TABLE("sor1", NULL, NULL, sor1_parents, 2977bc2e4d29SThierry Reding CLK_SOURCE_SOR1, 29, 0x7, 0, 0, 8, 1, 297805308d7eSThierry Reding TEGRA_DIVIDER_ROUND_UP, 183, 0, 297905308d7eSThierry Reding tegra_clk_sor1, sor1_parents_idx, 0, 298005308d7eSThierry Reding &sor1_lock), 298105308d7eSThierry Reding TEGRA_INIT_DATA_TABLE("sor1_out", NULL, NULL, sor1_out_parents, 298205308d7eSThierry Reding CLK_SOURCE_SOR1, 14, 0x3, 0, 0, 0, 0, 298305308d7eSThierry Reding 0, 0, TEGRA_PERIPH_NO_GATE, 298405308d7eSThierry Reding tegra_clk_sor1_out, NULL, 0, &sor1_lock), 2985bc2e4d29SThierry Reding }; 2986bc2e4d29SThierry Reding 298789e423c3SPeter De Schrijver static const char * const la_parents[] = { 298889e423c3SPeter De Schrijver "pll_p", "pll_c2", "pll_c", "pll_c3", "pll_re_out1", "pll_a1", "clk_m", "pll_c4_out0" 298989e423c3SPeter De Schrijver }; 299089e423c3SPeter De Schrijver 299189e423c3SPeter De Schrijver static struct tegra_clk_periph tegra210_la = 299289e423c3SPeter De Schrijver TEGRA_CLK_PERIPH(29, 7, 9, 0, 8, 1, TEGRA_DIVIDER_ROUND_UP, 76, 0, NULL, 0); 299389e423c3SPeter De Schrijver 29946b301a05SRhyland Klein static __init void tegra210_periph_clk_init(void __iomem *clk_base, 29956b301a05SRhyland Klein void __iomem *pmc_base) 29966b301a05SRhyland Klein { 29976b301a05SRhyland Klein struct clk *clk; 2998bc2e4d29SThierry Reding unsigned int i; 29996b301a05SRhyland Klein 30006b301a05SRhyland Klein /* xusb_ss_div2 */ 30016b301a05SRhyland Klein clk = clk_register_fixed_factor(NULL, "xusb_ss_div2", "xusb_ss_src", 0, 30026b301a05SRhyland Klein 1, 2); 30036b301a05SRhyland Klein clks[TEGRA210_CLK_XUSB_SS_DIV2] = clk; 30046b301a05SRhyland Klein 300574d3ba0bSThierry Reding clk = tegra_clk_register_periph_fixed("sor_safe", "pll_p", 0, clk_base, 300674d3ba0bSThierry Reding 1, 17, 222); 300774d3ba0bSThierry Reding clks[TEGRA210_CLK_SOR_SAFE] = clk; 300874d3ba0bSThierry Reding 30092e34c2acSThierry Reding clk = tegra_clk_register_periph_fixed("dpaux", "sor_safe", 0, clk_base, 3010eede7113SThierry Reding 1, 17, 181); 3011eede7113SThierry Reding clks[TEGRA210_CLK_DPAUX] = clk; 3012eede7113SThierry Reding 30132e34c2acSThierry Reding clk = tegra_clk_register_periph_fixed("dpaux1", "sor_safe", 0, clk_base, 3014eede7113SThierry Reding 1, 17, 207); 3015eede7113SThierry Reding clks[TEGRA210_CLK_DPAUX1] = clk; 3016eede7113SThierry Reding 30176b301a05SRhyland Klein /* pll_d_dsi_out */ 30186b301a05SRhyland Klein clk = clk_register_gate(NULL, "pll_d_dsi_out", "pll_d_out0", 0, 30196b301a05SRhyland Klein clk_base + PLLD_MISC0, 21, 0, &pll_d_lock); 30206b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_D_DSI_OUT] = clk; 30216b301a05SRhyland Klein 30226b301a05SRhyland Klein /* dsia */ 30236b301a05SRhyland Klein clk = tegra_clk_register_periph_gate("dsia", "pll_d_dsi_out", 0, 30246b301a05SRhyland Klein clk_base, 0, 48, 30256b301a05SRhyland Klein periph_clk_enb_refcnt); 30266b301a05SRhyland Klein clks[TEGRA210_CLK_DSIA] = clk; 30276b301a05SRhyland Klein 30286b301a05SRhyland Klein /* dsib */ 30296b301a05SRhyland Klein clk = tegra_clk_register_periph_gate("dsib", "pll_d_dsi_out", 0, 30306b301a05SRhyland Klein clk_base, 0, 82, 30316b301a05SRhyland Klein periph_clk_enb_refcnt); 30326b301a05SRhyland Klein clks[TEGRA210_CLK_DSIB] = clk; 30336b301a05SRhyland Klein 303489e423c3SPeter De Schrijver /* la */ 303589e423c3SPeter De Schrijver clk = tegra_clk_register_periph("la", la_parents, 303689e423c3SPeter De Schrijver ARRAY_SIZE(la_parents), &tegra210_la, clk_base, 303789e423c3SPeter De Schrijver CLK_SOURCE_LA, 0); 303889e423c3SPeter De Schrijver clks[TEGRA210_CLK_LA] = clk; 303989e423c3SPeter De Schrijver 30406b301a05SRhyland Klein /* emc mux */ 30416b301a05SRhyland Klein clk = clk_register_mux(NULL, "emc_mux", mux_pllmcp_clkm, 30426b301a05SRhyland Klein ARRAY_SIZE(mux_pllmcp_clkm), 0, 30436b301a05SRhyland Klein clk_base + CLK_SOURCE_EMC, 30446b301a05SRhyland Klein 29, 3, 0, &emc_lock); 30456b301a05SRhyland Klein 30466b301a05SRhyland Klein clk = tegra_clk_register_mc("mc", "emc_mux", clk_base + CLK_SOURCE_EMC, 30476b301a05SRhyland Klein &emc_lock); 30486b301a05SRhyland Klein clks[TEGRA210_CLK_MC] = clk; 30496b301a05SRhyland Klein 30506b301a05SRhyland Klein /* cml0 */ 30516b301a05SRhyland Klein clk = clk_register_gate(NULL, "cml0", "pll_e", 0, clk_base + PLLE_AUX, 30526b301a05SRhyland Klein 0, 0, &pll_e_lock); 30536b301a05SRhyland Klein clk_register_clkdev(clk, "cml0", NULL); 30546b301a05SRhyland Klein clks[TEGRA210_CLK_CML0] = clk; 30556b301a05SRhyland Klein 30566b301a05SRhyland Klein /* cml1 */ 30576b301a05SRhyland Klein clk = clk_register_gate(NULL, "cml1", "pll_e", 0, clk_base + PLLE_AUX, 30586b301a05SRhyland Klein 1, 0, &pll_e_lock); 30596b301a05SRhyland Klein clk_register_clkdev(clk, "cml1", NULL); 30606b301a05SRhyland Klein clks[TEGRA210_CLK_CML1] = clk; 30616b301a05SRhyland Klein 306224c3ebefSPeter De Schrijver clk = tegra_clk_register_super_clk("aclk", aclk_parents, 306324c3ebefSPeter De Schrijver ARRAY_SIZE(aclk_parents), 0, clk_base + 0x6e0, 306424c3ebefSPeter De Schrijver 0, NULL); 306524c3ebefSPeter De Schrijver clks[TEGRA210_CLK_ACLK] = clk; 306624c3ebefSPeter De Schrijver 3067c76a69e4SPeter De-Schrijver clk = tegra_clk_register_sdmmc_mux_div("sdmmc2", clk_base, 3068c76a69e4SPeter De-Schrijver CLK_SOURCE_SDMMC2, 9, 3069c76a69e4SPeter De-Schrijver TEGRA_DIVIDER_ROUND_UP, 0, NULL); 3070c76a69e4SPeter De-Schrijver clks[TEGRA210_CLK_SDMMC2] = clk; 3071c76a69e4SPeter De-Schrijver 3072c76a69e4SPeter De-Schrijver clk = tegra_clk_register_sdmmc_mux_div("sdmmc4", clk_base, 3073c76a69e4SPeter De-Schrijver CLK_SOURCE_SDMMC4, 15, 3074c76a69e4SPeter De-Schrijver TEGRA_DIVIDER_ROUND_UP, 0, NULL); 3075c76a69e4SPeter De-Schrijver clks[TEGRA210_CLK_SDMMC4] = clk; 3076c76a69e4SPeter De-Schrijver 3077bc2e4d29SThierry Reding for (i = 0; i < ARRAY_SIZE(tegra210_periph); i++) { 3078bc2e4d29SThierry Reding struct tegra_periph_init_data *init = &tegra210_periph[i]; 3079bc2e4d29SThierry Reding struct clk **clkp; 3080bc2e4d29SThierry Reding 3081bc2e4d29SThierry Reding clkp = tegra_lookup_dt_id(init->clk_id, tegra210_clks); 3082bc2e4d29SThierry Reding if (!clkp) { 3083bc2e4d29SThierry Reding pr_warn("clock %u not found\n", init->clk_id); 3084bc2e4d29SThierry Reding continue; 3085bc2e4d29SThierry Reding } 3086bc2e4d29SThierry Reding 3087bc2e4d29SThierry Reding clk = tegra_clk_register_periph_data(clk_base, init); 3088bc2e4d29SThierry Reding *clkp = clk; 3089bc2e4d29SThierry Reding } 3090bc2e4d29SThierry Reding 30916b301a05SRhyland Klein tegra_periph_clk_init(clk_base, pmc_base, tegra210_clks, &pll_p_params); 30926b301a05SRhyland Klein } 30936b301a05SRhyland Klein 30946b301a05SRhyland Klein static void __init tegra210_pll_init(void __iomem *clk_base, 30956b301a05SRhyland Klein void __iomem *pmc) 30966b301a05SRhyland Klein { 30976b301a05SRhyland Klein struct clk *clk; 30986b301a05SRhyland Klein 30996b301a05SRhyland Klein /* PLLC */ 3100ac99afe5SAlex Frid clk = tegra_clk_register_pllc_tegra210("pll_c", "pll_ref", clk_base, 31016b301a05SRhyland Klein pmc, 0, &pll_c_params, NULL); 31026b301a05SRhyland Klein if (!WARN_ON(IS_ERR(clk))) 31036b301a05SRhyland Klein clk_register_clkdev(clk, "pll_c", NULL); 31046b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_C] = clk; 31056b301a05SRhyland Klein 31066b301a05SRhyland Klein /* PLLC_OUT1 */ 31076b301a05SRhyland Klein clk = tegra_clk_register_divider("pll_c_out1_div", "pll_c", 31086b301a05SRhyland Klein clk_base + PLLC_OUT, 0, TEGRA_DIVIDER_ROUND_UP, 31096b301a05SRhyland Klein 8, 8, 1, NULL); 31106b301a05SRhyland Klein clk = tegra_clk_register_pll_out("pll_c_out1", "pll_c_out1_div", 31116b301a05SRhyland Klein clk_base + PLLC_OUT, 1, 0, 31126b301a05SRhyland Klein CLK_SET_RATE_PARENT, 0, NULL); 31136b301a05SRhyland Klein clk_register_clkdev(clk, "pll_c_out1", NULL); 31146b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_C_OUT1] = clk; 31156b301a05SRhyland Klein 31166b301a05SRhyland Klein /* PLLC_UD */ 31176b301a05SRhyland Klein clk = clk_register_fixed_factor(NULL, "pll_c_ud", "pll_c", 31186b301a05SRhyland Klein CLK_SET_RATE_PARENT, 1, 1); 31196b301a05SRhyland Klein clk_register_clkdev(clk, "pll_c_ud", NULL); 31206b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_C_UD] = clk; 31216b301a05SRhyland Klein 31226b301a05SRhyland Klein /* PLLC2 */ 31236b301a05SRhyland Klein clk = tegra_clk_register_pllc_tegra210("pll_c2", "pll_ref", clk_base, 31246b301a05SRhyland Klein pmc, 0, &pll_c2_params, NULL); 31256b301a05SRhyland Klein clk_register_clkdev(clk, "pll_c2", NULL); 31266b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_C2] = clk; 31276b301a05SRhyland Klein 31286b301a05SRhyland Klein /* PLLC3 */ 31296b301a05SRhyland Klein clk = tegra_clk_register_pllc_tegra210("pll_c3", "pll_ref", clk_base, 31306b301a05SRhyland Klein pmc, 0, &pll_c3_params, NULL); 31316b301a05SRhyland Klein clk_register_clkdev(clk, "pll_c3", NULL); 31326b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_C3] = clk; 31336b301a05SRhyland Klein 31346b301a05SRhyland Klein /* PLLM */ 31356b301a05SRhyland Klein clk = tegra_clk_register_pllm("pll_m", "osc", clk_base, pmc, 31366b301a05SRhyland Klein CLK_SET_RATE_GATE, &pll_m_params, NULL); 31376b301a05SRhyland Klein clk_register_clkdev(clk, "pll_m", NULL); 31386b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_M] = clk; 31396b301a05SRhyland Klein 31406b301a05SRhyland Klein /* PLLMB */ 31416b301a05SRhyland Klein clk = tegra_clk_register_pllmb("pll_mb", "osc", clk_base, pmc, 31426b301a05SRhyland Klein CLK_SET_RATE_GATE, &pll_mb_params, NULL); 31436b301a05SRhyland Klein clk_register_clkdev(clk, "pll_mb", NULL); 31446b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_MB] = clk; 31456b301a05SRhyland Klein 31466b301a05SRhyland Klein /* PLLM_UD */ 31476b301a05SRhyland Klein clk = clk_register_fixed_factor(NULL, "pll_m_ud", "pll_m", 31486b301a05SRhyland Klein CLK_SET_RATE_PARENT, 1, 1); 31496b301a05SRhyland Klein clk_register_clkdev(clk, "pll_m_ud", NULL); 31506b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_M_UD] = clk; 31516b301a05SRhyland Klein 31526b301a05SRhyland Klein /* PLLU_VCO */ 3153e745f992SPeter De Schrijver if (!tegra210_init_pllu()) { 3154e745f992SPeter De Schrijver clk = clk_register_fixed_rate(NULL, "pll_u_vco", "pll_ref", 0, 3155e745f992SPeter De Schrijver 480*1000*1000); 31566b301a05SRhyland Klein clk_register_clkdev(clk, "pll_u_vco", NULL); 31576b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_U] = clk; 3158e745f992SPeter De Schrijver } 31596b301a05SRhyland Klein 31606b301a05SRhyland Klein /* PLLU_OUT */ 31616b301a05SRhyland Klein clk = clk_register_divider_table(NULL, "pll_u_out", "pll_u_vco", 0, 31626b301a05SRhyland Klein clk_base + PLLU_BASE, 16, 4, 0, 31636b301a05SRhyland Klein pll_vco_post_div_table, NULL); 31646b301a05SRhyland Klein clk_register_clkdev(clk, "pll_u_out", NULL); 31656b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_U_OUT] = clk; 31666b301a05SRhyland Klein 31676b301a05SRhyland Klein /* PLLU_OUT1 */ 31686b301a05SRhyland Klein clk = tegra_clk_register_divider("pll_u_out1_div", "pll_u_out", 31696b301a05SRhyland Klein clk_base + PLLU_OUTA, 0, 31706b301a05SRhyland Klein TEGRA_DIVIDER_ROUND_UP, 31716b301a05SRhyland Klein 8, 8, 1, &pll_u_lock); 31726b301a05SRhyland Klein clk = tegra_clk_register_pll_out("pll_u_out1", "pll_u_out1_div", 31736b301a05SRhyland Klein clk_base + PLLU_OUTA, 1, 0, 31746b301a05SRhyland Klein CLK_SET_RATE_PARENT, 0, &pll_u_lock); 31756b301a05SRhyland Klein clk_register_clkdev(clk, "pll_u_out1", NULL); 31766b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_U_OUT1] = clk; 31776b301a05SRhyland Klein 31786b301a05SRhyland Klein /* PLLU_OUT2 */ 31796b301a05SRhyland Klein clk = tegra_clk_register_divider("pll_u_out2_div", "pll_u_out", 31806b301a05SRhyland Klein clk_base + PLLU_OUTA, 0, 31816b301a05SRhyland Klein TEGRA_DIVIDER_ROUND_UP, 31826b301a05SRhyland Klein 24, 8, 1, &pll_u_lock); 31836b301a05SRhyland Klein clk = tegra_clk_register_pll_out("pll_u_out2", "pll_u_out2_div", 31846b301a05SRhyland Klein clk_base + PLLU_OUTA, 17, 16, 31856b301a05SRhyland Klein CLK_SET_RATE_PARENT, 0, &pll_u_lock); 31866b301a05SRhyland Klein clk_register_clkdev(clk, "pll_u_out2", NULL); 31876b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_U_OUT2] = clk; 31886b301a05SRhyland Klein 31896b301a05SRhyland Klein /* PLLU_480M */ 31906b301a05SRhyland Klein clk = clk_register_gate(NULL, "pll_u_480M", "pll_u_vco", 31916b301a05SRhyland Klein CLK_SET_RATE_PARENT, clk_base + PLLU_BASE, 31926b301a05SRhyland Klein 22, 0, &pll_u_lock); 31936b301a05SRhyland Klein clk_register_clkdev(clk, "pll_u_480M", NULL); 31946b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_U_480M] = clk; 31956b301a05SRhyland Klein 31966b301a05SRhyland Klein /* PLLU_60M */ 31976b301a05SRhyland Klein clk = clk_register_gate(NULL, "pll_u_60M", "pll_u_out2", 31986b301a05SRhyland Klein CLK_SET_RATE_PARENT, clk_base + PLLU_BASE, 31997157c69aSAlex Frid 23, 0, &pll_u_lock); 32006b301a05SRhyland Klein clk_register_clkdev(clk, "pll_u_60M", NULL); 32016b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_U_60M] = clk; 32026b301a05SRhyland Klein 32036b301a05SRhyland Klein /* PLLU_48M */ 32046b301a05SRhyland Klein clk = clk_register_gate(NULL, "pll_u_48M", "pll_u_out1", 32056b301a05SRhyland Klein CLK_SET_RATE_PARENT, clk_base + PLLU_BASE, 32067157c69aSAlex Frid 25, 0, &pll_u_lock); 32076b301a05SRhyland Klein clk_register_clkdev(clk, "pll_u_48M", NULL); 32086b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_U_48M] = clk; 32096b301a05SRhyland Klein 32106b301a05SRhyland Klein /* PLLD */ 32116b301a05SRhyland Klein clk = tegra_clk_register_pll("pll_d", "pll_ref", clk_base, pmc, 0, 32126b301a05SRhyland Klein &pll_d_params, &pll_d_lock); 32136b301a05SRhyland Klein clk_register_clkdev(clk, "pll_d", NULL); 32146b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_D] = clk; 32156b301a05SRhyland Klein 32166b301a05SRhyland Klein /* PLLD_OUT0 */ 32176b301a05SRhyland Klein clk = clk_register_fixed_factor(NULL, "pll_d_out0", "pll_d", 32186b301a05SRhyland Klein CLK_SET_RATE_PARENT, 1, 2); 32196b301a05SRhyland Klein clk_register_clkdev(clk, "pll_d_out0", NULL); 32206b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_D_OUT0] = clk; 32216b301a05SRhyland Klein 32226b301a05SRhyland Klein /* PLLRE */ 3223926655f9SRhyland Klein clk = tegra_clk_register_pllre_tegra210("pll_re_vco", "pll_ref", 3224926655f9SRhyland Klein clk_base, pmc, 0, 3225926655f9SRhyland Klein &pll_re_vco_params, 3226926655f9SRhyland Klein &pll_re_lock, pll_ref_freq); 32276b301a05SRhyland Klein clk_register_clkdev(clk, "pll_re_vco", NULL); 32286b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_RE_VCO] = clk; 32296b301a05SRhyland Klein 32306b301a05SRhyland Klein clk = clk_register_divider_table(NULL, "pll_re_out", "pll_re_vco", 0, 32316b301a05SRhyland Klein clk_base + PLLRE_BASE, 16, 5, 0, 32326b301a05SRhyland Klein pll_vco_post_div_table, &pll_re_lock); 32336b301a05SRhyland Klein clk_register_clkdev(clk, "pll_re_out", NULL); 32346b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_RE_OUT] = clk; 32356b301a05SRhyland Klein 3236926655f9SRhyland Klein clk = tegra_clk_register_divider("pll_re_out1_div", "pll_re_vco", 3237926655f9SRhyland Klein clk_base + PLLRE_OUT1, 0, 3238926655f9SRhyland Klein TEGRA_DIVIDER_ROUND_UP, 3239926655f9SRhyland Klein 8, 8, 1, NULL); 3240926655f9SRhyland Klein clk = tegra_clk_register_pll_out("pll_re_out1", "pll_re_out1_div", 3241926655f9SRhyland Klein clk_base + PLLRE_OUT1, 1, 0, 3242926655f9SRhyland Klein CLK_SET_RATE_PARENT, 0, NULL); 3243926655f9SRhyland Klein clks[TEGRA210_CLK_PLL_RE_OUT1] = clk; 3244926655f9SRhyland Klein 32456b301a05SRhyland Klein /* PLLE */ 32466b301a05SRhyland Klein clk = tegra_clk_register_plle_tegra210("pll_e", "pll_ref", 32476b301a05SRhyland Klein clk_base, 0, &pll_e_params, NULL); 32486b301a05SRhyland Klein clk_register_clkdev(clk, "pll_e", NULL); 32496b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_E] = clk; 32506b301a05SRhyland Klein 32516b301a05SRhyland Klein /* PLLC4 */ 32526b301a05SRhyland Klein clk = tegra_clk_register_pllre("pll_c4_vco", "pll_ref", clk_base, pmc, 32536b301a05SRhyland Klein 0, &pll_c4_vco_params, NULL, pll_ref_freq); 32546b301a05SRhyland Klein clk_register_clkdev(clk, "pll_c4_vco", NULL); 32556b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_C4] = clk; 32566b301a05SRhyland Klein 32576b301a05SRhyland Klein /* PLLC4_OUT0 */ 32586b301a05SRhyland Klein clk = clk_register_divider_table(NULL, "pll_c4_out0", "pll_c4_vco", 0, 32596b301a05SRhyland Klein clk_base + PLLC4_BASE, 19, 4, 0, 32606b301a05SRhyland Klein pll_vco_post_div_table, NULL); 32616b301a05SRhyland Klein clk_register_clkdev(clk, "pll_c4_out0", NULL); 32626b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_C4_OUT0] = clk; 32636b301a05SRhyland Klein 32646b301a05SRhyland Klein /* PLLC4_OUT1 */ 32656b301a05SRhyland Klein clk = clk_register_fixed_factor(NULL, "pll_c4_out1", "pll_c4_vco", 32666b301a05SRhyland Klein CLK_SET_RATE_PARENT, 1, 3); 32676b301a05SRhyland Klein clk_register_clkdev(clk, "pll_c4_out1", NULL); 32686b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_C4_OUT1] = clk; 32696b301a05SRhyland Klein 32706b301a05SRhyland Klein /* PLLC4_OUT2 */ 32716b301a05SRhyland Klein clk = clk_register_fixed_factor(NULL, "pll_c4_out2", "pll_c4_vco", 32726b301a05SRhyland Klein CLK_SET_RATE_PARENT, 1, 5); 32736b301a05SRhyland Klein clk_register_clkdev(clk, "pll_c4_out2", NULL); 32746b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_C4_OUT2] = clk; 32756b301a05SRhyland Klein 32766b301a05SRhyland Klein /* PLLC4_OUT3 */ 32776b301a05SRhyland Klein clk = tegra_clk_register_divider("pll_c4_out3_div", "pll_c4_out0", 32786b301a05SRhyland Klein clk_base + PLLC4_OUT, 0, TEGRA_DIVIDER_ROUND_UP, 32796b301a05SRhyland Klein 8, 8, 1, NULL); 32806b301a05SRhyland Klein clk = tegra_clk_register_pll_out("pll_c4_out3", "pll_c4_out3_div", 32816b301a05SRhyland Klein clk_base + PLLC4_OUT, 1, 0, 32826b301a05SRhyland Klein CLK_SET_RATE_PARENT, 0, NULL); 32836b301a05SRhyland Klein clk_register_clkdev(clk, "pll_c4_out3", NULL); 32846b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_C4_OUT3] = clk; 32856b301a05SRhyland Klein 32866b301a05SRhyland Klein /* PLLDP */ 32876b301a05SRhyland Klein clk = tegra_clk_register_pllss_tegra210("pll_dp", "pll_ref", clk_base, 32886b301a05SRhyland Klein 0, &pll_dp_params, NULL); 32896b301a05SRhyland Klein clk_register_clkdev(clk, "pll_dp", NULL); 32906b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_DP] = clk; 32916b301a05SRhyland Klein 32926b301a05SRhyland Klein /* PLLD2 */ 32936b301a05SRhyland Klein clk = tegra_clk_register_pllss_tegra210("pll_d2", "pll_ref", clk_base, 32946b301a05SRhyland Klein 0, &pll_d2_params, NULL); 32956b301a05SRhyland Klein clk_register_clkdev(clk, "pll_d2", NULL); 32966b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_D2] = clk; 32976b301a05SRhyland Klein 32986b301a05SRhyland Klein /* PLLD2_OUT0 */ 32996b301a05SRhyland Klein clk = clk_register_fixed_factor(NULL, "pll_d2_out0", "pll_d2", 33006b301a05SRhyland Klein CLK_SET_RATE_PARENT, 1, 1); 33016b301a05SRhyland Klein clk_register_clkdev(clk, "pll_d2_out0", NULL); 33026b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_D2_OUT0] = clk; 33036b301a05SRhyland Klein 33046b301a05SRhyland Klein /* PLLP_OUT2 */ 33056b301a05SRhyland Klein clk = clk_register_fixed_factor(NULL, "pll_p_out2", "pll_p", 33066b301a05SRhyland Klein CLK_SET_RATE_PARENT, 1, 2); 33076b301a05SRhyland Klein clk_register_clkdev(clk, "pll_p_out2", NULL); 33086b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_P_OUT2] = clk; 33096b301a05SRhyland Klein 33106b301a05SRhyland Klein } 33116b301a05SRhyland Klein 33126b301a05SRhyland Klein /* Tegra210 CPU clock and reset control functions */ 33136b301a05SRhyland Klein static void tegra210_wait_cpu_in_reset(u32 cpu) 33146b301a05SRhyland Klein { 33156b301a05SRhyland Klein unsigned int reg; 33166b301a05SRhyland Klein 33176b301a05SRhyland Klein do { 33186b301a05SRhyland Klein reg = readl(clk_base + CLK_RST_CONTROLLER_CPU_CMPLX_STATUS); 33196b301a05SRhyland Klein cpu_relax(); 33206b301a05SRhyland Klein } while (!(reg & (1 << cpu))); /* check CPU been reset or not */ 33216b301a05SRhyland Klein } 33226b301a05SRhyland Klein 33236b301a05SRhyland Klein static void tegra210_disable_cpu_clock(u32 cpu) 33246b301a05SRhyland Klein { 33256b301a05SRhyland Klein /* flow controller would take care in the power sequence. */ 33266b301a05SRhyland Klein } 33276b301a05SRhyland Klein 33286b301a05SRhyland Klein #ifdef CONFIG_PM_SLEEP 33296b301a05SRhyland Klein static void tegra210_cpu_clock_suspend(void) 33306b301a05SRhyland Klein { 33316b301a05SRhyland Klein /* switch coresite to clk_m, save off original source */ 33326b301a05SRhyland Klein tegra210_cpu_clk_sctx.clk_csite_src = 33336b301a05SRhyland Klein readl(clk_base + CLK_SOURCE_CSITE); 33346b301a05SRhyland Klein writel(3 << 30, clk_base + CLK_SOURCE_CSITE); 33356b301a05SRhyland Klein } 33366b301a05SRhyland Klein 33376b301a05SRhyland Klein static void tegra210_cpu_clock_resume(void) 33386b301a05SRhyland Klein { 33396b301a05SRhyland Klein writel(tegra210_cpu_clk_sctx.clk_csite_src, 33406b301a05SRhyland Klein clk_base + CLK_SOURCE_CSITE); 33416b301a05SRhyland Klein } 33426b301a05SRhyland Klein #endif 33436b301a05SRhyland Klein 33446b301a05SRhyland Klein static struct tegra_cpu_car_ops tegra210_cpu_car_ops = { 33456b301a05SRhyland Klein .wait_for_reset = tegra210_wait_cpu_in_reset, 33466b301a05SRhyland Klein .disable_clock = tegra210_disable_cpu_clock, 33476b301a05SRhyland Klein #ifdef CONFIG_PM_SLEEP 33486b301a05SRhyland Klein .suspend = tegra210_cpu_clock_suspend, 33496b301a05SRhyland Klein .resume = tegra210_cpu_clock_resume, 33506b301a05SRhyland Klein #endif 33516b301a05SRhyland Klein }; 33526b301a05SRhyland Klein 33536b301a05SRhyland Klein static const struct of_device_id pmc_match[] __initconst = { 33546b301a05SRhyland Klein { .compatible = "nvidia,tegra210-pmc" }, 33556b301a05SRhyland Klein { }, 33566b301a05SRhyland Klein }; 33576b301a05SRhyland Klein 33586b301a05SRhyland Klein static struct tegra_clk_init_table init_table[] __initdata = { 33596b301a05SRhyland Klein { TEGRA210_CLK_UARTA, TEGRA210_CLK_PLL_P, 408000000, 0 }, 33606b301a05SRhyland Klein { TEGRA210_CLK_UARTB, TEGRA210_CLK_PLL_P, 408000000, 0 }, 33616b301a05SRhyland Klein { TEGRA210_CLK_UARTC, TEGRA210_CLK_PLL_P, 408000000, 0 }, 33626b301a05SRhyland Klein { TEGRA210_CLK_UARTD, TEGRA210_CLK_PLL_P, 408000000, 0 }, 33636b301a05SRhyland Klein { TEGRA210_CLK_PLL_A, TEGRA210_CLK_CLK_MAX, 564480000, 1 }, 33646b301a05SRhyland Klein { TEGRA210_CLK_PLL_A_OUT0, TEGRA210_CLK_CLK_MAX, 11289600, 1 }, 33656b301a05SRhyland Klein { TEGRA210_CLK_EXTERN1, TEGRA210_CLK_PLL_A_OUT0, 0, 1 }, 33666b301a05SRhyland Klein { TEGRA210_CLK_CLK_OUT_1_MUX, TEGRA210_CLK_EXTERN1, 0, 1 }, 33676b301a05SRhyland Klein { TEGRA210_CLK_CLK_OUT_1, TEGRA210_CLK_CLK_MAX, 0, 1 }, 33686b301a05SRhyland Klein { TEGRA210_CLK_I2S0, TEGRA210_CLK_PLL_A_OUT0, 11289600, 0 }, 33696b301a05SRhyland Klein { TEGRA210_CLK_I2S1, TEGRA210_CLK_PLL_A_OUT0, 11289600, 0 }, 33706b301a05SRhyland Klein { TEGRA210_CLK_I2S2, TEGRA210_CLK_PLL_A_OUT0, 11289600, 0 }, 33716b301a05SRhyland Klein { TEGRA210_CLK_I2S3, TEGRA210_CLK_PLL_A_OUT0, 11289600, 0 }, 33726b301a05SRhyland Klein { TEGRA210_CLK_I2S4, TEGRA210_CLK_PLL_A_OUT0, 11289600, 0 }, 33736b301a05SRhyland Klein { TEGRA210_CLK_HOST1X, TEGRA210_CLK_PLL_P, 136000000, 1 }, 33746b301a05SRhyland Klein { TEGRA210_CLK_SCLK_MUX, TEGRA210_CLK_PLL_P, 0, 1 }, 33752dcabf05SDmitry Osipenko { TEGRA210_CLK_SCLK, TEGRA210_CLK_CLK_MAX, 102000000, 0 }, 33766b301a05SRhyland Klein { TEGRA210_CLK_DFLL_SOC, TEGRA210_CLK_PLL_P, 51000000, 1 }, 33776b301a05SRhyland Klein { TEGRA210_CLK_DFLL_REF, TEGRA210_CLK_PLL_P, 51000000, 1 }, 33786b301a05SRhyland Klein { TEGRA210_CLK_SBC4, TEGRA210_CLK_PLL_P, 12000000, 1 }, 33790d34dfbfSJC Kuo { TEGRA210_CLK_PLL_U_OUT1, TEGRA210_CLK_CLK_MAX, 48000000, 1 }, 33806b301a05SRhyland Klein { TEGRA210_CLK_XUSB_GATE, TEGRA210_CLK_CLK_MAX, 0, 1 }, 33816b301a05SRhyland Klein { TEGRA210_CLK_XUSB_SS_SRC, TEGRA210_CLK_PLL_U_480M, 120000000, 0 }, 33826b301a05SRhyland Klein { TEGRA210_CLK_XUSB_FS_SRC, TEGRA210_CLK_PLL_U_48M, 48000000, 0 }, 33836b301a05SRhyland Klein { TEGRA210_CLK_XUSB_HS_SRC, TEGRA210_CLK_XUSB_SS_SRC, 120000000, 0 }, 33846b301a05SRhyland Klein { TEGRA210_CLK_XUSB_SSP_SRC, TEGRA210_CLK_XUSB_SS_SRC, 120000000, 0 }, 33856b301a05SRhyland Klein { TEGRA210_CLK_XUSB_FALCON_SRC, TEGRA210_CLK_PLL_P_OUT_XUSB, 204000000, 0 }, 33866b301a05SRhyland Klein { TEGRA210_CLK_XUSB_HOST_SRC, TEGRA210_CLK_PLL_P_OUT_XUSB, 102000000, 0 }, 33876b301a05SRhyland Klein { TEGRA210_CLK_XUSB_DEV_SRC, TEGRA210_CLK_PLL_P_OUT_XUSB, 102000000, 0 }, 33886b301a05SRhyland Klein { TEGRA210_CLK_SATA, TEGRA210_CLK_PLL_P, 104000000, 0 }, 33896b301a05SRhyland Klein { TEGRA210_CLK_SATA_OOB, TEGRA210_CLK_PLL_P, 204000000, 0 }, 33906b301a05SRhyland Klein { TEGRA210_CLK_MSELECT, TEGRA210_CLK_CLK_MAX, 0, 1 }, 33916b301a05SRhyland Klein { TEGRA210_CLK_CSITE, TEGRA210_CLK_CLK_MAX, 0, 1 }, 3392bea1baa1SPeter De Schrijver /* TODO find a way to enable this on-demand */ 3393bea1baa1SPeter De Schrijver { TEGRA210_CLK_DBGAPB, TEGRA210_CLK_CLK_MAX, 0, 1 }, 33946b301a05SRhyland Klein { TEGRA210_CLK_TSENSOR, TEGRA210_CLK_CLK_M, 400000, 0 }, 33956b301a05SRhyland Klein { TEGRA210_CLK_I2C1, TEGRA210_CLK_PLL_P, 0, 0 }, 33966b301a05SRhyland Klein { TEGRA210_CLK_I2C2, TEGRA210_CLK_PLL_P, 0, 0 }, 33976b301a05SRhyland Klein { TEGRA210_CLK_I2C3, TEGRA210_CLK_PLL_P, 0, 0 }, 33986b301a05SRhyland Klein { TEGRA210_CLK_I2C4, TEGRA210_CLK_PLL_P, 0, 0 }, 33996b301a05SRhyland Klein { TEGRA210_CLK_I2C5, TEGRA210_CLK_PLL_P, 0, 0 }, 34006b301a05SRhyland Klein { TEGRA210_CLK_I2C6, TEGRA210_CLK_PLL_P, 0, 0 }, 34016b301a05SRhyland Klein { TEGRA210_CLK_PLL_DP, TEGRA210_CLK_CLK_MAX, 270000000, 0 }, 34026b301a05SRhyland Klein { TEGRA210_CLK_SOC_THERM, TEGRA210_CLK_PLL_P, 51000000, 0 }, 34036b301a05SRhyland Klein { TEGRA210_CLK_CCLK_G, TEGRA210_CLK_CLK_MAX, 0, 1 }, 3404e745f992SPeter De Schrijver { TEGRA210_CLK_PLL_U_OUT2, TEGRA210_CLK_CLK_MAX, 60000000, 1 }, 3405845d782dSJon Hunter { TEGRA210_CLK_SPDIF_IN_SYNC, TEGRA210_CLK_CLK_MAX, 24576000, 0 }, 3406845d782dSJon Hunter { TEGRA210_CLK_I2S0_SYNC, TEGRA210_CLK_CLK_MAX, 24576000, 0 }, 3407845d782dSJon Hunter { TEGRA210_CLK_I2S1_SYNC, TEGRA210_CLK_CLK_MAX, 24576000, 0 }, 3408845d782dSJon Hunter { TEGRA210_CLK_I2S2_SYNC, TEGRA210_CLK_CLK_MAX, 24576000, 0 }, 3409845d782dSJon Hunter { TEGRA210_CLK_I2S3_SYNC, TEGRA210_CLK_CLK_MAX, 24576000, 0 }, 3410845d782dSJon Hunter { TEGRA210_CLK_I2S4_SYNC, TEGRA210_CLK_CLK_MAX, 24576000, 0 }, 3411845d782dSJon Hunter { TEGRA210_CLK_VIMCLK_SYNC, TEGRA210_CLK_CLK_MAX, 24576000, 0 }, 34129caec662SJon Hunter { TEGRA210_CLK_HDA, TEGRA210_CLK_PLL_P, 51000000, 0 }, 34139caec662SJon Hunter { TEGRA210_CLK_HDA2CODEC_2X, TEGRA210_CLK_PLL_P, 48000000, 0 }, 34146b301a05SRhyland Klein /* This MUST be the last entry. */ 34156b301a05SRhyland Klein { TEGRA210_CLK_CLK_MAX, TEGRA210_CLK_CLK_MAX, 0, 0 }, 34166b301a05SRhyland Klein }; 34176b301a05SRhyland Klein 34186b301a05SRhyland Klein /** 34196b301a05SRhyland Klein * tegra210_clock_apply_init_table - initialize clocks on Tegra210 SoCs 34206b301a05SRhyland Klein * 34216b301a05SRhyland Klein * Program an initial clock rate and enable or disable clocks needed 34226b301a05SRhyland Klein * by the rest of the kernel, for Tegra210 SoCs. It is intended to be 34236b301a05SRhyland Klein * called by assigning a pointer to it to tegra_clk_apply_init_table - 34246b301a05SRhyland Klein * this will be called as an arch_initcall. No return value. 34256b301a05SRhyland Klein */ 34266b301a05SRhyland Klein static void __init tegra210_clock_apply_init_table(void) 34276b301a05SRhyland Klein { 34286b301a05SRhyland Klein tegra_init_from_table(init_table, clks, TEGRA210_CLK_CLK_MAX); 34296b301a05SRhyland Klein } 34306b301a05SRhyland Klein 34316b301a05SRhyland Klein /** 343268d724ceSPeter De Schrijver * tegra210_car_barrier - wait for pending writes to the CAR to complete 343368d724ceSPeter De Schrijver * 343468d724ceSPeter De Schrijver * Wait for any outstanding writes to the CAR MMIO space from this CPU 343568d724ceSPeter De Schrijver * to complete before continuing execution. No return value. 343668d724ceSPeter De Schrijver */ 343768d724ceSPeter De Schrijver static void tegra210_car_barrier(void) 343868d724ceSPeter De Schrijver { 343968d724ceSPeter De Schrijver readl_relaxed(clk_base + RST_DFLL_DVCO); 344068d724ceSPeter De Schrijver } 344168d724ceSPeter De Schrijver 344268d724ceSPeter De Schrijver /** 344368d724ceSPeter De Schrijver * tegra210_clock_assert_dfll_dvco_reset - assert the DFLL's DVCO reset 344468d724ceSPeter De Schrijver * 344568d724ceSPeter De Schrijver * Assert the reset line of the DFLL's DVCO. No return value. 344668d724ceSPeter De Schrijver */ 344768d724ceSPeter De Schrijver static void tegra210_clock_assert_dfll_dvco_reset(void) 344868d724ceSPeter De Schrijver { 344968d724ceSPeter De Schrijver u32 v; 345068d724ceSPeter De Schrijver 345168d724ceSPeter De Schrijver v = readl_relaxed(clk_base + RST_DFLL_DVCO); 345268d724ceSPeter De Schrijver v |= (1 << DVFS_DFLL_RESET_SHIFT); 345368d724ceSPeter De Schrijver writel_relaxed(v, clk_base + RST_DFLL_DVCO); 345468d724ceSPeter De Schrijver tegra210_car_barrier(); 345568d724ceSPeter De Schrijver } 345668d724ceSPeter De Schrijver 345768d724ceSPeter De Schrijver /** 345868d724ceSPeter De Schrijver * tegra210_clock_deassert_dfll_dvco_reset - deassert the DFLL's DVCO reset 345968d724ceSPeter De Schrijver * 346068d724ceSPeter De Schrijver * Deassert the reset line of the DFLL's DVCO, allowing the DVCO to 346168d724ceSPeter De Schrijver * operate. No return value. 346268d724ceSPeter De Schrijver */ 346368d724ceSPeter De Schrijver static void tegra210_clock_deassert_dfll_dvco_reset(void) 346468d724ceSPeter De Schrijver { 346568d724ceSPeter De Schrijver u32 v; 346668d724ceSPeter De Schrijver 346768d724ceSPeter De Schrijver v = readl_relaxed(clk_base + RST_DFLL_DVCO); 346868d724ceSPeter De Schrijver v &= ~(1 << DVFS_DFLL_RESET_SHIFT); 346968d724ceSPeter De Schrijver writel_relaxed(v, clk_base + RST_DFLL_DVCO); 347068d724ceSPeter De Schrijver tegra210_car_barrier(); 347168d724ceSPeter De Schrijver } 347268d724ceSPeter De Schrijver 347368d724ceSPeter De Schrijver static int tegra210_reset_assert(unsigned long id) 347468d724ceSPeter De Schrijver { 347568d724ceSPeter De Schrijver if (id == TEGRA210_RST_DFLL_DVCO) 347668d724ceSPeter De Schrijver tegra210_clock_assert_dfll_dvco_reset(); 347768d724ceSPeter De Schrijver else if (id == TEGRA210_RST_ADSP) 347868d724ceSPeter De Schrijver writel(GENMASK(26, 21) | BIT(7), 347968d724ceSPeter De Schrijver clk_base + CLK_RST_CONTROLLER_RST_DEV_Y_SET); 348068d724ceSPeter De Schrijver else 348168d724ceSPeter De Schrijver return -EINVAL; 348268d724ceSPeter De Schrijver 348368d724ceSPeter De Schrijver return 0; 348468d724ceSPeter De Schrijver } 348568d724ceSPeter De Schrijver 348668d724ceSPeter De Schrijver static int tegra210_reset_deassert(unsigned long id) 348768d724ceSPeter De Schrijver { 348868d724ceSPeter De Schrijver if (id == TEGRA210_RST_DFLL_DVCO) 348968d724ceSPeter De Schrijver tegra210_clock_deassert_dfll_dvco_reset(); 349068d724ceSPeter De Schrijver else if (id == TEGRA210_RST_ADSP) { 349168d724ceSPeter De Schrijver writel(BIT(21), clk_base + CLK_RST_CONTROLLER_RST_DEV_Y_CLR); 349268d724ceSPeter De Schrijver /* 349368d724ceSPeter De Schrijver * Considering adsp cpu clock (min: 12.5MHZ, max: 1GHz) 349468d724ceSPeter De Schrijver * a delay of 5us ensures that it's at least 349568d724ceSPeter De Schrijver * 6 * adsp_cpu_cycle_period long. 349668d724ceSPeter De Schrijver */ 349768d724ceSPeter De Schrijver udelay(5); 349868d724ceSPeter De Schrijver writel(GENMASK(26, 22) | BIT(7), 349968d724ceSPeter De Schrijver clk_base + CLK_RST_CONTROLLER_RST_DEV_Y_CLR); 350068d724ceSPeter De Schrijver } else 350168d724ceSPeter De Schrijver return -EINVAL; 350268d724ceSPeter De Schrijver 350368d724ceSPeter De Schrijver return 0; 350468d724ceSPeter De Schrijver } 350568d724ceSPeter De Schrijver 3506e403d005SPeter De Schrijver static void tegra210_mbist_clk_init(void) 3507e403d005SPeter De Schrijver { 3508e403d005SPeter De Schrijver unsigned int i, j; 3509e403d005SPeter De Schrijver 3510e403d005SPeter De Schrijver for (i = 0; i < ARRAY_SIZE(tegra210_pg_mbist_war); i++) { 3511e403d005SPeter De Schrijver unsigned int num_clks = tegra210_pg_mbist_war[i].num_clks; 3512e403d005SPeter De Schrijver struct clk_bulk_data *clk_data; 3513e403d005SPeter De Schrijver 3514e403d005SPeter De Schrijver if (!num_clks) 3515e403d005SPeter De Schrijver continue; 3516e403d005SPeter De Schrijver 3517e403d005SPeter De Schrijver clk_data = kmalloc_array(num_clks, sizeof(*clk_data), 3518e403d005SPeter De Schrijver GFP_KERNEL); 3519e403d005SPeter De Schrijver if (WARN_ON(!clk_data)) 3520e403d005SPeter De Schrijver return; 3521e403d005SPeter De Schrijver 3522e403d005SPeter De Schrijver tegra210_pg_mbist_war[i].clks = clk_data; 3523e403d005SPeter De Schrijver for (j = 0; j < num_clks; j++) { 3524e403d005SPeter De Schrijver int clk_id = tegra210_pg_mbist_war[i].clk_init_data[j]; 3525e403d005SPeter De Schrijver struct clk *clk = clks[clk_id]; 3526e403d005SPeter De Schrijver 3527e403d005SPeter De Schrijver if (WARN(IS_ERR(clk), "clk_id: %d\n", clk_id)) { 3528e403d005SPeter De Schrijver kfree(clk_data); 3529e403d005SPeter De Schrijver tegra210_pg_mbist_war[i].clks = NULL; 3530e403d005SPeter De Schrijver break; 3531e403d005SPeter De Schrijver } 3532e403d005SPeter De Schrijver clk_data[j].clk = clk; 3533e403d005SPeter De Schrijver } 3534e403d005SPeter De Schrijver } 3535e403d005SPeter De Schrijver } 3536e403d005SPeter De Schrijver 353768d724ceSPeter De Schrijver /** 35386b301a05SRhyland Klein * tegra210_clock_init - Tegra210-specific clock initialization 35396b301a05SRhyland Klein * @np: struct device_node * of the DT node for the SoC CAR IP block 35406b301a05SRhyland Klein * 35416b301a05SRhyland Klein * Register most SoC clocks for the Tegra210 system-on-chip. Intended 35426b301a05SRhyland Klein * to be called by the OF init code when a DT node with the 35436b301a05SRhyland Klein * "nvidia,tegra210-car" string is encountered, and declared with 35446b301a05SRhyland Klein * CLK_OF_DECLARE. No return value. 35456b301a05SRhyland Klein */ 35466b301a05SRhyland Klein static void __init tegra210_clock_init(struct device_node *np) 35476b301a05SRhyland Klein { 35486b301a05SRhyland Klein struct device_node *node; 35496b301a05SRhyland Klein u32 value, clk_m_div; 35506b301a05SRhyland Klein 35516b301a05SRhyland Klein clk_base = of_iomap(np, 0); 35526b301a05SRhyland Klein if (!clk_base) { 35536b301a05SRhyland Klein pr_err("ioremap tegra210 CAR failed\n"); 35546b301a05SRhyland Klein return; 35556b301a05SRhyland Klein } 35566b301a05SRhyland Klein 35576b301a05SRhyland Klein node = of_find_matching_node(NULL, pmc_match); 35586b301a05SRhyland Klein if (!node) { 35596b301a05SRhyland Klein pr_err("Failed to find pmc node\n"); 35606b301a05SRhyland Klein WARN_ON(1); 35616b301a05SRhyland Klein return; 35626b301a05SRhyland Klein } 35636b301a05SRhyland Klein 35646b301a05SRhyland Klein pmc_base = of_iomap(node, 0); 35656b301a05SRhyland Klein if (!pmc_base) { 35666b301a05SRhyland Klein pr_err("Can't map pmc registers\n"); 35676b301a05SRhyland Klein WARN_ON(1); 35686b301a05SRhyland Klein return; 35696b301a05SRhyland Klein } 35706b301a05SRhyland Klein 3571e403d005SPeter De Schrijver ahub_base = ioremap(TEGRA210_AHUB_BASE, SZ_64K); 3572e403d005SPeter De Schrijver if (!ahub_base) { 3573e403d005SPeter De Schrijver pr_err("ioremap tegra210 APE failed\n"); 3574e403d005SPeter De Schrijver return; 3575e403d005SPeter De Schrijver } 3576e403d005SPeter De Schrijver 3577e403d005SPeter De Schrijver dispa_base = ioremap(TEGRA210_DISPA_BASE, SZ_256K); 3578e403d005SPeter De Schrijver if (!dispa_base) { 3579e403d005SPeter De Schrijver pr_err("ioremap tegra210 DISPA failed\n"); 3580e403d005SPeter De Schrijver return; 3581e403d005SPeter De Schrijver } 3582e403d005SPeter De Schrijver 3583e403d005SPeter De Schrijver vic_base = ioremap(TEGRA210_VIC_BASE, SZ_256K); 3584e403d005SPeter De Schrijver if (!vic_base) { 3585e403d005SPeter De Schrijver pr_err("ioremap tegra210 VIC failed\n"); 3586e403d005SPeter De Schrijver return; 3587e403d005SPeter De Schrijver } 3588e403d005SPeter De Schrijver 35896b301a05SRhyland Klein clks = tegra_clk_init(clk_base, TEGRA210_CLK_CLK_MAX, 35906b301a05SRhyland Klein TEGRA210_CAR_BANK_COUNT); 35916b301a05SRhyland Klein if (!clks) 35926b301a05SRhyland Klein return; 35936b301a05SRhyland Klein 35945834fd75SJonas Gorski value = readl(clk_base + SPARE_REG0) >> CLK_M_DIVISOR_SHIFT; 35956b301a05SRhyland Klein clk_m_div = (value & CLK_M_DIVISOR_MASK) + 1; 35966b301a05SRhyland Klein 35976b301a05SRhyland Klein if (tegra_osc_clk_init(clk_base, tegra210_clks, tegra210_input_freq, 35986b301a05SRhyland Klein ARRAY_SIZE(tegra210_input_freq), clk_m_div, 35996b301a05SRhyland Klein &osc_freq, &pll_ref_freq) < 0) 36006b301a05SRhyland Klein return; 36016b301a05SRhyland Klein 36026b301a05SRhyland Klein tegra_fixed_clk_init(tegra210_clks); 36036b301a05SRhyland Klein tegra210_pll_init(clk_base, pmc_base); 36046b301a05SRhyland Klein tegra210_periph_clk_init(clk_base, pmc_base); 36056b301a05SRhyland Klein tegra_audio_clk_init(clk_base, pmc_base, tegra210_clks, 36066b301a05SRhyland Klein tegra210_audio_plls, 3607845d782dSJon Hunter ARRAY_SIZE(tegra210_audio_plls), 24576000); 36086b301a05SRhyland Klein tegra_pmc_clk_init(pmc_base, tegra210_clks); 36096b301a05SRhyland Klein 36106b301a05SRhyland Klein /* For Tegra210, PLLD is the only source for DSIA & DSIB */ 36115834fd75SJonas Gorski value = readl(clk_base + PLLD_BASE); 36126b301a05SRhyland Klein value &= ~BIT(25); 36135834fd75SJonas Gorski writel(value, clk_base + PLLD_BASE); 36146b301a05SRhyland Klein 36156b301a05SRhyland Klein tegra_clk_apply_init_table = tegra210_clock_apply_init_table; 36166b301a05SRhyland Klein 36176b301a05SRhyland Klein tegra_super_clk_gen5_init(clk_base, pmc_base, tegra210_clks, 36186b301a05SRhyland Klein &pll_x_params); 361968d724ceSPeter De Schrijver tegra_init_special_resets(2, tegra210_reset_assert, 362068d724ceSPeter De Schrijver tegra210_reset_deassert); 362168d724ceSPeter De Schrijver 36225d797111SDmitry Osipenko tegra_add_of_provider(np, of_clk_src_onecell_get); 36236b301a05SRhyland Klein tegra_register_devclks(devclks, ARRAY_SIZE(devclks)); 36246b301a05SRhyland Klein 3625e403d005SPeter De Schrijver tegra210_mbist_clk_init(); 3626e403d005SPeter De Schrijver 36276b301a05SRhyland Klein tegra_cpu_car_ops = &tegra210_cpu_car_ops; 36286b301a05SRhyland Klein } 36296b301a05SRhyland Klein CLK_OF_DECLARE(tegra210, "nvidia,tegra210-car", tegra210_clock_init); 3630