19952f691SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
26b301a05SRhyland Klein /*
354443ef6SJC Kuo * Copyright (c) 2012-2020 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>
12535f296dSSowjanya Komatineni #include <linux/syscore_ops.h>
136b301a05SRhyland Klein #include <linux/delay.h>
146b301a05SRhyland Klein #include <linux/export.h>
15e403d005SPeter De Schrijver #include <linux/mutex.h>
166b301a05SRhyland Klein #include <linux/clk/tegra.h>
176b301a05SRhyland Klein #include <dt-bindings/clock/tegra210-car.h>
1868d724ceSPeter De Schrijver #include <dt-bindings/reset/tegra210-car.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
40a3cba697SJoseph Lo #define CLK_SOURCE_EMC_DLL 0x664
416b301a05SRhyland Klein
426b301a05SRhyland Klein #define PLLC_BASE 0x80
436b301a05SRhyland Klein #define PLLC_OUT 0x84
446b301a05SRhyland Klein #define PLLC_MISC0 0x88
456b301a05SRhyland Klein #define PLLC_MISC1 0x8c
466b301a05SRhyland Klein #define PLLC_MISC2 0x5d0
476b301a05SRhyland Klein #define PLLC_MISC3 0x5d4
486b301a05SRhyland Klein
496b301a05SRhyland Klein #define PLLC2_BASE 0x4e8
506b301a05SRhyland Klein #define PLLC2_MISC0 0x4ec
516b301a05SRhyland Klein #define PLLC2_MISC1 0x4f0
526b301a05SRhyland Klein #define PLLC2_MISC2 0x4f4
536b301a05SRhyland Klein #define PLLC2_MISC3 0x4f8
546b301a05SRhyland Klein
556b301a05SRhyland Klein #define PLLC3_BASE 0x4fc
566b301a05SRhyland Klein #define PLLC3_MISC0 0x500
576b301a05SRhyland Klein #define PLLC3_MISC1 0x504
586b301a05SRhyland Klein #define PLLC3_MISC2 0x508
596b301a05SRhyland Klein #define PLLC3_MISC3 0x50c
606b301a05SRhyland Klein
616b301a05SRhyland Klein #define PLLM_BASE 0x90
626b301a05SRhyland Klein #define PLLM_MISC1 0x98
63474f2ba2SRhyland Klein #define PLLM_MISC2 0x9c
646b301a05SRhyland Klein #define PLLP_BASE 0xa0
656b301a05SRhyland Klein #define PLLP_MISC0 0xac
666b301a05SRhyland Klein #define PLLP_MISC1 0x680
676b301a05SRhyland Klein #define PLLA_BASE 0xb0
686b301a05SRhyland Klein #define PLLA_MISC0 0xbc
696b301a05SRhyland Klein #define PLLA_MISC1 0xb8
706b301a05SRhyland Klein #define PLLA_MISC2 0x5d8
716b301a05SRhyland Klein #define PLLD_BASE 0xd0
726b301a05SRhyland Klein #define PLLD_MISC0 0xdc
736b301a05SRhyland Klein #define PLLD_MISC1 0xd8
746b301a05SRhyland Klein #define PLLU_BASE 0xc0
756b301a05SRhyland Klein #define PLLU_OUTA 0xc4
766b301a05SRhyland Klein #define PLLU_MISC0 0xcc
776b301a05SRhyland Klein #define PLLU_MISC1 0xc8
786b301a05SRhyland Klein #define PLLX_BASE 0xe0
796b301a05SRhyland Klein #define PLLX_MISC0 0xe4
806b301a05SRhyland Klein #define PLLX_MISC1 0x510
816b301a05SRhyland Klein #define PLLX_MISC2 0x514
826b301a05SRhyland Klein #define PLLX_MISC3 0x518
836b301a05SRhyland Klein #define PLLX_MISC4 0x5f0
846b301a05SRhyland Klein #define PLLX_MISC5 0x5f4
856b301a05SRhyland Klein #define PLLE_BASE 0xe8
866b301a05SRhyland Klein #define PLLE_MISC0 0xec
876b301a05SRhyland Klein #define PLLD2_BASE 0x4b8
886b301a05SRhyland Klein #define PLLD2_MISC0 0x4bc
896b301a05SRhyland Klein #define PLLD2_MISC1 0x570
906b301a05SRhyland Klein #define PLLD2_MISC2 0x574
916b301a05SRhyland Klein #define PLLD2_MISC3 0x578
926b301a05SRhyland Klein #define PLLE_AUX 0x48c
936b301a05SRhyland Klein #define PLLRE_BASE 0x4c4
946b301a05SRhyland Klein #define PLLRE_MISC0 0x4c8
95926655f9SRhyland Klein #define PLLRE_OUT1 0x4cc
966b301a05SRhyland Klein #define PLLDP_BASE 0x590
976b301a05SRhyland Klein #define PLLDP_MISC 0x594
986b301a05SRhyland Klein
996b301a05SRhyland Klein #define PLLC4_BASE 0x5a4
1006b301a05SRhyland Klein #define PLLC4_MISC0 0x5a8
1016b301a05SRhyland Klein #define PLLC4_OUT 0x5e4
1026b301a05SRhyland Klein #define PLLMB_BASE 0x5e8
103474f2ba2SRhyland Klein #define PLLMB_MISC1 0x5ec
1046b301a05SRhyland Klein #define PLLA1_BASE 0x6a4
1056b301a05SRhyland Klein #define PLLA1_MISC0 0x6a8
1066b301a05SRhyland Klein #define PLLA1_MISC1 0x6ac
1076b301a05SRhyland Klein #define PLLA1_MISC2 0x6b0
1086b301a05SRhyland Klein #define PLLA1_MISC3 0x6b4
1096b301a05SRhyland Klein
1106b301a05SRhyland Klein #define PLLU_IDDQ_BIT 31
1116b301a05SRhyland Klein #define PLLCX_IDDQ_BIT 27
1126b301a05SRhyland Klein #define PLLRE_IDDQ_BIT 24
1136b301a05SRhyland Klein #define PLLA_IDDQ_BIT 25
1146b301a05SRhyland Klein #define PLLD_IDDQ_BIT 20
1156b301a05SRhyland Klein #define PLLSS_IDDQ_BIT 18
1166b301a05SRhyland Klein #define PLLM_IDDQ_BIT 5
1176b301a05SRhyland Klein #define PLLMB_IDDQ_BIT 17
1186b301a05SRhyland Klein #define PLLXP_IDDQ_BIT 3
1196b301a05SRhyland Klein
1206b301a05SRhyland Klein #define PLLCX_RESET_BIT 30
1216b301a05SRhyland Klein
1226b301a05SRhyland Klein #define PLL_BASE_LOCK BIT(27)
1236b301a05SRhyland Klein #define PLLCX_BASE_LOCK BIT(26)
1246b301a05SRhyland Klein #define PLLE_MISC_LOCK BIT(11)
1256b301a05SRhyland Klein #define PLLRE_MISC_LOCK BIT(27)
1266b301a05SRhyland Klein
1276b301a05SRhyland Klein #define PLL_MISC_LOCK_ENABLE 18
1286b301a05SRhyland Klein #define PLLC_MISC_LOCK_ENABLE 24
1296b301a05SRhyland Klein #define PLLDU_MISC_LOCK_ENABLE 22
1306b301a05SRhyland Klein #define PLLU_MISC_LOCK_ENABLE 29
1316b301a05SRhyland Klein #define PLLE_MISC_LOCK_ENABLE 9
1326b301a05SRhyland Klein #define PLLRE_MISC_LOCK_ENABLE 30
1336b301a05SRhyland Klein #define PLLSS_MISC_LOCK_ENABLE 30
1346b301a05SRhyland Klein #define PLLP_MISC_LOCK_ENABLE 18
1356b301a05SRhyland Klein #define PLLM_MISC_LOCK_ENABLE 4
1366b301a05SRhyland Klein #define PLLMB_MISC_LOCK_ENABLE 16
1376b301a05SRhyland Klein #define PLLA_MISC_LOCK_ENABLE 28
1386b301a05SRhyland Klein #define PLLU_MISC_LOCK_ENABLE 29
1396b301a05SRhyland Klein #define PLLD_MISC_LOCK_ENABLE 18
1406b301a05SRhyland Klein
1416b301a05SRhyland Klein #define PLLA_SDM_DIN_MASK 0xffff
1426b301a05SRhyland Klein #define PLLA_SDM_EN_MASK BIT(26)
1436b301a05SRhyland Klein
1446b301a05SRhyland Klein #define PLLD_SDM_EN_MASK BIT(16)
1456b301a05SRhyland Klein
1466b301a05SRhyland Klein #define PLLD2_SDM_EN_MASK BIT(31)
147030999feSPeter De Schrijver #define PLLD2_SSC_EN_MASK 0
1486b301a05SRhyland Klein
1496b301a05SRhyland Klein #define PLLDP_SS_CFG 0x598
1506b301a05SRhyland Klein #define PLLDP_SDM_EN_MASK BIT(31)
1516b301a05SRhyland Klein #define PLLDP_SSC_EN_MASK BIT(30)
1526b301a05SRhyland Klein #define PLLDP_SS_CTRL1 0x59c
1536b301a05SRhyland Klein #define PLLDP_SS_CTRL2 0x5a0
1546b301a05SRhyland Klein
1556b301a05SRhyland Klein #define PMC_PLLM_WB0_OVERRIDE 0x1dc
1566b301a05SRhyland Klein #define PMC_PLLM_WB0_OVERRIDE_2 0x2b0
1576b301a05SRhyland Klein
158e745f992SPeter De Schrijver #define UTMIP_PLL_CFG2 0x488
159e745f992SPeter De Schrijver #define UTMIP_PLL_CFG2_STABLE_COUNT(x) (((x) & 0xfff) << 6)
160e745f992SPeter De Schrijver #define UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(x) (((x) & 0x3f) << 18)
161e745f992SPeter De Schrijver #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_A_POWERDOWN BIT(0)
162e745f992SPeter De Schrijver #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_A_POWERUP BIT(1)
163e745f992SPeter De Schrijver #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_B_POWERDOWN BIT(2)
164e745f992SPeter De Schrijver #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_B_POWERUP BIT(3)
165e745f992SPeter De Schrijver #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_C_POWERDOWN BIT(4)
166e745f992SPeter De Schrijver #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_C_POWERUP BIT(5)
167e745f992SPeter De Schrijver #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_D_POWERDOWN BIT(24)
168e745f992SPeter De Schrijver #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_D_POWERUP BIT(25)
169e745f992SPeter De Schrijver
170e745f992SPeter De Schrijver #define UTMIP_PLL_CFG1 0x484
171e745f992SPeter De Schrijver #define UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(x) (((x) & 0x1f) << 27)
172e745f992SPeter De Schrijver #define UTMIP_PLL_CFG1_XTAL_FREQ_COUNT(x) (((x) & 0xfff) << 0)
173e745f992SPeter De Schrijver #define UTMIP_PLL_CFG1_FORCE_PLLU_POWERUP BIT(17)
174e745f992SPeter De Schrijver #define UTMIP_PLL_CFG1_FORCE_PLLU_POWERDOWN BIT(16)
175e745f992SPeter De Schrijver #define UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERUP BIT(15)
176e745f992SPeter De Schrijver #define UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERDOWN BIT(14)
177e745f992SPeter De Schrijver #define UTMIP_PLL_CFG1_FORCE_PLL_ACTIVE_POWERDOWN BIT(12)
178e745f992SPeter De Schrijver
1793358d2d9SAndrew Bresticker #define SATA_PLL_CFG0 0x490
1803358d2d9SAndrew Bresticker #define SATA_PLL_CFG0_PADPLL_RESET_SWCTL BIT(0)
1813358d2d9SAndrew Bresticker #define SATA_PLL_CFG0_PADPLL_USE_LOCKDET BIT(2)
18259af78d7SPeter De Schrijver #define SATA_PLL_CFG0_SATA_SEQ_IN_SWCTL BIT(4)
18359af78d7SPeter De Schrijver #define SATA_PLL_CFG0_SATA_SEQ_RESET_INPUT_VALUE BIT(5)
18459af78d7SPeter De Schrijver #define SATA_PLL_CFG0_SATA_SEQ_LANE_PD_INPUT_VALUE BIT(6)
18559af78d7SPeter De Schrijver #define SATA_PLL_CFG0_SATA_SEQ_PADPLL_PD_INPUT_VALUE BIT(7)
18659af78d7SPeter De Schrijver
1873358d2d9SAndrew Bresticker #define SATA_PLL_CFG0_PADPLL_SLEEP_IDDQ BIT(13)
1883358d2d9SAndrew Bresticker #define SATA_PLL_CFG0_SEQ_ENABLE BIT(24)
1893358d2d9SAndrew Bresticker
1903358d2d9SAndrew Bresticker #define XUSBIO_PLL_CFG0 0x51c
1913358d2d9SAndrew Bresticker #define XUSBIO_PLL_CFG0_PADPLL_RESET_SWCTL BIT(0)
1923358d2d9SAndrew Bresticker #define XUSBIO_PLL_CFG0_CLK_ENABLE_SWCTL BIT(2)
1933358d2d9SAndrew Bresticker #define XUSBIO_PLL_CFG0_PADPLL_USE_LOCKDET BIT(6)
1943358d2d9SAndrew Bresticker #define XUSBIO_PLL_CFG0_PADPLL_SLEEP_IDDQ BIT(13)
1953358d2d9SAndrew Bresticker #define XUSBIO_PLL_CFG0_SEQ_ENABLE BIT(24)
1963358d2d9SAndrew Bresticker
1976b301a05SRhyland Klein #define UTMIPLL_HW_PWRDN_CFG0 0x52c
1986b301a05SRhyland Klein #define UTMIPLL_HW_PWRDN_CFG0_UTMIPLL_LOCK BIT(31)
1996b301a05SRhyland Klein #define UTMIPLL_HW_PWRDN_CFG0_SEQ_START_STATE BIT(25)
2006b301a05SRhyland Klein #define UTMIPLL_HW_PWRDN_CFG0_SEQ_ENABLE BIT(24)
2016b301a05SRhyland Klein #define UTMIPLL_HW_PWRDN_CFG0_IDDQ_PD_INCLUDE BIT(7)
2026b301a05SRhyland Klein #define UTMIPLL_HW_PWRDN_CFG0_USE_LOCKDET BIT(6)
2036b301a05SRhyland Klein #define UTMIPLL_HW_PWRDN_CFG0_SEQ_RESET_INPUT_VALUE BIT(5)
2046b301a05SRhyland Klein #define UTMIPLL_HW_PWRDN_CFG0_SEQ_IN_SWCTL BIT(4)
2056b301a05SRhyland Klein #define UTMIPLL_HW_PWRDN_CFG0_CLK_ENABLE_SWCTL BIT(2)
2066b301a05SRhyland Klein #define UTMIPLL_HW_PWRDN_CFG0_IDDQ_OVERRIDE BIT(1)
2076b301a05SRhyland Klein #define UTMIPLL_HW_PWRDN_CFG0_IDDQ_SWCTL BIT(0)
2086b301a05SRhyland Klein
2096b301a05SRhyland Klein #define PLLU_HW_PWRDN_CFG0 0x530
2106b301a05SRhyland Klein #define PLLU_HW_PWRDN_CFG0_IDDQ_PD_INCLUDE BIT(28)
2116b301a05SRhyland Klein #define PLLU_HW_PWRDN_CFG0_SEQ_ENABLE BIT(24)
2126b301a05SRhyland Klein #define PLLU_HW_PWRDN_CFG0_USE_SWITCH_DETECT BIT(7)
2136b301a05SRhyland Klein #define PLLU_HW_PWRDN_CFG0_USE_LOCKDET BIT(6)
2146b301a05SRhyland Klein #define PLLU_HW_PWRDN_CFG0_CLK_ENABLE_SWCTL BIT(2)
2156b301a05SRhyland Klein #define PLLU_HW_PWRDN_CFG0_CLK_SWITCH_SWCTL BIT(0)
2166b301a05SRhyland Klein
2176b301a05SRhyland Klein #define XUSB_PLL_CFG0 0x534
2186b301a05SRhyland Klein #define XUSB_PLL_CFG0_UTMIPLL_LOCK_DLY 0x3ff
2196b301a05SRhyland Klein #define XUSB_PLL_CFG0_PLLU_LOCK_DLY_MASK (0x3ff << 14)
2206b301a05SRhyland Klein
2216b301a05SRhyland Klein #define SPARE_REG0 0x55c
2226b301a05SRhyland Klein #define CLK_M_DIVISOR_SHIFT 2
2236b301a05SRhyland Klein #define CLK_M_DIVISOR_MASK 0x3
2246b301a05SRhyland Klein
225535f296dSSowjanya Komatineni #define CLK_MASK_ARM 0x44
226535f296dSSowjanya Komatineni #define MISC_CLK_ENB 0x48
227535f296dSSowjanya Komatineni
22868d724ceSPeter De Schrijver #define RST_DFLL_DVCO 0x2f4
22968d724ceSPeter De Schrijver #define DVFS_DFLL_RESET_SHIFT 0
23068d724ceSPeter De Schrijver
231a3cba697SJoseph Lo #define CLK_RST_CONTROLLER_CLK_OUT_ENB_X_SET 0x284
232a3cba697SJoseph Lo #define CLK_RST_CONTROLLER_CLK_OUT_ENB_X_CLR 0x288
233a3cba697SJoseph Lo #define CLK_OUT_ENB_X_CLK_ENB_EMC_DLL BIT(14)
234a3cba697SJoseph Lo
23568d724ceSPeter De Schrijver #define CLK_RST_CONTROLLER_RST_DEV_Y_SET 0x2a8
23668d724ceSPeter De Schrijver #define CLK_RST_CONTROLLER_RST_DEV_Y_CLR 0x2ac
237535f296dSSowjanya Komatineni #define CPU_SOFTRST_CTRL 0x380
23868d724ceSPeter De Schrijver
239e403d005SPeter De Schrijver #define LVL2_CLK_GATE_OVRA 0xf8
240e403d005SPeter De Schrijver #define LVL2_CLK_GATE_OVRC 0x3a0
241e403d005SPeter De Schrijver #define LVL2_CLK_GATE_OVRD 0x3a4
242e403d005SPeter De Schrijver #define LVL2_CLK_GATE_OVRE 0x554
243e403d005SPeter De Schrijver
244e403d005SPeter De Schrijver /* I2S registers to handle during APE MBIST WAR */
245e403d005SPeter De Schrijver #define TEGRA210_I2S_BASE 0x1000
246e403d005SPeter De Schrijver #define TEGRA210_I2S_SIZE 0x100
247e403d005SPeter De Schrijver #define TEGRA210_I2S_CTRLS 5
248e403d005SPeter De Schrijver #define TEGRA210_I2S_CG 0x88
249e403d005SPeter De Schrijver #define TEGRA210_I2S_CTRL 0xa0
250e403d005SPeter De Schrijver
251e403d005SPeter De Schrijver /* DISPA registers to handle during MBIST WAR */
252e403d005SPeter De Schrijver #define DC_CMD_DISPLAY_COMMAND 0xc8
253e403d005SPeter De Schrijver #define DC_COM_DSC_TOP_CTL 0xcf8
254e403d005SPeter De Schrijver
255e403d005SPeter De Schrijver /* VIC register to handle during MBIST WAR */
256e403d005SPeter De Schrijver #define NV_PVIC_THI_SLCG_OVERRIDE_LOW 0x8c
257e403d005SPeter De Schrijver
258e403d005SPeter De Schrijver /* APE, DISPA and VIC base addesses needed for MBIST WAR */
259e403d005SPeter De Schrijver #define TEGRA210_AHUB_BASE 0x702d0000
260e403d005SPeter De Schrijver #define TEGRA210_DISPA_BASE 0x54200000
261e403d005SPeter De Schrijver #define TEGRA210_VIC_BASE 0x54340000
262e403d005SPeter De Schrijver
2636b301a05SRhyland Klein /*
2646b301a05SRhyland Klein * SDM fractional divisor is 16-bit 2's complement signed number within
2656b301a05SRhyland Klein * (-2^12 ... 2^12-1) range. Represented in PLL data structure as unsigned
2666b301a05SRhyland Klein * 16-bit value, with "0" divisor mapped to 0xFFFF. Data "0" is used to
2676b301a05SRhyland Klein * indicate that SDM is disabled.
2686b301a05SRhyland Klein *
2696b301a05SRhyland Klein * Effective ndiv value when SDM is enabled: ndiv + 1/2 + sdm_din/2^13
2706b301a05SRhyland Klein */
2716b301a05SRhyland Klein #define PLL_SDM_COEFF BIT(13)
2726b301a05SRhyland Klein #define sdin_din_to_data(din) ((u16)((din) ? : 0xFFFFU))
2736b301a05SRhyland Klein #define sdin_data_to_din(dat) (((dat) == 0xFFFFU) ? 0 : (s16)dat)
274a851ea2bSAlex Frid /* This macro returns ndiv effective scaled to SDM range */
275a851ea2bSAlex Frid #define sdin_get_n_eff(cfg) ((cfg)->n * PLL_SDM_COEFF + ((cfg)->sdm_data ? \
276a851ea2bSAlex Frid (PLL_SDM_COEFF/2 + sdin_data_to_din((cfg)->sdm_data)) : 0))
2776b301a05SRhyland Klein
2786b301a05SRhyland Klein /* Tegra CPU clock and reset control regs */
2796b301a05SRhyland Klein #define CLK_RST_CONTROLLER_CPU_CMPLX_STATUS 0x470
2806b301a05SRhyland Klein
2816b301a05SRhyland Klein #ifdef CONFIG_PM_SLEEP
2826b301a05SRhyland Klein static struct cpu_clk_suspend_context {
2836b301a05SRhyland Klein u32 clk_csite_src;
2846b301a05SRhyland Klein } tegra210_cpu_clk_sctx;
2856b301a05SRhyland Klein #endif
2866b301a05SRhyland Klein
287e403d005SPeter De Schrijver struct tegra210_domain_mbist_war {
288e403d005SPeter De Schrijver void (*handle_lvl2_ovr)(struct tegra210_domain_mbist_war *mbist);
289e403d005SPeter De Schrijver const u32 lvl2_offset;
290e403d005SPeter De Schrijver const u32 lvl2_mask;
291e403d005SPeter De Schrijver const unsigned int num_clks;
292e403d005SPeter De Schrijver const unsigned int *clk_init_data;
293e403d005SPeter De Schrijver struct clk_bulk_data *clks;
294e403d005SPeter De Schrijver };
295e403d005SPeter De Schrijver
296e403d005SPeter De Schrijver static struct clk **clks;
297e403d005SPeter De Schrijver
2986b301a05SRhyland Klein static void __iomem *clk_base;
2996b301a05SRhyland Klein static void __iomem *pmc_base;
300e403d005SPeter De Schrijver static void __iomem *ahub_base;
301e403d005SPeter De Schrijver static void __iomem *dispa_base;
302e403d005SPeter De Schrijver static void __iomem *vic_base;
3036b301a05SRhyland Klein
3046b301a05SRhyland Klein static unsigned long osc_freq;
3056b301a05SRhyland Klein static unsigned long pll_ref_freq;
3066b301a05SRhyland Klein
3076b301a05SRhyland Klein static DEFINE_SPINLOCK(pll_d_lock);
3086b301a05SRhyland Klein static DEFINE_SPINLOCK(pll_e_lock);
3096b301a05SRhyland Klein static DEFINE_SPINLOCK(pll_re_lock);
3106b301a05SRhyland Klein static DEFINE_SPINLOCK(pll_u_lock);
31105308d7eSThierry Reding static DEFINE_SPINLOCK(sor0_lock);
312bc2e4d29SThierry Reding static DEFINE_SPINLOCK(sor1_lock);
3136b301a05SRhyland Klein static DEFINE_SPINLOCK(emc_lock);
314e403d005SPeter De Schrijver static DEFINE_MUTEX(lvl2_ovr_lock);
3156b301a05SRhyland Klein
3166b301a05SRhyland Klein /* possible OSC frequencies in Hz */
3176b301a05SRhyland Klein static unsigned long tegra210_input_freq[] = {
3186b301a05SRhyland Klein [5] = 38400000,
3196b301a05SRhyland Klein [8] = 12000000,
3206b301a05SRhyland Klein };
3216b301a05SRhyland Klein
3226b301a05SRhyland Klein #define PLL_ENABLE (1 << 30)
3236b301a05SRhyland Klein
3246b301a05SRhyland Klein #define PLLCX_MISC1_IDDQ (1 << 27)
3256b301a05SRhyland Klein #define PLLCX_MISC0_RESET (1 << 30)
3266b301a05SRhyland Klein
3276b301a05SRhyland Klein #define PLLCX_MISC0_DEFAULT_VALUE 0x40080000
3286b301a05SRhyland Klein #define PLLCX_MISC0_WRITE_MASK 0x400ffffb
3296b301a05SRhyland Klein #define PLLCX_MISC1_DEFAULT_VALUE 0x08000000
3306b301a05SRhyland Klein #define PLLCX_MISC1_WRITE_MASK 0x08003cff
3316b301a05SRhyland Klein #define PLLCX_MISC2_DEFAULT_VALUE 0x1f720f05
3326b301a05SRhyland Klein #define PLLCX_MISC2_WRITE_MASK 0xffffff17
3336b301a05SRhyland Klein #define PLLCX_MISC3_DEFAULT_VALUE 0x000000c4
3346b301a05SRhyland Klein #define PLLCX_MISC3_WRITE_MASK 0x00ffffff
3356b301a05SRhyland Klein
3366b301a05SRhyland Klein /* PLLA */
3376b301a05SRhyland Klein #define PLLA_BASE_IDDQ (1 << 25)
3386b301a05SRhyland Klein #define PLLA_BASE_LOCK (1 << 27)
3396b301a05SRhyland Klein
3406b301a05SRhyland Klein #define PLLA_MISC0_LOCK_ENABLE (1 << 28)
3416b301a05SRhyland Klein #define PLLA_MISC0_LOCK_OVERRIDE (1 << 27)
3426b301a05SRhyland Klein
3436b301a05SRhyland Klein #define PLLA_MISC2_EN_SDM (1 << 26)
3446b301a05SRhyland Klein #define PLLA_MISC2_EN_DYNRAMP (1 << 25)
3456b301a05SRhyland Klein
3466b301a05SRhyland Klein #define PLLA_MISC0_DEFAULT_VALUE 0x12000020
3476b301a05SRhyland Klein #define PLLA_MISC0_WRITE_MASK 0x7fffffff
3486b301a05SRhyland Klein #define PLLA_MISC2_DEFAULT_VALUE 0x0
3496b301a05SRhyland Klein #define PLLA_MISC2_WRITE_MASK 0x06ffffff
3506b301a05SRhyland Klein
3516b301a05SRhyland Klein /* PLLD */
352e403d005SPeter De Schrijver #define PLLD_BASE_CSI_CLKSOURCE (1 << 23)
353e403d005SPeter De Schrijver
3546b301a05SRhyland Klein #define PLLD_MISC0_EN_SDM (1 << 16)
3556b301a05SRhyland Klein #define PLLD_MISC0_LOCK_OVERRIDE (1 << 17)
3566b301a05SRhyland Klein #define PLLD_MISC0_LOCK_ENABLE (1 << 18)
3576b301a05SRhyland Klein #define PLLD_MISC0_IDDQ (1 << 20)
3586b301a05SRhyland Klein #define PLLD_MISC0_DSI_CLKENABLE (1 << 21)
3596b301a05SRhyland Klein
3606b301a05SRhyland Klein #define PLLD_MISC0_DEFAULT_VALUE 0x00140000
3616b301a05SRhyland Klein #define PLLD_MISC0_WRITE_MASK 0x3ff7ffff
3626b301a05SRhyland Klein #define PLLD_MISC1_DEFAULT_VALUE 0x20
3636b301a05SRhyland Klein #define PLLD_MISC1_WRITE_MASK 0x00ffffff
3646b301a05SRhyland Klein
3656b301a05SRhyland Klein /* PLLD2 and PLLDP and PLLC4 */
3666b301a05SRhyland Klein #define PLLDSS_BASE_LOCK (1 << 27)
3676b301a05SRhyland Klein #define PLLDSS_BASE_LOCK_OVERRIDE (1 << 24)
3686b301a05SRhyland Klein #define PLLDSS_BASE_IDDQ (1 << 18)
3696b301a05SRhyland Klein #define PLLDSS_BASE_REF_SEL_SHIFT 25
3706b301a05SRhyland Klein #define PLLDSS_BASE_REF_SEL_MASK (0x3 << PLLDSS_BASE_REF_SEL_SHIFT)
3716b301a05SRhyland Klein
3726b301a05SRhyland Klein #define PLLDSS_MISC0_LOCK_ENABLE (1 << 30)
3736b301a05SRhyland Klein
3746b301a05SRhyland Klein #define PLLDSS_MISC1_CFG_EN_SDM (1 << 31)
3756b301a05SRhyland Klein #define PLLDSS_MISC1_CFG_EN_SSC (1 << 30)
3766b301a05SRhyland Klein
3776b301a05SRhyland Klein #define PLLD2_MISC0_DEFAULT_VALUE 0x40000020
3786b301a05SRhyland Klein #define PLLD2_MISC1_CFG_DEFAULT_VALUE 0x10000000
3796b301a05SRhyland Klein #define PLLD2_MISC2_CTRL1_DEFAULT_VALUE 0x0
3806b301a05SRhyland Klein #define PLLD2_MISC3_CTRL2_DEFAULT_VALUE 0x0
3816b301a05SRhyland Klein
3826b301a05SRhyland Klein #define PLLDP_MISC0_DEFAULT_VALUE 0x40000020
3836b301a05SRhyland Klein #define PLLDP_MISC1_CFG_DEFAULT_VALUE 0xc0000000
3846b301a05SRhyland Klein #define PLLDP_MISC2_CTRL1_DEFAULT_VALUE 0xf400f0da
3856b301a05SRhyland Klein #define PLLDP_MISC3_CTRL2_DEFAULT_VALUE 0x2004f400
3866b301a05SRhyland Klein
3876b301a05SRhyland Klein #define PLLDSS_MISC0_WRITE_MASK 0x47ffffff
3886b301a05SRhyland Klein #define PLLDSS_MISC1_CFG_WRITE_MASK 0xf8000000
3896b301a05SRhyland Klein #define PLLDSS_MISC2_CTRL1_WRITE_MASK 0xffffffff
3906b301a05SRhyland Klein #define PLLDSS_MISC3_CTRL2_WRITE_MASK 0xffffffff
3916b301a05SRhyland Klein
3926b301a05SRhyland Klein #define PLLC4_MISC0_DEFAULT_VALUE 0x40000000
3936b301a05SRhyland Klein
3946b301a05SRhyland Klein /* PLLRE */
3956b301a05SRhyland Klein #define PLLRE_MISC0_LOCK_ENABLE (1 << 30)
3966b301a05SRhyland Klein #define PLLRE_MISC0_LOCK_OVERRIDE (1 << 29)
3976b301a05SRhyland Klein #define PLLRE_MISC0_LOCK (1 << 27)
3986b301a05SRhyland Klein #define PLLRE_MISC0_IDDQ (1 << 24)
3996b301a05SRhyland Klein
4006b301a05SRhyland Klein #define PLLRE_BASE_DEFAULT_VALUE 0x0
4016b301a05SRhyland Klein #define PLLRE_MISC0_DEFAULT_VALUE 0x41000000
4026b301a05SRhyland Klein
4036b301a05SRhyland Klein #define PLLRE_BASE_DEFAULT_MASK 0x1c000000
4046b301a05SRhyland Klein #define PLLRE_MISC0_WRITE_MASK 0x67ffffff
4056b301a05SRhyland Klein
40654443ef6SJC Kuo /* PLLE */
40754443ef6SJC Kuo #define PLLE_MISC_IDDQ_SW_CTRL (1 << 14)
40854443ef6SJC Kuo #define PLLE_AUX_USE_LOCKDET (1 << 3)
40954443ef6SJC Kuo #define PLLE_AUX_SS_SEQ_INCLUDE (1 << 31)
41054443ef6SJC Kuo #define PLLE_AUX_ENABLE_SWCTL (1 << 4)
41154443ef6SJC Kuo #define PLLE_AUX_SS_SWCTL (1 << 6)
41254443ef6SJC Kuo #define PLLE_AUX_SEQ_ENABLE (1 << 24)
41354443ef6SJC Kuo
4146b301a05SRhyland Klein /* PLLX */
4156b301a05SRhyland Klein #define PLLX_USE_DYN_RAMP 1
4166b301a05SRhyland Klein #define PLLX_BASE_LOCK (1 << 27)
4176b301a05SRhyland Klein
4186b301a05SRhyland Klein #define PLLX_MISC0_FO_G_DISABLE (0x1 << 28)
4196b301a05SRhyland Klein #define PLLX_MISC0_LOCK_ENABLE (0x1 << 18)
4206b301a05SRhyland Klein
4216b301a05SRhyland Klein #define PLLX_MISC2_DYNRAMP_STEPB_SHIFT 24
4226b301a05SRhyland Klein #define PLLX_MISC2_DYNRAMP_STEPB_MASK (0xFF << PLLX_MISC2_DYNRAMP_STEPB_SHIFT)
4236b301a05SRhyland Klein #define PLLX_MISC2_DYNRAMP_STEPA_SHIFT 16
4246b301a05SRhyland Klein #define PLLX_MISC2_DYNRAMP_STEPA_MASK (0xFF << PLLX_MISC2_DYNRAMP_STEPA_SHIFT)
4256b301a05SRhyland Klein #define PLLX_MISC2_NDIV_NEW_SHIFT 8
4266b301a05SRhyland Klein #define PLLX_MISC2_NDIV_NEW_MASK (0xFF << PLLX_MISC2_NDIV_NEW_SHIFT)
4276b301a05SRhyland Klein #define PLLX_MISC2_LOCK_OVERRIDE (0x1 << 4)
4286b301a05SRhyland Klein #define PLLX_MISC2_DYNRAMP_DONE (0x1 << 2)
4296b301a05SRhyland Klein #define PLLX_MISC2_EN_DYNRAMP (0x1 << 0)
4306b301a05SRhyland Klein
4316b301a05SRhyland Klein #define PLLX_MISC3_IDDQ (0x1 << 3)
4326b301a05SRhyland Klein
4336b301a05SRhyland Klein #define PLLX_MISC0_DEFAULT_VALUE PLLX_MISC0_LOCK_ENABLE
4346b301a05SRhyland Klein #define PLLX_MISC0_WRITE_MASK 0x10c40000
4356b301a05SRhyland Klein #define PLLX_MISC1_DEFAULT_VALUE 0x20
4366b301a05SRhyland Klein #define PLLX_MISC1_WRITE_MASK 0x00ffffff
4376b301a05SRhyland Klein #define PLLX_MISC2_DEFAULT_VALUE 0x0
4386b301a05SRhyland Klein #define PLLX_MISC2_WRITE_MASK 0xffffff11
4396b301a05SRhyland Klein #define PLLX_MISC3_DEFAULT_VALUE PLLX_MISC3_IDDQ
4406b301a05SRhyland Klein #define PLLX_MISC3_WRITE_MASK 0x01ff0f0f
4416b301a05SRhyland Klein #define PLLX_MISC4_DEFAULT_VALUE 0x0
4426b301a05SRhyland Klein #define PLLX_MISC4_WRITE_MASK 0x8000ffff
4436b301a05SRhyland Klein #define PLLX_MISC5_DEFAULT_VALUE 0x0
4446b301a05SRhyland Klein #define PLLX_MISC5_WRITE_MASK 0x0000ffff
4456b301a05SRhyland Klein
4466b301a05SRhyland Klein #define PLLX_HW_CTRL_CFG 0x548
4476b301a05SRhyland Klein #define PLLX_HW_CTRL_CFG_SWCTRL (0x1 << 0)
4486b301a05SRhyland Klein
4496b301a05SRhyland Klein /* PLLMB */
4506b301a05SRhyland Klein #define PLLMB_BASE_LOCK (1 << 27)
4516b301a05SRhyland Klein
452474f2ba2SRhyland Klein #define PLLMB_MISC1_LOCK_OVERRIDE (1 << 18)
453474f2ba2SRhyland Klein #define PLLMB_MISC1_IDDQ (1 << 17)
454474f2ba2SRhyland Klein #define PLLMB_MISC1_LOCK_ENABLE (1 << 16)
4556b301a05SRhyland Klein
456474f2ba2SRhyland Klein #define PLLMB_MISC1_DEFAULT_VALUE 0x00030000
457474f2ba2SRhyland Klein #define PLLMB_MISC1_WRITE_MASK 0x0007ffff
4586b301a05SRhyland Klein
4596b301a05SRhyland Klein /* PLLP */
4606b301a05SRhyland Klein #define PLLP_BASE_OVERRIDE (1 << 28)
4616b301a05SRhyland Klein #define PLLP_BASE_LOCK (1 << 27)
4626b301a05SRhyland Klein
4636b301a05SRhyland Klein #define PLLP_MISC0_LOCK_ENABLE (1 << 18)
4646b301a05SRhyland Klein #define PLLP_MISC0_LOCK_OVERRIDE (1 << 17)
4656b301a05SRhyland Klein #define PLLP_MISC0_IDDQ (1 << 3)
4666b301a05SRhyland Klein
4676b301a05SRhyland Klein #define PLLP_MISC1_HSIO_EN_SHIFT 29
4686b301a05SRhyland Klein #define PLLP_MISC1_HSIO_EN (1 << PLLP_MISC1_HSIO_EN_SHIFT)
4696b301a05SRhyland Klein #define PLLP_MISC1_XUSB_EN_SHIFT 28
4706b301a05SRhyland Klein #define PLLP_MISC1_XUSB_EN (1 << PLLP_MISC1_XUSB_EN_SHIFT)
4716b301a05SRhyland Klein
4726b301a05SRhyland Klein #define PLLP_MISC0_DEFAULT_VALUE 0x00040008
4736b301a05SRhyland Klein #define PLLP_MISC1_DEFAULT_VALUE 0x0
4746b301a05SRhyland Klein
4756b301a05SRhyland Klein #define PLLP_MISC0_WRITE_MASK 0xdc6000f
4766b301a05SRhyland Klein #define PLLP_MISC1_WRITE_MASK 0x70ffffff
4776b301a05SRhyland Klein
4786b301a05SRhyland Klein /* PLLU */
4796b301a05SRhyland Klein #define PLLU_BASE_LOCK (1 << 27)
4806b301a05SRhyland Klein #define PLLU_BASE_OVERRIDE (1 << 24)
4816b301a05SRhyland Klein #define PLLU_BASE_CLKENABLE_USB (1 << 21)
4826b301a05SRhyland Klein #define PLLU_BASE_CLKENABLE_HSIC (1 << 22)
4836b301a05SRhyland Klein #define PLLU_BASE_CLKENABLE_ICUSB (1 << 23)
4846b301a05SRhyland Klein #define PLLU_BASE_CLKENABLE_48M (1 << 25)
4856b301a05SRhyland Klein #define PLLU_BASE_CLKENABLE_ALL (PLLU_BASE_CLKENABLE_USB |\
4866b301a05SRhyland Klein PLLU_BASE_CLKENABLE_HSIC |\
4876b301a05SRhyland Klein PLLU_BASE_CLKENABLE_ICUSB |\
4886b301a05SRhyland Klein PLLU_BASE_CLKENABLE_48M)
4896b301a05SRhyland Klein
4906b301a05SRhyland Klein #define PLLU_MISC0_IDDQ (1 << 31)
4916b301a05SRhyland Klein #define PLLU_MISC0_LOCK_ENABLE (1 << 29)
4926b301a05SRhyland Klein #define PLLU_MISC1_LOCK_OVERRIDE (1 << 0)
4936b301a05SRhyland Klein
4946b301a05SRhyland Klein #define PLLU_MISC0_DEFAULT_VALUE 0xa0000000
4956b301a05SRhyland Klein #define PLLU_MISC1_DEFAULT_VALUE 0x0
4966b301a05SRhyland Klein
4976b301a05SRhyland Klein #define PLLU_MISC0_WRITE_MASK 0xbfffffff
4986b301a05SRhyland Klein #define PLLU_MISC1_WRITE_MASK 0x00000007
4996b301a05SRhyland Klein
tegra210_plle_hw_sequence_is_enabled(void)50054443ef6SJC Kuo bool tegra210_plle_hw_sequence_is_enabled(void)
50154443ef6SJC Kuo {
50254443ef6SJC Kuo u32 value;
50354443ef6SJC Kuo
50454443ef6SJC Kuo value = readl_relaxed(clk_base + PLLE_AUX);
50554443ef6SJC Kuo if (value & PLLE_AUX_SEQ_ENABLE)
50654443ef6SJC Kuo return true;
50754443ef6SJC Kuo
50854443ef6SJC Kuo return false;
50954443ef6SJC Kuo }
51054443ef6SJC Kuo EXPORT_SYMBOL_GPL(tegra210_plle_hw_sequence_is_enabled);
51154443ef6SJC Kuo
tegra210_plle_hw_sequence_start(void)51254443ef6SJC Kuo int tegra210_plle_hw_sequence_start(void)
51354443ef6SJC Kuo {
51454443ef6SJC Kuo u32 value;
51554443ef6SJC Kuo
51654443ef6SJC Kuo if (tegra210_plle_hw_sequence_is_enabled())
51754443ef6SJC Kuo return 0;
51854443ef6SJC Kuo
51954443ef6SJC Kuo /* skip if PLLE is not enabled yet */
52054443ef6SJC Kuo value = readl_relaxed(clk_base + PLLE_MISC0);
52154443ef6SJC Kuo if (!(value & PLLE_MISC_LOCK))
52254443ef6SJC Kuo return -EIO;
52354443ef6SJC Kuo
52454443ef6SJC Kuo value &= ~PLLE_MISC_IDDQ_SW_CTRL;
52554443ef6SJC Kuo writel_relaxed(value, clk_base + PLLE_MISC0);
52654443ef6SJC Kuo
52754443ef6SJC Kuo value = readl_relaxed(clk_base + PLLE_AUX);
52854443ef6SJC Kuo value |= (PLLE_AUX_USE_LOCKDET | PLLE_AUX_SS_SEQ_INCLUDE);
52954443ef6SJC Kuo value &= ~(PLLE_AUX_ENABLE_SWCTL | PLLE_AUX_SS_SWCTL);
53054443ef6SJC Kuo writel_relaxed(value, clk_base + PLLE_AUX);
53154443ef6SJC Kuo
53254443ef6SJC Kuo fence_udelay(1, clk_base);
53354443ef6SJC Kuo
53454443ef6SJC Kuo value |= PLLE_AUX_SEQ_ENABLE;
53554443ef6SJC Kuo writel_relaxed(value, clk_base + PLLE_AUX);
53654443ef6SJC Kuo
53754443ef6SJC Kuo fence_udelay(1, clk_base);
53854443ef6SJC Kuo
53954443ef6SJC Kuo return 0;
54054443ef6SJC Kuo }
54154443ef6SJC Kuo EXPORT_SYMBOL_GPL(tegra210_plle_hw_sequence_start);
54254443ef6SJC Kuo
tegra210_xusb_pll_hw_control_enable(void)5433358d2d9SAndrew Bresticker void tegra210_xusb_pll_hw_control_enable(void)
5443358d2d9SAndrew Bresticker {
5453358d2d9SAndrew Bresticker u32 val;
5463358d2d9SAndrew Bresticker
5473358d2d9SAndrew Bresticker val = readl_relaxed(clk_base + XUSBIO_PLL_CFG0);
5483358d2d9SAndrew Bresticker val &= ~(XUSBIO_PLL_CFG0_CLK_ENABLE_SWCTL |
5493358d2d9SAndrew Bresticker XUSBIO_PLL_CFG0_PADPLL_RESET_SWCTL);
5503358d2d9SAndrew Bresticker val |= XUSBIO_PLL_CFG0_PADPLL_USE_LOCKDET |
5513358d2d9SAndrew Bresticker XUSBIO_PLL_CFG0_PADPLL_SLEEP_IDDQ;
5523358d2d9SAndrew Bresticker writel_relaxed(val, clk_base + XUSBIO_PLL_CFG0);
5533358d2d9SAndrew Bresticker }
5543358d2d9SAndrew Bresticker EXPORT_SYMBOL_GPL(tegra210_xusb_pll_hw_control_enable);
5553358d2d9SAndrew Bresticker
tegra210_xusb_pll_hw_sequence_start(void)5563358d2d9SAndrew Bresticker void tegra210_xusb_pll_hw_sequence_start(void)
5573358d2d9SAndrew Bresticker {
5583358d2d9SAndrew Bresticker u32 val;
5593358d2d9SAndrew Bresticker
5603358d2d9SAndrew Bresticker val = readl_relaxed(clk_base + XUSBIO_PLL_CFG0);
5613358d2d9SAndrew Bresticker val |= XUSBIO_PLL_CFG0_SEQ_ENABLE;
5623358d2d9SAndrew Bresticker writel_relaxed(val, clk_base + XUSBIO_PLL_CFG0);
5633358d2d9SAndrew Bresticker }
5643358d2d9SAndrew Bresticker EXPORT_SYMBOL_GPL(tegra210_xusb_pll_hw_sequence_start);
5653358d2d9SAndrew Bresticker
tegra210_sata_pll_hw_control_enable(void)5663358d2d9SAndrew Bresticker void tegra210_sata_pll_hw_control_enable(void)
5673358d2d9SAndrew Bresticker {
5683358d2d9SAndrew Bresticker u32 val;
5693358d2d9SAndrew Bresticker
5703358d2d9SAndrew Bresticker val = readl_relaxed(clk_base + SATA_PLL_CFG0);
5713358d2d9SAndrew Bresticker val &= ~SATA_PLL_CFG0_PADPLL_RESET_SWCTL;
5723358d2d9SAndrew Bresticker val |= SATA_PLL_CFG0_PADPLL_USE_LOCKDET |
5733358d2d9SAndrew Bresticker SATA_PLL_CFG0_PADPLL_SLEEP_IDDQ;
5743358d2d9SAndrew Bresticker writel_relaxed(val, clk_base + SATA_PLL_CFG0);
5753358d2d9SAndrew Bresticker }
5763358d2d9SAndrew Bresticker EXPORT_SYMBOL_GPL(tegra210_sata_pll_hw_control_enable);
5773358d2d9SAndrew Bresticker
tegra210_sata_pll_hw_sequence_start(void)5783358d2d9SAndrew Bresticker void tegra210_sata_pll_hw_sequence_start(void)
5793358d2d9SAndrew Bresticker {
5803358d2d9SAndrew Bresticker u32 val;
5813358d2d9SAndrew Bresticker
5823358d2d9SAndrew Bresticker val = readl_relaxed(clk_base + SATA_PLL_CFG0);
5833358d2d9SAndrew Bresticker val |= SATA_PLL_CFG0_SEQ_ENABLE;
5843358d2d9SAndrew Bresticker writel_relaxed(val, clk_base + SATA_PLL_CFG0);
5853358d2d9SAndrew Bresticker }
5863358d2d9SAndrew Bresticker EXPORT_SYMBOL_GPL(tegra210_sata_pll_hw_sequence_start);
5873358d2d9SAndrew Bresticker
tegra210_set_sata_pll_seq_sw(bool state)58859af78d7SPeter De Schrijver void tegra210_set_sata_pll_seq_sw(bool state)
58959af78d7SPeter De Schrijver {
59059af78d7SPeter De Schrijver u32 val;
59159af78d7SPeter De Schrijver
59259af78d7SPeter De Schrijver val = readl_relaxed(clk_base + SATA_PLL_CFG0);
59359af78d7SPeter De Schrijver if (state) {
59459af78d7SPeter De Schrijver val |= SATA_PLL_CFG0_SATA_SEQ_IN_SWCTL;
59559af78d7SPeter De Schrijver val |= SATA_PLL_CFG0_SATA_SEQ_RESET_INPUT_VALUE;
59659af78d7SPeter De Schrijver val |= SATA_PLL_CFG0_SATA_SEQ_LANE_PD_INPUT_VALUE;
59759af78d7SPeter De Schrijver val |= SATA_PLL_CFG0_SATA_SEQ_PADPLL_PD_INPUT_VALUE;
59859af78d7SPeter De Schrijver } else {
59959af78d7SPeter De Schrijver val &= ~SATA_PLL_CFG0_SATA_SEQ_IN_SWCTL;
60059af78d7SPeter De Schrijver val &= ~SATA_PLL_CFG0_SATA_SEQ_RESET_INPUT_VALUE;
60159af78d7SPeter De Schrijver val &= ~SATA_PLL_CFG0_SATA_SEQ_LANE_PD_INPUT_VALUE;
60259af78d7SPeter De Schrijver val &= ~SATA_PLL_CFG0_SATA_SEQ_PADPLL_PD_INPUT_VALUE;
60359af78d7SPeter De Schrijver }
60459af78d7SPeter De Schrijver writel_relaxed(val, clk_base + SATA_PLL_CFG0);
60559af78d7SPeter De Schrijver }
60659af78d7SPeter De Schrijver EXPORT_SYMBOL_GPL(tegra210_set_sata_pll_seq_sw);
60759af78d7SPeter De Schrijver
tegra210_clk_emc_dll_enable(bool flag)608a3cba697SJoseph Lo void tegra210_clk_emc_dll_enable(bool flag)
609a3cba697SJoseph Lo {
610a3cba697SJoseph Lo u32 offset = flag ? CLK_RST_CONTROLLER_CLK_OUT_ENB_X_SET :
611a3cba697SJoseph Lo CLK_RST_CONTROLLER_CLK_OUT_ENB_X_CLR;
612a3cba697SJoseph Lo
613a3cba697SJoseph Lo writel_relaxed(CLK_OUT_ENB_X_CLK_ENB_EMC_DLL, clk_base + offset);
614a3cba697SJoseph Lo }
615a3cba697SJoseph Lo EXPORT_SYMBOL_GPL(tegra210_clk_emc_dll_enable);
616a3cba697SJoseph Lo
tegra210_clk_emc_dll_update_setting(u32 emc_dll_src_value)617a3cba697SJoseph Lo void tegra210_clk_emc_dll_update_setting(u32 emc_dll_src_value)
618a3cba697SJoseph Lo {
619a3cba697SJoseph Lo writel_relaxed(emc_dll_src_value, clk_base + CLK_SOURCE_EMC_DLL);
620a3cba697SJoseph Lo }
621a3cba697SJoseph Lo EXPORT_SYMBOL_GPL(tegra210_clk_emc_dll_update_setting);
622a3cba697SJoseph Lo
tegra210_clk_emc_update_setting(u32 emc_src_value)623a3cba697SJoseph Lo void tegra210_clk_emc_update_setting(u32 emc_src_value)
624a3cba697SJoseph Lo {
625a3cba697SJoseph Lo writel_relaxed(emc_src_value, clk_base + CLK_SOURCE_EMC);
626a3cba697SJoseph Lo }
627a3cba697SJoseph Lo EXPORT_SYMBOL_GPL(tegra210_clk_emc_update_setting);
628a3cba697SJoseph Lo
tegra210_generic_mbist_war(struct tegra210_domain_mbist_war * mbist)629e403d005SPeter De Schrijver static void tegra210_generic_mbist_war(struct tegra210_domain_mbist_war *mbist)
630e403d005SPeter De Schrijver {
631e403d005SPeter De Schrijver u32 val;
632e403d005SPeter De Schrijver
633e403d005SPeter De Schrijver val = readl_relaxed(clk_base + mbist->lvl2_offset);
634e403d005SPeter De Schrijver writel_relaxed(val | mbist->lvl2_mask, clk_base + mbist->lvl2_offset);
635e403d005SPeter De Schrijver fence_udelay(1, clk_base);
636e403d005SPeter De Schrijver writel_relaxed(val, clk_base + mbist->lvl2_offset);
637e403d005SPeter De Schrijver fence_udelay(1, clk_base);
638e403d005SPeter De Schrijver }
639e403d005SPeter De Schrijver
tegra210_venc_mbist_war(struct tegra210_domain_mbist_war * mbist)640e403d005SPeter De Schrijver static void tegra210_venc_mbist_war(struct tegra210_domain_mbist_war *mbist)
641e403d005SPeter De Schrijver {
642e403d005SPeter De Schrijver u32 csi_src, ovra, ovre;
643e403d005SPeter De Schrijver unsigned long flags = 0;
644e403d005SPeter De Schrijver
645e403d005SPeter De Schrijver spin_lock_irqsave(&pll_d_lock, flags);
646e403d005SPeter De Schrijver
647e403d005SPeter De Schrijver csi_src = readl_relaxed(clk_base + PLLD_BASE);
648e403d005SPeter De Schrijver writel_relaxed(csi_src | PLLD_BASE_CSI_CLKSOURCE, clk_base + PLLD_BASE);
649e403d005SPeter De Schrijver fence_udelay(1, clk_base);
650e403d005SPeter De Schrijver
651e403d005SPeter De Schrijver ovra = readl_relaxed(clk_base + LVL2_CLK_GATE_OVRA);
652e403d005SPeter De Schrijver writel_relaxed(ovra | BIT(15), clk_base + LVL2_CLK_GATE_OVRA);
653e403d005SPeter De Schrijver ovre = readl_relaxed(clk_base + LVL2_CLK_GATE_OVRE);
654e403d005SPeter De Schrijver writel_relaxed(ovre | BIT(3), clk_base + LVL2_CLK_GATE_OVRE);
655e403d005SPeter De Schrijver fence_udelay(1, clk_base);
656e403d005SPeter De Schrijver
657e403d005SPeter De Schrijver writel_relaxed(ovra, clk_base + LVL2_CLK_GATE_OVRA);
658e403d005SPeter De Schrijver writel_relaxed(ovre, clk_base + LVL2_CLK_GATE_OVRE);
659e403d005SPeter De Schrijver writel_relaxed(csi_src, clk_base + PLLD_BASE);
660e403d005SPeter De Schrijver fence_udelay(1, clk_base);
661e403d005SPeter De Schrijver
662e403d005SPeter De Schrijver spin_unlock_irqrestore(&pll_d_lock, flags);
663e403d005SPeter De Schrijver }
664e403d005SPeter De Schrijver
tegra210_disp_mbist_war(struct tegra210_domain_mbist_war * mbist)665e403d005SPeter De Schrijver static void tegra210_disp_mbist_war(struct tegra210_domain_mbist_war *mbist)
666e403d005SPeter De Schrijver {
667e403d005SPeter De Schrijver u32 ovra, dsc_top_ctrl;
668e403d005SPeter De Schrijver
669e403d005SPeter De Schrijver ovra = readl_relaxed(clk_base + LVL2_CLK_GATE_OVRA);
670e403d005SPeter De Schrijver writel_relaxed(ovra | BIT(1), clk_base + LVL2_CLK_GATE_OVRA);
671e403d005SPeter De Schrijver fence_udelay(1, clk_base);
672e403d005SPeter De Schrijver
673e403d005SPeter De Schrijver dsc_top_ctrl = readl_relaxed(dispa_base + DC_COM_DSC_TOP_CTL);
674e403d005SPeter De Schrijver writel_relaxed(dsc_top_ctrl | BIT(2), dispa_base + DC_COM_DSC_TOP_CTL);
675e403d005SPeter De Schrijver readl_relaxed(dispa_base + DC_CMD_DISPLAY_COMMAND);
676e403d005SPeter De Schrijver writel_relaxed(dsc_top_ctrl, dispa_base + DC_COM_DSC_TOP_CTL);
677e403d005SPeter De Schrijver readl_relaxed(dispa_base + DC_CMD_DISPLAY_COMMAND);
678e403d005SPeter De Schrijver
679e403d005SPeter De Schrijver writel_relaxed(ovra, clk_base + LVL2_CLK_GATE_OVRA);
680e403d005SPeter De Schrijver fence_udelay(1, clk_base);
681e403d005SPeter De Schrijver }
682e403d005SPeter De Schrijver
tegra210_vic_mbist_war(struct tegra210_domain_mbist_war * mbist)683e403d005SPeter De Schrijver static void tegra210_vic_mbist_war(struct tegra210_domain_mbist_war *mbist)
684e403d005SPeter De Schrijver {
685e403d005SPeter De Schrijver u32 ovre, val;
686e403d005SPeter De Schrijver
687e403d005SPeter De Schrijver ovre = readl_relaxed(clk_base + LVL2_CLK_GATE_OVRE);
688e403d005SPeter De Schrijver writel_relaxed(ovre | BIT(5), clk_base + LVL2_CLK_GATE_OVRE);
689e403d005SPeter De Schrijver fence_udelay(1, clk_base);
690e403d005SPeter De Schrijver
691e403d005SPeter De Schrijver val = readl_relaxed(vic_base + NV_PVIC_THI_SLCG_OVERRIDE_LOW);
692e403d005SPeter De Schrijver writel_relaxed(val | BIT(0) | GENMASK(7, 2) | BIT(24),
693e403d005SPeter De Schrijver vic_base + NV_PVIC_THI_SLCG_OVERRIDE_LOW);
694e403d005SPeter De Schrijver fence_udelay(1, vic_base + NV_PVIC_THI_SLCG_OVERRIDE_LOW);
695e403d005SPeter De Schrijver
696e403d005SPeter De Schrijver writel_relaxed(val, vic_base + NV_PVIC_THI_SLCG_OVERRIDE_LOW);
697e403d005SPeter De Schrijver readl(vic_base + NV_PVIC_THI_SLCG_OVERRIDE_LOW);
698e403d005SPeter De Schrijver
699e403d005SPeter De Schrijver writel_relaxed(ovre, clk_base + LVL2_CLK_GATE_OVRE);
700e403d005SPeter De Schrijver fence_udelay(1, clk_base);
701e403d005SPeter De Schrijver }
702e403d005SPeter De Schrijver
tegra210_ape_mbist_war(struct tegra210_domain_mbist_war * mbist)703e403d005SPeter De Schrijver static void tegra210_ape_mbist_war(struct tegra210_domain_mbist_war *mbist)
704e403d005SPeter De Schrijver {
705e403d005SPeter De Schrijver void __iomem *i2s_base;
706e403d005SPeter De Schrijver unsigned int i;
707e403d005SPeter De Schrijver u32 ovrc, ovre;
708e403d005SPeter De Schrijver
709e403d005SPeter De Schrijver ovrc = readl_relaxed(clk_base + LVL2_CLK_GATE_OVRC);
710e403d005SPeter De Schrijver ovre = readl_relaxed(clk_base + LVL2_CLK_GATE_OVRE);
711e403d005SPeter De Schrijver writel_relaxed(ovrc | BIT(1), clk_base + LVL2_CLK_GATE_OVRC);
712e403d005SPeter De Schrijver writel_relaxed(ovre | BIT(10) | BIT(11),
713e403d005SPeter De Schrijver clk_base + LVL2_CLK_GATE_OVRE);
714e403d005SPeter De Schrijver fence_udelay(1, clk_base);
715e403d005SPeter De Schrijver
716e403d005SPeter De Schrijver i2s_base = ahub_base + TEGRA210_I2S_BASE;
717e403d005SPeter De Schrijver
718e403d005SPeter De Schrijver for (i = 0; i < TEGRA210_I2S_CTRLS; i++) {
719e403d005SPeter De Schrijver u32 i2s_ctrl;
720e403d005SPeter De Schrijver
721e403d005SPeter De Schrijver i2s_ctrl = readl_relaxed(i2s_base + TEGRA210_I2S_CTRL);
722e403d005SPeter De Schrijver writel_relaxed(i2s_ctrl | BIT(10),
723e403d005SPeter De Schrijver i2s_base + TEGRA210_I2S_CTRL);
724e403d005SPeter De Schrijver writel_relaxed(0, i2s_base + TEGRA210_I2S_CG);
725e403d005SPeter De Schrijver readl(i2s_base + TEGRA210_I2S_CG);
726e403d005SPeter De Schrijver writel_relaxed(1, i2s_base + TEGRA210_I2S_CG);
727e403d005SPeter De Schrijver writel_relaxed(i2s_ctrl, i2s_base + TEGRA210_I2S_CTRL);
728e403d005SPeter De Schrijver readl(i2s_base + TEGRA210_I2S_CTRL);
729e403d005SPeter De Schrijver
730e403d005SPeter De Schrijver i2s_base += TEGRA210_I2S_SIZE;
731e403d005SPeter De Schrijver }
732e403d005SPeter De Schrijver
733e403d005SPeter De Schrijver writel_relaxed(ovrc, clk_base + LVL2_CLK_GATE_OVRC);
734e403d005SPeter De Schrijver writel_relaxed(ovre, clk_base + LVL2_CLK_GATE_OVRE);
735e403d005SPeter De Schrijver fence_udelay(1, clk_base);
736e403d005SPeter De Schrijver }
737e403d005SPeter De Schrijver
_pll_misc_chk_default(void __iomem * base,struct tegra_clk_pll_params * params,u8 misc_num,u32 default_val,u32 mask)7386b301a05SRhyland Klein static inline void _pll_misc_chk_default(void __iomem *base,
7396b301a05SRhyland Klein struct tegra_clk_pll_params *params,
7406b301a05SRhyland Klein u8 misc_num, u32 default_val, u32 mask)
7416b301a05SRhyland Klein {
7426b301a05SRhyland Klein u32 boot_val = readl_relaxed(base + params->ext_misc_reg[misc_num]);
7436b301a05SRhyland Klein
7446b301a05SRhyland Klein boot_val &= mask;
7456b301a05SRhyland Klein default_val &= mask;
7466b301a05SRhyland Klein if (boot_val != default_val) {
7476b301a05SRhyland Klein pr_warn("boot misc%d 0x%x: expected 0x%x\n",
7486b301a05SRhyland Klein misc_num, boot_val, default_val);
7496b301a05SRhyland Klein pr_warn(" (comparison mask = 0x%x)\n", mask);
7506b301a05SRhyland Klein params->defaults_set = false;
7516b301a05SRhyland Klein }
7526b301a05SRhyland Klein }
7536b301a05SRhyland Klein
7546b301a05SRhyland Klein /*
7556b301a05SRhyland Klein * PLLCX: PLLC, PLLC2, PLLC3, PLLA1
7566b301a05SRhyland Klein * Hybrid PLLs with dynamic ramp. Dynamic ramp is allowed for any transition
7576b301a05SRhyland Klein * that changes NDIV only, while PLL is already locked.
7586b301a05SRhyland Klein */
pllcx_check_defaults(struct tegra_clk_pll_params * params)7596b301a05SRhyland Klein static void pllcx_check_defaults(struct tegra_clk_pll_params *params)
7606b301a05SRhyland Klein {
7616b301a05SRhyland Klein u32 default_val;
7626b301a05SRhyland Klein
7636b301a05SRhyland Klein default_val = PLLCX_MISC0_DEFAULT_VALUE & (~PLLCX_MISC0_RESET);
7646b301a05SRhyland Klein _pll_misc_chk_default(clk_base, params, 0, default_val,
7656b301a05SRhyland Klein PLLCX_MISC0_WRITE_MASK);
7666b301a05SRhyland Klein
7676b301a05SRhyland Klein default_val = PLLCX_MISC1_DEFAULT_VALUE & (~PLLCX_MISC1_IDDQ);
7686b301a05SRhyland Klein _pll_misc_chk_default(clk_base, params, 1, default_val,
7696b301a05SRhyland Klein PLLCX_MISC1_WRITE_MASK);
7706b301a05SRhyland Klein
7716b301a05SRhyland Klein default_val = PLLCX_MISC2_DEFAULT_VALUE;
7726b301a05SRhyland Klein _pll_misc_chk_default(clk_base, params, 2, default_val,
7736b301a05SRhyland Klein PLLCX_MISC2_WRITE_MASK);
7746b301a05SRhyland Klein
7756b301a05SRhyland Klein default_val = PLLCX_MISC3_DEFAULT_VALUE;
7766b301a05SRhyland Klein _pll_misc_chk_default(clk_base, params, 3, default_val,
7776b301a05SRhyland Klein PLLCX_MISC3_WRITE_MASK);
7786b301a05SRhyland Klein }
7796b301a05SRhyland Klein
tegra210_pllcx_set_defaults(const char * name,struct tegra_clk_pll * pllcx)780fd360e20SJon Hunter static void tegra210_pllcx_set_defaults(const char *name,
781fd360e20SJon Hunter struct tegra_clk_pll *pllcx)
7826b301a05SRhyland Klein {
7836b301a05SRhyland Klein pllcx->params->defaults_set = true;
7846b301a05SRhyland Klein
7851116d5a7SJon Hunter if (readl_relaxed(clk_base + pllcx->params->base_reg) & PLL_ENABLE) {
7866b301a05SRhyland Klein /* PLL is ON: only check if defaults already set */
7876b301a05SRhyland Klein pllcx_check_defaults(pllcx->params);
7881116d5a7SJon Hunter if (!pllcx->params->defaults_set)
7896b301a05SRhyland Klein pr_warn("%s already enabled. Postponing set full defaults\n",
7906b301a05SRhyland Klein name);
7916b301a05SRhyland Klein return;
7926b301a05SRhyland Klein }
7936b301a05SRhyland Klein
7946b301a05SRhyland Klein /* Defaults assert PLL reset, and set IDDQ */
7956b301a05SRhyland Klein writel_relaxed(PLLCX_MISC0_DEFAULT_VALUE,
7966b301a05SRhyland Klein clk_base + pllcx->params->ext_misc_reg[0]);
7976b301a05SRhyland Klein writel_relaxed(PLLCX_MISC1_DEFAULT_VALUE,
7986b301a05SRhyland Klein clk_base + pllcx->params->ext_misc_reg[1]);
7996b301a05SRhyland Klein writel_relaxed(PLLCX_MISC2_DEFAULT_VALUE,
8006b301a05SRhyland Klein clk_base + pllcx->params->ext_misc_reg[2]);
8016b301a05SRhyland Klein writel_relaxed(PLLCX_MISC3_DEFAULT_VALUE,
8026b301a05SRhyland Klein clk_base + pllcx->params->ext_misc_reg[3]);
8036b301a05SRhyland Klein udelay(1);
8046b301a05SRhyland Klein }
8056b301a05SRhyland Klein
_pllc_set_defaults(struct tegra_clk_pll * pllcx)806fd360e20SJon Hunter static void _pllc_set_defaults(struct tegra_clk_pll *pllcx)
8076b301a05SRhyland Klein {
8086b301a05SRhyland Klein tegra210_pllcx_set_defaults("PLL_C", pllcx);
8096b301a05SRhyland Klein }
8106b301a05SRhyland Klein
_pllc2_set_defaults(struct tegra_clk_pll * pllcx)811fd360e20SJon Hunter static void _pllc2_set_defaults(struct tegra_clk_pll *pllcx)
8126b301a05SRhyland Klein {
8136b301a05SRhyland Klein tegra210_pllcx_set_defaults("PLL_C2", pllcx);
8146b301a05SRhyland Klein }
8156b301a05SRhyland Klein
_pllc3_set_defaults(struct tegra_clk_pll * pllcx)816fd360e20SJon Hunter static void _pllc3_set_defaults(struct tegra_clk_pll *pllcx)
8176b301a05SRhyland Klein {
8186b301a05SRhyland Klein tegra210_pllcx_set_defaults("PLL_C3", pllcx);
8196b301a05SRhyland Klein }
8206b301a05SRhyland Klein
_plla1_set_defaults(struct tegra_clk_pll * pllcx)821fd360e20SJon Hunter static void _plla1_set_defaults(struct tegra_clk_pll *pllcx)
8226b301a05SRhyland Klein {
8236b301a05SRhyland Klein tegra210_pllcx_set_defaults("PLL_A1", pllcx);
8246b301a05SRhyland Klein }
8256b301a05SRhyland Klein
8266b301a05SRhyland Klein /*
8276b301a05SRhyland Klein * PLLA
8286b301a05SRhyland Klein * PLL with dynamic ramp and fractional SDM. Dynamic ramp is not used.
8296b301a05SRhyland Klein * Fractional SDM is allowed to provide exact audio rates.
8306b301a05SRhyland Klein */
tegra210_plla_set_defaults(struct tegra_clk_pll * plla)831fd360e20SJon Hunter static void tegra210_plla_set_defaults(struct tegra_clk_pll *plla)
8326b301a05SRhyland Klein {
8336b301a05SRhyland Klein u32 mask;
8346b301a05SRhyland Klein u32 val = readl_relaxed(clk_base + plla->params->base_reg);
8356b301a05SRhyland Klein
8366b301a05SRhyland Klein plla->params->defaults_set = true;
8376b301a05SRhyland Klein
8386b301a05SRhyland Klein if (val & PLL_ENABLE) {
8396b301a05SRhyland Klein /*
8406b301a05SRhyland Klein * PLL is ON: check if defaults already set, then set those
8416b301a05SRhyland Klein * that can be updated in flight.
8426b301a05SRhyland Klein */
8436b301a05SRhyland Klein if (val & PLLA_BASE_IDDQ) {
8446b301a05SRhyland Klein pr_warn("PLL_A boot enabled with IDDQ set\n");
8456b301a05SRhyland Klein plla->params->defaults_set = false;
8466b301a05SRhyland Klein }
8476b301a05SRhyland Klein
8486b301a05SRhyland Klein pr_warn("PLL_A already enabled. Postponing set full defaults\n");
8496b301a05SRhyland Klein
8506b301a05SRhyland Klein val = PLLA_MISC0_DEFAULT_VALUE; /* ignore lock enable */
8516b301a05SRhyland Klein mask = PLLA_MISC0_LOCK_ENABLE | PLLA_MISC0_LOCK_OVERRIDE;
8526b301a05SRhyland Klein _pll_misc_chk_default(clk_base, plla->params, 0, val,
8536b301a05SRhyland Klein ~mask & PLLA_MISC0_WRITE_MASK);
8546b301a05SRhyland Klein
8556b301a05SRhyland Klein val = PLLA_MISC2_DEFAULT_VALUE; /* ignore all but control bit */
8566b301a05SRhyland Klein _pll_misc_chk_default(clk_base, plla->params, 2, val,
8576b301a05SRhyland Klein PLLA_MISC2_EN_DYNRAMP);
8586b301a05SRhyland Klein
8596b301a05SRhyland Klein /* Enable lock detect */
8606b301a05SRhyland Klein val = readl_relaxed(clk_base + plla->params->ext_misc_reg[0]);
8616b301a05SRhyland Klein val &= ~mask;
8626b301a05SRhyland Klein val |= PLLA_MISC0_DEFAULT_VALUE & mask;
8636b301a05SRhyland Klein writel_relaxed(val, clk_base + plla->params->ext_misc_reg[0]);
8646b301a05SRhyland Klein udelay(1);
8656b301a05SRhyland Klein
8666b301a05SRhyland Klein return;
8676b301a05SRhyland Klein }
8686b301a05SRhyland Klein
8696b301a05SRhyland Klein /* set IDDQ, enable lock detect, disable dynamic ramp and SDM */
8706b301a05SRhyland Klein val |= PLLA_BASE_IDDQ;
8716b301a05SRhyland Klein writel_relaxed(val, clk_base + plla->params->base_reg);
8726b301a05SRhyland Klein writel_relaxed(PLLA_MISC0_DEFAULT_VALUE,
8736b301a05SRhyland Klein clk_base + plla->params->ext_misc_reg[0]);
8746b301a05SRhyland Klein writel_relaxed(PLLA_MISC2_DEFAULT_VALUE,
8756b301a05SRhyland Klein clk_base + plla->params->ext_misc_reg[2]);
8766b301a05SRhyland Klein udelay(1);
8776b301a05SRhyland Klein }
8786b301a05SRhyland Klein
8796b301a05SRhyland Klein /*
8806b301a05SRhyland Klein * PLLD
8816b301a05SRhyland Klein * PLL with fractional SDM.
8826b301a05SRhyland Klein */
tegra210_plld_set_defaults(struct tegra_clk_pll * plld)883fd360e20SJon Hunter static void tegra210_plld_set_defaults(struct tegra_clk_pll *plld)
8846b301a05SRhyland Klein {
8856b301a05SRhyland Klein u32 val;
8866b301a05SRhyland Klein u32 mask = 0xffff;
8876b301a05SRhyland Klein
8886b301a05SRhyland Klein plld->params->defaults_set = true;
8896b301a05SRhyland Klein
8906b301a05SRhyland Klein if (readl_relaxed(clk_base + plld->params->base_reg) &
8916b301a05SRhyland Klein PLL_ENABLE) {
8926b301a05SRhyland Klein
8936b301a05SRhyland Klein /*
8946b301a05SRhyland Klein * PLL is ON: check if defaults already set, then set those
8956b301a05SRhyland Klein * that can be updated in flight.
8966b301a05SRhyland Klein */
8976b301a05SRhyland Klein val = PLLD_MISC1_DEFAULT_VALUE;
8986b301a05SRhyland Klein _pll_misc_chk_default(clk_base, plld->params, 1,
8996b301a05SRhyland Klein val, PLLD_MISC1_WRITE_MASK);
9006b301a05SRhyland Klein
9016b301a05SRhyland Klein /* ignore lock, DSI and SDM controls, make sure IDDQ not set */
9026b301a05SRhyland Klein val = PLLD_MISC0_DEFAULT_VALUE & (~PLLD_MISC0_IDDQ);
9036b301a05SRhyland Klein mask |= PLLD_MISC0_DSI_CLKENABLE | PLLD_MISC0_LOCK_ENABLE |
9046b301a05SRhyland Klein PLLD_MISC0_LOCK_OVERRIDE | PLLD_MISC0_EN_SDM;
9056b301a05SRhyland Klein _pll_misc_chk_default(clk_base, plld->params, 0, val,
9066b301a05SRhyland Klein ~mask & PLLD_MISC0_WRITE_MASK);
9076b301a05SRhyland Klein
9088dce89a1SPeter De Schrijver if (!plld->params->defaults_set)
9098dce89a1SPeter De Schrijver pr_warn("PLL_D already enabled. Postponing set full defaults\n");
9108dce89a1SPeter De Schrijver
9116b301a05SRhyland Klein /* Enable lock detect */
9126b301a05SRhyland Klein mask = PLLD_MISC0_LOCK_ENABLE | PLLD_MISC0_LOCK_OVERRIDE;
9136b301a05SRhyland Klein val = readl_relaxed(clk_base + plld->params->ext_misc_reg[0]);
9146b301a05SRhyland Klein val &= ~mask;
9156b301a05SRhyland Klein val |= PLLD_MISC0_DEFAULT_VALUE & mask;
9166b301a05SRhyland Klein writel_relaxed(val, clk_base + plld->params->ext_misc_reg[0]);
9176b301a05SRhyland Klein udelay(1);
9186b301a05SRhyland Klein
9196b301a05SRhyland Klein return;
9206b301a05SRhyland Klein }
9216b301a05SRhyland Klein
9226b301a05SRhyland Klein val = readl_relaxed(clk_base + plld->params->ext_misc_reg[0]);
9236b301a05SRhyland Klein val &= PLLD_MISC0_DSI_CLKENABLE;
9246b301a05SRhyland Klein val |= PLLD_MISC0_DEFAULT_VALUE;
9256b301a05SRhyland Klein /* set IDDQ, enable lock detect, disable SDM */
9266b301a05SRhyland Klein writel_relaxed(val, clk_base + plld->params->ext_misc_reg[0]);
9276b301a05SRhyland Klein writel_relaxed(PLLD_MISC1_DEFAULT_VALUE, clk_base +
9286b301a05SRhyland Klein plld->params->ext_misc_reg[1]);
9296b301a05SRhyland Klein udelay(1);
9306b301a05SRhyland Klein }
9316b301a05SRhyland Klein
9326b301a05SRhyland Klein /*
9336b301a05SRhyland Klein * PLLD2, PLLDP
9346b301a05SRhyland Klein * PLL with fractional SDM and Spread Spectrum (SDM is a must if SSC is used).
9356b301a05SRhyland Klein */
plldss_defaults(const char * pll_name,struct tegra_clk_pll * plldss,u32 misc0_val,u32 misc1_val,u32 misc2_val,u32 misc3_val)9366b301a05SRhyland Klein static void plldss_defaults(const char *pll_name, struct tegra_clk_pll *plldss,
9376b301a05SRhyland Klein u32 misc0_val, u32 misc1_val, u32 misc2_val, u32 misc3_val)
9386b301a05SRhyland Klein {
9396b301a05SRhyland Klein u32 default_val;
9406b301a05SRhyland Klein u32 val = readl_relaxed(clk_base + plldss->params->base_reg);
9416b301a05SRhyland Klein
9426b301a05SRhyland Klein plldss->params->defaults_set = true;
9436b301a05SRhyland Klein
9446b301a05SRhyland Klein if (val & PLL_ENABLE) {
9456b301a05SRhyland Klein
9466b301a05SRhyland Klein /*
9476b301a05SRhyland Klein * PLL is ON: check if defaults already set, then set those
9486b301a05SRhyland Klein * that can be updated in flight.
9496b301a05SRhyland Klein */
9506b301a05SRhyland Klein if (val & PLLDSS_BASE_IDDQ) {
9516b301a05SRhyland Klein pr_warn("plldss boot enabled with IDDQ set\n");
9526b301a05SRhyland Klein plldss->params->defaults_set = false;
9536b301a05SRhyland Klein }
9546b301a05SRhyland Klein
9556b301a05SRhyland Klein /* ignore lock enable */
9566b301a05SRhyland Klein default_val = misc0_val;
9576b301a05SRhyland Klein _pll_misc_chk_default(clk_base, plldss->params, 0, default_val,
9586b301a05SRhyland Klein PLLDSS_MISC0_WRITE_MASK &
9596b301a05SRhyland Klein (~PLLDSS_MISC0_LOCK_ENABLE));
9606b301a05SRhyland Klein
9616b301a05SRhyland Klein /*
9626b301a05SRhyland Klein * If SSC is used, check all settings, otherwise just confirm
9636b301a05SRhyland Klein * that SSC is not used on boot as well. Do nothing when using
9646b301a05SRhyland Klein * this function for PLLC4 that has only MISC0.
9656b301a05SRhyland Klein */
9666b301a05SRhyland Klein if (plldss->params->ssc_ctrl_en_mask) {
9676b301a05SRhyland Klein default_val = misc1_val;
9686b301a05SRhyland Klein _pll_misc_chk_default(clk_base, plldss->params, 1,
9696b301a05SRhyland Klein default_val, PLLDSS_MISC1_CFG_WRITE_MASK);
9706b301a05SRhyland Klein default_val = misc2_val;
9716b301a05SRhyland Klein _pll_misc_chk_default(clk_base, plldss->params, 2,
9726b301a05SRhyland Klein default_val, PLLDSS_MISC2_CTRL1_WRITE_MASK);
9736b301a05SRhyland Klein default_val = misc3_val;
9746b301a05SRhyland Klein _pll_misc_chk_default(clk_base, plldss->params, 3,
9756b301a05SRhyland Klein default_val, PLLDSS_MISC3_CTRL2_WRITE_MASK);
9766b301a05SRhyland Klein } else if (plldss->params->ext_misc_reg[1]) {
9776b301a05SRhyland Klein default_val = misc1_val;
9786b301a05SRhyland Klein _pll_misc_chk_default(clk_base, plldss->params, 1,
9796b301a05SRhyland Klein default_val, PLLDSS_MISC1_CFG_WRITE_MASK &
9806b301a05SRhyland Klein (~PLLDSS_MISC1_CFG_EN_SDM));
9816b301a05SRhyland Klein }
9826b301a05SRhyland Klein
9831934ffd0SPeter De Schrijver if (!plldss->params->defaults_set)
9841934ffd0SPeter De Schrijver pr_warn("%s already enabled. Postponing set full defaults\n",
9851934ffd0SPeter De Schrijver pll_name);
9861934ffd0SPeter De Schrijver
9876b301a05SRhyland Klein /* Enable lock detect */
9886b301a05SRhyland Klein if (val & PLLDSS_BASE_LOCK_OVERRIDE) {
9896b301a05SRhyland Klein val &= ~PLLDSS_BASE_LOCK_OVERRIDE;
9906b301a05SRhyland Klein writel_relaxed(val, clk_base +
9916b301a05SRhyland Klein plldss->params->base_reg);
9926b301a05SRhyland Klein }
9936b301a05SRhyland Klein
9946b301a05SRhyland Klein val = readl_relaxed(clk_base + plldss->params->ext_misc_reg[0]);
9956b301a05SRhyland Klein val &= ~PLLDSS_MISC0_LOCK_ENABLE;
9966b301a05SRhyland Klein val |= misc0_val & PLLDSS_MISC0_LOCK_ENABLE;
9976b301a05SRhyland Klein writel_relaxed(val, clk_base + plldss->params->ext_misc_reg[0]);
9986b301a05SRhyland Klein udelay(1);
9996b301a05SRhyland Klein
10006b301a05SRhyland Klein return;
10016b301a05SRhyland Klein }
10026b301a05SRhyland Klein
10036b301a05SRhyland Klein /* set IDDQ, enable lock detect, configure SDM/SSC */
10046b301a05SRhyland Klein val |= PLLDSS_BASE_IDDQ;
10056b301a05SRhyland Klein val &= ~PLLDSS_BASE_LOCK_OVERRIDE;
10066b301a05SRhyland Klein writel_relaxed(val, clk_base + plldss->params->base_reg);
10076b301a05SRhyland Klein
10086b301a05SRhyland Klein /* When using this function for PLLC4 exit here */
10096b301a05SRhyland Klein if (!plldss->params->ext_misc_reg[1]) {
10106b301a05SRhyland Klein writel_relaxed(misc0_val, clk_base +
10116b301a05SRhyland Klein plldss->params->ext_misc_reg[0]);
10126b301a05SRhyland Klein udelay(1);
10136b301a05SRhyland Klein return;
10146b301a05SRhyland Klein }
10156b301a05SRhyland Klein
10166b301a05SRhyland Klein writel_relaxed(misc0_val, clk_base +
10176b301a05SRhyland Klein plldss->params->ext_misc_reg[0]);
10186b301a05SRhyland Klein /* if SSC used set by 1st enable */
10196b301a05SRhyland Klein writel_relaxed(misc1_val & (~PLLDSS_MISC1_CFG_EN_SSC),
10206b301a05SRhyland Klein clk_base + plldss->params->ext_misc_reg[1]);
10216b301a05SRhyland Klein writel_relaxed(misc2_val, clk_base + plldss->params->ext_misc_reg[2]);
10226b301a05SRhyland Klein writel_relaxed(misc3_val, clk_base + plldss->params->ext_misc_reg[3]);
10236b301a05SRhyland Klein udelay(1);
10246b301a05SRhyland Klein }
10256b301a05SRhyland Klein
tegra210_plld2_set_defaults(struct tegra_clk_pll * plld2)1026fd360e20SJon Hunter static void tegra210_plld2_set_defaults(struct tegra_clk_pll *plld2)
10276b301a05SRhyland Klein {
10286b301a05SRhyland Klein plldss_defaults("PLL_D2", plld2, PLLD2_MISC0_DEFAULT_VALUE,
10296b301a05SRhyland Klein PLLD2_MISC1_CFG_DEFAULT_VALUE,
10306b301a05SRhyland Klein PLLD2_MISC2_CTRL1_DEFAULT_VALUE,
10316b301a05SRhyland Klein PLLD2_MISC3_CTRL2_DEFAULT_VALUE);
10326b301a05SRhyland Klein }
10336b301a05SRhyland Klein
tegra210_plldp_set_defaults(struct tegra_clk_pll * plldp)1034fd360e20SJon Hunter static void tegra210_plldp_set_defaults(struct tegra_clk_pll *plldp)
10356b301a05SRhyland Klein {
10366b301a05SRhyland Klein plldss_defaults("PLL_DP", plldp, PLLDP_MISC0_DEFAULT_VALUE,
10376b301a05SRhyland Klein PLLDP_MISC1_CFG_DEFAULT_VALUE,
10386b301a05SRhyland Klein PLLDP_MISC2_CTRL1_DEFAULT_VALUE,
10396b301a05SRhyland Klein PLLDP_MISC3_CTRL2_DEFAULT_VALUE);
10406b301a05SRhyland Klein }
10416b301a05SRhyland Klein
10426b301a05SRhyland Klein /*
10436b301a05SRhyland Klein * PLLC4
10446b301a05SRhyland Klein * Base and misc0 layout is the same as PLLD2/PLLDP, but no SDM/SSC support.
10456b301a05SRhyland Klein * VCO is exposed to the clock tree via fixed 1/3 and 1/5 dividers.
10466b301a05SRhyland Klein */
tegra210_pllc4_set_defaults(struct tegra_clk_pll * pllc4)1047fd360e20SJon Hunter static void tegra210_pllc4_set_defaults(struct tegra_clk_pll *pllc4)
10486b301a05SRhyland Klein {
10496b301a05SRhyland Klein plldss_defaults("PLL_C4", pllc4, PLLC4_MISC0_DEFAULT_VALUE, 0, 0, 0);
10506b301a05SRhyland Klein }
10516b301a05SRhyland Klein
10526b301a05SRhyland Klein /*
10536b301a05SRhyland Klein * PLLRE
10546b301a05SRhyland Klein * VCO is exposed to the clock tree directly along with post-divider output
10556b301a05SRhyland Klein */
tegra210_pllre_set_defaults(struct tegra_clk_pll * pllre)1056fd360e20SJon Hunter static void tegra210_pllre_set_defaults(struct tegra_clk_pll *pllre)
10576b301a05SRhyland Klein {
10586b301a05SRhyland Klein u32 mask;
10596b301a05SRhyland Klein u32 val = readl_relaxed(clk_base + pllre->params->base_reg);
10606b301a05SRhyland Klein
10616b301a05SRhyland Klein pllre->params->defaults_set = true;
10626b301a05SRhyland Klein
10636b301a05SRhyland Klein if (val & PLL_ENABLE) {
10646b301a05SRhyland Klein /*
10656b301a05SRhyland Klein * PLL is ON: check if defaults already set, then set those
10666b301a05SRhyland Klein * that can be updated in flight.
10676b301a05SRhyland Klein */
10686b301a05SRhyland Klein val &= PLLRE_BASE_DEFAULT_MASK;
10696b301a05SRhyland Klein if (val != PLLRE_BASE_DEFAULT_VALUE) {
10706b301a05SRhyland Klein pr_warn("pllre boot base 0x%x : expected 0x%x\n",
10716b301a05SRhyland Klein val, PLLRE_BASE_DEFAULT_VALUE);
10726b301a05SRhyland Klein pr_warn("(comparison mask = 0x%x)\n",
10736b301a05SRhyland Klein PLLRE_BASE_DEFAULT_MASK);
10746b301a05SRhyland Klein pllre->params->defaults_set = false;
10756b301a05SRhyland Klein }
10766b301a05SRhyland Klein
10776b301a05SRhyland Klein /* Ignore lock enable */
10786b301a05SRhyland Klein val = PLLRE_MISC0_DEFAULT_VALUE & (~PLLRE_MISC0_IDDQ);
10796b301a05SRhyland Klein mask = PLLRE_MISC0_LOCK_ENABLE | PLLRE_MISC0_LOCK_OVERRIDE;
10806b301a05SRhyland Klein _pll_misc_chk_default(clk_base, pllre->params, 0, val,
10816b301a05SRhyland Klein ~mask & PLLRE_MISC0_WRITE_MASK);
10826b301a05SRhyland Klein
1083c1139d20SThierry Reding /* The PLL doesn't work if it's in IDDQ. */
10846b301a05SRhyland Klein val = readl_relaxed(clk_base + pllre->params->ext_misc_reg[0]);
1085c1139d20SThierry Reding if (val & PLLRE_MISC0_IDDQ)
1086c1139d20SThierry Reding pr_warn("unexpected IDDQ bit set for enabled clock\n");
1087c1139d20SThierry Reding
1088c1139d20SThierry Reding /* Enable lock detect */
10896b301a05SRhyland Klein val &= ~mask;
10906b301a05SRhyland Klein val |= PLLRE_MISC0_DEFAULT_VALUE & mask;
10916b301a05SRhyland Klein writel_relaxed(val, clk_base + pllre->params->ext_misc_reg[0]);
10926b301a05SRhyland Klein udelay(1);
10936b301a05SRhyland Klein
109420675070SThierry Reding if (!pllre->params->defaults_set)
109520675070SThierry Reding pr_warn("PLL_RE already enabled. Postponing set full defaults\n");
109620675070SThierry Reding
10976b301a05SRhyland Klein return;
10986b301a05SRhyland Klein }
10996b301a05SRhyland Klein
11006b301a05SRhyland Klein /* set IDDQ, enable lock detect */
11016b301a05SRhyland Klein val &= ~PLLRE_BASE_DEFAULT_MASK;
11026b301a05SRhyland Klein val |= PLLRE_BASE_DEFAULT_VALUE & PLLRE_BASE_DEFAULT_MASK;
11036b301a05SRhyland Klein writel_relaxed(val, clk_base + pllre->params->base_reg);
11046b301a05SRhyland Klein writel_relaxed(PLLRE_MISC0_DEFAULT_VALUE,
11056b301a05SRhyland Klein clk_base + pllre->params->ext_misc_reg[0]);
11066b301a05SRhyland Klein udelay(1);
11076b301a05SRhyland Klein }
11086b301a05SRhyland Klein
pllx_get_dyn_steps(struct clk_hw * hw,u32 * step_a,u32 * step_b)11096b301a05SRhyland Klein static void pllx_get_dyn_steps(struct clk_hw *hw, u32 *step_a, u32 *step_b)
11106b301a05SRhyland Klein {
11116b301a05SRhyland Klein unsigned long input_rate;
11126b301a05SRhyland Klein
11136b301a05SRhyland Klein /* cf rate */
11143dad5c5fSRhyland Klein if (!IS_ERR_OR_NULL(hw->clk))
11153dad5c5fSRhyland Klein input_rate = clk_hw_get_rate(clk_hw_get_parent(hw));
11163dad5c5fSRhyland Klein else
11176b301a05SRhyland Klein input_rate = 38400000;
11183dad5c5fSRhyland Klein
11193dad5c5fSRhyland Klein input_rate /= tegra_pll_get_fixed_mdiv(hw, input_rate);
11206b301a05SRhyland Klein
11216b301a05SRhyland Klein switch (input_rate) {
11226b301a05SRhyland Klein case 12000000:
11236b301a05SRhyland Klein case 12800000:
11246b301a05SRhyland Klein case 13000000:
11256b301a05SRhyland Klein *step_a = 0x2B;
11266b301a05SRhyland Klein *step_b = 0x0B;
11276b301a05SRhyland Klein return;
11286b301a05SRhyland Klein case 19200000:
11296b301a05SRhyland Klein *step_a = 0x12;
11306b301a05SRhyland Klein *step_b = 0x08;
11316b301a05SRhyland Klein return;
11326b301a05SRhyland Klein case 38400000:
11336b301a05SRhyland Klein *step_a = 0x04;
11346b301a05SRhyland Klein *step_b = 0x05;
11356b301a05SRhyland Klein return;
11366b301a05SRhyland Klein default:
11376b301a05SRhyland Klein pr_err("%s: Unexpected reference rate %lu\n",
11386b301a05SRhyland Klein __func__, input_rate);
11396b301a05SRhyland Klein BUG();
11406b301a05SRhyland Klein }
11416b301a05SRhyland Klein }
11426b301a05SRhyland Klein
pllx_check_defaults(struct tegra_clk_pll * pll)11436b301a05SRhyland Klein static void pllx_check_defaults(struct tegra_clk_pll *pll)
11446b301a05SRhyland Klein {
11456b301a05SRhyland Klein u32 default_val;
11466b301a05SRhyland Klein
11476b301a05SRhyland Klein default_val = PLLX_MISC0_DEFAULT_VALUE;
11486b301a05SRhyland Klein /* ignore lock enable */
11496b301a05SRhyland Klein _pll_misc_chk_default(clk_base, pll->params, 0, default_val,
11506b301a05SRhyland Klein PLLX_MISC0_WRITE_MASK & (~PLLX_MISC0_LOCK_ENABLE));
11516b301a05SRhyland Klein
11526b301a05SRhyland Klein default_val = PLLX_MISC1_DEFAULT_VALUE;
11536b301a05SRhyland Klein _pll_misc_chk_default(clk_base, pll->params, 1, default_val,
11546b301a05SRhyland Klein PLLX_MISC1_WRITE_MASK);
11556b301a05SRhyland Klein
11566b301a05SRhyland Klein /* ignore all but control bit */
11576b301a05SRhyland Klein default_val = PLLX_MISC2_DEFAULT_VALUE;
11586b301a05SRhyland Klein _pll_misc_chk_default(clk_base, pll->params, 2,
11596b301a05SRhyland Klein default_val, PLLX_MISC2_EN_DYNRAMP);
11606b301a05SRhyland Klein
11616b301a05SRhyland Klein default_val = PLLX_MISC3_DEFAULT_VALUE & (~PLLX_MISC3_IDDQ);
11626b301a05SRhyland Klein _pll_misc_chk_default(clk_base, pll->params, 3, default_val,
11636b301a05SRhyland Klein PLLX_MISC3_WRITE_MASK);
11646b301a05SRhyland Klein
11656b301a05SRhyland Klein default_val = PLLX_MISC4_DEFAULT_VALUE;
11666b301a05SRhyland Klein _pll_misc_chk_default(clk_base, pll->params, 4, default_val,
11676b301a05SRhyland Klein PLLX_MISC4_WRITE_MASK);
11686b301a05SRhyland Klein
11696b301a05SRhyland Klein default_val = PLLX_MISC5_DEFAULT_VALUE;
11706b301a05SRhyland Klein _pll_misc_chk_default(clk_base, pll->params, 5, default_val,
11716b301a05SRhyland Klein PLLX_MISC5_WRITE_MASK);
11726b301a05SRhyland Klein }
11736b301a05SRhyland Klein
tegra210_pllx_set_defaults(struct tegra_clk_pll * pllx)1174fd360e20SJon Hunter static void tegra210_pllx_set_defaults(struct tegra_clk_pll *pllx)
11756b301a05SRhyland Klein {
11766b301a05SRhyland Klein u32 val;
11776b301a05SRhyland Klein u32 step_a, step_b;
11786b301a05SRhyland Klein
11796b301a05SRhyland Klein pllx->params->defaults_set = true;
11806b301a05SRhyland Klein
11816b301a05SRhyland Klein /* Get ready dyn ramp state machine settings */
11826b301a05SRhyland Klein pllx_get_dyn_steps(&pllx->hw, &step_a, &step_b);
11836b301a05SRhyland Klein val = PLLX_MISC2_DEFAULT_VALUE & (~PLLX_MISC2_DYNRAMP_STEPA_MASK) &
11846b301a05SRhyland Klein (~PLLX_MISC2_DYNRAMP_STEPB_MASK);
11856b301a05SRhyland Klein val |= step_a << PLLX_MISC2_DYNRAMP_STEPA_SHIFT;
11866b301a05SRhyland Klein val |= step_b << PLLX_MISC2_DYNRAMP_STEPB_SHIFT;
11876b301a05SRhyland Klein
11886b301a05SRhyland Klein if (readl_relaxed(clk_base + pllx->params->base_reg) & PLL_ENABLE) {
11896b301a05SRhyland Klein
11906b301a05SRhyland Klein /*
11916b301a05SRhyland Klein * PLL is ON: check if defaults already set, then set those
11926b301a05SRhyland Klein * that can be updated in flight.
11936b301a05SRhyland Klein */
11946b301a05SRhyland Klein pllx_check_defaults(pllx);
11956b301a05SRhyland Klein
11968dce89a1SPeter De Schrijver if (!pllx->params->defaults_set)
11978dce89a1SPeter De Schrijver pr_warn("PLL_X already enabled. Postponing set full defaults\n");
11986b301a05SRhyland Klein /* Configure dyn ramp, disable lock override */
11996b301a05SRhyland Klein writel_relaxed(val, clk_base + pllx->params->ext_misc_reg[2]);
12006b301a05SRhyland Klein
12016b301a05SRhyland Klein /* Enable lock detect */
12026b301a05SRhyland Klein val = readl_relaxed(clk_base + pllx->params->ext_misc_reg[0]);
12036b301a05SRhyland Klein val &= ~PLLX_MISC0_LOCK_ENABLE;
12046b301a05SRhyland Klein val |= PLLX_MISC0_DEFAULT_VALUE & PLLX_MISC0_LOCK_ENABLE;
12056b301a05SRhyland Klein writel_relaxed(val, clk_base + pllx->params->ext_misc_reg[0]);
12066b301a05SRhyland Klein udelay(1);
12076b301a05SRhyland Klein
12086b301a05SRhyland Klein return;
12096b301a05SRhyland Klein }
12106b301a05SRhyland Klein
12116b301a05SRhyland Klein /* Enable lock detect and CPU output */
12126b301a05SRhyland Klein writel_relaxed(PLLX_MISC0_DEFAULT_VALUE, clk_base +
12136b301a05SRhyland Klein pllx->params->ext_misc_reg[0]);
12146b301a05SRhyland Klein
12156b301a05SRhyland Klein /* Setup */
12166b301a05SRhyland Klein writel_relaxed(PLLX_MISC1_DEFAULT_VALUE, clk_base +
12176b301a05SRhyland Klein pllx->params->ext_misc_reg[1]);
12186b301a05SRhyland Klein
12196b301a05SRhyland Klein /* Configure dyn ramp state machine, disable lock override */
12206b301a05SRhyland Klein writel_relaxed(val, clk_base + pllx->params->ext_misc_reg[2]);
12216b301a05SRhyland Klein
12226b301a05SRhyland Klein /* Set IDDQ */
12236b301a05SRhyland Klein writel_relaxed(PLLX_MISC3_DEFAULT_VALUE, clk_base +
12246b301a05SRhyland Klein pllx->params->ext_misc_reg[3]);
12256b301a05SRhyland Klein
12266b301a05SRhyland Klein /* Disable SDM */
12276b301a05SRhyland Klein writel_relaxed(PLLX_MISC4_DEFAULT_VALUE, clk_base +
12286b301a05SRhyland Klein pllx->params->ext_misc_reg[4]);
12296b301a05SRhyland Klein writel_relaxed(PLLX_MISC5_DEFAULT_VALUE, clk_base +
12306b301a05SRhyland Klein pllx->params->ext_misc_reg[5]);
12316b301a05SRhyland Klein udelay(1);
12326b301a05SRhyland Klein }
12336b301a05SRhyland Klein
12346b301a05SRhyland Klein /* PLLMB */
tegra210_pllmb_set_defaults(struct tegra_clk_pll * pllmb)1235fd360e20SJon Hunter static void tegra210_pllmb_set_defaults(struct tegra_clk_pll *pllmb)
12366b301a05SRhyland Klein {
12376b301a05SRhyland Klein u32 mask, val = readl_relaxed(clk_base + pllmb->params->base_reg);
12386b301a05SRhyland Klein
12396b301a05SRhyland Klein pllmb->params->defaults_set = true;
12406b301a05SRhyland Klein
12416b301a05SRhyland Klein if (val & PLL_ENABLE) {
12426b301a05SRhyland Klein
12436b301a05SRhyland Klein /*
12446b301a05SRhyland Klein * PLL is ON: check if defaults already set, then set those
12456b301a05SRhyland Klein * that can be updated in flight.
12466b301a05SRhyland Klein */
1247474f2ba2SRhyland Klein val = PLLMB_MISC1_DEFAULT_VALUE & (~PLLMB_MISC1_IDDQ);
1248474f2ba2SRhyland Klein mask = PLLMB_MISC1_LOCK_ENABLE | PLLMB_MISC1_LOCK_OVERRIDE;
12496b301a05SRhyland Klein _pll_misc_chk_default(clk_base, pllmb->params, 0, val,
1250474f2ba2SRhyland Klein ~mask & PLLMB_MISC1_WRITE_MASK);
12516b301a05SRhyland Klein
12528dce89a1SPeter De Schrijver if (!pllmb->params->defaults_set)
12538dce89a1SPeter De Schrijver pr_warn("PLL_MB already enabled. Postponing set full defaults\n");
12546b301a05SRhyland Klein /* Enable lock detect */
12556b301a05SRhyland Klein val = readl_relaxed(clk_base + pllmb->params->ext_misc_reg[0]);
12566b301a05SRhyland Klein val &= ~mask;
1257474f2ba2SRhyland Klein val |= PLLMB_MISC1_DEFAULT_VALUE & mask;
12586b301a05SRhyland Klein writel_relaxed(val, clk_base + pllmb->params->ext_misc_reg[0]);
12596b301a05SRhyland Klein udelay(1);
12606b301a05SRhyland Klein
12616b301a05SRhyland Klein return;
12626b301a05SRhyland Klein }
12636b301a05SRhyland Klein
12646b301a05SRhyland Klein /* set IDDQ, enable lock detect */
1265474f2ba2SRhyland Klein writel_relaxed(PLLMB_MISC1_DEFAULT_VALUE,
12666b301a05SRhyland Klein clk_base + pllmb->params->ext_misc_reg[0]);
12676b301a05SRhyland Klein udelay(1);
12686b301a05SRhyland Klein }
12696b301a05SRhyland Klein
12706b301a05SRhyland Klein /*
12716b301a05SRhyland Klein * PLLP
12726b301a05SRhyland Klein * VCO is exposed to the clock tree directly along with post-divider output.
12736b301a05SRhyland Klein * Both VCO and post-divider output rates are fixed at 408MHz and 204MHz,
12746b301a05SRhyland Klein * respectively.
12756b301a05SRhyland Klein */
pllp_check_defaults(struct tegra_clk_pll * pll,bool enabled)12766b301a05SRhyland Klein static void pllp_check_defaults(struct tegra_clk_pll *pll, bool enabled)
12776b301a05SRhyland Klein {
12786b301a05SRhyland Klein u32 val, mask;
12796b301a05SRhyland Klein
12806b301a05SRhyland Klein /* Ignore lock enable (will be set), make sure not in IDDQ if enabled */
12816b301a05SRhyland Klein val = PLLP_MISC0_DEFAULT_VALUE & (~PLLP_MISC0_IDDQ);
12826b301a05SRhyland Klein mask = PLLP_MISC0_LOCK_ENABLE | PLLP_MISC0_LOCK_OVERRIDE;
12836b301a05SRhyland Klein if (!enabled)
12846b301a05SRhyland Klein mask |= PLLP_MISC0_IDDQ;
12856b301a05SRhyland Klein _pll_misc_chk_default(clk_base, pll->params, 0, val,
12866b301a05SRhyland Klein ~mask & PLLP_MISC0_WRITE_MASK);
12876b301a05SRhyland Klein
12886b301a05SRhyland Klein /* Ignore branch controls */
12896b301a05SRhyland Klein val = PLLP_MISC1_DEFAULT_VALUE;
12906b301a05SRhyland Klein mask = PLLP_MISC1_HSIO_EN | PLLP_MISC1_XUSB_EN;
12916b301a05SRhyland Klein _pll_misc_chk_default(clk_base, pll->params, 1, val,
12926b301a05SRhyland Klein ~mask & PLLP_MISC1_WRITE_MASK);
12936b301a05SRhyland Klein }
12946b301a05SRhyland Klein
tegra210_pllp_set_defaults(struct tegra_clk_pll * pllp)1295fd360e20SJon Hunter static void tegra210_pllp_set_defaults(struct tegra_clk_pll *pllp)
12966b301a05SRhyland Klein {
12976b301a05SRhyland Klein u32 mask;
12986b301a05SRhyland Klein u32 val = readl_relaxed(clk_base + pllp->params->base_reg);
12996b301a05SRhyland Klein
13006b301a05SRhyland Klein pllp->params->defaults_set = true;
13016b301a05SRhyland Klein
13026b301a05SRhyland Klein if (val & PLL_ENABLE) {
13036b301a05SRhyland Klein
13046b301a05SRhyland Klein /*
13056b301a05SRhyland Klein * PLL is ON: check if defaults already set, then set those
13066b301a05SRhyland Klein * that can be updated in flight.
13076b301a05SRhyland Klein */
13086b301a05SRhyland Klein pllp_check_defaults(pllp, true);
13098dce89a1SPeter De Schrijver if (!pllp->params->defaults_set)
13108dce89a1SPeter De Schrijver pr_warn("PLL_P already enabled. Postponing set full defaults\n");
13116b301a05SRhyland Klein
13126b301a05SRhyland Klein /* Enable lock detect */
13136b301a05SRhyland Klein val = readl_relaxed(clk_base + pllp->params->ext_misc_reg[0]);
13146b301a05SRhyland Klein mask = PLLP_MISC0_LOCK_ENABLE | PLLP_MISC0_LOCK_OVERRIDE;
13156b301a05SRhyland Klein val &= ~mask;
13166b301a05SRhyland Klein val |= PLLP_MISC0_DEFAULT_VALUE & mask;
13176b301a05SRhyland Klein writel_relaxed(val, clk_base + pllp->params->ext_misc_reg[0]);
13186b301a05SRhyland Klein udelay(1);
13196b301a05SRhyland Klein
13206b301a05SRhyland Klein return;
13216b301a05SRhyland Klein }
13226b301a05SRhyland Klein
13236b301a05SRhyland Klein /* set IDDQ, enable lock detect */
13246b301a05SRhyland Klein writel_relaxed(PLLP_MISC0_DEFAULT_VALUE,
13256b301a05SRhyland Klein clk_base + pllp->params->ext_misc_reg[0]);
13266b301a05SRhyland Klein
13276b301a05SRhyland Klein /* Preserve branch control */
13286b301a05SRhyland Klein val = readl_relaxed(clk_base + pllp->params->ext_misc_reg[1]);
13296b301a05SRhyland Klein mask = PLLP_MISC1_HSIO_EN | PLLP_MISC1_XUSB_EN;
13306b301a05SRhyland Klein val &= mask;
13316b301a05SRhyland Klein val |= ~mask & PLLP_MISC1_DEFAULT_VALUE;
13326b301a05SRhyland Klein writel_relaxed(val, clk_base + pllp->params->ext_misc_reg[1]);
13336b301a05SRhyland Klein udelay(1);
13346b301a05SRhyland Klein }
13356b301a05SRhyland Klein
13366b301a05SRhyland Klein /*
13376b301a05SRhyland Klein * PLLU
13386b301a05SRhyland Klein * VCO is exposed to the clock tree directly along with post-divider output.
13396b301a05SRhyland Klein * Both VCO and post-divider output rates are fixed at 480MHz and 240MHz,
13406b301a05SRhyland Klein * respectively.
13416b301a05SRhyland Klein */
pllu_check_defaults(struct tegra_clk_pll_params * params,bool hw_control)1342e745f992SPeter De Schrijver static void pllu_check_defaults(struct tegra_clk_pll_params *params,
1343e745f992SPeter De Schrijver bool hw_control)
13446b301a05SRhyland Klein {
13456b301a05SRhyland Klein u32 val, mask;
13466b301a05SRhyland Klein
13476b301a05SRhyland Klein /* Ignore lock enable (will be set) and IDDQ if under h/w control */
13486b301a05SRhyland Klein val = PLLU_MISC0_DEFAULT_VALUE & (~PLLU_MISC0_IDDQ);
13496b301a05SRhyland Klein mask = PLLU_MISC0_LOCK_ENABLE | (hw_control ? PLLU_MISC0_IDDQ : 0);
1350e745f992SPeter De Schrijver _pll_misc_chk_default(clk_base, params, 0, val,
13516b301a05SRhyland Klein ~mask & PLLU_MISC0_WRITE_MASK);
13526b301a05SRhyland Klein
13536b301a05SRhyland Klein val = PLLU_MISC1_DEFAULT_VALUE;
13546b301a05SRhyland Klein mask = PLLU_MISC1_LOCK_OVERRIDE;
1355e745f992SPeter De Schrijver _pll_misc_chk_default(clk_base, params, 1, val,
13566b301a05SRhyland Klein ~mask & PLLU_MISC1_WRITE_MASK);
13576b301a05SRhyland Klein }
13586b301a05SRhyland Klein
tegra210_pllu_set_defaults(struct tegra_clk_pll_params * pllu)1359e745f992SPeter De Schrijver static void tegra210_pllu_set_defaults(struct tegra_clk_pll_params *pllu)
13606b301a05SRhyland Klein {
1361e745f992SPeter De Schrijver u32 val = readl_relaxed(clk_base + pllu->base_reg);
13626b301a05SRhyland Klein
1363e745f992SPeter De Schrijver pllu->defaults_set = true;
13646b301a05SRhyland Klein
13656b301a05SRhyland Klein if (val & PLL_ENABLE) {
13666b301a05SRhyland Klein
13676b301a05SRhyland Klein /*
13686b301a05SRhyland Klein * PLL is ON: check if defaults already set, then set those
13696b301a05SRhyland Klein * that can be updated in flight.
13706b301a05SRhyland Klein */
13716b301a05SRhyland Klein pllu_check_defaults(pllu, false);
1372e745f992SPeter De Schrijver if (!pllu->defaults_set)
13738dce89a1SPeter De Schrijver pr_warn("PLL_U already enabled. Postponing set full defaults\n");
13746b301a05SRhyland Klein
13756b301a05SRhyland Klein /* Enable lock detect */
1376e745f992SPeter De Schrijver val = readl_relaxed(clk_base + pllu->ext_misc_reg[0]);
13776b301a05SRhyland Klein val &= ~PLLU_MISC0_LOCK_ENABLE;
13786b301a05SRhyland Klein val |= PLLU_MISC0_DEFAULT_VALUE & PLLU_MISC0_LOCK_ENABLE;
1379e745f992SPeter De Schrijver writel_relaxed(val, clk_base + pllu->ext_misc_reg[0]);
13806b301a05SRhyland Klein
1381e745f992SPeter De Schrijver val = readl_relaxed(clk_base + pllu->ext_misc_reg[1]);
13826b301a05SRhyland Klein val &= ~PLLU_MISC1_LOCK_OVERRIDE;
13836b301a05SRhyland Klein val |= PLLU_MISC1_DEFAULT_VALUE & PLLU_MISC1_LOCK_OVERRIDE;
1384e745f992SPeter De Schrijver writel_relaxed(val, clk_base + pllu->ext_misc_reg[1]);
13856b301a05SRhyland Klein udelay(1);
13866b301a05SRhyland Klein
13876b301a05SRhyland Klein return;
13886b301a05SRhyland Klein }
13896b301a05SRhyland Klein
13906b301a05SRhyland Klein /* set IDDQ, enable lock detect */
13916b301a05SRhyland Klein writel_relaxed(PLLU_MISC0_DEFAULT_VALUE,
1392e745f992SPeter De Schrijver clk_base + pllu->ext_misc_reg[0]);
13936b301a05SRhyland Klein writel_relaxed(PLLU_MISC1_DEFAULT_VALUE,
1394e745f992SPeter De Schrijver clk_base + pllu->ext_misc_reg[1]);
13956b301a05SRhyland Klein udelay(1);
13966b301a05SRhyland Klein }
13976b301a05SRhyland Klein
13986b301a05SRhyland Klein #define mask(w) ((1 << (w)) - 1)
13996b301a05SRhyland Klein #define divm_mask(p) mask(p->params->div_nmp->divm_width)
14006b301a05SRhyland Klein #define divn_mask(p) mask(p->params->div_nmp->divn_width)
14016b301a05SRhyland Klein #define divp_mask(p) (p->params->flags & TEGRA_PLLU ? PLLU_POST_DIVP_MASK :\
14026b301a05SRhyland Klein mask(p->params->div_nmp->divp_width))
14036b301a05SRhyland Klein
14046b301a05SRhyland Klein #define divm_shift(p) ((p)->params->div_nmp->divm_shift)
14056b301a05SRhyland Klein #define divn_shift(p) ((p)->params->div_nmp->divn_shift)
14066b301a05SRhyland Klein #define divp_shift(p) ((p)->params->div_nmp->divp_shift)
14076b301a05SRhyland Klein
14086b301a05SRhyland Klein #define divm_mask_shifted(p) (divm_mask(p) << divm_shift(p))
14096b301a05SRhyland Klein #define divn_mask_shifted(p) (divn_mask(p) << divn_shift(p))
14106b301a05SRhyland Klein #define divp_mask_shifted(p) (divp_mask(p) << divp_shift(p))
14116b301a05SRhyland Klein
14126b301a05SRhyland Klein #define PLL_LOCKDET_DELAY 2 /* Lock detection safety delays */
tegra210_wait_for_mask(struct tegra_clk_pll * pll,u32 reg,u32 mask)14136b301a05SRhyland Klein static int tegra210_wait_for_mask(struct tegra_clk_pll *pll,
14146b301a05SRhyland Klein u32 reg, u32 mask)
14156b301a05SRhyland Klein {
14166b301a05SRhyland Klein int i;
14176b301a05SRhyland Klein u32 val = 0;
14186b301a05SRhyland Klein
14196b301a05SRhyland Klein for (i = 0; i < pll->params->lock_delay / PLL_LOCKDET_DELAY + 1; i++) {
14206b301a05SRhyland Klein udelay(PLL_LOCKDET_DELAY);
14216b301a05SRhyland Klein val = readl_relaxed(clk_base + reg);
14226b301a05SRhyland Klein if ((val & mask) == mask) {
14236b301a05SRhyland Klein udelay(PLL_LOCKDET_DELAY);
14246b301a05SRhyland Klein return 0;
14256b301a05SRhyland Klein }
14266b301a05SRhyland Klein }
14276b301a05SRhyland Klein return -ETIMEDOUT;
14286b301a05SRhyland Klein }
14296b301a05SRhyland Klein
tegra210_pllx_dyn_ramp(struct tegra_clk_pll * pllx,struct tegra_clk_pll_freq_table * cfg)14306b301a05SRhyland Klein static int tegra210_pllx_dyn_ramp(struct tegra_clk_pll *pllx,
14316b301a05SRhyland Klein struct tegra_clk_pll_freq_table *cfg)
14326b301a05SRhyland Klein {
14336b301a05SRhyland Klein u32 val, base, ndiv_new_mask;
14346b301a05SRhyland Klein
14356b301a05SRhyland Klein ndiv_new_mask = (divn_mask(pllx) >> pllx->params->div_nmp->divn_shift)
14366b301a05SRhyland Klein << PLLX_MISC2_NDIV_NEW_SHIFT;
14376b301a05SRhyland Klein
14386b301a05SRhyland Klein val = readl_relaxed(clk_base + pllx->params->ext_misc_reg[2]);
14396b301a05SRhyland Klein val &= (~ndiv_new_mask);
14406b301a05SRhyland Klein val |= cfg->n << PLLX_MISC2_NDIV_NEW_SHIFT;
14416b301a05SRhyland Klein writel_relaxed(val, clk_base + pllx->params->ext_misc_reg[2]);
14426b301a05SRhyland Klein udelay(1);
14436b301a05SRhyland Klein
14446b301a05SRhyland Klein val = readl_relaxed(clk_base + pllx->params->ext_misc_reg[2]);
14456b301a05SRhyland Klein val |= PLLX_MISC2_EN_DYNRAMP;
14466b301a05SRhyland Klein writel_relaxed(val, clk_base + pllx->params->ext_misc_reg[2]);
14476b301a05SRhyland Klein udelay(1);
14486b301a05SRhyland Klein
14496b301a05SRhyland Klein tegra210_wait_for_mask(pllx, pllx->params->ext_misc_reg[2],
14506b301a05SRhyland Klein PLLX_MISC2_DYNRAMP_DONE);
14516b301a05SRhyland Klein
14526b301a05SRhyland Klein base = readl_relaxed(clk_base + pllx->params->base_reg) &
14536b301a05SRhyland Klein (~divn_mask_shifted(pllx));
14546b301a05SRhyland Klein base |= cfg->n << pllx->params->div_nmp->divn_shift;
14556b301a05SRhyland Klein writel_relaxed(base, clk_base + pllx->params->base_reg);
14566b301a05SRhyland Klein udelay(1);
14576b301a05SRhyland Klein
14586b301a05SRhyland Klein val &= ~PLLX_MISC2_EN_DYNRAMP;
14596b301a05SRhyland Klein writel_relaxed(val, clk_base + pllx->params->ext_misc_reg[2]);
14606b301a05SRhyland Klein udelay(1);
14616b301a05SRhyland Klein
14626b301a05SRhyland Klein pr_debug("%s: dynamic ramp to m = %u n = %u p = %u, Fout = %lu kHz\n",
14636b301a05SRhyland Klein __clk_get_name(pllx->hw.clk), cfg->m, cfg->n, cfg->p,
14646b301a05SRhyland Klein cfg->input_rate / cfg->m * cfg->n /
14656b301a05SRhyland Klein pllx->params->pdiv_tohw[cfg->p].pdiv / 1000);
14666b301a05SRhyland Klein
14676b301a05SRhyland Klein return 0;
14686b301a05SRhyland Klein }
14696b301a05SRhyland Klein
14706b301a05SRhyland Klein /*
14716b301a05SRhyland Klein * Common configuration for PLLs with fixed input divider policy:
14726b301a05SRhyland Klein * - always set fixed M-value based on the reference rate
14736b301a05SRhyland Klein * - always set P-value value 1:1 for output rates above VCO minimum, and
14746b301a05SRhyland Klein * choose minimum necessary P-value for output rates below VCO maximum
14756b301a05SRhyland Klein * - calculate N-value based on selected M and P
14766b301a05SRhyland Klein * - calculate SDM_DIN fractional part
14776b301a05SRhyland Klein */
tegra210_pll_fixed_mdiv_cfg(struct clk_hw * hw,struct tegra_clk_pll_freq_table * cfg,unsigned long rate,unsigned long input_rate)14786b301a05SRhyland Klein static int tegra210_pll_fixed_mdiv_cfg(struct clk_hw *hw,
14796b301a05SRhyland Klein struct tegra_clk_pll_freq_table *cfg,
14806b301a05SRhyland Klein unsigned long rate, unsigned long input_rate)
14816b301a05SRhyland Klein {
14826b301a05SRhyland Klein struct tegra_clk_pll *pll = to_clk_pll(hw);
14836b301a05SRhyland Klein struct tegra_clk_pll_params *params = pll->params;
14846b301a05SRhyland Klein int p;
14856b301a05SRhyland Klein unsigned long cf, p_rate;
14866b301a05SRhyland Klein u32 pdiv;
14876b301a05SRhyland Klein
14886b301a05SRhyland Klein if (!rate)
14896b301a05SRhyland Klein return -EINVAL;
14906b301a05SRhyland Klein
14916b301a05SRhyland Klein if (!(params->flags & TEGRA_PLL_VCO_OUT)) {
14926b301a05SRhyland Klein p = DIV_ROUND_UP(params->vco_min, rate);
14936b301a05SRhyland Klein p = params->round_p_to_pdiv(p, &pdiv);
14946b301a05SRhyland Klein } else {
14956b301a05SRhyland Klein p = rate >= params->vco_min ? 1 : -EINVAL;
14966b301a05SRhyland Klein }
14976b301a05SRhyland Klein
1498287980e4SArnd Bergmann if (p < 0)
14996b301a05SRhyland Klein return -EINVAL;
15006b301a05SRhyland Klein
15016b301a05SRhyland Klein cfg->m = tegra_pll_get_fixed_mdiv(hw, input_rate);
15026b301a05SRhyland Klein cfg->p = p;
15036b301a05SRhyland Klein
15046b301a05SRhyland Klein /* Store P as HW value, as that is what is expected */
15056b301a05SRhyland Klein cfg->p = tegra_pll_p_div_to_hw(pll, cfg->p);
15066b301a05SRhyland Klein
15076b301a05SRhyland Klein p_rate = rate * p;
15086b301a05SRhyland Klein if (p_rate > params->vco_max)
15096b301a05SRhyland Klein p_rate = params->vco_max;
15106b301a05SRhyland Klein cf = input_rate / cfg->m;
15116b301a05SRhyland Klein cfg->n = p_rate / cf;
15126b301a05SRhyland Klein
15136b301a05SRhyland Klein cfg->sdm_data = 0;
1514ef6ed2b9SPeter De Schrijver cfg->output_rate = input_rate;
15156b301a05SRhyland Klein if (params->sdm_ctrl_reg) {
15166b301a05SRhyland Klein unsigned long rem = p_rate - cf * cfg->n;
15176b301a05SRhyland Klein /* If ssc is enabled SDM enabled as well, even for integer n */
15186b301a05SRhyland Klein if (rem || params->ssc_ctrl_reg) {
15196b301a05SRhyland Klein u64 s = rem * PLL_SDM_COEFF;
15206b301a05SRhyland Klein
15216b301a05SRhyland Klein do_div(s, cf);
15226b301a05SRhyland Klein s -= PLL_SDM_COEFF / 2;
15236b301a05SRhyland Klein cfg->sdm_data = sdin_din_to_data(s);
15246b301a05SRhyland Klein }
1525a851ea2bSAlex Frid cfg->output_rate *= sdin_get_n_eff(cfg);
1526ef6ed2b9SPeter De Schrijver cfg->output_rate /= p * cfg->m * PLL_SDM_COEFF;
1527ef6ed2b9SPeter De Schrijver } else {
1528ef6ed2b9SPeter De Schrijver cfg->output_rate *= cfg->n;
1529ef6ed2b9SPeter De Schrijver cfg->output_rate /= p * cfg->m;
15306b301a05SRhyland Klein }
15316b301a05SRhyland Klein
15326b301a05SRhyland Klein cfg->input_rate = input_rate;
15336b301a05SRhyland Klein
15346b301a05SRhyland Klein return 0;
15356b301a05SRhyland Klein }
15366b301a05SRhyland Klein
15376b301a05SRhyland Klein /*
15386b301a05SRhyland Klein * clk_pll_set_gain - set gain to m, n to calculate correct VCO rate
15396b301a05SRhyland Klein *
15406b301a05SRhyland Klein * @cfg: struct tegra_clk_pll_freq_table * cfg
15416b301a05SRhyland Klein *
15426b301a05SRhyland Klein * For Normal mode:
15436b301a05SRhyland Klein * Fvco = Fref * NDIV / MDIV
15446b301a05SRhyland Klein *
15456b301a05SRhyland Klein * For fractional mode:
15466b301a05SRhyland Klein * Fvco = Fref * (NDIV + 0.5 + SDM_DIN / PLL_SDM_COEFF) / MDIV
15476b301a05SRhyland Klein */
tegra210_clk_pll_set_gain(struct tegra_clk_pll_freq_table * cfg)15486b301a05SRhyland Klein static void tegra210_clk_pll_set_gain(struct tegra_clk_pll_freq_table *cfg)
15496b301a05SRhyland Klein {
1550a851ea2bSAlex Frid cfg->n = sdin_get_n_eff(cfg);
15516b301a05SRhyland Klein cfg->m *= PLL_SDM_COEFF;
15526b301a05SRhyland Klein }
15536b301a05SRhyland Klein
1554fd360e20SJon Hunter static unsigned long
tegra210_clk_adjust_vco_min(struct tegra_clk_pll_params * params,unsigned long parent_rate)1555fd360e20SJon Hunter tegra210_clk_adjust_vco_min(struct tegra_clk_pll_params *params,
15566b301a05SRhyland Klein unsigned long parent_rate)
15576b301a05SRhyland Klein {
15586b301a05SRhyland Klein unsigned long vco_min = params->vco_min;
15596b301a05SRhyland Klein
15606b301a05SRhyland Klein params->vco_min += DIV_ROUND_UP(parent_rate, PLL_SDM_COEFF);
15616b301a05SRhyland Klein vco_min = min(vco_min, params->vco_min);
15626b301a05SRhyland Klein
15636b301a05SRhyland Klein return vco_min;
15646b301a05SRhyland Klein }
15656b301a05SRhyland Klein
15666b301a05SRhyland Klein static struct div_nmp pllx_nmp = {
15676b301a05SRhyland Klein .divm_shift = 0,
15686b301a05SRhyland Klein .divm_width = 8,
15696b301a05SRhyland Klein .divn_shift = 8,
15706b301a05SRhyland Klein .divn_width = 8,
15716b301a05SRhyland Klein .divp_shift = 20,
15726b301a05SRhyland Klein .divp_width = 5,
15736b301a05SRhyland Klein };
15746b301a05SRhyland Klein /*
15756b301a05SRhyland Klein * PLL post divider maps - two types: quasi-linear and exponential
15766b301a05SRhyland Klein * post divider.
15776b301a05SRhyland Klein */
15786b301a05SRhyland Klein #define PLL_QLIN_PDIV_MAX 16
15796b301a05SRhyland Klein static const struct pdiv_map pll_qlin_pdiv_to_hw[] = {
15806b301a05SRhyland Klein { .pdiv = 1, .hw_val = 0 },
15816b301a05SRhyland Klein { .pdiv = 2, .hw_val = 1 },
15826b301a05SRhyland Klein { .pdiv = 3, .hw_val = 2 },
15836b301a05SRhyland Klein { .pdiv = 4, .hw_val = 3 },
15846b301a05SRhyland Klein { .pdiv = 5, .hw_val = 4 },
15856b301a05SRhyland Klein { .pdiv = 6, .hw_val = 5 },
15866b301a05SRhyland Klein { .pdiv = 8, .hw_val = 6 },
15876b301a05SRhyland Klein { .pdiv = 9, .hw_val = 7 },
15886b301a05SRhyland Klein { .pdiv = 10, .hw_val = 8 },
15896b301a05SRhyland Klein { .pdiv = 12, .hw_val = 9 },
15906b301a05SRhyland Klein { .pdiv = 15, .hw_val = 10 },
15916b301a05SRhyland Klein { .pdiv = 16, .hw_val = 11 },
15926b301a05SRhyland Klein { .pdiv = 18, .hw_val = 12 },
15936b301a05SRhyland Klein { .pdiv = 20, .hw_val = 13 },
15946b301a05SRhyland Klein { .pdiv = 24, .hw_val = 14 },
15956b301a05SRhyland Klein { .pdiv = 30, .hw_val = 15 },
15966b301a05SRhyland Klein { .pdiv = 32, .hw_val = 16 },
15976b301a05SRhyland Klein };
15986b301a05SRhyland Klein
pll_qlin_p_to_pdiv(u32 p,u32 * pdiv)15996b301a05SRhyland Klein static u32 pll_qlin_p_to_pdiv(u32 p, u32 *pdiv)
16006b301a05SRhyland Klein {
16016b301a05SRhyland Klein int i;
16026b301a05SRhyland Klein
16036b301a05SRhyland Klein if (p) {
16046b301a05SRhyland Klein for (i = 0; i <= PLL_QLIN_PDIV_MAX; i++) {
16056b301a05SRhyland Klein if (p <= pll_qlin_pdiv_to_hw[i].pdiv) {
16066b301a05SRhyland Klein if (pdiv)
16076b301a05SRhyland Klein *pdiv = i;
16086b301a05SRhyland Klein return pll_qlin_pdiv_to_hw[i].pdiv;
16096b301a05SRhyland Klein }
16106b301a05SRhyland Klein }
16116b301a05SRhyland Klein }
16126b301a05SRhyland Klein
16136b301a05SRhyland Klein return -EINVAL;
16146b301a05SRhyland Klein }
16156b301a05SRhyland Klein
16166b301a05SRhyland Klein #define PLL_EXPO_PDIV_MAX 7
16176b301a05SRhyland Klein static const struct pdiv_map pll_expo_pdiv_to_hw[] = {
16186b301a05SRhyland Klein { .pdiv = 1, .hw_val = 0 },
16196b301a05SRhyland Klein { .pdiv = 2, .hw_val = 1 },
16206b301a05SRhyland Klein { .pdiv = 4, .hw_val = 2 },
16216b301a05SRhyland Klein { .pdiv = 8, .hw_val = 3 },
16226b301a05SRhyland Klein { .pdiv = 16, .hw_val = 4 },
16236b301a05SRhyland Klein { .pdiv = 32, .hw_val = 5 },
16246b301a05SRhyland Klein { .pdiv = 64, .hw_val = 6 },
16256b301a05SRhyland Klein { .pdiv = 128, .hw_val = 7 },
16266b301a05SRhyland Klein };
16276b301a05SRhyland Klein
pll_expo_p_to_pdiv(u32 p,u32 * pdiv)16286b301a05SRhyland Klein static u32 pll_expo_p_to_pdiv(u32 p, u32 *pdiv)
16296b301a05SRhyland Klein {
16306b301a05SRhyland Klein if (p) {
16316b301a05SRhyland Klein u32 i = fls(p);
16326b301a05SRhyland Klein
16336b301a05SRhyland Klein if (i == ffs(p))
16346b301a05SRhyland Klein i--;
16356b301a05SRhyland Klein
16366b301a05SRhyland Klein if (i <= PLL_EXPO_PDIV_MAX) {
16376b301a05SRhyland Klein if (pdiv)
16386b301a05SRhyland Klein *pdiv = i;
16396b301a05SRhyland Klein return 1 << i;
16406b301a05SRhyland Klein }
16416b301a05SRhyland Klein }
16426b301a05SRhyland Klein return -EINVAL;
16436b301a05SRhyland Klein }
16446b301a05SRhyland Klein
16456b301a05SRhyland Klein static struct tegra_clk_pll_freq_table pll_x_freq_table[] = {
16466b301a05SRhyland Klein /* 1 GHz */
1647eddb65e7SThierry Reding { 12000000, 1000000000, 166, 1, 2, 0 }, /* actual: 996.0 MHz */
1648eddb65e7SThierry Reding { 13000000, 1000000000, 153, 1, 2, 0 }, /* actual: 994.0 MHz */
1649eddb65e7SThierry Reding { 38400000, 1000000000, 156, 3, 2, 0 }, /* actual: 998.4 MHz */
16506b301a05SRhyland Klein { 0, 0, 0, 0, 0, 0 },
16516b301a05SRhyland Klein };
16526b301a05SRhyland Klein
16536b301a05SRhyland Klein static struct tegra_clk_pll_params pll_x_params = {
16546b301a05SRhyland Klein .input_min = 12000000,
16556b301a05SRhyland Klein .input_max = 800000000,
16566b301a05SRhyland Klein .cf_min = 12000000,
16576b301a05SRhyland Klein .cf_max = 38400000,
16586b301a05SRhyland Klein .vco_min = 1350000000,
16596b301a05SRhyland Klein .vco_max = 3000000000UL,
16606b301a05SRhyland Klein .base_reg = PLLX_BASE,
16616b301a05SRhyland Klein .misc_reg = PLLX_MISC0,
16626b301a05SRhyland Klein .lock_mask = PLL_BASE_LOCK,
16636b301a05SRhyland Klein .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
16646b301a05SRhyland Klein .lock_delay = 300,
16656b301a05SRhyland Klein .ext_misc_reg[0] = PLLX_MISC0,
16666b301a05SRhyland Klein .ext_misc_reg[1] = PLLX_MISC1,
16676b301a05SRhyland Klein .ext_misc_reg[2] = PLLX_MISC2,
16686b301a05SRhyland Klein .ext_misc_reg[3] = PLLX_MISC3,
16696b301a05SRhyland Klein .ext_misc_reg[4] = PLLX_MISC4,
16706b301a05SRhyland Klein .ext_misc_reg[5] = PLLX_MISC5,
16716b301a05SRhyland Klein .iddq_reg = PLLX_MISC3,
16726b301a05SRhyland Klein .iddq_bit_idx = PLLXP_IDDQ_BIT,
16736b301a05SRhyland Klein .max_p = PLL_QLIN_PDIV_MAX,
16746b301a05SRhyland Klein .mdiv_default = 2,
16756b301a05SRhyland Klein .dyn_ramp_reg = PLLX_MISC2,
16766b301a05SRhyland Klein .stepa_shift = 16,
16776b301a05SRhyland Klein .stepb_shift = 24,
16786b301a05SRhyland Klein .round_p_to_pdiv = pll_qlin_p_to_pdiv,
16796b301a05SRhyland Klein .pdiv_tohw = pll_qlin_pdiv_to_hw,
16806b301a05SRhyland Klein .div_nmp = &pllx_nmp,
16816b301a05SRhyland Klein .freq_table = pll_x_freq_table,
16826b301a05SRhyland Klein .flags = TEGRA_PLL_USE_LOCK | TEGRA_PLL_HAS_LOCK_ENABLE,
16836b301a05SRhyland Klein .dyn_ramp = tegra210_pllx_dyn_ramp,
16846b301a05SRhyland Klein .set_defaults = tegra210_pllx_set_defaults,
16856b301a05SRhyland Klein .calc_rate = tegra210_pll_fixed_mdiv_cfg,
16866b301a05SRhyland Klein };
16876b301a05SRhyland Klein
16886b301a05SRhyland Klein static struct div_nmp pllc_nmp = {
16896b301a05SRhyland Klein .divm_shift = 0,
16906b301a05SRhyland Klein .divm_width = 8,
16916b301a05SRhyland Klein .divn_shift = 10,
16926b301a05SRhyland Klein .divn_width = 8,
16936b301a05SRhyland Klein .divp_shift = 20,
16946b301a05SRhyland Klein .divp_width = 5,
16956b301a05SRhyland Klein };
16966b301a05SRhyland Klein
16976b301a05SRhyland Klein static struct tegra_clk_pll_freq_table pll_cx_freq_table[] = {
1698eddb65e7SThierry Reding { 12000000, 510000000, 85, 1, 2, 0 },
1699eddb65e7SThierry Reding { 13000000, 510000000, 78, 1, 2, 0 }, /* actual: 507.0 MHz */
1700eddb65e7SThierry Reding { 38400000, 510000000, 79, 3, 2, 0 }, /* actual: 505.6 MHz */
17016b301a05SRhyland Klein { 0, 0, 0, 0, 0, 0 },
17026b301a05SRhyland Klein };
17036b301a05SRhyland Klein
17046b301a05SRhyland Klein static struct tegra_clk_pll_params pll_c_params = {
17056b301a05SRhyland Klein .input_min = 12000000,
17066b301a05SRhyland Klein .input_max = 700000000,
17076b301a05SRhyland Klein .cf_min = 12000000,
17086b301a05SRhyland Klein .cf_max = 50000000,
17096b301a05SRhyland Klein .vco_min = 600000000,
17106b301a05SRhyland Klein .vco_max = 1200000000,
17116b301a05SRhyland Klein .base_reg = PLLC_BASE,
17126b301a05SRhyland Klein .misc_reg = PLLC_MISC0,
17136b301a05SRhyland Klein .lock_mask = PLL_BASE_LOCK,
17146b301a05SRhyland Klein .lock_delay = 300,
17156b301a05SRhyland Klein .iddq_reg = PLLC_MISC1,
17166b301a05SRhyland Klein .iddq_bit_idx = PLLCX_IDDQ_BIT,
17176b301a05SRhyland Klein .reset_reg = PLLC_MISC0,
17186b301a05SRhyland Klein .reset_bit_idx = PLLCX_RESET_BIT,
17196b301a05SRhyland Klein .max_p = PLL_QLIN_PDIV_MAX,
17206b301a05SRhyland Klein .ext_misc_reg[0] = PLLC_MISC0,
17216b301a05SRhyland Klein .ext_misc_reg[1] = PLLC_MISC1,
17226b301a05SRhyland Klein .ext_misc_reg[2] = PLLC_MISC2,
17236b301a05SRhyland Klein .ext_misc_reg[3] = PLLC_MISC3,
17246b301a05SRhyland Klein .round_p_to_pdiv = pll_qlin_p_to_pdiv,
17256b301a05SRhyland Klein .pdiv_tohw = pll_qlin_pdiv_to_hw,
17266b301a05SRhyland Klein .mdiv_default = 3,
17276b301a05SRhyland Klein .div_nmp = &pllc_nmp,
17286b301a05SRhyland Klein .freq_table = pll_cx_freq_table,
172914050118SRhyland Klein .flags = TEGRA_PLL_USE_LOCK,
17306b301a05SRhyland Klein .set_defaults = _pllc_set_defaults,
17316b301a05SRhyland Klein .calc_rate = tegra210_pll_fixed_mdiv_cfg,
17326b301a05SRhyland Klein };
17336b301a05SRhyland Klein
17346b301a05SRhyland Klein static struct div_nmp pllcx_nmp = {
17356b301a05SRhyland Klein .divm_shift = 0,
17366b301a05SRhyland Klein .divm_width = 8,
17376b301a05SRhyland Klein .divn_shift = 10,
17386b301a05SRhyland Klein .divn_width = 8,
17396b301a05SRhyland Klein .divp_shift = 20,
17406b301a05SRhyland Klein .divp_width = 5,
17416b301a05SRhyland Klein };
17426b301a05SRhyland Klein
17436b301a05SRhyland Klein static struct tegra_clk_pll_params pll_c2_params = {
17446b301a05SRhyland Klein .input_min = 12000000,
17456b301a05SRhyland Klein .input_max = 700000000,
17466b301a05SRhyland Klein .cf_min = 12000000,
17476b301a05SRhyland Klein .cf_max = 50000000,
17486b301a05SRhyland Klein .vco_min = 600000000,
17496b301a05SRhyland Klein .vco_max = 1200000000,
17506b301a05SRhyland Klein .base_reg = PLLC2_BASE,
17516b301a05SRhyland Klein .misc_reg = PLLC2_MISC0,
17526b301a05SRhyland Klein .iddq_reg = PLLC2_MISC1,
17536b301a05SRhyland Klein .iddq_bit_idx = PLLCX_IDDQ_BIT,
17546b301a05SRhyland Klein .reset_reg = PLLC2_MISC0,
17556b301a05SRhyland Klein .reset_bit_idx = PLLCX_RESET_BIT,
17566b301a05SRhyland Klein .lock_mask = PLLCX_BASE_LOCK,
17576b301a05SRhyland Klein .lock_delay = 300,
17586b301a05SRhyland Klein .round_p_to_pdiv = pll_qlin_p_to_pdiv,
17596b301a05SRhyland Klein .pdiv_tohw = pll_qlin_pdiv_to_hw,
17606b301a05SRhyland Klein .mdiv_default = 3,
17616b301a05SRhyland Klein .div_nmp = &pllcx_nmp,
17626b301a05SRhyland Klein .max_p = PLL_QLIN_PDIV_MAX,
17636b301a05SRhyland Klein .ext_misc_reg[0] = PLLC2_MISC0,
17646b301a05SRhyland Klein .ext_misc_reg[1] = PLLC2_MISC1,
17656b301a05SRhyland Klein .ext_misc_reg[2] = PLLC2_MISC2,
17666b301a05SRhyland Klein .ext_misc_reg[3] = PLLC2_MISC3,
17676b301a05SRhyland Klein .freq_table = pll_cx_freq_table,
176814050118SRhyland Klein .flags = TEGRA_PLL_USE_LOCK,
17696b301a05SRhyland Klein .set_defaults = _pllc2_set_defaults,
17706b301a05SRhyland Klein .calc_rate = tegra210_pll_fixed_mdiv_cfg,
17716b301a05SRhyland Klein };
17726b301a05SRhyland Klein
17736b301a05SRhyland Klein static struct tegra_clk_pll_params pll_c3_params = {
17746b301a05SRhyland Klein .input_min = 12000000,
17756b301a05SRhyland Klein .input_max = 700000000,
17766b301a05SRhyland Klein .cf_min = 12000000,
17776b301a05SRhyland Klein .cf_max = 50000000,
17786b301a05SRhyland Klein .vco_min = 600000000,
17796b301a05SRhyland Klein .vco_max = 1200000000,
17806b301a05SRhyland Klein .base_reg = PLLC3_BASE,
17816b301a05SRhyland Klein .misc_reg = PLLC3_MISC0,
17826b301a05SRhyland Klein .lock_mask = PLLCX_BASE_LOCK,
17836b301a05SRhyland Klein .lock_delay = 300,
17846b301a05SRhyland Klein .iddq_reg = PLLC3_MISC1,
17856b301a05SRhyland Klein .iddq_bit_idx = PLLCX_IDDQ_BIT,
17866b301a05SRhyland Klein .reset_reg = PLLC3_MISC0,
17876b301a05SRhyland Klein .reset_bit_idx = PLLCX_RESET_BIT,
17886b301a05SRhyland Klein .round_p_to_pdiv = pll_qlin_p_to_pdiv,
17896b301a05SRhyland Klein .pdiv_tohw = pll_qlin_pdiv_to_hw,
17906b301a05SRhyland Klein .mdiv_default = 3,
17916b301a05SRhyland Klein .div_nmp = &pllcx_nmp,
17926b301a05SRhyland Klein .max_p = PLL_QLIN_PDIV_MAX,
17936b301a05SRhyland Klein .ext_misc_reg[0] = PLLC3_MISC0,
17946b301a05SRhyland Klein .ext_misc_reg[1] = PLLC3_MISC1,
17956b301a05SRhyland Klein .ext_misc_reg[2] = PLLC3_MISC2,
17966b301a05SRhyland Klein .ext_misc_reg[3] = PLLC3_MISC3,
17976b301a05SRhyland Klein .freq_table = pll_cx_freq_table,
179814050118SRhyland Klein .flags = TEGRA_PLL_USE_LOCK,
17996b301a05SRhyland Klein .set_defaults = _pllc3_set_defaults,
18006b301a05SRhyland Klein .calc_rate = tegra210_pll_fixed_mdiv_cfg,
18016b301a05SRhyland Klein };
18026b301a05SRhyland Klein
18036b301a05SRhyland Klein static struct div_nmp pllss_nmp = {
18046b301a05SRhyland Klein .divm_shift = 0,
18056b301a05SRhyland Klein .divm_width = 8,
18066b301a05SRhyland Klein .divn_shift = 8,
18076b301a05SRhyland Klein .divn_width = 8,
18086b301a05SRhyland Klein .divp_shift = 19,
18096b301a05SRhyland Klein .divp_width = 5,
18106b301a05SRhyland Klein };
18116b301a05SRhyland Klein
18126b301a05SRhyland Klein static struct tegra_clk_pll_freq_table pll_c4_vco_freq_table[] = {
1813eddb65e7SThierry Reding { 12000000, 600000000, 50, 1, 1, 0 },
1814eddb65e7SThierry Reding { 13000000, 600000000, 46, 1, 1, 0 }, /* actual: 598.0 MHz */
1815eddb65e7SThierry Reding { 38400000, 600000000, 62, 4, 1, 0 }, /* actual: 595.2 MHz */
18166b301a05SRhyland Klein { 0, 0, 0, 0, 0, 0 },
18176b301a05SRhyland Klein };
18186b301a05SRhyland Klein
18196b301a05SRhyland Klein static const struct clk_div_table pll_vco_post_div_table[] = {
18206b301a05SRhyland Klein { .val = 0, .div = 1 },
18216b301a05SRhyland Klein { .val = 1, .div = 2 },
18226b301a05SRhyland Klein { .val = 2, .div = 3 },
18236b301a05SRhyland Klein { .val = 3, .div = 4 },
18246b301a05SRhyland Klein { .val = 4, .div = 5 },
18256b301a05SRhyland Klein { .val = 5, .div = 6 },
18266b301a05SRhyland Klein { .val = 6, .div = 8 },
18276b301a05SRhyland Klein { .val = 7, .div = 10 },
18286b301a05SRhyland Klein { .val = 8, .div = 12 },
18296b301a05SRhyland Klein { .val = 9, .div = 16 },
18306b301a05SRhyland Klein { .val = 10, .div = 12 },
18316b301a05SRhyland Klein { .val = 11, .div = 16 },
18326b301a05SRhyland Klein { .val = 12, .div = 20 },
18336b301a05SRhyland Klein { .val = 13, .div = 24 },
18346b301a05SRhyland Klein { .val = 14, .div = 32 },
18356b301a05SRhyland Klein { .val = 0, .div = 0 },
18366b301a05SRhyland Klein };
18376b301a05SRhyland Klein
18386b301a05SRhyland Klein static struct tegra_clk_pll_params pll_c4_vco_params = {
18396b301a05SRhyland Klein .input_min = 9600000,
18406b301a05SRhyland Klein .input_max = 800000000,
18416b301a05SRhyland Klein .cf_min = 9600000,
18426b301a05SRhyland Klein .cf_max = 19200000,
18436b301a05SRhyland Klein .vco_min = 500000000,
18446b301a05SRhyland Klein .vco_max = 1080000000,
18456b301a05SRhyland Klein .base_reg = PLLC4_BASE,
18466b301a05SRhyland Klein .misc_reg = PLLC4_MISC0,
18476b301a05SRhyland Klein .lock_mask = PLL_BASE_LOCK,
18486b301a05SRhyland Klein .lock_delay = 300,
18496b301a05SRhyland Klein .max_p = PLL_QLIN_PDIV_MAX,
18506b301a05SRhyland Klein .ext_misc_reg[0] = PLLC4_MISC0,
18516b301a05SRhyland Klein .iddq_reg = PLLC4_BASE,
18526b301a05SRhyland Klein .iddq_bit_idx = PLLSS_IDDQ_BIT,
18536b301a05SRhyland Klein .round_p_to_pdiv = pll_qlin_p_to_pdiv,
18546b301a05SRhyland Klein .pdiv_tohw = pll_qlin_pdiv_to_hw,
18556b301a05SRhyland Klein .mdiv_default = 3,
18566b301a05SRhyland Klein .div_nmp = &pllss_nmp,
18576b301a05SRhyland Klein .freq_table = pll_c4_vco_freq_table,
18586b301a05SRhyland Klein .set_defaults = tegra210_pllc4_set_defaults,
185914050118SRhyland Klein .flags = TEGRA_PLL_USE_LOCK | TEGRA_PLL_VCO_OUT,
18606b301a05SRhyland Klein .calc_rate = tegra210_pll_fixed_mdiv_cfg,
18616b301a05SRhyland Klein };
18626b301a05SRhyland Klein
18636b301a05SRhyland Klein static struct tegra_clk_pll_freq_table pll_m_freq_table[] = {
1864eddb65e7SThierry Reding { 12000000, 800000000, 66, 1, 1, 0 }, /* actual: 792.0 MHz */
1865eddb65e7SThierry Reding { 13000000, 800000000, 61, 1, 1, 0 }, /* actual: 793.0 MHz */
1866eddb65e7SThierry Reding { 38400000, 297600000, 93, 4, 3, 0 },
1867eddb65e7SThierry Reding { 38400000, 400000000, 125, 4, 3, 0 },
1868eddb65e7SThierry Reding { 38400000, 532800000, 111, 4, 2, 0 },
1869eddb65e7SThierry Reding { 38400000, 665600000, 104, 3, 2, 0 },
1870eddb65e7SThierry Reding { 38400000, 800000000, 125, 3, 2, 0 },
1871eddb65e7SThierry Reding { 38400000, 931200000, 97, 4, 1, 0 },
1872eddb65e7SThierry Reding { 38400000, 1065600000, 111, 4, 1, 0 },
1873eddb65e7SThierry Reding { 38400000, 1200000000, 125, 4, 1, 0 },
1874eddb65e7SThierry Reding { 38400000, 1331200000, 104, 3, 1, 0 },
1875eddb65e7SThierry Reding { 38400000, 1459200000, 76, 2, 1, 0 },
1876eddb65e7SThierry Reding { 38400000, 1600000000, 125, 3, 1, 0 },
18776b301a05SRhyland Klein { 0, 0, 0, 0, 0, 0 },
18786b301a05SRhyland Klein };
18796b301a05SRhyland Klein
18806b301a05SRhyland Klein static struct div_nmp pllm_nmp = {
18816b301a05SRhyland Klein .divm_shift = 0,
18826b301a05SRhyland Klein .divm_width = 8,
18836b301a05SRhyland Klein .override_divm_shift = 0,
18846b301a05SRhyland Klein .divn_shift = 8,
18856b301a05SRhyland Klein .divn_width = 8,
18866b301a05SRhyland Klein .override_divn_shift = 8,
18876b301a05SRhyland Klein .divp_shift = 20,
18886b301a05SRhyland Klein .divp_width = 5,
18896b301a05SRhyland Klein .override_divp_shift = 27,
18906b301a05SRhyland Klein };
18916b301a05SRhyland Klein
18926b301a05SRhyland Klein static struct tegra_clk_pll_params pll_m_params = {
18936b301a05SRhyland Klein .input_min = 9600000,
18946b301a05SRhyland Klein .input_max = 500000000,
18956b301a05SRhyland Klein .cf_min = 9600000,
18966b301a05SRhyland Klein .cf_max = 19200000,
18976b301a05SRhyland Klein .vco_min = 800000000,
18986b301a05SRhyland Klein .vco_max = 1866000000,
18996b301a05SRhyland Klein .base_reg = PLLM_BASE,
1900474f2ba2SRhyland Klein .misc_reg = PLLM_MISC2,
19016b301a05SRhyland Klein .lock_mask = PLL_BASE_LOCK,
19026b301a05SRhyland Klein .lock_enable_bit_idx = PLLM_MISC_LOCK_ENABLE,
19036b301a05SRhyland Klein .lock_delay = 300,
1904474f2ba2SRhyland Klein .iddq_reg = PLLM_MISC2,
19056b301a05SRhyland Klein .iddq_bit_idx = PLLM_IDDQ_BIT,
19066b301a05SRhyland Klein .max_p = PLL_QLIN_PDIV_MAX,
1907474f2ba2SRhyland Klein .ext_misc_reg[0] = PLLM_MISC2,
1908d9e65791SJon Hunter .ext_misc_reg[1] = PLLM_MISC1,
19096b301a05SRhyland Klein .round_p_to_pdiv = pll_qlin_p_to_pdiv,
19106b301a05SRhyland Klein .pdiv_tohw = pll_qlin_pdiv_to_hw,
19116b301a05SRhyland Klein .div_nmp = &pllm_nmp,
19126b301a05SRhyland Klein .pmc_divnm_reg = PMC_PLLM_WB0_OVERRIDE,
19136b301a05SRhyland Klein .pmc_divp_reg = PMC_PLLM_WB0_OVERRIDE_2,
19146b301a05SRhyland Klein .freq_table = pll_m_freq_table,
19156b301a05SRhyland Klein .flags = TEGRA_PLL_USE_LOCK | TEGRA_PLL_HAS_LOCK_ENABLE,
19166b301a05SRhyland Klein .calc_rate = tegra210_pll_fixed_mdiv_cfg,
19176b301a05SRhyland Klein };
19186b301a05SRhyland Klein
19196b301a05SRhyland Klein static struct tegra_clk_pll_params pll_mb_params = {
19206b301a05SRhyland Klein .input_min = 9600000,
19216b301a05SRhyland Klein .input_max = 500000000,
19226b301a05SRhyland Klein .cf_min = 9600000,
19236b301a05SRhyland Klein .cf_max = 19200000,
19246b301a05SRhyland Klein .vco_min = 800000000,
19256b301a05SRhyland Klein .vco_max = 1866000000,
19266b301a05SRhyland Klein .base_reg = PLLMB_BASE,
1927474f2ba2SRhyland Klein .misc_reg = PLLMB_MISC1,
19286b301a05SRhyland Klein .lock_mask = PLL_BASE_LOCK,
19296b301a05SRhyland Klein .lock_delay = 300,
1930474f2ba2SRhyland Klein .iddq_reg = PLLMB_MISC1,
19316b301a05SRhyland Klein .iddq_bit_idx = PLLMB_IDDQ_BIT,
19326b301a05SRhyland Klein .max_p = PLL_QLIN_PDIV_MAX,
1933474f2ba2SRhyland Klein .ext_misc_reg[0] = PLLMB_MISC1,
19346b301a05SRhyland Klein .round_p_to_pdiv = pll_qlin_p_to_pdiv,
19356b301a05SRhyland Klein .pdiv_tohw = pll_qlin_pdiv_to_hw,
19366b301a05SRhyland Klein .div_nmp = &pllm_nmp,
19376b301a05SRhyland Klein .freq_table = pll_m_freq_table,
193814050118SRhyland Klein .flags = TEGRA_PLL_USE_LOCK,
19396b301a05SRhyland Klein .set_defaults = tegra210_pllmb_set_defaults,
19406b301a05SRhyland Klein .calc_rate = tegra210_pll_fixed_mdiv_cfg,
19416b301a05SRhyland Klein };
19426b301a05SRhyland Klein
19436b301a05SRhyland Klein
19446b301a05SRhyland Klein static struct tegra_clk_pll_freq_table pll_e_freq_table[] = {
19456b301a05SRhyland Klein /* PLLE special case: use cpcon field to store cml divider value */
19466b301a05SRhyland Klein { 672000000, 100000000, 125, 42, 0, 13 },
19476b301a05SRhyland Klein { 624000000, 100000000, 125, 39, 0, 13 },
19486b301a05SRhyland Klein { 336000000, 100000000, 125, 21, 0, 13 },
19496b301a05SRhyland Klein { 312000000, 100000000, 200, 26, 0, 14 },
19506b301a05SRhyland Klein { 38400000, 100000000, 125, 2, 0, 14 },
19516b301a05SRhyland Klein { 12000000, 100000000, 200, 1, 0, 14 },
19526b301a05SRhyland Klein { 0, 0, 0, 0, 0, 0 },
19536b301a05SRhyland Klein };
19546b301a05SRhyland Klein
19556b301a05SRhyland Klein static struct div_nmp plle_nmp = {
19566b301a05SRhyland Klein .divm_shift = 0,
19576b301a05SRhyland Klein .divm_width = 8,
19586b301a05SRhyland Klein .divn_shift = 8,
19596b301a05SRhyland Klein .divn_width = 8,
19606b301a05SRhyland Klein .divp_shift = 24,
19616b301a05SRhyland Klein .divp_width = 5,
19626b301a05SRhyland Klein };
19636b301a05SRhyland Klein
19646b301a05SRhyland Klein static struct tegra_clk_pll_params pll_e_params = {
19656b301a05SRhyland Klein .input_min = 12000000,
19666b301a05SRhyland Klein .input_max = 800000000,
19676b301a05SRhyland Klein .cf_min = 12000000,
19686b301a05SRhyland Klein .cf_max = 38400000,
19696b301a05SRhyland Klein .vco_min = 1600000000,
19706b301a05SRhyland Klein .vco_max = 2500000000U,
19716b301a05SRhyland Klein .base_reg = PLLE_BASE,
19726b301a05SRhyland Klein .misc_reg = PLLE_MISC0,
19736b301a05SRhyland Klein .aux_reg = PLLE_AUX,
19746b301a05SRhyland Klein .lock_mask = PLLE_MISC_LOCK,
19756b301a05SRhyland Klein .lock_enable_bit_idx = PLLE_MISC_LOCK_ENABLE,
19766b301a05SRhyland Klein .lock_delay = 300,
19776b301a05SRhyland Klein .div_nmp = &plle_nmp,
19786b301a05SRhyland Klein .freq_table = pll_e_freq_table,
19796b301a05SRhyland Klein .flags = TEGRA_PLL_FIXED | TEGRA_PLL_LOCK_MISC | TEGRA_PLL_USE_LOCK |
19806b301a05SRhyland Klein TEGRA_PLL_HAS_LOCK_ENABLE,
19816b301a05SRhyland Klein .fixed_rate = 100000000,
19826b301a05SRhyland Klein .calc_rate = tegra210_pll_fixed_mdiv_cfg,
19836b301a05SRhyland Klein };
19846b301a05SRhyland Klein
19856b301a05SRhyland Klein static struct tegra_clk_pll_freq_table pll_re_vco_freq_table[] = {
1986eddb65e7SThierry Reding { 12000000, 672000000, 56, 1, 1, 0 },
1987eddb65e7SThierry Reding { 13000000, 672000000, 51, 1, 1, 0 }, /* actual: 663.0 MHz */
1988eddb65e7SThierry Reding { 38400000, 672000000, 70, 4, 1, 0 },
19896b301a05SRhyland Klein { 0, 0, 0, 0, 0, 0 },
19906b301a05SRhyland Klein };
19916b301a05SRhyland Klein
19926b301a05SRhyland Klein static struct div_nmp pllre_nmp = {
19936b301a05SRhyland Klein .divm_shift = 0,
19946b301a05SRhyland Klein .divm_width = 8,
19956b301a05SRhyland Klein .divn_shift = 8,
19966b301a05SRhyland Klein .divn_width = 8,
19976b301a05SRhyland Klein .divp_shift = 16,
19986b301a05SRhyland Klein .divp_width = 5,
19996b301a05SRhyland Klein };
20006b301a05SRhyland Klein
20016b301a05SRhyland Klein static struct tegra_clk_pll_params pll_re_vco_params = {
20026b301a05SRhyland Klein .input_min = 9600000,
20036b301a05SRhyland Klein .input_max = 800000000,
20046b301a05SRhyland Klein .cf_min = 9600000,
20056b301a05SRhyland Klein .cf_max = 19200000,
20066b301a05SRhyland Klein .vco_min = 350000000,
20076b301a05SRhyland Klein .vco_max = 700000000,
20086b301a05SRhyland Klein .base_reg = PLLRE_BASE,
20096b301a05SRhyland Klein .misc_reg = PLLRE_MISC0,
20106b301a05SRhyland Klein .lock_mask = PLLRE_MISC_LOCK,
20116b301a05SRhyland Klein .lock_delay = 300,
20126b301a05SRhyland Klein .max_p = PLL_QLIN_PDIV_MAX,
20136b301a05SRhyland Klein .ext_misc_reg[0] = PLLRE_MISC0,
20146b301a05SRhyland Klein .iddq_reg = PLLRE_MISC0,
20156b301a05SRhyland Klein .iddq_bit_idx = PLLRE_IDDQ_BIT,
20166b301a05SRhyland Klein .round_p_to_pdiv = pll_qlin_p_to_pdiv,
20176b301a05SRhyland Klein .pdiv_tohw = pll_qlin_pdiv_to_hw,
20186b301a05SRhyland Klein .div_nmp = &pllre_nmp,
20196b301a05SRhyland Klein .freq_table = pll_re_vco_freq_table,
202014050118SRhyland Klein .flags = TEGRA_PLL_USE_LOCK | TEGRA_PLL_LOCK_MISC | TEGRA_PLL_VCO_OUT,
20216b301a05SRhyland Klein .set_defaults = tegra210_pllre_set_defaults,
20226b301a05SRhyland Klein .calc_rate = tegra210_pll_fixed_mdiv_cfg,
20236b301a05SRhyland Klein };
20246b301a05SRhyland Klein
20256b301a05SRhyland Klein static struct div_nmp pllp_nmp = {
20266b301a05SRhyland Klein .divm_shift = 0,
20276b301a05SRhyland Klein .divm_width = 8,
20286b301a05SRhyland Klein .divn_shift = 10,
20296b301a05SRhyland Klein .divn_width = 8,
20306b301a05SRhyland Klein .divp_shift = 20,
20316b301a05SRhyland Klein .divp_width = 5,
20326b301a05SRhyland Klein };
20336b301a05SRhyland Klein
20346b301a05SRhyland Klein static struct tegra_clk_pll_freq_table pll_p_freq_table[] = {
2035eddb65e7SThierry Reding { 12000000, 408000000, 34, 1, 1, 0 },
2036eddb65e7SThierry Reding { 38400000, 408000000, 85, 8, 1, 0 }, /* cf = 4.8MHz, allowed exception */
20376b301a05SRhyland Klein { 0, 0, 0, 0, 0, 0 },
20386b301a05SRhyland Klein };
20396b301a05SRhyland Klein
20406b301a05SRhyland Klein static struct tegra_clk_pll_params pll_p_params = {
20416b301a05SRhyland Klein .input_min = 9600000,
20426b301a05SRhyland Klein .input_max = 800000000,
20436b301a05SRhyland Klein .cf_min = 9600000,
20446b301a05SRhyland Klein .cf_max = 19200000,
20456b301a05SRhyland Klein .vco_min = 350000000,
20466b301a05SRhyland Klein .vco_max = 700000000,
20476b301a05SRhyland Klein .base_reg = PLLP_BASE,
20486b301a05SRhyland Klein .misc_reg = PLLP_MISC0,
20496b301a05SRhyland Klein .lock_mask = PLL_BASE_LOCK,
20506b301a05SRhyland Klein .lock_delay = 300,
20516b301a05SRhyland Klein .iddq_reg = PLLP_MISC0,
20526b301a05SRhyland Klein .iddq_bit_idx = PLLXP_IDDQ_BIT,
20536b301a05SRhyland Klein .ext_misc_reg[0] = PLLP_MISC0,
20546b301a05SRhyland Klein .ext_misc_reg[1] = PLLP_MISC1,
20556b301a05SRhyland Klein .div_nmp = &pllp_nmp,
20566b301a05SRhyland Klein .freq_table = pll_p_freq_table,
20576b301a05SRhyland Klein .fixed_rate = 408000000,
205814050118SRhyland Klein .flags = TEGRA_PLL_FIXED | TEGRA_PLL_USE_LOCK | TEGRA_PLL_VCO_OUT,
20596b301a05SRhyland Klein .set_defaults = tegra210_pllp_set_defaults,
20606b301a05SRhyland Klein .calc_rate = tegra210_pll_fixed_mdiv_cfg,
20616b301a05SRhyland Klein };
20626b301a05SRhyland Klein
20636b301a05SRhyland Klein static struct tegra_clk_pll_params pll_a1_params = {
20646b301a05SRhyland Klein .input_min = 12000000,
20656b301a05SRhyland Klein .input_max = 700000000,
20666b301a05SRhyland Klein .cf_min = 12000000,
20676b301a05SRhyland Klein .cf_max = 50000000,
20686b301a05SRhyland Klein .vco_min = 600000000,
20696b301a05SRhyland Klein .vco_max = 1200000000,
20706b301a05SRhyland Klein .base_reg = PLLA1_BASE,
20716b301a05SRhyland Klein .misc_reg = PLLA1_MISC0,
20726b301a05SRhyland Klein .lock_mask = PLLCX_BASE_LOCK,
20736b301a05SRhyland Klein .lock_delay = 300,
20749326947fSPeter De Schrijver .iddq_reg = PLLA1_MISC1,
20756b301a05SRhyland Klein .iddq_bit_idx = PLLCX_IDDQ_BIT,
20766b301a05SRhyland Klein .reset_reg = PLLA1_MISC0,
20776b301a05SRhyland Klein .reset_bit_idx = PLLCX_RESET_BIT,
20786b301a05SRhyland Klein .round_p_to_pdiv = pll_qlin_p_to_pdiv,
20796b301a05SRhyland Klein .pdiv_tohw = pll_qlin_pdiv_to_hw,
20806b301a05SRhyland Klein .div_nmp = &pllc_nmp,
20816b301a05SRhyland Klein .ext_misc_reg[0] = PLLA1_MISC0,
20826b301a05SRhyland Klein .ext_misc_reg[1] = PLLA1_MISC1,
20836b301a05SRhyland Klein .ext_misc_reg[2] = PLLA1_MISC2,
20846b301a05SRhyland Klein .ext_misc_reg[3] = PLLA1_MISC3,
20856b301a05SRhyland Klein .freq_table = pll_cx_freq_table,
208614050118SRhyland Klein .flags = TEGRA_PLL_USE_LOCK,
20876b301a05SRhyland Klein .set_defaults = _plla1_set_defaults,
20886b301a05SRhyland Klein .calc_rate = tegra210_pll_fixed_mdiv_cfg,
20896b301a05SRhyland Klein };
20906b301a05SRhyland Klein
20916b301a05SRhyland Klein static struct div_nmp plla_nmp = {
20926b301a05SRhyland Klein .divm_shift = 0,
20936b301a05SRhyland Klein .divm_width = 8,
20946b301a05SRhyland Klein .divn_shift = 8,
20956b301a05SRhyland Klein .divn_width = 8,
20966b301a05SRhyland Klein .divp_shift = 20,
20976b301a05SRhyland Klein .divp_width = 5,
20986b301a05SRhyland Klein };
20996b301a05SRhyland Klein
21006b301a05SRhyland Klein static struct tegra_clk_pll_freq_table pll_a_freq_table[] = {
2101eddb65e7SThierry Reding { 12000000, 282240000, 47, 1, 2, 1, 0xf148 }, /* actual: 282240234 */
2102eddb65e7SThierry Reding { 12000000, 368640000, 61, 1, 2, 1, 0xfe15 }, /* actual: 368640381 */
2103eddb65e7SThierry Reding { 12000000, 240000000, 60, 1, 3, 1, 0 },
2104eddb65e7SThierry Reding { 13000000, 282240000, 43, 1, 2, 1, 0xfd7d }, /* actual: 282239807 */
2105eddb65e7SThierry Reding { 13000000, 368640000, 56, 1, 2, 1, 0x06d8 }, /* actual: 368640137 */
2106eddb65e7SThierry Reding { 13000000, 240000000, 55, 1, 3, 1, 0 }, /* actual: 238.3 MHz */
2107eddb65e7SThierry Reding { 38400000, 282240000, 44, 3, 2, 1, 0xf333 }, /* actual: 282239844 */
2108eddb65e7SThierry Reding { 38400000, 368640000, 57, 3, 2, 1, 0x0333 }, /* actual: 368639844 */
21096b301a05SRhyland Klein { 38400000, 240000000, 75, 3, 3, 1, 0 },
21106b301a05SRhyland Klein { 0, 0, 0, 0, 0, 0, 0 },
21116b301a05SRhyland Klein };
21126b301a05SRhyland Klein
21136b301a05SRhyland Klein static struct tegra_clk_pll_params pll_a_params = {
21146b301a05SRhyland Klein .input_min = 12000000,
21156b301a05SRhyland Klein .input_max = 800000000,
21166b301a05SRhyland Klein .cf_min = 12000000,
21176b301a05SRhyland Klein .cf_max = 19200000,
21186b301a05SRhyland Klein .vco_min = 500000000,
21196b301a05SRhyland Klein .vco_max = 1000000000,
21206b301a05SRhyland Klein .base_reg = PLLA_BASE,
21216b301a05SRhyland Klein .misc_reg = PLLA_MISC0,
21226b301a05SRhyland Klein .lock_mask = PLL_BASE_LOCK,
21236b301a05SRhyland Klein .lock_delay = 300,
21246b301a05SRhyland Klein .round_p_to_pdiv = pll_qlin_p_to_pdiv,
21256b301a05SRhyland Klein .pdiv_tohw = pll_qlin_pdiv_to_hw,
21266b301a05SRhyland Klein .iddq_reg = PLLA_BASE,
21276b301a05SRhyland Klein .iddq_bit_idx = PLLA_IDDQ_BIT,
21286b301a05SRhyland Klein .div_nmp = &plla_nmp,
21296b301a05SRhyland Klein .sdm_din_reg = PLLA_MISC1,
21306b301a05SRhyland Klein .sdm_din_mask = PLLA_SDM_DIN_MASK,
21316b301a05SRhyland Klein .sdm_ctrl_reg = PLLA_MISC2,
21326b301a05SRhyland Klein .sdm_ctrl_en_mask = PLLA_SDM_EN_MASK,
21336b301a05SRhyland Klein .ext_misc_reg[0] = PLLA_MISC0,
21346b301a05SRhyland Klein .ext_misc_reg[1] = PLLA_MISC1,
21356b301a05SRhyland Klein .ext_misc_reg[2] = PLLA_MISC2,
21366b301a05SRhyland Klein .freq_table = pll_a_freq_table,
213714050118SRhyland Klein .flags = TEGRA_PLL_USE_LOCK | TEGRA_MDIV_NEW,
21386b301a05SRhyland Klein .set_defaults = tegra210_plla_set_defaults,
21396b301a05SRhyland Klein .calc_rate = tegra210_pll_fixed_mdiv_cfg,
21406b301a05SRhyland Klein .set_gain = tegra210_clk_pll_set_gain,
21416b301a05SRhyland Klein .adjust_vco = tegra210_clk_adjust_vco_min,
21426b301a05SRhyland Klein };
21436b301a05SRhyland Klein
21446b301a05SRhyland Klein static struct div_nmp plld_nmp = {
21456b301a05SRhyland Klein .divm_shift = 0,
21466b301a05SRhyland Klein .divm_width = 8,
21476b301a05SRhyland Klein .divn_shift = 11,
21486b301a05SRhyland Klein .divn_width = 8,
21496b301a05SRhyland Klein .divp_shift = 20,
21506b301a05SRhyland Klein .divp_width = 3,
21516b301a05SRhyland Klein };
21526b301a05SRhyland Klein
21536b301a05SRhyland Klein static struct tegra_clk_pll_freq_table pll_d_freq_table[] = {
2154eddb65e7SThierry Reding { 12000000, 594000000, 99, 1, 2, 0, 0 },
2155eddb65e7SThierry Reding { 13000000, 594000000, 91, 1, 2, 0, 0xfc4f }, /* actual: 594000183 */
2156eddb65e7SThierry Reding { 38400000, 594000000, 30, 1, 2, 0, 0x0e00 },
21576b301a05SRhyland Klein { 0, 0, 0, 0, 0, 0, 0 },
21586b301a05SRhyland Klein };
21596b301a05SRhyland Klein
21606b301a05SRhyland Klein static struct tegra_clk_pll_params pll_d_params = {
21616b301a05SRhyland Klein .input_min = 12000000,
21626b301a05SRhyland Klein .input_max = 800000000,
21636b301a05SRhyland Klein .cf_min = 12000000,
21646b301a05SRhyland Klein .cf_max = 38400000,
21656b301a05SRhyland Klein .vco_min = 750000000,
21666b301a05SRhyland Klein .vco_max = 1500000000,
21676b301a05SRhyland Klein .base_reg = PLLD_BASE,
21686b301a05SRhyland Klein .misc_reg = PLLD_MISC0,
21696b301a05SRhyland Klein .lock_mask = PLL_BASE_LOCK,
21706b301a05SRhyland Klein .lock_delay = 1000,
21716b301a05SRhyland Klein .iddq_reg = PLLD_MISC0,
21726b301a05SRhyland Klein .iddq_bit_idx = PLLD_IDDQ_BIT,
21736b301a05SRhyland Klein .round_p_to_pdiv = pll_expo_p_to_pdiv,
21746b301a05SRhyland Klein .pdiv_tohw = pll_expo_pdiv_to_hw,
21756b301a05SRhyland Klein .div_nmp = &plld_nmp,
21766b301a05SRhyland Klein .sdm_din_reg = PLLD_MISC0,
21776b301a05SRhyland Klein .sdm_din_mask = PLLA_SDM_DIN_MASK,
21786b301a05SRhyland Klein .sdm_ctrl_reg = PLLD_MISC0,
21796b301a05SRhyland Klein .sdm_ctrl_en_mask = PLLD_SDM_EN_MASK,
21806b301a05SRhyland Klein .ext_misc_reg[0] = PLLD_MISC0,
21816b301a05SRhyland Klein .ext_misc_reg[1] = PLLD_MISC1,
21826b301a05SRhyland Klein .freq_table = pll_d_freq_table,
218314050118SRhyland Klein .flags = TEGRA_PLL_USE_LOCK,
21846b301a05SRhyland Klein .mdiv_default = 1,
21856b301a05SRhyland Klein .set_defaults = tegra210_plld_set_defaults,
21866b301a05SRhyland Klein .calc_rate = tegra210_pll_fixed_mdiv_cfg,
21876b301a05SRhyland Klein .set_gain = tegra210_clk_pll_set_gain,
21886b301a05SRhyland Klein .adjust_vco = tegra210_clk_adjust_vco_min,
21896b301a05SRhyland Klein };
21906b301a05SRhyland Klein
21916b301a05SRhyland Klein static struct tegra_clk_pll_freq_table tegra210_pll_d2_freq_table[] = {
2192eddb65e7SThierry Reding { 12000000, 594000000, 99, 1, 2, 0, 0xf000 },
2193eddb65e7SThierry Reding { 13000000, 594000000, 91, 1, 2, 0, 0xfc4f }, /* actual: 594000183 */
2194eddb65e7SThierry Reding { 38400000, 594000000, 30, 1, 2, 0, 0x0e00 },
21956b301a05SRhyland Klein { 0, 0, 0, 0, 0, 0, 0 },
21966b301a05SRhyland Klein };
21976b301a05SRhyland Klein
21986b301a05SRhyland Klein /* s/w policy, always tegra_pll_ref */
21996b301a05SRhyland Klein static struct tegra_clk_pll_params pll_d2_params = {
22006b301a05SRhyland Klein .input_min = 12000000,
22016b301a05SRhyland Klein .input_max = 800000000,
22026b301a05SRhyland Klein .cf_min = 12000000,
22036b301a05SRhyland Klein .cf_max = 38400000,
22046b301a05SRhyland Klein .vco_min = 750000000,
22056b301a05SRhyland Klein .vco_max = 1500000000,
22066b301a05SRhyland Klein .base_reg = PLLD2_BASE,
22076b301a05SRhyland Klein .misc_reg = PLLD2_MISC0,
22086b301a05SRhyland Klein .lock_mask = PLL_BASE_LOCK,
22096b301a05SRhyland Klein .lock_delay = 300,
22106b301a05SRhyland Klein .iddq_reg = PLLD2_BASE,
22116b301a05SRhyland Klein .iddq_bit_idx = PLLSS_IDDQ_BIT,
22126b301a05SRhyland Klein .sdm_din_reg = PLLD2_MISC3,
22136b301a05SRhyland Klein .sdm_din_mask = PLLA_SDM_DIN_MASK,
22146b301a05SRhyland Klein .sdm_ctrl_reg = PLLD2_MISC1,
22156b301a05SRhyland Klein .sdm_ctrl_en_mask = PLLD2_SDM_EN_MASK,
2216e2f71656SThierry Reding /* disable spread-spectrum for pll_d2 */
2217e2f71656SThierry Reding .ssc_ctrl_reg = 0,
2218e2f71656SThierry Reding .ssc_ctrl_en_mask = 0,
22196b301a05SRhyland Klein .round_p_to_pdiv = pll_qlin_p_to_pdiv,
22206b301a05SRhyland Klein .pdiv_tohw = pll_qlin_pdiv_to_hw,
22216b301a05SRhyland Klein .div_nmp = &pllss_nmp,
22226b301a05SRhyland Klein .ext_misc_reg[0] = PLLD2_MISC0,
22236b301a05SRhyland Klein .ext_misc_reg[1] = PLLD2_MISC1,
22246b301a05SRhyland Klein .ext_misc_reg[2] = PLLD2_MISC2,
22256b301a05SRhyland Klein .ext_misc_reg[3] = PLLD2_MISC3,
22266b301a05SRhyland Klein .max_p = PLL_QLIN_PDIV_MAX,
22276b301a05SRhyland Klein .mdiv_default = 1,
22286b301a05SRhyland Klein .freq_table = tegra210_pll_d2_freq_table,
22296b301a05SRhyland Klein .set_defaults = tegra210_plld2_set_defaults,
223014050118SRhyland Klein .flags = TEGRA_PLL_USE_LOCK,
22316b301a05SRhyland Klein .calc_rate = tegra210_pll_fixed_mdiv_cfg,
22326b301a05SRhyland Klein .set_gain = tegra210_clk_pll_set_gain,
22336b301a05SRhyland Klein .adjust_vco = tegra210_clk_adjust_vco_min,
22346b301a05SRhyland Klein };
22356b301a05SRhyland Klein
22366b301a05SRhyland Klein static struct tegra_clk_pll_freq_table pll_dp_freq_table[] = {
2237eddb65e7SThierry Reding { 12000000, 270000000, 90, 1, 4, 0, 0xf000 },
2238eddb65e7SThierry Reding { 13000000, 270000000, 83, 1, 4, 0, 0xf000 }, /* actual: 269.8 MHz */
2239eddb65e7SThierry Reding { 38400000, 270000000, 28, 1, 4, 0, 0xf400 },
22406b301a05SRhyland Klein { 0, 0, 0, 0, 0, 0, 0 },
22416b301a05SRhyland Klein };
22426b301a05SRhyland Klein
22436b301a05SRhyland Klein static struct tegra_clk_pll_params pll_dp_params = {
22446b301a05SRhyland Klein .input_min = 12000000,
22456b301a05SRhyland Klein .input_max = 800000000,
22466b301a05SRhyland Klein .cf_min = 12000000,
22476b301a05SRhyland Klein .cf_max = 38400000,
22486b301a05SRhyland Klein .vco_min = 750000000,
22496b301a05SRhyland Klein .vco_max = 1500000000,
22506b301a05SRhyland Klein .base_reg = PLLDP_BASE,
22516b301a05SRhyland Klein .misc_reg = PLLDP_MISC,
22526b301a05SRhyland Klein .lock_mask = PLL_BASE_LOCK,
22536b301a05SRhyland Klein .lock_delay = 300,
22546b301a05SRhyland Klein .iddq_reg = PLLDP_BASE,
22556b301a05SRhyland Klein .iddq_bit_idx = PLLSS_IDDQ_BIT,
22566b301a05SRhyland Klein .sdm_din_reg = PLLDP_SS_CTRL2,
22576b301a05SRhyland Klein .sdm_din_mask = PLLA_SDM_DIN_MASK,
22586b301a05SRhyland Klein .sdm_ctrl_reg = PLLDP_SS_CFG,
22596b301a05SRhyland Klein .sdm_ctrl_en_mask = PLLDP_SDM_EN_MASK,
22606b301a05SRhyland Klein .ssc_ctrl_reg = PLLDP_SS_CFG,
22616b301a05SRhyland Klein .ssc_ctrl_en_mask = PLLDP_SSC_EN_MASK,
22626b301a05SRhyland Klein .round_p_to_pdiv = pll_qlin_p_to_pdiv,
22636b301a05SRhyland Klein .pdiv_tohw = pll_qlin_pdiv_to_hw,
22646b301a05SRhyland Klein .div_nmp = &pllss_nmp,
22656b301a05SRhyland Klein .ext_misc_reg[0] = PLLDP_MISC,
22666b301a05SRhyland Klein .ext_misc_reg[1] = PLLDP_SS_CFG,
22676b301a05SRhyland Klein .ext_misc_reg[2] = PLLDP_SS_CTRL1,
22686b301a05SRhyland Klein .ext_misc_reg[3] = PLLDP_SS_CTRL2,
22696b301a05SRhyland Klein .max_p = PLL_QLIN_PDIV_MAX,
22706b301a05SRhyland Klein .mdiv_default = 1,
22716b301a05SRhyland Klein .freq_table = pll_dp_freq_table,
22726b301a05SRhyland Klein .set_defaults = tegra210_plldp_set_defaults,
227314050118SRhyland Klein .flags = TEGRA_PLL_USE_LOCK,
22746b301a05SRhyland Klein .calc_rate = tegra210_pll_fixed_mdiv_cfg,
22756b301a05SRhyland Klein .set_gain = tegra210_clk_pll_set_gain,
22766b301a05SRhyland Klein .adjust_vco = tegra210_clk_adjust_vco_min,
22776b301a05SRhyland Klein };
22786b301a05SRhyland Klein
22796b301a05SRhyland Klein static struct div_nmp pllu_nmp = {
22806b301a05SRhyland Klein .divm_shift = 0,
22816b301a05SRhyland Klein .divm_width = 8,
22826b301a05SRhyland Klein .divn_shift = 8,
22836b301a05SRhyland Klein .divn_width = 8,
22846b301a05SRhyland Klein .divp_shift = 16,
22856b301a05SRhyland Klein .divp_width = 5,
22866b301a05SRhyland Klein };
22876b301a05SRhyland Klein
22886b301a05SRhyland Klein static struct tegra_clk_pll_freq_table pll_u_freq_table[] = {
22890d34dfbfSJC Kuo { 12000000, 480000000, 40, 1, 1, 0 },
22900d34dfbfSJC Kuo { 13000000, 480000000, 36, 1, 1, 0 }, /* actual: 468.0 MHz */
22910d34dfbfSJC Kuo { 38400000, 480000000, 25, 2, 1, 0 },
22926b301a05SRhyland Klein { 0, 0, 0, 0, 0, 0 },
22936b301a05SRhyland Klein };
22946b301a05SRhyland Klein
22956b301a05SRhyland Klein static struct tegra_clk_pll_params pll_u_vco_params = {
22966b301a05SRhyland Klein .input_min = 9600000,
22976b301a05SRhyland Klein .input_max = 800000000,
22986b301a05SRhyland Klein .cf_min = 9600000,
22996b301a05SRhyland Klein .cf_max = 19200000,
23006b301a05SRhyland Klein .vco_min = 350000000,
23016b301a05SRhyland Klein .vco_max = 700000000,
23026b301a05SRhyland Klein .base_reg = PLLU_BASE,
23036b301a05SRhyland Klein .misc_reg = PLLU_MISC0,
23046b301a05SRhyland Klein .lock_mask = PLL_BASE_LOCK,
23056b301a05SRhyland Klein .lock_delay = 1000,
23066b301a05SRhyland Klein .iddq_reg = PLLU_MISC0,
23076b301a05SRhyland Klein .iddq_bit_idx = PLLU_IDDQ_BIT,
23086b301a05SRhyland Klein .ext_misc_reg[0] = PLLU_MISC0,
23096b301a05SRhyland Klein .ext_misc_reg[1] = PLLU_MISC1,
23106b301a05SRhyland Klein .round_p_to_pdiv = pll_qlin_p_to_pdiv,
23116b301a05SRhyland Klein .pdiv_tohw = pll_qlin_pdiv_to_hw,
23126b301a05SRhyland Klein .div_nmp = &pllu_nmp,
23136b301a05SRhyland Klein .freq_table = pll_u_freq_table,
231414050118SRhyland Klein .flags = TEGRA_PLLU | TEGRA_PLL_USE_LOCK | TEGRA_PLL_VCO_OUT,
2315e745f992SPeter De Schrijver };
2316e745f992SPeter De Schrijver
2317e745f992SPeter De Schrijver struct utmi_clk_param {
2318e745f992SPeter De Schrijver /* Oscillator Frequency in KHz */
2319e745f992SPeter De Schrijver u32 osc_frequency;
2320e745f992SPeter De Schrijver /* UTMIP PLL Enable Delay Count */
2321e745f992SPeter De Schrijver u8 enable_delay_count;
2322e745f992SPeter De Schrijver /* UTMIP PLL Stable count */
2323e745f992SPeter De Schrijver u16 stable_count;
2324e745f992SPeter De Schrijver /* UTMIP PLL Active delay count */
2325e745f992SPeter De Schrijver u8 active_delay_count;
2326e745f992SPeter De Schrijver /* UTMIP PLL Xtal frequency count */
2327e745f992SPeter De Schrijver u16 xtal_freq_count;
2328e745f992SPeter De Schrijver };
2329e745f992SPeter De Schrijver
2330e745f992SPeter De Schrijver static const struct utmi_clk_param utmi_parameters[] = {
2331e745f992SPeter De Schrijver {
2332e745f992SPeter De Schrijver .osc_frequency = 38400000, .enable_delay_count = 0x0,
2333e745f992SPeter De Schrijver .stable_count = 0x0, .active_delay_count = 0x6,
2334e745f992SPeter De Schrijver .xtal_freq_count = 0x80
2335e745f992SPeter De Schrijver }, {
2336e745f992SPeter De Schrijver .osc_frequency = 13000000, .enable_delay_count = 0x02,
2337e745f992SPeter De Schrijver .stable_count = 0x33, .active_delay_count = 0x05,
2338e745f992SPeter De Schrijver .xtal_freq_count = 0x7f
2339e745f992SPeter De Schrijver }, {
2340e745f992SPeter De Schrijver .osc_frequency = 19200000, .enable_delay_count = 0x03,
2341e745f992SPeter De Schrijver .stable_count = 0x4b, .active_delay_count = 0x06,
2342e745f992SPeter De Schrijver .xtal_freq_count = 0xbb
2343e745f992SPeter De Schrijver }, {
2344e745f992SPeter De Schrijver .osc_frequency = 12000000, .enable_delay_count = 0x02,
2345e745f992SPeter De Schrijver .stable_count = 0x2f, .active_delay_count = 0x08,
2346e745f992SPeter De Schrijver .xtal_freq_count = 0x76
2347e745f992SPeter De Schrijver }, {
2348e745f992SPeter De Schrijver .osc_frequency = 26000000, .enable_delay_count = 0x04,
2349e745f992SPeter De Schrijver .stable_count = 0x66, .active_delay_count = 0x09,
2350e745f992SPeter De Schrijver .xtal_freq_count = 0xfe
2351e745f992SPeter De Schrijver }, {
2352e745f992SPeter De Schrijver .osc_frequency = 16800000, .enable_delay_count = 0x03,
2353e745f992SPeter De Schrijver .stable_count = 0x41, .active_delay_count = 0x0a,
2354e745f992SPeter De Schrijver .xtal_freq_count = 0xa4
2355e745f992SPeter De Schrijver },
23566b301a05SRhyland Klein };
23576b301a05SRhyland Klein
23586b301a05SRhyland Klein static struct tegra_clk tegra210_clks[tegra_clk_max] __initdata = {
23596b301a05SRhyland Klein [tegra_clk_ispb] = { .dt_id = TEGRA210_CLK_ISPB, .present = true },
23606b301a05SRhyland Klein [tegra_clk_rtc] = { .dt_id = TEGRA210_CLK_RTC, .present = true },
23616b301a05SRhyland Klein [tegra_clk_timer] = { .dt_id = TEGRA210_CLK_TIMER, .present = true },
23626b301a05SRhyland Klein [tegra_clk_uarta_8] = { .dt_id = TEGRA210_CLK_UARTA, .present = true },
23636b301a05SRhyland Klein [tegra_clk_i2s1] = { .dt_id = TEGRA210_CLK_I2S1, .present = true },
23646b301a05SRhyland Klein [tegra_clk_i2c1] = { .dt_id = TEGRA210_CLK_I2C1, .present = true },
23656b301a05SRhyland Klein [tegra_clk_sdmmc1_9] = { .dt_id = TEGRA210_CLK_SDMMC1, .present = true },
23666b301a05SRhyland Klein [tegra_clk_pwm] = { .dt_id = TEGRA210_CLK_PWM, .present = true },
23676b301a05SRhyland Klein [tegra_clk_i2s2] = { .dt_id = TEGRA210_CLK_I2S2, .present = true },
23686b301a05SRhyland Klein [tegra_clk_usbd] = { .dt_id = TEGRA210_CLK_USBD, .present = true },
23696b301a05SRhyland Klein [tegra_clk_isp_9] = { .dt_id = TEGRA210_CLK_ISP, .present = true },
23706b301a05SRhyland Klein [tegra_clk_disp2_8] = { .dt_id = TEGRA210_CLK_DISP2, .present = true },
23716b301a05SRhyland Klein [tegra_clk_disp1_8] = { .dt_id = TEGRA210_CLK_DISP1, .present = true },
23726b301a05SRhyland Klein [tegra_clk_host1x_9] = { .dt_id = TEGRA210_CLK_HOST1X, .present = true },
23736b301a05SRhyland Klein [tegra_clk_i2s0] = { .dt_id = TEGRA210_CLK_I2S0, .present = true },
23746b301a05SRhyland Klein [tegra_clk_apbdma] = { .dt_id = TEGRA210_CLK_APBDMA, .present = true },
23756b301a05SRhyland Klein [tegra_clk_kfuse] = { .dt_id = TEGRA210_CLK_KFUSE, .present = true },
23766b301a05SRhyland Klein [tegra_clk_sbc1_9] = { .dt_id = TEGRA210_CLK_SBC1, .present = true },
23776b301a05SRhyland Klein [tegra_clk_sbc2_9] = { .dt_id = TEGRA210_CLK_SBC2, .present = true },
23786b301a05SRhyland Klein [tegra_clk_sbc3_9] = { .dt_id = TEGRA210_CLK_SBC3, .present = true },
23796b301a05SRhyland Klein [tegra_clk_i2c5] = { .dt_id = TEGRA210_CLK_I2C5, .present = true },
23806b301a05SRhyland Klein [tegra_clk_csi] = { .dt_id = TEGRA210_CLK_CSI, .present = true },
23816b301a05SRhyland Klein [tegra_clk_i2c2] = { .dt_id = TEGRA210_CLK_I2C2, .present = true },
23826b301a05SRhyland Klein [tegra_clk_uartc_8] = { .dt_id = TEGRA210_CLK_UARTC, .present = true },
23836b301a05SRhyland Klein [tegra_clk_mipi_cal] = { .dt_id = TEGRA210_CLK_MIPI_CAL, .present = true },
23846b301a05SRhyland Klein [tegra_clk_usb2] = { .dt_id = TEGRA210_CLK_USB2, .present = true },
23856b301a05SRhyland Klein [tegra_clk_bsev] = { .dt_id = TEGRA210_CLK_BSEV, .present = true },
23866b301a05SRhyland Klein [tegra_clk_uartd_8] = { .dt_id = TEGRA210_CLK_UARTD, .present = true },
23876b301a05SRhyland Klein [tegra_clk_i2c3] = { .dt_id = TEGRA210_CLK_I2C3, .present = true },
23886b301a05SRhyland Klein [tegra_clk_sbc4_9] = { .dt_id = TEGRA210_CLK_SBC4, .present = true },
23896b301a05SRhyland Klein [tegra_clk_sdmmc3_9] = { .dt_id = TEGRA210_CLK_SDMMC3, .present = true },
23906b301a05SRhyland Klein [tegra_clk_pcie] = { .dt_id = TEGRA210_CLK_PCIE, .present = true },
23916b301a05SRhyland Klein [tegra_clk_owr_8] = { .dt_id = TEGRA210_CLK_OWR, .present = true },
23926b301a05SRhyland Klein [tegra_clk_afi] = { .dt_id = TEGRA210_CLK_AFI, .present = true },
23936b301a05SRhyland Klein [tegra_clk_csite_8] = { .dt_id = TEGRA210_CLK_CSITE, .present = true },
23946b301a05SRhyland Klein [tegra_clk_soc_therm_8] = { .dt_id = TEGRA210_CLK_SOC_THERM, .present = true },
23956b301a05SRhyland Klein [tegra_clk_dtv] = { .dt_id = TEGRA210_CLK_DTV, .present = true },
23966b301a05SRhyland Klein [tegra_clk_i2cslow] = { .dt_id = TEGRA210_CLK_I2CSLOW, .present = true },
23976b301a05SRhyland Klein [tegra_clk_tsec_8] = { .dt_id = TEGRA210_CLK_TSEC, .present = true },
23986b301a05SRhyland Klein [tegra_clk_xusb_host] = { .dt_id = TEGRA210_CLK_XUSB_HOST, .present = true },
23996b301a05SRhyland Klein [tegra_clk_csus] = { .dt_id = TEGRA210_CLK_CSUS, .present = true },
24006b301a05SRhyland Klein [tegra_clk_mselect] = { .dt_id = TEGRA210_CLK_MSELECT, .present = true },
24016b301a05SRhyland Klein [tegra_clk_tsensor] = { .dt_id = TEGRA210_CLK_TSENSOR, .present = true },
24026b301a05SRhyland Klein [tegra_clk_i2s3] = { .dt_id = TEGRA210_CLK_I2S3, .present = true },
24036b301a05SRhyland Klein [tegra_clk_i2s4] = { .dt_id = TEGRA210_CLK_I2S4, .present = true },
24046b301a05SRhyland Klein [tegra_clk_i2c4] = { .dt_id = TEGRA210_CLK_I2C4, .present = true },
24056b301a05SRhyland Klein [tegra_clk_d_audio] = { .dt_id = TEGRA210_CLK_D_AUDIO, .present = true },
24066b301a05SRhyland Klein [tegra_clk_hda2codec_2x_8] = { .dt_id = TEGRA210_CLK_HDA2CODEC_2X, .present = true },
24076b301a05SRhyland Klein [tegra_clk_spdif_2x] = { .dt_id = TEGRA210_CLK_SPDIF_2X, .present = true },
24086b301a05SRhyland Klein [tegra_clk_actmon] = { .dt_id = TEGRA210_CLK_ACTMON, .present = true },
24096b301a05SRhyland Klein [tegra_clk_extern1] = { .dt_id = TEGRA210_CLK_EXTERN1, .present = true },
24106b301a05SRhyland Klein [tegra_clk_extern2] = { .dt_id = TEGRA210_CLK_EXTERN2, .present = true },
24116b301a05SRhyland Klein [tegra_clk_extern3] = { .dt_id = TEGRA210_CLK_EXTERN3, .present = true },
24126b301a05SRhyland Klein [tegra_clk_sata_oob_8] = { .dt_id = TEGRA210_CLK_SATA_OOB, .present = true },
24136b301a05SRhyland Klein [tegra_clk_sata_8] = { .dt_id = TEGRA210_CLK_SATA, .present = true },
24146b301a05SRhyland Klein [tegra_clk_hda_8] = { .dt_id = TEGRA210_CLK_HDA, .present = true },
24156b301a05SRhyland Klein [tegra_clk_hda2hdmi] = { .dt_id = TEGRA210_CLK_HDA2HDMI, .present = true },
24166b301a05SRhyland Klein [tegra_clk_cilab] = { .dt_id = TEGRA210_CLK_CILAB, .present = true },
24176b301a05SRhyland Klein [tegra_clk_cilcd] = { .dt_id = TEGRA210_CLK_CILCD, .present = true },
24186b301a05SRhyland Klein [tegra_clk_cile] = { .dt_id = TEGRA210_CLK_CILE, .present = true },
24196b301a05SRhyland Klein [tegra_clk_dsialp] = { .dt_id = TEGRA210_CLK_DSIALP, .present = true },
24206b301a05SRhyland Klein [tegra_clk_dsiblp] = { .dt_id = TEGRA210_CLK_DSIBLP, .present = true },
24216b301a05SRhyland Klein [tegra_clk_entropy_8] = { .dt_id = TEGRA210_CLK_ENTROPY, .present = true },
24226b301a05SRhyland Klein [tegra_clk_xusb_ss] = { .dt_id = TEGRA210_CLK_XUSB_SS, .present = true },
24236b301a05SRhyland Klein [tegra_clk_i2c6] = { .dt_id = TEGRA210_CLK_I2C6, .present = true },
24246b301a05SRhyland Klein [tegra_clk_vim2_clk] = { .dt_id = TEGRA210_CLK_VIM2_CLK, .present = true },
24256b301a05SRhyland Klein [tegra_clk_clk72Mhz_8] = { .dt_id = TEGRA210_CLK_CLK72MHZ, .present = true },
24266b301a05SRhyland Klein [tegra_clk_vic03_8] = { .dt_id = TEGRA210_CLK_VIC03, .present = true },
24276b301a05SRhyland Klein [tegra_clk_dpaux] = { .dt_id = TEGRA210_CLK_DPAUX, .present = true },
242898c4b366SThierry Reding [tegra_clk_dpaux1] = { .dt_id = TEGRA210_CLK_DPAUX1, .present = true },
24296b301a05SRhyland Klein [tegra_clk_sor0] = { .dt_id = TEGRA210_CLK_SOR0, .present = true },
2430da8d1a35SThierry Reding [tegra_clk_sor0_out] = { .dt_id = TEGRA210_CLK_SOR0_OUT, .present = true },
2431e452b818SThierry Reding [tegra_clk_sor1] = { .dt_id = TEGRA210_CLK_SOR1, .present = true },
2432991a051eSThierry Reding [tegra_clk_sor1_out] = { .dt_id = TEGRA210_CLK_SOR1_OUT, .present = true },
24336b301a05SRhyland Klein [tegra_clk_gpu] = { .dt_id = TEGRA210_CLK_GPU, .present = true },
24346b301a05SRhyland Klein [tegra_clk_pll_g_ref] = { .dt_id = TEGRA210_CLK_PLL_G_REF, .present = true, },
24356b301a05SRhyland Klein [tegra_clk_uartb_8] = { .dt_id = TEGRA210_CLK_UARTB, .present = true },
24366b301a05SRhyland Klein [tegra_clk_spdif_in_8] = { .dt_id = TEGRA210_CLK_SPDIF_IN, .present = true },
24376b301a05SRhyland Klein [tegra_clk_spdif_out] = { .dt_id = TEGRA210_CLK_SPDIF_OUT, .present = true },
24386b301a05SRhyland Klein [tegra_clk_vi_10] = { .dt_id = TEGRA210_CLK_VI, .present = true },
24396b301a05SRhyland Klein [tegra_clk_vi_sensor_8] = { .dt_id = TEGRA210_CLK_VI_SENSOR, .present = true },
24406b301a05SRhyland Klein [tegra_clk_fuse] = { .dt_id = TEGRA210_CLK_FUSE, .present = true },
24416b301a05SRhyland Klein [tegra_clk_fuse_burn] = { .dt_id = TEGRA210_CLK_FUSE_BURN, .present = true },
24426b301a05SRhyland Klein [tegra_clk_clk_32k] = { .dt_id = TEGRA210_CLK_CLK_32K, .present = true },
24436b301a05SRhyland Klein [tegra_clk_clk_m] = { .dt_id = TEGRA210_CLK_CLK_M, .present = true },
24442b50e49bSSowjanya Komatineni [tegra_clk_osc] = { .dt_id = TEGRA210_CLK_OSC, .present = true },
24459a85eb4dSSowjanya Komatineni [tegra_clk_osc_div2] = { .dt_id = TEGRA210_CLK_OSC_DIV2, .present = true },
24469a85eb4dSSowjanya Komatineni [tegra_clk_osc_div4] = { .dt_id = TEGRA210_CLK_OSC_DIV4, .present = true },
24476b301a05SRhyland Klein [tegra_clk_pll_ref] = { .dt_id = TEGRA210_CLK_PLL_REF, .present = true },
24486b301a05SRhyland Klein [tegra_clk_pll_c] = { .dt_id = TEGRA210_CLK_PLL_C, .present = true },
24496b301a05SRhyland Klein [tegra_clk_pll_c_out1] = { .dt_id = TEGRA210_CLK_PLL_C_OUT1, .present = true },
24506b301a05SRhyland Klein [tegra_clk_pll_c2] = { .dt_id = TEGRA210_CLK_PLL_C2, .present = true },
24516b301a05SRhyland Klein [tegra_clk_pll_c3] = { .dt_id = TEGRA210_CLK_PLL_C3, .present = true },
24526b301a05SRhyland Klein [tegra_clk_pll_m] = { .dt_id = TEGRA210_CLK_PLL_M, .present = true },
24536b301a05SRhyland Klein [tegra_clk_pll_p] = { .dt_id = TEGRA210_CLK_PLL_P, .present = true },
24546b301a05SRhyland Klein [tegra_clk_pll_p_out1] = { .dt_id = TEGRA210_CLK_PLL_P_OUT1, .present = true },
24556b301a05SRhyland Klein [tegra_clk_pll_p_out3] = { .dt_id = TEGRA210_CLK_PLL_P_OUT3, .present = true },
24566b301a05SRhyland Klein [tegra_clk_pll_p_out4_cpu] = { .dt_id = TEGRA210_CLK_PLL_P_OUT4, .present = true },
24576b301a05SRhyland Klein [tegra_clk_pll_p_out_hsio] = { .dt_id = TEGRA210_CLK_PLL_P_OUT_HSIO, .present = true },
24586b301a05SRhyland Klein [tegra_clk_pll_p_out_xusb] = { .dt_id = TEGRA210_CLK_PLL_P_OUT_XUSB, .present = true },
24596b301a05SRhyland Klein [tegra_clk_pll_p_out_cpu] = { .dt_id = TEGRA210_CLK_PLL_P_OUT_CPU, .present = true },
24606b301a05SRhyland Klein [tegra_clk_pll_p_out_adsp] = { .dt_id = TEGRA210_CLK_PLL_P_OUT_ADSP, .present = true },
24616b301a05SRhyland Klein [tegra_clk_pll_a] = { .dt_id = TEGRA210_CLK_PLL_A, .present = true },
24626b301a05SRhyland Klein [tegra_clk_pll_a_out0] = { .dt_id = TEGRA210_CLK_PLL_A_OUT0, .present = true },
24636b301a05SRhyland Klein [tegra_clk_pll_d] = { .dt_id = TEGRA210_CLK_PLL_D, .present = true },
24646b301a05SRhyland Klein [tegra_clk_pll_d_out0] = { .dt_id = TEGRA210_CLK_PLL_D_OUT0, .present = true },
24656b301a05SRhyland Klein [tegra_clk_pll_d2] = { .dt_id = TEGRA210_CLK_PLL_D2, .present = true },
24666b301a05SRhyland Klein [tegra_clk_pll_d2_out0] = { .dt_id = TEGRA210_CLK_PLL_D2_OUT0, .present = true },
24676b301a05SRhyland Klein [tegra_clk_pll_u] = { .dt_id = TEGRA210_CLK_PLL_U, .present = true },
24686b301a05SRhyland Klein [tegra_clk_pll_u_out] = { .dt_id = TEGRA210_CLK_PLL_U_OUT, .present = true },
24696b301a05SRhyland Klein [tegra_clk_pll_u_out1] = { .dt_id = TEGRA210_CLK_PLL_U_OUT1, .present = true },
24706b301a05SRhyland Klein [tegra_clk_pll_u_out2] = { .dt_id = TEGRA210_CLK_PLL_U_OUT2, .present = true },
24716b301a05SRhyland Klein [tegra_clk_pll_u_480m] = { .dt_id = TEGRA210_CLK_PLL_U_480M, .present = true },
24726b301a05SRhyland Klein [tegra_clk_pll_u_60m] = { .dt_id = TEGRA210_CLK_PLL_U_60M, .present = true },
24736b301a05SRhyland Klein [tegra_clk_pll_u_48m] = { .dt_id = TEGRA210_CLK_PLL_U_48M, .present = true },
24746b301a05SRhyland Klein [tegra_clk_pll_x] = { .dt_id = TEGRA210_CLK_PLL_X, .present = true },
24756b301a05SRhyland Klein [tegra_clk_pll_x_out0] = { .dt_id = TEGRA210_CLK_PLL_X_OUT0, .present = true },
24766b301a05SRhyland Klein [tegra_clk_pll_re_vco] = { .dt_id = TEGRA210_CLK_PLL_RE_VCO, .present = true },
24776b301a05SRhyland Klein [tegra_clk_pll_re_out] = { .dt_id = TEGRA210_CLK_PLL_RE_OUT, .present = true },
24786b301a05SRhyland Klein [tegra_clk_spdif_in_sync] = { .dt_id = TEGRA210_CLK_SPDIF_IN_SYNC, .present = true },
24796b301a05SRhyland Klein [tegra_clk_i2s0_sync] = { .dt_id = TEGRA210_CLK_I2S0_SYNC, .present = true },
24806b301a05SRhyland Klein [tegra_clk_i2s1_sync] = { .dt_id = TEGRA210_CLK_I2S1_SYNC, .present = true },
24816b301a05SRhyland Klein [tegra_clk_i2s2_sync] = { .dt_id = TEGRA210_CLK_I2S2_SYNC, .present = true },
24826b301a05SRhyland Klein [tegra_clk_i2s3_sync] = { .dt_id = TEGRA210_CLK_I2S3_SYNC, .present = true },
24836b301a05SRhyland Klein [tegra_clk_i2s4_sync] = { .dt_id = TEGRA210_CLK_I2S4_SYNC, .present = true },
24846b301a05SRhyland Klein [tegra_clk_vimclk_sync] = { .dt_id = TEGRA210_CLK_VIMCLK_SYNC, .present = true },
24856b301a05SRhyland Klein [tegra_clk_audio0] = { .dt_id = TEGRA210_CLK_AUDIO0, .present = true },
24866b301a05SRhyland Klein [tegra_clk_audio1] = { .dt_id = TEGRA210_CLK_AUDIO1, .present = true },
24876b301a05SRhyland Klein [tegra_clk_audio2] = { .dt_id = TEGRA210_CLK_AUDIO2, .present = true },
24886b301a05SRhyland Klein [tegra_clk_audio3] = { .dt_id = TEGRA210_CLK_AUDIO3, .present = true },
24896b301a05SRhyland Klein [tegra_clk_audio4] = { .dt_id = TEGRA210_CLK_AUDIO4, .present = true },
24906b301a05SRhyland Klein [tegra_clk_spdif] = { .dt_id = TEGRA210_CLK_SPDIF, .present = true },
24916b301a05SRhyland Klein [tegra_clk_xusb_gate] = { .dt_id = TEGRA210_CLK_XUSB_GATE, .present = true },
24926b301a05SRhyland Klein [tegra_clk_xusb_host_src_8] = { .dt_id = TEGRA210_CLK_XUSB_HOST_SRC, .present = true },
24936b301a05SRhyland Klein [tegra_clk_xusb_falcon_src_8] = { .dt_id = TEGRA210_CLK_XUSB_FALCON_SRC, .present = true },
24946b301a05SRhyland Klein [tegra_clk_xusb_fs_src] = { .dt_id = TEGRA210_CLK_XUSB_FS_SRC, .present = true },
24956b301a05SRhyland Klein [tegra_clk_xusb_ss_src_8] = { .dt_id = TEGRA210_CLK_XUSB_SS_SRC, .present = true },
24966b301a05SRhyland Klein [tegra_clk_xusb_ss_div2] = { .dt_id = TEGRA210_CLK_XUSB_SS_DIV2, .present = true },
24976b301a05SRhyland Klein [tegra_clk_xusb_dev_src_8] = { .dt_id = TEGRA210_CLK_XUSB_DEV_SRC, .present = true },
24986b301a05SRhyland Klein [tegra_clk_xusb_dev] = { .dt_id = TEGRA210_CLK_XUSB_DEV, .present = true },
24996b301a05SRhyland Klein [tegra_clk_xusb_hs_src_4] = { .dt_id = TEGRA210_CLK_XUSB_HS_SRC, .present = true },
25006b301a05SRhyland Klein [tegra_clk_xusb_ssp_src] = { .dt_id = TEGRA210_CLK_XUSB_SSP_SRC, .present = true },
25016b301a05SRhyland Klein [tegra_clk_usb2_hsic_trk] = { .dt_id = TEGRA210_CLK_USB2_HSIC_TRK, .present = true },
25026b301a05SRhyland Klein [tegra_clk_hsic_trk] = { .dt_id = TEGRA210_CLK_HSIC_TRK, .present = true },
25036b301a05SRhyland Klein [tegra_clk_usb2_trk] = { .dt_id = TEGRA210_CLK_USB2_TRK, .present = true },
25046b301a05SRhyland Klein [tegra_clk_sclk] = { .dt_id = TEGRA210_CLK_SCLK, .present = true },
25056b301a05SRhyland Klein [tegra_clk_sclk_mux] = { .dt_id = TEGRA210_CLK_SCLK_MUX, .present = true },
25066b301a05SRhyland Klein [tegra_clk_hclk] = { .dt_id = TEGRA210_CLK_HCLK, .present = true },
25076b301a05SRhyland Klein [tegra_clk_pclk] = { .dt_id = TEGRA210_CLK_PCLK, .present = true },
25086b301a05SRhyland Klein [tegra_clk_cclk_g] = { .dt_id = TEGRA210_CLK_CCLK_G, .present = true },
25096b301a05SRhyland Klein [tegra_clk_cclk_lp] = { .dt_id = TEGRA210_CLK_CCLK_LP, .present = true },
25106b301a05SRhyland Klein [tegra_clk_dfll_ref] = { .dt_id = TEGRA210_CLK_DFLL_REF, .present = true },
25116b301a05SRhyland Klein [tegra_clk_dfll_soc] = { .dt_id = TEGRA210_CLK_DFLL_SOC, .present = true },
25126b301a05SRhyland Klein [tegra_clk_vi_sensor2_8] = { .dt_id = TEGRA210_CLK_VI_SENSOR2, .present = true },
25136b301a05SRhyland Klein [tegra_clk_pll_p_out5] = { .dt_id = TEGRA210_CLK_PLL_P_OUT5, .present = true },
25146b301a05SRhyland Klein [tegra_clk_pll_c4] = { .dt_id = TEGRA210_CLK_PLL_C4, .present = true },
25156b301a05SRhyland Klein [tegra_clk_pll_dp] = { .dt_id = TEGRA210_CLK_PLL_DP, .present = true },
25166b301a05SRhyland Klein [tegra_clk_audio0_mux] = { .dt_id = TEGRA210_CLK_AUDIO0_MUX, .present = true },
25176b301a05SRhyland Klein [tegra_clk_audio1_mux] = { .dt_id = TEGRA210_CLK_AUDIO1_MUX, .present = true },
25186b301a05SRhyland Klein [tegra_clk_audio2_mux] = { .dt_id = TEGRA210_CLK_AUDIO2_MUX, .present = true },
25196b301a05SRhyland Klein [tegra_clk_audio3_mux] = { .dt_id = TEGRA210_CLK_AUDIO3_MUX, .present = true },
25206b301a05SRhyland Klein [tegra_clk_audio4_mux] = { .dt_id = TEGRA210_CLK_AUDIO4_MUX, .present = true },
25216b301a05SRhyland Klein [tegra_clk_spdif_mux] = { .dt_id = TEGRA210_CLK_SPDIF_MUX, .present = true },
25226b301a05SRhyland Klein [tegra_clk_maud] = { .dt_id = TEGRA210_CLK_MAUD, .present = true },
25236b301a05SRhyland Klein [tegra_clk_mipibif] = { .dt_id = TEGRA210_CLK_MIPIBIF, .present = true },
25246b301a05SRhyland Klein [tegra_clk_qspi] = { .dt_id = TEGRA210_CLK_QSPI, .present = true },
25256b301a05SRhyland Klein [tegra_clk_sdmmc_legacy] = { .dt_id = TEGRA210_CLK_SDMMC_LEGACY, .present = true },
25266b301a05SRhyland Klein [tegra_clk_tsecb] = { .dt_id = TEGRA210_CLK_TSECB, .present = true },
25276b301a05SRhyland Klein [tegra_clk_uartape] = { .dt_id = TEGRA210_CLK_UARTAPE, .present = true },
25286b301a05SRhyland Klein [tegra_clk_vi_i2c] = { .dt_id = TEGRA210_CLK_VI_I2C, .present = true },
25296b301a05SRhyland Klein [tegra_clk_ape] = { .dt_id = TEGRA210_CLK_APE, .present = true },
25306b301a05SRhyland Klein [tegra_clk_dbgapb] = { .dt_id = TEGRA210_CLK_DBGAPB, .present = true },
25316b301a05SRhyland Klein [tegra_clk_nvdec] = { .dt_id = TEGRA210_CLK_NVDEC, .present = true },
25326b301a05SRhyland Klein [tegra_clk_nvenc] = { .dt_id = TEGRA210_CLK_NVENC, .present = true },
25336b301a05SRhyland Klein [tegra_clk_nvjpg] = { .dt_id = TEGRA210_CLK_NVJPG, .present = true },
25346b301a05SRhyland Klein [tegra_clk_pll_c4_out0] = { .dt_id = TEGRA210_CLK_PLL_C4_OUT0, .present = true },
25356b301a05SRhyland Klein [tegra_clk_pll_c4_out1] = { .dt_id = TEGRA210_CLK_PLL_C4_OUT1, .present = true },
25366b301a05SRhyland Klein [tegra_clk_pll_c4_out2] = { .dt_id = TEGRA210_CLK_PLL_C4_OUT2, .present = true },
25376b301a05SRhyland Klein [tegra_clk_pll_c4_out3] = { .dt_id = TEGRA210_CLK_PLL_C4_OUT3, .present = true },
253829569941SJon Hunter [tegra_clk_apb2ape] = { .dt_id = TEGRA210_CLK_APB2APE, .present = true },
25399326947fSPeter De Schrijver [tegra_clk_pll_a1] = { .dt_id = TEGRA210_CLK_PLL_A1, .present = true },
254034ac2c27SPeter De Schrijver [tegra_clk_ispa] = { .dt_id = TEGRA210_CLK_ISPA, .present = true },
2541bfa34832SPeter De Schrijver [tegra_clk_cec] = { .dt_id = TEGRA210_CLK_CEC, .present = true },
25426cfc8bc9SPeter De Schrijver [tegra_clk_dmic1] = { .dt_id = TEGRA210_CLK_DMIC1, .present = true },
25436cfc8bc9SPeter De Schrijver [tegra_clk_dmic2] = { .dt_id = TEGRA210_CLK_DMIC2, .present = true },
25446cfc8bc9SPeter De Schrijver [tegra_clk_dmic3] = { .dt_id = TEGRA210_CLK_DMIC3, .present = true },
2545319af797SPeter De Schrijver [tegra_clk_dmic1_sync_clk] = { .dt_id = TEGRA210_CLK_DMIC1_SYNC_CLK, .present = true },
2546319af797SPeter De Schrijver [tegra_clk_dmic2_sync_clk] = { .dt_id = TEGRA210_CLK_DMIC2_SYNC_CLK, .present = true },
2547319af797SPeter De Schrijver [tegra_clk_dmic3_sync_clk] = { .dt_id = TEGRA210_CLK_DMIC3_SYNC_CLK, .present = true },
2548319af797SPeter De Schrijver [tegra_clk_dmic1_sync_clk_mux] = { .dt_id = TEGRA210_CLK_DMIC1_SYNC_CLK_MUX, .present = true },
2549319af797SPeter De Schrijver [tegra_clk_dmic2_sync_clk_mux] = { .dt_id = TEGRA210_CLK_DMIC2_SYNC_CLK_MUX, .present = true },
2550319af797SPeter De Schrijver [tegra_clk_dmic3_sync_clk_mux] = { .dt_id = TEGRA210_CLK_DMIC3_SYNC_CLK_MUX, .present = true },
255188da44c5SPeter De Schrijver [tegra_clk_dp2] = { .dt_id = TEGRA210_CLK_DP2, .present = true },
255288da44c5SPeter De Schrijver [tegra_clk_iqc1] = { .dt_id = TEGRA210_CLK_IQC1, .present = true },
255388da44c5SPeter De Schrijver [tegra_clk_iqc2] = { .dt_id = TEGRA210_CLK_IQC2, .present = true },
255488da44c5SPeter De Schrijver [tegra_clk_pll_a_out_adsp] = { .dt_id = TEGRA210_CLK_PLL_A_OUT_ADSP, .present = true },
255588da44c5SPeter De Schrijver [tegra_clk_pll_a_out0_out_adsp] = { .dt_id = TEGRA210_CLK_PLL_A_OUT0_OUT_ADSP, .present = true },
255688da44c5SPeter De Schrijver [tegra_clk_adsp] = { .dt_id = TEGRA210_CLK_ADSP, .present = true },
255788da44c5SPeter De Schrijver [tegra_clk_adsp_neon] = { .dt_id = TEGRA210_CLK_ADSP_NEON, .present = true },
25586b301a05SRhyland Klein };
25596b301a05SRhyland Klein
25606b301a05SRhyland Klein static struct tegra_devclk devclks[] __initdata = {
25616b301a05SRhyland Klein { .con_id = "clk_m", .dt_id = TEGRA210_CLK_CLK_M },
25626b301a05SRhyland Klein { .con_id = "pll_ref", .dt_id = TEGRA210_CLK_PLL_REF },
25636b301a05SRhyland Klein { .con_id = "clk_32k", .dt_id = TEGRA210_CLK_CLK_32K },
25642b50e49bSSowjanya Komatineni { .con_id = "osc", .dt_id = TEGRA210_CLK_OSC },
25659a85eb4dSSowjanya Komatineni { .con_id = "osc_div2", .dt_id = TEGRA210_CLK_OSC_DIV2 },
25669a85eb4dSSowjanya Komatineni { .con_id = "osc_div4", .dt_id = TEGRA210_CLK_OSC_DIV4 },
25676b301a05SRhyland Klein { .con_id = "pll_c", .dt_id = TEGRA210_CLK_PLL_C },
25686b301a05SRhyland Klein { .con_id = "pll_c_out1", .dt_id = TEGRA210_CLK_PLL_C_OUT1 },
25696b301a05SRhyland Klein { .con_id = "pll_c2", .dt_id = TEGRA210_CLK_PLL_C2 },
25706b301a05SRhyland Klein { .con_id = "pll_c3", .dt_id = TEGRA210_CLK_PLL_C3 },
25716b301a05SRhyland Klein { .con_id = "pll_p", .dt_id = TEGRA210_CLK_PLL_P },
25726b301a05SRhyland Klein { .con_id = "pll_p_out1", .dt_id = TEGRA210_CLK_PLL_P_OUT1 },
25736b301a05SRhyland Klein { .con_id = "pll_p_out2", .dt_id = TEGRA210_CLK_PLL_P_OUT2 },
25746b301a05SRhyland Klein { .con_id = "pll_p_out3", .dt_id = TEGRA210_CLK_PLL_P_OUT3 },
25756b301a05SRhyland Klein { .con_id = "pll_p_out4", .dt_id = TEGRA210_CLK_PLL_P_OUT4 },
25766b301a05SRhyland Klein { .con_id = "pll_m", .dt_id = TEGRA210_CLK_PLL_M },
25776b301a05SRhyland Klein { .con_id = "pll_x", .dt_id = TEGRA210_CLK_PLL_X },
25786b301a05SRhyland Klein { .con_id = "pll_x_out0", .dt_id = TEGRA210_CLK_PLL_X_OUT0 },
25796b301a05SRhyland Klein { .con_id = "pll_u", .dt_id = TEGRA210_CLK_PLL_U },
25806b301a05SRhyland Klein { .con_id = "pll_u_out", .dt_id = TEGRA210_CLK_PLL_U_OUT },
25816b301a05SRhyland Klein { .con_id = "pll_u_out1", .dt_id = TEGRA210_CLK_PLL_U_OUT1 },
25826b301a05SRhyland Klein { .con_id = "pll_u_out2", .dt_id = TEGRA210_CLK_PLL_U_OUT2 },
25836b301a05SRhyland Klein { .con_id = "pll_u_480M", .dt_id = TEGRA210_CLK_PLL_U_480M },
25846b301a05SRhyland Klein { .con_id = "pll_u_60M", .dt_id = TEGRA210_CLK_PLL_U_60M },
25856b301a05SRhyland Klein { .con_id = "pll_u_48M", .dt_id = TEGRA210_CLK_PLL_U_48M },
25866b301a05SRhyland Klein { .con_id = "pll_d", .dt_id = TEGRA210_CLK_PLL_D },
25876b301a05SRhyland Klein { .con_id = "pll_d_out0", .dt_id = TEGRA210_CLK_PLL_D_OUT0 },
25886b301a05SRhyland Klein { .con_id = "pll_d2", .dt_id = TEGRA210_CLK_PLL_D2 },
25896b301a05SRhyland Klein { .con_id = "pll_d2_out0", .dt_id = TEGRA210_CLK_PLL_D2_OUT0 },
25906b301a05SRhyland Klein { .con_id = "pll_a", .dt_id = TEGRA210_CLK_PLL_A },
25916b301a05SRhyland Klein { .con_id = "pll_a_out0", .dt_id = TEGRA210_CLK_PLL_A_OUT0 },
25926b301a05SRhyland Klein { .con_id = "pll_re_vco", .dt_id = TEGRA210_CLK_PLL_RE_VCO },
25936b301a05SRhyland Klein { .con_id = "pll_re_out", .dt_id = TEGRA210_CLK_PLL_RE_OUT },
25946b301a05SRhyland Klein { .con_id = "spdif_in_sync", .dt_id = TEGRA210_CLK_SPDIF_IN_SYNC },
25956b301a05SRhyland Klein { .con_id = "i2s0_sync", .dt_id = TEGRA210_CLK_I2S0_SYNC },
25966b301a05SRhyland Klein { .con_id = "i2s1_sync", .dt_id = TEGRA210_CLK_I2S1_SYNC },
25976b301a05SRhyland Klein { .con_id = "i2s2_sync", .dt_id = TEGRA210_CLK_I2S2_SYNC },
25986b301a05SRhyland Klein { .con_id = "i2s3_sync", .dt_id = TEGRA210_CLK_I2S3_SYNC },
25996b301a05SRhyland Klein { .con_id = "i2s4_sync", .dt_id = TEGRA210_CLK_I2S4_SYNC },
26006b301a05SRhyland Klein { .con_id = "vimclk_sync", .dt_id = TEGRA210_CLK_VIMCLK_SYNC },
26016b301a05SRhyland Klein { .con_id = "audio0", .dt_id = TEGRA210_CLK_AUDIO0 },
26026b301a05SRhyland Klein { .con_id = "audio1", .dt_id = TEGRA210_CLK_AUDIO1 },
26036b301a05SRhyland Klein { .con_id = "audio2", .dt_id = TEGRA210_CLK_AUDIO2 },
26046b301a05SRhyland Klein { .con_id = "audio3", .dt_id = TEGRA210_CLK_AUDIO3 },
26056b301a05SRhyland Klein { .con_id = "audio4", .dt_id = TEGRA210_CLK_AUDIO4 },
26066b301a05SRhyland Klein { .con_id = "spdif", .dt_id = TEGRA210_CLK_SPDIF },
26076b301a05SRhyland Klein { .con_id = "spdif_2x", .dt_id = TEGRA210_CLK_SPDIF_2X },
2608acbeec3dSSowjanya Komatineni { .con_id = "extern1", .dt_id = TEGRA210_CLK_EXTERN1 },
2609acbeec3dSSowjanya Komatineni { .con_id = "extern2", .dt_id = TEGRA210_CLK_EXTERN2 },
2610acbeec3dSSowjanya Komatineni { .con_id = "extern3", .dt_id = TEGRA210_CLK_EXTERN3 },
26116b301a05SRhyland Klein { .con_id = "cclk_g", .dt_id = TEGRA210_CLK_CCLK_G },
26126b301a05SRhyland Klein { .con_id = "cclk_lp", .dt_id = TEGRA210_CLK_CCLK_LP },
26136b301a05SRhyland Klein { .con_id = "sclk", .dt_id = TEGRA210_CLK_SCLK },
26146b301a05SRhyland Klein { .con_id = "hclk", .dt_id = TEGRA210_CLK_HCLK },
26156b301a05SRhyland Klein { .con_id = "pclk", .dt_id = TEGRA210_CLK_PCLK },
26166b301a05SRhyland Klein { .con_id = "fuse", .dt_id = TEGRA210_CLK_FUSE },
26176b301a05SRhyland Klein { .dev_id = "rtc-tegra", .dt_id = TEGRA210_CLK_RTC },
26186b301a05SRhyland Klein { .dev_id = "timer", .dt_id = TEGRA210_CLK_TIMER },
26196b301a05SRhyland Klein { .con_id = "pll_c4_out0", .dt_id = TEGRA210_CLK_PLL_C4_OUT0 },
26206b301a05SRhyland Klein { .con_id = "pll_c4_out1", .dt_id = TEGRA210_CLK_PLL_C4_OUT1 },
26216b301a05SRhyland Klein { .con_id = "pll_c4_out2", .dt_id = TEGRA210_CLK_PLL_C4_OUT2 },
26226b301a05SRhyland Klein { .con_id = "pll_c4_out3", .dt_id = TEGRA210_CLK_PLL_C4_OUT3 },
26236b301a05SRhyland Klein { .con_id = "dpaux", .dt_id = TEGRA210_CLK_DPAUX },
26246b301a05SRhyland Klein };
26256b301a05SRhyland Klein
26266b301a05SRhyland Klein static struct tegra_audio_clk_info tegra210_audio_plls[] = {
26276b301a05SRhyland Klein { "pll_a", &pll_a_params, tegra_clk_pll_a, "pll_ref" },
26286b301a05SRhyland Klein { "pll_a1", &pll_a1_params, tegra_clk_pll_a1, "pll_ref" },
26296b301a05SRhyland Klein };
26306b301a05SRhyland Klein
263124c3ebefSPeter De Schrijver static const char * const aclk_parents[] = {
263224c3ebefSPeter De Schrijver "pll_a1", "pll_c", "pll_p", "pll_a_out0", "pll_c2", "pll_c3",
263324c3ebefSPeter De Schrijver "clk_m"
263424c3ebefSPeter De Schrijver };
263524c3ebefSPeter De Schrijver
2636e403d005SPeter De Schrijver static const unsigned int nvjpg_slcg_clkids[] = { TEGRA210_CLK_NVDEC };
2637e403d005SPeter De Schrijver static const unsigned int nvdec_slcg_clkids[] = { TEGRA210_CLK_NVJPG };
2638e403d005SPeter De Schrijver static const unsigned int sor_slcg_clkids[] = { TEGRA210_CLK_HDA2CODEC_2X,
2639e403d005SPeter De Schrijver TEGRA210_CLK_HDA2HDMI, TEGRA210_CLK_DISP1, TEGRA210_CLK_DISP2 };
2640e403d005SPeter De Schrijver static const unsigned int disp_slcg_clkids[] = { TEGRA210_CLK_LA,
2641e403d005SPeter De Schrijver TEGRA210_CLK_HOST1X};
2642e403d005SPeter De Schrijver static const unsigned int xusba_slcg_clkids[] = { TEGRA210_CLK_XUSB_HOST,
2643e403d005SPeter De Schrijver TEGRA210_CLK_XUSB_DEV };
2644e403d005SPeter De Schrijver static const unsigned int xusbb_slcg_clkids[] = { TEGRA210_CLK_XUSB_HOST,
2645e403d005SPeter De Schrijver TEGRA210_CLK_XUSB_SS };
2646e403d005SPeter De Schrijver static const unsigned int xusbc_slcg_clkids[] = { TEGRA210_CLK_XUSB_DEV,
2647e403d005SPeter De Schrijver TEGRA210_CLK_XUSB_SS };
2648e403d005SPeter De Schrijver static const unsigned int venc_slcg_clkids[] = { TEGRA210_CLK_HOST1X,
2649e403d005SPeter De Schrijver TEGRA210_CLK_PLL_D };
2650e403d005SPeter De Schrijver static const unsigned int ape_slcg_clkids[] = { TEGRA210_CLK_ACLK,
2651e403d005SPeter De Schrijver TEGRA210_CLK_I2S0, TEGRA210_CLK_I2S1, TEGRA210_CLK_I2S2,
2652e403d005SPeter De Schrijver TEGRA210_CLK_I2S3, TEGRA210_CLK_I2S4, TEGRA210_CLK_SPDIF_OUT,
2653e403d005SPeter De Schrijver TEGRA210_CLK_D_AUDIO };
2654e403d005SPeter De Schrijver static const unsigned int vic_slcg_clkids[] = { TEGRA210_CLK_HOST1X };
2655e403d005SPeter De Schrijver
2656e403d005SPeter De Schrijver static struct tegra210_domain_mbist_war tegra210_pg_mbist_war[] = {
2657e403d005SPeter De Schrijver [TEGRA_POWERGATE_VENC] = {
2658e403d005SPeter De Schrijver .handle_lvl2_ovr = tegra210_venc_mbist_war,
2659e403d005SPeter De Schrijver .num_clks = ARRAY_SIZE(venc_slcg_clkids),
2660e403d005SPeter De Schrijver .clk_init_data = venc_slcg_clkids,
2661e403d005SPeter De Schrijver },
2662e403d005SPeter De Schrijver [TEGRA_POWERGATE_SATA] = {
2663e403d005SPeter De Schrijver .handle_lvl2_ovr = tegra210_generic_mbist_war,
2664e403d005SPeter De Schrijver .lvl2_offset = LVL2_CLK_GATE_OVRC,
2665e403d005SPeter De Schrijver .lvl2_mask = BIT(0) | BIT(17) | BIT(19),
2666e403d005SPeter De Schrijver },
2667e403d005SPeter De Schrijver [TEGRA_POWERGATE_MPE] = {
2668e403d005SPeter De Schrijver .handle_lvl2_ovr = tegra210_generic_mbist_war,
2669e403d005SPeter De Schrijver .lvl2_offset = LVL2_CLK_GATE_OVRE,
2670a4dbbceeSJoseph Lo .lvl2_mask = BIT(29),
2671e403d005SPeter De Schrijver },
2672e403d005SPeter De Schrijver [TEGRA_POWERGATE_SOR] = {
2673e403d005SPeter De Schrijver .handle_lvl2_ovr = tegra210_generic_mbist_war,
2674e403d005SPeter De Schrijver .num_clks = ARRAY_SIZE(sor_slcg_clkids),
2675e403d005SPeter De Schrijver .clk_init_data = sor_slcg_clkids,
2676e403d005SPeter De Schrijver .lvl2_offset = LVL2_CLK_GATE_OVRA,
2677e403d005SPeter De Schrijver .lvl2_mask = BIT(1) | BIT(2),
2678e403d005SPeter De Schrijver },
2679e403d005SPeter De Schrijver [TEGRA_POWERGATE_DIS] = {
2680e403d005SPeter De Schrijver .handle_lvl2_ovr = tegra210_disp_mbist_war,
2681e403d005SPeter De Schrijver .num_clks = ARRAY_SIZE(disp_slcg_clkids),
2682e403d005SPeter De Schrijver .clk_init_data = disp_slcg_clkids,
2683e403d005SPeter De Schrijver },
2684e403d005SPeter De Schrijver [TEGRA_POWERGATE_DISB] = {
2685e403d005SPeter De Schrijver .num_clks = ARRAY_SIZE(disp_slcg_clkids),
2686e403d005SPeter De Schrijver .clk_init_data = disp_slcg_clkids,
2687e403d005SPeter De Schrijver .handle_lvl2_ovr = tegra210_generic_mbist_war,
2688e403d005SPeter De Schrijver .lvl2_offset = LVL2_CLK_GATE_OVRA,
2689e403d005SPeter De Schrijver .lvl2_mask = BIT(2),
2690e403d005SPeter De Schrijver },
2691e403d005SPeter De Schrijver [TEGRA_POWERGATE_XUSBA] = {
2692e403d005SPeter De Schrijver .num_clks = ARRAY_SIZE(xusba_slcg_clkids),
2693e403d005SPeter De Schrijver .clk_init_data = xusba_slcg_clkids,
2694e403d005SPeter De Schrijver .handle_lvl2_ovr = tegra210_generic_mbist_war,
2695e403d005SPeter De Schrijver .lvl2_offset = LVL2_CLK_GATE_OVRC,
2696e403d005SPeter De Schrijver .lvl2_mask = BIT(30) | BIT(31),
2697e403d005SPeter De Schrijver },
2698e403d005SPeter De Schrijver [TEGRA_POWERGATE_XUSBB] = {
2699e403d005SPeter De Schrijver .num_clks = ARRAY_SIZE(xusbb_slcg_clkids),
2700e403d005SPeter De Schrijver .clk_init_data = xusbb_slcg_clkids,
2701e403d005SPeter De Schrijver .handle_lvl2_ovr = tegra210_generic_mbist_war,
2702e403d005SPeter De Schrijver .lvl2_offset = LVL2_CLK_GATE_OVRC,
2703e403d005SPeter De Schrijver .lvl2_mask = BIT(30) | BIT(31),
2704e403d005SPeter De Schrijver },
2705e403d005SPeter De Schrijver [TEGRA_POWERGATE_XUSBC] = {
2706e403d005SPeter De Schrijver .num_clks = ARRAY_SIZE(xusbc_slcg_clkids),
2707e403d005SPeter De Schrijver .clk_init_data = xusbc_slcg_clkids,
2708e403d005SPeter De Schrijver .handle_lvl2_ovr = tegra210_generic_mbist_war,
2709e403d005SPeter De Schrijver .lvl2_offset = LVL2_CLK_GATE_OVRC,
2710e403d005SPeter De Schrijver .lvl2_mask = BIT(30) | BIT(31),
2711e403d005SPeter De Schrijver },
2712e403d005SPeter De Schrijver [TEGRA_POWERGATE_VIC] = {
2713e403d005SPeter De Schrijver .num_clks = ARRAY_SIZE(vic_slcg_clkids),
2714e403d005SPeter De Schrijver .clk_init_data = vic_slcg_clkids,
2715e403d005SPeter De Schrijver .handle_lvl2_ovr = tegra210_vic_mbist_war,
2716e403d005SPeter De Schrijver },
2717e403d005SPeter De Schrijver [TEGRA_POWERGATE_NVDEC] = {
2718e403d005SPeter De Schrijver .num_clks = ARRAY_SIZE(nvdec_slcg_clkids),
2719e403d005SPeter De Schrijver .clk_init_data = nvdec_slcg_clkids,
2720e403d005SPeter De Schrijver .handle_lvl2_ovr = tegra210_generic_mbist_war,
2721a4dbbceeSJoseph Lo .lvl2_offset = LVL2_CLK_GATE_OVRE,
2722e403d005SPeter De Schrijver .lvl2_mask = BIT(9) | BIT(31),
2723e403d005SPeter De Schrijver },
2724e403d005SPeter De Schrijver [TEGRA_POWERGATE_NVJPG] = {
2725e403d005SPeter De Schrijver .num_clks = ARRAY_SIZE(nvjpg_slcg_clkids),
2726e403d005SPeter De Schrijver .clk_init_data = nvjpg_slcg_clkids,
2727e403d005SPeter De Schrijver .handle_lvl2_ovr = tegra210_generic_mbist_war,
2728a4dbbceeSJoseph Lo .lvl2_offset = LVL2_CLK_GATE_OVRE,
2729e403d005SPeter De Schrijver .lvl2_mask = BIT(9) | BIT(31),
2730e403d005SPeter De Schrijver },
2731e403d005SPeter De Schrijver [TEGRA_POWERGATE_AUD] = {
2732e403d005SPeter De Schrijver .num_clks = ARRAY_SIZE(ape_slcg_clkids),
2733e403d005SPeter De Schrijver .clk_init_data = ape_slcg_clkids,
2734e403d005SPeter De Schrijver .handle_lvl2_ovr = tegra210_ape_mbist_war,
2735e403d005SPeter De Schrijver },
2736e403d005SPeter De Schrijver [TEGRA_POWERGATE_VE2] = {
2737e403d005SPeter De Schrijver .handle_lvl2_ovr = tegra210_generic_mbist_war,
2738e403d005SPeter De Schrijver .lvl2_offset = LVL2_CLK_GATE_OVRD,
2739e403d005SPeter De Schrijver .lvl2_mask = BIT(22),
2740e403d005SPeter De Schrijver },
2741e403d005SPeter De Schrijver };
2742e403d005SPeter De Schrijver
tegra210_clk_handle_mbist_war(unsigned int id)2743e403d005SPeter De Schrijver int tegra210_clk_handle_mbist_war(unsigned int id)
2744e403d005SPeter De Schrijver {
2745e403d005SPeter De Schrijver int err;
2746e403d005SPeter De Schrijver struct tegra210_domain_mbist_war *mbist_war;
2747e403d005SPeter De Schrijver
2748e403d005SPeter De Schrijver if (id >= ARRAY_SIZE(tegra210_pg_mbist_war)) {
2749e403d005SPeter De Schrijver WARN(1, "unknown domain id in MBIST WAR handler\n");
2750e403d005SPeter De Schrijver return -EINVAL;
2751e403d005SPeter De Schrijver }
2752e403d005SPeter De Schrijver
2753e403d005SPeter De Schrijver mbist_war = &tegra210_pg_mbist_war[id];
2754e403d005SPeter De Schrijver if (!mbist_war->handle_lvl2_ovr)
2755e403d005SPeter De Schrijver return 0;
2756e403d005SPeter De Schrijver
2757e403d005SPeter De Schrijver if (mbist_war->num_clks && !mbist_war->clks)
2758e403d005SPeter De Schrijver return -ENODEV;
2759e403d005SPeter De Schrijver
2760e403d005SPeter De Schrijver err = clk_bulk_prepare_enable(mbist_war->num_clks, mbist_war->clks);
2761e403d005SPeter De Schrijver if (err < 0)
2762e403d005SPeter De Schrijver return err;
2763e403d005SPeter De Schrijver
2764e403d005SPeter De Schrijver mutex_lock(&lvl2_ovr_lock);
2765e403d005SPeter De Schrijver
2766e403d005SPeter De Schrijver mbist_war->handle_lvl2_ovr(mbist_war);
2767e403d005SPeter De Schrijver
2768e403d005SPeter De Schrijver mutex_unlock(&lvl2_ovr_lock);
2769e403d005SPeter De Schrijver
2770e403d005SPeter De Schrijver clk_bulk_disable_unprepare(mbist_war->num_clks, mbist_war->clks);
2771e403d005SPeter De Schrijver
2772e403d005SPeter De Schrijver return 0;
2773e403d005SPeter De Schrijver }
2774e403d005SPeter De Schrijver
tegra210_put_utmipll_in_iddq(void)27753843832fSPeter De Schrijver void tegra210_put_utmipll_in_iddq(void)
27763843832fSPeter De Schrijver {
27773843832fSPeter De Schrijver u32 reg;
27783843832fSPeter De Schrijver
27793843832fSPeter De Schrijver reg = readl_relaxed(clk_base + UTMIPLL_HW_PWRDN_CFG0);
27803843832fSPeter De Schrijver
27813843832fSPeter De Schrijver if (reg & UTMIPLL_HW_PWRDN_CFG0_UTMIPLL_LOCK) {
27823843832fSPeter De Schrijver pr_err("trying to assert IDDQ while UTMIPLL is locked\n");
27833843832fSPeter De Schrijver return;
27843843832fSPeter De Schrijver }
27853843832fSPeter De Schrijver
27863843832fSPeter De Schrijver reg |= UTMIPLL_HW_PWRDN_CFG0_IDDQ_OVERRIDE;
27873843832fSPeter De Schrijver writel_relaxed(reg, clk_base + UTMIPLL_HW_PWRDN_CFG0);
27883843832fSPeter De Schrijver }
27893843832fSPeter De Schrijver EXPORT_SYMBOL_GPL(tegra210_put_utmipll_in_iddq);
27903843832fSPeter De Schrijver
tegra210_put_utmipll_out_iddq(void)27913843832fSPeter De Schrijver void tegra210_put_utmipll_out_iddq(void)
27923843832fSPeter De Schrijver {
27933843832fSPeter De Schrijver u32 reg;
27943843832fSPeter De Schrijver
27953843832fSPeter De Schrijver reg = readl_relaxed(clk_base + UTMIPLL_HW_PWRDN_CFG0);
27963843832fSPeter De Schrijver reg &= ~UTMIPLL_HW_PWRDN_CFG0_IDDQ_OVERRIDE;
27973843832fSPeter De Schrijver writel_relaxed(reg, clk_base + UTMIPLL_HW_PWRDN_CFG0);
27983843832fSPeter De Schrijver }
27993843832fSPeter De Schrijver EXPORT_SYMBOL_GPL(tegra210_put_utmipll_out_iddq);
28003843832fSPeter De Schrijver
tegra210_utmi_param_configure(void)2801e745f992SPeter De Schrijver static void tegra210_utmi_param_configure(void)
2802e745f992SPeter De Schrijver {
2803e745f992SPeter De Schrijver u32 reg;
2804e745f992SPeter De Schrijver int i;
2805e745f992SPeter De Schrijver
2806e745f992SPeter De Schrijver for (i = 0; i < ARRAY_SIZE(utmi_parameters); i++) {
2807e745f992SPeter De Schrijver if (osc_freq == utmi_parameters[i].osc_frequency)
2808e745f992SPeter De Schrijver break;
2809e745f992SPeter De Schrijver }
2810e745f992SPeter De Schrijver
2811e745f992SPeter De Schrijver if (i >= ARRAY_SIZE(utmi_parameters)) {
2812e745f992SPeter De Schrijver pr_err("%s: Unexpected oscillator freq %lu\n", __func__,
2813e745f992SPeter De Schrijver osc_freq);
2814e745f992SPeter De Schrijver return;
2815e745f992SPeter De Schrijver }
2816e745f992SPeter De Schrijver
2817e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + UTMIPLL_HW_PWRDN_CFG0);
2818e745f992SPeter De Schrijver reg &= ~UTMIPLL_HW_PWRDN_CFG0_IDDQ_OVERRIDE;
2819e745f992SPeter De Schrijver writel_relaxed(reg, clk_base + UTMIPLL_HW_PWRDN_CFG0);
2820e745f992SPeter De Schrijver
2821e745f992SPeter De Schrijver udelay(10);
2822e745f992SPeter De Schrijver
2823e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + UTMIP_PLL_CFG2);
2824e745f992SPeter De Schrijver
2825e745f992SPeter De Schrijver /* Program UTMIP PLL stable and active counts */
2826e745f992SPeter De Schrijver /* [FIXME] arclk_rst.h says WRONG! This should be 1ms -> 0x50 Check! */
2827e745f992SPeter De Schrijver reg &= ~UTMIP_PLL_CFG2_STABLE_COUNT(~0);
2828e745f992SPeter De Schrijver reg |= UTMIP_PLL_CFG2_STABLE_COUNT(utmi_parameters[i].stable_count);
2829e745f992SPeter De Schrijver
2830e745f992SPeter De Schrijver reg &= ~UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(~0);
2831e745f992SPeter De Schrijver reg |=
2832e745f992SPeter De Schrijver UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(utmi_parameters[i].active_delay_count);
2833e745f992SPeter De Schrijver writel_relaxed(reg, clk_base + UTMIP_PLL_CFG2);
2834e745f992SPeter De Schrijver
2835e745f992SPeter De Schrijver /* Program UTMIP PLL delay and oscillator frequency counts */
2836e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + UTMIP_PLL_CFG1);
2837e745f992SPeter De Schrijver
283871422dbbSAlex Frid reg &= ~UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(~0);
2839e745f992SPeter De Schrijver reg |=
2840e745f992SPeter De Schrijver UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(utmi_parameters[i].enable_delay_count);
2841e745f992SPeter De Schrijver
2842e745f992SPeter De Schrijver reg &= ~UTMIP_PLL_CFG1_XTAL_FREQ_COUNT(~0);
2843e745f992SPeter De Schrijver reg |=
2844e745f992SPeter De Schrijver UTMIP_PLL_CFG1_XTAL_FREQ_COUNT(utmi_parameters[i].xtal_freq_count);
2845e745f992SPeter De Schrijver
2846e745f992SPeter De Schrijver reg |= UTMIP_PLL_CFG1_FORCE_PLLU_POWERDOWN;
2847e745f992SPeter De Schrijver writel_relaxed(reg, clk_base + UTMIP_PLL_CFG1);
2848e745f992SPeter De Schrijver
2849e745f992SPeter De Schrijver /* Remove power downs from UTMIP PLL control bits */
2850e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + UTMIP_PLL_CFG1);
2851e745f992SPeter De Schrijver reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERDOWN;
2852e745f992SPeter De Schrijver reg |= UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERUP;
2853e745f992SPeter De Schrijver writel_relaxed(reg, clk_base + UTMIP_PLL_CFG1);
285471422dbbSAlex Frid
285571422dbbSAlex Frid udelay(20);
2856e745f992SPeter De Schrijver
2857e745f992SPeter De Schrijver /* Enable samplers for SNPS, XUSB_HOST, XUSB_DEV */
2858e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + UTMIP_PLL_CFG2);
2859e745f992SPeter De Schrijver reg |= UTMIP_PLL_CFG2_FORCE_PD_SAMP_A_POWERUP;
2860e745f992SPeter De Schrijver reg |= UTMIP_PLL_CFG2_FORCE_PD_SAMP_B_POWERUP;
2861e745f992SPeter De Schrijver reg |= UTMIP_PLL_CFG2_FORCE_PD_SAMP_D_POWERUP;
2862e745f992SPeter De Schrijver reg &= ~UTMIP_PLL_CFG2_FORCE_PD_SAMP_A_POWERDOWN;
2863e745f992SPeter De Schrijver reg &= ~UTMIP_PLL_CFG2_FORCE_PD_SAMP_B_POWERDOWN;
2864e745f992SPeter De Schrijver reg &= ~UTMIP_PLL_CFG2_FORCE_PD_SAMP_D_POWERDOWN;
2865e745f992SPeter De Schrijver writel_relaxed(reg, clk_base + UTMIP_PLL_CFG2);
2866e745f992SPeter De Schrijver
2867e745f992SPeter De Schrijver /* Setup HW control of UTMIPLL */
2868e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + UTMIP_PLL_CFG1);
2869e745f992SPeter De Schrijver reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERDOWN;
2870e745f992SPeter De Schrijver reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERUP;
2871e745f992SPeter De Schrijver writel_relaxed(reg, clk_base + UTMIP_PLL_CFG1);
2872e745f992SPeter De Schrijver
2873e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + UTMIPLL_HW_PWRDN_CFG0);
2874e745f992SPeter De Schrijver reg |= UTMIPLL_HW_PWRDN_CFG0_USE_LOCKDET;
2875e745f992SPeter De Schrijver reg &= ~UTMIPLL_HW_PWRDN_CFG0_CLK_ENABLE_SWCTL;
2876e745f992SPeter De Schrijver writel_relaxed(reg, clk_base + UTMIPLL_HW_PWRDN_CFG0);
2877e745f992SPeter De Schrijver
2878e745f992SPeter De Schrijver udelay(1);
2879e745f992SPeter De Schrijver
2880e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + XUSB_PLL_CFG0);
2881e745f992SPeter De Schrijver reg &= ~XUSB_PLL_CFG0_UTMIPLL_LOCK_DLY;
2882e745f992SPeter De Schrijver writel_relaxed(reg, clk_base + XUSB_PLL_CFG0);
2883e745f992SPeter De Schrijver
2884e745f992SPeter De Schrijver udelay(1);
2885e745f992SPeter De Schrijver
2886e745f992SPeter De Schrijver /* Enable HW control UTMIPLL */
2887e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + UTMIPLL_HW_PWRDN_CFG0);
2888e745f992SPeter De Schrijver reg |= UTMIPLL_HW_PWRDN_CFG0_SEQ_ENABLE;
2889e745f992SPeter De Schrijver writel_relaxed(reg, clk_base + UTMIPLL_HW_PWRDN_CFG0);
2890e745f992SPeter De Schrijver }
2891e745f992SPeter De Schrijver
tegra210_enable_pllu(void)2892e745f992SPeter De Schrijver static int tegra210_enable_pllu(void)
2893e745f992SPeter De Schrijver {
2894e745f992SPeter De Schrijver struct tegra_clk_pll_freq_table *fentry;
2895e745f992SPeter De Schrijver struct tegra_clk_pll pllu;
2896e745f992SPeter De Schrijver u32 reg;
2897535f296dSSowjanya Komatineni int ret;
2898e745f992SPeter De Schrijver
2899e745f992SPeter De Schrijver for (fentry = pll_u_freq_table; fentry->input_rate; fentry++) {
2900e745f992SPeter De Schrijver if (fentry->input_rate == pll_ref_freq)
2901e745f992SPeter De Schrijver break;
2902e745f992SPeter De Schrijver }
2903e745f992SPeter De Schrijver
2904e745f992SPeter De Schrijver if (!fentry->input_rate) {
2905e745f992SPeter De Schrijver pr_err("Unknown PLL_U reference frequency %lu\n", pll_ref_freq);
2906e745f992SPeter De Schrijver return -EINVAL;
2907e745f992SPeter De Schrijver }
2908e745f992SPeter De Schrijver
2909e745f992SPeter De Schrijver /* clear IDDQ bit */
2910e745f992SPeter De Schrijver pllu.params = &pll_u_vco_params;
2911e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + pllu.params->ext_misc_reg[0]);
2912e745f992SPeter De Schrijver reg &= ~BIT(pllu.params->iddq_bit_idx);
2913e745f992SPeter De Schrijver writel_relaxed(reg, clk_base + pllu.params->ext_misc_reg[0]);
2914f68cbb35SSowjanya Komatineni fence_udelay(5, clk_base);
2915e745f992SPeter De Schrijver
2916e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + PLLU_BASE);
2917e745f992SPeter De Schrijver reg &= ~GENMASK(20, 0);
2918e745f992SPeter De Schrijver reg |= fentry->m;
2919e745f992SPeter De Schrijver reg |= fentry->n << 8;
2920e745f992SPeter De Schrijver reg |= fentry->p << 16;
2921e745f992SPeter De Schrijver writel(reg, clk_base + PLLU_BASE);
2922f68cbb35SSowjanya Komatineni fence_udelay(1, clk_base);
2923e745f992SPeter De Schrijver reg |= PLL_ENABLE;
2924e745f992SPeter De Schrijver writel(reg, clk_base + PLLU_BASE);
2925e745f992SPeter De Schrijver
2926535f296dSSowjanya Komatineni /*
2927535f296dSSowjanya Komatineni * During clocks resume, same PLLU init and enable sequence get
2928535f296dSSowjanya Komatineni * executed. So, readx_poll_timeout_atomic can't be used here as it
2929535f296dSSowjanya Komatineni * uses ktime_get() and timekeeping resume doesn't happen by that
2930535f296dSSowjanya Komatineni * time. So, using tegra210_wait_for_mask for PLL LOCK.
2931535f296dSSowjanya Komatineni */
2932535f296dSSowjanya Komatineni ret = tegra210_wait_for_mask(&pllu, PLLU_BASE, PLL_BASE_LOCK);
2933535f296dSSowjanya Komatineni if (ret) {
2934e745f992SPeter De Schrijver pr_err("Timed out waiting for PLL_U to lock\n");
2935e745f992SPeter De Schrijver return -ETIMEDOUT;
2936e745f992SPeter De Schrijver }
2937e745f992SPeter De Schrijver
2938e745f992SPeter De Schrijver return 0;
2939e745f992SPeter De Schrijver }
2940e745f992SPeter De Schrijver
tegra210_init_pllu(void)2941e745f992SPeter De Schrijver static int tegra210_init_pllu(void)
2942e745f992SPeter De Schrijver {
2943e745f992SPeter De Schrijver u32 reg;
2944e745f992SPeter De Schrijver int err;
2945e745f992SPeter De Schrijver
2946e745f992SPeter De Schrijver tegra210_pllu_set_defaults(&pll_u_vco_params);
2947e745f992SPeter De Schrijver /* skip initialization when pllu is in hw controlled mode */
2948e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + PLLU_BASE);
2949e745f992SPeter De Schrijver if (reg & PLLU_BASE_OVERRIDE) {
2950e745f992SPeter De Schrijver if (!(reg & PLL_ENABLE)) {
2951e745f992SPeter De Schrijver err = tegra210_enable_pllu();
2952e745f992SPeter De Schrijver if (err < 0) {
2953e745f992SPeter De Schrijver WARN_ON(1);
2954e745f992SPeter De Schrijver return err;
2955e745f992SPeter De Schrijver }
2956e745f992SPeter De Schrijver }
2957e745f992SPeter De Schrijver /* enable hw controlled mode */
2958e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + PLLU_BASE);
2959e745f992SPeter De Schrijver reg &= ~PLLU_BASE_OVERRIDE;
2960e745f992SPeter De Schrijver writel(reg, clk_base + PLLU_BASE);
2961e745f992SPeter De Schrijver
2962e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + PLLU_HW_PWRDN_CFG0);
2963e745f992SPeter De Schrijver reg |= PLLU_HW_PWRDN_CFG0_IDDQ_PD_INCLUDE |
2964e745f992SPeter De Schrijver PLLU_HW_PWRDN_CFG0_USE_SWITCH_DETECT |
2965e745f992SPeter De Schrijver PLLU_HW_PWRDN_CFG0_USE_LOCKDET;
2966e745f992SPeter De Schrijver reg &= ~(PLLU_HW_PWRDN_CFG0_CLK_ENABLE_SWCTL |
2967e745f992SPeter De Schrijver PLLU_HW_PWRDN_CFG0_CLK_SWITCH_SWCTL);
2968e745f992SPeter De Schrijver writel_relaxed(reg, clk_base + PLLU_HW_PWRDN_CFG0);
2969e745f992SPeter De Schrijver
2970e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + XUSB_PLL_CFG0);
2971e745f992SPeter De Schrijver reg &= ~XUSB_PLL_CFG0_PLLU_LOCK_DLY_MASK;
2972e745f992SPeter De Schrijver writel_relaxed(reg, clk_base + XUSB_PLL_CFG0);
2973f68cbb35SSowjanya Komatineni fence_udelay(1, clk_base);
2974e745f992SPeter De Schrijver
2975e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + PLLU_HW_PWRDN_CFG0);
2976e745f992SPeter De Schrijver reg |= PLLU_HW_PWRDN_CFG0_SEQ_ENABLE;
2977e745f992SPeter De Schrijver writel_relaxed(reg, clk_base + PLLU_HW_PWRDN_CFG0);
2978f68cbb35SSowjanya Komatineni fence_udelay(1, clk_base);
2979e745f992SPeter De Schrijver
2980e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + PLLU_BASE);
2981e745f992SPeter De Schrijver reg &= ~PLLU_BASE_CLKENABLE_USB;
2982e745f992SPeter De Schrijver writel_relaxed(reg, clk_base + PLLU_BASE);
2983e745f992SPeter De Schrijver }
2984e745f992SPeter De Schrijver
2985e745f992SPeter De Schrijver /* enable UTMIPLL hw control if not yet done by the bootloader */
2986e745f992SPeter De Schrijver reg = readl_relaxed(clk_base + UTMIPLL_HW_PWRDN_CFG0);
2987e745f992SPeter De Schrijver if (!(reg & UTMIPLL_HW_PWRDN_CFG0_SEQ_ENABLE))
2988e745f992SPeter De Schrijver tegra210_utmi_param_configure();
2989e745f992SPeter De Schrijver
2990e745f992SPeter De Schrijver return 0;
2991e745f992SPeter De Schrijver }
2992e745f992SPeter De Schrijver
2993bc2e4d29SThierry Reding /*
299405308d7eSThierry Reding * The SOR hardware blocks are driven by two clocks: a module clock that is
299505308d7eSThierry Reding * used to access registers and a pixel clock that is sourced from the same
299605308d7eSThierry Reding * pixel clock that also drives the head attached to the SOR. The module
299705308d7eSThierry Reding * clock is typically called sorX (with X being the SOR instance) and the
299805308d7eSThierry Reding * pixel clock is called sorX_out. The source for the SOR pixel clock is
299905308d7eSThierry Reding * referred to as the "parent" clock.
300005308d7eSThierry Reding *
300105308d7eSThierry Reding * On Tegra186 and newer, clocks are provided by the BPMP. Unfortunately the
300205308d7eSThierry Reding * BPMP implementation for the SOR clocks doesn't exactly match the above in
300305308d7eSThierry Reding * some aspects. For example, the SOR module is really clocked by the pad or
300405308d7eSThierry Reding * sor_safe clocks, but BPMP models the sorX clock as being sourced by the
300505308d7eSThierry Reding * pixel clocks. Conversely the sorX_out clock is sourced by the sor_safe or
300605308d7eSThierry Reding * pad clocks on BPMP.
300705308d7eSThierry Reding *
300805308d7eSThierry Reding * In order to allow the display driver to deal with all SoC generations in
300905308d7eSThierry Reding * a unified way, implement the BPMP semantics in this driver.
3010bc2e4d29SThierry Reding */
301105308d7eSThierry Reding
301205308d7eSThierry Reding static const char * const sor0_parents[] = {
301305308d7eSThierry Reding "pll_d_out0",
301405308d7eSThierry Reding };
301505308d7eSThierry Reding
301605308d7eSThierry Reding static const char * const sor0_out_parents[] = {
301705308d7eSThierry Reding "sor_safe", "sor0_pad_clkout",
3018bc2e4d29SThierry Reding };
3019bc2e4d29SThierry Reding
3020bc2e4d29SThierry Reding static const char * const sor1_parents[] = {
3021bc2e4d29SThierry Reding "pll_p", "pll_d_out0", "pll_d2_out0", "clk_m",
3022bc2e4d29SThierry Reding };
3023bc2e4d29SThierry Reding
3024bc2e4d29SThierry Reding static u32 sor1_parents_idx[] = { 0, 2, 5, 6 };
3025bc2e4d29SThierry Reding
30261d3e3c4eSJoseph Lo static const struct clk_div_table mc_div_table_tegra210[] = {
30271d3e3c4eSJoseph Lo { .val = 0, .div = 2 },
30281d3e3c4eSJoseph Lo { .val = 1, .div = 4 },
30291d3e3c4eSJoseph Lo { .val = 2, .div = 1 },
30301d3e3c4eSJoseph Lo { .val = 3, .div = 2 },
30311d3e3c4eSJoseph Lo { .val = 0, .div = 0 },
30321d3e3c4eSJoseph Lo };
30331d3e3c4eSJoseph Lo
tegra210_clk_register_mc(const char * name,const char * parent_name)30341d3e3c4eSJoseph Lo static void tegra210_clk_register_mc(const char *name,
30351d3e3c4eSJoseph Lo const char *parent_name)
30361d3e3c4eSJoseph Lo {
30371d3e3c4eSJoseph Lo struct clk *clk;
30381d3e3c4eSJoseph Lo
30391d3e3c4eSJoseph Lo clk = clk_register_divider_table(NULL, name, parent_name,
30401d3e3c4eSJoseph Lo CLK_IS_CRITICAL,
30411d3e3c4eSJoseph Lo clk_base + CLK_SOURCE_EMC,
30421d3e3c4eSJoseph Lo 15, 2, CLK_DIVIDER_READ_ONLY,
30431d3e3c4eSJoseph Lo mc_div_table_tegra210, &emc_lock);
30441d3e3c4eSJoseph Lo clks[TEGRA210_CLK_MC] = clk;
30451d3e3c4eSJoseph Lo }
30461d3e3c4eSJoseph Lo
304705308d7eSThierry Reding static const char * const sor1_out_parents[] = {
304805308d7eSThierry Reding /*
304905308d7eSThierry Reding * Bit 0 of the mux selects sor1_pad_clkout, irrespective of bit 1, so
305005308d7eSThierry Reding * the sor1_pad_clkout parent appears twice in the list below. This is
305105308d7eSThierry Reding * merely to support clk_get_parent() if firmware happened to set
305205308d7eSThierry Reding * these bits to 0b11. While not an invalid setting, code should
305305308d7eSThierry Reding * always set the bits to 0b01 to select sor1_pad_clkout.
305405308d7eSThierry Reding */
305505308d7eSThierry Reding "sor_safe", "sor1_pad_clkout", "sor1_out", "sor1_pad_clkout",
305605308d7eSThierry Reding };
305705308d7eSThierry Reding
3058bc2e4d29SThierry Reding static struct tegra_periph_init_data tegra210_periph[] = {
305905308d7eSThierry Reding /*
306005308d7eSThierry Reding * On Tegra210, the sor0 clock doesn't have a mux it bitfield 31:29,
306105308d7eSThierry Reding * but it is hardwired to the pll_d_out0 clock.
306205308d7eSThierry Reding */
306305308d7eSThierry Reding TEGRA_INIT_DATA_TABLE("sor0", NULL, NULL, sor0_parents,
306405308d7eSThierry Reding CLK_SOURCE_SOR0, 29, 0x0, 0, 0, 0, 0,
306505308d7eSThierry Reding 0, 182, 0, tegra_clk_sor0, NULL, 0,
306605308d7eSThierry Reding &sor0_lock),
306705308d7eSThierry Reding TEGRA_INIT_DATA_TABLE("sor0_out", NULL, NULL, sor0_out_parents,
306805308d7eSThierry Reding CLK_SOURCE_SOR0, 14, 0x1, 0, 0, 0, 0,
306905308d7eSThierry Reding 0, 0, TEGRA_PERIPH_NO_GATE, tegra_clk_sor0_out,
307005308d7eSThierry Reding NULL, 0, &sor0_lock),
3071bc2e4d29SThierry Reding TEGRA_INIT_DATA_TABLE("sor1", NULL, NULL, sor1_parents,
3072bc2e4d29SThierry Reding CLK_SOURCE_SOR1, 29, 0x7, 0, 0, 8, 1,
307305308d7eSThierry Reding TEGRA_DIVIDER_ROUND_UP, 183, 0,
307405308d7eSThierry Reding tegra_clk_sor1, sor1_parents_idx, 0,
307505308d7eSThierry Reding &sor1_lock),
307605308d7eSThierry Reding TEGRA_INIT_DATA_TABLE("sor1_out", NULL, NULL, sor1_out_parents,
307705308d7eSThierry Reding CLK_SOURCE_SOR1, 14, 0x3, 0, 0, 0, 0,
307805308d7eSThierry Reding 0, 0, TEGRA_PERIPH_NO_GATE,
307905308d7eSThierry Reding tegra_clk_sor1_out, NULL, 0, &sor1_lock),
3080bc2e4d29SThierry Reding };
3081bc2e4d29SThierry Reding
308289e423c3SPeter De Schrijver static const char * const la_parents[] = {
308389e423c3SPeter De Schrijver "pll_p", "pll_c2", "pll_c", "pll_c3", "pll_re_out1", "pll_a1", "clk_m", "pll_c4_out0"
308489e423c3SPeter De Schrijver };
308589e423c3SPeter De Schrijver
308689e423c3SPeter De Schrijver static struct tegra_clk_periph tegra210_la =
3087ba0eb9d5SStephen Boyd TEGRA_CLK_PERIPH(29, 7, 9, 0, 8, 1, TEGRA_DIVIDER_ROUND_UP, 76, 0, NULL, NULL);
308889e423c3SPeter De Schrijver
tegra210_periph_clk_init(struct device_node * np,void __iomem * clk_base,void __iomem * pmc_base)30891d3e3c4eSJoseph Lo static __init void tegra210_periph_clk_init(struct device_node *np,
30901d3e3c4eSJoseph Lo void __iomem *clk_base,
30916b301a05SRhyland Klein void __iomem *pmc_base)
30926b301a05SRhyland Klein {
30936b301a05SRhyland Klein struct clk *clk;
3094bc2e4d29SThierry Reding unsigned int i;
30956b301a05SRhyland Klein
30966b301a05SRhyland Klein /* xusb_ss_div2 */
30976b301a05SRhyland Klein clk = clk_register_fixed_factor(NULL, "xusb_ss_div2", "xusb_ss_src", 0,
30986b301a05SRhyland Klein 1, 2);
30996b301a05SRhyland Klein clks[TEGRA210_CLK_XUSB_SS_DIV2] = clk;
31006b301a05SRhyland Klein
310174d3ba0bSThierry Reding clk = tegra_clk_register_periph_fixed("sor_safe", "pll_p", 0, clk_base,
310274d3ba0bSThierry Reding 1, 17, 222);
310374d3ba0bSThierry Reding clks[TEGRA210_CLK_SOR_SAFE] = clk;
310474d3ba0bSThierry Reding
31052e34c2acSThierry Reding clk = tegra_clk_register_periph_fixed("dpaux", "sor_safe", 0, clk_base,
3106eede7113SThierry Reding 1, 17, 181);
3107eede7113SThierry Reding clks[TEGRA210_CLK_DPAUX] = clk;
3108eede7113SThierry Reding
31092e34c2acSThierry Reding clk = tegra_clk_register_periph_fixed("dpaux1", "sor_safe", 0, clk_base,
3110eede7113SThierry Reding 1, 17, 207);
3111eede7113SThierry Reding clks[TEGRA210_CLK_DPAUX1] = clk;
3112eede7113SThierry Reding
31136b301a05SRhyland Klein /* pll_d_dsi_out */
31146b301a05SRhyland Klein clk = clk_register_gate(NULL, "pll_d_dsi_out", "pll_d_out0", 0,
31156b301a05SRhyland Klein clk_base + PLLD_MISC0, 21, 0, &pll_d_lock);
31166b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_D_DSI_OUT] = clk;
31176b301a05SRhyland Klein
31186b301a05SRhyland Klein /* dsia */
31196b301a05SRhyland Klein clk = tegra_clk_register_periph_gate("dsia", "pll_d_dsi_out", 0,
31206b301a05SRhyland Klein clk_base, 0, 48,
31216b301a05SRhyland Klein periph_clk_enb_refcnt);
31226b301a05SRhyland Klein clks[TEGRA210_CLK_DSIA] = clk;
31236b301a05SRhyland Klein
31246b301a05SRhyland Klein /* dsib */
31256b301a05SRhyland Klein clk = tegra_clk_register_periph_gate("dsib", "pll_d_dsi_out", 0,
31266b301a05SRhyland Klein clk_base, 0, 82,
31276b301a05SRhyland Klein periph_clk_enb_refcnt);
31286b301a05SRhyland Klein clks[TEGRA210_CLK_DSIB] = clk;
31296b301a05SRhyland Klein
3130dec39632SSowjanya Komatineni /* csi_tpg */
3131dec39632SSowjanya Komatineni clk = clk_register_gate(NULL, "csi_tpg", "pll_d",
3132dec39632SSowjanya Komatineni CLK_SET_RATE_PARENT, clk_base + PLLD_BASE,
3133dec39632SSowjanya Komatineni 23, 0, &pll_d_lock);
3134dec39632SSowjanya Komatineni clk_register_clkdev(clk, "csi_tpg", NULL);
3135dec39632SSowjanya Komatineni clks[TEGRA210_CLK_CSI_TPG] = clk;
3136dec39632SSowjanya Komatineni
313789e423c3SPeter De Schrijver /* la */
313889e423c3SPeter De Schrijver clk = tegra_clk_register_periph("la", la_parents,
313989e423c3SPeter De Schrijver ARRAY_SIZE(la_parents), &tegra210_la, clk_base,
314089e423c3SPeter De Schrijver CLK_SOURCE_LA, 0);
314189e423c3SPeter De Schrijver clks[TEGRA210_CLK_LA] = clk;
314289e423c3SPeter De Schrijver
31436b301a05SRhyland Klein /* cml0 */
31446b301a05SRhyland Klein clk = clk_register_gate(NULL, "cml0", "pll_e", 0, clk_base + PLLE_AUX,
31456b301a05SRhyland Klein 0, 0, &pll_e_lock);
31466b301a05SRhyland Klein clk_register_clkdev(clk, "cml0", NULL);
31476b301a05SRhyland Klein clks[TEGRA210_CLK_CML0] = clk;
31486b301a05SRhyland Klein
31496b301a05SRhyland Klein /* cml1 */
31506b301a05SRhyland Klein clk = clk_register_gate(NULL, "cml1", "pll_e", 0, clk_base + PLLE_AUX,
31516b301a05SRhyland Klein 1, 0, &pll_e_lock);
31526b301a05SRhyland Klein clk_register_clkdev(clk, "cml1", NULL);
31536b301a05SRhyland Klein clks[TEGRA210_CLK_CML1] = clk;
31546b301a05SRhyland Klein
315524c3ebefSPeter De Schrijver clk = tegra_clk_register_super_clk("aclk", aclk_parents,
315624c3ebefSPeter De Schrijver ARRAY_SIZE(aclk_parents), 0, clk_base + 0x6e0,
315724c3ebefSPeter De Schrijver 0, NULL);
315824c3ebefSPeter De Schrijver clks[TEGRA210_CLK_ACLK] = clk;
315924c3ebefSPeter De Schrijver
3160c76a69e4SPeter De-Schrijver clk = tegra_clk_register_sdmmc_mux_div("sdmmc2", clk_base,
3161c76a69e4SPeter De-Schrijver CLK_SOURCE_SDMMC2, 9,
3162c76a69e4SPeter De-Schrijver TEGRA_DIVIDER_ROUND_UP, 0, NULL);
3163c76a69e4SPeter De-Schrijver clks[TEGRA210_CLK_SDMMC2] = clk;
3164c76a69e4SPeter De-Schrijver
3165c76a69e4SPeter De-Schrijver clk = tegra_clk_register_sdmmc_mux_div("sdmmc4", clk_base,
3166c76a69e4SPeter De-Schrijver CLK_SOURCE_SDMMC4, 15,
3167c76a69e4SPeter De-Schrijver TEGRA_DIVIDER_ROUND_UP, 0, NULL);
3168c76a69e4SPeter De-Schrijver clks[TEGRA210_CLK_SDMMC4] = clk;
3169c76a69e4SPeter De-Schrijver
3170bc2e4d29SThierry Reding for (i = 0; i < ARRAY_SIZE(tegra210_periph); i++) {
3171bc2e4d29SThierry Reding struct tegra_periph_init_data *init = &tegra210_periph[i];
3172bc2e4d29SThierry Reding struct clk **clkp;
3173bc2e4d29SThierry Reding
3174bc2e4d29SThierry Reding clkp = tegra_lookup_dt_id(init->clk_id, tegra210_clks);
3175bc2e4d29SThierry Reding if (!clkp) {
3176bc2e4d29SThierry Reding pr_warn("clock %u not found\n", init->clk_id);
3177bc2e4d29SThierry Reding continue;
3178bc2e4d29SThierry Reding }
3179bc2e4d29SThierry Reding
3180bc2e4d29SThierry Reding clk = tegra_clk_register_periph_data(clk_base, init);
3181bc2e4d29SThierry Reding *clkp = clk;
3182bc2e4d29SThierry Reding }
3183bc2e4d29SThierry Reding
31846b301a05SRhyland Klein tegra_periph_clk_init(clk_base, pmc_base, tegra210_clks, &pll_p_params);
31851d3e3c4eSJoseph Lo
31861d3e3c4eSJoseph Lo /* emc */
31871d3e3c4eSJoseph Lo clk = tegra210_clk_register_emc(np, clk_base);
31881d3e3c4eSJoseph Lo clks[TEGRA210_CLK_EMC] = clk;
31891d3e3c4eSJoseph Lo
31901d3e3c4eSJoseph Lo /* mc */
31911d3e3c4eSJoseph Lo tegra210_clk_register_mc("mc", "emc");
31926b301a05SRhyland Klein }
31936b301a05SRhyland Klein
tegra210_pll_init(void __iomem * clk_base,void __iomem * pmc)31946b301a05SRhyland Klein static void __init tegra210_pll_init(void __iomem *clk_base,
31956b301a05SRhyland Klein void __iomem *pmc)
31966b301a05SRhyland Klein {
31976b301a05SRhyland Klein struct clk *clk;
31986b301a05SRhyland Klein
31996b301a05SRhyland Klein /* PLLC */
3200ac99afe5SAlex Frid clk = tegra_clk_register_pllc_tegra210("pll_c", "pll_ref", clk_base,
32016b301a05SRhyland Klein pmc, 0, &pll_c_params, NULL);
32026b301a05SRhyland Klein if (!WARN_ON(IS_ERR(clk)))
32036b301a05SRhyland Klein clk_register_clkdev(clk, "pll_c", NULL);
32046b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_C] = clk;
32056b301a05SRhyland Klein
32066b301a05SRhyland Klein /* PLLC_OUT1 */
32076b301a05SRhyland Klein clk = tegra_clk_register_divider("pll_c_out1_div", "pll_c",
32086b301a05SRhyland Klein clk_base + PLLC_OUT, 0, TEGRA_DIVIDER_ROUND_UP,
32096b301a05SRhyland Klein 8, 8, 1, NULL);
32106b301a05SRhyland Klein clk = tegra_clk_register_pll_out("pll_c_out1", "pll_c_out1_div",
32116b301a05SRhyland Klein clk_base + PLLC_OUT, 1, 0,
32126b301a05SRhyland Klein CLK_SET_RATE_PARENT, 0, NULL);
32136b301a05SRhyland Klein clk_register_clkdev(clk, "pll_c_out1", NULL);
32146b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_C_OUT1] = clk;
32156b301a05SRhyland Klein
32166b301a05SRhyland Klein /* PLLC_UD */
32176b301a05SRhyland Klein clk = clk_register_fixed_factor(NULL, "pll_c_ud", "pll_c",
32186b301a05SRhyland Klein CLK_SET_RATE_PARENT, 1, 1);
32196b301a05SRhyland Klein clk_register_clkdev(clk, "pll_c_ud", NULL);
32206b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_C_UD] = clk;
32216b301a05SRhyland Klein
32226b301a05SRhyland Klein /* PLLC2 */
32236b301a05SRhyland Klein clk = tegra_clk_register_pllc_tegra210("pll_c2", "pll_ref", clk_base,
32246b301a05SRhyland Klein pmc, 0, &pll_c2_params, NULL);
32256b301a05SRhyland Klein clk_register_clkdev(clk, "pll_c2", NULL);
32266b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_C2] = clk;
32276b301a05SRhyland Klein
32286b301a05SRhyland Klein /* PLLC3 */
32296b301a05SRhyland Klein clk = tegra_clk_register_pllc_tegra210("pll_c3", "pll_ref", clk_base,
32306b301a05SRhyland Klein pmc, 0, &pll_c3_params, NULL);
32316b301a05SRhyland Klein clk_register_clkdev(clk, "pll_c3", NULL);
32326b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_C3] = clk;
32336b301a05SRhyland Klein
32346b301a05SRhyland Klein /* PLLM */
32356b301a05SRhyland Klein clk = tegra_clk_register_pllm("pll_m", "osc", clk_base, pmc,
32366b301a05SRhyland Klein CLK_SET_RATE_GATE, &pll_m_params, NULL);
32376b301a05SRhyland Klein clk_register_clkdev(clk, "pll_m", NULL);
32386b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_M] = clk;
32396b301a05SRhyland Klein
32406b301a05SRhyland Klein /* PLLMB */
32416b301a05SRhyland Klein clk = tegra_clk_register_pllmb("pll_mb", "osc", clk_base, pmc,
32426b301a05SRhyland Klein CLK_SET_RATE_GATE, &pll_mb_params, NULL);
32436b301a05SRhyland Klein clk_register_clkdev(clk, "pll_mb", NULL);
32446b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_MB] = clk;
32456b301a05SRhyland Klein
32466b301a05SRhyland Klein /* PLLM_UD */
32476b301a05SRhyland Klein clk = clk_register_fixed_factor(NULL, "pll_m_ud", "pll_m",
32486b301a05SRhyland Klein CLK_SET_RATE_PARENT, 1, 1);
32496b301a05SRhyland Klein clk_register_clkdev(clk, "pll_m_ud", NULL);
32506b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_M_UD] = clk;
32516b301a05SRhyland Klein
3252cd4d6f35SJoseph Lo /* PLLMB_UD */
3253cd4d6f35SJoseph Lo clk = clk_register_fixed_factor(NULL, "pll_mb_ud", "pll_mb",
3254cd4d6f35SJoseph Lo CLK_SET_RATE_PARENT, 1, 1);
3255cd4d6f35SJoseph Lo clk_register_clkdev(clk, "pll_mb_ud", NULL);
3256cd4d6f35SJoseph Lo clks[TEGRA210_CLK_PLL_MB_UD] = clk;
3257cd4d6f35SJoseph Lo
3258cd4d6f35SJoseph Lo /* PLLP_UD */
3259cd4d6f35SJoseph Lo clk = clk_register_fixed_factor(NULL, "pll_p_ud", "pll_p",
3260cd4d6f35SJoseph Lo 0, 1, 1);
3261cd4d6f35SJoseph Lo clks[TEGRA210_CLK_PLL_P_UD] = clk;
3262cd4d6f35SJoseph Lo
32636b301a05SRhyland Klein /* PLLU_VCO */
3264e745f992SPeter De Schrijver if (!tegra210_init_pllu()) {
3265e745f992SPeter De Schrijver clk = clk_register_fixed_rate(NULL, "pll_u_vco", "pll_ref", 0,
3266e745f992SPeter De Schrijver 480*1000*1000);
32676b301a05SRhyland Klein clk_register_clkdev(clk, "pll_u_vco", NULL);
32686b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_U] = clk;
3269e745f992SPeter De Schrijver }
32706b301a05SRhyland Klein
32716b301a05SRhyland Klein /* PLLU_OUT */
32726b301a05SRhyland Klein clk = clk_register_divider_table(NULL, "pll_u_out", "pll_u_vco", 0,
32736b301a05SRhyland Klein clk_base + PLLU_BASE, 16, 4, 0,
32746b301a05SRhyland Klein pll_vco_post_div_table, NULL);
32756b301a05SRhyland Klein clk_register_clkdev(clk, "pll_u_out", NULL);
32766b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_U_OUT] = clk;
32776b301a05SRhyland Klein
32786b301a05SRhyland Klein /* PLLU_OUT1 */
32796b301a05SRhyland Klein clk = tegra_clk_register_divider("pll_u_out1_div", "pll_u_out",
32806b301a05SRhyland Klein clk_base + PLLU_OUTA, 0,
32816b301a05SRhyland Klein TEGRA_DIVIDER_ROUND_UP,
32826b301a05SRhyland Klein 8, 8, 1, &pll_u_lock);
32836b301a05SRhyland Klein clk = tegra_clk_register_pll_out("pll_u_out1", "pll_u_out1_div",
32846b301a05SRhyland Klein clk_base + PLLU_OUTA, 1, 0,
32856b301a05SRhyland Klein CLK_SET_RATE_PARENT, 0, &pll_u_lock);
32866b301a05SRhyland Klein clk_register_clkdev(clk, "pll_u_out1", NULL);
32876b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_U_OUT1] = clk;
32886b301a05SRhyland Klein
32896b301a05SRhyland Klein /* PLLU_OUT2 */
32906b301a05SRhyland Klein clk = tegra_clk_register_divider("pll_u_out2_div", "pll_u_out",
32916b301a05SRhyland Klein clk_base + PLLU_OUTA, 0,
32926b301a05SRhyland Klein TEGRA_DIVIDER_ROUND_UP,
32936b301a05SRhyland Klein 24, 8, 1, &pll_u_lock);
32946b301a05SRhyland Klein clk = tegra_clk_register_pll_out("pll_u_out2", "pll_u_out2_div",
32956b301a05SRhyland Klein clk_base + PLLU_OUTA, 17, 16,
32966b301a05SRhyland Klein CLK_SET_RATE_PARENT, 0, &pll_u_lock);
32976b301a05SRhyland Klein clk_register_clkdev(clk, "pll_u_out2", NULL);
32986b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_U_OUT2] = clk;
32996b301a05SRhyland Klein
33006b301a05SRhyland Klein /* PLLU_480M */
33016b301a05SRhyland Klein clk = clk_register_gate(NULL, "pll_u_480M", "pll_u_vco",
33026b301a05SRhyland Klein CLK_SET_RATE_PARENT, clk_base + PLLU_BASE,
33036b301a05SRhyland Klein 22, 0, &pll_u_lock);
33046b301a05SRhyland Klein clk_register_clkdev(clk, "pll_u_480M", NULL);
33056b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_U_480M] = clk;
33066b301a05SRhyland Klein
33076b301a05SRhyland Klein /* PLLU_60M */
33086b301a05SRhyland Klein clk = clk_register_gate(NULL, "pll_u_60M", "pll_u_out2",
33096b301a05SRhyland Klein CLK_SET_RATE_PARENT, clk_base + PLLU_BASE,
33107157c69aSAlex Frid 23, 0, &pll_u_lock);
33116b301a05SRhyland Klein clk_register_clkdev(clk, "pll_u_60M", NULL);
33126b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_U_60M] = clk;
33136b301a05SRhyland Klein
33146b301a05SRhyland Klein /* PLLU_48M */
33156b301a05SRhyland Klein clk = clk_register_gate(NULL, "pll_u_48M", "pll_u_out1",
33166b301a05SRhyland Klein CLK_SET_RATE_PARENT, clk_base + PLLU_BASE,
33177157c69aSAlex Frid 25, 0, &pll_u_lock);
33186b301a05SRhyland Klein clk_register_clkdev(clk, "pll_u_48M", NULL);
33196b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_U_48M] = clk;
33206b301a05SRhyland Klein
33216b301a05SRhyland Klein /* PLLD */
33226b301a05SRhyland Klein clk = tegra_clk_register_pll("pll_d", "pll_ref", clk_base, pmc, 0,
33236b301a05SRhyland Klein &pll_d_params, &pll_d_lock);
33246b301a05SRhyland Klein clk_register_clkdev(clk, "pll_d", NULL);
33256b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_D] = clk;
33266b301a05SRhyland Klein
33276b301a05SRhyland Klein /* PLLD_OUT0 */
33286b301a05SRhyland Klein clk = clk_register_fixed_factor(NULL, "pll_d_out0", "pll_d",
33296b301a05SRhyland Klein CLK_SET_RATE_PARENT, 1, 2);
33306b301a05SRhyland Klein clk_register_clkdev(clk, "pll_d_out0", NULL);
33316b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_D_OUT0] = clk;
33326b301a05SRhyland Klein
33336b301a05SRhyland Klein /* PLLRE */
3334926655f9SRhyland Klein clk = tegra_clk_register_pllre_tegra210("pll_re_vco", "pll_ref",
3335926655f9SRhyland Klein clk_base, pmc, 0,
3336926655f9SRhyland Klein &pll_re_vco_params,
3337926655f9SRhyland Klein &pll_re_lock, pll_ref_freq);
33386b301a05SRhyland Klein clk_register_clkdev(clk, "pll_re_vco", NULL);
33396b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_RE_VCO] = clk;
33406b301a05SRhyland Klein
33416b301a05SRhyland Klein clk = clk_register_divider_table(NULL, "pll_re_out", "pll_re_vco", 0,
33426b301a05SRhyland Klein clk_base + PLLRE_BASE, 16, 5, 0,
33436b301a05SRhyland Klein pll_vco_post_div_table, &pll_re_lock);
33446b301a05SRhyland Klein clk_register_clkdev(clk, "pll_re_out", NULL);
33456b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_RE_OUT] = clk;
33466b301a05SRhyland Klein
3347926655f9SRhyland Klein clk = tegra_clk_register_divider("pll_re_out1_div", "pll_re_vco",
3348926655f9SRhyland Klein clk_base + PLLRE_OUT1, 0,
3349926655f9SRhyland Klein TEGRA_DIVIDER_ROUND_UP,
3350926655f9SRhyland Klein 8, 8, 1, NULL);
3351926655f9SRhyland Klein clk = tegra_clk_register_pll_out("pll_re_out1", "pll_re_out1_div",
3352926655f9SRhyland Klein clk_base + PLLRE_OUT1, 1, 0,
3353926655f9SRhyland Klein CLK_SET_RATE_PARENT, 0, NULL);
3354926655f9SRhyland Klein clks[TEGRA210_CLK_PLL_RE_OUT1] = clk;
3355926655f9SRhyland Klein
33566b301a05SRhyland Klein /* PLLE */
33576b301a05SRhyland Klein clk = tegra_clk_register_plle_tegra210("pll_e", "pll_ref",
33586b301a05SRhyland Klein clk_base, 0, &pll_e_params, NULL);
33596b301a05SRhyland Klein clk_register_clkdev(clk, "pll_e", NULL);
33606b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_E] = clk;
33616b301a05SRhyland Klein
33626b301a05SRhyland Klein /* PLLC4 */
33636b301a05SRhyland Klein clk = tegra_clk_register_pllre("pll_c4_vco", "pll_ref", clk_base, pmc,
33646b301a05SRhyland Klein 0, &pll_c4_vco_params, NULL, pll_ref_freq);
33656b301a05SRhyland Klein clk_register_clkdev(clk, "pll_c4_vco", NULL);
33666b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_C4] = clk;
33676b301a05SRhyland Klein
33686b301a05SRhyland Klein /* PLLC4_OUT0 */
33696b301a05SRhyland Klein clk = clk_register_divider_table(NULL, "pll_c4_out0", "pll_c4_vco", 0,
33706b301a05SRhyland Klein clk_base + PLLC4_BASE, 19, 4, 0,
33716b301a05SRhyland Klein pll_vco_post_div_table, NULL);
33726b301a05SRhyland Klein clk_register_clkdev(clk, "pll_c4_out0", NULL);
33736b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_C4_OUT0] = clk;
33746b301a05SRhyland Klein
33756b301a05SRhyland Klein /* PLLC4_OUT1 */
33766b301a05SRhyland Klein clk = clk_register_fixed_factor(NULL, "pll_c4_out1", "pll_c4_vco",
33776b301a05SRhyland Klein CLK_SET_RATE_PARENT, 1, 3);
33786b301a05SRhyland Klein clk_register_clkdev(clk, "pll_c4_out1", NULL);
33796b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_C4_OUT1] = clk;
33806b301a05SRhyland Klein
33816b301a05SRhyland Klein /* PLLC4_OUT2 */
33826b301a05SRhyland Klein clk = clk_register_fixed_factor(NULL, "pll_c4_out2", "pll_c4_vco",
33836b301a05SRhyland Klein CLK_SET_RATE_PARENT, 1, 5);
33846b301a05SRhyland Klein clk_register_clkdev(clk, "pll_c4_out2", NULL);
33856b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_C4_OUT2] = clk;
33866b301a05SRhyland Klein
33876b301a05SRhyland Klein /* PLLC4_OUT3 */
33886b301a05SRhyland Klein clk = tegra_clk_register_divider("pll_c4_out3_div", "pll_c4_out0",
33896b301a05SRhyland Klein clk_base + PLLC4_OUT, 0, TEGRA_DIVIDER_ROUND_UP,
33906b301a05SRhyland Klein 8, 8, 1, NULL);
33916b301a05SRhyland Klein clk = tegra_clk_register_pll_out("pll_c4_out3", "pll_c4_out3_div",
33926b301a05SRhyland Klein clk_base + PLLC4_OUT, 1, 0,
33936b301a05SRhyland Klein CLK_SET_RATE_PARENT, 0, NULL);
33946b301a05SRhyland Klein clk_register_clkdev(clk, "pll_c4_out3", NULL);
33956b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_C4_OUT3] = clk;
33966b301a05SRhyland Klein
33976b301a05SRhyland Klein /* PLLDP */
33986b301a05SRhyland Klein clk = tegra_clk_register_pllss_tegra210("pll_dp", "pll_ref", clk_base,
33996b301a05SRhyland Klein 0, &pll_dp_params, NULL);
34006b301a05SRhyland Klein clk_register_clkdev(clk, "pll_dp", NULL);
34016b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_DP] = clk;
34026b301a05SRhyland Klein
34036b301a05SRhyland Klein /* PLLD2 */
34046b301a05SRhyland Klein clk = tegra_clk_register_pllss_tegra210("pll_d2", "pll_ref", clk_base,
34056b301a05SRhyland Klein 0, &pll_d2_params, NULL);
34066b301a05SRhyland Klein clk_register_clkdev(clk, "pll_d2", NULL);
34076b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_D2] = clk;
34086b301a05SRhyland Klein
34096b301a05SRhyland Klein /* PLLD2_OUT0 */
34106b301a05SRhyland Klein clk = clk_register_fixed_factor(NULL, "pll_d2_out0", "pll_d2",
34116b301a05SRhyland Klein CLK_SET_RATE_PARENT, 1, 1);
34126b301a05SRhyland Klein clk_register_clkdev(clk, "pll_d2_out0", NULL);
34136b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_D2_OUT0] = clk;
34146b301a05SRhyland Klein
34156b301a05SRhyland Klein /* PLLP_OUT2 */
34166b301a05SRhyland Klein clk = clk_register_fixed_factor(NULL, "pll_p_out2", "pll_p",
34176b301a05SRhyland Klein CLK_SET_RATE_PARENT, 1, 2);
34186b301a05SRhyland Klein clk_register_clkdev(clk, "pll_p_out2", NULL);
34196b301a05SRhyland Klein clks[TEGRA210_CLK_PLL_P_OUT2] = clk;
34206b301a05SRhyland Klein
34216b301a05SRhyland Klein }
34226b301a05SRhyland Klein
34236b301a05SRhyland Klein /* Tegra210 CPU clock and reset control functions */
tegra210_wait_cpu_in_reset(u32 cpu)34246b301a05SRhyland Klein static void tegra210_wait_cpu_in_reset(u32 cpu)
34256b301a05SRhyland Klein {
34266b301a05SRhyland Klein unsigned int reg;
34276b301a05SRhyland Klein
34286b301a05SRhyland Klein do {
34296b301a05SRhyland Klein reg = readl(clk_base + CLK_RST_CONTROLLER_CPU_CMPLX_STATUS);
34306b301a05SRhyland Klein cpu_relax();
34316b301a05SRhyland Klein } while (!(reg & (1 << cpu))); /* check CPU been reset or not */
34326b301a05SRhyland Klein }
34336b301a05SRhyland Klein
tegra210_disable_cpu_clock(u32 cpu)34346b301a05SRhyland Klein static void tegra210_disable_cpu_clock(u32 cpu)
34356b301a05SRhyland Klein {
34366b301a05SRhyland Klein /* flow controller would take care in the power sequence. */
34376b301a05SRhyland Klein }
34386b301a05SRhyland Klein
34396b301a05SRhyland Klein #ifdef CONFIG_PM_SLEEP
3440535f296dSSowjanya Komatineni #define car_readl(_base, _off) readl_relaxed(clk_base + (_base) + ((_off) * 4))
3441535f296dSSowjanya Komatineni #define car_writel(_val, _base, _off) \
3442535f296dSSowjanya Komatineni writel_relaxed(_val, clk_base + (_base) + ((_off) * 4))
3443535f296dSSowjanya Komatineni
3444535f296dSSowjanya Komatineni static u32 spare_reg_ctx, misc_clk_enb_ctx, clk_msk_arm_ctx;
3445535f296dSSowjanya Komatineni static u32 cpu_softrst_ctx[3];
3446535f296dSSowjanya Komatineni
tegra210_clk_suspend(void)3447535f296dSSowjanya Komatineni static int tegra210_clk_suspend(void)
3448535f296dSSowjanya Komatineni {
3449535f296dSSowjanya Komatineni unsigned int i;
3450535f296dSSowjanya Komatineni
3451535f296dSSowjanya Komatineni clk_save_context();
3452535f296dSSowjanya Komatineni
3453535f296dSSowjanya Komatineni /*
3454535f296dSSowjanya Komatineni * Save the bootloader configured clock registers SPARE_REG0,
3455535f296dSSowjanya Komatineni * MISC_CLK_ENB, CLK_MASK_ARM, CPU_SOFTRST_CTRL.
3456535f296dSSowjanya Komatineni */
3457535f296dSSowjanya Komatineni spare_reg_ctx = readl_relaxed(clk_base + SPARE_REG0);
3458535f296dSSowjanya Komatineni misc_clk_enb_ctx = readl_relaxed(clk_base + MISC_CLK_ENB);
3459535f296dSSowjanya Komatineni clk_msk_arm_ctx = readl_relaxed(clk_base + CLK_MASK_ARM);
3460535f296dSSowjanya Komatineni
3461535f296dSSowjanya Komatineni for (i = 0; i < ARRAY_SIZE(cpu_softrst_ctx); i++)
3462535f296dSSowjanya Komatineni cpu_softrst_ctx[i] = car_readl(CPU_SOFTRST_CTRL, i);
3463535f296dSSowjanya Komatineni
3464535f296dSSowjanya Komatineni tegra_clk_periph_suspend();
3465535f296dSSowjanya Komatineni return 0;
3466535f296dSSowjanya Komatineni }
3467535f296dSSowjanya Komatineni
tegra210_clk_resume(void)3468535f296dSSowjanya Komatineni static void tegra210_clk_resume(void)
3469535f296dSSowjanya Komatineni {
3470535f296dSSowjanya Komatineni unsigned int i;
3471535f296dSSowjanya Komatineni
3472535f296dSSowjanya Komatineni tegra_clk_osc_resume(clk_base);
3473535f296dSSowjanya Komatineni
3474535f296dSSowjanya Komatineni /*
3475535f296dSSowjanya Komatineni * Restore the bootloader configured clock registers SPARE_REG0,
3476535f296dSSowjanya Komatineni * MISC_CLK_ENB, CLK_MASK_ARM, CPU_SOFTRST_CTRL from saved context.
3477535f296dSSowjanya Komatineni */
3478535f296dSSowjanya Komatineni writel_relaxed(spare_reg_ctx, clk_base + SPARE_REG0);
3479535f296dSSowjanya Komatineni writel_relaxed(misc_clk_enb_ctx, clk_base + MISC_CLK_ENB);
3480535f296dSSowjanya Komatineni writel_relaxed(clk_msk_arm_ctx, clk_base + CLK_MASK_ARM);
3481535f296dSSowjanya Komatineni
3482535f296dSSowjanya Komatineni for (i = 0; i < ARRAY_SIZE(cpu_softrst_ctx); i++)
3483535f296dSSowjanya Komatineni car_writel(cpu_softrst_ctx[i], CPU_SOFTRST_CTRL, i);
3484535f296dSSowjanya Komatineni
3485535f296dSSowjanya Komatineni /*
3486535f296dSSowjanya Komatineni * Tegra clock programming sequence recommends peripheral clock to
3487535f296dSSowjanya Komatineni * be enabled prior to changing its clock source and divider to
3488535f296dSSowjanya Komatineni * prevent glitchless frequency switch.
3489535f296dSSowjanya Komatineni * So, enable all peripheral clocks before restoring their source
3490535f296dSSowjanya Komatineni * and dividers.
3491535f296dSSowjanya Komatineni */
3492535f296dSSowjanya Komatineni writel_relaxed(TEGRA210_CLK_ENB_VLD_MSK_L, clk_base + CLK_OUT_ENB_L);
3493535f296dSSowjanya Komatineni writel_relaxed(TEGRA210_CLK_ENB_VLD_MSK_H, clk_base + CLK_OUT_ENB_H);
3494535f296dSSowjanya Komatineni writel_relaxed(TEGRA210_CLK_ENB_VLD_MSK_U, clk_base + CLK_OUT_ENB_U);
3495535f296dSSowjanya Komatineni writel_relaxed(TEGRA210_CLK_ENB_VLD_MSK_V, clk_base + CLK_OUT_ENB_V);
3496535f296dSSowjanya Komatineni writel_relaxed(TEGRA210_CLK_ENB_VLD_MSK_W, clk_base + CLK_OUT_ENB_W);
3497535f296dSSowjanya Komatineni writel_relaxed(TEGRA210_CLK_ENB_VLD_MSK_X, clk_base + CLK_OUT_ENB_X);
3498535f296dSSowjanya Komatineni writel_relaxed(TEGRA210_CLK_ENB_VLD_MSK_Y, clk_base + CLK_OUT_ENB_Y);
3499535f296dSSowjanya Komatineni
3500535f296dSSowjanya Komatineni /* wait for all writes to happen to have all the clocks enabled */
3501535f296dSSowjanya Komatineni fence_udelay(2, clk_base);
3502535f296dSSowjanya Komatineni
3503535f296dSSowjanya Komatineni /* restore PLLs and all peripheral clock rates */
3504535f296dSSowjanya Komatineni tegra210_init_pllu();
3505535f296dSSowjanya Komatineni clk_restore_context();
3506535f296dSSowjanya Komatineni
3507535f296dSSowjanya Komatineni /* restore saved context of peripheral clocks and reset state */
3508535f296dSSowjanya Komatineni tegra_clk_periph_resume();
3509535f296dSSowjanya Komatineni }
3510535f296dSSowjanya Komatineni
tegra210_cpu_clock_suspend(void)35116b301a05SRhyland Klein static void tegra210_cpu_clock_suspend(void)
35126b301a05SRhyland Klein {
35136b301a05SRhyland Klein /* switch coresite to clk_m, save off original source */
35146b301a05SRhyland Klein tegra210_cpu_clk_sctx.clk_csite_src =
35156b301a05SRhyland Klein readl(clk_base + CLK_SOURCE_CSITE);
35166b301a05SRhyland Klein writel(3 << 30, clk_base + CLK_SOURCE_CSITE);
35176b301a05SRhyland Klein }
35186b301a05SRhyland Klein
tegra210_cpu_clock_resume(void)35196b301a05SRhyland Klein static void tegra210_cpu_clock_resume(void)
35206b301a05SRhyland Klein {
35216b301a05SRhyland Klein writel(tegra210_cpu_clk_sctx.clk_csite_src,
35226b301a05SRhyland Klein clk_base + CLK_SOURCE_CSITE);
35236b301a05SRhyland Klein }
35246b301a05SRhyland Klein #endif
35256b301a05SRhyland Klein
3526535f296dSSowjanya Komatineni static struct syscore_ops tegra_clk_syscore_ops = {
352707b293c5SYueHaibing #ifdef CONFIG_PM_SLEEP
3528535f296dSSowjanya Komatineni .suspend = tegra210_clk_suspend,
3529535f296dSSowjanya Komatineni .resume = tegra210_clk_resume,
353007b293c5SYueHaibing #endif
3531535f296dSSowjanya Komatineni };
3532535f296dSSowjanya Komatineni
35336b301a05SRhyland Klein static struct tegra_cpu_car_ops tegra210_cpu_car_ops = {
35346b301a05SRhyland Klein .wait_for_reset = tegra210_wait_cpu_in_reset,
35356b301a05SRhyland Klein .disable_clock = tegra210_disable_cpu_clock,
35366b301a05SRhyland Klein #ifdef CONFIG_PM_SLEEP
35376b301a05SRhyland Klein .suspend = tegra210_cpu_clock_suspend,
35386b301a05SRhyland Klein .resume = tegra210_cpu_clock_resume,
35396b301a05SRhyland Klein #endif
35406b301a05SRhyland Klein };
35416b301a05SRhyland Klein
35426b301a05SRhyland Klein static const struct of_device_id pmc_match[] __initconst = {
35436b301a05SRhyland Klein { .compatible = "nvidia,tegra210-pmc" },
35446b301a05SRhyland Klein { },
35456b301a05SRhyland Klein };
35466b301a05SRhyland Klein
35476b301a05SRhyland Klein static struct tegra_clk_init_table init_table[] __initdata = {
35486b301a05SRhyland Klein { TEGRA210_CLK_UARTA, TEGRA210_CLK_PLL_P, 408000000, 0 },
35496b301a05SRhyland Klein { TEGRA210_CLK_UARTB, TEGRA210_CLK_PLL_P, 408000000, 0 },
35506b301a05SRhyland Klein { TEGRA210_CLK_UARTC, TEGRA210_CLK_PLL_P, 408000000, 0 },
35516b301a05SRhyland Klein { TEGRA210_CLK_UARTD, TEGRA210_CLK_PLL_P, 408000000, 0 },
3552efdd205cSSowjanya Komatineni { TEGRA210_CLK_PLL_A, TEGRA210_CLK_CLK_MAX, 564480000, 0 },
3553efdd205cSSowjanya Komatineni { TEGRA210_CLK_PLL_A_OUT0, TEGRA210_CLK_CLK_MAX, 11289600, 0 },
35546b301a05SRhyland Klein { TEGRA210_CLK_I2S0, TEGRA210_CLK_PLL_A_OUT0, 11289600, 0 },
35556b301a05SRhyland Klein { TEGRA210_CLK_I2S1, TEGRA210_CLK_PLL_A_OUT0, 11289600, 0 },
35566b301a05SRhyland Klein { TEGRA210_CLK_I2S2, TEGRA210_CLK_PLL_A_OUT0, 11289600, 0 },
35576b301a05SRhyland Klein { TEGRA210_CLK_I2S3, TEGRA210_CLK_PLL_A_OUT0, 11289600, 0 },
35586b301a05SRhyland Klein { TEGRA210_CLK_I2S4, TEGRA210_CLK_PLL_A_OUT0, 11289600, 0 },
35596b301a05SRhyland Klein { TEGRA210_CLK_HOST1X, TEGRA210_CLK_PLL_P, 136000000, 1 },
35606b301a05SRhyland Klein { TEGRA210_CLK_SCLK_MUX, TEGRA210_CLK_PLL_P, 0, 1 },
35612dcabf05SDmitry Osipenko { TEGRA210_CLK_SCLK, TEGRA210_CLK_CLK_MAX, 102000000, 0 },
35626b301a05SRhyland Klein { TEGRA210_CLK_DFLL_SOC, TEGRA210_CLK_PLL_P, 51000000, 1 },
35636b301a05SRhyland Klein { TEGRA210_CLK_DFLL_REF, TEGRA210_CLK_PLL_P, 51000000, 1 },
35646b301a05SRhyland Klein { TEGRA210_CLK_SBC4, TEGRA210_CLK_PLL_P, 12000000, 1 },
35650d34dfbfSJC Kuo { TEGRA210_CLK_PLL_U_OUT1, TEGRA210_CLK_CLK_MAX, 48000000, 1 },
35666b301a05SRhyland Klein { TEGRA210_CLK_XUSB_GATE, TEGRA210_CLK_CLK_MAX, 0, 1 },
35676b301a05SRhyland Klein { TEGRA210_CLK_XUSB_SS_SRC, TEGRA210_CLK_PLL_U_480M, 120000000, 0 },
35686b301a05SRhyland Klein { TEGRA210_CLK_XUSB_FS_SRC, TEGRA210_CLK_PLL_U_48M, 48000000, 0 },
35696b301a05SRhyland Klein { TEGRA210_CLK_XUSB_HS_SRC, TEGRA210_CLK_XUSB_SS_SRC, 120000000, 0 },
35706b301a05SRhyland Klein { TEGRA210_CLK_XUSB_SSP_SRC, TEGRA210_CLK_XUSB_SS_SRC, 120000000, 0 },
35716b301a05SRhyland Klein { TEGRA210_CLK_XUSB_FALCON_SRC, TEGRA210_CLK_PLL_P_OUT_XUSB, 204000000, 0 },
35726b301a05SRhyland Klein { TEGRA210_CLK_XUSB_HOST_SRC, TEGRA210_CLK_PLL_P_OUT_XUSB, 102000000, 0 },
35736b301a05SRhyland Klein { TEGRA210_CLK_XUSB_DEV_SRC, TEGRA210_CLK_PLL_P_OUT_XUSB, 102000000, 0 },
35746b301a05SRhyland Klein { TEGRA210_CLK_SATA, TEGRA210_CLK_PLL_P, 104000000, 0 },
35756b301a05SRhyland Klein { TEGRA210_CLK_SATA_OOB, TEGRA210_CLK_PLL_P, 204000000, 0 },
35766b301a05SRhyland Klein { TEGRA210_CLK_MSELECT, TEGRA210_CLK_CLK_MAX, 0, 1 },
35776b301a05SRhyland Klein { TEGRA210_CLK_CSITE, TEGRA210_CLK_CLK_MAX, 0, 1 },
3578bea1baa1SPeter De Schrijver /* TODO find a way to enable this on-demand */
3579bea1baa1SPeter De Schrijver { TEGRA210_CLK_DBGAPB, TEGRA210_CLK_CLK_MAX, 0, 1 },
35806b301a05SRhyland Klein { TEGRA210_CLK_TSENSOR, TEGRA210_CLK_CLK_M, 400000, 0 },
35816b301a05SRhyland Klein { TEGRA210_CLK_I2C1, TEGRA210_CLK_PLL_P, 0, 0 },
35826b301a05SRhyland Klein { TEGRA210_CLK_I2C2, TEGRA210_CLK_PLL_P, 0, 0 },
35836b301a05SRhyland Klein { TEGRA210_CLK_I2C3, TEGRA210_CLK_PLL_P, 0, 0 },
35846b301a05SRhyland Klein { TEGRA210_CLK_I2C4, TEGRA210_CLK_PLL_P, 0, 0 },
35856b301a05SRhyland Klein { TEGRA210_CLK_I2C5, TEGRA210_CLK_PLL_P, 0, 0 },
35866b301a05SRhyland Klein { TEGRA210_CLK_I2C6, TEGRA210_CLK_PLL_P, 0, 0 },
35876b301a05SRhyland Klein { TEGRA210_CLK_PLL_DP, TEGRA210_CLK_CLK_MAX, 270000000, 0 },
35886b301a05SRhyland Klein { TEGRA210_CLK_SOC_THERM, TEGRA210_CLK_PLL_P, 51000000, 0 },
35896b301a05SRhyland Klein { TEGRA210_CLK_CCLK_G, TEGRA210_CLK_CLK_MAX, 0, 1 },
3590e745f992SPeter De Schrijver { TEGRA210_CLK_PLL_U_OUT2, TEGRA210_CLK_CLK_MAX, 60000000, 1 },
3591845d782dSJon Hunter { TEGRA210_CLK_SPDIF_IN_SYNC, TEGRA210_CLK_CLK_MAX, 24576000, 0 },
3592845d782dSJon Hunter { TEGRA210_CLK_I2S0_SYNC, TEGRA210_CLK_CLK_MAX, 24576000, 0 },
3593845d782dSJon Hunter { TEGRA210_CLK_I2S1_SYNC, TEGRA210_CLK_CLK_MAX, 24576000, 0 },
3594845d782dSJon Hunter { TEGRA210_CLK_I2S2_SYNC, TEGRA210_CLK_CLK_MAX, 24576000, 0 },
3595845d782dSJon Hunter { TEGRA210_CLK_I2S3_SYNC, TEGRA210_CLK_CLK_MAX, 24576000, 0 },
3596845d782dSJon Hunter { TEGRA210_CLK_I2S4_SYNC, TEGRA210_CLK_CLK_MAX, 24576000, 0 },
3597845d782dSJon Hunter { TEGRA210_CLK_VIMCLK_SYNC, TEGRA210_CLK_CLK_MAX, 24576000, 0 },
35989caec662SJon Hunter { TEGRA210_CLK_HDA, TEGRA210_CLK_PLL_P, 51000000, 0 },
35999caec662SJon Hunter { TEGRA210_CLK_HDA2CODEC_2X, TEGRA210_CLK_PLL_P, 48000000, 0 },
3600*c461c677SJon Hunter { TEGRA210_CLK_PWM, TEGRA210_CLK_PLL_P, 48000000, 0 },
36016b301a05SRhyland Klein /* This MUST be the last entry. */
36026b301a05SRhyland Klein { TEGRA210_CLK_CLK_MAX, TEGRA210_CLK_CLK_MAX, 0, 0 },
36036b301a05SRhyland Klein };
36046b301a05SRhyland Klein
36056b301a05SRhyland Klein /**
36066b301a05SRhyland Klein * tegra210_clock_apply_init_table - initialize clocks on Tegra210 SoCs
36076b301a05SRhyland Klein *
36086b301a05SRhyland Klein * Program an initial clock rate and enable or disable clocks needed
36096b301a05SRhyland Klein * by the rest of the kernel, for Tegra210 SoCs. It is intended to be
36106b301a05SRhyland Klein * called by assigning a pointer to it to tegra_clk_apply_init_table -
36116b301a05SRhyland Klein * this will be called as an arch_initcall. No return value.
36126b301a05SRhyland Klein */
tegra210_clock_apply_init_table(void)36136b301a05SRhyland Klein static void __init tegra210_clock_apply_init_table(void)
36146b301a05SRhyland Klein {
36156b301a05SRhyland Klein tegra_init_from_table(init_table, clks, TEGRA210_CLK_CLK_MAX);
36166b301a05SRhyland Klein }
36176b301a05SRhyland Klein
36186b301a05SRhyland Klein /**
361968d724ceSPeter De Schrijver * tegra210_car_barrier - wait for pending writes to the CAR to complete
362068d724ceSPeter De Schrijver *
362168d724ceSPeter De Schrijver * Wait for any outstanding writes to the CAR MMIO space from this CPU
362268d724ceSPeter De Schrijver * to complete before continuing execution. No return value.
362368d724ceSPeter De Schrijver */
tegra210_car_barrier(void)362468d724ceSPeter De Schrijver static void tegra210_car_barrier(void)
362568d724ceSPeter De Schrijver {
362668d724ceSPeter De Schrijver readl_relaxed(clk_base + RST_DFLL_DVCO);
362768d724ceSPeter De Schrijver }
362868d724ceSPeter De Schrijver
362968d724ceSPeter De Schrijver /**
363068d724ceSPeter De Schrijver * tegra210_clock_assert_dfll_dvco_reset - assert the DFLL's DVCO reset
363168d724ceSPeter De Schrijver *
363268d724ceSPeter De Schrijver * Assert the reset line of the DFLL's DVCO. No return value.
363368d724ceSPeter De Schrijver */
tegra210_clock_assert_dfll_dvco_reset(void)363468d724ceSPeter De Schrijver static void tegra210_clock_assert_dfll_dvco_reset(void)
363568d724ceSPeter De Schrijver {
363668d724ceSPeter De Schrijver u32 v;
363768d724ceSPeter De Schrijver
363868d724ceSPeter De Schrijver v = readl_relaxed(clk_base + RST_DFLL_DVCO);
363968d724ceSPeter De Schrijver v |= (1 << DVFS_DFLL_RESET_SHIFT);
364068d724ceSPeter De Schrijver writel_relaxed(v, clk_base + RST_DFLL_DVCO);
364168d724ceSPeter De Schrijver tegra210_car_barrier();
364268d724ceSPeter De Schrijver }
364368d724ceSPeter De Schrijver
364468d724ceSPeter De Schrijver /**
364568d724ceSPeter De Schrijver * tegra210_clock_deassert_dfll_dvco_reset - deassert the DFLL's DVCO reset
364668d724ceSPeter De Schrijver *
364768d724ceSPeter De Schrijver * Deassert the reset line of the DFLL's DVCO, allowing the DVCO to
364868d724ceSPeter De Schrijver * operate. No return value.
364968d724ceSPeter De Schrijver */
tegra210_clock_deassert_dfll_dvco_reset(void)365068d724ceSPeter De Schrijver static void tegra210_clock_deassert_dfll_dvco_reset(void)
365168d724ceSPeter De Schrijver {
365268d724ceSPeter De Schrijver u32 v;
365368d724ceSPeter De Schrijver
365468d724ceSPeter De Schrijver v = readl_relaxed(clk_base + RST_DFLL_DVCO);
365568d724ceSPeter De Schrijver v &= ~(1 << DVFS_DFLL_RESET_SHIFT);
365668d724ceSPeter De Schrijver writel_relaxed(v, clk_base + RST_DFLL_DVCO);
365768d724ceSPeter De Schrijver tegra210_car_barrier();
365868d724ceSPeter De Schrijver }
365968d724ceSPeter De Schrijver
tegra210_reset_assert(unsigned long id)366068d724ceSPeter De Schrijver static int tegra210_reset_assert(unsigned long id)
366168d724ceSPeter De Schrijver {
366268d724ceSPeter De Schrijver if (id == TEGRA210_RST_DFLL_DVCO)
366368d724ceSPeter De Schrijver tegra210_clock_assert_dfll_dvco_reset();
366468d724ceSPeter De Schrijver else if (id == TEGRA210_RST_ADSP)
366568d724ceSPeter De Schrijver writel(GENMASK(26, 21) | BIT(7),
366668d724ceSPeter De Schrijver clk_base + CLK_RST_CONTROLLER_RST_DEV_Y_SET);
366768d724ceSPeter De Schrijver else
366868d724ceSPeter De Schrijver return -EINVAL;
366968d724ceSPeter De Schrijver
367068d724ceSPeter De Schrijver return 0;
367168d724ceSPeter De Schrijver }
367268d724ceSPeter De Schrijver
tegra210_reset_deassert(unsigned long id)367368d724ceSPeter De Schrijver static int tegra210_reset_deassert(unsigned long id)
367468d724ceSPeter De Schrijver {
367568d724ceSPeter De Schrijver if (id == TEGRA210_RST_DFLL_DVCO)
367668d724ceSPeter De Schrijver tegra210_clock_deassert_dfll_dvco_reset();
367768d724ceSPeter De Schrijver else if (id == TEGRA210_RST_ADSP) {
367868d724ceSPeter De Schrijver writel(BIT(21), clk_base + CLK_RST_CONTROLLER_RST_DEV_Y_CLR);
367968d724ceSPeter De Schrijver /*
368068d724ceSPeter De Schrijver * Considering adsp cpu clock (min: 12.5MHZ, max: 1GHz)
368168d724ceSPeter De Schrijver * a delay of 5us ensures that it's at least
368268d724ceSPeter De Schrijver * 6 * adsp_cpu_cycle_period long.
368368d724ceSPeter De Schrijver */
368468d724ceSPeter De Schrijver udelay(5);
368568d724ceSPeter De Schrijver writel(GENMASK(26, 22) | BIT(7),
368668d724ceSPeter De Schrijver clk_base + CLK_RST_CONTROLLER_RST_DEV_Y_CLR);
368768d724ceSPeter De Schrijver } else
368868d724ceSPeter De Schrijver return -EINVAL;
368968d724ceSPeter De Schrijver
369068d724ceSPeter De Schrijver return 0;
369168d724ceSPeter De Schrijver }
369268d724ceSPeter De Schrijver
tegra210_mbist_clk_init(void)3693e403d005SPeter De Schrijver static void tegra210_mbist_clk_init(void)
3694e403d005SPeter De Schrijver {
3695e403d005SPeter De Schrijver unsigned int i, j;
3696e403d005SPeter De Schrijver
3697e403d005SPeter De Schrijver for (i = 0; i < ARRAY_SIZE(tegra210_pg_mbist_war); i++) {
3698e403d005SPeter De Schrijver unsigned int num_clks = tegra210_pg_mbist_war[i].num_clks;
3699e403d005SPeter De Schrijver struct clk_bulk_data *clk_data;
3700e403d005SPeter De Schrijver
3701e403d005SPeter De Schrijver if (!num_clks)
3702e403d005SPeter De Schrijver continue;
3703e403d005SPeter De Schrijver
3704e403d005SPeter De Schrijver clk_data = kmalloc_array(num_clks, sizeof(*clk_data),
3705e403d005SPeter De Schrijver GFP_KERNEL);
3706e403d005SPeter De Schrijver if (WARN_ON(!clk_data))
3707e403d005SPeter De Schrijver return;
3708e403d005SPeter De Schrijver
3709e403d005SPeter De Schrijver tegra210_pg_mbist_war[i].clks = clk_data;
3710e403d005SPeter De Schrijver for (j = 0; j < num_clks; j++) {
3711e403d005SPeter De Schrijver int clk_id = tegra210_pg_mbist_war[i].clk_init_data[j];
3712e403d005SPeter De Schrijver struct clk *clk = clks[clk_id];
3713e403d005SPeter De Schrijver
3714e403d005SPeter De Schrijver if (WARN(IS_ERR(clk), "clk_id: %d\n", clk_id)) {
3715e403d005SPeter De Schrijver kfree(clk_data);
3716e403d005SPeter De Schrijver tegra210_pg_mbist_war[i].clks = NULL;
3717e403d005SPeter De Schrijver break;
3718e403d005SPeter De Schrijver }
3719e403d005SPeter De Schrijver clk_data[j].clk = clk;
3720e403d005SPeter De Schrijver }
3721e403d005SPeter De Schrijver }
3722e403d005SPeter De Schrijver }
3723e403d005SPeter De Schrijver
372468d724ceSPeter De Schrijver /**
37256b301a05SRhyland Klein * tegra210_clock_init - Tegra210-specific clock initialization
37266b301a05SRhyland Klein * @np: struct device_node * of the DT node for the SoC CAR IP block
37276b301a05SRhyland Klein *
37286b301a05SRhyland Klein * Register most SoC clocks for the Tegra210 system-on-chip. Intended
37296b301a05SRhyland Klein * to be called by the OF init code when a DT node with the
37306b301a05SRhyland Klein * "nvidia,tegra210-car" string is encountered, and declared with
37316b301a05SRhyland Klein * CLK_OF_DECLARE. No return value.
37326b301a05SRhyland Klein */
tegra210_clock_init(struct device_node * np)37336b301a05SRhyland Klein static void __init tegra210_clock_init(struct device_node *np)
37346b301a05SRhyland Klein {
37356b301a05SRhyland Klein struct device_node *node;
37366b301a05SRhyland Klein u32 value, clk_m_div;
37376b301a05SRhyland Klein
37386b301a05SRhyland Klein clk_base = of_iomap(np, 0);
37396b301a05SRhyland Klein if (!clk_base) {
37406b301a05SRhyland Klein pr_err("ioremap tegra210 CAR failed\n");
37416b301a05SRhyland Klein return;
37426b301a05SRhyland Klein }
37436b301a05SRhyland Klein
37446b301a05SRhyland Klein node = of_find_matching_node(NULL, pmc_match);
37456b301a05SRhyland Klein if (!node) {
37466b301a05SRhyland Klein pr_err("Failed to find pmc node\n");
37476b301a05SRhyland Klein WARN_ON(1);
37486b301a05SRhyland Klein return;
37496b301a05SRhyland Klein }
37506b301a05SRhyland Klein
37516b301a05SRhyland Klein pmc_base = of_iomap(node, 0);
375256c78cb1SMiaoqian Lin of_node_put(node);
37536b301a05SRhyland Klein if (!pmc_base) {
37546b301a05SRhyland Klein pr_err("Can't map pmc registers\n");
37556b301a05SRhyland Klein WARN_ON(1);
37566b301a05SRhyland Klein return;
37576b301a05SRhyland Klein }
37586b301a05SRhyland Klein
3759e403d005SPeter De Schrijver ahub_base = ioremap(TEGRA210_AHUB_BASE, SZ_64K);
3760e403d005SPeter De Schrijver if (!ahub_base) {
3761e403d005SPeter De Schrijver pr_err("ioremap tegra210 APE failed\n");
3762e403d005SPeter De Schrijver return;
3763e403d005SPeter De Schrijver }
3764e403d005SPeter De Schrijver
3765e403d005SPeter De Schrijver dispa_base = ioremap(TEGRA210_DISPA_BASE, SZ_256K);
3766e403d005SPeter De Schrijver if (!dispa_base) {
3767e403d005SPeter De Schrijver pr_err("ioremap tegra210 DISPA failed\n");
3768e403d005SPeter De Schrijver return;
3769e403d005SPeter De Schrijver }
3770e403d005SPeter De Schrijver
3771e403d005SPeter De Schrijver vic_base = ioremap(TEGRA210_VIC_BASE, SZ_256K);
3772e403d005SPeter De Schrijver if (!vic_base) {
3773e403d005SPeter De Schrijver pr_err("ioremap tegra210 VIC failed\n");
3774e403d005SPeter De Schrijver return;
3775e403d005SPeter De Schrijver }
3776e403d005SPeter De Schrijver
37776b301a05SRhyland Klein clks = tegra_clk_init(clk_base, TEGRA210_CLK_CLK_MAX,
37786b301a05SRhyland Klein TEGRA210_CAR_BANK_COUNT);
37796b301a05SRhyland Klein if (!clks)
37806b301a05SRhyland Klein return;
37816b301a05SRhyland Klein
37825834fd75SJonas Gorski value = readl(clk_base + SPARE_REG0) >> CLK_M_DIVISOR_SHIFT;
37836b301a05SRhyland Klein clk_m_div = (value & CLK_M_DIVISOR_MASK) + 1;
37846b301a05SRhyland Klein
37856b301a05SRhyland Klein if (tegra_osc_clk_init(clk_base, tegra210_clks, tegra210_input_freq,
37866b301a05SRhyland Klein ARRAY_SIZE(tegra210_input_freq), clk_m_div,
37876b301a05SRhyland Klein &osc_freq, &pll_ref_freq) < 0)
37886b301a05SRhyland Klein return;
37896b301a05SRhyland Klein
37906b301a05SRhyland Klein tegra_fixed_clk_init(tegra210_clks);
37916b301a05SRhyland Klein tegra210_pll_init(clk_base, pmc_base);
37921d3e3c4eSJoseph Lo tegra210_periph_clk_init(np, clk_base, pmc_base);
37936b301a05SRhyland Klein tegra_audio_clk_init(clk_base, pmc_base, tegra210_clks,
37946b301a05SRhyland Klein tegra210_audio_plls,
3795845d782dSJon Hunter ARRAY_SIZE(tegra210_audio_plls), 24576000);
37966b301a05SRhyland Klein
37976b301a05SRhyland Klein /* For Tegra210, PLLD is the only source for DSIA & DSIB */
37985834fd75SJonas Gorski value = readl(clk_base + PLLD_BASE);
37996b301a05SRhyland Klein value &= ~BIT(25);
38005834fd75SJonas Gorski writel(value, clk_base + PLLD_BASE);
38016b301a05SRhyland Klein
38026b301a05SRhyland Klein tegra_clk_apply_init_table = tegra210_clock_apply_init_table;
38036b301a05SRhyland Klein
38046b301a05SRhyland Klein tegra_super_clk_gen5_init(clk_base, pmc_base, tegra210_clks,
38056b301a05SRhyland Klein &pll_x_params);
380668d724ceSPeter De Schrijver tegra_init_special_resets(2, tegra210_reset_assert,
380768d724ceSPeter De Schrijver tegra210_reset_deassert);
380868d724ceSPeter De Schrijver
38095d797111SDmitry Osipenko tegra_add_of_provider(np, of_clk_src_onecell_get);
38106b301a05SRhyland Klein tegra_register_devclks(devclks, ARRAY_SIZE(devclks));
38116b301a05SRhyland Klein
3812e403d005SPeter De Schrijver tegra210_mbist_clk_init();
3813e403d005SPeter De Schrijver
38146b301a05SRhyland Klein tegra_cpu_car_ops = &tegra210_cpu_car_ops;
3815535f296dSSowjanya Komatineni
3816535f296dSSowjanya Komatineni register_syscore_ops(&tegra_clk_syscore_ops);
38176b301a05SRhyland Klein }
38186b301a05SRhyland Klein CLK_OF_DECLARE(tegra210, "nvidia,tegra210-car", tegra210_clock_init);
3819