18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (c) 2012, 2013, NVIDIA CORPORATION.  All rights reserved.
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#include <linux/io.h>
78c2ecf20Sopenharmony_ci#include <linux/clk-provider.h>
88c2ecf20Sopenharmony_ci#include <linux/of.h>
98c2ecf20Sopenharmony_ci#include <linux/of_address.h>
108c2ecf20Sopenharmony_ci#include <linux/delay.h>
118c2ecf20Sopenharmony_ci#include <linux/export.h>
128c2ecf20Sopenharmony_ci#include <linux/clk/tegra.h>
138c2ecf20Sopenharmony_ci#include <dt-bindings/clock/tegra114-car.h>
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#include "clk.h"
168c2ecf20Sopenharmony_ci#include "clk-id.h"
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci#define RST_DFLL_DVCO			0x2F4
198c2ecf20Sopenharmony_ci#define CPU_FINETRIM_SELECT		0x4d4	/* override default prop dlys */
208c2ecf20Sopenharmony_ci#define CPU_FINETRIM_DR			0x4d8	/* rise->rise prop dly A */
218c2ecf20Sopenharmony_ci#define CPU_FINETRIM_R			0x4e4	/* rise->rise prop dly inc A */
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci/* RST_DFLL_DVCO bitfields */
248c2ecf20Sopenharmony_ci#define DVFS_DFLL_RESET_SHIFT		0
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci/* CPU_FINETRIM_SELECT and CPU_FINETRIM_DR bitfields */
278c2ecf20Sopenharmony_ci#define CPU_FINETRIM_1_FCPU_1		BIT(0)	/* fcpu0 */
288c2ecf20Sopenharmony_ci#define CPU_FINETRIM_1_FCPU_2		BIT(1)	/* fcpu1 */
298c2ecf20Sopenharmony_ci#define CPU_FINETRIM_1_FCPU_3		BIT(2)	/* fcpu2 */
308c2ecf20Sopenharmony_ci#define CPU_FINETRIM_1_FCPU_4		BIT(3)	/* fcpu3 */
318c2ecf20Sopenharmony_ci#define CPU_FINETRIM_1_FCPU_5		BIT(4)	/* fl2 */
328c2ecf20Sopenharmony_ci#define CPU_FINETRIM_1_FCPU_6		BIT(5)	/* ftop */
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci/* CPU_FINETRIM_R bitfields */
358c2ecf20Sopenharmony_ci#define CPU_FINETRIM_R_FCPU_1_SHIFT	0		/* fcpu0 */
368c2ecf20Sopenharmony_ci#define CPU_FINETRIM_R_FCPU_1_MASK	(0x3 << CPU_FINETRIM_R_FCPU_1_SHIFT)
378c2ecf20Sopenharmony_ci#define CPU_FINETRIM_R_FCPU_2_SHIFT	2		/* fcpu1 */
388c2ecf20Sopenharmony_ci#define CPU_FINETRIM_R_FCPU_2_MASK	(0x3 << CPU_FINETRIM_R_FCPU_2_SHIFT)
398c2ecf20Sopenharmony_ci#define CPU_FINETRIM_R_FCPU_3_SHIFT	4		/* fcpu2 */
408c2ecf20Sopenharmony_ci#define CPU_FINETRIM_R_FCPU_3_MASK	(0x3 << CPU_FINETRIM_R_FCPU_3_SHIFT)
418c2ecf20Sopenharmony_ci#define CPU_FINETRIM_R_FCPU_4_SHIFT	6		/* fcpu3 */
428c2ecf20Sopenharmony_ci#define CPU_FINETRIM_R_FCPU_4_MASK	(0x3 << CPU_FINETRIM_R_FCPU_4_SHIFT)
438c2ecf20Sopenharmony_ci#define CPU_FINETRIM_R_FCPU_5_SHIFT	8		/* fl2 */
448c2ecf20Sopenharmony_ci#define CPU_FINETRIM_R_FCPU_5_MASK	(0x3 << CPU_FINETRIM_R_FCPU_5_SHIFT)
458c2ecf20Sopenharmony_ci#define CPU_FINETRIM_R_FCPU_6_SHIFT	10		/* ftop */
468c2ecf20Sopenharmony_ci#define CPU_FINETRIM_R_FCPU_6_MASK	(0x3 << CPU_FINETRIM_R_FCPU_6_SHIFT)
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci#define TEGRA114_CLK_PERIPH_BANKS	5
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci#define PLLC_BASE 0x80
518c2ecf20Sopenharmony_ci#define PLLC_MISC2 0x88
528c2ecf20Sopenharmony_ci#define PLLC_MISC 0x8c
538c2ecf20Sopenharmony_ci#define PLLC2_BASE 0x4e8
548c2ecf20Sopenharmony_ci#define PLLC2_MISC 0x4ec
558c2ecf20Sopenharmony_ci#define PLLC3_BASE 0x4fc
568c2ecf20Sopenharmony_ci#define PLLC3_MISC 0x500
578c2ecf20Sopenharmony_ci#define PLLM_BASE 0x90
588c2ecf20Sopenharmony_ci#define PLLM_MISC 0x9c
598c2ecf20Sopenharmony_ci#define PLLP_BASE 0xa0
608c2ecf20Sopenharmony_ci#define PLLP_MISC 0xac
618c2ecf20Sopenharmony_ci#define PLLX_BASE 0xe0
628c2ecf20Sopenharmony_ci#define PLLX_MISC 0xe4
638c2ecf20Sopenharmony_ci#define PLLX_MISC2 0x514
648c2ecf20Sopenharmony_ci#define PLLX_MISC3 0x518
658c2ecf20Sopenharmony_ci#define PLLD_BASE 0xd0
668c2ecf20Sopenharmony_ci#define PLLD_MISC 0xdc
678c2ecf20Sopenharmony_ci#define PLLD2_BASE 0x4b8
688c2ecf20Sopenharmony_ci#define PLLD2_MISC 0x4bc
698c2ecf20Sopenharmony_ci#define PLLE_BASE 0xe8
708c2ecf20Sopenharmony_ci#define PLLE_MISC 0xec
718c2ecf20Sopenharmony_ci#define PLLA_BASE 0xb0
728c2ecf20Sopenharmony_ci#define PLLA_MISC 0xbc
738c2ecf20Sopenharmony_ci#define PLLU_BASE 0xc0
748c2ecf20Sopenharmony_ci#define PLLU_MISC 0xcc
758c2ecf20Sopenharmony_ci#define PLLRE_BASE 0x4c4
768c2ecf20Sopenharmony_ci#define PLLRE_MISC 0x4c8
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci#define PLL_MISC_LOCK_ENABLE 18
798c2ecf20Sopenharmony_ci#define PLLC_MISC_LOCK_ENABLE 24
808c2ecf20Sopenharmony_ci#define PLLDU_MISC_LOCK_ENABLE 22
818c2ecf20Sopenharmony_ci#define PLLE_MISC_LOCK_ENABLE 9
828c2ecf20Sopenharmony_ci#define PLLRE_MISC_LOCK_ENABLE 30
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci#define PLLC_IDDQ_BIT 26
858c2ecf20Sopenharmony_ci#define PLLX_IDDQ_BIT 3
868c2ecf20Sopenharmony_ci#define PLLRE_IDDQ_BIT 16
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci#define PLL_BASE_LOCK BIT(27)
898c2ecf20Sopenharmony_ci#define PLLE_MISC_LOCK BIT(11)
908c2ecf20Sopenharmony_ci#define PLLRE_MISC_LOCK BIT(24)
918c2ecf20Sopenharmony_ci#define PLLCX_BASE_LOCK (BIT(26)|BIT(27))
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci#define PLLE_AUX 0x48c
948c2ecf20Sopenharmony_ci#define PLLC_OUT 0x84
958c2ecf20Sopenharmony_ci#define PLLM_OUT 0x94
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci#define OSC_CTRL			0x50
988c2ecf20Sopenharmony_ci#define OSC_CTRL_OSC_FREQ_SHIFT		28
998c2ecf20Sopenharmony_ci#define OSC_CTRL_PLL_REF_DIV_SHIFT	26
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci#define PLLXC_SW_MAX_P			6
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ci#define CCLKG_BURST_POLICY 0x368
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_ci#define CLK_SOURCE_CSITE 0x1d4
1068c2ecf20Sopenharmony_ci#define CLK_SOURCE_EMC 0x19c
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci/* PLLM override registers */
1098c2ecf20Sopenharmony_ci#define PMC_PLLM_WB0_OVERRIDE 0x1dc
1108c2ecf20Sopenharmony_ci#define PMC_PLLM_WB0_OVERRIDE_2 0x2b0
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci/* Tegra CPU clock and reset control regs */
1138c2ecf20Sopenharmony_ci#define CLK_RST_CONTROLLER_CPU_CMPLX_STATUS	0x470
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci#define MUX8(_name, _parents, _offset, \
1168c2ecf20Sopenharmony_ci			     _clk_num, _gate_flags, _clk_id)	\
1178c2ecf20Sopenharmony_ci	TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\
1188c2ecf20Sopenharmony_ci			29, MASK(3), 0, 0, 8, 1, TEGRA_DIVIDER_ROUND_UP,\
1198c2ecf20Sopenharmony_ci			_clk_num, _gate_flags, _clk_id, _parents##_idx, 0,\
1208c2ecf20Sopenharmony_ci			NULL)
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_ci#ifdef CONFIG_PM_SLEEP
1238c2ecf20Sopenharmony_cistatic struct cpu_clk_suspend_context {
1248c2ecf20Sopenharmony_ci	u32 clk_csite_src;
1258c2ecf20Sopenharmony_ci	u32 cclkg_burst;
1268c2ecf20Sopenharmony_ci	u32 cclkg_divider;
1278c2ecf20Sopenharmony_ci} tegra114_cpu_clk_sctx;
1288c2ecf20Sopenharmony_ci#endif
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_cistatic void __iomem *clk_base;
1318c2ecf20Sopenharmony_cistatic void __iomem *pmc_base;
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(pll_d_lock);
1348c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(pll_d2_lock);
1358c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(pll_u_lock);
1368c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(pll_re_lock);
1378c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(emc_lock);
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_cistatic struct div_nmp pllxc_nmp = {
1408c2ecf20Sopenharmony_ci	.divm_shift = 0,
1418c2ecf20Sopenharmony_ci	.divm_width = 8,
1428c2ecf20Sopenharmony_ci	.divn_shift = 8,
1438c2ecf20Sopenharmony_ci	.divn_width = 8,
1448c2ecf20Sopenharmony_ci	.divp_shift = 20,
1458c2ecf20Sopenharmony_ci	.divp_width = 4,
1468c2ecf20Sopenharmony_ci};
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_cistatic const struct pdiv_map pllxc_p[] = {
1498c2ecf20Sopenharmony_ci	{ .pdiv =  1, .hw_val =  0 },
1508c2ecf20Sopenharmony_ci	{ .pdiv =  2, .hw_val =  1 },
1518c2ecf20Sopenharmony_ci	{ .pdiv =  3, .hw_val =  2 },
1528c2ecf20Sopenharmony_ci	{ .pdiv =  4, .hw_val =  3 },
1538c2ecf20Sopenharmony_ci	{ .pdiv =  5, .hw_val =  4 },
1548c2ecf20Sopenharmony_ci	{ .pdiv =  6, .hw_val =  5 },
1558c2ecf20Sopenharmony_ci	{ .pdiv =  8, .hw_val =  6 },
1568c2ecf20Sopenharmony_ci	{ .pdiv = 10, .hw_val =  7 },
1578c2ecf20Sopenharmony_ci	{ .pdiv = 12, .hw_val =  8 },
1588c2ecf20Sopenharmony_ci	{ .pdiv = 16, .hw_val =  9 },
1598c2ecf20Sopenharmony_ci	{ .pdiv = 12, .hw_val = 10 },
1608c2ecf20Sopenharmony_ci	{ .pdiv = 16, .hw_val = 11 },
1618c2ecf20Sopenharmony_ci	{ .pdiv = 20, .hw_val = 12 },
1628c2ecf20Sopenharmony_ci	{ .pdiv = 24, .hw_val = 13 },
1638c2ecf20Sopenharmony_ci	{ .pdiv = 32, .hw_val = 14 },
1648c2ecf20Sopenharmony_ci	{ .pdiv =  0, .hw_val =  0 },
1658c2ecf20Sopenharmony_ci};
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_cistatic struct tegra_clk_pll_freq_table pll_c_freq_table[] = {
1688c2ecf20Sopenharmony_ci	{ 12000000, 624000000, 104, 1, 2, 0 },
1698c2ecf20Sopenharmony_ci	{ 12000000, 600000000, 100, 1, 2, 0 },
1708c2ecf20Sopenharmony_ci	{ 13000000, 600000000,  92, 1, 2, 0 }, /* actual: 598.0 MHz */
1718c2ecf20Sopenharmony_ci	{ 16800000, 600000000,  71, 1, 2, 0 }, /* actual: 596.4 MHz */
1728c2ecf20Sopenharmony_ci	{ 19200000, 600000000,  62, 1, 2, 0 }, /* actual: 595.2 MHz */
1738c2ecf20Sopenharmony_ci	{ 26000000, 600000000,  92, 2, 2, 0 }, /* actual: 598.0 MHz */
1748c2ecf20Sopenharmony_ci	{        0,         0,   0, 0, 0, 0 },
1758c2ecf20Sopenharmony_ci};
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_cistatic struct tegra_clk_pll_params pll_c_params = {
1788c2ecf20Sopenharmony_ci	.input_min = 12000000,
1798c2ecf20Sopenharmony_ci	.input_max = 800000000,
1808c2ecf20Sopenharmony_ci	.cf_min = 12000000,
1818c2ecf20Sopenharmony_ci	.cf_max = 19200000, /* s/w policy, h/w capability 50 MHz */
1828c2ecf20Sopenharmony_ci	.vco_min = 600000000,
1838c2ecf20Sopenharmony_ci	.vco_max = 1400000000,
1848c2ecf20Sopenharmony_ci	.base_reg = PLLC_BASE,
1858c2ecf20Sopenharmony_ci	.misc_reg = PLLC_MISC,
1868c2ecf20Sopenharmony_ci	.lock_mask = PLL_BASE_LOCK,
1878c2ecf20Sopenharmony_ci	.lock_enable_bit_idx = PLLC_MISC_LOCK_ENABLE,
1888c2ecf20Sopenharmony_ci	.lock_delay = 300,
1898c2ecf20Sopenharmony_ci	.iddq_reg = PLLC_MISC,
1908c2ecf20Sopenharmony_ci	.iddq_bit_idx = PLLC_IDDQ_BIT,
1918c2ecf20Sopenharmony_ci	.max_p = PLLXC_SW_MAX_P,
1928c2ecf20Sopenharmony_ci	.dyn_ramp_reg = PLLC_MISC2,
1938c2ecf20Sopenharmony_ci	.stepa_shift = 17,
1948c2ecf20Sopenharmony_ci	.stepb_shift = 9,
1958c2ecf20Sopenharmony_ci	.pdiv_tohw = pllxc_p,
1968c2ecf20Sopenharmony_ci	.div_nmp = &pllxc_nmp,
1978c2ecf20Sopenharmony_ci	.freq_table = pll_c_freq_table,
1988c2ecf20Sopenharmony_ci	.flags = TEGRA_PLL_USE_LOCK | TEGRA_PLL_HAS_LOCK_ENABLE,
1998c2ecf20Sopenharmony_ci};
2008c2ecf20Sopenharmony_ci
2018c2ecf20Sopenharmony_cistatic struct div_nmp pllcx_nmp = {
2028c2ecf20Sopenharmony_ci	.divm_shift = 0,
2038c2ecf20Sopenharmony_ci	.divm_width = 2,
2048c2ecf20Sopenharmony_ci	.divn_shift = 8,
2058c2ecf20Sopenharmony_ci	.divn_width = 8,
2068c2ecf20Sopenharmony_ci	.divp_shift = 20,
2078c2ecf20Sopenharmony_ci	.divp_width = 3,
2088c2ecf20Sopenharmony_ci};
2098c2ecf20Sopenharmony_ci
2108c2ecf20Sopenharmony_cistatic const struct pdiv_map pllc_p[] = {
2118c2ecf20Sopenharmony_ci	{ .pdiv =  1, .hw_val = 0 },
2128c2ecf20Sopenharmony_ci	{ .pdiv =  2, .hw_val = 1 },
2138c2ecf20Sopenharmony_ci	{ .pdiv =  4, .hw_val = 3 },
2148c2ecf20Sopenharmony_ci	{ .pdiv =  8, .hw_val = 5 },
2158c2ecf20Sopenharmony_ci	{ .pdiv = 16, .hw_val = 7 },
2168c2ecf20Sopenharmony_ci	{ .pdiv =  0, .hw_val = 0 },
2178c2ecf20Sopenharmony_ci};
2188c2ecf20Sopenharmony_ci
2198c2ecf20Sopenharmony_cistatic struct tegra_clk_pll_freq_table pll_cx_freq_table[] = {
2208c2ecf20Sopenharmony_ci	{ 12000000, 600000000, 100, 1, 2, 0 },
2218c2ecf20Sopenharmony_ci	{ 13000000, 600000000,  92, 1, 2, 0 }, /* actual: 598.0 MHz */
2228c2ecf20Sopenharmony_ci	{ 16800000, 600000000,  71, 1, 2, 0 }, /* actual: 596.4 MHz */
2238c2ecf20Sopenharmony_ci	{ 19200000, 600000000,  62, 1, 2, 0 }, /* actual: 595.2 MHz */
2248c2ecf20Sopenharmony_ci	{ 26000000, 600000000,  92, 2, 2, 0 }, /* actual: 598.0 MHz */
2258c2ecf20Sopenharmony_ci	{        0,         0,   0, 0, 0, 0 },
2268c2ecf20Sopenharmony_ci};
2278c2ecf20Sopenharmony_ci
2288c2ecf20Sopenharmony_cistatic struct tegra_clk_pll_params pll_c2_params = {
2298c2ecf20Sopenharmony_ci	.input_min = 12000000,
2308c2ecf20Sopenharmony_ci	.input_max = 48000000,
2318c2ecf20Sopenharmony_ci	.cf_min = 12000000,
2328c2ecf20Sopenharmony_ci	.cf_max = 19200000,
2338c2ecf20Sopenharmony_ci	.vco_min = 600000000,
2348c2ecf20Sopenharmony_ci	.vco_max = 1200000000,
2358c2ecf20Sopenharmony_ci	.base_reg = PLLC2_BASE,
2368c2ecf20Sopenharmony_ci	.misc_reg = PLLC2_MISC,
2378c2ecf20Sopenharmony_ci	.lock_mask = PLL_BASE_LOCK,
2388c2ecf20Sopenharmony_ci	.lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
2398c2ecf20Sopenharmony_ci	.lock_delay = 300,
2408c2ecf20Sopenharmony_ci	.pdiv_tohw = pllc_p,
2418c2ecf20Sopenharmony_ci	.div_nmp = &pllcx_nmp,
2428c2ecf20Sopenharmony_ci	.max_p = 7,
2438c2ecf20Sopenharmony_ci	.ext_misc_reg[0] = 0x4f0,
2448c2ecf20Sopenharmony_ci	.ext_misc_reg[1] = 0x4f4,
2458c2ecf20Sopenharmony_ci	.ext_misc_reg[2] = 0x4f8,
2468c2ecf20Sopenharmony_ci	.freq_table = pll_cx_freq_table,
2478c2ecf20Sopenharmony_ci	.flags = TEGRA_PLL_USE_LOCK,
2488c2ecf20Sopenharmony_ci};
2498c2ecf20Sopenharmony_ci
2508c2ecf20Sopenharmony_cistatic struct tegra_clk_pll_params pll_c3_params = {
2518c2ecf20Sopenharmony_ci	.input_min = 12000000,
2528c2ecf20Sopenharmony_ci	.input_max = 48000000,
2538c2ecf20Sopenharmony_ci	.cf_min = 12000000,
2548c2ecf20Sopenharmony_ci	.cf_max = 19200000,
2558c2ecf20Sopenharmony_ci	.vco_min = 600000000,
2568c2ecf20Sopenharmony_ci	.vco_max = 1200000000,
2578c2ecf20Sopenharmony_ci	.base_reg = PLLC3_BASE,
2588c2ecf20Sopenharmony_ci	.misc_reg = PLLC3_MISC,
2598c2ecf20Sopenharmony_ci	.lock_mask = PLL_BASE_LOCK,
2608c2ecf20Sopenharmony_ci	.lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
2618c2ecf20Sopenharmony_ci	.lock_delay = 300,
2628c2ecf20Sopenharmony_ci	.pdiv_tohw = pllc_p,
2638c2ecf20Sopenharmony_ci	.div_nmp = &pllcx_nmp,
2648c2ecf20Sopenharmony_ci	.max_p = 7,
2658c2ecf20Sopenharmony_ci	.ext_misc_reg[0] = 0x504,
2668c2ecf20Sopenharmony_ci	.ext_misc_reg[1] = 0x508,
2678c2ecf20Sopenharmony_ci	.ext_misc_reg[2] = 0x50c,
2688c2ecf20Sopenharmony_ci	.freq_table = pll_cx_freq_table,
2698c2ecf20Sopenharmony_ci	.flags = TEGRA_PLL_USE_LOCK,
2708c2ecf20Sopenharmony_ci};
2718c2ecf20Sopenharmony_ci
2728c2ecf20Sopenharmony_cistatic struct div_nmp pllm_nmp = {
2738c2ecf20Sopenharmony_ci	.divm_shift = 0,
2748c2ecf20Sopenharmony_ci	.divm_width = 8,
2758c2ecf20Sopenharmony_ci	.override_divm_shift = 0,
2768c2ecf20Sopenharmony_ci	.divn_shift = 8,
2778c2ecf20Sopenharmony_ci	.divn_width = 8,
2788c2ecf20Sopenharmony_ci	.override_divn_shift = 8,
2798c2ecf20Sopenharmony_ci	.divp_shift = 20,
2808c2ecf20Sopenharmony_ci	.divp_width = 1,
2818c2ecf20Sopenharmony_ci	.override_divp_shift = 27,
2828c2ecf20Sopenharmony_ci};
2838c2ecf20Sopenharmony_ci
2848c2ecf20Sopenharmony_cistatic const struct pdiv_map pllm_p[] = {
2858c2ecf20Sopenharmony_ci	{ .pdiv = 1, .hw_val = 0 },
2868c2ecf20Sopenharmony_ci	{ .pdiv = 2, .hw_val = 1 },
2878c2ecf20Sopenharmony_ci	{ .pdiv = 0, .hw_val = 0 },
2888c2ecf20Sopenharmony_ci};
2898c2ecf20Sopenharmony_ci
2908c2ecf20Sopenharmony_cistatic struct tegra_clk_pll_freq_table pll_m_freq_table[] = {
2918c2ecf20Sopenharmony_ci	{ 12000000, 800000000, 66, 1, 1, 0 }, /* actual: 792.0 MHz */
2928c2ecf20Sopenharmony_ci	{ 13000000, 800000000, 61, 1, 1, 0 }, /* actual: 793.0 MHz */
2938c2ecf20Sopenharmony_ci	{ 16800000, 800000000, 47, 1, 1, 0 }, /* actual: 789.6 MHz */
2948c2ecf20Sopenharmony_ci	{ 19200000, 800000000, 41, 1, 1, 0 }, /* actual: 787.2 MHz */
2958c2ecf20Sopenharmony_ci	{ 26000000, 800000000, 61, 2, 1, 0 }, /* actual: 793.0 MHz */
2968c2ecf20Sopenharmony_ci	{        0,         0,  0, 0, 0, 0 },
2978c2ecf20Sopenharmony_ci};
2988c2ecf20Sopenharmony_ci
2998c2ecf20Sopenharmony_cistatic struct tegra_clk_pll_params pll_m_params = {
3008c2ecf20Sopenharmony_ci	.input_min = 12000000,
3018c2ecf20Sopenharmony_ci	.input_max = 500000000,
3028c2ecf20Sopenharmony_ci	.cf_min = 12000000,
3038c2ecf20Sopenharmony_ci	.cf_max = 19200000, /* s/w policy, h/w capability 50 MHz */
3048c2ecf20Sopenharmony_ci	.vco_min = 400000000,
3058c2ecf20Sopenharmony_ci	.vco_max = 1066000000,
3068c2ecf20Sopenharmony_ci	.base_reg = PLLM_BASE,
3078c2ecf20Sopenharmony_ci	.misc_reg = PLLM_MISC,
3088c2ecf20Sopenharmony_ci	.lock_mask = PLL_BASE_LOCK,
3098c2ecf20Sopenharmony_ci	.lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
3108c2ecf20Sopenharmony_ci	.lock_delay = 300,
3118c2ecf20Sopenharmony_ci	.max_p = 2,
3128c2ecf20Sopenharmony_ci	.pdiv_tohw = pllm_p,
3138c2ecf20Sopenharmony_ci	.div_nmp = &pllm_nmp,
3148c2ecf20Sopenharmony_ci	.pmc_divnm_reg = PMC_PLLM_WB0_OVERRIDE,
3158c2ecf20Sopenharmony_ci	.pmc_divp_reg = PMC_PLLM_WB0_OVERRIDE_2,
3168c2ecf20Sopenharmony_ci	.freq_table = pll_m_freq_table,
3178c2ecf20Sopenharmony_ci	.flags = TEGRA_PLL_USE_LOCK | TEGRA_PLL_HAS_LOCK_ENABLE |
3188c2ecf20Sopenharmony_ci		 TEGRA_PLL_FIXED,
3198c2ecf20Sopenharmony_ci};
3208c2ecf20Sopenharmony_ci
3218c2ecf20Sopenharmony_cistatic struct div_nmp pllp_nmp = {
3228c2ecf20Sopenharmony_ci	.divm_shift = 0,
3238c2ecf20Sopenharmony_ci	.divm_width = 5,
3248c2ecf20Sopenharmony_ci	.divn_shift = 8,
3258c2ecf20Sopenharmony_ci	.divn_width = 10,
3268c2ecf20Sopenharmony_ci	.divp_shift = 20,
3278c2ecf20Sopenharmony_ci	.divp_width = 3,
3288c2ecf20Sopenharmony_ci};
3298c2ecf20Sopenharmony_ci
3308c2ecf20Sopenharmony_cistatic struct tegra_clk_pll_freq_table pll_p_freq_table[] = {
3318c2ecf20Sopenharmony_ci	{ 12000000, 216000000, 432, 12, 2, 8 },
3328c2ecf20Sopenharmony_ci	{ 13000000, 216000000, 432, 13, 2, 8 },
3338c2ecf20Sopenharmony_ci	{ 16800000, 216000000, 360, 14, 2, 8 },
3348c2ecf20Sopenharmony_ci	{ 19200000, 216000000, 360, 16, 2, 8 },
3358c2ecf20Sopenharmony_ci	{ 26000000, 216000000, 432, 26, 2, 8 },
3368c2ecf20Sopenharmony_ci	{        0,         0,   0,  0, 0, 0 },
3378c2ecf20Sopenharmony_ci};
3388c2ecf20Sopenharmony_ci
3398c2ecf20Sopenharmony_cistatic struct tegra_clk_pll_params pll_p_params = {
3408c2ecf20Sopenharmony_ci	.input_min = 2000000,
3418c2ecf20Sopenharmony_ci	.input_max = 31000000,
3428c2ecf20Sopenharmony_ci	.cf_min = 1000000,
3438c2ecf20Sopenharmony_ci	.cf_max = 6000000,
3448c2ecf20Sopenharmony_ci	.vco_min = 200000000,
3458c2ecf20Sopenharmony_ci	.vco_max = 700000000,
3468c2ecf20Sopenharmony_ci	.base_reg = PLLP_BASE,
3478c2ecf20Sopenharmony_ci	.misc_reg = PLLP_MISC,
3488c2ecf20Sopenharmony_ci	.lock_mask = PLL_BASE_LOCK,
3498c2ecf20Sopenharmony_ci	.lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
3508c2ecf20Sopenharmony_ci	.lock_delay = 300,
3518c2ecf20Sopenharmony_ci	.div_nmp = &pllp_nmp,
3528c2ecf20Sopenharmony_ci	.freq_table = pll_p_freq_table,
3538c2ecf20Sopenharmony_ci	.flags = TEGRA_PLL_FIXED | TEGRA_PLL_USE_LOCK |
3548c2ecf20Sopenharmony_ci		 TEGRA_PLL_HAS_LOCK_ENABLE,
3558c2ecf20Sopenharmony_ci	.fixed_rate = 408000000,
3568c2ecf20Sopenharmony_ci};
3578c2ecf20Sopenharmony_ci
3588c2ecf20Sopenharmony_cistatic struct tegra_clk_pll_freq_table pll_a_freq_table[] = {
3598c2ecf20Sopenharmony_ci	{  9600000, 282240000, 147,  5, 1, 4 },
3608c2ecf20Sopenharmony_ci	{  9600000, 368640000, 192,  5, 1, 4 },
3618c2ecf20Sopenharmony_ci	{  9600000, 240000000, 200,  8, 1, 8 },
3628c2ecf20Sopenharmony_ci	{ 28800000, 282240000, 245, 25, 1, 8 },
3638c2ecf20Sopenharmony_ci	{ 28800000, 368640000, 320, 25, 1, 8 },
3648c2ecf20Sopenharmony_ci	{ 28800000, 240000000, 200, 24, 1, 8 },
3658c2ecf20Sopenharmony_ci	{        0,         0,   0,  0, 0, 0 },
3668c2ecf20Sopenharmony_ci};
3678c2ecf20Sopenharmony_ci
3688c2ecf20Sopenharmony_ci
3698c2ecf20Sopenharmony_cistatic struct tegra_clk_pll_params pll_a_params = {
3708c2ecf20Sopenharmony_ci	.input_min = 2000000,
3718c2ecf20Sopenharmony_ci	.input_max = 31000000,
3728c2ecf20Sopenharmony_ci	.cf_min = 1000000,
3738c2ecf20Sopenharmony_ci	.cf_max = 6000000,
3748c2ecf20Sopenharmony_ci	.vco_min = 200000000,
3758c2ecf20Sopenharmony_ci	.vco_max = 700000000,
3768c2ecf20Sopenharmony_ci	.base_reg = PLLA_BASE,
3778c2ecf20Sopenharmony_ci	.misc_reg = PLLA_MISC,
3788c2ecf20Sopenharmony_ci	.lock_mask = PLL_BASE_LOCK,
3798c2ecf20Sopenharmony_ci	.lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
3808c2ecf20Sopenharmony_ci	.lock_delay = 300,
3818c2ecf20Sopenharmony_ci	.div_nmp = &pllp_nmp,
3828c2ecf20Sopenharmony_ci	.freq_table = pll_a_freq_table,
3838c2ecf20Sopenharmony_ci	.flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_USE_LOCK |
3848c2ecf20Sopenharmony_ci		 TEGRA_PLL_HAS_LOCK_ENABLE,
3858c2ecf20Sopenharmony_ci};
3868c2ecf20Sopenharmony_ci
3878c2ecf20Sopenharmony_cistatic struct tegra_clk_pll_freq_table pll_d_freq_table[] = {
3888c2ecf20Sopenharmony_ci	{ 12000000,  216000000,  864, 12, 4, 12 },
3898c2ecf20Sopenharmony_ci	{ 13000000,  216000000,  864, 13, 4, 12 },
3908c2ecf20Sopenharmony_ci	{ 16800000,  216000000,  720, 14, 4, 12 },
3918c2ecf20Sopenharmony_ci	{ 19200000,  216000000,  720, 16, 4, 12 },
3928c2ecf20Sopenharmony_ci	{ 26000000,  216000000,  864, 26, 4, 12 },
3938c2ecf20Sopenharmony_ci	{ 12000000,  594000000,  594, 12, 1, 12 },
3948c2ecf20Sopenharmony_ci	{ 13000000,  594000000,  594, 13, 1, 12 },
3958c2ecf20Sopenharmony_ci	{ 16800000,  594000000,  495, 14, 1, 12 },
3968c2ecf20Sopenharmony_ci	{ 19200000,  594000000,  495, 16, 1, 12 },
3978c2ecf20Sopenharmony_ci	{ 26000000,  594000000,  594, 26, 1, 12 },
3988c2ecf20Sopenharmony_ci	{ 12000000, 1000000000, 1000, 12, 1, 12 },
3998c2ecf20Sopenharmony_ci	{ 13000000, 1000000000, 1000, 13, 1, 12 },
4008c2ecf20Sopenharmony_ci	{ 19200000, 1000000000,  625, 12, 1, 12 },
4018c2ecf20Sopenharmony_ci	{ 26000000, 1000000000, 1000, 26, 1, 12 },
4028c2ecf20Sopenharmony_ci	{        0,          0,    0,  0, 0,  0 },
4038c2ecf20Sopenharmony_ci};
4048c2ecf20Sopenharmony_ci
4058c2ecf20Sopenharmony_cistatic struct tegra_clk_pll_params pll_d_params = {
4068c2ecf20Sopenharmony_ci	.input_min = 2000000,
4078c2ecf20Sopenharmony_ci	.input_max = 40000000,
4088c2ecf20Sopenharmony_ci	.cf_min = 1000000,
4098c2ecf20Sopenharmony_ci	.cf_max = 6000000,
4108c2ecf20Sopenharmony_ci	.vco_min = 500000000,
4118c2ecf20Sopenharmony_ci	.vco_max = 1000000000,
4128c2ecf20Sopenharmony_ci	.base_reg = PLLD_BASE,
4138c2ecf20Sopenharmony_ci	.misc_reg = PLLD_MISC,
4148c2ecf20Sopenharmony_ci	.lock_mask = PLL_BASE_LOCK,
4158c2ecf20Sopenharmony_ci	.lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE,
4168c2ecf20Sopenharmony_ci	.lock_delay = 1000,
4178c2ecf20Sopenharmony_ci	.div_nmp = &pllp_nmp,
4188c2ecf20Sopenharmony_ci	.freq_table = pll_d_freq_table,
4198c2ecf20Sopenharmony_ci	.flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON |
4208c2ecf20Sopenharmony_ci		 TEGRA_PLL_HAS_LOCK_ENABLE,
4218c2ecf20Sopenharmony_ci};
4228c2ecf20Sopenharmony_ci
4238c2ecf20Sopenharmony_cistatic struct tegra_clk_pll_params pll_d2_params = {
4248c2ecf20Sopenharmony_ci	.input_min = 2000000,
4258c2ecf20Sopenharmony_ci	.input_max = 40000000,
4268c2ecf20Sopenharmony_ci	.cf_min = 1000000,
4278c2ecf20Sopenharmony_ci	.cf_max = 6000000,
4288c2ecf20Sopenharmony_ci	.vco_min = 500000000,
4298c2ecf20Sopenharmony_ci	.vco_max = 1000000000,
4308c2ecf20Sopenharmony_ci	.base_reg = PLLD2_BASE,
4318c2ecf20Sopenharmony_ci	.misc_reg = PLLD2_MISC,
4328c2ecf20Sopenharmony_ci	.lock_mask = PLL_BASE_LOCK,
4338c2ecf20Sopenharmony_ci	.lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE,
4348c2ecf20Sopenharmony_ci	.lock_delay = 1000,
4358c2ecf20Sopenharmony_ci	.div_nmp = &pllp_nmp,
4368c2ecf20Sopenharmony_ci	.freq_table = pll_d_freq_table,
4378c2ecf20Sopenharmony_ci	.flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON |
4388c2ecf20Sopenharmony_ci		 TEGRA_PLL_HAS_LOCK_ENABLE,
4398c2ecf20Sopenharmony_ci};
4408c2ecf20Sopenharmony_ci
4418c2ecf20Sopenharmony_cistatic const struct pdiv_map pllu_p[] = {
4428c2ecf20Sopenharmony_ci	{ .pdiv = 1, .hw_val = 1 },
4438c2ecf20Sopenharmony_ci	{ .pdiv = 2, .hw_val = 0 },
4448c2ecf20Sopenharmony_ci	{ .pdiv = 0, .hw_val = 0 },
4458c2ecf20Sopenharmony_ci};
4468c2ecf20Sopenharmony_ci
4478c2ecf20Sopenharmony_cistatic struct div_nmp pllu_nmp = {
4488c2ecf20Sopenharmony_ci	.divm_shift = 0,
4498c2ecf20Sopenharmony_ci	.divm_width = 5,
4508c2ecf20Sopenharmony_ci	.divn_shift = 8,
4518c2ecf20Sopenharmony_ci	.divn_width = 10,
4528c2ecf20Sopenharmony_ci	.divp_shift = 20,
4538c2ecf20Sopenharmony_ci	.divp_width = 1,
4548c2ecf20Sopenharmony_ci};
4558c2ecf20Sopenharmony_ci
4568c2ecf20Sopenharmony_cistatic struct tegra_clk_pll_freq_table pll_u_freq_table[] = {
4578c2ecf20Sopenharmony_ci	{ 12000000, 480000000, 960, 12, 2, 12 },
4588c2ecf20Sopenharmony_ci	{ 13000000, 480000000, 960, 13, 2, 12 },
4598c2ecf20Sopenharmony_ci	{ 16800000, 480000000, 400,  7, 2,  5 },
4608c2ecf20Sopenharmony_ci	{ 19200000, 480000000, 200,  4, 2,  3 },
4618c2ecf20Sopenharmony_ci	{ 26000000, 480000000, 960, 26, 2, 12 },
4628c2ecf20Sopenharmony_ci	{        0,         0,   0,  0, 0,  0 },
4638c2ecf20Sopenharmony_ci};
4648c2ecf20Sopenharmony_ci
4658c2ecf20Sopenharmony_cistatic struct tegra_clk_pll_params pll_u_params = {
4668c2ecf20Sopenharmony_ci	.input_min = 2000000,
4678c2ecf20Sopenharmony_ci	.input_max = 40000000,
4688c2ecf20Sopenharmony_ci	.cf_min = 1000000,
4698c2ecf20Sopenharmony_ci	.cf_max = 6000000,
4708c2ecf20Sopenharmony_ci	.vco_min = 480000000,
4718c2ecf20Sopenharmony_ci	.vco_max = 960000000,
4728c2ecf20Sopenharmony_ci	.base_reg = PLLU_BASE,
4738c2ecf20Sopenharmony_ci	.misc_reg = PLLU_MISC,
4748c2ecf20Sopenharmony_ci	.lock_mask = PLL_BASE_LOCK,
4758c2ecf20Sopenharmony_ci	.lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE,
4768c2ecf20Sopenharmony_ci	.lock_delay = 1000,
4778c2ecf20Sopenharmony_ci	.pdiv_tohw = pllu_p,
4788c2ecf20Sopenharmony_ci	.div_nmp = &pllu_nmp,
4798c2ecf20Sopenharmony_ci	.freq_table = pll_u_freq_table,
4808c2ecf20Sopenharmony_ci	.flags = TEGRA_PLLU | TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON |
4818c2ecf20Sopenharmony_ci		 TEGRA_PLL_USE_LOCK | TEGRA_PLL_HAS_LOCK_ENABLE,
4828c2ecf20Sopenharmony_ci};
4838c2ecf20Sopenharmony_ci
4848c2ecf20Sopenharmony_cistatic struct tegra_clk_pll_freq_table pll_x_freq_table[] = {
4858c2ecf20Sopenharmony_ci	/* 1 GHz */
4868c2ecf20Sopenharmony_ci	{ 12000000, 1000000000, 83, 1, 1, 0 }, /* actual: 996.0 MHz */
4878c2ecf20Sopenharmony_ci	{ 13000000, 1000000000, 76, 1, 1, 0 }, /* actual: 988.0 MHz */
4888c2ecf20Sopenharmony_ci	{ 16800000, 1000000000, 59, 1, 1, 0 }, /* actual: 991.2 MHz */
4898c2ecf20Sopenharmony_ci	{ 19200000, 1000000000, 52, 1, 1, 0 }, /* actual: 998.4 MHz */
4908c2ecf20Sopenharmony_ci	{ 26000000, 1000000000, 76, 2, 1, 0 }, /* actual: 988.0 MHz */
4918c2ecf20Sopenharmony_ci	{        0,          0,  0, 0, 0, 0 },
4928c2ecf20Sopenharmony_ci};
4938c2ecf20Sopenharmony_ci
4948c2ecf20Sopenharmony_cistatic struct tegra_clk_pll_params pll_x_params = {
4958c2ecf20Sopenharmony_ci	.input_min = 12000000,
4968c2ecf20Sopenharmony_ci	.input_max = 800000000,
4978c2ecf20Sopenharmony_ci	.cf_min = 12000000,
4988c2ecf20Sopenharmony_ci	.cf_max = 19200000, /* s/w policy, h/w capability 50 MHz */
4998c2ecf20Sopenharmony_ci	.vco_min = 700000000,
5008c2ecf20Sopenharmony_ci	.vco_max = 2400000000U,
5018c2ecf20Sopenharmony_ci	.base_reg = PLLX_BASE,
5028c2ecf20Sopenharmony_ci	.misc_reg = PLLX_MISC,
5038c2ecf20Sopenharmony_ci	.lock_mask = PLL_BASE_LOCK,
5048c2ecf20Sopenharmony_ci	.lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
5058c2ecf20Sopenharmony_ci	.lock_delay = 300,
5068c2ecf20Sopenharmony_ci	.iddq_reg = PLLX_MISC3,
5078c2ecf20Sopenharmony_ci	.iddq_bit_idx = PLLX_IDDQ_BIT,
5088c2ecf20Sopenharmony_ci	.max_p = PLLXC_SW_MAX_P,
5098c2ecf20Sopenharmony_ci	.dyn_ramp_reg = PLLX_MISC2,
5108c2ecf20Sopenharmony_ci	.stepa_shift = 16,
5118c2ecf20Sopenharmony_ci	.stepb_shift = 24,
5128c2ecf20Sopenharmony_ci	.pdiv_tohw = pllxc_p,
5138c2ecf20Sopenharmony_ci	.div_nmp = &pllxc_nmp,
5148c2ecf20Sopenharmony_ci	.freq_table = pll_x_freq_table,
5158c2ecf20Sopenharmony_ci	.flags = TEGRA_PLL_USE_LOCK | TEGRA_PLL_HAS_LOCK_ENABLE,
5168c2ecf20Sopenharmony_ci};
5178c2ecf20Sopenharmony_ci
5188c2ecf20Sopenharmony_cistatic struct tegra_clk_pll_freq_table pll_e_freq_table[] = {
5198c2ecf20Sopenharmony_ci	/* PLLE special case: use cpcon field to store cml divider value */
5208c2ecf20Sopenharmony_ci	{ 336000000, 100000000, 100, 21, 16, 11 },
5218c2ecf20Sopenharmony_ci	{ 312000000, 100000000, 200, 26, 24, 13 },
5228c2ecf20Sopenharmony_ci	{  12000000, 100000000, 200,  1, 24, 13 },
5238c2ecf20Sopenharmony_ci	{         0,         0,   0,  0,  0,  0 },
5248c2ecf20Sopenharmony_ci};
5258c2ecf20Sopenharmony_ci
5268c2ecf20Sopenharmony_cistatic const struct pdiv_map plle_p[] = {
5278c2ecf20Sopenharmony_ci	{ .pdiv =  1, .hw_val =  0 },
5288c2ecf20Sopenharmony_ci	{ .pdiv =  2, .hw_val =  1 },
5298c2ecf20Sopenharmony_ci	{ .pdiv =  3, .hw_val =  2 },
5308c2ecf20Sopenharmony_ci	{ .pdiv =  4, .hw_val =  3 },
5318c2ecf20Sopenharmony_ci	{ .pdiv =  5, .hw_val =  4 },
5328c2ecf20Sopenharmony_ci	{ .pdiv =  6, .hw_val =  5 },
5338c2ecf20Sopenharmony_ci	{ .pdiv =  8, .hw_val =  6 },
5348c2ecf20Sopenharmony_ci	{ .pdiv = 10, .hw_val =  7 },
5358c2ecf20Sopenharmony_ci	{ .pdiv = 12, .hw_val =  8 },
5368c2ecf20Sopenharmony_ci	{ .pdiv = 16, .hw_val =  9 },
5378c2ecf20Sopenharmony_ci	{ .pdiv = 12, .hw_val = 10 },
5388c2ecf20Sopenharmony_ci	{ .pdiv = 16, .hw_val = 11 },
5398c2ecf20Sopenharmony_ci	{ .pdiv = 20, .hw_val = 12 },
5408c2ecf20Sopenharmony_ci	{ .pdiv = 24, .hw_val = 13 },
5418c2ecf20Sopenharmony_ci	{ .pdiv = 32, .hw_val = 14 },
5428c2ecf20Sopenharmony_ci	{ .pdiv =  0, .hw_val =  0 }
5438c2ecf20Sopenharmony_ci};
5448c2ecf20Sopenharmony_ci
5458c2ecf20Sopenharmony_cistatic struct div_nmp plle_nmp = {
5468c2ecf20Sopenharmony_ci	.divm_shift = 0,
5478c2ecf20Sopenharmony_ci	.divm_width = 8,
5488c2ecf20Sopenharmony_ci	.divn_shift = 8,
5498c2ecf20Sopenharmony_ci	.divn_width = 8,
5508c2ecf20Sopenharmony_ci	.divp_shift = 24,
5518c2ecf20Sopenharmony_ci	.divp_width = 4,
5528c2ecf20Sopenharmony_ci};
5538c2ecf20Sopenharmony_ci
5548c2ecf20Sopenharmony_cistatic struct tegra_clk_pll_params pll_e_params = {
5558c2ecf20Sopenharmony_ci	.input_min = 12000000,
5568c2ecf20Sopenharmony_ci	.input_max = 1000000000,
5578c2ecf20Sopenharmony_ci	.cf_min = 12000000,
5588c2ecf20Sopenharmony_ci	.cf_max = 75000000,
5598c2ecf20Sopenharmony_ci	.vco_min = 1600000000,
5608c2ecf20Sopenharmony_ci	.vco_max = 2400000000U,
5618c2ecf20Sopenharmony_ci	.base_reg = PLLE_BASE,
5628c2ecf20Sopenharmony_ci	.misc_reg = PLLE_MISC,
5638c2ecf20Sopenharmony_ci	.aux_reg = PLLE_AUX,
5648c2ecf20Sopenharmony_ci	.lock_mask = PLLE_MISC_LOCK,
5658c2ecf20Sopenharmony_ci	.lock_enable_bit_idx = PLLE_MISC_LOCK_ENABLE,
5668c2ecf20Sopenharmony_ci	.lock_delay = 300,
5678c2ecf20Sopenharmony_ci	.pdiv_tohw = plle_p,
5688c2ecf20Sopenharmony_ci	.div_nmp = &plle_nmp,
5698c2ecf20Sopenharmony_ci	.freq_table = pll_e_freq_table,
5708c2ecf20Sopenharmony_ci	.flags = TEGRA_PLL_FIXED | TEGRA_PLL_HAS_LOCK_ENABLE,
5718c2ecf20Sopenharmony_ci	.fixed_rate = 100000000,
5728c2ecf20Sopenharmony_ci};
5738c2ecf20Sopenharmony_ci
5748c2ecf20Sopenharmony_cistatic struct div_nmp pllre_nmp = {
5758c2ecf20Sopenharmony_ci	.divm_shift = 0,
5768c2ecf20Sopenharmony_ci	.divm_width = 8,
5778c2ecf20Sopenharmony_ci	.divn_shift = 8,
5788c2ecf20Sopenharmony_ci	.divn_width = 8,
5798c2ecf20Sopenharmony_ci	.divp_shift = 16,
5808c2ecf20Sopenharmony_ci	.divp_width = 4,
5818c2ecf20Sopenharmony_ci};
5828c2ecf20Sopenharmony_ci
5838c2ecf20Sopenharmony_cistatic struct tegra_clk_pll_params pll_re_vco_params = {
5848c2ecf20Sopenharmony_ci	.input_min = 12000000,
5858c2ecf20Sopenharmony_ci	.input_max = 1000000000,
5868c2ecf20Sopenharmony_ci	.cf_min = 12000000,
5878c2ecf20Sopenharmony_ci	.cf_max = 19200000, /* s/w policy, h/w capability 38 MHz */
5888c2ecf20Sopenharmony_ci	.vco_min = 300000000,
5898c2ecf20Sopenharmony_ci	.vco_max = 600000000,
5908c2ecf20Sopenharmony_ci	.base_reg = PLLRE_BASE,
5918c2ecf20Sopenharmony_ci	.misc_reg = PLLRE_MISC,
5928c2ecf20Sopenharmony_ci	.lock_mask = PLLRE_MISC_LOCK,
5938c2ecf20Sopenharmony_ci	.lock_enable_bit_idx = PLLRE_MISC_LOCK_ENABLE,
5948c2ecf20Sopenharmony_ci	.lock_delay = 300,
5958c2ecf20Sopenharmony_ci	.iddq_reg = PLLRE_MISC,
5968c2ecf20Sopenharmony_ci	.iddq_bit_idx = PLLRE_IDDQ_BIT,
5978c2ecf20Sopenharmony_ci	.div_nmp = &pllre_nmp,
5988c2ecf20Sopenharmony_ci	.flags = TEGRA_PLL_USE_LOCK | TEGRA_PLL_HAS_LOCK_ENABLE |
5998c2ecf20Sopenharmony_ci		 TEGRA_PLL_LOCK_MISC,
6008c2ecf20Sopenharmony_ci};
6018c2ecf20Sopenharmony_ci
6028c2ecf20Sopenharmony_ci/* possible OSC frequencies in Hz */
6038c2ecf20Sopenharmony_cistatic unsigned long tegra114_input_freq[] = {
6048c2ecf20Sopenharmony_ci	[ 0] = 13000000,
6058c2ecf20Sopenharmony_ci	[ 1] = 16800000,
6068c2ecf20Sopenharmony_ci	[ 4] = 19200000,
6078c2ecf20Sopenharmony_ci	[ 5] = 38400000,
6088c2ecf20Sopenharmony_ci	[ 8] = 12000000,
6098c2ecf20Sopenharmony_ci	[ 9] = 48000000,
6108c2ecf20Sopenharmony_ci	[12] = 26000000,
6118c2ecf20Sopenharmony_ci};
6128c2ecf20Sopenharmony_ci
6138c2ecf20Sopenharmony_ci#define MASK(x) (BIT(x) - 1)
6148c2ecf20Sopenharmony_ci
6158c2ecf20Sopenharmony_ci/* peripheral mux definitions */
6168c2ecf20Sopenharmony_ci
6178c2ecf20Sopenharmony_cistatic const char *mux_plld_out0_plld2_out0[] = {
6188c2ecf20Sopenharmony_ci	"pll_d_out0", "pll_d2_out0",
6198c2ecf20Sopenharmony_ci};
6208c2ecf20Sopenharmony_ci#define mux_plld_out0_plld2_out0_idx NULL
6218c2ecf20Sopenharmony_ci
6228c2ecf20Sopenharmony_cistatic const char *mux_pllmcp_clkm[] = {
6238c2ecf20Sopenharmony_ci	"pll_m_out0", "pll_c_out0", "pll_p_out0", "clk_m", "pll_m_ud",
6248c2ecf20Sopenharmony_ci};
6258c2ecf20Sopenharmony_ci
6268c2ecf20Sopenharmony_cistatic const struct clk_div_table pll_re_div_table[] = {
6278c2ecf20Sopenharmony_ci	{ .val = 0, .div = 1 },
6288c2ecf20Sopenharmony_ci	{ .val = 1, .div = 2 },
6298c2ecf20Sopenharmony_ci	{ .val = 2, .div = 3 },
6308c2ecf20Sopenharmony_ci	{ .val = 3, .div = 4 },
6318c2ecf20Sopenharmony_ci	{ .val = 4, .div = 5 },
6328c2ecf20Sopenharmony_ci	{ .val = 5, .div = 6 },
6338c2ecf20Sopenharmony_ci	{ .val = 0, .div = 0 },
6348c2ecf20Sopenharmony_ci};
6358c2ecf20Sopenharmony_ci
6368c2ecf20Sopenharmony_cistatic struct tegra_clk tegra114_clks[tegra_clk_max] __initdata = {
6378c2ecf20Sopenharmony_ci	[tegra_clk_rtc] = { .dt_id = TEGRA114_CLK_RTC, .present = true },
6388c2ecf20Sopenharmony_ci	[tegra_clk_timer] = { .dt_id = TEGRA114_CLK_TIMER, .present = true },
6398c2ecf20Sopenharmony_ci	[tegra_clk_uarta] = { .dt_id = TEGRA114_CLK_UARTA, .present = true },
6408c2ecf20Sopenharmony_ci	[tegra_clk_uartd] = { .dt_id = TEGRA114_CLK_UARTD, .present = true },
6418c2ecf20Sopenharmony_ci	[tegra_clk_sdmmc2_8] = { .dt_id = TEGRA114_CLK_SDMMC2, .present = true },
6428c2ecf20Sopenharmony_ci	[tegra_clk_i2s1] = { .dt_id = TEGRA114_CLK_I2S1, .present = true },
6438c2ecf20Sopenharmony_ci	[tegra_clk_i2c1] = { .dt_id = TEGRA114_CLK_I2C1, .present = true },
6448c2ecf20Sopenharmony_ci	[tegra_clk_ndflash] = { .dt_id = TEGRA114_CLK_NDFLASH, .present = true },
6458c2ecf20Sopenharmony_ci	[tegra_clk_sdmmc1_8] = { .dt_id = TEGRA114_CLK_SDMMC1, .present = true },
6468c2ecf20Sopenharmony_ci	[tegra_clk_sdmmc4_8] = { .dt_id = TEGRA114_CLK_SDMMC4, .present = true },
6478c2ecf20Sopenharmony_ci	[tegra_clk_pwm] = { .dt_id = TEGRA114_CLK_PWM, .present = true },
6488c2ecf20Sopenharmony_ci	[tegra_clk_i2s0] = { .dt_id = TEGRA114_CLK_I2S0, .present = true },
6498c2ecf20Sopenharmony_ci	[tegra_clk_i2s2] = { .dt_id = TEGRA114_CLK_I2S2, .present = true },
6508c2ecf20Sopenharmony_ci	[tegra_clk_epp_8] = { .dt_id = TEGRA114_CLK_EPP, .present = true },
6518c2ecf20Sopenharmony_ci	[tegra_clk_gr2d_8] = { .dt_id = TEGRA114_CLK_GR2D, .present = true },
6528c2ecf20Sopenharmony_ci	[tegra_clk_usbd] = { .dt_id = TEGRA114_CLK_USBD, .present = true },
6538c2ecf20Sopenharmony_ci	[tegra_clk_isp] = { .dt_id = TEGRA114_CLK_ISP, .present = true },
6548c2ecf20Sopenharmony_ci	[tegra_clk_gr3d_8] = { .dt_id = TEGRA114_CLK_GR3D, .present = true },
6558c2ecf20Sopenharmony_ci	[tegra_clk_disp2] = { .dt_id = TEGRA114_CLK_DISP2, .present = true },
6568c2ecf20Sopenharmony_ci	[tegra_clk_disp1] = { .dt_id = TEGRA114_CLK_DISP1, .present = true },
6578c2ecf20Sopenharmony_ci	[tegra_clk_host1x_8] = { .dt_id = TEGRA114_CLK_HOST1X, .present = true },
6588c2ecf20Sopenharmony_ci	[tegra_clk_vcp] = { .dt_id = TEGRA114_CLK_VCP, .present = true },
6598c2ecf20Sopenharmony_ci	[tegra_clk_apbdma] = { .dt_id = TEGRA114_CLK_APBDMA, .present = true },
6608c2ecf20Sopenharmony_ci	[tegra_clk_kbc] = { .dt_id = TEGRA114_CLK_KBC, .present = true },
6618c2ecf20Sopenharmony_ci	[tegra_clk_kfuse] = { .dt_id = TEGRA114_CLK_KFUSE, .present = true },
6628c2ecf20Sopenharmony_ci	[tegra_clk_sbc1_8] = { .dt_id = TEGRA114_CLK_SBC1, .present = true },
6638c2ecf20Sopenharmony_ci	[tegra_clk_nor] = { .dt_id = TEGRA114_CLK_NOR, .present = true },
6648c2ecf20Sopenharmony_ci	[tegra_clk_sbc2_8] = { .dt_id = TEGRA114_CLK_SBC2, .present = true },
6658c2ecf20Sopenharmony_ci	[tegra_clk_sbc3_8] = { .dt_id = TEGRA114_CLK_SBC3, .present = true },
6668c2ecf20Sopenharmony_ci	[tegra_clk_i2c5] = { .dt_id = TEGRA114_CLK_I2C5, .present = true },
6678c2ecf20Sopenharmony_ci	[tegra_clk_mipi] = { .dt_id = TEGRA114_CLK_MIPI, .present = true },
6688c2ecf20Sopenharmony_ci	[tegra_clk_hdmi] = { .dt_id = TEGRA114_CLK_HDMI, .present = true },
6698c2ecf20Sopenharmony_ci	[tegra_clk_csi] = { .dt_id = TEGRA114_CLK_CSI, .present = true },
6708c2ecf20Sopenharmony_ci	[tegra_clk_i2c2] = { .dt_id = TEGRA114_CLK_I2C2, .present = true },
6718c2ecf20Sopenharmony_ci	[tegra_clk_uartc] = { .dt_id = TEGRA114_CLK_UARTC, .present = true },
6728c2ecf20Sopenharmony_ci	[tegra_clk_emc] = { .dt_id = TEGRA114_CLK_EMC, .present = true },
6738c2ecf20Sopenharmony_ci	[tegra_clk_usb2] = { .dt_id = TEGRA114_CLK_USB2, .present = true },
6748c2ecf20Sopenharmony_ci	[tegra_clk_usb3] = { .dt_id = TEGRA114_CLK_USB3, .present = true },
6758c2ecf20Sopenharmony_ci	[tegra_clk_vde_8] = { .dt_id = TEGRA114_CLK_VDE, .present = true },
6768c2ecf20Sopenharmony_ci	[tegra_clk_bsea] = { .dt_id = TEGRA114_CLK_BSEA, .present = true },
6778c2ecf20Sopenharmony_ci	[tegra_clk_bsev] = { .dt_id = TEGRA114_CLK_BSEV, .present = true },
6788c2ecf20Sopenharmony_ci	[tegra_clk_i2c3] = { .dt_id = TEGRA114_CLK_I2C3, .present = true },
6798c2ecf20Sopenharmony_ci	[tegra_clk_sbc4_8] = { .dt_id = TEGRA114_CLK_SBC4, .present = true },
6808c2ecf20Sopenharmony_ci	[tegra_clk_sdmmc3_8] = { .dt_id = TEGRA114_CLK_SDMMC3, .present = true },
6818c2ecf20Sopenharmony_ci	[tegra_clk_owr] = { .dt_id = TEGRA114_CLK_OWR, .present = true },
6828c2ecf20Sopenharmony_ci	[tegra_clk_csite] = { .dt_id = TEGRA114_CLK_CSITE, .present = true },
6838c2ecf20Sopenharmony_ci	[tegra_clk_la] = { .dt_id = TEGRA114_CLK_LA, .present = true },
6848c2ecf20Sopenharmony_ci	[tegra_clk_trace] = { .dt_id = TEGRA114_CLK_TRACE, .present = true },
6858c2ecf20Sopenharmony_ci	[tegra_clk_soc_therm] = { .dt_id = TEGRA114_CLK_SOC_THERM, .present = true },
6868c2ecf20Sopenharmony_ci	[tegra_clk_dtv] = { .dt_id = TEGRA114_CLK_DTV, .present = true },
6878c2ecf20Sopenharmony_ci	[tegra_clk_ndspeed] = { .dt_id = TEGRA114_CLK_NDSPEED, .present = true },
6888c2ecf20Sopenharmony_ci	[tegra_clk_i2cslow] = { .dt_id = TEGRA114_CLK_I2CSLOW, .present = true },
6898c2ecf20Sopenharmony_ci	[tegra_clk_tsec] = { .dt_id = TEGRA114_CLK_TSEC, .present = true },
6908c2ecf20Sopenharmony_ci	[tegra_clk_xusb_host] = { .dt_id = TEGRA114_CLK_XUSB_HOST, .present = true },
6918c2ecf20Sopenharmony_ci	[tegra_clk_msenc] = { .dt_id = TEGRA114_CLK_MSENC, .present = true },
6928c2ecf20Sopenharmony_ci	[tegra_clk_csus] = { .dt_id = TEGRA114_CLK_CSUS, .present = true },
6938c2ecf20Sopenharmony_ci	[tegra_clk_mselect] = { .dt_id = TEGRA114_CLK_MSELECT, .present = true },
6948c2ecf20Sopenharmony_ci	[tegra_clk_tsensor] = { .dt_id = TEGRA114_CLK_TSENSOR, .present = true },
6958c2ecf20Sopenharmony_ci	[tegra_clk_i2s3] = { .dt_id = TEGRA114_CLK_I2S3, .present = true },
6968c2ecf20Sopenharmony_ci	[tegra_clk_i2s4] = { .dt_id = TEGRA114_CLK_I2S4, .present = true },
6978c2ecf20Sopenharmony_ci	[tegra_clk_i2c4] = { .dt_id = TEGRA114_CLK_I2C4, .present = true },
6988c2ecf20Sopenharmony_ci	[tegra_clk_sbc5_8] = { .dt_id = TEGRA114_CLK_SBC5, .present = true },
6998c2ecf20Sopenharmony_ci	[tegra_clk_sbc6_8] = { .dt_id = TEGRA114_CLK_SBC6, .present = true },
7008c2ecf20Sopenharmony_ci	[tegra_clk_d_audio] = { .dt_id = TEGRA114_CLK_D_AUDIO, .present = true },
7018c2ecf20Sopenharmony_ci	[tegra_clk_apbif] = { .dt_id = TEGRA114_CLK_APBIF, .present = true },
7028c2ecf20Sopenharmony_ci	[tegra_clk_dam0] = { .dt_id = TEGRA114_CLK_DAM0, .present = true },
7038c2ecf20Sopenharmony_ci	[tegra_clk_dam1] = { .dt_id = TEGRA114_CLK_DAM1, .present = true },
7048c2ecf20Sopenharmony_ci	[tegra_clk_dam2] = { .dt_id = TEGRA114_CLK_DAM2, .present = true },
7058c2ecf20Sopenharmony_ci	[tegra_clk_hda2codec_2x] = { .dt_id = TEGRA114_CLK_HDA2CODEC_2X, .present = true },
7068c2ecf20Sopenharmony_ci	[tegra_clk_audio0_2x] = { .dt_id = TEGRA114_CLK_AUDIO0_2X, .present = true },
7078c2ecf20Sopenharmony_ci	[tegra_clk_audio1_2x] = { .dt_id = TEGRA114_CLK_AUDIO1_2X, .present = true },
7088c2ecf20Sopenharmony_ci	[tegra_clk_audio2_2x] = { .dt_id = TEGRA114_CLK_AUDIO2_2X, .present = true },
7098c2ecf20Sopenharmony_ci	[tegra_clk_audio3_2x] = { .dt_id = TEGRA114_CLK_AUDIO3_2X, .present = true },
7108c2ecf20Sopenharmony_ci	[tegra_clk_audio4_2x] = { .dt_id = TEGRA114_CLK_AUDIO4_2X, .present = true },
7118c2ecf20Sopenharmony_ci	[tegra_clk_spdif_2x] = { .dt_id = TEGRA114_CLK_SPDIF_2X, .present = true },
7128c2ecf20Sopenharmony_ci	[tegra_clk_actmon] = { .dt_id = TEGRA114_CLK_ACTMON, .present = true },
7138c2ecf20Sopenharmony_ci	[tegra_clk_extern1] = { .dt_id = TEGRA114_CLK_EXTERN1, .present = true },
7148c2ecf20Sopenharmony_ci	[tegra_clk_extern2] = { .dt_id = TEGRA114_CLK_EXTERN2, .present = true },
7158c2ecf20Sopenharmony_ci	[tegra_clk_extern3] = { .dt_id = TEGRA114_CLK_EXTERN3, .present = true },
7168c2ecf20Sopenharmony_ci	[tegra_clk_hda] = { .dt_id = TEGRA114_CLK_HDA, .present = true },
7178c2ecf20Sopenharmony_ci	[tegra_clk_se] = { .dt_id = TEGRA114_CLK_SE, .present = true },
7188c2ecf20Sopenharmony_ci	[tegra_clk_hda2hdmi] = { .dt_id = TEGRA114_CLK_HDA2HDMI, .present = true },
7198c2ecf20Sopenharmony_ci	[tegra_clk_cilab] = { .dt_id = TEGRA114_CLK_CILAB, .present = true },
7208c2ecf20Sopenharmony_ci	[tegra_clk_cilcd] = { .dt_id = TEGRA114_CLK_CILCD, .present = true },
7218c2ecf20Sopenharmony_ci	[tegra_clk_cile] = { .dt_id = TEGRA114_CLK_CILE, .present = true },
7228c2ecf20Sopenharmony_ci	[tegra_clk_dsialp] = { .dt_id = TEGRA114_CLK_DSIALP, .present = true },
7238c2ecf20Sopenharmony_ci	[tegra_clk_dsiblp] = { .dt_id = TEGRA114_CLK_DSIBLP, .present = true },
7248c2ecf20Sopenharmony_ci	[tegra_clk_dds] = { .dt_id = TEGRA114_CLK_DDS, .present = true },
7258c2ecf20Sopenharmony_ci	[tegra_clk_dp2] = { .dt_id = TEGRA114_CLK_DP2, .present = true },
7268c2ecf20Sopenharmony_ci	[tegra_clk_amx] = { .dt_id = TEGRA114_CLK_AMX, .present = true },
7278c2ecf20Sopenharmony_ci	[tegra_clk_adx] = { .dt_id = TEGRA114_CLK_ADX, .present = true },
7288c2ecf20Sopenharmony_ci	[tegra_clk_xusb_ss] = { .dt_id = TEGRA114_CLK_XUSB_SS, .present = true },
7298c2ecf20Sopenharmony_ci	[tegra_clk_uartb] = { .dt_id = TEGRA114_CLK_UARTB, .present = true },
7308c2ecf20Sopenharmony_ci	[tegra_clk_vfir] = { .dt_id = TEGRA114_CLK_VFIR, .present = true },
7318c2ecf20Sopenharmony_ci	[tegra_clk_spdif_in] = { .dt_id = TEGRA114_CLK_SPDIF_IN, .present = true },
7328c2ecf20Sopenharmony_ci	[tegra_clk_spdif_out] = { .dt_id = TEGRA114_CLK_SPDIF_OUT, .present = true },
7338c2ecf20Sopenharmony_ci	[tegra_clk_vi_8] = { .dt_id = TEGRA114_CLK_VI, .present = true },
7348c2ecf20Sopenharmony_ci	[tegra_clk_fuse] = { .dt_id = TEGRA114_CLK_FUSE, .present = true },
7358c2ecf20Sopenharmony_ci	[tegra_clk_fuse_burn] = { .dt_id = TEGRA114_CLK_FUSE_BURN, .present = true },
7368c2ecf20Sopenharmony_ci	[tegra_clk_clk_32k] = { .dt_id = TEGRA114_CLK_CLK_32K, .present = true },
7378c2ecf20Sopenharmony_ci	[tegra_clk_clk_m] = { .dt_id = TEGRA114_CLK_CLK_M, .present = true },
7388c2ecf20Sopenharmony_ci	[tegra_clk_osc] = { .dt_id = TEGRA114_CLK_OSC, .present = true },
7398c2ecf20Sopenharmony_ci	[tegra_clk_osc_div2] = { .dt_id = TEGRA114_CLK_OSC_DIV2, .present = true },
7408c2ecf20Sopenharmony_ci	[tegra_clk_osc_div4] = { .dt_id = TEGRA114_CLK_OSC_DIV4, .present = true },
7418c2ecf20Sopenharmony_ci	[tegra_clk_pll_ref] = { .dt_id = TEGRA114_CLK_PLL_REF, .present = true },
7428c2ecf20Sopenharmony_ci	[tegra_clk_pll_c] = { .dt_id = TEGRA114_CLK_PLL_C, .present = true },
7438c2ecf20Sopenharmony_ci	[tegra_clk_pll_c_out1] = { .dt_id = TEGRA114_CLK_PLL_C_OUT1, .present = true },
7448c2ecf20Sopenharmony_ci	[tegra_clk_pll_c2] = { .dt_id = TEGRA114_CLK_PLL_C2, .present = true },
7458c2ecf20Sopenharmony_ci	[tegra_clk_pll_c3] = { .dt_id = TEGRA114_CLK_PLL_C3, .present = true },
7468c2ecf20Sopenharmony_ci	[tegra_clk_pll_m] = { .dt_id = TEGRA114_CLK_PLL_M, .present = true },
7478c2ecf20Sopenharmony_ci	[tegra_clk_pll_m_out1] = { .dt_id = TEGRA114_CLK_PLL_M_OUT1, .present = true },
7488c2ecf20Sopenharmony_ci	[tegra_clk_pll_p] = { .dt_id = TEGRA114_CLK_PLL_P, .present = true },
7498c2ecf20Sopenharmony_ci	[tegra_clk_pll_p_out1] = { .dt_id = TEGRA114_CLK_PLL_P_OUT1, .present = true },
7508c2ecf20Sopenharmony_ci	[tegra_clk_pll_p_out2_int] = { .dt_id = TEGRA114_CLK_PLL_P_OUT2, .present = true },
7518c2ecf20Sopenharmony_ci	[tegra_clk_pll_p_out3] = { .dt_id = TEGRA114_CLK_PLL_P_OUT3, .present = true },
7528c2ecf20Sopenharmony_ci	[tegra_clk_pll_p_out4] = { .dt_id = TEGRA114_CLK_PLL_P_OUT4, .present = true },
7538c2ecf20Sopenharmony_ci	[tegra_clk_pll_a] = { .dt_id = TEGRA114_CLK_PLL_A, .present = true },
7548c2ecf20Sopenharmony_ci	[tegra_clk_pll_a_out0] = { .dt_id = TEGRA114_CLK_PLL_A_OUT0, .present = true },
7558c2ecf20Sopenharmony_ci	[tegra_clk_pll_d] = { .dt_id = TEGRA114_CLK_PLL_D, .present = true },
7568c2ecf20Sopenharmony_ci	[tegra_clk_pll_d_out0] = { .dt_id = TEGRA114_CLK_PLL_D_OUT0, .present = true },
7578c2ecf20Sopenharmony_ci	[tegra_clk_pll_d2] = { .dt_id = TEGRA114_CLK_PLL_D2, .present = true },
7588c2ecf20Sopenharmony_ci	[tegra_clk_pll_d2_out0] = { .dt_id = TEGRA114_CLK_PLL_D2_OUT0, .present = true },
7598c2ecf20Sopenharmony_ci	[tegra_clk_pll_u] = { .dt_id = TEGRA114_CLK_PLL_U, .present = true },
7608c2ecf20Sopenharmony_ci	[tegra_clk_pll_u_480m] = { .dt_id = TEGRA114_CLK_PLL_U_480M, .present = true },
7618c2ecf20Sopenharmony_ci	[tegra_clk_pll_u_60m] = { .dt_id = TEGRA114_CLK_PLL_U_60M, .present = true },
7628c2ecf20Sopenharmony_ci	[tegra_clk_pll_u_48m] = { .dt_id = TEGRA114_CLK_PLL_U_48M, .present = true },
7638c2ecf20Sopenharmony_ci	[tegra_clk_pll_u_12m] = { .dt_id = TEGRA114_CLK_PLL_U_12M, .present = true },
7648c2ecf20Sopenharmony_ci	[tegra_clk_pll_x] = { .dt_id = TEGRA114_CLK_PLL_X, .present = true },
7658c2ecf20Sopenharmony_ci	[tegra_clk_pll_x_out0] = { .dt_id = TEGRA114_CLK_PLL_X_OUT0, .present = true },
7668c2ecf20Sopenharmony_ci	[tegra_clk_pll_re_vco] = { .dt_id = TEGRA114_CLK_PLL_RE_VCO, .present = true },
7678c2ecf20Sopenharmony_ci	[tegra_clk_pll_re_out] = { .dt_id = TEGRA114_CLK_PLL_RE_OUT, .present = true },
7688c2ecf20Sopenharmony_ci	[tegra_clk_pll_e_out0] = { .dt_id = TEGRA114_CLK_PLL_E_OUT0, .present = true },
7698c2ecf20Sopenharmony_ci	[tegra_clk_spdif_in_sync] = { .dt_id = TEGRA114_CLK_SPDIF_IN_SYNC, .present = true },
7708c2ecf20Sopenharmony_ci	[tegra_clk_i2s0_sync] = { .dt_id = TEGRA114_CLK_I2S0_SYNC, .present = true },
7718c2ecf20Sopenharmony_ci	[tegra_clk_i2s1_sync] = { .dt_id = TEGRA114_CLK_I2S1_SYNC, .present = true },
7728c2ecf20Sopenharmony_ci	[tegra_clk_i2s2_sync] = { .dt_id = TEGRA114_CLK_I2S2_SYNC, .present = true },
7738c2ecf20Sopenharmony_ci	[tegra_clk_i2s3_sync] = { .dt_id = TEGRA114_CLK_I2S3_SYNC, .present = true },
7748c2ecf20Sopenharmony_ci	[tegra_clk_i2s4_sync] = { .dt_id = TEGRA114_CLK_I2S4_SYNC, .present = true },
7758c2ecf20Sopenharmony_ci	[tegra_clk_vimclk_sync] = { .dt_id = TEGRA114_CLK_VIMCLK_SYNC, .present = true },
7768c2ecf20Sopenharmony_ci	[tegra_clk_audio0] = { .dt_id = TEGRA114_CLK_AUDIO0, .present = true },
7778c2ecf20Sopenharmony_ci	[tegra_clk_audio1] = { .dt_id = TEGRA114_CLK_AUDIO1, .present = true },
7788c2ecf20Sopenharmony_ci	[tegra_clk_audio2] = { .dt_id = TEGRA114_CLK_AUDIO2, .present = true },
7798c2ecf20Sopenharmony_ci	[tegra_clk_audio3] = { .dt_id = TEGRA114_CLK_AUDIO3, .present = true },
7808c2ecf20Sopenharmony_ci	[tegra_clk_audio4] = { .dt_id = TEGRA114_CLK_AUDIO4, .present = true },
7818c2ecf20Sopenharmony_ci	[tegra_clk_spdif] = { .dt_id = TEGRA114_CLK_SPDIF, .present = true },
7828c2ecf20Sopenharmony_ci	[tegra_clk_xusb_host_src] = { .dt_id = TEGRA114_CLK_XUSB_HOST_SRC, .present = true },
7838c2ecf20Sopenharmony_ci	[tegra_clk_xusb_falcon_src] = { .dt_id = TEGRA114_CLK_XUSB_FALCON_SRC, .present = true },
7848c2ecf20Sopenharmony_ci	[tegra_clk_xusb_fs_src] = { .dt_id = TEGRA114_CLK_XUSB_FS_SRC, .present = true },
7858c2ecf20Sopenharmony_ci	[tegra_clk_xusb_ss_src] = { .dt_id = TEGRA114_CLK_XUSB_SS_SRC, .present = true },
7868c2ecf20Sopenharmony_ci	[tegra_clk_xusb_ss_div2] = { .dt_id = TEGRA114_CLK_XUSB_SS_DIV2, .present = true},
7878c2ecf20Sopenharmony_ci	[tegra_clk_xusb_dev_src] = { .dt_id = TEGRA114_CLK_XUSB_DEV_SRC, .present = true },
7888c2ecf20Sopenharmony_ci	[tegra_clk_xusb_dev] = { .dt_id = TEGRA114_CLK_XUSB_DEV, .present = true },
7898c2ecf20Sopenharmony_ci	[tegra_clk_xusb_hs_src] = { .dt_id = TEGRA114_CLK_XUSB_HS_SRC, .present = true },
7908c2ecf20Sopenharmony_ci	[tegra_clk_sclk] = { .dt_id = TEGRA114_CLK_SCLK, .present = true },
7918c2ecf20Sopenharmony_ci	[tegra_clk_hclk] = { .dt_id = TEGRA114_CLK_HCLK, .present = true },
7928c2ecf20Sopenharmony_ci	[tegra_clk_pclk] = { .dt_id = TEGRA114_CLK_PCLK, .present = true },
7938c2ecf20Sopenharmony_ci	[tegra_clk_cclk_g] = { .dt_id = TEGRA114_CLK_CCLK_G, .present = true },
7948c2ecf20Sopenharmony_ci	[tegra_clk_cclk_lp] = { .dt_id = TEGRA114_CLK_CCLK_LP, .present = true },
7958c2ecf20Sopenharmony_ci	[tegra_clk_dfll_ref] = { .dt_id = TEGRA114_CLK_DFLL_REF, .present = true },
7968c2ecf20Sopenharmony_ci	[tegra_clk_dfll_soc] = { .dt_id = TEGRA114_CLK_DFLL_SOC, .present = true },
7978c2ecf20Sopenharmony_ci	[tegra_clk_audio0_mux] = { .dt_id = TEGRA114_CLK_AUDIO0_MUX, .present = true },
7988c2ecf20Sopenharmony_ci	[tegra_clk_audio1_mux] = { .dt_id = TEGRA114_CLK_AUDIO1_MUX, .present = true },
7998c2ecf20Sopenharmony_ci	[tegra_clk_audio2_mux] = { .dt_id = TEGRA114_CLK_AUDIO2_MUX, .present = true },
8008c2ecf20Sopenharmony_ci	[tegra_clk_audio3_mux] = { .dt_id = TEGRA114_CLK_AUDIO3_MUX, .present = true },
8018c2ecf20Sopenharmony_ci	[tegra_clk_audio4_mux] = { .dt_id = TEGRA114_CLK_AUDIO4_MUX, .present = true },
8028c2ecf20Sopenharmony_ci	[tegra_clk_spdif_mux] = { .dt_id = TEGRA114_CLK_SPDIF_MUX, .present = true },
8038c2ecf20Sopenharmony_ci	[tegra_clk_dsia_mux] = { .dt_id = TEGRA114_CLK_DSIA_MUX, .present = true },
8048c2ecf20Sopenharmony_ci	[tegra_clk_dsib_mux] = { .dt_id = TEGRA114_CLK_DSIB_MUX, .present = true },
8058c2ecf20Sopenharmony_ci	[tegra_clk_cec] = { .dt_id = TEGRA114_CLK_CEC, .present = true },
8068c2ecf20Sopenharmony_ci};
8078c2ecf20Sopenharmony_ci
8088c2ecf20Sopenharmony_cistatic struct tegra_devclk devclks[] __initdata = {
8098c2ecf20Sopenharmony_ci	{ .con_id = "clk_m", .dt_id = TEGRA114_CLK_CLK_M },
8108c2ecf20Sopenharmony_ci	{ .con_id = "pll_ref", .dt_id = TEGRA114_CLK_PLL_REF },
8118c2ecf20Sopenharmony_ci	{ .con_id = "clk_32k", .dt_id = TEGRA114_CLK_CLK_32K },
8128c2ecf20Sopenharmony_ci	{ .con_id = "osc", .dt_id = TEGRA114_CLK_OSC },
8138c2ecf20Sopenharmony_ci	{ .con_id = "osc_div2", .dt_id = TEGRA114_CLK_OSC_DIV2 },
8148c2ecf20Sopenharmony_ci	{ .con_id = "osc_div4", .dt_id = TEGRA114_CLK_OSC_DIV4 },
8158c2ecf20Sopenharmony_ci	{ .con_id = "pll_c", .dt_id = TEGRA114_CLK_PLL_C },
8168c2ecf20Sopenharmony_ci	{ .con_id = "pll_c_out1", .dt_id = TEGRA114_CLK_PLL_C_OUT1 },
8178c2ecf20Sopenharmony_ci	{ .con_id = "pll_c2", .dt_id = TEGRA114_CLK_PLL_C2 },
8188c2ecf20Sopenharmony_ci	{ .con_id = "pll_c3", .dt_id = TEGRA114_CLK_PLL_C3 },
8198c2ecf20Sopenharmony_ci	{ .con_id = "pll_p", .dt_id = TEGRA114_CLK_PLL_P },
8208c2ecf20Sopenharmony_ci	{ .con_id = "pll_p_out1", .dt_id = TEGRA114_CLK_PLL_P_OUT1 },
8218c2ecf20Sopenharmony_ci	{ .con_id = "pll_p_out2", .dt_id = TEGRA114_CLK_PLL_P_OUT2 },
8228c2ecf20Sopenharmony_ci	{ .con_id = "pll_p_out3", .dt_id = TEGRA114_CLK_PLL_P_OUT3 },
8238c2ecf20Sopenharmony_ci	{ .con_id = "pll_p_out4", .dt_id = TEGRA114_CLK_PLL_P_OUT4 },
8248c2ecf20Sopenharmony_ci	{ .con_id = "pll_m", .dt_id = TEGRA114_CLK_PLL_M },
8258c2ecf20Sopenharmony_ci	{ .con_id = "pll_m_out1", .dt_id = TEGRA114_CLK_PLL_M_OUT1 },
8268c2ecf20Sopenharmony_ci	{ .con_id = "pll_x", .dt_id = TEGRA114_CLK_PLL_X },
8278c2ecf20Sopenharmony_ci	{ .con_id = "pll_x_out0", .dt_id = TEGRA114_CLK_PLL_X_OUT0 },
8288c2ecf20Sopenharmony_ci	{ .con_id = "pll_u", .dt_id = TEGRA114_CLK_PLL_U },
8298c2ecf20Sopenharmony_ci	{ .con_id = "pll_u_480M", .dt_id = TEGRA114_CLK_PLL_U_480M },
8308c2ecf20Sopenharmony_ci	{ .con_id = "pll_u_60M", .dt_id = TEGRA114_CLK_PLL_U_60M },
8318c2ecf20Sopenharmony_ci	{ .con_id = "pll_u_48M", .dt_id = TEGRA114_CLK_PLL_U_48M },
8328c2ecf20Sopenharmony_ci	{ .con_id = "pll_u_12M", .dt_id = TEGRA114_CLK_PLL_U_12M },
8338c2ecf20Sopenharmony_ci	{ .con_id = "pll_d", .dt_id = TEGRA114_CLK_PLL_D },
8348c2ecf20Sopenharmony_ci	{ .con_id = "pll_d_out0", .dt_id = TEGRA114_CLK_PLL_D_OUT0 },
8358c2ecf20Sopenharmony_ci	{ .con_id = "pll_d2", .dt_id = TEGRA114_CLK_PLL_D2 },
8368c2ecf20Sopenharmony_ci	{ .con_id = "pll_d2_out0", .dt_id = TEGRA114_CLK_PLL_D2_OUT0 },
8378c2ecf20Sopenharmony_ci	{ .con_id = "pll_a", .dt_id = TEGRA114_CLK_PLL_A },
8388c2ecf20Sopenharmony_ci	{ .con_id = "pll_a_out0", .dt_id = TEGRA114_CLK_PLL_A_OUT0 },
8398c2ecf20Sopenharmony_ci	{ .con_id = "pll_re_vco", .dt_id = TEGRA114_CLK_PLL_RE_VCO },
8408c2ecf20Sopenharmony_ci	{ .con_id = "pll_re_out", .dt_id = TEGRA114_CLK_PLL_RE_OUT },
8418c2ecf20Sopenharmony_ci	{ .con_id = "pll_e_out0", .dt_id = TEGRA114_CLK_PLL_E_OUT0 },
8428c2ecf20Sopenharmony_ci	{ .con_id = "spdif_in_sync", .dt_id = TEGRA114_CLK_SPDIF_IN_SYNC },
8438c2ecf20Sopenharmony_ci	{ .con_id = "i2s0_sync", .dt_id = TEGRA114_CLK_I2S0_SYNC },
8448c2ecf20Sopenharmony_ci	{ .con_id = "i2s1_sync", .dt_id = TEGRA114_CLK_I2S1_SYNC },
8458c2ecf20Sopenharmony_ci	{ .con_id = "i2s2_sync", .dt_id = TEGRA114_CLK_I2S2_SYNC },
8468c2ecf20Sopenharmony_ci	{ .con_id = "i2s3_sync", .dt_id = TEGRA114_CLK_I2S3_SYNC },
8478c2ecf20Sopenharmony_ci	{ .con_id = "i2s4_sync", .dt_id = TEGRA114_CLK_I2S4_SYNC },
8488c2ecf20Sopenharmony_ci	{ .con_id = "vimclk_sync", .dt_id = TEGRA114_CLK_VIMCLK_SYNC },
8498c2ecf20Sopenharmony_ci	{ .con_id = "audio0", .dt_id = TEGRA114_CLK_AUDIO0 },
8508c2ecf20Sopenharmony_ci	{ .con_id = "audio1", .dt_id = TEGRA114_CLK_AUDIO1 },
8518c2ecf20Sopenharmony_ci	{ .con_id = "audio2", .dt_id = TEGRA114_CLK_AUDIO2 },
8528c2ecf20Sopenharmony_ci	{ .con_id = "audio3", .dt_id = TEGRA114_CLK_AUDIO3 },
8538c2ecf20Sopenharmony_ci	{ .con_id = "audio4", .dt_id = TEGRA114_CLK_AUDIO4 },
8548c2ecf20Sopenharmony_ci	{ .con_id = "spdif", .dt_id = TEGRA114_CLK_SPDIF },
8558c2ecf20Sopenharmony_ci	{ .con_id = "audio0_2x", .dt_id = TEGRA114_CLK_AUDIO0_2X },
8568c2ecf20Sopenharmony_ci	{ .con_id = "audio1_2x", .dt_id = TEGRA114_CLK_AUDIO1_2X },
8578c2ecf20Sopenharmony_ci	{ .con_id = "audio2_2x", .dt_id = TEGRA114_CLK_AUDIO2_2X },
8588c2ecf20Sopenharmony_ci	{ .con_id = "audio3_2x", .dt_id = TEGRA114_CLK_AUDIO3_2X },
8598c2ecf20Sopenharmony_ci	{ .con_id = "audio4_2x", .dt_id = TEGRA114_CLK_AUDIO4_2X },
8608c2ecf20Sopenharmony_ci	{ .con_id = "spdif_2x", .dt_id = TEGRA114_CLK_SPDIF_2X },
8618c2ecf20Sopenharmony_ci	{ .con_id = "extern1", .dt_id = TEGRA114_CLK_EXTERN1 },
8628c2ecf20Sopenharmony_ci	{ .con_id = "extern2", .dt_id = TEGRA114_CLK_EXTERN2 },
8638c2ecf20Sopenharmony_ci	{ .con_id = "extern3", .dt_id = TEGRA114_CLK_EXTERN3 },
8648c2ecf20Sopenharmony_ci	{ .con_id = "cclk_g", .dt_id = TEGRA114_CLK_CCLK_G },
8658c2ecf20Sopenharmony_ci	{ .con_id = "cclk_lp", .dt_id = TEGRA114_CLK_CCLK_LP },
8668c2ecf20Sopenharmony_ci	{ .con_id = "sclk", .dt_id = TEGRA114_CLK_SCLK },
8678c2ecf20Sopenharmony_ci	{ .con_id = "hclk", .dt_id = TEGRA114_CLK_HCLK },
8688c2ecf20Sopenharmony_ci	{ .con_id = "pclk", .dt_id = TEGRA114_CLK_PCLK },
8698c2ecf20Sopenharmony_ci	{ .con_id = "fuse", .dt_id = TEGRA114_CLK_FUSE },
8708c2ecf20Sopenharmony_ci	{ .dev_id = "rtc-tegra", .dt_id = TEGRA114_CLK_RTC },
8718c2ecf20Sopenharmony_ci	{ .dev_id = "timer", .dt_id = TEGRA114_CLK_TIMER },
8728c2ecf20Sopenharmony_ci};
8738c2ecf20Sopenharmony_ci
8748c2ecf20Sopenharmony_cistatic const char *mux_pllm_pllc2_c_c3_pllp_plla[] = {
8758c2ecf20Sopenharmony_ci	"pll_m", "pll_c2", "pll_c", "pll_c3", "pll_p", "pll_a_out0"
8768c2ecf20Sopenharmony_ci};
8778c2ecf20Sopenharmony_cistatic u32 mux_pllm_pllc2_c_c3_pllp_plla_idx[] = {
8788c2ecf20Sopenharmony_ci	[0] = 0, [1] = 1, [2] = 2, [3] = 3, [4] = 4, [5] = 6,
8798c2ecf20Sopenharmony_ci};
8808c2ecf20Sopenharmony_ci
8818c2ecf20Sopenharmony_cistatic struct tegra_audio_clk_info tegra114_audio_plls[] = {
8828c2ecf20Sopenharmony_ci	{ "pll_a", &pll_a_params, tegra_clk_pll_a, "pll_p_out1" },
8838c2ecf20Sopenharmony_ci};
8848c2ecf20Sopenharmony_ci
8858c2ecf20Sopenharmony_cistatic struct clk **clks;
8868c2ecf20Sopenharmony_ci
8878c2ecf20Sopenharmony_cistatic unsigned long osc_freq;
8888c2ecf20Sopenharmony_cistatic unsigned long pll_ref_freq;
8898c2ecf20Sopenharmony_ci
8908c2ecf20Sopenharmony_cistatic void __init tegra114_fixed_clk_init(void __iomem *clk_base)
8918c2ecf20Sopenharmony_ci{
8928c2ecf20Sopenharmony_ci	struct clk *clk;
8938c2ecf20Sopenharmony_ci
8948c2ecf20Sopenharmony_ci	/* clk_32k */
8958c2ecf20Sopenharmony_ci	clk = clk_register_fixed_rate(NULL, "clk_32k", NULL, 0, 32768);
8968c2ecf20Sopenharmony_ci	clks[TEGRA114_CLK_CLK_32K] = clk;
8978c2ecf20Sopenharmony_ci}
8988c2ecf20Sopenharmony_ci
8998c2ecf20Sopenharmony_cistatic void __init tegra114_pll_init(void __iomem *clk_base,
9008c2ecf20Sopenharmony_ci				     void __iomem *pmc)
9018c2ecf20Sopenharmony_ci{
9028c2ecf20Sopenharmony_ci	struct clk *clk;
9038c2ecf20Sopenharmony_ci
9048c2ecf20Sopenharmony_ci	/* PLLC */
9058c2ecf20Sopenharmony_ci	clk = tegra_clk_register_pllxc("pll_c", "pll_ref", clk_base,
9068c2ecf20Sopenharmony_ci			pmc, 0, &pll_c_params, NULL);
9078c2ecf20Sopenharmony_ci	clks[TEGRA114_CLK_PLL_C] = clk;
9088c2ecf20Sopenharmony_ci
9098c2ecf20Sopenharmony_ci	/* PLLC_OUT1 */
9108c2ecf20Sopenharmony_ci	clk = tegra_clk_register_divider("pll_c_out1_div", "pll_c",
9118c2ecf20Sopenharmony_ci			clk_base + PLLC_OUT, 0, TEGRA_DIVIDER_ROUND_UP,
9128c2ecf20Sopenharmony_ci			8, 8, 1, NULL);
9138c2ecf20Sopenharmony_ci	clk = tegra_clk_register_pll_out("pll_c_out1", "pll_c_out1_div",
9148c2ecf20Sopenharmony_ci				clk_base + PLLC_OUT, 1, 0,
9158c2ecf20Sopenharmony_ci				CLK_SET_RATE_PARENT, 0, NULL);
9168c2ecf20Sopenharmony_ci	clks[TEGRA114_CLK_PLL_C_OUT1] = clk;
9178c2ecf20Sopenharmony_ci
9188c2ecf20Sopenharmony_ci	/* PLLC2 */
9198c2ecf20Sopenharmony_ci	clk = tegra_clk_register_pllc("pll_c2", "pll_ref", clk_base, pmc, 0,
9208c2ecf20Sopenharmony_ci			     &pll_c2_params, NULL);
9218c2ecf20Sopenharmony_ci	clks[TEGRA114_CLK_PLL_C2] = clk;
9228c2ecf20Sopenharmony_ci
9238c2ecf20Sopenharmony_ci	/* PLLC3 */
9248c2ecf20Sopenharmony_ci	clk = tegra_clk_register_pllc("pll_c3", "pll_ref", clk_base, pmc, 0,
9258c2ecf20Sopenharmony_ci			     &pll_c3_params, NULL);
9268c2ecf20Sopenharmony_ci	clks[TEGRA114_CLK_PLL_C3] = clk;
9278c2ecf20Sopenharmony_ci
9288c2ecf20Sopenharmony_ci	/* PLLM */
9298c2ecf20Sopenharmony_ci	clk = tegra_clk_register_pllm("pll_m", "pll_ref", clk_base, pmc,
9308c2ecf20Sopenharmony_ci			     CLK_SET_RATE_GATE, &pll_m_params, NULL);
9318c2ecf20Sopenharmony_ci	clks[TEGRA114_CLK_PLL_M] = clk;
9328c2ecf20Sopenharmony_ci
9338c2ecf20Sopenharmony_ci	/* PLLM_OUT1 */
9348c2ecf20Sopenharmony_ci	clk = tegra_clk_register_divider("pll_m_out1_div", "pll_m",
9358c2ecf20Sopenharmony_ci				clk_base + PLLM_OUT, 0, TEGRA_DIVIDER_ROUND_UP,
9368c2ecf20Sopenharmony_ci				8, 8, 1, NULL);
9378c2ecf20Sopenharmony_ci	clk = tegra_clk_register_pll_out("pll_m_out1", "pll_m_out1_div",
9388c2ecf20Sopenharmony_ci				clk_base + PLLM_OUT, 1, 0, CLK_IGNORE_UNUSED |
9398c2ecf20Sopenharmony_ci				CLK_SET_RATE_PARENT, 0, NULL);
9408c2ecf20Sopenharmony_ci	clks[TEGRA114_CLK_PLL_M_OUT1] = clk;
9418c2ecf20Sopenharmony_ci
9428c2ecf20Sopenharmony_ci	/* PLLM_UD */
9438c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "pll_m_ud", "pll_m",
9448c2ecf20Sopenharmony_ci					CLK_SET_RATE_PARENT, 1, 1);
9458c2ecf20Sopenharmony_ci
9468c2ecf20Sopenharmony_ci	/* PLLU */
9478c2ecf20Sopenharmony_ci	clk = tegra_clk_register_pllu_tegra114("pll_u", "pll_ref", clk_base, 0,
9488c2ecf20Sopenharmony_ci					       &pll_u_params, &pll_u_lock);
9498c2ecf20Sopenharmony_ci	clks[TEGRA114_CLK_PLL_U] = clk;
9508c2ecf20Sopenharmony_ci
9518c2ecf20Sopenharmony_ci	/* PLLU_480M */
9528c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "pll_u_480M", "pll_u",
9538c2ecf20Sopenharmony_ci				CLK_SET_RATE_PARENT, clk_base + PLLU_BASE,
9548c2ecf20Sopenharmony_ci				22, 0, &pll_u_lock);
9558c2ecf20Sopenharmony_ci	clks[TEGRA114_CLK_PLL_U_480M] = clk;
9568c2ecf20Sopenharmony_ci
9578c2ecf20Sopenharmony_ci	/* PLLU_60M */
9588c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "pll_u_60M", "pll_u",
9598c2ecf20Sopenharmony_ci					CLK_SET_RATE_PARENT, 1, 8);
9608c2ecf20Sopenharmony_ci	clks[TEGRA114_CLK_PLL_U_60M] = clk;
9618c2ecf20Sopenharmony_ci
9628c2ecf20Sopenharmony_ci	/* PLLU_48M */
9638c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "pll_u_48M", "pll_u",
9648c2ecf20Sopenharmony_ci					CLK_SET_RATE_PARENT, 1, 10);
9658c2ecf20Sopenharmony_ci	clks[TEGRA114_CLK_PLL_U_48M] = clk;
9668c2ecf20Sopenharmony_ci
9678c2ecf20Sopenharmony_ci	/* PLLU_12M */
9688c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "pll_u_12M", "pll_u",
9698c2ecf20Sopenharmony_ci					CLK_SET_RATE_PARENT, 1, 40);
9708c2ecf20Sopenharmony_ci	clks[TEGRA114_CLK_PLL_U_12M] = clk;
9718c2ecf20Sopenharmony_ci
9728c2ecf20Sopenharmony_ci	/* PLLD */
9738c2ecf20Sopenharmony_ci	clk = tegra_clk_register_pll("pll_d", "pll_ref", clk_base, pmc, 0,
9748c2ecf20Sopenharmony_ci			    &pll_d_params, &pll_d_lock);
9758c2ecf20Sopenharmony_ci	clks[TEGRA114_CLK_PLL_D] = clk;
9768c2ecf20Sopenharmony_ci
9778c2ecf20Sopenharmony_ci	/* PLLD_OUT0 */
9788c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "pll_d_out0", "pll_d",
9798c2ecf20Sopenharmony_ci					CLK_SET_RATE_PARENT, 1, 2);
9808c2ecf20Sopenharmony_ci	clks[TEGRA114_CLK_PLL_D_OUT0] = clk;
9818c2ecf20Sopenharmony_ci
9828c2ecf20Sopenharmony_ci	/* PLLD2 */
9838c2ecf20Sopenharmony_ci	clk = tegra_clk_register_pll("pll_d2", "pll_ref", clk_base, pmc, 0,
9848c2ecf20Sopenharmony_ci			    &pll_d2_params, &pll_d2_lock);
9858c2ecf20Sopenharmony_ci	clks[TEGRA114_CLK_PLL_D2] = clk;
9868c2ecf20Sopenharmony_ci
9878c2ecf20Sopenharmony_ci	/* PLLD2_OUT0 */
9888c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "pll_d2_out0", "pll_d2",
9898c2ecf20Sopenharmony_ci					CLK_SET_RATE_PARENT, 1, 2);
9908c2ecf20Sopenharmony_ci	clks[TEGRA114_CLK_PLL_D2_OUT0] = clk;
9918c2ecf20Sopenharmony_ci
9928c2ecf20Sopenharmony_ci	/* PLLRE */
9938c2ecf20Sopenharmony_ci	clk = tegra_clk_register_pllre("pll_re_vco", "pll_ref", clk_base, pmc,
9948c2ecf20Sopenharmony_ci			     0, &pll_re_vco_params, &pll_re_lock, pll_ref_freq);
9958c2ecf20Sopenharmony_ci	clks[TEGRA114_CLK_PLL_RE_VCO] = clk;
9968c2ecf20Sopenharmony_ci
9978c2ecf20Sopenharmony_ci	clk = clk_register_divider_table(NULL, "pll_re_out", "pll_re_vco", 0,
9988c2ecf20Sopenharmony_ci					 clk_base + PLLRE_BASE, 16, 4, 0,
9998c2ecf20Sopenharmony_ci					 pll_re_div_table, &pll_re_lock);
10008c2ecf20Sopenharmony_ci	clks[TEGRA114_CLK_PLL_RE_OUT] = clk;
10018c2ecf20Sopenharmony_ci
10028c2ecf20Sopenharmony_ci	/* PLLE */
10038c2ecf20Sopenharmony_ci	clk = tegra_clk_register_plle_tegra114("pll_e_out0", "pll_ref",
10048c2ecf20Sopenharmony_ci				      clk_base, 0, &pll_e_params, NULL);
10058c2ecf20Sopenharmony_ci	clks[TEGRA114_CLK_PLL_E_OUT0] = clk;
10068c2ecf20Sopenharmony_ci}
10078c2ecf20Sopenharmony_ci
10088c2ecf20Sopenharmony_ci#define CLK_SOURCE_VI_SENSOR 0x1a8
10098c2ecf20Sopenharmony_ci
10108c2ecf20Sopenharmony_cistatic struct tegra_periph_init_data tegra_periph_clk_list[] = {
10118c2ecf20Sopenharmony_ci	MUX8("vi_sensor", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_VI_SENSOR, 20, TEGRA_PERIPH_NO_RESET, TEGRA114_CLK_VI_SENSOR),
10128c2ecf20Sopenharmony_ci};
10138c2ecf20Sopenharmony_ci
10148c2ecf20Sopenharmony_cistatic __init void tegra114_periph_clk_init(void __iomem *clk_base,
10158c2ecf20Sopenharmony_ci					    void __iomem *pmc_base)
10168c2ecf20Sopenharmony_ci{
10178c2ecf20Sopenharmony_ci	struct clk *clk;
10188c2ecf20Sopenharmony_ci	struct tegra_periph_init_data *data;
10198c2ecf20Sopenharmony_ci	unsigned int i;
10208c2ecf20Sopenharmony_ci
10218c2ecf20Sopenharmony_ci	/* xusb_ss_div2 */
10228c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "xusb_ss_div2", "xusb_ss_src", 0,
10238c2ecf20Sopenharmony_ci					1, 2);
10248c2ecf20Sopenharmony_ci	clks[TEGRA114_CLK_XUSB_SS_DIV2] = clk;
10258c2ecf20Sopenharmony_ci
10268c2ecf20Sopenharmony_ci	/* dsia mux */
10278c2ecf20Sopenharmony_ci	clk = clk_register_mux(NULL, "dsia_mux", mux_plld_out0_plld2_out0,
10288c2ecf20Sopenharmony_ci			       ARRAY_SIZE(mux_plld_out0_plld2_out0),
10298c2ecf20Sopenharmony_ci			       CLK_SET_RATE_NO_REPARENT,
10308c2ecf20Sopenharmony_ci			       clk_base + PLLD_BASE, 25, 1, 0, &pll_d_lock);
10318c2ecf20Sopenharmony_ci	clks[TEGRA114_CLK_DSIA_MUX] = clk;
10328c2ecf20Sopenharmony_ci
10338c2ecf20Sopenharmony_ci	/* dsib mux */
10348c2ecf20Sopenharmony_ci	clk = clk_register_mux(NULL, "dsib_mux", mux_plld_out0_plld2_out0,
10358c2ecf20Sopenharmony_ci			       ARRAY_SIZE(mux_plld_out0_plld2_out0),
10368c2ecf20Sopenharmony_ci			       CLK_SET_RATE_NO_REPARENT,
10378c2ecf20Sopenharmony_ci			       clk_base + PLLD2_BASE, 25, 1, 0, &pll_d2_lock);
10388c2ecf20Sopenharmony_ci	clks[TEGRA114_CLK_DSIB_MUX] = clk;
10398c2ecf20Sopenharmony_ci
10408c2ecf20Sopenharmony_ci	clk = tegra_clk_register_periph_gate("dsia", "dsia_mux", 0, clk_base,
10418c2ecf20Sopenharmony_ci					     0, 48, periph_clk_enb_refcnt);
10428c2ecf20Sopenharmony_ci	clks[TEGRA114_CLK_DSIA] = clk;
10438c2ecf20Sopenharmony_ci
10448c2ecf20Sopenharmony_ci	clk = tegra_clk_register_periph_gate("dsib", "dsib_mux", 0, clk_base,
10458c2ecf20Sopenharmony_ci					     0, 82, periph_clk_enb_refcnt);
10468c2ecf20Sopenharmony_ci	clks[TEGRA114_CLK_DSIB] = clk;
10478c2ecf20Sopenharmony_ci
10488c2ecf20Sopenharmony_ci	/* emc mux */
10498c2ecf20Sopenharmony_ci	clk = clk_register_mux(NULL, "emc_mux", mux_pllmcp_clkm,
10508c2ecf20Sopenharmony_ci			       ARRAY_SIZE(mux_pllmcp_clkm),
10518c2ecf20Sopenharmony_ci			       CLK_SET_RATE_NO_REPARENT,
10528c2ecf20Sopenharmony_ci			       clk_base + CLK_SOURCE_EMC,
10538c2ecf20Sopenharmony_ci			       29, 3, 0, &emc_lock);
10548c2ecf20Sopenharmony_ci
10558c2ecf20Sopenharmony_ci	clk = tegra_clk_register_mc("mc", "emc_mux", clk_base + CLK_SOURCE_EMC,
10568c2ecf20Sopenharmony_ci				    &emc_lock);
10578c2ecf20Sopenharmony_ci	clks[TEGRA114_CLK_MC] = clk;
10588c2ecf20Sopenharmony_ci
10598c2ecf20Sopenharmony_ci	clk = tegra_clk_register_periph_gate("mipi-cal", "clk_m", 0, clk_base,
10608c2ecf20Sopenharmony_ci					     CLK_SET_RATE_PARENT, 56,
10618c2ecf20Sopenharmony_ci					     periph_clk_enb_refcnt);
10628c2ecf20Sopenharmony_ci	clks[TEGRA114_CLK_MIPI_CAL] = clk;
10638c2ecf20Sopenharmony_ci
10648c2ecf20Sopenharmony_ci	for (i = 0; i < ARRAY_SIZE(tegra_periph_clk_list); i++) {
10658c2ecf20Sopenharmony_ci		data = &tegra_periph_clk_list[i];
10668c2ecf20Sopenharmony_ci		clk = tegra_clk_register_periph_data(clk_base, data);
10678c2ecf20Sopenharmony_ci		clks[data->clk_id] = clk;
10688c2ecf20Sopenharmony_ci	}
10698c2ecf20Sopenharmony_ci
10708c2ecf20Sopenharmony_ci	tegra_periph_clk_init(clk_base, pmc_base, tegra114_clks,
10718c2ecf20Sopenharmony_ci				&pll_p_params);
10728c2ecf20Sopenharmony_ci}
10738c2ecf20Sopenharmony_ci
10748c2ecf20Sopenharmony_ci/* Tegra114 CPU clock and reset control functions */
10758c2ecf20Sopenharmony_cistatic void tegra114_wait_cpu_in_reset(u32 cpu)
10768c2ecf20Sopenharmony_ci{
10778c2ecf20Sopenharmony_ci	unsigned int reg;
10788c2ecf20Sopenharmony_ci
10798c2ecf20Sopenharmony_ci	do {
10808c2ecf20Sopenharmony_ci		reg = readl(clk_base + CLK_RST_CONTROLLER_CPU_CMPLX_STATUS);
10818c2ecf20Sopenharmony_ci		cpu_relax();
10828c2ecf20Sopenharmony_ci	} while (!(reg & (1 << cpu)));  /* check CPU been reset or not */
10838c2ecf20Sopenharmony_ci}
10848c2ecf20Sopenharmony_ci
10858c2ecf20Sopenharmony_cistatic void tegra114_disable_cpu_clock(u32 cpu)
10868c2ecf20Sopenharmony_ci{
10878c2ecf20Sopenharmony_ci	/* flow controller would take care in the power sequence. */
10888c2ecf20Sopenharmony_ci}
10898c2ecf20Sopenharmony_ci
10908c2ecf20Sopenharmony_ci#ifdef CONFIG_PM_SLEEP
10918c2ecf20Sopenharmony_cistatic void tegra114_cpu_clock_suspend(void)
10928c2ecf20Sopenharmony_ci{
10938c2ecf20Sopenharmony_ci	/* switch coresite to clk_m, save off original source */
10948c2ecf20Sopenharmony_ci	tegra114_cpu_clk_sctx.clk_csite_src =
10958c2ecf20Sopenharmony_ci				readl(clk_base + CLK_SOURCE_CSITE);
10968c2ecf20Sopenharmony_ci	writel(3 << 30, clk_base + CLK_SOURCE_CSITE);
10978c2ecf20Sopenharmony_ci
10988c2ecf20Sopenharmony_ci	tegra114_cpu_clk_sctx.cclkg_burst =
10998c2ecf20Sopenharmony_ci				readl(clk_base + CCLKG_BURST_POLICY);
11008c2ecf20Sopenharmony_ci	tegra114_cpu_clk_sctx.cclkg_divider =
11018c2ecf20Sopenharmony_ci				readl(clk_base + CCLKG_BURST_POLICY + 4);
11028c2ecf20Sopenharmony_ci}
11038c2ecf20Sopenharmony_ci
11048c2ecf20Sopenharmony_cistatic void tegra114_cpu_clock_resume(void)
11058c2ecf20Sopenharmony_ci{
11068c2ecf20Sopenharmony_ci	writel(tegra114_cpu_clk_sctx.clk_csite_src,
11078c2ecf20Sopenharmony_ci					clk_base + CLK_SOURCE_CSITE);
11088c2ecf20Sopenharmony_ci
11098c2ecf20Sopenharmony_ci	writel(tegra114_cpu_clk_sctx.cclkg_burst,
11108c2ecf20Sopenharmony_ci					clk_base + CCLKG_BURST_POLICY);
11118c2ecf20Sopenharmony_ci	writel(tegra114_cpu_clk_sctx.cclkg_divider,
11128c2ecf20Sopenharmony_ci					clk_base + CCLKG_BURST_POLICY + 4);
11138c2ecf20Sopenharmony_ci}
11148c2ecf20Sopenharmony_ci#endif
11158c2ecf20Sopenharmony_ci
11168c2ecf20Sopenharmony_cistatic struct tegra_cpu_car_ops tegra114_cpu_car_ops = {
11178c2ecf20Sopenharmony_ci	.wait_for_reset	= tegra114_wait_cpu_in_reset,
11188c2ecf20Sopenharmony_ci	.disable_clock	= tegra114_disable_cpu_clock,
11198c2ecf20Sopenharmony_ci#ifdef CONFIG_PM_SLEEP
11208c2ecf20Sopenharmony_ci	.suspend	= tegra114_cpu_clock_suspend,
11218c2ecf20Sopenharmony_ci	.resume		= tegra114_cpu_clock_resume,
11228c2ecf20Sopenharmony_ci#endif
11238c2ecf20Sopenharmony_ci};
11248c2ecf20Sopenharmony_ci
11258c2ecf20Sopenharmony_cistatic const struct of_device_id pmc_match[] __initconst = {
11268c2ecf20Sopenharmony_ci	{ .compatible = "nvidia,tegra114-pmc" },
11278c2ecf20Sopenharmony_ci	{ },
11288c2ecf20Sopenharmony_ci};
11298c2ecf20Sopenharmony_ci
11308c2ecf20Sopenharmony_ci/*
11318c2ecf20Sopenharmony_ci * dfll_soc/dfll_ref apparently must be kept enabled, otherwise I2C5
11328c2ecf20Sopenharmony_ci * breaks
11338c2ecf20Sopenharmony_ci */
11348c2ecf20Sopenharmony_cistatic struct tegra_clk_init_table init_table[] __initdata = {
11358c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_UARTA, TEGRA114_CLK_PLL_P, 408000000, 0 },
11368c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_UARTB, TEGRA114_CLK_PLL_P, 408000000, 0 },
11378c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_UARTC, TEGRA114_CLK_PLL_P, 408000000, 0 },
11388c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_UARTD, TEGRA114_CLK_PLL_P, 408000000, 0 },
11398c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_PLL_A, TEGRA114_CLK_CLK_MAX, 564480000, 0 },
11408c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_PLL_A_OUT0, TEGRA114_CLK_CLK_MAX, 11289600, 0 },
11418c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_I2S0, TEGRA114_CLK_PLL_A_OUT0, 11289600, 0 },
11428c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_I2S1, TEGRA114_CLK_PLL_A_OUT0, 11289600, 0 },
11438c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_I2S2, TEGRA114_CLK_PLL_A_OUT0, 11289600, 0 },
11448c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_I2S3, TEGRA114_CLK_PLL_A_OUT0, 11289600, 0 },
11458c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_I2S4, TEGRA114_CLK_PLL_A_OUT0, 11289600, 0 },
11468c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_HOST1X, TEGRA114_CLK_PLL_P, 136000000, 0 },
11478c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_DFLL_SOC, TEGRA114_CLK_PLL_P, 51000000, 1 },
11488c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_DFLL_REF, TEGRA114_CLK_PLL_P, 51000000, 1 },
11498c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_DISP1, TEGRA114_CLK_PLL_P, 0, 0 },
11508c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_DISP2, TEGRA114_CLK_PLL_P, 0, 0 },
11518c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_GR2D, TEGRA114_CLK_PLL_C2, 300000000, 0 },
11528c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_GR3D, TEGRA114_CLK_PLL_C2, 300000000, 0 },
11538c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_DSIALP, TEGRA114_CLK_PLL_P, 68000000, 0 },
11548c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_DSIBLP, TEGRA114_CLK_PLL_P, 68000000, 0 },
11558c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_PLL_RE_VCO, TEGRA114_CLK_CLK_MAX, 612000000, 0 },
11568c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_XUSB_SS_SRC, TEGRA114_CLK_PLL_RE_OUT, 122400000, 0 },
11578c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_XUSB_FS_SRC, TEGRA114_CLK_PLL_U_48M, 48000000, 0 },
11588c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_XUSB_HS_SRC, TEGRA114_CLK_XUSB_SS_DIV2, 61200000, 0 },
11598c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_XUSB_FALCON_SRC, TEGRA114_CLK_PLL_P, 204000000, 0 },
11608c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_XUSB_HOST_SRC, TEGRA114_CLK_PLL_P, 102000000, 0 },
11618c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_VDE, TEGRA114_CLK_CLK_MAX, 600000000, 0 },
11628c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_SPDIF_IN_SYNC, TEGRA114_CLK_CLK_MAX, 24000000, 0 },
11638c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_I2S0_SYNC, TEGRA114_CLK_CLK_MAX, 24000000, 0 },
11648c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_I2S1_SYNC, TEGRA114_CLK_CLK_MAX, 24000000, 0 },
11658c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_I2S2_SYNC, TEGRA114_CLK_CLK_MAX, 24000000, 0 },
11668c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_I2S3_SYNC, TEGRA114_CLK_CLK_MAX, 24000000, 0 },
11678c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_I2S4_SYNC, TEGRA114_CLK_CLK_MAX, 24000000, 0 },
11688c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_VIMCLK_SYNC, TEGRA114_CLK_CLK_MAX, 24000000, 0 },
11698c2ecf20Sopenharmony_ci	/* must be the last entry */
11708c2ecf20Sopenharmony_ci	{ TEGRA114_CLK_CLK_MAX, TEGRA114_CLK_CLK_MAX, 0, 0 },
11718c2ecf20Sopenharmony_ci};
11728c2ecf20Sopenharmony_ci
11738c2ecf20Sopenharmony_cistatic void __init tegra114_clock_apply_init_table(void)
11748c2ecf20Sopenharmony_ci{
11758c2ecf20Sopenharmony_ci	tegra_init_from_table(init_table, clks, TEGRA114_CLK_CLK_MAX);
11768c2ecf20Sopenharmony_ci}
11778c2ecf20Sopenharmony_ci
11788c2ecf20Sopenharmony_ci/**
11798c2ecf20Sopenharmony_ci * tegra114_car_barrier - wait for pending writes to the CAR to complete
11808c2ecf20Sopenharmony_ci *
11818c2ecf20Sopenharmony_ci * Wait for any outstanding writes to the CAR MMIO space from this CPU
11828c2ecf20Sopenharmony_ci * to complete before continuing execution.  No return value.
11838c2ecf20Sopenharmony_ci */
11848c2ecf20Sopenharmony_cistatic void tegra114_car_barrier(void)
11858c2ecf20Sopenharmony_ci{
11868c2ecf20Sopenharmony_ci	wmb();		/* probably unnecessary */
11878c2ecf20Sopenharmony_ci	readl_relaxed(clk_base + CPU_FINETRIM_SELECT);
11888c2ecf20Sopenharmony_ci}
11898c2ecf20Sopenharmony_ci
11908c2ecf20Sopenharmony_ci/**
11918c2ecf20Sopenharmony_ci * tegra114_clock_tune_cpu_trimmers_high - use high-voltage propagation delays
11928c2ecf20Sopenharmony_ci *
11938c2ecf20Sopenharmony_ci * When the CPU rail voltage is in the high-voltage range, use the
11948c2ecf20Sopenharmony_ci * built-in hardwired clock propagation delays in the CPU clock
11958c2ecf20Sopenharmony_ci * shaper.  No return value.
11968c2ecf20Sopenharmony_ci */
11978c2ecf20Sopenharmony_civoid tegra114_clock_tune_cpu_trimmers_high(void)
11988c2ecf20Sopenharmony_ci{
11998c2ecf20Sopenharmony_ci	u32 select = 0;
12008c2ecf20Sopenharmony_ci
12018c2ecf20Sopenharmony_ci	/* Use hardwired rise->rise & fall->fall clock propagation delays */
12028c2ecf20Sopenharmony_ci	select |= ~(CPU_FINETRIM_1_FCPU_1 | CPU_FINETRIM_1_FCPU_2 |
12038c2ecf20Sopenharmony_ci		    CPU_FINETRIM_1_FCPU_3 | CPU_FINETRIM_1_FCPU_4 |
12048c2ecf20Sopenharmony_ci		    CPU_FINETRIM_1_FCPU_5 | CPU_FINETRIM_1_FCPU_6);
12058c2ecf20Sopenharmony_ci	writel_relaxed(select, clk_base + CPU_FINETRIM_SELECT);
12068c2ecf20Sopenharmony_ci
12078c2ecf20Sopenharmony_ci	tegra114_car_barrier();
12088c2ecf20Sopenharmony_ci}
12098c2ecf20Sopenharmony_ciEXPORT_SYMBOL(tegra114_clock_tune_cpu_trimmers_high);
12108c2ecf20Sopenharmony_ci
12118c2ecf20Sopenharmony_ci/**
12128c2ecf20Sopenharmony_ci * tegra114_clock_tune_cpu_trimmers_low - use low-voltage propagation delays
12138c2ecf20Sopenharmony_ci *
12148c2ecf20Sopenharmony_ci * When the CPU rail voltage is in the low-voltage range, use the
12158c2ecf20Sopenharmony_ci * extended clock propagation delays set by
12168c2ecf20Sopenharmony_ci * tegra114_clock_tune_cpu_trimmers_init().  The intention is to
12178c2ecf20Sopenharmony_ci * maintain the input clock duty cycle that the FCPU subsystem
12188c2ecf20Sopenharmony_ci * expects.  No return value.
12198c2ecf20Sopenharmony_ci */
12208c2ecf20Sopenharmony_civoid tegra114_clock_tune_cpu_trimmers_low(void)
12218c2ecf20Sopenharmony_ci{
12228c2ecf20Sopenharmony_ci	u32 select = 0;
12238c2ecf20Sopenharmony_ci
12248c2ecf20Sopenharmony_ci	/*
12258c2ecf20Sopenharmony_ci	 * Use software-specified rise->rise & fall->fall clock
12268c2ecf20Sopenharmony_ci	 * propagation delays (from
12278c2ecf20Sopenharmony_ci	 * tegra114_clock_tune_cpu_trimmers_init()
12288c2ecf20Sopenharmony_ci	 */
12298c2ecf20Sopenharmony_ci	select |= (CPU_FINETRIM_1_FCPU_1 | CPU_FINETRIM_1_FCPU_2 |
12308c2ecf20Sopenharmony_ci		   CPU_FINETRIM_1_FCPU_3 | CPU_FINETRIM_1_FCPU_4 |
12318c2ecf20Sopenharmony_ci		   CPU_FINETRIM_1_FCPU_5 | CPU_FINETRIM_1_FCPU_6);
12328c2ecf20Sopenharmony_ci	writel_relaxed(select, clk_base + CPU_FINETRIM_SELECT);
12338c2ecf20Sopenharmony_ci
12348c2ecf20Sopenharmony_ci	tegra114_car_barrier();
12358c2ecf20Sopenharmony_ci}
12368c2ecf20Sopenharmony_ciEXPORT_SYMBOL(tegra114_clock_tune_cpu_trimmers_low);
12378c2ecf20Sopenharmony_ci
12388c2ecf20Sopenharmony_ci/**
12398c2ecf20Sopenharmony_ci * tegra114_clock_tune_cpu_trimmers_init - set up and enable clk prop delays
12408c2ecf20Sopenharmony_ci *
12418c2ecf20Sopenharmony_ci * Program extended clock propagation delays into the FCPU clock
12428c2ecf20Sopenharmony_ci * shaper and enable them.  XXX Define the purpose - peak current
12438c2ecf20Sopenharmony_ci * reduction?  No return value.
12448c2ecf20Sopenharmony_ci */
12458c2ecf20Sopenharmony_ci/* XXX Initial voltage rail state assumption issues? */
12468c2ecf20Sopenharmony_civoid tegra114_clock_tune_cpu_trimmers_init(void)
12478c2ecf20Sopenharmony_ci{
12488c2ecf20Sopenharmony_ci	u32 dr = 0, r = 0;
12498c2ecf20Sopenharmony_ci
12508c2ecf20Sopenharmony_ci	/* Increment the rise->rise clock delay by four steps */
12518c2ecf20Sopenharmony_ci	r |= (CPU_FINETRIM_R_FCPU_1_MASK | CPU_FINETRIM_R_FCPU_2_MASK |
12528c2ecf20Sopenharmony_ci	      CPU_FINETRIM_R_FCPU_3_MASK | CPU_FINETRIM_R_FCPU_4_MASK |
12538c2ecf20Sopenharmony_ci	      CPU_FINETRIM_R_FCPU_5_MASK | CPU_FINETRIM_R_FCPU_6_MASK);
12548c2ecf20Sopenharmony_ci	writel_relaxed(r, clk_base + CPU_FINETRIM_R);
12558c2ecf20Sopenharmony_ci
12568c2ecf20Sopenharmony_ci	/*
12578c2ecf20Sopenharmony_ci	 * Use the rise->rise clock propagation delay specified in the
12588c2ecf20Sopenharmony_ci	 * r field
12598c2ecf20Sopenharmony_ci	 */
12608c2ecf20Sopenharmony_ci	dr |= (CPU_FINETRIM_1_FCPU_1 | CPU_FINETRIM_1_FCPU_2 |
12618c2ecf20Sopenharmony_ci	       CPU_FINETRIM_1_FCPU_3 | CPU_FINETRIM_1_FCPU_4 |
12628c2ecf20Sopenharmony_ci	       CPU_FINETRIM_1_FCPU_5 | CPU_FINETRIM_1_FCPU_6);
12638c2ecf20Sopenharmony_ci	writel_relaxed(dr, clk_base + CPU_FINETRIM_DR);
12648c2ecf20Sopenharmony_ci
12658c2ecf20Sopenharmony_ci	tegra114_clock_tune_cpu_trimmers_low();
12668c2ecf20Sopenharmony_ci}
12678c2ecf20Sopenharmony_ciEXPORT_SYMBOL(tegra114_clock_tune_cpu_trimmers_init);
12688c2ecf20Sopenharmony_ci
12698c2ecf20Sopenharmony_ci/**
12708c2ecf20Sopenharmony_ci * tegra114_clock_assert_dfll_dvco_reset - assert the DFLL's DVCO reset
12718c2ecf20Sopenharmony_ci *
12728c2ecf20Sopenharmony_ci * Assert the reset line of the DFLL's DVCO.  No return value.
12738c2ecf20Sopenharmony_ci */
12748c2ecf20Sopenharmony_civoid tegra114_clock_assert_dfll_dvco_reset(void)
12758c2ecf20Sopenharmony_ci{
12768c2ecf20Sopenharmony_ci	u32 v;
12778c2ecf20Sopenharmony_ci
12788c2ecf20Sopenharmony_ci	v = readl_relaxed(clk_base + RST_DFLL_DVCO);
12798c2ecf20Sopenharmony_ci	v |= (1 << DVFS_DFLL_RESET_SHIFT);
12808c2ecf20Sopenharmony_ci	writel_relaxed(v, clk_base + RST_DFLL_DVCO);
12818c2ecf20Sopenharmony_ci	tegra114_car_barrier();
12828c2ecf20Sopenharmony_ci}
12838c2ecf20Sopenharmony_ciEXPORT_SYMBOL(tegra114_clock_assert_dfll_dvco_reset);
12848c2ecf20Sopenharmony_ci
12858c2ecf20Sopenharmony_ci/**
12868c2ecf20Sopenharmony_ci * tegra114_clock_deassert_dfll_dvco_reset - deassert the DFLL's DVCO reset
12878c2ecf20Sopenharmony_ci *
12888c2ecf20Sopenharmony_ci * Deassert the reset line of the DFLL's DVCO, allowing the DVCO to
12898c2ecf20Sopenharmony_ci * operate.  No return value.
12908c2ecf20Sopenharmony_ci */
12918c2ecf20Sopenharmony_civoid tegra114_clock_deassert_dfll_dvco_reset(void)
12928c2ecf20Sopenharmony_ci{
12938c2ecf20Sopenharmony_ci	u32 v;
12948c2ecf20Sopenharmony_ci
12958c2ecf20Sopenharmony_ci	v = readl_relaxed(clk_base + RST_DFLL_DVCO);
12968c2ecf20Sopenharmony_ci	v &= ~(1 << DVFS_DFLL_RESET_SHIFT);
12978c2ecf20Sopenharmony_ci	writel_relaxed(v, clk_base + RST_DFLL_DVCO);
12988c2ecf20Sopenharmony_ci	tegra114_car_barrier();
12998c2ecf20Sopenharmony_ci}
13008c2ecf20Sopenharmony_ciEXPORT_SYMBOL(tegra114_clock_deassert_dfll_dvco_reset);
13018c2ecf20Sopenharmony_ci
13028c2ecf20Sopenharmony_cistatic void __init tegra114_clock_init(struct device_node *np)
13038c2ecf20Sopenharmony_ci{
13048c2ecf20Sopenharmony_ci	struct device_node *node;
13058c2ecf20Sopenharmony_ci
13068c2ecf20Sopenharmony_ci	clk_base = of_iomap(np, 0);
13078c2ecf20Sopenharmony_ci	if (!clk_base) {
13088c2ecf20Sopenharmony_ci		pr_err("ioremap tegra114 CAR failed\n");
13098c2ecf20Sopenharmony_ci		return;
13108c2ecf20Sopenharmony_ci	}
13118c2ecf20Sopenharmony_ci
13128c2ecf20Sopenharmony_ci	node = of_find_matching_node(NULL, pmc_match);
13138c2ecf20Sopenharmony_ci	if (!node) {
13148c2ecf20Sopenharmony_ci		pr_err("Failed to find pmc node\n");
13158c2ecf20Sopenharmony_ci		WARN_ON(1);
13168c2ecf20Sopenharmony_ci		return;
13178c2ecf20Sopenharmony_ci	}
13188c2ecf20Sopenharmony_ci
13198c2ecf20Sopenharmony_ci	pmc_base = of_iomap(node, 0);
13208c2ecf20Sopenharmony_ci	of_node_put(node);
13218c2ecf20Sopenharmony_ci	if (!pmc_base) {
13228c2ecf20Sopenharmony_ci		pr_err("Can't map pmc registers\n");
13238c2ecf20Sopenharmony_ci		WARN_ON(1);
13248c2ecf20Sopenharmony_ci		return;
13258c2ecf20Sopenharmony_ci	}
13268c2ecf20Sopenharmony_ci
13278c2ecf20Sopenharmony_ci	clks = tegra_clk_init(clk_base, TEGRA114_CLK_CLK_MAX,
13288c2ecf20Sopenharmony_ci				TEGRA114_CLK_PERIPH_BANKS);
13298c2ecf20Sopenharmony_ci	if (!clks)
13308c2ecf20Sopenharmony_ci		return;
13318c2ecf20Sopenharmony_ci
13328c2ecf20Sopenharmony_ci	if (tegra_osc_clk_init(clk_base, tegra114_clks, tegra114_input_freq,
13338c2ecf20Sopenharmony_ci			       ARRAY_SIZE(tegra114_input_freq), 1, &osc_freq,
13348c2ecf20Sopenharmony_ci			       &pll_ref_freq) < 0)
13358c2ecf20Sopenharmony_ci		return;
13368c2ecf20Sopenharmony_ci
13378c2ecf20Sopenharmony_ci	tegra114_fixed_clk_init(clk_base);
13388c2ecf20Sopenharmony_ci	tegra114_pll_init(clk_base, pmc_base);
13398c2ecf20Sopenharmony_ci	tegra114_periph_clk_init(clk_base, pmc_base);
13408c2ecf20Sopenharmony_ci	tegra_audio_clk_init(clk_base, pmc_base, tegra114_clks,
13418c2ecf20Sopenharmony_ci			     tegra114_audio_plls,
13428c2ecf20Sopenharmony_ci			     ARRAY_SIZE(tegra114_audio_plls), 24000000);
13438c2ecf20Sopenharmony_ci	tegra_super_clk_gen4_init(clk_base, pmc_base, tegra114_clks,
13448c2ecf20Sopenharmony_ci					&pll_x_params);
13458c2ecf20Sopenharmony_ci
13468c2ecf20Sopenharmony_ci	tegra_add_of_provider(np, of_clk_src_onecell_get);
13478c2ecf20Sopenharmony_ci	tegra_register_devclks(devclks, ARRAY_SIZE(devclks));
13488c2ecf20Sopenharmony_ci
13498c2ecf20Sopenharmony_ci	tegra_clk_apply_init_table = tegra114_clock_apply_init_table;
13508c2ecf20Sopenharmony_ci
13518c2ecf20Sopenharmony_ci	tegra_cpu_car_ops = &tegra114_cpu_car_ops;
13528c2ecf20Sopenharmony_ci}
13538c2ecf20Sopenharmony_ciCLK_OF_DECLARE(tegra114, "nvidia,tegra114-car", tegra114_clock_init);
1354