xref: /openbmc/linux/drivers/clk/tegra/clk-tegra210.c (revision 98c4b3661b5aee0e583d17d6304f6489c0f41155)
16b301a05SRhyland Klein /*
26b301a05SRhyland Klein  * Copyright (c) 2012-2014 NVIDIA CORPORATION.  All rights reserved.
36b301a05SRhyland Klein  *
46b301a05SRhyland Klein  * This program is free software; you can redistribute it and/or modify it
56b301a05SRhyland Klein  * under the terms and conditions of the GNU General Public License,
66b301a05SRhyland Klein  * version 2, as published by the Free Software Foundation.
76b301a05SRhyland Klein  *
86b301a05SRhyland Klein  * This program is distributed in the hope it will be useful, but WITHOUT
96b301a05SRhyland Klein  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
106b301a05SRhyland Klein  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
116b301a05SRhyland Klein  * more details.
126b301a05SRhyland Klein  *
136b301a05SRhyland Klein  * You should have received a copy of the GNU General Public License
146b301a05SRhyland Klein  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
156b301a05SRhyland Klein  */
166b301a05SRhyland Klein 
176b301a05SRhyland Klein #include <linux/io.h>
186b301a05SRhyland Klein #include <linux/clk.h>
196b301a05SRhyland Klein #include <linux/clk-provider.h>
206b301a05SRhyland Klein #include <linux/clkdev.h>
216b301a05SRhyland Klein #include <linux/of.h>
226b301a05SRhyland Klein #include <linux/of_address.h>
236b301a05SRhyland Klein #include <linux/delay.h>
246b301a05SRhyland Klein #include <linux/export.h>
256b301a05SRhyland Klein #include <linux/clk/tegra.h>
266b301a05SRhyland Klein #include <dt-bindings/clock/tegra210-car.h>
276b301a05SRhyland Klein 
286b301a05SRhyland Klein #include "clk.h"
296b301a05SRhyland Klein #include "clk-id.h"
306b301a05SRhyland Klein 
316b301a05SRhyland Klein /*
326b301a05SRhyland Klein  * TEGRA210_CAR_BANK_COUNT: the number of peripheral clock register
336b301a05SRhyland Klein  * banks present in the Tegra210 CAR IP block.  The banks are
346b301a05SRhyland Klein  * identified by single letters, e.g.: L, H, U, V, W, X, Y.  See
356b301a05SRhyland Klein  * periph_regs[] in drivers/clk/tegra/clk.c
366b301a05SRhyland Klein  */
376b301a05SRhyland Klein #define TEGRA210_CAR_BANK_COUNT			7
386b301a05SRhyland Klein 
396b301a05SRhyland Klein #define CLK_SOURCE_CSITE 0x1d4
406b301a05SRhyland Klein #define CLK_SOURCE_EMC 0x19c
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
956b301a05SRhyland Klein #define PLLDP_BASE 0x590
966b301a05SRhyland Klein #define PLLDP_MISC 0x594
976b301a05SRhyland Klein 
986b301a05SRhyland Klein #define PLLC4_BASE 0x5a4
996b301a05SRhyland Klein #define PLLC4_MISC0 0x5a8
1006b301a05SRhyland Klein #define PLLC4_OUT 0x5e4
1016b301a05SRhyland Klein #define PLLMB_BASE 0x5e8
102474f2ba2SRhyland Klein #define PLLMB_MISC1 0x5ec
1036b301a05SRhyland Klein #define PLLA1_BASE 0x6a4
1046b301a05SRhyland Klein #define PLLA1_MISC0 0x6a8
1056b301a05SRhyland Klein #define PLLA1_MISC1 0x6ac
1066b301a05SRhyland Klein #define PLLA1_MISC2 0x6b0
1076b301a05SRhyland Klein #define PLLA1_MISC3 0x6b4
1086b301a05SRhyland Klein 
1096b301a05SRhyland Klein #define PLLU_IDDQ_BIT 31
1106b301a05SRhyland Klein #define PLLCX_IDDQ_BIT 27
1116b301a05SRhyland Klein #define PLLRE_IDDQ_BIT 24
1126b301a05SRhyland Klein #define PLLA_IDDQ_BIT 25
1136b301a05SRhyland Klein #define PLLD_IDDQ_BIT 20
1146b301a05SRhyland Klein #define PLLSS_IDDQ_BIT 18
1156b301a05SRhyland Klein #define PLLM_IDDQ_BIT 5
1166b301a05SRhyland Klein #define PLLMB_IDDQ_BIT 17
1176b301a05SRhyland Klein #define PLLXP_IDDQ_BIT 3
1186b301a05SRhyland Klein 
1196b301a05SRhyland Klein #define PLLCX_RESET_BIT 30
1206b301a05SRhyland Klein 
1216b301a05SRhyland Klein #define PLL_BASE_LOCK BIT(27)
1226b301a05SRhyland Klein #define PLLCX_BASE_LOCK BIT(26)
1236b301a05SRhyland Klein #define PLLE_MISC_LOCK BIT(11)
1246b301a05SRhyland Klein #define PLLRE_MISC_LOCK BIT(27)
1256b301a05SRhyland Klein 
1266b301a05SRhyland Klein #define PLL_MISC_LOCK_ENABLE 18
1276b301a05SRhyland Klein #define PLLC_MISC_LOCK_ENABLE 24
1286b301a05SRhyland Klein #define PLLDU_MISC_LOCK_ENABLE 22
1296b301a05SRhyland Klein #define PLLU_MISC_LOCK_ENABLE 29
1306b301a05SRhyland Klein #define PLLE_MISC_LOCK_ENABLE 9
1316b301a05SRhyland Klein #define PLLRE_MISC_LOCK_ENABLE 30
1326b301a05SRhyland Klein #define PLLSS_MISC_LOCK_ENABLE 30
1336b301a05SRhyland Klein #define PLLP_MISC_LOCK_ENABLE 18
1346b301a05SRhyland Klein #define PLLM_MISC_LOCK_ENABLE 4
1356b301a05SRhyland Klein #define PLLMB_MISC_LOCK_ENABLE 16
1366b301a05SRhyland Klein #define PLLA_MISC_LOCK_ENABLE 28
1376b301a05SRhyland Klein #define PLLU_MISC_LOCK_ENABLE 29
1386b301a05SRhyland Klein #define PLLD_MISC_LOCK_ENABLE 18
1396b301a05SRhyland Klein 
1406b301a05SRhyland Klein #define PLLA_SDM_DIN_MASK 0xffff
1416b301a05SRhyland Klein #define PLLA_SDM_EN_MASK BIT(26)
1426b301a05SRhyland Klein 
1436b301a05SRhyland Klein #define PLLD_SDM_EN_MASK BIT(16)
1446b301a05SRhyland Klein 
1456b301a05SRhyland Klein #define PLLD2_SDM_EN_MASK BIT(31)
1466b301a05SRhyland Klein #define PLLD2_SSC_EN_MASK BIT(30)
1476b301a05SRhyland Klein 
1486b301a05SRhyland Klein #define PLLDP_SS_CFG	0x598
1496b301a05SRhyland Klein #define PLLDP_SDM_EN_MASK BIT(31)
1506b301a05SRhyland Klein #define PLLDP_SSC_EN_MASK BIT(30)
1516b301a05SRhyland Klein #define PLLDP_SS_CTRL1	0x59c
1526b301a05SRhyland Klein #define PLLDP_SS_CTRL2	0x5a0
1536b301a05SRhyland Klein 
1546b301a05SRhyland Klein #define PMC_PLLM_WB0_OVERRIDE 0x1dc
1556b301a05SRhyland Klein #define PMC_PLLM_WB0_OVERRIDE_2 0x2b0
1566b301a05SRhyland Klein 
1576b301a05SRhyland Klein #define UTMIP_PLL_CFG2 0x488
1586b301a05SRhyland Klein #define UTMIP_PLL_CFG2_STABLE_COUNT(x) (((x) & 0xfff) << 6)
1596b301a05SRhyland Klein #define UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(x) (((x) & 0x3f) << 18)
1606b301a05SRhyland Klein #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_A_POWERDOWN BIT(0)
1616b301a05SRhyland Klein #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_A_POWERUP BIT(1)
1626b301a05SRhyland Klein #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_B_POWERDOWN BIT(2)
1636b301a05SRhyland Klein #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_B_POWERUP BIT(3)
1646b301a05SRhyland Klein #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_C_POWERDOWN BIT(4)
1656b301a05SRhyland Klein #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_C_POWERUP BIT(5)
1666b301a05SRhyland Klein #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_D_POWERDOWN BIT(24)
1676b301a05SRhyland Klein #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_D_POWERUP BIT(25)
1686b301a05SRhyland Klein 
1696b301a05SRhyland Klein #define UTMIP_PLL_CFG1 0x484
1706b301a05SRhyland Klein #define UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(x) (((x) & 0x1f) << 27)
1716b301a05SRhyland Klein #define UTMIP_PLL_CFG1_XTAL_FREQ_COUNT(x) (((x) & 0xfff) << 0)
1726b301a05SRhyland Klein #define UTMIP_PLL_CFG1_FORCE_PLLU_POWERUP BIT(17)
1736b301a05SRhyland Klein #define UTMIP_PLL_CFG1_FORCE_PLLU_POWERDOWN BIT(16)
1746b301a05SRhyland Klein #define UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERUP BIT(15)
1756b301a05SRhyland Klein #define UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERDOWN BIT(14)
1766b301a05SRhyland Klein #define UTMIP_PLL_CFG1_FORCE_PLL_ACTIVE_POWERDOWN BIT(12)
1776b301a05SRhyland Klein 
1783358d2d9SAndrew Bresticker #define SATA_PLL_CFG0				0x490
1793358d2d9SAndrew Bresticker #define SATA_PLL_CFG0_PADPLL_RESET_SWCTL	BIT(0)
1803358d2d9SAndrew Bresticker #define SATA_PLL_CFG0_PADPLL_USE_LOCKDET	BIT(2)
1813358d2d9SAndrew Bresticker #define SATA_PLL_CFG0_PADPLL_SLEEP_IDDQ		BIT(13)
1823358d2d9SAndrew Bresticker #define SATA_PLL_CFG0_SEQ_ENABLE		BIT(24)
1833358d2d9SAndrew Bresticker 
1843358d2d9SAndrew Bresticker #define XUSBIO_PLL_CFG0				0x51c
1853358d2d9SAndrew Bresticker #define XUSBIO_PLL_CFG0_PADPLL_RESET_SWCTL	BIT(0)
1863358d2d9SAndrew Bresticker #define XUSBIO_PLL_CFG0_CLK_ENABLE_SWCTL	BIT(2)
1873358d2d9SAndrew Bresticker #define XUSBIO_PLL_CFG0_PADPLL_USE_LOCKDET	BIT(6)
1883358d2d9SAndrew Bresticker #define XUSBIO_PLL_CFG0_PADPLL_SLEEP_IDDQ	BIT(13)
1893358d2d9SAndrew Bresticker #define XUSBIO_PLL_CFG0_SEQ_ENABLE		BIT(24)
1903358d2d9SAndrew Bresticker 
1916b301a05SRhyland Klein #define UTMIPLL_HW_PWRDN_CFG0			0x52c
1926b301a05SRhyland Klein #define UTMIPLL_HW_PWRDN_CFG0_UTMIPLL_LOCK	BIT(31)
1936b301a05SRhyland Klein #define UTMIPLL_HW_PWRDN_CFG0_SEQ_START_STATE	BIT(25)
1946b301a05SRhyland Klein #define UTMIPLL_HW_PWRDN_CFG0_SEQ_ENABLE	BIT(24)
1956b301a05SRhyland Klein #define UTMIPLL_HW_PWRDN_CFG0_IDDQ_PD_INCLUDE	BIT(7)
1966b301a05SRhyland Klein #define UTMIPLL_HW_PWRDN_CFG0_USE_LOCKDET	BIT(6)
1976b301a05SRhyland Klein #define UTMIPLL_HW_PWRDN_CFG0_SEQ_RESET_INPUT_VALUE	BIT(5)
1986b301a05SRhyland Klein #define UTMIPLL_HW_PWRDN_CFG0_SEQ_IN_SWCTL	BIT(4)
1996b301a05SRhyland Klein #define UTMIPLL_HW_PWRDN_CFG0_CLK_ENABLE_SWCTL	BIT(2)
2006b301a05SRhyland Klein #define UTMIPLL_HW_PWRDN_CFG0_IDDQ_OVERRIDE	BIT(1)
2016b301a05SRhyland Klein #define UTMIPLL_HW_PWRDN_CFG0_IDDQ_SWCTL	BIT(0)
2026b301a05SRhyland Klein 
2036b301a05SRhyland Klein #define PLLU_HW_PWRDN_CFG0			0x530
2046b301a05SRhyland Klein #define PLLU_HW_PWRDN_CFG0_IDDQ_PD_INCLUDE	BIT(28)
2056b301a05SRhyland Klein #define PLLU_HW_PWRDN_CFG0_SEQ_ENABLE		BIT(24)
2066b301a05SRhyland Klein #define PLLU_HW_PWRDN_CFG0_USE_SWITCH_DETECT	BIT(7)
2076b301a05SRhyland Klein #define PLLU_HW_PWRDN_CFG0_USE_LOCKDET		BIT(6)
2086b301a05SRhyland Klein #define PLLU_HW_PWRDN_CFG0_CLK_ENABLE_SWCTL	BIT(2)
2096b301a05SRhyland Klein #define PLLU_HW_PWRDN_CFG0_CLK_SWITCH_SWCTL	BIT(0)
2106b301a05SRhyland Klein 
2116b301a05SRhyland Klein #define XUSB_PLL_CFG0				0x534
2126b301a05SRhyland Klein #define XUSB_PLL_CFG0_UTMIPLL_LOCK_DLY		0x3ff
2136b301a05SRhyland Klein #define XUSB_PLL_CFG0_PLLU_LOCK_DLY_MASK	(0x3ff << 14)
2146b301a05SRhyland Klein 
2156b301a05SRhyland Klein #define SPARE_REG0 0x55c
2166b301a05SRhyland Klein #define CLK_M_DIVISOR_SHIFT 2
2176b301a05SRhyland Klein #define CLK_M_DIVISOR_MASK 0x3
2186b301a05SRhyland Klein 
2196b301a05SRhyland Klein /*
2206b301a05SRhyland Klein  * SDM fractional divisor is 16-bit 2's complement signed number within
2216b301a05SRhyland Klein  * (-2^12 ... 2^12-1) range. Represented in PLL data structure as unsigned
2226b301a05SRhyland Klein  * 16-bit value, with "0" divisor mapped to 0xFFFF. Data "0" is used to
2236b301a05SRhyland Klein  * indicate that SDM is disabled.
2246b301a05SRhyland Klein  *
2256b301a05SRhyland Klein  * Effective ndiv value when SDM is enabled: ndiv + 1/2 + sdm_din/2^13
2266b301a05SRhyland Klein  */
2276b301a05SRhyland Klein #define PLL_SDM_COEFF BIT(13)
2286b301a05SRhyland Klein #define sdin_din_to_data(din)	((u16)((din) ? : 0xFFFFU))
2296b301a05SRhyland Klein #define sdin_data_to_din(dat)	(((dat) == 0xFFFFU) ? 0 : (s16)dat)
2306b301a05SRhyland Klein 
2316b301a05SRhyland Klein /* Tegra CPU clock and reset control regs */
2326b301a05SRhyland Klein #define CLK_RST_CONTROLLER_CPU_CMPLX_STATUS	0x470
2336b301a05SRhyland Klein 
2346b301a05SRhyland Klein #ifdef CONFIG_PM_SLEEP
2356b301a05SRhyland Klein static struct cpu_clk_suspend_context {
2366b301a05SRhyland Klein 	u32 clk_csite_src;
2376b301a05SRhyland Klein } tegra210_cpu_clk_sctx;
2386b301a05SRhyland Klein #endif
2396b301a05SRhyland Klein 
2406b301a05SRhyland Klein static void __iomem *clk_base;
2416b301a05SRhyland Klein static void __iomem *pmc_base;
2426b301a05SRhyland Klein 
2436b301a05SRhyland Klein static unsigned long osc_freq;
2446b301a05SRhyland Klein static unsigned long pll_ref_freq;
2456b301a05SRhyland Klein 
2466b301a05SRhyland Klein static DEFINE_SPINLOCK(pll_d_lock);
2476b301a05SRhyland Klein static DEFINE_SPINLOCK(pll_e_lock);
2486b301a05SRhyland Klein static DEFINE_SPINLOCK(pll_re_lock);
2496b301a05SRhyland Klein static DEFINE_SPINLOCK(pll_u_lock);
2506b301a05SRhyland Klein static DEFINE_SPINLOCK(emc_lock);
2516b301a05SRhyland Klein 
2526b301a05SRhyland Klein /* possible OSC frequencies in Hz */
2536b301a05SRhyland Klein static unsigned long tegra210_input_freq[] = {
2546b301a05SRhyland Klein 	[5] = 38400000,
2556b301a05SRhyland Klein 	[8] = 12000000,
2566b301a05SRhyland Klein };
2576b301a05SRhyland Klein 
2586b301a05SRhyland Klein static const char *mux_pllmcp_clkm[] = {
2594f8d4440SJon Hunter 	"pll_m", "pll_c", "pll_p", "clk_m", "pll_m_ud", "pll_mb", "pll_mb",
2604f8d4440SJon Hunter 	"pll_p",
2616b301a05SRhyland Klein };
2626b301a05SRhyland Klein #define mux_pllmcp_clkm_idx NULL
2636b301a05SRhyland Klein 
2646b301a05SRhyland Klein #define PLL_ENABLE			(1 << 30)
2656b301a05SRhyland Klein 
2666b301a05SRhyland Klein #define PLLCX_MISC1_IDDQ		(1 << 27)
2676b301a05SRhyland Klein #define PLLCX_MISC0_RESET		(1 << 30)
2686b301a05SRhyland Klein 
2696b301a05SRhyland Klein #define PLLCX_MISC0_DEFAULT_VALUE	0x40080000
2706b301a05SRhyland Klein #define PLLCX_MISC0_WRITE_MASK		0x400ffffb
2716b301a05SRhyland Klein #define PLLCX_MISC1_DEFAULT_VALUE	0x08000000
2726b301a05SRhyland Klein #define PLLCX_MISC1_WRITE_MASK		0x08003cff
2736b301a05SRhyland Klein #define PLLCX_MISC2_DEFAULT_VALUE	0x1f720f05
2746b301a05SRhyland Klein #define PLLCX_MISC2_WRITE_MASK		0xffffff17
2756b301a05SRhyland Klein #define PLLCX_MISC3_DEFAULT_VALUE	0x000000c4
2766b301a05SRhyland Klein #define PLLCX_MISC3_WRITE_MASK		0x00ffffff
2776b301a05SRhyland Klein 
2786b301a05SRhyland Klein /* PLLA */
2796b301a05SRhyland Klein #define PLLA_BASE_IDDQ			(1 << 25)
2806b301a05SRhyland Klein #define PLLA_BASE_LOCK			(1 << 27)
2816b301a05SRhyland Klein 
2826b301a05SRhyland Klein #define PLLA_MISC0_LOCK_ENABLE		(1 << 28)
2836b301a05SRhyland Klein #define PLLA_MISC0_LOCK_OVERRIDE	(1 << 27)
2846b301a05SRhyland Klein 
2856b301a05SRhyland Klein #define PLLA_MISC2_EN_SDM		(1 << 26)
2866b301a05SRhyland Klein #define PLLA_MISC2_EN_DYNRAMP		(1 << 25)
2876b301a05SRhyland Klein 
2886b301a05SRhyland Klein #define PLLA_MISC0_DEFAULT_VALUE	0x12000020
2896b301a05SRhyland Klein #define PLLA_MISC0_WRITE_MASK		0x7fffffff
2906b301a05SRhyland Klein #define PLLA_MISC2_DEFAULT_VALUE	0x0
2916b301a05SRhyland Klein #define PLLA_MISC2_WRITE_MASK		0x06ffffff
2926b301a05SRhyland Klein 
2936b301a05SRhyland Klein /* PLLD */
2946b301a05SRhyland Klein #define PLLD_MISC0_EN_SDM		(1 << 16)
2956b301a05SRhyland Klein #define PLLD_MISC0_LOCK_OVERRIDE	(1 << 17)
2966b301a05SRhyland Klein #define PLLD_MISC0_LOCK_ENABLE		(1 << 18)
2976b301a05SRhyland Klein #define PLLD_MISC0_IDDQ			(1 << 20)
2986b301a05SRhyland Klein #define PLLD_MISC0_DSI_CLKENABLE	(1 << 21)
2996b301a05SRhyland Klein 
3006b301a05SRhyland Klein #define PLLD_MISC0_DEFAULT_VALUE	0x00140000
3016b301a05SRhyland Klein #define PLLD_MISC0_WRITE_MASK		0x3ff7ffff
3026b301a05SRhyland Klein #define PLLD_MISC1_DEFAULT_VALUE	0x20
3036b301a05SRhyland Klein #define PLLD_MISC1_WRITE_MASK		0x00ffffff
3046b301a05SRhyland Klein 
3056b301a05SRhyland Klein /* PLLD2 and PLLDP  and PLLC4 */
3066b301a05SRhyland Klein #define PLLDSS_BASE_LOCK		(1 << 27)
3076b301a05SRhyland Klein #define PLLDSS_BASE_LOCK_OVERRIDE	(1 << 24)
3086b301a05SRhyland Klein #define PLLDSS_BASE_IDDQ		(1 << 18)
3096b301a05SRhyland Klein #define PLLDSS_BASE_REF_SEL_SHIFT	25
3106b301a05SRhyland Klein #define PLLDSS_BASE_REF_SEL_MASK	(0x3 << PLLDSS_BASE_REF_SEL_SHIFT)
3116b301a05SRhyland Klein 
3126b301a05SRhyland Klein #define PLLDSS_MISC0_LOCK_ENABLE	(1 << 30)
3136b301a05SRhyland Klein 
3146b301a05SRhyland Klein #define PLLDSS_MISC1_CFG_EN_SDM		(1 << 31)
3156b301a05SRhyland Klein #define PLLDSS_MISC1_CFG_EN_SSC		(1 << 30)
3166b301a05SRhyland Klein 
3176b301a05SRhyland Klein #define PLLD2_MISC0_DEFAULT_VALUE	0x40000020
3186b301a05SRhyland Klein #define PLLD2_MISC1_CFG_DEFAULT_VALUE	0x10000000
3196b301a05SRhyland Klein #define PLLD2_MISC2_CTRL1_DEFAULT_VALUE	0x0
3206b301a05SRhyland Klein #define PLLD2_MISC3_CTRL2_DEFAULT_VALUE	0x0
3216b301a05SRhyland Klein 
3226b301a05SRhyland Klein #define PLLDP_MISC0_DEFAULT_VALUE	0x40000020
3236b301a05SRhyland Klein #define PLLDP_MISC1_CFG_DEFAULT_VALUE	0xc0000000
3246b301a05SRhyland Klein #define PLLDP_MISC2_CTRL1_DEFAULT_VALUE	0xf400f0da
3256b301a05SRhyland Klein #define PLLDP_MISC3_CTRL2_DEFAULT_VALUE	0x2004f400
3266b301a05SRhyland Klein 
3276b301a05SRhyland Klein #define PLLDSS_MISC0_WRITE_MASK		0x47ffffff
3286b301a05SRhyland Klein #define PLLDSS_MISC1_CFG_WRITE_MASK	0xf8000000
3296b301a05SRhyland Klein #define PLLDSS_MISC2_CTRL1_WRITE_MASK	0xffffffff
3306b301a05SRhyland Klein #define PLLDSS_MISC3_CTRL2_WRITE_MASK	0xffffffff
3316b301a05SRhyland Klein 
3326b301a05SRhyland Klein #define PLLC4_MISC0_DEFAULT_VALUE	0x40000000
3336b301a05SRhyland Klein 
3346b301a05SRhyland Klein /* PLLRE */
3356b301a05SRhyland Klein #define PLLRE_MISC0_LOCK_ENABLE		(1 << 30)
3366b301a05SRhyland Klein #define PLLRE_MISC0_LOCK_OVERRIDE	(1 << 29)
3376b301a05SRhyland Klein #define PLLRE_MISC0_LOCK		(1 << 27)
3386b301a05SRhyland Klein #define PLLRE_MISC0_IDDQ		(1 << 24)
3396b301a05SRhyland Klein 
3406b301a05SRhyland Klein #define PLLRE_BASE_DEFAULT_VALUE	0x0
3416b301a05SRhyland Klein #define PLLRE_MISC0_DEFAULT_VALUE	0x41000000
3426b301a05SRhyland Klein 
3436b301a05SRhyland Klein #define PLLRE_BASE_DEFAULT_MASK		0x1c000000
3446b301a05SRhyland Klein #define PLLRE_MISC0_WRITE_MASK		0x67ffffff
3456b301a05SRhyland Klein 
3466b301a05SRhyland Klein /* PLLX */
3476b301a05SRhyland Klein #define PLLX_USE_DYN_RAMP		1
3486b301a05SRhyland Klein #define PLLX_BASE_LOCK			(1 << 27)
3496b301a05SRhyland Klein 
3506b301a05SRhyland Klein #define PLLX_MISC0_FO_G_DISABLE		(0x1 << 28)
3516b301a05SRhyland Klein #define PLLX_MISC0_LOCK_ENABLE		(0x1 << 18)
3526b301a05SRhyland Klein 
3536b301a05SRhyland Klein #define PLLX_MISC2_DYNRAMP_STEPB_SHIFT	24
3546b301a05SRhyland Klein #define PLLX_MISC2_DYNRAMP_STEPB_MASK	(0xFF << PLLX_MISC2_DYNRAMP_STEPB_SHIFT)
3556b301a05SRhyland Klein #define PLLX_MISC2_DYNRAMP_STEPA_SHIFT	16
3566b301a05SRhyland Klein #define PLLX_MISC2_DYNRAMP_STEPA_MASK	(0xFF << PLLX_MISC2_DYNRAMP_STEPA_SHIFT)
3576b301a05SRhyland Klein #define PLLX_MISC2_NDIV_NEW_SHIFT	8
3586b301a05SRhyland Klein #define PLLX_MISC2_NDIV_NEW_MASK	(0xFF << PLLX_MISC2_NDIV_NEW_SHIFT)
3596b301a05SRhyland Klein #define PLLX_MISC2_LOCK_OVERRIDE	(0x1 << 4)
3606b301a05SRhyland Klein #define PLLX_MISC2_DYNRAMP_DONE		(0x1 << 2)
3616b301a05SRhyland Klein #define PLLX_MISC2_EN_DYNRAMP		(0x1 << 0)
3626b301a05SRhyland Klein 
3636b301a05SRhyland Klein #define PLLX_MISC3_IDDQ			(0x1 << 3)
3646b301a05SRhyland Klein 
3656b301a05SRhyland Klein #define PLLX_MISC0_DEFAULT_VALUE	PLLX_MISC0_LOCK_ENABLE
3666b301a05SRhyland Klein #define PLLX_MISC0_WRITE_MASK		0x10c40000
3676b301a05SRhyland Klein #define PLLX_MISC1_DEFAULT_VALUE	0x20
3686b301a05SRhyland Klein #define PLLX_MISC1_WRITE_MASK		0x00ffffff
3696b301a05SRhyland Klein #define PLLX_MISC2_DEFAULT_VALUE	0x0
3706b301a05SRhyland Klein #define PLLX_MISC2_WRITE_MASK		0xffffff11
3716b301a05SRhyland Klein #define PLLX_MISC3_DEFAULT_VALUE	PLLX_MISC3_IDDQ
3726b301a05SRhyland Klein #define PLLX_MISC3_WRITE_MASK		0x01ff0f0f
3736b301a05SRhyland Klein #define PLLX_MISC4_DEFAULT_VALUE	0x0
3746b301a05SRhyland Klein #define PLLX_MISC4_WRITE_MASK		0x8000ffff
3756b301a05SRhyland Klein #define PLLX_MISC5_DEFAULT_VALUE	0x0
3766b301a05SRhyland Klein #define PLLX_MISC5_WRITE_MASK		0x0000ffff
3776b301a05SRhyland Klein 
3786b301a05SRhyland Klein #define PLLX_HW_CTRL_CFG		0x548
3796b301a05SRhyland Klein #define PLLX_HW_CTRL_CFG_SWCTRL		(0x1 << 0)
3806b301a05SRhyland Klein 
3816b301a05SRhyland Klein /* PLLMB */
3826b301a05SRhyland Klein #define PLLMB_BASE_LOCK			(1 << 27)
3836b301a05SRhyland Klein 
384474f2ba2SRhyland Klein #define PLLMB_MISC1_LOCK_OVERRIDE	(1 << 18)
385474f2ba2SRhyland Klein #define PLLMB_MISC1_IDDQ		(1 << 17)
386474f2ba2SRhyland Klein #define PLLMB_MISC1_LOCK_ENABLE		(1 << 16)
3876b301a05SRhyland Klein 
388474f2ba2SRhyland Klein #define PLLMB_MISC1_DEFAULT_VALUE	0x00030000
389474f2ba2SRhyland Klein #define PLLMB_MISC1_WRITE_MASK		0x0007ffff
3906b301a05SRhyland Klein 
3916b301a05SRhyland Klein /* PLLP */
3926b301a05SRhyland Klein #define PLLP_BASE_OVERRIDE		(1 << 28)
3936b301a05SRhyland Klein #define PLLP_BASE_LOCK			(1 << 27)
3946b301a05SRhyland Klein 
3956b301a05SRhyland Klein #define PLLP_MISC0_LOCK_ENABLE		(1 << 18)
3966b301a05SRhyland Klein #define PLLP_MISC0_LOCK_OVERRIDE	(1 << 17)
3976b301a05SRhyland Klein #define PLLP_MISC0_IDDQ			(1 << 3)
3986b301a05SRhyland Klein 
3996b301a05SRhyland Klein #define PLLP_MISC1_HSIO_EN_SHIFT	29
4006b301a05SRhyland Klein #define PLLP_MISC1_HSIO_EN		(1 << PLLP_MISC1_HSIO_EN_SHIFT)
4016b301a05SRhyland Klein #define PLLP_MISC1_XUSB_EN_SHIFT	28
4026b301a05SRhyland Klein #define PLLP_MISC1_XUSB_EN		(1 << PLLP_MISC1_XUSB_EN_SHIFT)
4036b301a05SRhyland Klein 
4046b301a05SRhyland Klein #define PLLP_MISC0_DEFAULT_VALUE	0x00040008
4056b301a05SRhyland Klein #define PLLP_MISC1_DEFAULT_VALUE	0x0
4066b301a05SRhyland Klein 
4076b301a05SRhyland Klein #define PLLP_MISC0_WRITE_MASK		0xdc6000f
4086b301a05SRhyland Klein #define PLLP_MISC1_WRITE_MASK		0x70ffffff
4096b301a05SRhyland Klein 
4106b301a05SRhyland Klein /* PLLU */
4116b301a05SRhyland Klein #define PLLU_BASE_LOCK			(1 << 27)
4126b301a05SRhyland Klein #define PLLU_BASE_OVERRIDE		(1 << 24)
4136b301a05SRhyland Klein #define PLLU_BASE_CLKENABLE_USB		(1 << 21)
4146b301a05SRhyland Klein #define PLLU_BASE_CLKENABLE_HSIC	(1 << 22)
4156b301a05SRhyland Klein #define PLLU_BASE_CLKENABLE_ICUSB	(1 << 23)
4166b301a05SRhyland Klein #define PLLU_BASE_CLKENABLE_48M		(1 << 25)
4176b301a05SRhyland Klein #define PLLU_BASE_CLKENABLE_ALL		(PLLU_BASE_CLKENABLE_USB |\
4186b301a05SRhyland Klein 					 PLLU_BASE_CLKENABLE_HSIC |\
4196b301a05SRhyland Klein 					 PLLU_BASE_CLKENABLE_ICUSB |\
4206b301a05SRhyland Klein 					 PLLU_BASE_CLKENABLE_48M)
4216b301a05SRhyland Klein 
4226b301a05SRhyland Klein #define PLLU_MISC0_IDDQ			(1 << 31)
4236b301a05SRhyland Klein #define PLLU_MISC0_LOCK_ENABLE		(1 << 29)
4246b301a05SRhyland Klein #define PLLU_MISC1_LOCK_OVERRIDE	(1 << 0)
4256b301a05SRhyland Klein 
4266b301a05SRhyland Klein #define PLLU_MISC0_DEFAULT_VALUE	0xa0000000
4276b301a05SRhyland Klein #define PLLU_MISC1_DEFAULT_VALUE	0x0
4286b301a05SRhyland Klein 
4296b301a05SRhyland Klein #define PLLU_MISC0_WRITE_MASK		0xbfffffff
4306b301a05SRhyland Klein #define PLLU_MISC1_WRITE_MASK		0x00000007
4316b301a05SRhyland Klein 
4323358d2d9SAndrew Bresticker void tegra210_xusb_pll_hw_control_enable(void)
4333358d2d9SAndrew Bresticker {
4343358d2d9SAndrew Bresticker 	u32 val;
4353358d2d9SAndrew Bresticker 
4363358d2d9SAndrew Bresticker 	val = readl_relaxed(clk_base + XUSBIO_PLL_CFG0);
4373358d2d9SAndrew Bresticker 	val &= ~(XUSBIO_PLL_CFG0_CLK_ENABLE_SWCTL |
4383358d2d9SAndrew Bresticker 		 XUSBIO_PLL_CFG0_PADPLL_RESET_SWCTL);
4393358d2d9SAndrew Bresticker 	val |= XUSBIO_PLL_CFG0_PADPLL_USE_LOCKDET |
4403358d2d9SAndrew Bresticker 	       XUSBIO_PLL_CFG0_PADPLL_SLEEP_IDDQ;
4413358d2d9SAndrew Bresticker 	writel_relaxed(val, clk_base + XUSBIO_PLL_CFG0);
4423358d2d9SAndrew Bresticker }
4433358d2d9SAndrew Bresticker EXPORT_SYMBOL_GPL(tegra210_xusb_pll_hw_control_enable);
4443358d2d9SAndrew Bresticker 
4453358d2d9SAndrew Bresticker void tegra210_xusb_pll_hw_sequence_start(void)
4463358d2d9SAndrew Bresticker {
4473358d2d9SAndrew Bresticker 	u32 val;
4483358d2d9SAndrew Bresticker 
4493358d2d9SAndrew Bresticker 	val = readl_relaxed(clk_base + XUSBIO_PLL_CFG0);
4503358d2d9SAndrew Bresticker 	val |= XUSBIO_PLL_CFG0_SEQ_ENABLE;
4513358d2d9SAndrew Bresticker 	writel_relaxed(val, clk_base + XUSBIO_PLL_CFG0);
4523358d2d9SAndrew Bresticker }
4533358d2d9SAndrew Bresticker EXPORT_SYMBOL_GPL(tegra210_xusb_pll_hw_sequence_start);
4543358d2d9SAndrew Bresticker 
4553358d2d9SAndrew Bresticker void tegra210_sata_pll_hw_control_enable(void)
4563358d2d9SAndrew Bresticker {
4573358d2d9SAndrew Bresticker 	u32 val;
4583358d2d9SAndrew Bresticker 
4593358d2d9SAndrew Bresticker 	val = readl_relaxed(clk_base + SATA_PLL_CFG0);
4603358d2d9SAndrew Bresticker 	val &= ~SATA_PLL_CFG0_PADPLL_RESET_SWCTL;
4613358d2d9SAndrew Bresticker 	val |= SATA_PLL_CFG0_PADPLL_USE_LOCKDET |
4623358d2d9SAndrew Bresticker 	       SATA_PLL_CFG0_PADPLL_SLEEP_IDDQ;
4633358d2d9SAndrew Bresticker 	writel_relaxed(val, clk_base + SATA_PLL_CFG0);
4643358d2d9SAndrew Bresticker }
4653358d2d9SAndrew Bresticker EXPORT_SYMBOL_GPL(tegra210_sata_pll_hw_control_enable);
4663358d2d9SAndrew Bresticker 
4673358d2d9SAndrew Bresticker void tegra210_sata_pll_hw_sequence_start(void)
4683358d2d9SAndrew Bresticker {
4693358d2d9SAndrew Bresticker 	u32 val;
4703358d2d9SAndrew Bresticker 
4713358d2d9SAndrew Bresticker 	val = readl_relaxed(clk_base + SATA_PLL_CFG0);
4723358d2d9SAndrew Bresticker 	val |= SATA_PLL_CFG0_SEQ_ENABLE;
4733358d2d9SAndrew Bresticker 	writel_relaxed(val, clk_base + SATA_PLL_CFG0);
4743358d2d9SAndrew Bresticker }
4753358d2d9SAndrew Bresticker EXPORT_SYMBOL_GPL(tegra210_sata_pll_hw_sequence_start);
4763358d2d9SAndrew Bresticker 
4776b301a05SRhyland Klein static inline void _pll_misc_chk_default(void __iomem *base,
4786b301a05SRhyland Klein 					struct tegra_clk_pll_params *params,
4796b301a05SRhyland Klein 					u8 misc_num, u32 default_val, u32 mask)
4806b301a05SRhyland Klein {
4816b301a05SRhyland Klein 	u32 boot_val = readl_relaxed(base + params->ext_misc_reg[misc_num]);
4826b301a05SRhyland Klein 
4836b301a05SRhyland Klein 	boot_val &= mask;
4846b301a05SRhyland Klein 	default_val &= mask;
4856b301a05SRhyland Klein 	if (boot_val != default_val) {
4866b301a05SRhyland Klein 		pr_warn("boot misc%d 0x%x: expected 0x%x\n",
4876b301a05SRhyland Klein 			misc_num, boot_val, default_val);
4886b301a05SRhyland Klein 		pr_warn(" (comparison mask = 0x%x)\n", mask);
4896b301a05SRhyland Klein 		params->defaults_set = false;
4906b301a05SRhyland Klein 	}
4916b301a05SRhyland Klein }
4926b301a05SRhyland Klein 
4936b301a05SRhyland Klein /*
4946b301a05SRhyland Klein  * PLLCX: PLLC, PLLC2, PLLC3, PLLA1
4956b301a05SRhyland Klein  * Hybrid PLLs with dynamic ramp. Dynamic ramp is allowed for any transition
4966b301a05SRhyland Klein  * that changes NDIV only, while PLL is already locked.
4976b301a05SRhyland Klein  */
4986b301a05SRhyland Klein static void pllcx_check_defaults(struct tegra_clk_pll_params *params)
4996b301a05SRhyland Klein {
5006b301a05SRhyland Klein 	u32 default_val;
5016b301a05SRhyland Klein 
5026b301a05SRhyland Klein 	default_val = PLLCX_MISC0_DEFAULT_VALUE & (~PLLCX_MISC0_RESET);
5036b301a05SRhyland Klein 	_pll_misc_chk_default(clk_base, params, 0, default_val,
5046b301a05SRhyland Klein 			PLLCX_MISC0_WRITE_MASK);
5056b301a05SRhyland Klein 
5066b301a05SRhyland Klein 	default_val = PLLCX_MISC1_DEFAULT_VALUE & (~PLLCX_MISC1_IDDQ);
5076b301a05SRhyland Klein 	_pll_misc_chk_default(clk_base, params, 1, default_val,
5086b301a05SRhyland Klein 			PLLCX_MISC1_WRITE_MASK);
5096b301a05SRhyland Klein 
5106b301a05SRhyland Klein 	default_val = PLLCX_MISC2_DEFAULT_VALUE;
5116b301a05SRhyland Klein 	_pll_misc_chk_default(clk_base, params, 2, default_val,
5126b301a05SRhyland Klein 			PLLCX_MISC2_WRITE_MASK);
5136b301a05SRhyland Klein 
5146b301a05SRhyland Klein 	default_val = PLLCX_MISC3_DEFAULT_VALUE;
5156b301a05SRhyland Klein 	_pll_misc_chk_default(clk_base, params, 3, default_val,
5166b301a05SRhyland Klein 			PLLCX_MISC3_WRITE_MASK);
5176b301a05SRhyland Klein }
5186b301a05SRhyland Klein 
519fd360e20SJon Hunter static void tegra210_pllcx_set_defaults(const char *name,
520fd360e20SJon Hunter 					struct tegra_clk_pll *pllcx)
5216b301a05SRhyland Klein {
5226b301a05SRhyland Klein 	pllcx->params->defaults_set = true;
5236b301a05SRhyland Klein 
5246b301a05SRhyland Klein 	if (readl_relaxed(clk_base + pllcx->params->base_reg) &
5256b301a05SRhyland Klein 			PLL_ENABLE) {
5266b301a05SRhyland Klein 		/* PLL is ON: only check if defaults already set */
5276b301a05SRhyland Klein 		pllcx_check_defaults(pllcx->params);
5286b301a05SRhyland Klein 		pr_warn("%s already enabled. Postponing set full defaults\n",
5296b301a05SRhyland Klein 			name);
5306b301a05SRhyland Klein 		return;
5316b301a05SRhyland Klein 	}
5326b301a05SRhyland Klein 
5336b301a05SRhyland Klein 	/* Defaults assert PLL reset, and set IDDQ */
5346b301a05SRhyland Klein 	writel_relaxed(PLLCX_MISC0_DEFAULT_VALUE,
5356b301a05SRhyland Klein 			clk_base + pllcx->params->ext_misc_reg[0]);
5366b301a05SRhyland Klein 	writel_relaxed(PLLCX_MISC1_DEFAULT_VALUE,
5376b301a05SRhyland Klein 			clk_base + pllcx->params->ext_misc_reg[1]);
5386b301a05SRhyland Klein 	writel_relaxed(PLLCX_MISC2_DEFAULT_VALUE,
5396b301a05SRhyland Klein 			clk_base + pllcx->params->ext_misc_reg[2]);
5406b301a05SRhyland Klein 	writel_relaxed(PLLCX_MISC3_DEFAULT_VALUE,
5416b301a05SRhyland Klein 			clk_base + pllcx->params->ext_misc_reg[3]);
5426b301a05SRhyland Klein 	udelay(1);
5436b301a05SRhyland Klein }
5446b301a05SRhyland Klein 
545fd360e20SJon Hunter static void _pllc_set_defaults(struct tegra_clk_pll *pllcx)
5466b301a05SRhyland Klein {
5476b301a05SRhyland Klein 	tegra210_pllcx_set_defaults("PLL_C", pllcx);
5486b301a05SRhyland Klein }
5496b301a05SRhyland Klein 
550fd360e20SJon Hunter static void _pllc2_set_defaults(struct tegra_clk_pll *pllcx)
5516b301a05SRhyland Klein {
5526b301a05SRhyland Klein 	tegra210_pllcx_set_defaults("PLL_C2", pllcx);
5536b301a05SRhyland Klein }
5546b301a05SRhyland Klein 
555fd360e20SJon Hunter static void _pllc3_set_defaults(struct tegra_clk_pll *pllcx)
5566b301a05SRhyland Klein {
5576b301a05SRhyland Klein 	tegra210_pllcx_set_defaults("PLL_C3", pllcx);
5586b301a05SRhyland Klein }
5596b301a05SRhyland Klein 
560fd360e20SJon Hunter static void _plla1_set_defaults(struct tegra_clk_pll *pllcx)
5616b301a05SRhyland Klein {
5626b301a05SRhyland Klein 	tegra210_pllcx_set_defaults("PLL_A1", pllcx);
5636b301a05SRhyland Klein }
5646b301a05SRhyland Klein 
5656b301a05SRhyland Klein /*
5666b301a05SRhyland Klein  * PLLA
5676b301a05SRhyland Klein  * PLL with dynamic ramp and fractional SDM. Dynamic ramp is not used.
5686b301a05SRhyland Klein  * Fractional SDM is allowed to provide exact audio rates.
5696b301a05SRhyland Klein  */
570fd360e20SJon Hunter static void tegra210_plla_set_defaults(struct tegra_clk_pll *plla)
5716b301a05SRhyland Klein {
5726b301a05SRhyland Klein 	u32 mask;
5736b301a05SRhyland Klein 	u32 val = readl_relaxed(clk_base + plla->params->base_reg);
5746b301a05SRhyland Klein 
5756b301a05SRhyland Klein 	plla->params->defaults_set = true;
5766b301a05SRhyland Klein 
5776b301a05SRhyland Klein 	if (val & PLL_ENABLE) {
5786b301a05SRhyland Klein 		/*
5796b301a05SRhyland Klein 		 * PLL is ON: check if defaults already set, then set those
5806b301a05SRhyland Klein 		 * that can be updated in flight.
5816b301a05SRhyland Klein 		 */
5826b301a05SRhyland Klein 		if (val & PLLA_BASE_IDDQ) {
5836b301a05SRhyland Klein 			pr_warn("PLL_A boot enabled with IDDQ set\n");
5846b301a05SRhyland Klein 			plla->params->defaults_set = false;
5856b301a05SRhyland Klein 		}
5866b301a05SRhyland Klein 
5876b301a05SRhyland Klein 		pr_warn("PLL_A already enabled. Postponing set full defaults\n");
5886b301a05SRhyland Klein 
5896b301a05SRhyland Klein 		val = PLLA_MISC0_DEFAULT_VALUE;	/* ignore lock enable */
5906b301a05SRhyland Klein 		mask = PLLA_MISC0_LOCK_ENABLE | PLLA_MISC0_LOCK_OVERRIDE;
5916b301a05SRhyland Klein 		_pll_misc_chk_default(clk_base, plla->params, 0, val,
5926b301a05SRhyland Klein 				~mask & PLLA_MISC0_WRITE_MASK);
5936b301a05SRhyland Klein 
5946b301a05SRhyland Klein 		val = PLLA_MISC2_DEFAULT_VALUE; /* ignore all but control bit */
5956b301a05SRhyland Klein 		_pll_misc_chk_default(clk_base, plla->params, 2, val,
5966b301a05SRhyland Klein 				PLLA_MISC2_EN_DYNRAMP);
5976b301a05SRhyland Klein 
5986b301a05SRhyland Klein 		/* Enable lock detect */
5996b301a05SRhyland Klein 		val = readl_relaxed(clk_base + plla->params->ext_misc_reg[0]);
6006b301a05SRhyland Klein 		val &= ~mask;
6016b301a05SRhyland Klein 		val |= PLLA_MISC0_DEFAULT_VALUE & mask;
6026b301a05SRhyland Klein 		writel_relaxed(val, clk_base + plla->params->ext_misc_reg[0]);
6036b301a05SRhyland Klein 		udelay(1);
6046b301a05SRhyland Klein 
6056b301a05SRhyland Klein 		return;
6066b301a05SRhyland Klein 	}
6076b301a05SRhyland Klein 
6086b301a05SRhyland Klein 	/* set IDDQ, enable lock detect, disable dynamic ramp and SDM */
6096b301a05SRhyland Klein 	val |= PLLA_BASE_IDDQ;
6106b301a05SRhyland Klein 	writel_relaxed(val, clk_base + plla->params->base_reg);
6116b301a05SRhyland Klein 	writel_relaxed(PLLA_MISC0_DEFAULT_VALUE,
6126b301a05SRhyland Klein 			clk_base + plla->params->ext_misc_reg[0]);
6136b301a05SRhyland Klein 	writel_relaxed(PLLA_MISC2_DEFAULT_VALUE,
6146b301a05SRhyland Klein 			clk_base + plla->params->ext_misc_reg[2]);
6156b301a05SRhyland Klein 	udelay(1);
6166b301a05SRhyland Klein }
6176b301a05SRhyland Klein 
6186b301a05SRhyland Klein /*
6196b301a05SRhyland Klein  * PLLD
6206b301a05SRhyland Klein  * PLL with fractional SDM.
6216b301a05SRhyland Klein  */
622fd360e20SJon Hunter static void tegra210_plld_set_defaults(struct tegra_clk_pll *plld)
6236b301a05SRhyland Klein {
6246b301a05SRhyland Klein 	u32 val;
6256b301a05SRhyland Klein 	u32 mask = 0xffff;
6266b301a05SRhyland Klein 
6276b301a05SRhyland Klein 	plld->params->defaults_set = true;
6286b301a05SRhyland Klein 
6296b301a05SRhyland Klein 	if (readl_relaxed(clk_base + plld->params->base_reg) &
6306b301a05SRhyland Klein 			PLL_ENABLE) {
6316b301a05SRhyland Klein 		pr_warn("PLL_D already enabled. Postponing set full defaults\n");
6326b301a05SRhyland Klein 
6336b301a05SRhyland Klein 		/*
6346b301a05SRhyland Klein 		 * PLL is ON: check if defaults already set, then set those
6356b301a05SRhyland Klein 		 * that can be updated in flight.
6366b301a05SRhyland Klein 		 */
6376b301a05SRhyland Klein 		val = PLLD_MISC1_DEFAULT_VALUE;
6386b301a05SRhyland Klein 		_pll_misc_chk_default(clk_base, plld->params, 1,
6396b301a05SRhyland Klein 				val, PLLD_MISC1_WRITE_MASK);
6406b301a05SRhyland Klein 
6416b301a05SRhyland Klein 		/* ignore lock, DSI and SDM controls, make sure IDDQ not set */
6426b301a05SRhyland Klein 		val = PLLD_MISC0_DEFAULT_VALUE & (~PLLD_MISC0_IDDQ);
6436b301a05SRhyland Klein 		mask |= PLLD_MISC0_DSI_CLKENABLE | PLLD_MISC0_LOCK_ENABLE |
6446b301a05SRhyland Klein 			PLLD_MISC0_LOCK_OVERRIDE | PLLD_MISC0_EN_SDM;
6456b301a05SRhyland Klein 		_pll_misc_chk_default(clk_base, plld->params, 0, val,
6466b301a05SRhyland Klein 				~mask & PLLD_MISC0_WRITE_MASK);
6476b301a05SRhyland Klein 
6486b301a05SRhyland Klein 		/* Enable lock detect */
6496b301a05SRhyland Klein 		mask = PLLD_MISC0_LOCK_ENABLE | PLLD_MISC0_LOCK_OVERRIDE;
6506b301a05SRhyland Klein 		val = readl_relaxed(clk_base + plld->params->ext_misc_reg[0]);
6516b301a05SRhyland Klein 		val &= ~mask;
6526b301a05SRhyland Klein 		val |= PLLD_MISC0_DEFAULT_VALUE & mask;
6536b301a05SRhyland Klein 		writel_relaxed(val, clk_base + plld->params->ext_misc_reg[0]);
6546b301a05SRhyland Klein 		udelay(1);
6556b301a05SRhyland Klein 
6566b301a05SRhyland Klein 		return;
6576b301a05SRhyland Klein 	}
6586b301a05SRhyland Klein 
6596b301a05SRhyland Klein 	val = readl_relaxed(clk_base + plld->params->ext_misc_reg[0]);
6606b301a05SRhyland Klein 	val &= PLLD_MISC0_DSI_CLKENABLE;
6616b301a05SRhyland Klein 	val |= PLLD_MISC0_DEFAULT_VALUE;
6626b301a05SRhyland Klein 	/* set IDDQ, enable lock detect, disable SDM */
6636b301a05SRhyland Klein 	writel_relaxed(val, clk_base + plld->params->ext_misc_reg[0]);
6646b301a05SRhyland Klein 	writel_relaxed(PLLD_MISC1_DEFAULT_VALUE, clk_base +
6656b301a05SRhyland Klein 			plld->params->ext_misc_reg[1]);
6666b301a05SRhyland Klein 	udelay(1);
6676b301a05SRhyland Klein }
6686b301a05SRhyland Klein 
6696b301a05SRhyland Klein /*
6706b301a05SRhyland Klein  * PLLD2, PLLDP
6716b301a05SRhyland Klein  * PLL with fractional SDM and Spread Spectrum (SDM is a must if SSC is used).
6726b301a05SRhyland Klein  */
6736b301a05SRhyland Klein static void plldss_defaults(const char *pll_name, struct tegra_clk_pll *plldss,
6746b301a05SRhyland Klein 		u32 misc0_val, u32 misc1_val, u32 misc2_val, u32 misc3_val)
6756b301a05SRhyland Klein {
6766b301a05SRhyland Klein 	u32 default_val;
6776b301a05SRhyland Klein 	u32 val = readl_relaxed(clk_base + plldss->params->base_reg);
6786b301a05SRhyland Klein 
6796b301a05SRhyland Klein 	plldss->params->defaults_set = true;
6806b301a05SRhyland Klein 
6816b301a05SRhyland Klein 	if (val & PLL_ENABLE) {
6826b301a05SRhyland Klein 		pr_warn("%s already enabled. Postponing set full defaults\n",
6836b301a05SRhyland Klein 			 pll_name);
6846b301a05SRhyland Klein 
6856b301a05SRhyland Klein 		/*
6866b301a05SRhyland Klein 		 * PLL is ON: check if defaults already set, then set those
6876b301a05SRhyland Klein 		 * that can be updated in flight.
6886b301a05SRhyland Klein 		 */
6896b301a05SRhyland Klein 		if (val & PLLDSS_BASE_IDDQ) {
6906b301a05SRhyland Klein 			pr_warn("plldss boot enabled with IDDQ set\n");
6916b301a05SRhyland Klein 			plldss->params->defaults_set = false;
6926b301a05SRhyland Klein 		}
6936b301a05SRhyland Klein 
6946b301a05SRhyland Klein 		/* ignore lock enable */
6956b301a05SRhyland Klein 		default_val = misc0_val;
6966b301a05SRhyland Klein 		_pll_misc_chk_default(clk_base, plldss->params, 0, default_val,
6976b301a05SRhyland Klein 				     PLLDSS_MISC0_WRITE_MASK &
6986b301a05SRhyland Klein 				     (~PLLDSS_MISC0_LOCK_ENABLE));
6996b301a05SRhyland Klein 
7006b301a05SRhyland Klein 		/*
7016b301a05SRhyland Klein 		 * If SSC is used, check all settings, otherwise just confirm
7026b301a05SRhyland Klein 		 * that SSC is not used on boot as well. Do nothing when using
7036b301a05SRhyland Klein 		 * this function for PLLC4 that has only MISC0.
7046b301a05SRhyland Klein 		 */
7056b301a05SRhyland Klein 		if (plldss->params->ssc_ctrl_en_mask) {
7066b301a05SRhyland Klein 			default_val = misc1_val;
7076b301a05SRhyland Klein 			_pll_misc_chk_default(clk_base, plldss->params, 1,
7086b301a05SRhyland Klein 				default_val, PLLDSS_MISC1_CFG_WRITE_MASK);
7096b301a05SRhyland Klein 			default_val = misc2_val;
7106b301a05SRhyland Klein 			_pll_misc_chk_default(clk_base, plldss->params, 2,
7116b301a05SRhyland Klein 				default_val, PLLDSS_MISC2_CTRL1_WRITE_MASK);
7126b301a05SRhyland Klein 			default_val = misc3_val;
7136b301a05SRhyland Klein 			_pll_misc_chk_default(clk_base, plldss->params, 3,
7146b301a05SRhyland Klein 				default_val, PLLDSS_MISC3_CTRL2_WRITE_MASK);
7156b301a05SRhyland Klein 		} else if (plldss->params->ext_misc_reg[1]) {
7166b301a05SRhyland Klein 			default_val = misc1_val;
7176b301a05SRhyland Klein 			_pll_misc_chk_default(clk_base, plldss->params, 1,
7186b301a05SRhyland Klein 				default_val, PLLDSS_MISC1_CFG_WRITE_MASK &
7196b301a05SRhyland Klein 				(~PLLDSS_MISC1_CFG_EN_SDM));
7206b301a05SRhyland Klein 		}
7216b301a05SRhyland Klein 
7226b301a05SRhyland Klein 		/* Enable lock detect */
7236b301a05SRhyland Klein 		if (val & PLLDSS_BASE_LOCK_OVERRIDE) {
7246b301a05SRhyland Klein 			val &= ~PLLDSS_BASE_LOCK_OVERRIDE;
7256b301a05SRhyland Klein 			writel_relaxed(val, clk_base +
7266b301a05SRhyland Klein 					plldss->params->base_reg);
7276b301a05SRhyland Klein 		}
7286b301a05SRhyland Klein 
7296b301a05SRhyland Klein 		val = readl_relaxed(clk_base + plldss->params->ext_misc_reg[0]);
7306b301a05SRhyland Klein 		val &= ~PLLDSS_MISC0_LOCK_ENABLE;
7316b301a05SRhyland Klein 		val |= misc0_val & PLLDSS_MISC0_LOCK_ENABLE;
7326b301a05SRhyland Klein 		writel_relaxed(val, clk_base + plldss->params->ext_misc_reg[0]);
7336b301a05SRhyland Klein 		udelay(1);
7346b301a05SRhyland Klein 
7356b301a05SRhyland Klein 		return;
7366b301a05SRhyland Klein 	}
7376b301a05SRhyland Klein 
7386b301a05SRhyland Klein 	/* set IDDQ, enable lock detect, configure SDM/SSC  */
7396b301a05SRhyland Klein 	val |= PLLDSS_BASE_IDDQ;
7406b301a05SRhyland Klein 	val &= ~PLLDSS_BASE_LOCK_OVERRIDE;
7416b301a05SRhyland Klein 	writel_relaxed(val, clk_base + plldss->params->base_reg);
7426b301a05SRhyland Klein 
7436b301a05SRhyland Klein 	/* When using this function for PLLC4 exit here */
7446b301a05SRhyland Klein 	if (!plldss->params->ext_misc_reg[1]) {
7456b301a05SRhyland Klein 		writel_relaxed(misc0_val, clk_base +
7466b301a05SRhyland Klein 				plldss->params->ext_misc_reg[0]);
7476b301a05SRhyland Klein 		udelay(1);
7486b301a05SRhyland Klein 		return;
7496b301a05SRhyland Klein 	}
7506b301a05SRhyland Klein 
7516b301a05SRhyland Klein 	writel_relaxed(misc0_val, clk_base +
7526b301a05SRhyland Klein 			plldss->params->ext_misc_reg[0]);
7536b301a05SRhyland Klein 	/* if SSC used set by 1st enable */
7546b301a05SRhyland Klein 	writel_relaxed(misc1_val & (~PLLDSS_MISC1_CFG_EN_SSC),
7556b301a05SRhyland Klein 			clk_base + plldss->params->ext_misc_reg[1]);
7566b301a05SRhyland Klein 	writel_relaxed(misc2_val, clk_base + plldss->params->ext_misc_reg[2]);
7576b301a05SRhyland Klein 	writel_relaxed(misc3_val, clk_base + plldss->params->ext_misc_reg[3]);
7586b301a05SRhyland Klein 	udelay(1);
7596b301a05SRhyland Klein }
7606b301a05SRhyland Klein 
761fd360e20SJon Hunter static void tegra210_plld2_set_defaults(struct tegra_clk_pll *plld2)
7626b301a05SRhyland Klein {
7636b301a05SRhyland Klein 	plldss_defaults("PLL_D2", plld2, PLLD2_MISC0_DEFAULT_VALUE,
7646b301a05SRhyland Klein 			PLLD2_MISC1_CFG_DEFAULT_VALUE,
7656b301a05SRhyland Klein 			PLLD2_MISC2_CTRL1_DEFAULT_VALUE,
7666b301a05SRhyland Klein 			PLLD2_MISC3_CTRL2_DEFAULT_VALUE);
7676b301a05SRhyland Klein }
7686b301a05SRhyland Klein 
769fd360e20SJon Hunter static void tegra210_plldp_set_defaults(struct tegra_clk_pll *plldp)
7706b301a05SRhyland Klein {
7716b301a05SRhyland Klein 	plldss_defaults("PLL_DP", plldp, PLLDP_MISC0_DEFAULT_VALUE,
7726b301a05SRhyland Klein 			PLLDP_MISC1_CFG_DEFAULT_VALUE,
7736b301a05SRhyland Klein 			PLLDP_MISC2_CTRL1_DEFAULT_VALUE,
7746b301a05SRhyland Klein 			PLLDP_MISC3_CTRL2_DEFAULT_VALUE);
7756b301a05SRhyland Klein }
7766b301a05SRhyland Klein 
7776b301a05SRhyland Klein /*
7786b301a05SRhyland Klein  * PLLC4
7796b301a05SRhyland Klein  * Base and misc0 layout is the same as PLLD2/PLLDP, but no SDM/SSC support.
7806b301a05SRhyland Klein  * VCO is exposed to the clock tree via fixed 1/3 and 1/5 dividers.
7816b301a05SRhyland Klein  */
782fd360e20SJon Hunter static void tegra210_pllc4_set_defaults(struct tegra_clk_pll *pllc4)
7836b301a05SRhyland Klein {
7846b301a05SRhyland Klein 	plldss_defaults("PLL_C4", pllc4, PLLC4_MISC0_DEFAULT_VALUE, 0, 0, 0);
7856b301a05SRhyland Klein }
7866b301a05SRhyland Klein 
7876b301a05SRhyland Klein /*
7886b301a05SRhyland Klein  * PLLRE
7896b301a05SRhyland Klein  * VCO is exposed to the clock tree directly along with post-divider output
7906b301a05SRhyland Klein  */
791fd360e20SJon Hunter static void tegra210_pllre_set_defaults(struct tegra_clk_pll *pllre)
7926b301a05SRhyland Klein {
7936b301a05SRhyland Klein 	u32 mask;
7946b301a05SRhyland Klein 	u32 val = readl_relaxed(clk_base + pllre->params->base_reg);
7956b301a05SRhyland Klein 
7966b301a05SRhyland Klein 	pllre->params->defaults_set = true;
7976b301a05SRhyland Klein 
7986b301a05SRhyland Klein 	if (val & PLL_ENABLE) {
7996b301a05SRhyland Klein 		pr_warn("PLL_RE already enabled. Postponing set full defaults\n");
8006b301a05SRhyland Klein 
8016b301a05SRhyland Klein 		/*
8026b301a05SRhyland Klein 		 * PLL is ON: check if defaults already set, then set those
8036b301a05SRhyland Klein 		 * that can be updated in flight.
8046b301a05SRhyland Klein 		 */
8056b301a05SRhyland Klein 		val &= PLLRE_BASE_DEFAULT_MASK;
8066b301a05SRhyland Klein 		if (val != PLLRE_BASE_DEFAULT_VALUE) {
8076b301a05SRhyland Klein 			pr_warn("pllre boot base 0x%x : expected 0x%x\n",
8086b301a05SRhyland Klein 				val, PLLRE_BASE_DEFAULT_VALUE);
8096b301a05SRhyland Klein 			pr_warn("(comparison mask = 0x%x)\n",
8106b301a05SRhyland Klein 				PLLRE_BASE_DEFAULT_MASK);
8116b301a05SRhyland Klein 			pllre->params->defaults_set = false;
8126b301a05SRhyland Klein 		}
8136b301a05SRhyland Klein 
8146b301a05SRhyland Klein 		/* Ignore lock enable */
8156b301a05SRhyland Klein 		val = PLLRE_MISC0_DEFAULT_VALUE & (~PLLRE_MISC0_IDDQ);
8166b301a05SRhyland Klein 		mask = PLLRE_MISC0_LOCK_ENABLE | PLLRE_MISC0_LOCK_OVERRIDE;
8176b301a05SRhyland Klein 		_pll_misc_chk_default(clk_base, pllre->params, 0, val,
8186b301a05SRhyland Klein 				~mask & PLLRE_MISC0_WRITE_MASK);
8196b301a05SRhyland Klein 
8206b301a05SRhyland Klein 		/* Enable lock detect */
8216b301a05SRhyland Klein 		val = readl_relaxed(clk_base + pllre->params->ext_misc_reg[0]);
8226b301a05SRhyland Klein 		val &= ~mask;
8236b301a05SRhyland Klein 		val |= PLLRE_MISC0_DEFAULT_VALUE & mask;
8246b301a05SRhyland Klein 		writel_relaxed(val, clk_base + pllre->params->ext_misc_reg[0]);
8256b301a05SRhyland Klein 		udelay(1);
8266b301a05SRhyland Klein 
8276b301a05SRhyland Klein 		return;
8286b301a05SRhyland Klein 	}
8296b301a05SRhyland Klein 
8306b301a05SRhyland Klein 	/* set IDDQ, enable lock detect */
8316b301a05SRhyland Klein 	val &= ~PLLRE_BASE_DEFAULT_MASK;
8326b301a05SRhyland Klein 	val |= PLLRE_BASE_DEFAULT_VALUE & PLLRE_BASE_DEFAULT_MASK;
8336b301a05SRhyland Klein 	writel_relaxed(val, clk_base + pllre->params->base_reg);
8346b301a05SRhyland Klein 	writel_relaxed(PLLRE_MISC0_DEFAULT_VALUE,
8356b301a05SRhyland Klein 			clk_base + pllre->params->ext_misc_reg[0]);
8366b301a05SRhyland Klein 	udelay(1);
8376b301a05SRhyland Klein }
8386b301a05SRhyland Klein 
8396b301a05SRhyland Klein static void pllx_get_dyn_steps(struct clk_hw *hw, u32 *step_a, u32 *step_b)
8406b301a05SRhyland Klein {
8416b301a05SRhyland Klein 	unsigned long input_rate;
8426b301a05SRhyland Klein 
8436b301a05SRhyland Klein 	/* cf rate */
8443dad5c5fSRhyland Klein 	if (!IS_ERR_OR_NULL(hw->clk))
8453dad5c5fSRhyland Klein 		input_rate = clk_hw_get_rate(clk_hw_get_parent(hw));
8463dad5c5fSRhyland Klein 	else
8476b301a05SRhyland Klein 		input_rate = 38400000;
8483dad5c5fSRhyland Klein 
8493dad5c5fSRhyland Klein 	input_rate /= tegra_pll_get_fixed_mdiv(hw, input_rate);
8506b301a05SRhyland Klein 
8516b301a05SRhyland Klein 	switch (input_rate) {
8526b301a05SRhyland Klein 	case 12000000:
8536b301a05SRhyland Klein 	case 12800000:
8546b301a05SRhyland Klein 	case 13000000:
8556b301a05SRhyland Klein 		*step_a = 0x2B;
8566b301a05SRhyland Klein 		*step_b = 0x0B;
8576b301a05SRhyland Klein 		return;
8586b301a05SRhyland Klein 	case 19200000:
8596b301a05SRhyland Klein 		*step_a = 0x12;
8606b301a05SRhyland Klein 		*step_b = 0x08;
8616b301a05SRhyland Klein 		return;
8626b301a05SRhyland Klein 	case 38400000:
8636b301a05SRhyland Klein 		*step_a = 0x04;
8646b301a05SRhyland Klein 		*step_b = 0x05;
8656b301a05SRhyland Klein 		return;
8666b301a05SRhyland Klein 	default:
8676b301a05SRhyland Klein 		pr_err("%s: Unexpected reference rate %lu\n",
8686b301a05SRhyland Klein 			__func__, input_rate);
8696b301a05SRhyland Klein 		BUG();
8706b301a05SRhyland Klein 	}
8716b301a05SRhyland Klein }
8726b301a05SRhyland Klein 
8736b301a05SRhyland Klein static void pllx_check_defaults(struct tegra_clk_pll *pll)
8746b301a05SRhyland Klein {
8756b301a05SRhyland Klein 	u32 default_val;
8766b301a05SRhyland Klein 
8776b301a05SRhyland Klein 	default_val = PLLX_MISC0_DEFAULT_VALUE;
8786b301a05SRhyland Klein 	/* ignore lock enable */
8796b301a05SRhyland Klein 	_pll_misc_chk_default(clk_base, pll->params, 0, default_val,
8806b301a05SRhyland Klein 			PLLX_MISC0_WRITE_MASK & (~PLLX_MISC0_LOCK_ENABLE));
8816b301a05SRhyland Klein 
8826b301a05SRhyland Klein 	default_val = PLLX_MISC1_DEFAULT_VALUE;
8836b301a05SRhyland Klein 	_pll_misc_chk_default(clk_base, pll->params, 1, default_val,
8846b301a05SRhyland Klein 			PLLX_MISC1_WRITE_MASK);
8856b301a05SRhyland Klein 
8866b301a05SRhyland Klein 	/* ignore all but control bit */
8876b301a05SRhyland Klein 	default_val = PLLX_MISC2_DEFAULT_VALUE;
8886b301a05SRhyland Klein 	_pll_misc_chk_default(clk_base, pll->params, 2,
8896b301a05SRhyland Klein 			default_val, PLLX_MISC2_EN_DYNRAMP);
8906b301a05SRhyland Klein 
8916b301a05SRhyland Klein 	default_val = PLLX_MISC3_DEFAULT_VALUE & (~PLLX_MISC3_IDDQ);
8926b301a05SRhyland Klein 	_pll_misc_chk_default(clk_base, pll->params, 3, default_val,
8936b301a05SRhyland Klein 			PLLX_MISC3_WRITE_MASK);
8946b301a05SRhyland Klein 
8956b301a05SRhyland Klein 	default_val = PLLX_MISC4_DEFAULT_VALUE;
8966b301a05SRhyland Klein 	_pll_misc_chk_default(clk_base, pll->params, 4, default_val,
8976b301a05SRhyland Klein 			PLLX_MISC4_WRITE_MASK);
8986b301a05SRhyland Klein 
8996b301a05SRhyland Klein 	default_val = PLLX_MISC5_DEFAULT_VALUE;
9006b301a05SRhyland Klein 	_pll_misc_chk_default(clk_base, pll->params, 5, default_val,
9016b301a05SRhyland Klein 			PLLX_MISC5_WRITE_MASK);
9026b301a05SRhyland Klein }
9036b301a05SRhyland Klein 
904fd360e20SJon Hunter static void tegra210_pllx_set_defaults(struct tegra_clk_pll *pllx)
9056b301a05SRhyland Klein {
9066b301a05SRhyland Klein 	u32 val;
9076b301a05SRhyland Klein 	u32 step_a, step_b;
9086b301a05SRhyland Klein 
9096b301a05SRhyland Klein 	pllx->params->defaults_set = true;
9106b301a05SRhyland Klein 
9116b301a05SRhyland Klein 	/* Get ready dyn ramp state machine settings */
9126b301a05SRhyland Klein 	pllx_get_dyn_steps(&pllx->hw, &step_a, &step_b);
9136b301a05SRhyland Klein 	val = PLLX_MISC2_DEFAULT_VALUE & (~PLLX_MISC2_DYNRAMP_STEPA_MASK) &
9146b301a05SRhyland Klein 		(~PLLX_MISC2_DYNRAMP_STEPB_MASK);
9156b301a05SRhyland Klein 	val |= step_a << PLLX_MISC2_DYNRAMP_STEPA_SHIFT;
9166b301a05SRhyland Klein 	val |= step_b << PLLX_MISC2_DYNRAMP_STEPB_SHIFT;
9176b301a05SRhyland Klein 
9186b301a05SRhyland Klein 	if (readl_relaxed(clk_base + pllx->params->base_reg) & PLL_ENABLE) {
9196b301a05SRhyland Klein 		pr_warn("PLL_X already enabled. Postponing set full defaults\n");
9206b301a05SRhyland Klein 
9216b301a05SRhyland Klein 		/*
9226b301a05SRhyland Klein 		 * PLL is ON: check if defaults already set, then set those
9236b301a05SRhyland Klein 		 * that can be updated in flight.
9246b301a05SRhyland Klein 		 */
9256b301a05SRhyland Klein 		pllx_check_defaults(pllx);
9266b301a05SRhyland Klein 
9276b301a05SRhyland Klein 		/* Configure dyn ramp, disable lock override */
9286b301a05SRhyland Klein 		writel_relaxed(val, clk_base + pllx->params->ext_misc_reg[2]);
9296b301a05SRhyland Klein 
9306b301a05SRhyland Klein 		/* Enable lock detect */
9316b301a05SRhyland Klein 		val = readl_relaxed(clk_base + pllx->params->ext_misc_reg[0]);
9326b301a05SRhyland Klein 		val &= ~PLLX_MISC0_LOCK_ENABLE;
9336b301a05SRhyland Klein 		val |= PLLX_MISC0_DEFAULT_VALUE & PLLX_MISC0_LOCK_ENABLE;
9346b301a05SRhyland Klein 		writel_relaxed(val, clk_base + pllx->params->ext_misc_reg[0]);
9356b301a05SRhyland Klein 		udelay(1);
9366b301a05SRhyland Klein 
9376b301a05SRhyland Klein 		return;
9386b301a05SRhyland Klein 	}
9396b301a05SRhyland Klein 
9406b301a05SRhyland Klein 	/* Enable lock detect and CPU output */
9416b301a05SRhyland Klein 	writel_relaxed(PLLX_MISC0_DEFAULT_VALUE, clk_base +
9426b301a05SRhyland Klein 			pllx->params->ext_misc_reg[0]);
9436b301a05SRhyland Klein 
9446b301a05SRhyland Klein 	/* Setup */
9456b301a05SRhyland Klein 	writel_relaxed(PLLX_MISC1_DEFAULT_VALUE, clk_base +
9466b301a05SRhyland Klein 			pllx->params->ext_misc_reg[1]);
9476b301a05SRhyland Klein 
9486b301a05SRhyland Klein 	/* Configure dyn ramp state machine, disable lock override */
9496b301a05SRhyland Klein 	writel_relaxed(val, clk_base + pllx->params->ext_misc_reg[2]);
9506b301a05SRhyland Klein 
9516b301a05SRhyland Klein 	/* Set IDDQ */
9526b301a05SRhyland Klein 	writel_relaxed(PLLX_MISC3_DEFAULT_VALUE, clk_base +
9536b301a05SRhyland Klein 			pllx->params->ext_misc_reg[3]);
9546b301a05SRhyland Klein 
9556b301a05SRhyland Klein 	/* Disable SDM */
9566b301a05SRhyland Klein 	writel_relaxed(PLLX_MISC4_DEFAULT_VALUE, clk_base +
9576b301a05SRhyland Klein 			pllx->params->ext_misc_reg[4]);
9586b301a05SRhyland Klein 	writel_relaxed(PLLX_MISC5_DEFAULT_VALUE, clk_base +
9596b301a05SRhyland Klein 			pllx->params->ext_misc_reg[5]);
9606b301a05SRhyland Klein 	udelay(1);
9616b301a05SRhyland Klein }
9626b301a05SRhyland Klein 
9636b301a05SRhyland Klein /* PLLMB */
964fd360e20SJon Hunter static void tegra210_pllmb_set_defaults(struct tegra_clk_pll *pllmb)
9656b301a05SRhyland Klein {
9666b301a05SRhyland Klein 	u32 mask, val = readl_relaxed(clk_base + pllmb->params->base_reg);
9676b301a05SRhyland Klein 
9686b301a05SRhyland Klein 	pllmb->params->defaults_set = true;
9696b301a05SRhyland Klein 
9706b301a05SRhyland Klein 	if (val & PLL_ENABLE) {
9716b301a05SRhyland Klein 		pr_warn("PLL_MB already enabled. Postponing set full defaults\n");
9726b301a05SRhyland Klein 
9736b301a05SRhyland Klein 		/*
9746b301a05SRhyland Klein 		 * PLL is ON: check if defaults already set, then set those
9756b301a05SRhyland Klein 		 * that can be updated in flight.
9766b301a05SRhyland Klein 		 */
977474f2ba2SRhyland Klein 		val = PLLMB_MISC1_DEFAULT_VALUE & (~PLLMB_MISC1_IDDQ);
978474f2ba2SRhyland Klein 		mask = PLLMB_MISC1_LOCK_ENABLE | PLLMB_MISC1_LOCK_OVERRIDE;
9796b301a05SRhyland Klein 		_pll_misc_chk_default(clk_base, pllmb->params, 0, val,
980474f2ba2SRhyland Klein 				~mask & PLLMB_MISC1_WRITE_MASK);
9816b301a05SRhyland Klein 
9826b301a05SRhyland Klein 		/* Enable lock detect */
9836b301a05SRhyland Klein 		val = readl_relaxed(clk_base + pllmb->params->ext_misc_reg[0]);
9846b301a05SRhyland Klein 		val &= ~mask;
985474f2ba2SRhyland Klein 		val |= PLLMB_MISC1_DEFAULT_VALUE & mask;
9866b301a05SRhyland Klein 		writel_relaxed(val, clk_base + pllmb->params->ext_misc_reg[0]);
9876b301a05SRhyland Klein 		udelay(1);
9886b301a05SRhyland Klein 
9896b301a05SRhyland Klein 		return;
9906b301a05SRhyland Klein 	}
9916b301a05SRhyland Klein 
9926b301a05SRhyland Klein 	/* set IDDQ, enable lock detect */
993474f2ba2SRhyland Klein 	writel_relaxed(PLLMB_MISC1_DEFAULT_VALUE,
9946b301a05SRhyland Klein 			clk_base + pllmb->params->ext_misc_reg[0]);
9956b301a05SRhyland Klein 	udelay(1);
9966b301a05SRhyland Klein }
9976b301a05SRhyland Klein 
9986b301a05SRhyland Klein /*
9996b301a05SRhyland Klein  * PLLP
10006b301a05SRhyland Klein  * VCO is exposed to the clock tree directly along with post-divider output.
10016b301a05SRhyland Klein  * Both VCO and post-divider output rates are fixed at 408MHz and 204MHz,
10026b301a05SRhyland Klein  * respectively.
10036b301a05SRhyland Klein  */
10046b301a05SRhyland Klein static void pllp_check_defaults(struct tegra_clk_pll *pll, bool enabled)
10056b301a05SRhyland Klein {
10066b301a05SRhyland Klein 	u32 val, mask;
10076b301a05SRhyland Klein 
10086b301a05SRhyland Klein 	/* Ignore lock enable (will be set), make sure not in IDDQ if enabled */
10096b301a05SRhyland Klein 	val = PLLP_MISC0_DEFAULT_VALUE & (~PLLP_MISC0_IDDQ);
10106b301a05SRhyland Klein 	mask = PLLP_MISC0_LOCK_ENABLE | PLLP_MISC0_LOCK_OVERRIDE;
10116b301a05SRhyland Klein 	if (!enabled)
10126b301a05SRhyland Klein 		mask |= PLLP_MISC0_IDDQ;
10136b301a05SRhyland Klein 	_pll_misc_chk_default(clk_base, pll->params, 0, val,
10146b301a05SRhyland Klein 			~mask & PLLP_MISC0_WRITE_MASK);
10156b301a05SRhyland Klein 
10166b301a05SRhyland Klein 	/* Ignore branch controls */
10176b301a05SRhyland Klein 	val = PLLP_MISC1_DEFAULT_VALUE;
10186b301a05SRhyland Klein 	mask = PLLP_MISC1_HSIO_EN | PLLP_MISC1_XUSB_EN;
10196b301a05SRhyland Klein 	_pll_misc_chk_default(clk_base, pll->params, 1, val,
10206b301a05SRhyland Klein 			~mask & PLLP_MISC1_WRITE_MASK);
10216b301a05SRhyland Klein }
10226b301a05SRhyland Klein 
1023fd360e20SJon Hunter static void tegra210_pllp_set_defaults(struct tegra_clk_pll *pllp)
10246b301a05SRhyland Klein {
10256b301a05SRhyland Klein 	u32 mask;
10266b301a05SRhyland Klein 	u32 val = readl_relaxed(clk_base + pllp->params->base_reg);
10276b301a05SRhyland Klein 
10286b301a05SRhyland Klein 	pllp->params->defaults_set = true;
10296b301a05SRhyland Klein 
10306b301a05SRhyland Klein 	if (val & PLL_ENABLE) {
10316b301a05SRhyland Klein 		pr_warn("PLL_P already enabled. Postponing set full defaults\n");
10326b301a05SRhyland Klein 
10336b301a05SRhyland Klein 		/*
10346b301a05SRhyland Klein 		 * PLL is ON: check if defaults already set, then set those
10356b301a05SRhyland Klein 		 * that can be updated in flight.
10366b301a05SRhyland Klein 		 */
10376b301a05SRhyland Klein 		pllp_check_defaults(pllp, true);
10386b301a05SRhyland Klein 
10396b301a05SRhyland Klein 		/* Enable lock detect */
10406b301a05SRhyland Klein 		val = readl_relaxed(clk_base + pllp->params->ext_misc_reg[0]);
10416b301a05SRhyland Klein 		mask = PLLP_MISC0_LOCK_ENABLE | PLLP_MISC0_LOCK_OVERRIDE;
10426b301a05SRhyland Klein 		val &= ~mask;
10436b301a05SRhyland Klein 		val |= PLLP_MISC0_DEFAULT_VALUE & mask;
10446b301a05SRhyland Klein 		writel_relaxed(val, clk_base + pllp->params->ext_misc_reg[0]);
10456b301a05SRhyland Klein 		udelay(1);
10466b301a05SRhyland Klein 
10476b301a05SRhyland Klein 		return;
10486b301a05SRhyland Klein 	}
10496b301a05SRhyland Klein 
10506b301a05SRhyland Klein 	/* set IDDQ, enable lock detect */
10516b301a05SRhyland Klein 	writel_relaxed(PLLP_MISC0_DEFAULT_VALUE,
10526b301a05SRhyland Klein 			clk_base + pllp->params->ext_misc_reg[0]);
10536b301a05SRhyland Klein 
10546b301a05SRhyland Klein 	/* Preserve branch control */
10556b301a05SRhyland Klein 	val = readl_relaxed(clk_base + pllp->params->ext_misc_reg[1]);
10566b301a05SRhyland Klein 	mask = PLLP_MISC1_HSIO_EN | PLLP_MISC1_XUSB_EN;
10576b301a05SRhyland Klein 	val &= mask;
10586b301a05SRhyland Klein 	val |= ~mask & PLLP_MISC1_DEFAULT_VALUE;
10596b301a05SRhyland Klein 	writel_relaxed(val, clk_base + pllp->params->ext_misc_reg[1]);
10606b301a05SRhyland Klein 	udelay(1);
10616b301a05SRhyland Klein }
10626b301a05SRhyland Klein 
10636b301a05SRhyland Klein /*
10646b301a05SRhyland Klein  * PLLU
10656b301a05SRhyland Klein  * VCO is exposed to the clock tree directly along with post-divider output.
10666b301a05SRhyland Klein  * Both VCO and post-divider output rates are fixed at 480MHz and 240MHz,
10676b301a05SRhyland Klein  * respectively.
10686b301a05SRhyland Klein  */
10696b301a05SRhyland Klein static void pllu_check_defaults(struct tegra_clk_pll *pll, bool hw_control)
10706b301a05SRhyland Klein {
10716b301a05SRhyland Klein 	u32 val, mask;
10726b301a05SRhyland Klein 
10736b301a05SRhyland Klein 	/* Ignore lock enable (will be set) and IDDQ if under h/w control */
10746b301a05SRhyland Klein 	val = PLLU_MISC0_DEFAULT_VALUE & (~PLLU_MISC0_IDDQ);
10756b301a05SRhyland Klein 	mask = PLLU_MISC0_LOCK_ENABLE | (hw_control ? PLLU_MISC0_IDDQ : 0);
10766b301a05SRhyland Klein 	_pll_misc_chk_default(clk_base, pll->params, 0, val,
10776b301a05SRhyland Klein 			~mask & PLLU_MISC0_WRITE_MASK);
10786b301a05SRhyland Klein 
10796b301a05SRhyland Klein 	val = PLLU_MISC1_DEFAULT_VALUE;
10806b301a05SRhyland Klein 	mask = PLLU_MISC1_LOCK_OVERRIDE;
10816b301a05SRhyland Klein 	_pll_misc_chk_default(clk_base, pll->params, 1, val,
10826b301a05SRhyland Klein 			~mask & PLLU_MISC1_WRITE_MASK);
10836b301a05SRhyland Klein }
10846b301a05SRhyland Klein 
1085fd360e20SJon Hunter static void tegra210_pllu_set_defaults(struct tegra_clk_pll *pllu)
10866b301a05SRhyland Klein {
10876b301a05SRhyland Klein 	u32 val = readl_relaxed(clk_base + pllu->params->base_reg);
10886b301a05SRhyland Klein 
10896b301a05SRhyland Klein 	pllu->params->defaults_set = true;
10906b301a05SRhyland Klein 
10916b301a05SRhyland Klein 	if (val & PLL_ENABLE) {
10926b301a05SRhyland Klein 		pr_warn("PLL_U already enabled. Postponing set full defaults\n");
10936b301a05SRhyland Klein 
10946b301a05SRhyland Klein 		/*
10956b301a05SRhyland Klein 		 * PLL is ON: check if defaults already set, then set those
10966b301a05SRhyland Klein 		 * that can be updated in flight.
10976b301a05SRhyland Klein 		 */
10986b301a05SRhyland Klein 		pllu_check_defaults(pllu, false);
10996b301a05SRhyland Klein 
11006b301a05SRhyland Klein 		/* Enable lock detect */
11016b301a05SRhyland Klein 		val = readl_relaxed(clk_base + pllu->params->ext_misc_reg[0]);
11026b301a05SRhyland Klein 		val &= ~PLLU_MISC0_LOCK_ENABLE;
11036b301a05SRhyland Klein 		val |= PLLU_MISC0_DEFAULT_VALUE & PLLU_MISC0_LOCK_ENABLE;
11046b301a05SRhyland Klein 		writel_relaxed(val, clk_base + pllu->params->ext_misc_reg[0]);
11056b301a05SRhyland Klein 
11066b301a05SRhyland Klein 		val = readl_relaxed(clk_base + pllu->params->ext_misc_reg[1]);
11076b301a05SRhyland Klein 		val &= ~PLLU_MISC1_LOCK_OVERRIDE;
11086b301a05SRhyland Klein 		val |= PLLU_MISC1_DEFAULT_VALUE & PLLU_MISC1_LOCK_OVERRIDE;
11096b301a05SRhyland Klein 		writel_relaxed(val, clk_base + pllu->params->ext_misc_reg[1]);
11106b301a05SRhyland Klein 		udelay(1);
11116b301a05SRhyland Klein 
11126b301a05SRhyland Klein 		return;
11136b301a05SRhyland Klein 	}
11146b301a05SRhyland Klein 
11156b301a05SRhyland Klein 	/* set IDDQ, enable lock detect */
11166b301a05SRhyland Klein 	writel_relaxed(PLLU_MISC0_DEFAULT_VALUE,
11176b301a05SRhyland Klein 			clk_base + pllu->params->ext_misc_reg[0]);
11186b301a05SRhyland Klein 	writel_relaxed(PLLU_MISC1_DEFAULT_VALUE,
11196b301a05SRhyland Klein 			clk_base + pllu->params->ext_misc_reg[1]);
11206b301a05SRhyland Klein 	udelay(1);
11216b301a05SRhyland Klein }
11226b301a05SRhyland Klein 
11236b301a05SRhyland Klein #define mask(w) ((1 << (w)) - 1)
11246b301a05SRhyland Klein #define divm_mask(p) mask(p->params->div_nmp->divm_width)
11256b301a05SRhyland Klein #define divn_mask(p) mask(p->params->div_nmp->divn_width)
11266b301a05SRhyland Klein #define divp_mask(p) (p->params->flags & TEGRA_PLLU ? PLLU_POST_DIVP_MASK :\
11276b301a05SRhyland Klein 		      mask(p->params->div_nmp->divp_width))
11286b301a05SRhyland Klein 
11296b301a05SRhyland Klein #define divm_shift(p) ((p)->params->div_nmp->divm_shift)
11306b301a05SRhyland Klein #define divn_shift(p) ((p)->params->div_nmp->divn_shift)
11316b301a05SRhyland Klein #define divp_shift(p) ((p)->params->div_nmp->divp_shift)
11326b301a05SRhyland Klein 
11336b301a05SRhyland Klein #define divm_mask_shifted(p) (divm_mask(p) << divm_shift(p))
11346b301a05SRhyland Klein #define divn_mask_shifted(p) (divn_mask(p) << divn_shift(p))
11356b301a05SRhyland Klein #define divp_mask_shifted(p) (divp_mask(p) << divp_shift(p))
11366b301a05SRhyland Klein 
11376b301a05SRhyland Klein #define PLL_LOCKDET_DELAY 2	/* Lock detection safety delays */
11386b301a05SRhyland Klein static int tegra210_wait_for_mask(struct tegra_clk_pll *pll,
11396b301a05SRhyland Klein 				  u32 reg, u32 mask)
11406b301a05SRhyland Klein {
11416b301a05SRhyland Klein 	int i;
11426b301a05SRhyland Klein 	u32 val = 0;
11436b301a05SRhyland Klein 
11446b301a05SRhyland Klein 	for (i = 0; i < pll->params->lock_delay / PLL_LOCKDET_DELAY + 1; i++) {
11456b301a05SRhyland Klein 		udelay(PLL_LOCKDET_DELAY);
11466b301a05SRhyland Klein 		val = readl_relaxed(clk_base + reg);
11476b301a05SRhyland Klein 		if ((val & mask) == mask) {
11486b301a05SRhyland Klein 			udelay(PLL_LOCKDET_DELAY);
11496b301a05SRhyland Klein 			return 0;
11506b301a05SRhyland Klein 		}
11516b301a05SRhyland Klein 	}
11526b301a05SRhyland Klein 	return -ETIMEDOUT;
11536b301a05SRhyland Klein }
11546b301a05SRhyland Klein 
11556b301a05SRhyland Klein static int tegra210_pllx_dyn_ramp(struct tegra_clk_pll *pllx,
11566b301a05SRhyland Klein 		struct tegra_clk_pll_freq_table *cfg)
11576b301a05SRhyland Klein {
11586b301a05SRhyland Klein 	u32 val, base, ndiv_new_mask;
11596b301a05SRhyland Klein 
11606b301a05SRhyland Klein 	ndiv_new_mask = (divn_mask(pllx) >> pllx->params->div_nmp->divn_shift)
11616b301a05SRhyland Klein 			 << PLLX_MISC2_NDIV_NEW_SHIFT;
11626b301a05SRhyland Klein 
11636b301a05SRhyland Klein 	val = readl_relaxed(clk_base + pllx->params->ext_misc_reg[2]);
11646b301a05SRhyland Klein 	val &= (~ndiv_new_mask);
11656b301a05SRhyland Klein 	val |= cfg->n << PLLX_MISC2_NDIV_NEW_SHIFT;
11666b301a05SRhyland Klein 	writel_relaxed(val, clk_base + pllx->params->ext_misc_reg[2]);
11676b301a05SRhyland Klein 	udelay(1);
11686b301a05SRhyland Klein 
11696b301a05SRhyland Klein 	val = readl_relaxed(clk_base + pllx->params->ext_misc_reg[2]);
11706b301a05SRhyland Klein 	val |= PLLX_MISC2_EN_DYNRAMP;
11716b301a05SRhyland Klein 	writel_relaxed(val, clk_base + pllx->params->ext_misc_reg[2]);
11726b301a05SRhyland Klein 	udelay(1);
11736b301a05SRhyland Klein 
11746b301a05SRhyland Klein 	tegra210_wait_for_mask(pllx, pllx->params->ext_misc_reg[2],
11756b301a05SRhyland Klein 			       PLLX_MISC2_DYNRAMP_DONE);
11766b301a05SRhyland Klein 
11776b301a05SRhyland Klein 	base = readl_relaxed(clk_base + pllx->params->base_reg) &
11786b301a05SRhyland Klein 		(~divn_mask_shifted(pllx));
11796b301a05SRhyland Klein 	base |= cfg->n << pllx->params->div_nmp->divn_shift;
11806b301a05SRhyland Klein 	writel_relaxed(base, clk_base + pllx->params->base_reg);
11816b301a05SRhyland Klein 	udelay(1);
11826b301a05SRhyland Klein 
11836b301a05SRhyland Klein 	val &= ~PLLX_MISC2_EN_DYNRAMP;
11846b301a05SRhyland Klein 	writel_relaxed(val, clk_base + pllx->params->ext_misc_reg[2]);
11856b301a05SRhyland Klein 	udelay(1);
11866b301a05SRhyland Klein 
11876b301a05SRhyland Klein 	pr_debug("%s: dynamic ramp to m = %u n = %u p = %u, Fout = %lu kHz\n",
11886b301a05SRhyland Klein 		 __clk_get_name(pllx->hw.clk), cfg->m, cfg->n, cfg->p,
11896b301a05SRhyland Klein 		 cfg->input_rate / cfg->m * cfg->n /
11906b301a05SRhyland Klein 		 pllx->params->pdiv_tohw[cfg->p].pdiv / 1000);
11916b301a05SRhyland Klein 
11926b301a05SRhyland Klein 	return 0;
11936b301a05SRhyland Klein }
11946b301a05SRhyland Klein 
11956b301a05SRhyland Klein /*
11966b301a05SRhyland Klein  * Common configuration for PLLs with fixed input divider policy:
11976b301a05SRhyland Klein  * - always set fixed M-value based on the reference rate
11986b301a05SRhyland Klein  * - always set P-value value 1:1 for output rates above VCO minimum, and
11996b301a05SRhyland Klein  *   choose minimum necessary P-value for output rates below VCO maximum
12006b301a05SRhyland Klein  * - calculate N-value based on selected M and P
12016b301a05SRhyland Klein  * - calculate SDM_DIN fractional part
12026b301a05SRhyland Klein  */
12036b301a05SRhyland Klein static int tegra210_pll_fixed_mdiv_cfg(struct clk_hw *hw,
12046b301a05SRhyland Klein 			       struct tegra_clk_pll_freq_table *cfg,
12056b301a05SRhyland Klein 			       unsigned long rate, unsigned long input_rate)
12066b301a05SRhyland Klein {
12076b301a05SRhyland Klein 	struct tegra_clk_pll *pll = to_clk_pll(hw);
12086b301a05SRhyland Klein 	struct tegra_clk_pll_params *params = pll->params;
12096b301a05SRhyland Klein 	int p;
12106b301a05SRhyland Klein 	unsigned long cf, p_rate;
12116b301a05SRhyland Klein 	u32 pdiv;
12126b301a05SRhyland Klein 
12136b301a05SRhyland Klein 	if (!rate)
12146b301a05SRhyland Klein 		return -EINVAL;
12156b301a05SRhyland Klein 
12166b301a05SRhyland Klein 	if (!(params->flags & TEGRA_PLL_VCO_OUT)) {
12176b301a05SRhyland Klein 		p = DIV_ROUND_UP(params->vco_min, rate);
12186b301a05SRhyland Klein 		p = params->round_p_to_pdiv(p, &pdiv);
12196b301a05SRhyland Klein 	} else {
12206b301a05SRhyland Klein 		p = rate >= params->vco_min ? 1 : -EINVAL;
12216b301a05SRhyland Klein 	}
12226b301a05SRhyland Klein 
12236b301a05SRhyland Klein 	if (IS_ERR_VALUE(p))
12246b301a05SRhyland Klein 		return -EINVAL;
12256b301a05SRhyland Klein 
12266b301a05SRhyland Klein 	cfg->m = tegra_pll_get_fixed_mdiv(hw, input_rate);
12276b301a05SRhyland Klein 	cfg->p = p;
12286b301a05SRhyland Klein 
12296b301a05SRhyland Klein 	/* Store P as HW value, as that is what is expected */
12306b301a05SRhyland Klein 	cfg->p = tegra_pll_p_div_to_hw(pll, cfg->p);
12316b301a05SRhyland Klein 
12326b301a05SRhyland Klein 	p_rate = rate * p;
12336b301a05SRhyland Klein 	if (p_rate > params->vco_max)
12346b301a05SRhyland Klein 		p_rate = params->vco_max;
12356b301a05SRhyland Klein 	cf = input_rate / cfg->m;
12366b301a05SRhyland Klein 	cfg->n = p_rate / cf;
12376b301a05SRhyland Klein 
12386b301a05SRhyland Klein 	cfg->sdm_data = 0;
12396b301a05SRhyland Klein 	if (params->sdm_ctrl_reg) {
12406b301a05SRhyland Klein 		unsigned long rem = p_rate - cf * cfg->n;
12416b301a05SRhyland Klein 		/* If ssc is enabled SDM enabled as well, even for integer n */
12426b301a05SRhyland Klein 		if (rem || params->ssc_ctrl_reg) {
12436b301a05SRhyland Klein 			u64 s = rem * PLL_SDM_COEFF;
12446b301a05SRhyland Klein 
12456b301a05SRhyland Klein 			do_div(s, cf);
12466b301a05SRhyland Klein 			s -= PLL_SDM_COEFF / 2;
12476b301a05SRhyland Klein 			cfg->sdm_data = sdin_din_to_data(s);
12486b301a05SRhyland Klein 		}
12496b301a05SRhyland Klein 	}
12506b301a05SRhyland Klein 
12516b301a05SRhyland Klein 	cfg->input_rate = input_rate;
12526b301a05SRhyland Klein 	cfg->output_rate = rate;
12536b301a05SRhyland Klein 
12546b301a05SRhyland Klein 	return 0;
12556b301a05SRhyland Klein }
12566b301a05SRhyland Klein 
12576b301a05SRhyland Klein /*
12586b301a05SRhyland Klein  * clk_pll_set_gain - set gain to m, n to calculate correct VCO rate
12596b301a05SRhyland Klein  *
12606b301a05SRhyland Klein  * @cfg: struct tegra_clk_pll_freq_table * cfg
12616b301a05SRhyland Klein  *
12626b301a05SRhyland Klein  * For Normal mode:
12636b301a05SRhyland Klein  *     Fvco = Fref * NDIV / MDIV
12646b301a05SRhyland Klein  *
12656b301a05SRhyland Klein  * For fractional mode:
12666b301a05SRhyland Klein  *     Fvco = Fref * (NDIV + 0.5 + SDM_DIN / PLL_SDM_COEFF) / MDIV
12676b301a05SRhyland Klein  */
12686b301a05SRhyland Klein static void tegra210_clk_pll_set_gain(struct tegra_clk_pll_freq_table *cfg)
12696b301a05SRhyland Klein {
12706b301a05SRhyland Klein 	cfg->n = cfg->n * PLL_SDM_COEFF + PLL_SDM_COEFF/2 +
12716b301a05SRhyland Klein 			sdin_data_to_din(cfg->sdm_data);
12726b301a05SRhyland Klein 	cfg->m *= PLL_SDM_COEFF;
12736b301a05SRhyland Klein }
12746b301a05SRhyland Klein 
1275fd360e20SJon Hunter static unsigned long
1276fd360e20SJon Hunter tegra210_clk_adjust_vco_min(struct tegra_clk_pll_params *params,
12776b301a05SRhyland Klein 			    unsigned long parent_rate)
12786b301a05SRhyland Klein {
12796b301a05SRhyland Klein 	unsigned long vco_min = params->vco_min;
12806b301a05SRhyland Klein 
12816b301a05SRhyland Klein 	params->vco_min += DIV_ROUND_UP(parent_rate, PLL_SDM_COEFF);
12826b301a05SRhyland Klein 	vco_min = min(vco_min, params->vco_min);
12836b301a05SRhyland Klein 
12846b301a05SRhyland Klein 	return vco_min;
12856b301a05SRhyland Klein }
12866b301a05SRhyland Klein 
12876b301a05SRhyland Klein static struct div_nmp pllx_nmp = {
12886b301a05SRhyland Klein 	.divm_shift = 0,
12896b301a05SRhyland Klein 	.divm_width = 8,
12906b301a05SRhyland Klein 	.divn_shift = 8,
12916b301a05SRhyland Klein 	.divn_width = 8,
12926b301a05SRhyland Klein 	.divp_shift = 20,
12936b301a05SRhyland Klein 	.divp_width = 5,
12946b301a05SRhyland Klein };
12956b301a05SRhyland Klein /*
12966b301a05SRhyland Klein  * PLL post divider maps - two types: quasi-linear and exponential
12976b301a05SRhyland Klein  * post divider.
12986b301a05SRhyland Klein  */
12996b301a05SRhyland Klein #define PLL_QLIN_PDIV_MAX	16
13006b301a05SRhyland Klein static const struct pdiv_map pll_qlin_pdiv_to_hw[] = {
13016b301a05SRhyland Klein 	{ .pdiv =  1, .hw_val =  0 },
13026b301a05SRhyland Klein 	{ .pdiv =  2, .hw_val =  1 },
13036b301a05SRhyland Klein 	{ .pdiv =  3, .hw_val =  2 },
13046b301a05SRhyland Klein 	{ .pdiv =  4, .hw_val =  3 },
13056b301a05SRhyland Klein 	{ .pdiv =  5, .hw_val =  4 },
13066b301a05SRhyland Klein 	{ .pdiv =  6, .hw_val =  5 },
13076b301a05SRhyland Klein 	{ .pdiv =  8, .hw_val =  6 },
13086b301a05SRhyland Klein 	{ .pdiv =  9, .hw_val =  7 },
13096b301a05SRhyland Klein 	{ .pdiv = 10, .hw_val =  8 },
13106b301a05SRhyland Klein 	{ .pdiv = 12, .hw_val =  9 },
13116b301a05SRhyland Klein 	{ .pdiv = 15, .hw_val = 10 },
13126b301a05SRhyland Klein 	{ .pdiv = 16, .hw_val = 11 },
13136b301a05SRhyland Klein 	{ .pdiv = 18, .hw_val = 12 },
13146b301a05SRhyland Klein 	{ .pdiv = 20, .hw_val = 13 },
13156b301a05SRhyland Klein 	{ .pdiv = 24, .hw_val = 14 },
13166b301a05SRhyland Klein 	{ .pdiv = 30, .hw_val = 15 },
13176b301a05SRhyland Klein 	{ .pdiv = 32, .hw_val = 16 },
13186b301a05SRhyland Klein };
13196b301a05SRhyland Klein 
13206b301a05SRhyland Klein static u32 pll_qlin_p_to_pdiv(u32 p, u32 *pdiv)
13216b301a05SRhyland Klein {
13226b301a05SRhyland Klein 	int i;
13236b301a05SRhyland Klein 
13246b301a05SRhyland Klein 	if (p) {
13256b301a05SRhyland Klein 		for (i = 0; i <= PLL_QLIN_PDIV_MAX; i++) {
13266b301a05SRhyland Klein 			if (p <= pll_qlin_pdiv_to_hw[i].pdiv) {
13276b301a05SRhyland Klein 				if (pdiv)
13286b301a05SRhyland Klein 					*pdiv = i;
13296b301a05SRhyland Klein 				return pll_qlin_pdiv_to_hw[i].pdiv;
13306b301a05SRhyland Klein 			}
13316b301a05SRhyland Klein 		}
13326b301a05SRhyland Klein 	}
13336b301a05SRhyland Klein 
13346b301a05SRhyland Klein 	return -EINVAL;
13356b301a05SRhyland Klein }
13366b301a05SRhyland Klein 
13376b301a05SRhyland Klein #define PLL_EXPO_PDIV_MAX	7
13386b301a05SRhyland Klein static const struct pdiv_map pll_expo_pdiv_to_hw[] = {
13396b301a05SRhyland Klein 	{ .pdiv =   1, .hw_val = 0 },
13406b301a05SRhyland Klein 	{ .pdiv =   2, .hw_val = 1 },
13416b301a05SRhyland Klein 	{ .pdiv =   4, .hw_val = 2 },
13426b301a05SRhyland Klein 	{ .pdiv =   8, .hw_val = 3 },
13436b301a05SRhyland Klein 	{ .pdiv =  16, .hw_val = 4 },
13446b301a05SRhyland Klein 	{ .pdiv =  32, .hw_val = 5 },
13456b301a05SRhyland Klein 	{ .pdiv =  64, .hw_val = 6 },
13466b301a05SRhyland Klein 	{ .pdiv = 128, .hw_val = 7 },
13476b301a05SRhyland Klein };
13486b301a05SRhyland Klein 
13496b301a05SRhyland Klein static u32 pll_expo_p_to_pdiv(u32 p, u32 *pdiv)
13506b301a05SRhyland Klein {
13516b301a05SRhyland Klein 	if (p) {
13526b301a05SRhyland Klein 		u32 i = fls(p);
13536b301a05SRhyland Klein 
13546b301a05SRhyland Klein 		if (i == ffs(p))
13556b301a05SRhyland Klein 			i--;
13566b301a05SRhyland Klein 
13576b301a05SRhyland Klein 		if (i <= PLL_EXPO_PDIV_MAX) {
13586b301a05SRhyland Klein 			if (pdiv)
13596b301a05SRhyland Klein 				*pdiv = i;
13606b301a05SRhyland Klein 			return 1 << i;
13616b301a05SRhyland Klein 		}
13626b301a05SRhyland Klein 	}
13636b301a05SRhyland Klein 	return -EINVAL;
13646b301a05SRhyland Klein }
13656b301a05SRhyland Klein 
13666b301a05SRhyland Klein static struct tegra_clk_pll_freq_table pll_x_freq_table[] = {
13676b301a05SRhyland Klein 	/* 1 GHz */
13686b301a05SRhyland Klein 	{ 12000000, 1000000000, 166, 1, 1, 0 }, /* actual: 996.0 MHz */
13696b301a05SRhyland Klein 	{ 13000000, 1000000000, 153, 1, 1, 0 }, /* actual: 994.0 MHz */
13706b301a05SRhyland Klein 	{ 38400000, 1000000000, 156, 3, 1, 0 }, /* actual: 998.4 MHz */
13716b301a05SRhyland Klein 	{        0,          0,   0, 0, 0, 0 },
13726b301a05SRhyland Klein };
13736b301a05SRhyland Klein 
13746b301a05SRhyland Klein static struct tegra_clk_pll_params pll_x_params = {
13756b301a05SRhyland Klein 	.input_min = 12000000,
13766b301a05SRhyland Klein 	.input_max = 800000000,
13776b301a05SRhyland Klein 	.cf_min = 12000000,
13786b301a05SRhyland Klein 	.cf_max = 38400000,
13796b301a05SRhyland Klein 	.vco_min = 1350000000,
13806b301a05SRhyland Klein 	.vco_max = 3000000000UL,
13816b301a05SRhyland Klein 	.base_reg = PLLX_BASE,
13826b301a05SRhyland Klein 	.misc_reg = PLLX_MISC0,
13836b301a05SRhyland Klein 	.lock_mask = PLL_BASE_LOCK,
13846b301a05SRhyland Klein 	.lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
13856b301a05SRhyland Klein 	.lock_delay = 300,
13866b301a05SRhyland Klein 	.ext_misc_reg[0] = PLLX_MISC0,
13876b301a05SRhyland Klein 	.ext_misc_reg[1] = PLLX_MISC1,
13886b301a05SRhyland Klein 	.ext_misc_reg[2] = PLLX_MISC2,
13896b301a05SRhyland Klein 	.ext_misc_reg[3] = PLLX_MISC3,
13906b301a05SRhyland Klein 	.ext_misc_reg[4] = PLLX_MISC4,
13916b301a05SRhyland Klein 	.ext_misc_reg[5] = PLLX_MISC5,
13926b301a05SRhyland Klein 	.iddq_reg = PLLX_MISC3,
13936b301a05SRhyland Klein 	.iddq_bit_idx = PLLXP_IDDQ_BIT,
13946b301a05SRhyland Klein 	.max_p = PLL_QLIN_PDIV_MAX,
13956b301a05SRhyland Klein 	.mdiv_default = 2,
13966b301a05SRhyland Klein 	.dyn_ramp_reg = PLLX_MISC2,
13976b301a05SRhyland Klein 	.stepa_shift = 16,
13986b301a05SRhyland Klein 	.stepb_shift = 24,
13996b301a05SRhyland Klein 	.round_p_to_pdiv = pll_qlin_p_to_pdiv,
14006b301a05SRhyland Klein 	.pdiv_tohw = pll_qlin_pdiv_to_hw,
14016b301a05SRhyland Klein 	.div_nmp = &pllx_nmp,
14026b301a05SRhyland Klein 	.freq_table = pll_x_freq_table,
14036b301a05SRhyland Klein 	.flags = TEGRA_PLL_USE_LOCK | TEGRA_PLL_HAS_LOCK_ENABLE,
14046b301a05SRhyland Klein 	.dyn_ramp = tegra210_pllx_dyn_ramp,
14056b301a05SRhyland Klein 	.set_defaults = tegra210_pllx_set_defaults,
14066b301a05SRhyland Klein 	.calc_rate = tegra210_pll_fixed_mdiv_cfg,
14076b301a05SRhyland Klein };
14086b301a05SRhyland Klein 
14096b301a05SRhyland Klein static struct div_nmp pllc_nmp = {
14106b301a05SRhyland Klein 	.divm_shift = 0,
14116b301a05SRhyland Klein 	.divm_width = 8,
14126b301a05SRhyland Klein 	.divn_shift = 10,
14136b301a05SRhyland Klein 	.divn_width = 8,
14146b301a05SRhyland Klein 	.divp_shift = 20,
14156b301a05SRhyland Klein 	.divp_width = 5,
14166b301a05SRhyland Klein };
14176b301a05SRhyland Klein 
14186b301a05SRhyland Klein static struct tegra_clk_pll_freq_table pll_cx_freq_table[] = {
14196b301a05SRhyland Klein 	{ 12000000, 510000000, 85, 1, 1, 0 },
14206b301a05SRhyland Klein 	{ 13000000, 510000000, 78, 1, 1, 0 }, /* actual: 507.0 MHz */
14216b301a05SRhyland Klein 	{ 38400000, 510000000, 79, 3, 1, 0 }, /* actual: 505.6 MHz */
14226b301a05SRhyland Klein 	{        0,         0,  0, 0, 0, 0 },
14236b301a05SRhyland Klein };
14246b301a05SRhyland Klein 
14256b301a05SRhyland Klein static struct tegra_clk_pll_params pll_c_params = {
14266b301a05SRhyland Klein 	.input_min = 12000000,
14276b301a05SRhyland Klein 	.input_max = 700000000,
14286b301a05SRhyland Klein 	.cf_min = 12000000,
14296b301a05SRhyland Klein 	.cf_max = 50000000,
14306b301a05SRhyland Klein 	.vco_min = 600000000,
14316b301a05SRhyland Klein 	.vco_max = 1200000000,
14326b301a05SRhyland Klein 	.base_reg = PLLC_BASE,
14336b301a05SRhyland Klein 	.misc_reg = PLLC_MISC0,
14346b301a05SRhyland Klein 	.lock_mask = PLL_BASE_LOCK,
14356b301a05SRhyland Klein 	.lock_delay = 300,
14366b301a05SRhyland Klein 	.iddq_reg = PLLC_MISC1,
14376b301a05SRhyland Klein 	.iddq_bit_idx = PLLCX_IDDQ_BIT,
14386b301a05SRhyland Klein 	.reset_reg = PLLC_MISC0,
14396b301a05SRhyland Klein 	.reset_bit_idx = PLLCX_RESET_BIT,
14406b301a05SRhyland Klein 	.max_p = PLL_QLIN_PDIV_MAX,
14416b301a05SRhyland Klein 	.ext_misc_reg[0] = PLLC_MISC0,
14426b301a05SRhyland Klein 	.ext_misc_reg[1] = PLLC_MISC1,
14436b301a05SRhyland Klein 	.ext_misc_reg[2] = PLLC_MISC2,
14446b301a05SRhyland Klein 	.ext_misc_reg[3] = PLLC_MISC3,
14456b301a05SRhyland Klein 	.round_p_to_pdiv = pll_qlin_p_to_pdiv,
14466b301a05SRhyland Klein 	.pdiv_tohw = pll_qlin_pdiv_to_hw,
14476b301a05SRhyland Klein 	.mdiv_default = 3,
14486b301a05SRhyland Klein 	.div_nmp = &pllc_nmp,
14496b301a05SRhyland Klein 	.freq_table = pll_cx_freq_table,
145014050118SRhyland Klein 	.flags = TEGRA_PLL_USE_LOCK,
14516b301a05SRhyland Klein 	.set_defaults = _pllc_set_defaults,
14526b301a05SRhyland Klein 	.calc_rate = tegra210_pll_fixed_mdiv_cfg,
14536b301a05SRhyland Klein };
14546b301a05SRhyland Klein 
14556b301a05SRhyland Klein static struct div_nmp pllcx_nmp = {
14566b301a05SRhyland Klein 	.divm_shift = 0,
14576b301a05SRhyland Klein 	.divm_width = 8,
14586b301a05SRhyland Klein 	.divn_shift = 10,
14596b301a05SRhyland Klein 	.divn_width = 8,
14606b301a05SRhyland Klein 	.divp_shift = 20,
14616b301a05SRhyland Klein 	.divp_width = 5,
14626b301a05SRhyland Klein };
14636b301a05SRhyland Klein 
14646b301a05SRhyland Klein static struct tegra_clk_pll_params pll_c2_params = {
14656b301a05SRhyland Klein 	.input_min = 12000000,
14666b301a05SRhyland Klein 	.input_max = 700000000,
14676b301a05SRhyland Klein 	.cf_min = 12000000,
14686b301a05SRhyland Klein 	.cf_max = 50000000,
14696b301a05SRhyland Klein 	.vco_min = 600000000,
14706b301a05SRhyland Klein 	.vco_max = 1200000000,
14716b301a05SRhyland Klein 	.base_reg = PLLC2_BASE,
14726b301a05SRhyland Klein 	.misc_reg = PLLC2_MISC0,
14736b301a05SRhyland Klein 	.iddq_reg = PLLC2_MISC1,
14746b301a05SRhyland Klein 	.iddq_bit_idx = PLLCX_IDDQ_BIT,
14756b301a05SRhyland Klein 	.reset_reg = PLLC2_MISC0,
14766b301a05SRhyland Klein 	.reset_bit_idx = PLLCX_RESET_BIT,
14776b301a05SRhyland Klein 	.lock_mask = PLLCX_BASE_LOCK,
14786b301a05SRhyland Klein 	.lock_delay = 300,
14796b301a05SRhyland Klein 	.round_p_to_pdiv = pll_qlin_p_to_pdiv,
14806b301a05SRhyland Klein 	.pdiv_tohw = pll_qlin_pdiv_to_hw,
14816b301a05SRhyland Klein 	.mdiv_default = 3,
14826b301a05SRhyland Klein 	.div_nmp = &pllcx_nmp,
14836b301a05SRhyland Klein 	.max_p = PLL_QLIN_PDIV_MAX,
14846b301a05SRhyland Klein 	.ext_misc_reg[0] = PLLC2_MISC0,
14856b301a05SRhyland Klein 	.ext_misc_reg[1] = PLLC2_MISC1,
14866b301a05SRhyland Klein 	.ext_misc_reg[2] = PLLC2_MISC2,
14876b301a05SRhyland Klein 	.ext_misc_reg[3] = PLLC2_MISC3,
14886b301a05SRhyland Klein 	.freq_table = pll_cx_freq_table,
148914050118SRhyland Klein 	.flags = TEGRA_PLL_USE_LOCK,
14906b301a05SRhyland Klein 	.set_defaults = _pllc2_set_defaults,
14916b301a05SRhyland Klein 	.calc_rate = tegra210_pll_fixed_mdiv_cfg,
14926b301a05SRhyland Klein };
14936b301a05SRhyland Klein 
14946b301a05SRhyland Klein static struct tegra_clk_pll_params pll_c3_params = {
14956b301a05SRhyland Klein 	.input_min = 12000000,
14966b301a05SRhyland Klein 	.input_max = 700000000,
14976b301a05SRhyland Klein 	.cf_min = 12000000,
14986b301a05SRhyland Klein 	.cf_max = 50000000,
14996b301a05SRhyland Klein 	.vco_min = 600000000,
15006b301a05SRhyland Klein 	.vco_max = 1200000000,
15016b301a05SRhyland Klein 	.base_reg = PLLC3_BASE,
15026b301a05SRhyland Klein 	.misc_reg = PLLC3_MISC0,
15036b301a05SRhyland Klein 	.lock_mask = PLLCX_BASE_LOCK,
15046b301a05SRhyland Klein 	.lock_delay = 300,
15056b301a05SRhyland Klein 	.iddq_reg = PLLC3_MISC1,
15066b301a05SRhyland Klein 	.iddq_bit_idx = PLLCX_IDDQ_BIT,
15076b301a05SRhyland Klein 	.reset_reg = PLLC3_MISC0,
15086b301a05SRhyland Klein 	.reset_bit_idx = PLLCX_RESET_BIT,
15096b301a05SRhyland Klein 	.round_p_to_pdiv = pll_qlin_p_to_pdiv,
15106b301a05SRhyland Klein 	.pdiv_tohw = pll_qlin_pdiv_to_hw,
15116b301a05SRhyland Klein 	.mdiv_default = 3,
15126b301a05SRhyland Klein 	.div_nmp = &pllcx_nmp,
15136b301a05SRhyland Klein 	.max_p = PLL_QLIN_PDIV_MAX,
15146b301a05SRhyland Klein 	.ext_misc_reg[0] = PLLC3_MISC0,
15156b301a05SRhyland Klein 	.ext_misc_reg[1] = PLLC3_MISC1,
15166b301a05SRhyland Klein 	.ext_misc_reg[2] = PLLC3_MISC2,
15176b301a05SRhyland Klein 	.ext_misc_reg[3] = PLLC3_MISC3,
15186b301a05SRhyland Klein 	.freq_table = pll_cx_freq_table,
151914050118SRhyland Klein 	.flags = TEGRA_PLL_USE_LOCK,
15206b301a05SRhyland Klein 	.set_defaults = _pllc3_set_defaults,
15216b301a05SRhyland Klein 	.calc_rate = tegra210_pll_fixed_mdiv_cfg,
15226b301a05SRhyland Klein };
15236b301a05SRhyland Klein 
15246b301a05SRhyland Klein static struct div_nmp pllss_nmp = {
15256b301a05SRhyland Klein 	.divm_shift = 0,
15266b301a05SRhyland Klein 	.divm_width = 8,
15276b301a05SRhyland Klein 	.divn_shift = 8,
15286b301a05SRhyland Klein 	.divn_width = 8,
15296b301a05SRhyland Klein 	.divp_shift = 19,
15306b301a05SRhyland Klein 	.divp_width = 5,
15316b301a05SRhyland Klein };
15326b301a05SRhyland Klein 
15336b301a05SRhyland Klein static struct tegra_clk_pll_freq_table pll_c4_vco_freq_table[] = {
15346b301a05SRhyland Klein 	{ 12000000, 600000000, 50, 1, 0, 0 },
15356b301a05SRhyland Klein 	{ 13000000, 600000000, 46, 1, 0, 0 }, /* actual: 598.0 MHz */
15366b301a05SRhyland Klein 	{ 38400000, 600000000, 62, 4, 0, 0 }, /* actual: 595.2 MHz */
15376b301a05SRhyland Klein 	{        0,         0,  0, 0, 0, 0 },
15386b301a05SRhyland Klein };
15396b301a05SRhyland Klein 
15406b301a05SRhyland Klein static const struct clk_div_table pll_vco_post_div_table[] = {
15416b301a05SRhyland Klein 	{ .val =  0, .div =  1 },
15426b301a05SRhyland Klein 	{ .val =  1, .div =  2 },
15436b301a05SRhyland Klein 	{ .val =  2, .div =  3 },
15446b301a05SRhyland Klein 	{ .val =  3, .div =  4 },
15456b301a05SRhyland Klein 	{ .val =  4, .div =  5 },
15466b301a05SRhyland Klein 	{ .val =  5, .div =  6 },
15476b301a05SRhyland Klein 	{ .val =  6, .div =  8 },
15486b301a05SRhyland Klein 	{ .val =  7, .div = 10 },
15496b301a05SRhyland Klein 	{ .val =  8, .div = 12 },
15506b301a05SRhyland Klein 	{ .val =  9, .div = 16 },
15516b301a05SRhyland Klein 	{ .val = 10, .div = 12 },
15526b301a05SRhyland Klein 	{ .val = 11, .div = 16 },
15536b301a05SRhyland Klein 	{ .val = 12, .div = 20 },
15546b301a05SRhyland Klein 	{ .val = 13, .div = 24 },
15556b301a05SRhyland Klein 	{ .val = 14, .div = 32 },
15566b301a05SRhyland Klein 	{ .val =  0, .div =  0 },
15576b301a05SRhyland Klein };
15586b301a05SRhyland Klein 
15596b301a05SRhyland Klein static struct tegra_clk_pll_params pll_c4_vco_params = {
15606b301a05SRhyland Klein 	.input_min = 9600000,
15616b301a05SRhyland Klein 	.input_max = 800000000,
15626b301a05SRhyland Klein 	.cf_min = 9600000,
15636b301a05SRhyland Klein 	.cf_max = 19200000,
15646b301a05SRhyland Klein 	.vco_min = 500000000,
15656b301a05SRhyland Klein 	.vco_max = 1080000000,
15666b301a05SRhyland Klein 	.base_reg = PLLC4_BASE,
15676b301a05SRhyland Klein 	.misc_reg = PLLC4_MISC0,
15686b301a05SRhyland Klein 	.lock_mask = PLL_BASE_LOCK,
15696b301a05SRhyland Klein 	.lock_delay = 300,
15706b301a05SRhyland Klein 	.max_p = PLL_QLIN_PDIV_MAX,
15716b301a05SRhyland Klein 	.ext_misc_reg[0] = PLLC4_MISC0,
15726b301a05SRhyland Klein 	.iddq_reg = PLLC4_BASE,
15736b301a05SRhyland Klein 	.iddq_bit_idx = PLLSS_IDDQ_BIT,
15746b301a05SRhyland Klein 	.round_p_to_pdiv = pll_qlin_p_to_pdiv,
15756b301a05SRhyland Klein 	.pdiv_tohw = pll_qlin_pdiv_to_hw,
15766b301a05SRhyland Klein 	.mdiv_default = 3,
15776b301a05SRhyland Klein 	.div_nmp = &pllss_nmp,
15786b301a05SRhyland Klein 	.freq_table = pll_c4_vco_freq_table,
15796b301a05SRhyland Klein 	.set_defaults = tegra210_pllc4_set_defaults,
158014050118SRhyland Klein 	.flags = TEGRA_PLL_USE_LOCK | TEGRA_PLL_VCO_OUT,
15816b301a05SRhyland Klein 	.calc_rate = tegra210_pll_fixed_mdiv_cfg,
15826b301a05SRhyland Klein };
15836b301a05SRhyland Klein 
15846b301a05SRhyland Klein static struct tegra_clk_pll_freq_table pll_m_freq_table[] = {
15856b301a05SRhyland Klein 	{ 12000000,  800000000,  66, 1, 0, 0 }, /* actual: 792.0 MHz */
15866b301a05SRhyland Klein 	{ 13000000,  800000000,  61, 1, 0, 0 }, /* actual: 793.0 MHz */
15876b301a05SRhyland Klein 	{ 38400000,  297600000,  93, 4, 2, 0 },
15886b301a05SRhyland Klein 	{ 38400000,  400000000, 125, 4, 2, 0 },
15896b301a05SRhyland Klein 	{ 38400000,  532800000, 111, 4, 1, 0 },
15906b301a05SRhyland Klein 	{ 38400000,  665600000, 104, 3, 1, 0 },
15916b301a05SRhyland Klein 	{ 38400000,  800000000, 125, 3, 1, 0 },
15926b301a05SRhyland Klein 	{ 38400000,  931200000,  97, 4, 0, 0 },
15936b301a05SRhyland Klein 	{ 38400000, 1065600000, 111, 4, 0, 0 },
15946b301a05SRhyland Klein 	{ 38400000, 1200000000, 125, 4, 0, 0 },
15956b301a05SRhyland Klein 	{ 38400000, 1331200000, 104, 3, 0, 0 },
15966b301a05SRhyland Klein 	{ 38400000, 1459200000,  76, 2, 0, 0 },
15976b301a05SRhyland Klein 	{ 38400000, 1600000000, 125, 3, 0, 0 },
15986b301a05SRhyland Klein 	{        0,          0,   0, 0, 0, 0 },
15996b301a05SRhyland Klein };
16006b301a05SRhyland Klein 
16016b301a05SRhyland Klein static struct div_nmp pllm_nmp = {
16026b301a05SRhyland Klein 	.divm_shift = 0,
16036b301a05SRhyland Klein 	.divm_width = 8,
16046b301a05SRhyland Klein 	.override_divm_shift = 0,
16056b301a05SRhyland Klein 	.divn_shift = 8,
16066b301a05SRhyland Klein 	.divn_width = 8,
16076b301a05SRhyland Klein 	.override_divn_shift = 8,
16086b301a05SRhyland Klein 	.divp_shift = 20,
16096b301a05SRhyland Klein 	.divp_width = 5,
16106b301a05SRhyland Klein 	.override_divp_shift = 27,
16116b301a05SRhyland Klein };
16126b301a05SRhyland Klein 
16136b301a05SRhyland Klein static struct tegra_clk_pll_params pll_m_params = {
16146b301a05SRhyland Klein 	.input_min = 9600000,
16156b301a05SRhyland Klein 	.input_max = 500000000,
16166b301a05SRhyland Klein 	.cf_min = 9600000,
16176b301a05SRhyland Klein 	.cf_max = 19200000,
16186b301a05SRhyland Klein 	.vco_min = 800000000,
16196b301a05SRhyland Klein 	.vco_max = 1866000000,
16206b301a05SRhyland Klein 	.base_reg = PLLM_BASE,
1621474f2ba2SRhyland Klein 	.misc_reg = PLLM_MISC2,
16226b301a05SRhyland Klein 	.lock_mask = PLL_BASE_LOCK,
16236b301a05SRhyland Klein 	.lock_enable_bit_idx = PLLM_MISC_LOCK_ENABLE,
16246b301a05SRhyland Klein 	.lock_delay = 300,
1625474f2ba2SRhyland Klein 	.iddq_reg = PLLM_MISC2,
16266b301a05SRhyland Klein 	.iddq_bit_idx = PLLM_IDDQ_BIT,
16276b301a05SRhyland Klein 	.max_p = PLL_QLIN_PDIV_MAX,
1628474f2ba2SRhyland Klein 	.ext_misc_reg[0] = PLLM_MISC2,
1629d9e65791SJon Hunter 	.ext_misc_reg[1] = PLLM_MISC1,
16306b301a05SRhyland Klein 	.round_p_to_pdiv = pll_qlin_p_to_pdiv,
16316b301a05SRhyland Klein 	.pdiv_tohw = pll_qlin_pdiv_to_hw,
16326b301a05SRhyland Klein 	.div_nmp = &pllm_nmp,
16336b301a05SRhyland Klein 	.pmc_divnm_reg = PMC_PLLM_WB0_OVERRIDE,
16346b301a05SRhyland Klein 	.pmc_divp_reg = PMC_PLLM_WB0_OVERRIDE_2,
16356b301a05SRhyland Klein 	.freq_table = pll_m_freq_table,
16366b301a05SRhyland Klein 	.flags = TEGRA_PLL_USE_LOCK | TEGRA_PLL_HAS_LOCK_ENABLE,
16376b301a05SRhyland Klein 	.calc_rate = tegra210_pll_fixed_mdiv_cfg,
16386b301a05SRhyland Klein };
16396b301a05SRhyland Klein 
16406b301a05SRhyland Klein static struct tegra_clk_pll_params pll_mb_params = {
16416b301a05SRhyland Klein 	.input_min = 9600000,
16426b301a05SRhyland Klein 	.input_max = 500000000,
16436b301a05SRhyland Klein 	.cf_min = 9600000,
16446b301a05SRhyland Klein 	.cf_max = 19200000,
16456b301a05SRhyland Klein 	.vco_min = 800000000,
16466b301a05SRhyland Klein 	.vco_max = 1866000000,
16476b301a05SRhyland Klein 	.base_reg = PLLMB_BASE,
1648474f2ba2SRhyland Klein 	.misc_reg = PLLMB_MISC1,
16496b301a05SRhyland Klein 	.lock_mask = PLL_BASE_LOCK,
16506b301a05SRhyland Klein 	.lock_delay = 300,
1651474f2ba2SRhyland Klein 	.iddq_reg = PLLMB_MISC1,
16526b301a05SRhyland Klein 	.iddq_bit_idx = PLLMB_IDDQ_BIT,
16536b301a05SRhyland Klein 	.max_p = PLL_QLIN_PDIV_MAX,
1654474f2ba2SRhyland Klein 	.ext_misc_reg[0] = PLLMB_MISC1,
16556b301a05SRhyland Klein 	.round_p_to_pdiv = pll_qlin_p_to_pdiv,
16566b301a05SRhyland Klein 	.pdiv_tohw = pll_qlin_pdiv_to_hw,
16576b301a05SRhyland Klein 	.div_nmp = &pllm_nmp,
16586b301a05SRhyland Klein 	.freq_table = pll_m_freq_table,
165914050118SRhyland Klein 	.flags = TEGRA_PLL_USE_LOCK,
16606b301a05SRhyland Klein 	.set_defaults = tegra210_pllmb_set_defaults,
16616b301a05SRhyland Klein 	.calc_rate = tegra210_pll_fixed_mdiv_cfg,
16626b301a05SRhyland Klein };
16636b301a05SRhyland Klein 
16646b301a05SRhyland Klein 
16656b301a05SRhyland Klein static struct tegra_clk_pll_freq_table pll_e_freq_table[] = {
16666b301a05SRhyland Klein 	/* PLLE special case: use cpcon field to store cml divider value */
16676b301a05SRhyland Klein 	{ 672000000, 100000000, 125, 42, 0, 13 },
16686b301a05SRhyland Klein 	{ 624000000, 100000000, 125, 39, 0, 13 },
16696b301a05SRhyland Klein 	{ 336000000, 100000000, 125, 21, 0, 13 },
16706b301a05SRhyland Klein 	{ 312000000, 100000000, 200, 26, 0, 14 },
16716b301a05SRhyland Klein 	{  38400000, 100000000, 125,  2, 0, 14 },
16726b301a05SRhyland Klein 	{  12000000, 100000000, 200,  1, 0, 14 },
16736b301a05SRhyland Klein 	{         0,         0,   0,  0, 0,  0 },
16746b301a05SRhyland Klein };
16756b301a05SRhyland Klein 
16766b301a05SRhyland Klein static struct div_nmp plle_nmp = {
16776b301a05SRhyland Klein 	.divm_shift = 0,
16786b301a05SRhyland Klein 	.divm_width = 8,
16796b301a05SRhyland Klein 	.divn_shift = 8,
16806b301a05SRhyland Klein 	.divn_width = 8,
16816b301a05SRhyland Klein 	.divp_shift = 24,
16826b301a05SRhyland Klein 	.divp_width = 5,
16836b301a05SRhyland Klein };
16846b301a05SRhyland Klein 
16856b301a05SRhyland Klein static struct tegra_clk_pll_params pll_e_params = {
16866b301a05SRhyland Klein 	.input_min = 12000000,
16876b301a05SRhyland Klein 	.input_max = 800000000,
16886b301a05SRhyland Klein 	.cf_min = 12000000,
16896b301a05SRhyland Klein 	.cf_max = 38400000,
16906b301a05SRhyland Klein 	.vco_min = 1600000000,
16916b301a05SRhyland Klein 	.vco_max = 2500000000U,
16926b301a05SRhyland Klein 	.base_reg = PLLE_BASE,
16936b301a05SRhyland Klein 	.misc_reg = PLLE_MISC0,
16946b301a05SRhyland Klein 	.aux_reg = PLLE_AUX,
16956b301a05SRhyland Klein 	.lock_mask = PLLE_MISC_LOCK,
16966b301a05SRhyland Klein 	.lock_enable_bit_idx = PLLE_MISC_LOCK_ENABLE,
16976b301a05SRhyland Klein 	.lock_delay = 300,
16986b301a05SRhyland Klein 	.div_nmp = &plle_nmp,
16996b301a05SRhyland Klein 	.freq_table = pll_e_freq_table,
17006b301a05SRhyland Klein 	.flags = TEGRA_PLL_FIXED | TEGRA_PLL_LOCK_MISC | TEGRA_PLL_USE_LOCK |
17016b301a05SRhyland Klein 		 TEGRA_PLL_HAS_LOCK_ENABLE,
17026b301a05SRhyland Klein 	.fixed_rate = 100000000,
17036b301a05SRhyland Klein 	.calc_rate = tegra210_pll_fixed_mdiv_cfg,
17046b301a05SRhyland Klein };
17056b301a05SRhyland Klein 
17066b301a05SRhyland Klein static struct tegra_clk_pll_freq_table pll_re_vco_freq_table[] = {
17076b301a05SRhyland Klein 	{ 12000000, 672000000, 56, 1, 0, 0 },
17086b301a05SRhyland Klein 	{ 13000000, 672000000, 51, 1, 0, 0 }, /* actual: 663.0 MHz */
17096b301a05SRhyland Klein 	{ 38400000, 672000000, 70, 4, 0, 0 },
17106b301a05SRhyland Klein 	{        0,         0,  0, 0, 0, 0 },
17116b301a05SRhyland Klein };
17126b301a05SRhyland Klein 
17136b301a05SRhyland Klein static struct div_nmp pllre_nmp = {
17146b301a05SRhyland Klein 	.divm_shift = 0,
17156b301a05SRhyland Klein 	.divm_width = 8,
17166b301a05SRhyland Klein 	.divn_shift = 8,
17176b301a05SRhyland Klein 	.divn_width = 8,
17186b301a05SRhyland Klein 	.divp_shift = 16,
17196b301a05SRhyland Klein 	.divp_width = 5,
17206b301a05SRhyland Klein };
17216b301a05SRhyland Klein 
17226b301a05SRhyland Klein static struct tegra_clk_pll_params pll_re_vco_params = {
17236b301a05SRhyland Klein 	.input_min = 9600000,
17246b301a05SRhyland Klein 	.input_max = 800000000,
17256b301a05SRhyland Klein 	.cf_min = 9600000,
17266b301a05SRhyland Klein 	.cf_max = 19200000,
17276b301a05SRhyland Klein 	.vco_min = 350000000,
17286b301a05SRhyland Klein 	.vco_max = 700000000,
17296b301a05SRhyland Klein 	.base_reg = PLLRE_BASE,
17306b301a05SRhyland Klein 	.misc_reg = PLLRE_MISC0,
17316b301a05SRhyland Klein 	.lock_mask = PLLRE_MISC_LOCK,
17326b301a05SRhyland Klein 	.lock_delay = 300,
17336b301a05SRhyland Klein 	.max_p = PLL_QLIN_PDIV_MAX,
17346b301a05SRhyland Klein 	.ext_misc_reg[0] = PLLRE_MISC0,
17356b301a05SRhyland Klein 	.iddq_reg = PLLRE_MISC0,
17366b301a05SRhyland Klein 	.iddq_bit_idx = PLLRE_IDDQ_BIT,
17376b301a05SRhyland Klein 	.round_p_to_pdiv = pll_qlin_p_to_pdiv,
17386b301a05SRhyland Klein 	.pdiv_tohw = pll_qlin_pdiv_to_hw,
17396b301a05SRhyland Klein 	.div_nmp = &pllre_nmp,
17406b301a05SRhyland Klein 	.freq_table = pll_re_vco_freq_table,
174114050118SRhyland Klein 	.flags = TEGRA_PLL_USE_LOCK | TEGRA_PLL_LOCK_MISC | TEGRA_PLL_VCO_OUT,
17426b301a05SRhyland Klein 	.set_defaults = tegra210_pllre_set_defaults,
17436b301a05SRhyland Klein 	.calc_rate = tegra210_pll_fixed_mdiv_cfg,
17446b301a05SRhyland Klein };
17456b301a05SRhyland Klein 
17466b301a05SRhyland Klein static struct div_nmp pllp_nmp = {
17476b301a05SRhyland Klein 	.divm_shift = 0,
17486b301a05SRhyland Klein 	.divm_width = 8,
17496b301a05SRhyland Klein 	.divn_shift = 10,
17506b301a05SRhyland Klein 	.divn_width = 8,
17516b301a05SRhyland Klein 	.divp_shift = 20,
17526b301a05SRhyland Klein 	.divp_width = 5,
17536b301a05SRhyland Klein };
17546b301a05SRhyland Klein 
17556b301a05SRhyland Klein static struct tegra_clk_pll_freq_table pll_p_freq_table[] = {
17566b301a05SRhyland Klein 	{ 12000000, 408000000, 34, 1, 0, 0 },
17576b301a05SRhyland Klein 	{ 38400000, 408000000, 85, 8, 0, 0 }, /* cf = 4.8MHz, allowed exception */
17586b301a05SRhyland Klein 	{        0,         0,  0, 0, 0, 0 },
17596b301a05SRhyland Klein };
17606b301a05SRhyland Klein 
17616b301a05SRhyland Klein static struct tegra_clk_pll_params pll_p_params = {
17626b301a05SRhyland Klein 	.input_min = 9600000,
17636b301a05SRhyland Klein 	.input_max = 800000000,
17646b301a05SRhyland Klein 	.cf_min = 9600000,
17656b301a05SRhyland Klein 	.cf_max = 19200000,
17666b301a05SRhyland Klein 	.vco_min = 350000000,
17676b301a05SRhyland Klein 	.vco_max = 700000000,
17686b301a05SRhyland Klein 	.base_reg = PLLP_BASE,
17696b301a05SRhyland Klein 	.misc_reg = PLLP_MISC0,
17706b301a05SRhyland Klein 	.lock_mask = PLL_BASE_LOCK,
17716b301a05SRhyland Klein 	.lock_delay = 300,
17726b301a05SRhyland Klein 	.iddq_reg = PLLP_MISC0,
17736b301a05SRhyland Klein 	.iddq_bit_idx = PLLXP_IDDQ_BIT,
17746b301a05SRhyland Klein 	.ext_misc_reg[0] = PLLP_MISC0,
17756b301a05SRhyland Klein 	.ext_misc_reg[1] = PLLP_MISC1,
17766b301a05SRhyland Klein 	.div_nmp = &pllp_nmp,
17776b301a05SRhyland Klein 	.freq_table = pll_p_freq_table,
17786b301a05SRhyland Klein 	.fixed_rate = 408000000,
177914050118SRhyland Klein 	.flags = TEGRA_PLL_FIXED | TEGRA_PLL_USE_LOCK | TEGRA_PLL_VCO_OUT,
17806b301a05SRhyland Klein 	.set_defaults = tegra210_pllp_set_defaults,
17816b301a05SRhyland Klein 	.calc_rate = tegra210_pll_fixed_mdiv_cfg,
17826b301a05SRhyland Klein };
17836b301a05SRhyland Klein 
17846b301a05SRhyland Klein static struct tegra_clk_pll_params pll_a1_params = {
17856b301a05SRhyland Klein 	.input_min = 12000000,
17866b301a05SRhyland Klein 	.input_max = 700000000,
17876b301a05SRhyland Klein 	.cf_min = 12000000,
17886b301a05SRhyland Klein 	.cf_max = 50000000,
17896b301a05SRhyland Klein 	.vco_min = 600000000,
17906b301a05SRhyland Klein 	.vco_max = 1200000000,
17916b301a05SRhyland Klein 	.base_reg = PLLA1_BASE,
17926b301a05SRhyland Klein 	.misc_reg = PLLA1_MISC0,
17936b301a05SRhyland Klein 	.lock_mask = PLLCX_BASE_LOCK,
17946b301a05SRhyland Klein 	.lock_delay = 300,
17956b301a05SRhyland Klein 	.iddq_reg = PLLA1_MISC0,
17966b301a05SRhyland Klein 	.iddq_bit_idx = PLLCX_IDDQ_BIT,
17976b301a05SRhyland Klein 	.reset_reg = PLLA1_MISC0,
17986b301a05SRhyland Klein 	.reset_bit_idx = PLLCX_RESET_BIT,
17996b301a05SRhyland Klein 	.round_p_to_pdiv = pll_qlin_p_to_pdiv,
18006b301a05SRhyland Klein 	.pdiv_tohw = pll_qlin_pdiv_to_hw,
18016b301a05SRhyland Klein 	.div_nmp = &pllc_nmp,
18026b301a05SRhyland Klein 	.ext_misc_reg[0] = PLLA1_MISC0,
18036b301a05SRhyland Klein 	.ext_misc_reg[1] = PLLA1_MISC1,
18046b301a05SRhyland Klein 	.ext_misc_reg[2] = PLLA1_MISC2,
18056b301a05SRhyland Klein 	.ext_misc_reg[3] = PLLA1_MISC3,
18066b301a05SRhyland Klein 	.freq_table = pll_cx_freq_table,
180714050118SRhyland Klein 	.flags = TEGRA_PLL_USE_LOCK,
18086b301a05SRhyland Klein 	.set_defaults = _plla1_set_defaults,
18096b301a05SRhyland Klein 	.calc_rate = tegra210_pll_fixed_mdiv_cfg,
18106b301a05SRhyland Klein };
18116b301a05SRhyland Klein 
18126b301a05SRhyland Klein static struct div_nmp plla_nmp = {
18136b301a05SRhyland Klein 	.divm_shift = 0,
18146b301a05SRhyland Klein 	.divm_width = 8,
18156b301a05SRhyland Klein 	.divn_shift = 8,
18166b301a05SRhyland Klein 	.divn_width = 8,
18176b301a05SRhyland Klein 	.divp_shift = 20,
18186b301a05SRhyland Klein 	.divp_width = 5,
18196b301a05SRhyland Klein };
18206b301a05SRhyland Klein 
18216b301a05SRhyland Klein static struct tegra_clk_pll_freq_table pll_a_freq_table[] = {
18226b301a05SRhyland Klein 	{ 12000000, 282240000, 47, 1, 1, 1, 0xf148 }, /* actual: 282240234 */
18236b301a05SRhyland Klein 	{ 12000000, 368640000, 61, 1, 1, 1, 0xfe15 }, /* actual: 368640381 */
18246b301a05SRhyland Klein 	{ 12000000, 240000000, 60, 1, 2, 1,      0 },
18256b301a05SRhyland Klein 	{ 13000000, 282240000, 43, 1, 1, 1, 0xfd7d }, /* actual: 282239807 */
18266b301a05SRhyland Klein 	{ 13000000, 368640000, 56, 1, 1, 1, 0x06d8 }, /* actual: 368640137 */
18276b301a05SRhyland Klein 	{ 13000000, 240000000, 55, 1, 2, 1,      0 }, /* actual: 238.3 MHz */
18286b301a05SRhyland Klein 	{ 38400000, 282240000, 44, 3, 1, 1, 0xf333 }, /* actual: 282239844 */
18296b301a05SRhyland Klein 	{ 38400000, 368640000, 57, 3, 1, 1, 0x0333 }, /* actual: 368639844 */
18306b301a05SRhyland Klein 	{ 38400000, 240000000, 75, 3, 3, 1,      0 },
18316b301a05SRhyland Klein 	{        0,         0,  0, 0, 0, 0,      0 },
18326b301a05SRhyland Klein };
18336b301a05SRhyland Klein 
18346b301a05SRhyland Klein static struct tegra_clk_pll_params pll_a_params = {
18356b301a05SRhyland Klein 	.input_min = 12000000,
18366b301a05SRhyland Klein 	.input_max = 800000000,
18376b301a05SRhyland Klein 	.cf_min = 12000000,
18386b301a05SRhyland Klein 	.cf_max = 19200000,
18396b301a05SRhyland Klein 	.vco_min = 500000000,
18406b301a05SRhyland Klein 	.vco_max = 1000000000,
18416b301a05SRhyland Klein 	.base_reg = PLLA_BASE,
18426b301a05SRhyland Klein 	.misc_reg = PLLA_MISC0,
18436b301a05SRhyland Klein 	.lock_mask = PLL_BASE_LOCK,
18446b301a05SRhyland Klein 	.lock_delay = 300,
18456b301a05SRhyland Klein 	.round_p_to_pdiv = pll_qlin_p_to_pdiv,
18466b301a05SRhyland Klein 	.pdiv_tohw = pll_qlin_pdiv_to_hw,
18476b301a05SRhyland Klein 	.iddq_reg = PLLA_BASE,
18486b301a05SRhyland Klein 	.iddq_bit_idx = PLLA_IDDQ_BIT,
18496b301a05SRhyland Klein 	.div_nmp = &plla_nmp,
18506b301a05SRhyland Klein 	.sdm_din_reg = PLLA_MISC1,
18516b301a05SRhyland Klein 	.sdm_din_mask = PLLA_SDM_DIN_MASK,
18526b301a05SRhyland Klein 	.sdm_ctrl_reg = PLLA_MISC2,
18536b301a05SRhyland Klein 	.sdm_ctrl_en_mask = PLLA_SDM_EN_MASK,
18546b301a05SRhyland Klein 	.ext_misc_reg[0] = PLLA_MISC0,
18556b301a05SRhyland Klein 	.ext_misc_reg[1] = PLLA_MISC1,
18566b301a05SRhyland Klein 	.ext_misc_reg[2] = PLLA_MISC2,
18576b301a05SRhyland Klein 	.freq_table = pll_a_freq_table,
185814050118SRhyland Klein 	.flags = TEGRA_PLL_USE_LOCK | TEGRA_MDIV_NEW,
18596b301a05SRhyland Klein 	.set_defaults = tegra210_plla_set_defaults,
18606b301a05SRhyland Klein 	.calc_rate = tegra210_pll_fixed_mdiv_cfg,
18616b301a05SRhyland Klein 	.set_gain = tegra210_clk_pll_set_gain,
18626b301a05SRhyland Klein 	.adjust_vco = tegra210_clk_adjust_vco_min,
18636b301a05SRhyland Klein };
18646b301a05SRhyland Klein 
18656b301a05SRhyland Klein static struct div_nmp plld_nmp = {
18666b301a05SRhyland Klein 	.divm_shift = 0,
18676b301a05SRhyland Klein 	.divm_width = 8,
18686b301a05SRhyland Klein 	.divn_shift = 11,
18696b301a05SRhyland Klein 	.divn_width = 8,
18706b301a05SRhyland Klein 	.divp_shift = 20,
18716b301a05SRhyland Klein 	.divp_width = 3,
18726b301a05SRhyland Klein };
18736b301a05SRhyland Klein 
18746b301a05SRhyland Klein static struct tegra_clk_pll_freq_table pll_d_freq_table[] = {
18756b301a05SRhyland Klein 	{ 12000000, 594000000, 99, 1, 1, 0,      0 },
18766b301a05SRhyland Klein 	{ 13000000, 594000000, 91, 1, 1, 0, 0xfc4f }, /* actual: 594000183 */
18776b301a05SRhyland Klein 	{ 38400000, 594000000, 30, 1, 1, 0, 0x0e00 },
18786b301a05SRhyland Klein 	{        0,         0,  0, 0, 0, 0,      0 },
18796b301a05SRhyland Klein };
18806b301a05SRhyland Klein 
18816b301a05SRhyland Klein static struct tegra_clk_pll_params pll_d_params = {
18826b301a05SRhyland Klein 	.input_min = 12000000,
18836b301a05SRhyland Klein 	.input_max = 800000000,
18846b301a05SRhyland Klein 	.cf_min = 12000000,
18856b301a05SRhyland Klein 	.cf_max = 38400000,
18866b301a05SRhyland Klein 	.vco_min = 750000000,
18876b301a05SRhyland Klein 	.vco_max = 1500000000,
18886b301a05SRhyland Klein 	.base_reg = PLLD_BASE,
18896b301a05SRhyland Klein 	.misc_reg = PLLD_MISC0,
18906b301a05SRhyland Klein 	.lock_mask = PLL_BASE_LOCK,
18916b301a05SRhyland Klein 	.lock_delay = 1000,
18926b301a05SRhyland Klein 	.iddq_reg = PLLD_MISC0,
18936b301a05SRhyland Klein 	.iddq_bit_idx = PLLD_IDDQ_BIT,
18946b301a05SRhyland Klein 	.round_p_to_pdiv = pll_expo_p_to_pdiv,
18956b301a05SRhyland Klein 	.pdiv_tohw = pll_expo_pdiv_to_hw,
18966b301a05SRhyland Klein 	.div_nmp = &plld_nmp,
18976b301a05SRhyland Klein 	.sdm_din_reg = PLLD_MISC0,
18986b301a05SRhyland Klein 	.sdm_din_mask = PLLA_SDM_DIN_MASK,
18996b301a05SRhyland Klein 	.sdm_ctrl_reg = PLLD_MISC0,
19006b301a05SRhyland Klein 	.sdm_ctrl_en_mask = PLLD_SDM_EN_MASK,
19016b301a05SRhyland Klein 	.ext_misc_reg[0] = PLLD_MISC0,
19026b301a05SRhyland Klein 	.ext_misc_reg[1] = PLLD_MISC1,
19036b301a05SRhyland Klein 	.freq_table = pll_d_freq_table,
190414050118SRhyland Klein 	.flags = TEGRA_PLL_USE_LOCK,
19056b301a05SRhyland Klein 	.mdiv_default = 1,
19066b301a05SRhyland Klein 	.set_defaults = tegra210_plld_set_defaults,
19076b301a05SRhyland Klein 	.calc_rate = tegra210_pll_fixed_mdiv_cfg,
19086b301a05SRhyland Klein 	.set_gain = tegra210_clk_pll_set_gain,
19096b301a05SRhyland Klein 	.adjust_vco = tegra210_clk_adjust_vco_min,
19106b301a05SRhyland Klein };
19116b301a05SRhyland Klein 
19126b301a05SRhyland Klein static struct tegra_clk_pll_freq_table tegra210_pll_d2_freq_table[] = {
19136b301a05SRhyland Klein 	{ 12000000, 594000000, 99, 1, 1, 0, 0xf000 },
19146b301a05SRhyland Klein 	{ 13000000, 594000000, 91, 1, 1, 0, 0xfc4f }, /* actual: 594000183 */
19156b301a05SRhyland Klein 	{ 38400000, 594000000, 30, 1, 1, 0, 0x0e00 },
19166b301a05SRhyland Klein 	{        0,         0,  0, 0, 0, 0,      0 },
19176b301a05SRhyland Klein };
19186b301a05SRhyland Klein 
19196b301a05SRhyland Klein /* s/w policy, always tegra_pll_ref */
19206b301a05SRhyland Klein static struct tegra_clk_pll_params pll_d2_params = {
19216b301a05SRhyland Klein 	.input_min = 12000000,
19226b301a05SRhyland Klein 	.input_max = 800000000,
19236b301a05SRhyland Klein 	.cf_min = 12000000,
19246b301a05SRhyland Klein 	.cf_max = 38400000,
19256b301a05SRhyland Klein 	.vco_min = 750000000,
19266b301a05SRhyland Klein 	.vco_max = 1500000000,
19276b301a05SRhyland Klein 	.base_reg = PLLD2_BASE,
19286b301a05SRhyland Klein 	.misc_reg = PLLD2_MISC0,
19296b301a05SRhyland Klein 	.lock_mask = PLL_BASE_LOCK,
19306b301a05SRhyland Klein 	.lock_delay = 300,
19316b301a05SRhyland Klein 	.iddq_reg = PLLD2_BASE,
19326b301a05SRhyland Klein 	.iddq_bit_idx = PLLSS_IDDQ_BIT,
19336b301a05SRhyland Klein 	.sdm_din_reg = PLLD2_MISC3,
19346b301a05SRhyland Klein 	.sdm_din_mask = PLLA_SDM_DIN_MASK,
19356b301a05SRhyland Klein 	.sdm_ctrl_reg = PLLD2_MISC1,
19366b301a05SRhyland Klein 	.sdm_ctrl_en_mask = PLLD2_SDM_EN_MASK,
19376b301a05SRhyland Klein 	.ssc_ctrl_reg = PLLD2_MISC1,
19386b301a05SRhyland Klein 	.ssc_ctrl_en_mask = PLLD2_SSC_EN_MASK,
19396b301a05SRhyland Klein 	.round_p_to_pdiv = pll_qlin_p_to_pdiv,
19406b301a05SRhyland Klein 	.pdiv_tohw = pll_qlin_pdiv_to_hw,
19416b301a05SRhyland Klein 	.div_nmp = &pllss_nmp,
19426b301a05SRhyland Klein 	.ext_misc_reg[0] = PLLD2_MISC0,
19436b301a05SRhyland Klein 	.ext_misc_reg[1] = PLLD2_MISC1,
19446b301a05SRhyland Klein 	.ext_misc_reg[2] = PLLD2_MISC2,
19456b301a05SRhyland Klein 	.ext_misc_reg[3] = PLLD2_MISC3,
19466b301a05SRhyland Klein 	.max_p = PLL_QLIN_PDIV_MAX,
19476b301a05SRhyland Klein 	.mdiv_default = 1,
19486b301a05SRhyland Klein 	.freq_table = tegra210_pll_d2_freq_table,
19496b301a05SRhyland Klein 	.set_defaults = tegra210_plld2_set_defaults,
195014050118SRhyland Klein 	.flags = TEGRA_PLL_USE_LOCK,
19516b301a05SRhyland Klein 	.calc_rate = tegra210_pll_fixed_mdiv_cfg,
19526b301a05SRhyland Klein 	.set_gain = tegra210_clk_pll_set_gain,
19536b301a05SRhyland Klein 	.adjust_vco = tegra210_clk_adjust_vco_min,
19546b301a05SRhyland Klein };
19556b301a05SRhyland Klein 
19566b301a05SRhyland Klein static struct tegra_clk_pll_freq_table pll_dp_freq_table[] = {
19576b301a05SRhyland Klein 	{ 12000000, 270000000, 90, 1, 3, 0, 0xf000 },
19586b301a05SRhyland Klein 	{ 13000000, 270000000, 83, 1, 3, 0, 0xf000 }, /* actual: 269.8 MHz */
19596b301a05SRhyland Klein 	{ 38400000, 270000000, 28, 1, 3, 0, 0xf400 },
19606b301a05SRhyland Klein 	{        0,         0,  0, 0, 0, 0,      0 },
19616b301a05SRhyland Klein };
19626b301a05SRhyland Klein 
19636b301a05SRhyland Klein static struct tegra_clk_pll_params pll_dp_params = {
19646b301a05SRhyland Klein 	.input_min = 12000000,
19656b301a05SRhyland Klein 	.input_max = 800000000,
19666b301a05SRhyland Klein 	.cf_min = 12000000,
19676b301a05SRhyland Klein 	.cf_max = 38400000,
19686b301a05SRhyland Klein 	.vco_min = 750000000,
19696b301a05SRhyland Klein 	.vco_max = 1500000000,
19706b301a05SRhyland Klein 	.base_reg = PLLDP_BASE,
19716b301a05SRhyland Klein 	.misc_reg = PLLDP_MISC,
19726b301a05SRhyland Klein 	.lock_mask = PLL_BASE_LOCK,
19736b301a05SRhyland Klein 	.lock_delay = 300,
19746b301a05SRhyland Klein 	.iddq_reg = PLLDP_BASE,
19756b301a05SRhyland Klein 	.iddq_bit_idx = PLLSS_IDDQ_BIT,
19766b301a05SRhyland Klein 	.sdm_din_reg = PLLDP_SS_CTRL2,
19776b301a05SRhyland Klein 	.sdm_din_mask = PLLA_SDM_DIN_MASK,
19786b301a05SRhyland Klein 	.sdm_ctrl_reg = PLLDP_SS_CFG,
19796b301a05SRhyland Klein 	.sdm_ctrl_en_mask = PLLDP_SDM_EN_MASK,
19806b301a05SRhyland Klein 	.ssc_ctrl_reg = PLLDP_SS_CFG,
19816b301a05SRhyland Klein 	.ssc_ctrl_en_mask = PLLDP_SSC_EN_MASK,
19826b301a05SRhyland Klein 	.round_p_to_pdiv = pll_qlin_p_to_pdiv,
19836b301a05SRhyland Klein 	.pdiv_tohw = pll_qlin_pdiv_to_hw,
19846b301a05SRhyland Klein 	.div_nmp = &pllss_nmp,
19856b301a05SRhyland Klein 	.ext_misc_reg[0] = PLLDP_MISC,
19866b301a05SRhyland Klein 	.ext_misc_reg[1] = PLLDP_SS_CFG,
19876b301a05SRhyland Klein 	.ext_misc_reg[2] = PLLDP_SS_CTRL1,
19886b301a05SRhyland Klein 	.ext_misc_reg[3] = PLLDP_SS_CTRL2,
19896b301a05SRhyland Klein 	.max_p = PLL_QLIN_PDIV_MAX,
19906b301a05SRhyland Klein 	.mdiv_default = 1,
19916b301a05SRhyland Klein 	.freq_table = pll_dp_freq_table,
19926b301a05SRhyland Klein 	.set_defaults = tegra210_plldp_set_defaults,
199314050118SRhyland Klein 	.flags = TEGRA_PLL_USE_LOCK,
19946b301a05SRhyland Klein 	.calc_rate = tegra210_pll_fixed_mdiv_cfg,
19956b301a05SRhyland Klein 	.set_gain = tegra210_clk_pll_set_gain,
19966b301a05SRhyland Klein 	.adjust_vco = tegra210_clk_adjust_vco_min,
19976b301a05SRhyland Klein };
19986b301a05SRhyland Klein 
19996b301a05SRhyland Klein static struct div_nmp pllu_nmp = {
20006b301a05SRhyland Klein 	.divm_shift = 0,
20016b301a05SRhyland Klein 	.divm_width = 8,
20026b301a05SRhyland Klein 	.divn_shift = 8,
20036b301a05SRhyland Klein 	.divn_width = 8,
20046b301a05SRhyland Klein 	.divp_shift = 16,
20056b301a05SRhyland Klein 	.divp_width = 5,
20066b301a05SRhyland Klein };
20076b301a05SRhyland Klein 
20086b301a05SRhyland Klein static struct tegra_clk_pll_freq_table pll_u_freq_table[] = {
20096b301a05SRhyland Klein 	{ 12000000, 480000000, 40, 1, 0, 0 },
20106b301a05SRhyland Klein 	{ 13000000, 480000000, 36, 1, 0, 0 }, /* actual: 468.0 MHz */
20116b301a05SRhyland Klein 	{ 38400000, 480000000, 25, 2, 0, 0 },
20126b301a05SRhyland Klein 	{        0,         0,  0, 0, 0, 0 },
20136b301a05SRhyland Klein };
20146b301a05SRhyland Klein 
20156b301a05SRhyland Klein static struct tegra_clk_pll_params pll_u_vco_params = {
20166b301a05SRhyland Klein 	.input_min = 9600000,
20176b301a05SRhyland Klein 	.input_max = 800000000,
20186b301a05SRhyland Klein 	.cf_min = 9600000,
20196b301a05SRhyland Klein 	.cf_max = 19200000,
20206b301a05SRhyland Klein 	.vco_min = 350000000,
20216b301a05SRhyland Klein 	.vco_max = 700000000,
20226b301a05SRhyland Klein 	.base_reg = PLLU_BASE,
20236b301a05SRhyland Klein 	.misc_reg = PLLU_MISC0,
20246b301a05SRhyland Klein 	.lock_mask = PLL_BASE_LOCK,
20256b301a05SRhyland Klein 	.lock_delay = 1000,
20266b301a05SRhyland Klein 	.iddq_reg = PLLU_MISC0,
20276b301a05SRhyland Klein 	.iddq_bit_idx = PLLU_IDDQ_BIT,
20286b301a05SRhyland Klein 	.ext_misc_reg[0] = PLLU_MISC0,
20296b301a05SRhyland Klein 	.ext_misc_reg[1] = PLLU_MISC1,
20306b301a05SRhyland Klein 	.round_p_to_pdiv = pll_qlin_p_to_pdiv,
20316b301a05SRhyland Klein 	.pdiv_tohw = pll_qlin_pdiv_to_hw,
20326b301a05SRhyland Klein 	.div_nmp = &pllu_nmp,
20336b301a05SRhyland Klein 	.freq_table = pll_u_freq_table,
203414050118SRhyland Klein 	.flags = TEGRA_PLLU | TEGRA_PLL_USE_LOCK | TEGRA_PLL_VCO_OUT,
20356b301a05SRhyland Klein 	.set_defaults = tegra210_pllu_set_defaults,
20366b301a05SRhyland Klein 	.calc_rate = tegra210_pll_fixed_mdiv_cfg,
20376b301a05SRhyland Klein };
20386b301a05SRhyland Klein 
20396b301a05SRhyland Klein struct utmi_clk_param {
20406b301a05SRhyland Klein 	/* Oscillator Frequency in KHz */
20416b301a05SRhyland Klein 	u32 osc_frequency;
20426b301a05SRhyland Klein 	/* UTMIP PLL Enable Delay Count  */
20436b301a05SRhyland Klein 	u8 enable_delay_count;
20446b301a05SRhyland Klein 	/* UTMIP PLL Stable count */
20456b301a05SRhyland Klein 	u16 stable_count;
20466b301a05SRhyland Klein 	/*  UTMIP PLL Active delay count */
20476b301a05SRhyland Klein 	u8 active_delay_count;
20486b301a05SRhyland Klein 	/* UTMIP PLL Xtal frequency count */
20496b301a05SRhyland Klein 	u16 xtal_freq_count;
20506b301a05SRhyland Klein };
20516b301a05SRhyland Klein 
20526b301a05SRhyland Klein static const struct utmi_clk_param utmi_parameters[] = {
20536b301a05SRhyland Klein 	{
20546b301a05SRhyland Klein 		.osc_frequency = 38400000, .enable_delay_count = 0x0,
20556b301a05SRhyland Klein 		.stable_count = 0x0, .active_delay_count = 0x6,
20566b301a05SRhyland Klein 		.xtal_freq_count = 0x80
20576b301a05SRhyland Klein 	}, {
20586b301a05SRhyland Klein 		.osc_frequency = 13000000, .enable_delay_count = 0x02,
20596b301a05SRhyland Klein 		.stable_count = 0x33, .active_delay_count = 0x05,
20606b301a05SRhyland Klein 		.xtal_freq_count = 0x7f
20616b301a05SRhyland Klein 	}, {
20626b301a05SRhyland Klein 		.osc_frequency = 19200000, .enable_delay_count = 0x03,
20636b301a05SRhyland Klein 		.stable_count = 0x4b, .active_delay_count = 0x06,
20646b301a05SRhyland Klein 		.xtal_freq_count = 0xbb
20656b301a05SRhyland Klein 	}, {
20666b301a05SRhyland Klein 		.osc_frequency = 12000000, .enable_delay_count = 0x02,
20676b301a05SRhyland Klein 		.stable_count = 0x2f, .active_delay_count = 0x08,
20686b301a05SRhyland Klein 		.xtal_freq_count = 0x76
20696b301a05SRhyland Klein 	}, {
20706b301a05SRhyland Klein 		.osc_frequency = 26000000, .enable_delay_count = 0x04,
20716b301a05SRhyland Klein 		.stable_count = 0x66, .active_delay_count = 0x09,
20726b301a05SRhyland Klein 		.xtal_freq_count = 0xfe
20736b301a05SRhyland Klein 	}, {
20746b301a05SRhyland Klein 		.osc_frequency = 16800000, .enable_delay_count = 0x03,
20756b301a05SRhyland Klein 		.stable_count = 0x41, .active_delay_count = 0x0a,
20766b301a05SRhyland Klein 		.xtal_freq_count = 0xa4
20776b301a05SRhyland Klein 	},
20786b301a05SRhyland Klein };
20796b301a05SRhyland Klein 
20806b301a05SRhyland Klein static struct tegra_clk tegra210_clks[tegra_clk_max] __initdata = {
20816b301a05SRhyland Klein 	[tegra_clk_ispb] = { .dt_id = TEGRA210_CLK_ISPB, .present = true },
20826b301a05SRhyland Klein 	[tegra_clk_rtc] = { .dt_id = TEGRA210_CLK_RTC, .present = true },
20836b301a05SRhyland Klein 	[tegra_clk_timer] = { .dt_id = TEGRA210_CLK_TIMER, .present = true },
20846b301a05SRhyland Klein 	[tegra_clk_uarta_8] = { .dt_id = TEGRA210_CLK_UARTA, .present = true },
20856b301a05SRhyland Klein 	[tegra_clk_sdmmc2_9] = { .dt_id = TEGRA210_CLK_SDMMC2, .present = true },
20866b301a05SRhyland Klein 	[tegra_clk_i2s1] = { .dt_id = TEGRA210_CLK_I2S1, .present = true },
20876b301a05SRhyland Klein 	[tegra_clk_i2c1] = { .dt_id = TEGRA210_CLK_I2C1, .present = true },
20886b301a05SRhyland Klein 	[tegra_clk_sdmmc1_9] = { .dt_id = TEGRA210_CLK_SDMMC1, .present = true },
20896b301a05SRhyland Klein 	[tegra_clk_sdmmc4_9] = { .dt_id = TEGRA210_CLK_SDMMC4, .present = true },
20906b301a05SRhyland Klein 	[tegra_clk_pwm] = { .dt_id = TEGRA210_CLK_PWM, .present = true },
20916b301a05SRhyland Klein 	[tegra_clk_i2s2] = { .dt_id = TEGRA210_CLK_I2S2, .present = true },
20926b301a05SRhyland Klein 	[tegra_clk_usbd] = { .dt_id = TEGRA210_CLK_USBD, .present = true },
20936b301a05SRhyland Klein 	[tegra_clk_isp_9] = { .dt_id = TEGRA210_CLK_ISP, .present = true },
20946b301a05SRhyland Klein 	[tegra_clk_disp2_8] = { .dt_id = TEGRA210_CLK_DISP2, .present = true },
20956b301a05SRhyland Klein 	[tegra_clk_disp1_8] = { .dt_id = TEGRA210_CLK_DISP1, .present = true },
20966b301a05SRhyland Klein 	[tegra_clk_host1x_9] = { .dt_id = TEGRA210_CLK_HOST1X, .present = true },
20976b301a05SRhyland Klein 	[tegra_clk_i2s0] = { .dt_id = TEGRA210_CLK_I2S0, .present = true },
20986b301a05SRhyland Klein 	[tegra_clk_apbdma] = { .dt_id = TEGRA210_CLK_APBDMA, .present = true },
20996b301a05SRhyland Klein 	[tegra_clk_kfuse] = { .dt_id = TEGRA210_CLK_KFUSE, .present = true },
21006b301a05SRhyland Klein 	[tegra_clk_sbc1_9] = { .dt_id = TEGRA210_CLK_SBC1, .present = true },
21016b301a05SRhyland Klein 	[tegra_clk_sbc2_9] = { .dt_id = TEGRA210_CLK_SBC2, .present = true },
21026b301a05SRhyland Klein 	[tegra_clk_sbc3_9] = { .dt_id = TEGRA210_CLK_SBC3, .present = true },
21036b301a05SRhyland Klein 	[tegra_clk_i2c5] = { .dt_id = TEGRA210_CLK_I2C5, .present = true },
21046b301a05SRhyland Klein 	[tegra_clk_csi] = { .dt_id = TEGRA210_CLK_CSI, .present = true },
21056b301a05SRhyland Klein 	[tegra_clk_i2c2] = { .dt_id = TEGRA210_CLK_I2C2, .present = true },
21066b301a05SRhyland Klein 	[tegra_clk_uartc_8] = { .dt_id = TEGRA210_CLK_UARTC, .present = true },
21076b301a05SRhyland Klein 	[tegra_clk_mipi_cal] = { .dt_id = TEGRA210_CLK_MIPI_CAL, .present = true },
21086b301a05SRhyland Klein 	[tegra_clk_emc] = { .dt_id = TEGRA210_CLK_EMC, .present = true },
21096b301a05SRhyland Klein 	[tegra_clk_usb2] = { .dt_id = TEGRA210_CLK_USB2, .present = true },
21106b301a05SRhyland Klein 	[tegra_clk_bsev] = { .dt_id = TEGRA210_CLK_BSEV, .present = true },
21116b301a05SRhyland Klein 	[tegra_clk_uartd_8] = { .dt_id = TEGRA210_CLK_UARTD, .present = true },
21126b301a05SRhyland Klein 	[tegra_clk_i2c3] = { .dt_id = TEGRA210_CLK_I2C3, .present = true },
21136b301a05SRhyland Klein 	[tegra_clk_sbc4_9] = { .dt_id = TEGRA210_CLK_SBC4, .present = true },
21146b301a05SRhyland Klein 	[tegra_clk_sdmmc3_9] = { .dt_id = TEGRA210_CLK_SDMMC3, .present = true },
21156b301a05SRhyland Klein 	[tegra_clk_pcie] = { .dt_id = TEGRA210_CLK_PCIE, .present = true },
21166b301a05SRhyland Klein 	[tegra_clk_owr_8] = { .dt_id = TEGRA210_CLK_OWR, .present = true },
21176b301a05SRhyland Klein 	[tegra_clk_afi] = { .dt_id = TEGRA210_CLK_AFI, .present = true },
21186b301a05SRhyland Klein 	[tegra_clk_csite_8] = { .dt_id = TEGRA210_CLK_CSITE, .present = true },
21196b301a05SRhyland Klein 	[tegra_clk_soc_therm_8] = { .dt_id = TEGRA210_CLK_SOC_THERM, .present = true },
21206b301a05SRhyland Klein 	[tegra_clk_dtv] = { .dt_id = TEGRA210_CLK_DTV, .present = true },
21216b301a05SRhyland Klein 	[tegra_clk_i2cslow] = { .dt_id = TEGRA210_CLK_I2CSLOW, .present = true },
21226b301a05SRhyland Klein 	[tegra_clk_tsec_8] = { .dt_id = TEGRA210_CLK_TSEC, .present = true },
21236b301a05SRhyland Klein 	[tegra_clk_xusb_host] = { .dt_id = TEGRA210_CLK_XUSB_HOST, .present = true },
21246b301a05SRhyland Klein 	[tegra_clk_csus] = { .dt_id = TEGRA210_CLK_CSUS, .present = true },
21256b301a05SRhyland Klein 	[tegra_clk_mselect] = { .dt_id = TEGRA210_CLK_MSELECT, .present = true },
21266b301a05SRhyland Klein 	[tegra_clk_tsensor] = { .dt_id = TEGRA210_CLK_TSENSOR, .present = true },
21276b301a05SRhyland Klein 	[tegra_clk_i2s3] = { .dt_id = TEGRA210_CLK_I2S3, .present = true },
21286b301a05SRhyland Klein 	[tegra_clk_i2s4] = { .dt_id = TEGRA210_CLK_I2S4, .present = true },
21296b301a05SRhyland Klein 	[tegra_clk_i2c4] = { .dt_id = TEGRA210_CLK_I2C4, .present = true },
21306b301a05SRhyland Klein 	[tegra_clk_d_audio] = { .dt_id = TEGRA210_CLK_D_AUDIO, .present = true },
21316b301a05SRhyland Klein 	[tegra_clk_hda2codec_2x_8] = { .dt_id = TEGRA210_CLK_HDA2CODEC_2X, .present = true },
21326b301a05SRhyland Klein 	[tegra_clk_spdif_2x] = { .dt_id = TEGRA210_CLK_SPDIF_2X, .present = true },
21336b301a05SRhyland Klein 	[tegra_clk_actmon] = { .dt_id = TEGRA210_CLK_ACTMON, .present = true },
21346b301a05SRhyland Klein 	[tegra_clk_extern1] = { .dt_id = TEGRA210_CLK_EXTERN1, .present = true },
21356b301a05SRhyland Klein 	[tegra_clk_extern2] = { .dt_id = TEGRA210_CLK_EXTERN2, .present = true },
21366b301a05SRhyland Klein 	[tegra_clk_extern3] = { .dt_id = TEGRA210_CLK_EXTERN3, .present = true },
21376b301a05SRhyland Klein 	[tegra_clk_sata_oob_8] = { .dt_id = TEGRA210_CLK_SATA_OOB, .present = true },
21386b301a05SRhyland Klein 	[tegra_clk_sata_8] = { .dt_id = TEGRA210_CLK_SATA, .present = true },
21396b301a05SRhyland Klein 	[tegra_clk_hda_8] = { .dt_id = TEGRA210_CLK_HDA, .present = true },
21406b301a05SRhyland Klein 	[tegra_clk_hda2hdmi] = { .dt_id = TEGRA210_CLK_HDA2HDMI, .present = true },
21416b301a05SRhyland Klein 	[tegra_clk_cilab] = { .dt_id = TEGRA210_CLK_CILAB, .present = true },
21426b301a05SRhyland Klein 	[tegra_clk_cilcd] = { .dt_id = TEGRA210_CLK_CILCD, .present = true },
21436b301a05SRhyland Klein 	[tegra_clk_cile] = { .dt_id = TEGRA210_CLK_CILE, .present = true },
21446b301a05SRhyland Klein 	[tegra_clk_dsialp] = { .dt_id = TEGRA210_CLK_DSIALP, .present = true },
21456b301a05SRhyland Klein 	[tegra_clk_dsiblp] = { .dt_id = TEGRA210_CLK_DSIBLP, .present = true },
21466b301a05SRhyland Klein 	[tegra_clk_entropy_8] = { .dt_id = TEGRA210_CLK_ENTROPY, .present = true },
21476b301a05SRhyland Klein 	[tegra_clk_xusb_ss] = { .dt_id = TEGRA210_CLK_XUSB_SS, .present = true },
21486b301a05SRhyland Klein 	[tegra_clk_i2c6] = { .dt_id = TEGRA210_CLK_I2C6, .present = true },
21496b301a05SRhyland Klein 	[tegra_clk_vim2_clk] = { .dt_id = TEGRA210_CLK_VIM2_CLK, .present = true },
21506b301a05SRhyland Klein 	[tegra_clk_clk72Mhz_8] = { .dt_id = TEGRA210_CLK_CLK72MHZ, .present = true },
21516b301a05SRhyland Klein 	[tegra_clk_vic03_8] = { .dt_id = TEGRA210_CLK_VIC03, .present = true },
21526b301a05SRhyland Klein 	[tegra_clk_dpaux] = { .dt_id = TEGRA210_CLK_DPAUX, .present = true },
2153*98c4b366SThierry Reding 	[tegra_clk_dpaux1] = { .dt_id = TEGRA210_CLK_DPAUX1, .present = true },
21546b301a05SRhyland Klein 	[tegra_clk_sor0] = { .dt_id = TEGRA210_CLK_SOR0, .present = true },
21556b301a05SRhyland Klein 	[tegra_clk_sor0_lvds] = { .dt_id = TEGRA210_CLK_SOR0_LVDS, .present = true },
21566b301a05SRhyland Klein 	[tegra_clk_gpu] = { .dt_id = TEGRA210_CLK_GPU, .present = true },
21576b301a05SRhyland Klein 	[tegra_clk_pll_g_ref] = { .dt_id = TEGRA210_CLK_PLL_G_REF, .present = true, },
21586b301a05SRhyland Klein 	[tegra_clk_uartb_8] = { .dt_id = TEGRA210_CLK_UARTB, .present = true },
21596b301a05SRhyland Klein 	[tegra_clk_vfir] = { .dt_id = TEGRA210_CLK_VFIR, .present = true },
21606b301a05SRhyland Klein 	[tegra_clk_spdif_in_8] = { .dt_id = TEGRA210_CLK_SPDIF_IN, .present = true },
21616b301a05SRhyland Klein 	[tegra_clk_spdif_out] = { .dt_id = TEGRA210_CLK_SPDIF_OUT, .present = true },
21626b301a05SRhyland Klein 	[tegra_clk_vi_10] = { .dt_id = TEGRA210_CLK_VI, .present = true },
21636b301a05SRhyland Klein 	[tegra_clk_vi_sensor_8] = { .dt_id = TEGRA210_CLK_VI_SENSOR, .present = true },
21646b301a05SRhyland Klein 	[tegra_clk_fuse] = { .dt_id = TEGRA210_CLK_FUSE, .present = true },
21656b301a05SRhyland Klein 	[tegra_clk_fuse_burn] = { .dt_id = TEGRA210_CLK_FUSE_BURN, .present = true },
21666b301a05SRhyland Klein 	[tegra_clk_clk_32k] = { .dt_id = TEGRA210_CLK_CLK_32K, .present = true },
21676b301a05SRhyland Klein 	[tegra_clk_clk_m] = { .dt_id = TEGRA210_CLK_CLK_M, .present = true },
21686b301a05SRhyland Klein 	[tegra_clk_clk_m_div2] = { .dt_id = TEGRA210_CLK_CLK_M_DIV2, .present = true },
21696b301a05SRhyland Klein 	[tegra_clk_clk_m_div4] = { .dt_id = TEGRA210_CLK_CLK_M_DIV4, .present = true },
21706b301a05SRhyland Klein 	[tegra_clk_pll_ref] = { .dt_id = TEGRA210_CLK_PLL_REF, .present = true },
21716b301a05SRhyland Klein 	[tegra_clk_pll_c] = { .dt_id = TEGRA210_CLK_PLL_C, .present = true },
21726b301a05SRhyland Klein 	[tegra_clk_pll_c_out1] = { .dt_id = TEGRA210_CLK_PLL_C_OUT1, .present = true },
21736b301a05SRhyland Klein 	[tegra_clk_pll_c2] = { .dt_id = TEGRA210_CLK_PLL_C2, .present = true },
21746b301a05SRhyland Klein 	[tegra_clk_pll_c3] = { .dt_id = TEGRA210_CLK_PLL_C3, .present = true },
21756b301a05SRhyland Klein 	[tegra_clk_pll_m] = { .dt_id = TEGRA210_CLK_PLL_M, .present = true },
21766b301a05SRhyland Klein 	[tegra_clk_pll_m_out1] = { .dt_id = TEGRA210_CLK_PLL_M_OUT1, .present = true },
21776b301a05SRhyland Klein 	[tegra_clk_pll_p] = { .dt_id = TEGRA210_CLK_PLL_P, .present = true },
21786b301a05SRhyland Klein 	[tegra_clk_pll_p_out1] = { .dt_id = TEGRA210_CLK_PLL_P_OUT1, .present = true },
21796b301a05SRhyland Klein 	[tegra_clk_pll_p_out3] = { .dt_id = TEGRA210_CLK_PLL_P_OUT3, .present = true },
21806b301a05SRhyland Klein 	[tegra_clk_pll_p_out4_cpu] = { .dt_id = TEGRA210_CLK_PLL_P_OUT4, .present = true },
21816b301a05SRhyland Klein 	[tegra_clk_pll_p_out_hsio] = { .dt_id = TEGRA210_CLK_PLL_P_OUT_HSIO, .present = true },
21826b301a05SRhyland Klein 	[tegra_clk_pll_p_out_xusb] = { .dt_id = TEGRA210_CLK_PLL_P_OUT_XUSB, .present = true },
21836b301a05SRhyland Klein 	[tegra_clk_pll_p_out_cpu] = { .dt_id = TEGRA210_CLK_PLL_P_OUT_CPU, .present = true },
21846b301a05SRhyland Klein 	[tegra_clk_pll_p_out_adsp] = { .dt_id = TEGRA210_CLK_PLL_P_OUT_ADSP, .present = true },
21856b301a05SRhyland Klein 	[tegra_clk_pll_a] = { .dt_id = TEGRA210_CLK_PLL_A, .present = true },
21866b301a05SRhyland Klein 	[tegra_clk_pll_a_out0] = { .dt_id = TEGRA210_CLK_PLL_A_OUT0, .present = true },
21876b301a05SRhyland Klein 	[tegra_clk_pll_d] = { .dt_id = TEGRA210_CLK_PLL_D, .present = true },
21886b301a05SRhyland Klein 	[tegra_clk_pll_d_out0] = { .dt_id = TEGRA210_CLK_PLL_D_OUT0, .present = true },
21896b301a05SRhyland Klein 	[tegra_clk_pll_d2] = { .dt_id = TEGRA210_CLK_PLL_D2, .present = true },
21906b301a05SRhyland Klein 	[tegra_clk_pll_d2_out0] = { .dt_id = TEGRA210_CLK_PLL_D2_OUT0, .present = true },
21916b301a05SRhyland Klein 	[tegra_clk_pll_u] = { .dt_id = TEGRA210_CLK_PLL_U, .present = true },
21926b301a05SRhyland Klein 	[tegra_clk_pll_u_out] = { .dt_id = TEGRA210_CLK_PLL_U_OUT, .present = true },
21936b301a05SRhyland Klein 	[tegra_clk_pll_u_out1] = { .dt_id = TEGRA210_CLK_PLL_U_OUT1, .present = true },
21946b301a05SRhyland Klein 	[tegra_clk_pll_u_out2] = { .dt_id = TEGRA210_CLK_PLL_U_OUT2, .present = true },
21956b301a05SRhyland Klein 	[tegra_clk_pll_u_480m] = { .dt_id = TEGRA210_CLK_PLL_U_480M, .present = true },
21966b301a05SRhyland Klein 	[tegra_clk_pll_u_60m] = { .dt_id = TEGRA210_CLK_PLL_U_60M, .present = true },
21976b301a05SRhyland Klein 	[tegra_clk_pll_u_48m] = { .dt_id = TEGRA210_CLK_PLL_U_48M, .present = true },
21986b301a05SRhyland Klein 	[tegra_clk_pll_x] = { .dt_id = TEGRA210_CLK_PLL_X, .present = true },
21996b301a05SRhyland Klein 	[tegra_clk_pll_x_out0] = { .dt_id = TEGRA210_CLK_PLL_X_OUT0, .present = true },
22006b301a05SRhyland Klein 	[tegra_clk_pll_re_vco] = { .dt_id = TEGRA210_CLK_PLL_RE_VCO, .present = true },
22016b301a05SRhyland Klein 	[tegra_clk_pll_re_out] = { .dt_id = TEGRA210_CLK_PLL_RE_OUT, .present = true },
22026b301a05SRhyland Klein 	[tegra_clk_spdif_in_sync] = { .dt_id = TEGRA210_CLK_SPDIF_IN_SYNC, .present = true },
22036b301a05SRhyland Klein 	[tegra_clk_i2s0_sync] = { .dt_id = TEGRA210_CLK_I2S0_SYNC, .present = true },
22046b301a05SRhyland Klein 	[tegra_clk_i2s1_sync] = { .dt_id = TEGRA210_CLK_I2S1_SYNC, .present = true },
22056b301a05SRhyland Klein 	[tegra_clk_i2s2_sync] = { .dt_id = TEGRA210_CLK_I2S2_SYNC, .present = true },
22066b301a05SRhyland Klein 	[tegra_clk_i2s3_sync] = { .dt_id = TEGRA210_CLK_I2S3_SYNC, .present = true },
22076b301a05SRhyland Klein 	[tegra_clk_i2s4_sync] = { .dt_id = TEGRA210_CLK_I2S4_SYNC, .present = true },
22086b301a05SRhyland Klein 	[tegra_clk_vimclk_sync] = { .dt_id = TEGRA210_CLK_VIMCLK_SYNC, .present = true },
22096b301a05SRhyland Klein 	[tegra_clk_audio0] = { .dt_id = TEGRA210_CLK_AUDIO0, .present = true },
22106b301a05SRhyland Klein 	[tegra_clk_audio1] = { .dt_id = TEGRA210_CLK_AUDIO1, .present = true },
22116b301a05SRhyland Klein 	[tegra_clk_audio2] = { .dt_id = TEGRA210_CLK_AUDIO2, .present = true },
22126b301a05SRhyland Klein 	[tegra_clk_audio3] = { .dt_id = TEGRA210_CLK_AUDIO3, .present = true },
22136b301a05SRhyland Klein 	[tegra_clk_audio4] = { .dt_id = TEGRA210_CLK_AUDIO4, .present = true },
22146b301a05SRhyland Klein 	[tegra_clk_spdif] = { .dt_id = TEGRA210_CLK_SPDIF, .present = true },
22156b301a05SRhyland Klein 	[tegra_clk_clk_out_1] = { .dt_id = TEGRA210_CLK_CLK_OUT_1, .present = true },
22166b301a05SRhyland Klein 	[tegra_clk_clk_out_2] = { .dt_id = TEGRA210_CLK_CLK_OUT_2, .present = true },
22176b301a05SRhyland Klein 	[tegra_clk_clk_out_3] = { .dt_id = TEGRA210_CLK_CLK_OUT_3, .present = true },
22186b301a05SRhyland Klein 	[tegra_clk_blink] = { .dt_id = TEGRA210_CLK_BLINK, .present = true },
22196b301a05SRhyland Klein 	[tegra_clk_xusb_gate] = { .dt_id = TEGRA210_CLK_XUSB_GATE, .present = true },
22206b301a05SRhyland Klein 	[tegra_clk_xusb_host_src_8] = { .dt_id = TEGRA210_CLK_XUSB_HOST_SRC, .present = true },
22216b301a05SRhyland Klein 	[tegra_clk_xusb_falcon_src_8] = { .dt_id = TEGRA210_CLK_XUSB_FALCON_SRC, .present = true },
22226b301a05SRhyland Klein 	[tegra_clk_xusb_fs_src] = { .dt_id = TEGRA210_CLK_XUSB_FS_SRC, .present = true },
22236b301a05SRhyland Klein 	[tegra_clk_xusb_ss_src_8] = { .dt_id = TEGRA210_CLK_XUSB_SS_SRC, .present = true },
22246b301a05SRhyland Klein 	[tegra_clk_xusb_ss_div2] = { .dt_id = TEGRA210_CLK_XUSB_SS_DIV2, .present = true },
22256b301a05SRhyland Klein 	[tegra_clk_xusb_dev_src_8] = { .dt_id = TEGRA210_CLK_XUSB_DEV_SRC, .present = true },
22266b301a05SRhyland Klein 	[tegra_clk_xusb_dev] = { .dt_id = TEGRA210_CLK_XUSB_DEV, .present = true },
22276b301a05SRhyland Klein 	[tegra_clk_xusb_hs_src_4] = { .dt_id = TEGRA210_CLK_XUSB_HS_SRC, .present = true },
22286b301a05SRhyland Klein 	[tegra_clk_xusb_ssp_src] = { .dt_id = TEGRA210_CLK_XUSB_SSP_SRC, .present = true },
22296b301a05SRhyland Klein 	[tegra_clk_usb2_hsic_trk] = { .dt_id = TEGRA210_CLK_USB2_HSIC_TRK, .present = true },
22306b301a05SRhyland Klein 	[tegra_clk_hsic_trk] = { .dt_id = TEGRA210_CLK_HSIC_TRK, .present = true },
22316b301a05SRhyland Klein 	[tegra_clk_usb2_trk] = { .dt_id = TEGRA210_CLK_USB2_TRK, .present = true },
22326b301a05SRhyland Klein 	[tegra_clk_sclk] = { .dt_id = TEGRA210_CLK_SCLK, .present = true },
22336b301a05SRhyland Klein 	[tegra_clk_sclk_mux] = { .dt_id = TEGRA210_CLK_SCLK_MUX, .present = true },
22346b301a05SRhyland Klein 	[tegra_clk_hclk] = { .dt_id = TEGRA210_CLK_HCLK, .present = true },
22356b301a05SRhyland Klein 	[tegra_clk_pclk] = { .dt_id = TEGRA210_CLK_PCLK, .present = true },
22366b301a05SRhyland Klein 	[tegra_clk_cclk_g] = { .dt_id = TEGRA210_CLK_CCLK_G, .present = true },
22376b301a05SRhyland Klein 	[tegra_clk_cclk_lp] = { .dt_id = TEGRA210_CLK_CCLK_LP, .present = true },
22386b301a05SRhyland Klein 	[tegra_clk_dfll_ref] = { .dt_id = TEGRA210_CLK_DFLL_REF, .present = true },
22396b301a05SRhyland Klein 	[tegra_clk_dfll_soc] = { .dt_id = TEGRA210_CLK_DFLL_SOC, .present = true },
22406b301a05SRhyland Klein 	[tegra_clk_vi_sensor2_8] = { .dt_id = TEGRA210_CLK_VI_SENSOR2, .present = true },
22416b301a05SRhyland Klein 	[tegra_clk_pll_p_out5] = { .dt_id = TEGRA210_CLK_PLL_P_OUT5, .present = true },
22426b301a05SRhyland Klein 	[tegra_clk_pll_c4] = { .dt_id = TEGRA210_CLK_PLL_C4, .present = true },
22436b301a05SRhyland Klein 	[tegra_clk_pll_dp] = { .dt_id = TEGRA210_CLK_PLL_DP, .present = true },
22446b301a05SRhyland Klein 	[tegra_clk_audio0_mux] = { .dt_id = TEGRA210_CLK_AUDIO0_MUX, .present = true },
22456b301a05SRhyland Klein 	[tegra_clk_audio1_mux] = { .dt_id = TEGRA210_CLK_AUDIO1_MUX, .present = true },
22466b301a05SRhyland Klein 	[tegra_clk_audio2_mux] = { .dt_id = TEGRA210_CLK_AUDIO2_MUX, .present = true },
22476b301a05SRhyland Klein 	[tegra_clk_audio3_mux] = { .dt_id = TEGRA210_CLK_AUDIO3_MUX, .present = true },
22486b301a05SRhyland Klein 	[tegra_clk_audio4_mux] = { .dt_id = TEGRA210_CLK_AUDIO4_MUX, .present = true },
22496b301a05SRhyland Klein 	[tegra_clk_spdif_mux] = { .dt_id = TEGRA210_CLK_SPDIF_MUX, .present = true },
22506b301a05SRhyland Klein 	[tegra_clk_clk_out_1_mux] = { .dt_id = TEGRA210_CLK_CLK_OUT_1_MUX, .present = true },
22516b301a05SRhyland Klein 	[tegra_clk_clk_out_2_mux] = { .dt_id = TEGRA210_CLK_CLK_OUT_2_MUX, .present = true },
22526b301a05SRhyland Klein 	[tegra_clk_clk_out_3_mux] = { .dt_id = TEGRA210_CLK_CLK_OUT_3_MUX, .present = true },
22536b301a05SRhyland Klein 	[tegra_clk_maud] = { .dt_id = TEGRA210_CLK_MAUD, .present = true },
22546b301a05SRhyland Klein 	[tegra_clk_mipibif] = { .dt_id = TEGRA210_CLK_MIPIBIF, .present = true },
22556b301a05SRhyland Klein 	[tegra_clk_qspi] = { .dt_id = TEGRA210_CLK_QSPI, .present = true },
22566b301a05SRhyland Klein 	[tegra_clk_sdmmc_legacy] = { .dt_id = TEGRA210_CLK_SDMMC_LEGACY, .present = true },
22576b301a05SRhyland Klein 	[tegra_clk_tsecb] = { .dt_id = TEGRA210_CLK_TSECB, .present = true },
22586b301a05SRhyland Klein 	[tegra_clk_uartape] = { .dt_id = TEGRA210_CLK_UARTAPE, .present = true },
22596b301a05SRhyland Klein 	[tegra_clk_vi_i2c] = { .dt_id = TEGRA210_CLK_VI_I2C, .present = true },
22606b301a05SRhyland Klein 	[tegra_clk_ape] = { .dt_id = TEGRA210_CLK_APE, .present = true },
22616b301a05SRhyland Klein 	[tegra_clk_dbgapb] = { .dt_id = TEGRA210_CLK_DBGAPB, .present = true },
22626b301a05SRhyland Klein 	[tegra_clk_nvdec] = { .dt_id = TEGRA210_CLK_NVDEC, .present = true },
22636b301a05SRhyland Klein 	[tegra_clk_nvenc] = { .dt_id = TEGRA210_CLK_NVENC, .present = true },
22646b301a05SRhyland Klein 	[tegra_clk_nvjpg] = { .dt_id = TEGRA210_CLK_NVJPG, .present = true },
22656b301a05SRhyland Klein 	[tegra_clk_pll_c4_out0] = { .dt_id = TEGRA210_CLK_PLL_C4_OUT0, .present = true },
22666b301a05SRhyland Klein 	[tegra_clk_pll_c4_out1] = { .dt_id = TEGRA210_CLK_PLL_C4_OUT1, .present = true },
22676b301a05SRhyland Klein 	[tegra_clk_pll_c4_out2] = { .dt_id = TEGRA210_CLK_PLL_C4_OUT2, .present = true },
22686b301a05SRhyland Klein 	[tegra_clk_pll_c4_out3] = { .dt_id = TEGRA210_CLK_PLL_C4_OUT3, .present = true },
226929569941SJon Hunter 	[tegra_clk_apb2ape] = { .dt_id = TEGRA210_CLK_APB2APE, .present = true },
22706b301a05SRhyland Klein };
22716b301a05SRhyland Klein 
22726b301a05SRhyland Klein static struct tegra_devclk devclks[] __initdata = {
22736b301a05SRhyland Klein 	{ .con_id = "clk_m", .dt_id = TEGRA210_CLK_CLK_M },
22746b301a05SRhyland Klein 	{ .con_id = "pll_ref", .dt_id = TEGRA210_CLK_PLL_REF },
22756b301a05SRhyland Klein 	{ .con_id = "clk_32k", .dt_id = TEGRA210_CLK_CLK_32K },
22766b301a05SRhyland Klein 	{ .con_id = "clk_m_div2", .dt_id = TEGRA210_CLK_CLK_M_DIV2 },
22776b301a05SRhyland Klein 	{ .con_id = "clk_m_div4", .dt_id = TEGRA210_CLK_CLK_M_DIV4 },
22786b301a05SRhyland Klein 	{ .con_id = "pll_c", .dt_id = TEGRA210_CLK_PLL_C },
22796b301a05SRhyland Klein 	{ .con_id = "pll_c_out1", .dt_id = TEGRA210_CLK_PLL_C_OUT1 },
22806b301a05SRhyland Klein 	{ .con_id = "pll_c2", .dt_id = TEGRA210_CLK_PLL_C2 },
22816b301a05SRhyland Klein 	{ .con_id = "pll_c3", .dt_id = TEGRA210_CLK_PLL_C3 },
22826b301a05SRhyland Klein 	{ .con_id = "pll_p", .dt_id = TEGRA210_CLK_PLL_P },
22836b301a05SRhyland Klein 	{ .con_id = "pll_p_out1", .dt_id = TEGRA210_CLK_PLL_P_OUT1 },
22846b301a05SRhyland Klein 	{ .con_id = "pll_p_out2", .dt_id = TEGRA210_CLK_PLL_P_OUT2 },
22856b301a05SRhyland Klein 	{ .con_id = "pll_p_out3", .dt_id = TEGRA210_CLK_PLL_P_OUT3 },
22866b301a05SRhyland Klein 	{ .con_id = "pll_p_out4", .dt_id = TEGRA210_CLK_PLL_P_OUT4 },
22876b301a05SRhyland Klein 	{ .con_id = "pll_m", .dt_id = TEGRA210_CLK_PLL_M },
22886b301a05SRhyland Klein 	{ .con_id = "pll_m_out1", .dt_id = TEGRA210_CLK_PLL_M_OUT1 },
22896b301a05SRhyland Klein 	{ .con_id = "pll_x", .dt_id = TEGRA210_CLK_PLL_X },
22906b301a05SRhyland Klein 	{ .con_id = "pll_x_out0", .dt_id = TEGRA210_CLK_PLL_X_OUT0 },
22916b301a05SRhyland Klein 	{ .con_id = "pll_u", .dt_id = TEGRA210_CLK_PLL_U },
22926b301a05SRhyland Klein 	{ .con_id = "pll_u_out", .dt_id = TEGRA210_CLK_PLL_U_OUT },
22936b301a05SRhyland Klein 	{ .con_id = "pll_u_out1", .dt_id = TEGRA210_CLK_PLL_U_OUT1 },
22946b301a05SRhyland Klein 	{ .con_id = "pll_u_out2", .dt_id = TEGRA210_CLK_PLL_U_OUT2 },
22956b301a05SRhyland Klein 	{ .con_id = "pll_u_480M", .dt_id = TEGRA210_CLK_PLL_U_480M },
22966b301a05SRhyland Klein 	{ .con_id = "pll_u_60M", .dt_id = TEGRA210_CLK_PLL_U_60M },
22976b301a05SRhyland Klein 	{ .con_id = "pll_u_48M", .dt_id = TEGRA210_CLK_PLL_U_48M },
22986b301a05SRhyland Klein 	{ .con_id = "pll_d", .dt_id = TEGRA210_CLK_PLL_D },
22996b301a05SRhyland Klein 	{ .con_id = "pll_d_out0", .dt_id = TEGRA210_CLK_PLL_D_OUT0 },
23006b301a05SRhyland Klein 	{ .con_id = "pll_d2", .dt_id = TEGRA210_CLK_PLL_D2 },
23016b301a05SRhyland Klein 	{ .con_id = "pll_d2_out0", .dt_id = TEGRA210_CLK_PLL_D2_OUT0 },
23026b301a05SRhyland Klein 	{ .con_id = "pll_a", .dt_id = TEGRA210_CLK_PLL_A },
23036b301a05SRhyland Klein 	{ .con_id = "pll_a_out0", .dt_id = TEGRA210_CLK_PLL_A_OUT0 },
23046b301a05SRhyland Klein 	{ .con_id = "pll_re_vco", .dt_id = TEGRA210_CLK_PLL_RE_VCO },
23056b301a05SRhyland Klein 	{ .con_id = "pll_re_out", .dt_id = TEGRA210_CLK_PLL_RE_OUT },
23066b301a05SRhyland Klein 	{ .con_id = "spdif_in_sync", .dt_id = TEGRA210_CLK_SPDIF_IN_SYNC },
23076b301a05SRhyland Klein 	{ .con_id = "i2s0_sync", .dt_id = TEGRA210_CLK_I2S0_SYNC },
23086b301a05SRhyland Klein 	{ .con_id = "i2s1_sync", .dt_id = TEGRA210_CLK_I2S1_SYNC },
23096b301a05SRhyland Klein 	{ .con_id = "i2s2_sync", .dt_id = TEGRA210_CLK_I2S2_SYNC },
23106b301a05SRhyland Klein 	{ .con_id = "i2s3_sync", .dt_id = TEGRA210_CLK_I2S3_SYNC },
23116b301a05SRhyland Klein 	{ .con_id = "i2s4_sync", .dt_id = TEGRA210_CLK_I2S4_SYNC },
23126b301a05SRhyland Klein 	{ .con_id = "vimclk_sync", .dt_id = TEGRA210_CLK_VIMCLK_SYNC },
23136b301a05SRhyland Klein 	{ .con_id = "audio0", .dt_id = TEGRA210_CLK_AUDIO0 },
23146b301a05SRhyland Klein 	{ .con_id = "audio1", .dt_id = TEGRA210_CLK_AUDIO1 },
23156b301a05SRhyland Klein 	{ .con_id = "audio2", .dt_id = TEGRA210_CLK_AUDIO2 },
23166b301a05SRhyland Klein 	{ .con_id = "audio3", .dt_id = TEGRA210_CLK_AUDIO3 },
23176b301a05SRhyland Klein 	{ .con_id = "audio4", .dt_id = TEGRA210_CLK_AUDIO4 },
23186b301a05SRhyland Klein 	{ .con_id = "spdif", .dt_id = TEGRA210_CLK_SPDIF },
23196b301a05SRhyland Klein 	{ .con_id = "spdif_2x", .dt_id = TEGRA210_CLK_SPDIF_2X },
23206b301a05SRhyland Klein 	{ .con_id = "extern1", .dev_id = "clk_out_1", .dt_id = TEGRA210_CLK_EXTERN1 },
23216b301a05SRhyland Klein 	{ .con_id = "extern2", .dev_id = "clk_out_2", .dt_id = TEGRA210_CLK_EXTERN2 },
23226b301a05SRhyland Klein 	{ .con_id = "extern3", .dev_id = "clk_out_3", .dt_id = TEGRA210_CLK_EXTERN3 },
23236b301a05SRhyland Klein 	{ .con_id = "blink", .dt_id = TEGRA210_CLK_BLINK },
23246b301a05SRhyland Klein 	{ .con_id = "cclk_g", .dt_id = TEGRA210_CLK_CCLK_G },
23256b301a05SRhyland Klein 	{ .con_id = "cclk_lp", .dt_id = TEGRA210_CLK_CCLK_LP },
23266b301a05SRhyland Klein 	{ .con_id = "sclk", .dt_id = TEGRA210_CLK_SCLK },
23276b301a05SRhyland Klein 	{ .con_id = "hclk", .dt_id = TEGRA210_CLK_HCLK },
23286b301a05SRhyland Klein 	{ .con_id = "pclk", .dt_id = TEGRA210_CLK_PCLK },
23296b301a05SRhyland Klein 	{ .con_id = "fuse", .dt_id = TEGRA210_CLK_FUSE },
23306b301a05SRhyland Klein 	{ .dev_id = "rtc-tegra", .dt_id = TEGRA210_CLK_RTC },
23316b301a05SRhyland Klein 	{ .dev_id = "timer", .dt_id = TEGRA210_CLK_TIMER },
23326b301a05SRhyland Klein 	{ .con_id = "pll_c4_out0", .dt_id = TEGRA210_CLK_PLL_C4_OUT0 },
23336b301a05SRhyland Klein 	{ .con_id = "pll_c4_out1", .dt_id = TEGRA210_CLK_PLL_C4_OUT1 },
23346b301a05SRhyland Klein 	{ .con_id = "pll_c4_out2", .dt_id = TEGRA210_CLK_PLL_C4_OUT2 },
23356b301a05SRhyland Klein 	{ .con_id = "pll_c4_out3", .dt_id = TEGRA210_CLK_PLL_C4_OUT3 },
23366b301a05SRhyland Klein 	{ .con_id = "dpaux", .dt_id = TEGRA210_CLK_DPAUX },
23376b301a05SRhyland Klein 	{ .con_id = "sor0", .dt_id = TEGRA210_CLK_SOR0 },
23386b301a05SRhyland Klein };
23396b301a05SRhyland Klein 
23406b301a05SRhyland Klein static struct tegra_audio_clk_info tegra210_audio_plls[] = {
23416b301a05SRhyland Klein 	{ "pll_a", &pll_a_params, tegra_clk_pll_a, "pll_ref" },
23426b301a05SRhyland Klein 	{ "pll_a1", &pll_a1_params, tegra_clk_pll_a1, "pll_ref" },
23436b301a05SRhyland Klein };
23446b301a05SRhyland Klein 
23456b301a05SRhyland Klein static struct clk **clks;
23466b301a05SRhyland Klein 
23476b301a05SRhyland Klein static void tegra210_utmi_param_configure(void __iomem *clk_base)
23486b301a05SRhyland Klein {
23496b301a05SRhyland Klein 	u32 reg;
23506b301a05SRhyland Klein 	int i;
23516b301a05SRhyland Klein 
23526b301a05SRhyland Klein 	for (i = 0; i < ARRAY_SIZE(utmi_parameters); i++) {
23536b301a05SRhyland Klein 		if (osc_freq == utmi_parameters[i].osc_frequency)
23546b301a05SRhyland Klein 			break;
23556b301a05SRhyland Klein 	}
23566b301a05SRhyland Klein 
23576b301a05SRhyland Klein 	if (i >= ARRAY_SIZE(utmi_parameters)) {
23586b301a05SRhyland Klein 		pr_err("%s: Unexpected oscillator freq %lu\n", __func__,
23596b301a05SRhyland Klein 		       osc_freq);
23606b301a05SRhyland Klein 		return;
23616b301a05SRhyland Klein 	}
23626b301a05SRhyland Klein 
23636b301a05SRhyland Klein 	reg = readl_relaxed(clk_base + PLLU_HW_PWRDN_CFG0);
23646b301a05SRhyland Klein 	reg |= PLLU_HW_PWRDN_CFG0_IDDQ_PD_INCLUDE |
23656b301a05SRhyland Klein 	       PLLU_HW_PWRDN_CFG0_USE_SWITCH_DETECT |
23666b301a05SRhyland Klein 	       PLLU_HW_PWRDN_CFG0_USE_LOCKDET;
23676b301a05SRhyland Klein 	reg &= ~(PLLU_HW_PWRDN_CFG0_CLK_ENABLE_SWCTL |
23686b301a05SRhyland Klein 		  PLLU_HW_PWRDN_CFG0_CLK_SWITCH_SWCTL);
23696b301a05SRhyland Klein 	writel_relaxed(reg, clk_base + PLLU_HW_PWRDN_CFG0);
23706b301a05SRhyland Klein 
23716b301a05SRhyland Klein 	reg = readl_relaxed(clk_base + PLLU_HW_PWRDN_CFG0);
23726b301a05SRhyland Klein 	reg |= PLLU_HW_PWRDN_CFG0_SEQ_ENABLE;
23736b301a05SRhyland Klein 	writel_relaxed(reg, clk_base + PLLU_HW_PWRDN_CFG0);
23746b301a05SRhyland Klein 	udelay(1);
23756b301a05SRhyland Klein 
23766b301a05SRhyland Klein 	reg = readl_relaxed(clk_base + PLLU_BASE);
23776b301a05SRhyland Klein 	reg &= ~PLLU_BASE_CLKENABLE_USB;
23786b301a05SRhyland Klein 	writel_relaxed(reg, clk_base + PLLU_BASE);
23796b301a05SRhyland Klein 
23806b301a05SRhyland Klein 	reg = readl_relaxed(clk_base + UTMIPLL_HW_PWRDN_CFG0);
23816b301a05SRhyland Klein 	reg &= ~UTMIPLL_HW_PWRDN_CFG0_IDDQ_OVERRIDE;
23826b301a05SRhyland Klein 	writel_relaxed(reg, clk_base + UTMIPLL_HW_PWRDN_CFG0);
23836b301a05SRhyland Klein 
23846b301a05SRhyland Klein 	udelay(10);
23856b301a05SRhyland Klein 
23866b301a05SRhyland Klein 	reg = readl_relaxed(clk_base + UTMIP_PLL_CFG2);
23876b301a05SRhyland Klein 
23886b301a05SRhyland Klein 	/* Program UTMIP PLL stable and active counts */
23896b301a05SRhyland Klein 	/* [FIXME] arclk_rst.h says WRONG! This should be 1ms -> 0x50 Check! */
23906b301a05SRhyland Klein 	reg &= ~UTMIP_PLL_CFG2_STABLE_COUNT(~0);
23916b301a05SRhyland Klein 	reg |= UTMIP_PLL_CFG2_STABLE_COUNT(utmi_parameters[i].stable_count);
23926b301a05SRhyland Klein 
23936b301a05SRhyland Klein 	reg &= ~UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(~0);
23946b301a05SRhyland Klein 
23956b301a05SRhyland Klein 	reg |= UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(utmi_parameters[i].
23966b301a05SRhyland Klein 					    active_delay_count);
23976b301a05SRhyland Klein 	writel_relaxed(reg, clk_base + UTMIP_PLL_CFG2);
23986b301a05SRhyland Klein 
23996b301a05SRhyland Klein 	/* Program UTMIP PLL delay and oscillator frequency counts */
24006b301a05SRhyland Klein 	reg = readl_relaxed(clk_base + UTMIP_PLL_CFG1);
24016b301a05SRhyland Klein 	reg &= ~UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(~0);
24026b301a05SRhyland Klein 
24036b301a05SRhyland Klein 	reg |= UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(utmi_parameters[i].
24046b301a05SRhyland Klein 					    enable_delay_count);
24056b301a05SRhyland Klein 
24066b301a05SRhyland Klein 	reg &= ~UTMIP_PLL_CFG1_XTAL_FREQ_COUNT(~0);
24076b301a05SRhyland Klein 	reg |= UTMIP_PLL_CFG1_XTAL_FREQ_COUNT(utmi_parameters[i].
24086b301a05SRhyland Klein 					   xtal_freq_count);
24096b301a05SRhyland Klein 
24106b301a05SRhyland Klein 	reg |= UTMIP_PLL_CFG1_FORCE_PLLU_POWERDOWN;
24116b301a05SRhyland Klein 	writel_relaxed(reg, clk_base + UTMIP_PLL_CFG1);
24126b301a05SRhyland Klein 
24136b301a05SRhyland Klein 	/* Remove power downs from UTMIP PLL control bits */
24146b301a05SRhyland Klein 	reg = readl_relaxed(clk_base + UTMIP_PLL_CFG1);
24156b301a05SRhyland Klein 	reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERDOWN;
24166b301a05SRhyland Klein 	reg |= UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERUP;
24176b301a05SRhyland Klein 	writel_relaxed(reg, clk_base + UTMIP_PLL_CFG1);
24186b301a05SRhyland Klein 	udelay(1);
24196b301a05SRhyland Klein 
24206b301a05SRhyland Klein 	/* Enable samplers for SNPS, XUSB_HOST, XUSB_DEV */
24216b301a05SRhyland Klein 	reg = readl_relaxed(clk_base + UTMIP_PLL_CFG2);
24226b301a05SRhyland Klein 	reg |= UTMIP_PLL_CFG2_FORCE_PD_SAMP_A_POWERUP;
24236b301a05SRhyland Klein 	reg |= UTMIP_PLL_CFG2_FORCE_PD_SAMP_B_POWERUP;
24246b301a05SRhyland Klein 	reg |= UTMIP_PLL_CFG2_FORCE_PD_SAMP_D_POWERUP;
24256b301a05SRhyland Klein 	reg &= ~UTMIP_PLL_CFG2_FORCE_PD_SAMP_A_POWERDOWN;
24266b301a05SRhyland Klein 	reg &= ~UTMIP_PLL_CFG2_FORCE_PD_SAMP_B_POWERDOWN;
24276b301a05SRhyland Klein 	reg &= ~UTMIP_PLL_CFG2_FORCE_PD_SAMP_D_POWERDOWN;
24286b301a05SRhyland Klein 	writel_relaxed(reg, clk_base + UTMIP_PLL_CFG2);
24296b301a05SRhyland Klein 
24306b301a05SRhyland Klein 	/* Setup HW control of UTMIPLL */
24316b301a05SRhyland Klein 	reg = readl_relaxed(clk_base + UTMIP_PLL_CFG1);
24326b301a05SRhyland Klein 	reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERDOWN;
24336b301a05SRhyland Klein 	reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERUP;
24346b301a05SRhyland Klein 	writel_relaxed(reg, clk_base + UTMIP_PLL_CFG1);
24356b301a05SRhyland Klein 
24366b301a05SRhyland Klein 	reg = readl_relaxed(clk_base + UTMIPLL_HW_PWRDN_CFG0);
24376b301a05SRhyland Klein 	reg |= UTMIPLL_HW_PWRDN_CFG0_USE_LOCKDET;
24386b301a05SRhyland Klein 	reg &= ~UTMIPLL_HW_PWRDN_CFG0_CLK_ENABLE_SWCTL;
24396b301a05SRhyland Klein 	writel_relaxed(reg, clk_base + UTMIPLL_HW_PWRDN_CFG0);
24406b301a05SRhyland Klein 
24416b301a05SRhyland Klein 	udelay(1);
24426b301a05SRhyland Klein 
24436b301a05SRhyland Klein 	reg = readl_relaxed(clk_base + XUSB_PLL_CFG0);
24446b301a05SRhyland Klein 	reg &= ~XUSB_PLL_CFG0_UTMIPLL_LOCK_DLY;
24456b301a05SRhyland Klein 	writel_relaxed(reg, clk_base + XUSB_PLL_CFG0);
24466b301a05SRhyland Klein 
24476b301a05SRhyland Klein 	udelay(1);
24486b301a05SRhyland Klein 
24496b301a05SRhyland Klein 	/* Enable HW control UTMIPLL */
24506b301a05SRhyland Klein 	reg = readl_relaxed(clk_base + UTMIPLL_HW_PWRDN_CFG0);
24516b301a05SRhyland Klein 	reg |= UTMIPLL_HW_PWRDN_CFG0_SEQ_ENABLE;
24526b301a05SRhyland Klein 	writel_relaxed(reg, clk_base + UTMIPLL_HW_PWRDN_CFG0);
24536b301a05SRhyland Klein }
24546b301a05SRhyland Klein 
24556b301a05SRhyland Klein static __init void tegra210_periph_clk_init(void __iomem *clk_base,
24566b301a05SRhyland Klein 					    void __iomem *pmc_base)
24576b301a05SRhyland Klein {
24586b301a05SRhyland Klein 	struct clk *clk;
24596b301a05SRhyland Klein 
24606b301a05SRhyland Klein 	/* xusb_ss_div2 */
24616b301a05SRhyland Klein 	clk = clk_register_fixed_factor(NULL, "xusb_ss_div2", "xusb_ss_src", 0,
24626b301a05SRhyland Klein 					1, 2);
24636b301a05SRhyland Klein 	clks[TEGRA210_CLK_XUSB_SS_DIV2] = clk;
24646b301a05SRhyland Klein 
24656b301a05SRhyland Klein 	/* pll_d_dsi_out */
24666b301a05SRhyland Klein 	clk = clk_register_gate(NULL, "pll_d_dsi_out", "pll_d_out0", 0,
24676b301a05SRhyland Klein 				clk_base + PLLD_MISC0, 21, 0, &pll_d_lock);
24686b301a05SRhyland Klein 	clks[TEGRA210_CLK_PLL_D_DSI_OUT] = clk;
24696b301a05SRhyland Klein 
24706b301a05SRhyland Klein 	/* dsia */
24716b301a05SRhyland Klein 	clk = tegra_clk_register_periph_gate("dsia", "pll_d_dsi_out", 0,
24726b301a05SRhyland Klein 					     clk_base, 0, 48,
24736b301a05SRhyland Klein 					     periph_clk_enb_refcnt);
24746b301a05SRhyland Klein 	clks[TEGRA210_CLK_DSIA] = clk;
24756b301a05SRhyland Klein 
24766b301a05SRhyland Klein 	/* dsib */
24776b301a05SRhyland Klein 	clk = tegra_clk_register_periph_gate("dsib", "pll_d_dsi_out", 0,
24786b301a05SRhyland Klein 					     clk_base, 0, 82,
24796b301a05SRhyland Klein 					     periph_clk_enb_refcnt);
24806b301a05SRhyland Klein 	clks[TEGRA210_CLK_DSIB] = clk;
24816b301a05SRhyland Klein 
24826b301a05SRhyland Klein 	/* emc mux */
24836b301a05SRhyland Klein 	clk = clk_register_mux(NULL, "emc_mux", mux_pllmcp_clkm,
24846b301a05SRhyland Klein 			       ARRAY_SIZE(mux_pllmcp_clkm), 0,
24856b301a05SRhyland Klein 			       clk_base + CLK_SOURCE_EMC,
24866b301a05SRhyland Klein 			       29, 3, 0, &emc_lock);
24876b301a05SRhyland Klein 
24886b301a05SRhyland Klein 	clk = tegra_clk_register_mc("mc", "emc_mux", clk_base + CLK_SOURCE_EMC,
24896b301a05SRhyland Klein 				    &emc_lock);
24906b301a05SRhyland Klein 	clks[TEGRA210_CLK_MC] = clk;
24916b301a05SRhyland Klein 
24926b301a05SRhyland Klein 	/* cml0 */
24936b301a05SRhyland Klein 	clk = clk_register_gate(NULL, "cml0", "pll_e", 0, clk_base + PLLE_AUX,
24946b301a05SRhyland Klein 				0, 0, &pll_e_lock);
24956b301a05SRhyland Klein 	clk_register_clkdev(clk, "cml0", NULL);
24966b301a05SRhyland Klein 	clks[TEGRA210_CLK_CML0] = clk;
24976b301a05SRhyland Klein 
24986b301a05SRhyland Klein 	/* cml1 */
24996b301a05SRhyland Klein 	clk = clk_register_gate(NULL, "cml1", "pll_e", 0, clk_base + PLLE_AUX,
25006b301a05SRhyland Klein 				1, 0, &pll_e_lock);
25016b301a05SRhyland Klein 	clk_register_clkdev(clk, "cml1", NULL);
25026b301a05SRhyland Klein 	clks[TEGRA210_CLK_CML1] = clk;
25036b301a05SRhyland Klein 
25046b301a05SRhyland Klein 	tegra_periph_clk_init(clk_base, pmc_base, tegra210_clks, &pll_p_params);
25056b301a05SRhyland Klein }
25066b301a05SRhyland Klein 
25076b301a05SRhyland Klein static void __init tegra210_pll_init(void __iomem *clk_base,
25086b301a05SRhyland Klein 				     void __iomem *pmc)
25096b301a05SRhyland Klein {
25106b301a05SRhyland Klein 	u32 val;
25116b301a05SRhyland Klein 	struct clk *clk;
25126b301a05SRhyland Klein 
25136b301a05SRhyland Klein 	/* PLLC */
25146b301a05SRhyland Klein 	clk = tegra_clk_register_pllxc_tegra210("pll_c", "pll_ref", clk_base,
25156b301a05SRhyland Klein 			pmc, 0, &pll_c_params, NULL);
25166b301a05SRhyland Klein 	if (!WARN_ON(IS_ERR(clk)))
25176b301a05SRhyland Klein 		clk_register_clkdev(clk, "pll_c", NULL);
25186b301a05SRhyland Klein 	clks[TEGRA210_CLK_PLL_C] = clk;
25196b301a05SRhyland Klein 
25206b301a05SRhyland Klein 	/* PLLC_OUT1 */
25216b301a05SRhyland Klein 	clk = tegra_clk_register_divider("pll_c_out1_div", "pll_c",
25226b301a05SRhyland Klein 			clk_base + PLLC_OUT, 0, TEGRA_DIVIDER_ROUND_UP,
25236b301a05SRhyland Klein 			8, 8, 1, NULL);
25246b301a05SRhyland Klein 	clk = tegra_clk_register_pll_out("pll_c_out1", "pll_c_out1_div",
25256b301a05SRhyland Klein 				clk_base + PLLC_OUT, 1, 0,
25266b301a05SRhyland Klein 				CLK_SET_RATE_PARENT, 0, NULL);
25276b301a05SRhyland Klein 	clk_register_clkdev(clk, "pll_c_out1", NULL);
25286b301a05SRhyland Klein 	clks[TEGRA210_CLK_PLL_C_OUT1] = clk;
25296b301a05SRhyland Klein 
25306b301a05SRhyland Klein 	/* PLLC_UD */
25316b301a05SRhyland Klein 	clk = clk_register_fixed_factor(NULL, "pll_c_ud", "pll_c",
25326b301a05SRhyland Klein 					CLK_SET_RATE_PARENT, 1, 1);
25336b301a05SRhyland Klein 	clk_register_clkdev(clk, "pll_c_ud", NULL);
25346b301a05SRhyland Klein 	clks[TEGRA210_CLK_PLL_C_UD] = clk;
25356b301a05SRhyland Klein 
25366b301a05SRhyland Klein 	/* PLLC2 */
25376b301a05SRhyland Klein 	clk = tegra_clk_register_pllc_tegra210("pll_c2", "pll_ref", clk_base,
25386b301a05SRhyland Klein 			     pmc, 0, &pll_c2_params, NULL);
25396b301a05SRhyland Klein 	clk_register_clkdev(clk, "pll_c2", NULL);
25406b301a05SRhyland Klein 	clks[TEGRA210_CLK_PLL_C2] = clk;
25416b301a05SRhyland Klein 
25426b301a05SRhyland Klein 	/* PLLC3 */
25436b301a05SRhyland Klein 	clk = tegra_clk_register_pllc_tegra210("pll_c3", "pll_ref", clk_base,
25446b301a05SRhyland Klein 			     pmc, 0, &pll_c3_params, NULL);
25456b301a05SRhyland Klein 	clk_register_clkdev(clk, "pll_c3", NULL);
25466b301a05SRhyland Klein 	clks[TEGRA210_CLK_PLL_C3] = clk;
25476b301a05SRhyland Klein 
25486b301a05SRhyland Klein 	/* PLLM */
25496b301a05SRhyland Klein 	clk = tegra_clk_register_pllm("pll_m", "osc", clk_base, pmc,
25506b301a05SRhyland Klein 			     CLK_SET_RATE_GATE, &pll_m_params, NULL);
25516b301a05SRhyland Klein 	clk_register_clkdev(clk, "pll_m", NULL);
25526b301a05SRhyland Klein 	clks[TEGRA210_CLK_PLL_M] = clk;
25536b301a05SRhyland Klein 
25546b301a05SRhyland Klein 	/* PLLMB */
25556b301a05SRhyland Klein 	clk = tegra_clk_register_pllmb("pll_mb", "osc", clk_base, pmc,
25566b301a05SRhyland Klein 			     CLK_SET_RATE_GATE, &pll_mb_params, NULL);
25576b301a05SRhyland Klein 	clk_register_clkdev(clk, "pll_mb", NULL);
25586b301a05SRhyland Klein 	clks[TEGRA210_CLK_PLL_MB] = clk;
25596b301a05SRhyland Klein 
25606b301a05SRhyland Klein 	clk_register_clkdev(clk, "pll_m_out1", NULL);
25616b301a05SRhyland Klein 	clks[TEGRA210_CLK_PLL_M_OUT1] = clk;
25626b301a05SRhyland Klein 
25636b301a05SRhyland Klein 	/* PLLM_UD */
25646b301a05SRhyland Klein 	clk = clk_register_fixed_factor(NULL, "pll_m_ud", "pll_m",
25656b301a05SRhyland Klein 					CLK_SET_RATE_PARENT, 1, 1);
25666b301a05SRhyland Klein 	clk_register_clkdev(clk, "pll_m_ud", NULL);
25676b301a05SRhyland Klein 	clks[TEGRA210_CLK_PLL_M_UD] = clk;
25686b301a05SRhyland Klein 
25696b301a05SRhyland Klein 	/* PLLU_VCO */
25706b301a05SRhyland Klein 	val = readl(clk_base + pll_u_vco_params.base_reg);
25712d5b6cf8SJon Hunter 	val &= ~PLLU_BASE_OVERRIDE; /* disable PLLU_OVERRIDE */
25726b301a05SRhyland Klein 	writel(val, clk_base + pll_u_vco_params.base_reg);
25736b301a05SRhyland Klein 
25746b301a05SRhyland Klein 	clk = tegra_clk_register_pllre("pll_u_vco", "pll_ref", clk_base, pmc,
25756b301a05SRhyland Klein 			    0, &pll_u_vco_params, &pll_u_lock, pll_ref_freq);
25766b301a05SRhyland Klein 	clk_register_clkdev(clk, "pll_u_vco", NULL);
25776b301a05SRhyland Klein 	clks[TEGRA210_CLK_PLL_U] = clk;
25786b301a05SRhyland Klein 
25796b301a05SRhyland Klein 	/* PLLU_OUT */
25806b301a05SRhyland Klein 	clk = clk_register_divider_table(NULL, "pll_u_out", "pll_u_vco", 0,
25816b301a05SRhyland Klein 					 clk_base + PLLU_BASE, 16, 4, 0,
25826b301a05SRhyland Klein 					 pll_vco_post_div_table, NULL);
25836b301a05SRhyland Klein 	clk_register_clkdev(clk, "pll_u_out", NULL);
25846b301a05SRhyland Klein 	clks[TEGRA210_CLK_PLL_U_OUT] = clk;
25856b301a05SRhyland Klein 
25866b301a05SRhyland Klein 	/* PLLU_OUT1 */
25876b301a05SRhyland Klein 	clk = tegra_clk_register_divider("pll_u_out1_div", "pll_u_out",
25886b301a05SRhyland Klein 				clk_base + PLLU_OUTA, 0,
25896b301a05SRhyland Klein 				TEGRA_DIVIDER_ROUND_UP,
25906b301a05SRhyland Klein 				8, 8, 1, &pll_u_lock);
25916b301a05SRhyland Klein 	clk = tegra_clk_register_pll_out("pll_u_out1", "pll_u_out1_div",
25926b301a05SRhyland Klein 				clk_base + PLLU_OUTA, 1, 0,
25936b301a05SRhyland Klein 				CLK_SET_RATE_PARENT, 0, &pll_u_lock);
25946b301a05SRhyland Klein 	clk_register_clkdev(clk, "pll_u_out1", NULL);
25956b301a05SRhyland Klein 	clks[TEGRA210_CLK_PLL_U_OUT1] = clk;
25966b301a05SRhyland Klein 
25976b301a05SRhyland Klein 	/* PLLU_OUT2 */
25986b301a05SRhyland Klein 	clk = tegra_clk_register_divider("pll_u_out2_div", "pll_u_out",
25996b301a05SRhyland Klein 				clk_base + PLLU_OUTA, 0,
26006b301a05SRhyland Klein 				TEGRA_DIVIDER_ROUND_UP,
26016b301a05SRhyland Klein 				24, 8, 1, &pll_u_lock);
26026b301a05SRhyland Klein 	clk = tegra_clk_register_pll_out("pll_u_out2", "pll_u_out2_div",
26036b301a05SRhyland Klein 				clk_base + PLLU_OUTA, 17, 16,
26046b301a05SRhyland Klein 				CLK_SET_RATE_PARENT, 0, &pll_u_lock);
26056b301a05SRhyland Klein 	clk_register_clkdev(clk, "pll_u_out2", NULL);
26066b301a05SRhyland Klein 	clks[TEGRA210_CLK_PLL_U_OUT2] = clk;
26076b301a05SRhyland Klein 
26086b301a05SRhyland Klein 	tegra210_utmi_param_configure(clk_base);
26096b301a05SRhyland Klein 
26106b301a05SRhyland Klein 	/* PLLU_480M */
26116b301a05SRhyland Klein 	clk = clk_register_gate(NULL, "pll_u_480M", "pll_u_vco",
26126b301a05SRhyland Klein 				CLK_SET_RATE_PARENT, clk_base + PLLU_BASE,
26136b301a05SRhyland Klein 				22, 0, &pll_u_lock);
26146b301a05SRhyland Klein 	clk_register_clkdev(clk, "pll_u_480M", NULL);
26156b301a05SRhyland Klein 	clks[TEGRA210_CLK_PLL_U_480M] = clk;
26166b301a05SRhyland Klein 
26176b301a05SRhyland Klein 	/* PLLU_60M */
26186b301a05SRhyland Klein 	clk = clk_register_gate(NULL, "pll_u_60M", "pll_u_out2",
26196b301a05SRhyland Klein 				CLK_SET_RATE_PARENT, clk_base + PLLU_BASE,
26206b301a05SRhyland Klein 				23, 0, NULL);
26216b301a05SRhyland Klein 	clk_register_clkdev(clk, "pll_u_60M", NULL);
26226b301a05SRhyland Klein 	clks[TEGRA210_CLK_PLL_U_60M] = clk;
26236b301a05SRhyland Klein 
26246b301a05SRhyland Klein 	/* PLLU_48M */
26256b301a05SRhyland Klein 	clk = clk_register_gate(NULL, "pll_u_48M", "pll_u_out1",
26266b301a05SRhyland Klein 				CLK_SET_RATE_PARENT, clk_base + PLLU_BASE,
26276b301a05SRhyland Klein 				25, 0, NULL);
26286b301a05SRhyland Klein 	clk_register_clkdev(clk, "pll_u_48M", NULL);
26296b301a05SRhyland Klein 	clks[TEGRA210_CLK_PLL_U_48M] = clk;
26306b301a05SRhyland Klein 
26316b301a05SRhyland Klein 	/* PLLD */
26326b301a05SRhyland Klein 	clk = tegra_clk_register_pll("pll_d", "pll_ref", clk_base, pmc, 0,
26336b301a05SRhyland Klein 			    &pll_d_params, &pll_d_lock);
26346b301a05SRhyland Klein 	clk_register_clkdev(clk, "pll_d", NULL);
26356b301a05SRhyland Klein 	clks[TEGRA210_CLK_PLL_D] = clk;
26366b301a05SRhyland Klein 
26376b301a05SRhyland Klein 	/* PLLD_OUT0 */
26386b301a05SRhyland Klein 	clk = clk_register_fixed_factor(NULL, "pll_d_out0", "pll_d",
26396b301a05SRhyland Klein 					CLK_SET_RATE_PARENT, 1, 2);
26406b301a05SRhyland Klein 	clk_register_clkdev(clk, "pll_d_out0", NULL);
26416b301a05SRhyland Klein 	clks[TEGRA210_CLK_PLL_D_OUT0] = clk;
26426b301a05SRhyland Klein 
26436b301a05SRhyland Klein 	/* PLLRE */
26446b301a05SRhyland Klein 	clk = tegra_clk_register_pllre("pll_re_vco", "pll_ref", clk_base, pmc,
26456b301a05SRhyland Klein 			     0, &pll_re_vco_params, &pll_re_lock, pll_ref_freq);
26466b301a05SRhyland Klein 	clk_register_clkdev(clk, "pll_re_vco", NULL);
26476b301a05SRhyland Klein 	clks[TEGRA210_CLK_PLL_RE_VCO] = clk;
26486b301a05SRhyland Klein 
26496b301a05SRhyland Klein 	clk = clk_register_divider_table(NULL, "pll_re_out", "pll_re_vco", 0,
26506b301a05SRhyland Klein 					 clk_base + PLLRE_BASE, 16, 5, 0,
26516b301a05SRhyland Klein 					 pll_vco_post_div_table, &pll_re_lock);
26526b301a05SRhyland Klein 	clk_register_clkdev(clk, "pll_re_out", NULL);
26536b301a05SRhyland Klein 	clks[TEGRA210_CLK_PLL_RE_OUT] = clk;
26546b301a05SRhyland Klein 
26556b301a05SRhyland Klein 	/* PLLE */
26566b301a05SRhyland Klein 	clk = tegra_clk_register_plle_tegra210("pll_e", "pll_ref",
26576b301a05SRhyland Klein 				      clk_base, 0, &pll_e_params, NULL);
26586b301a05SRhyland Klein 	clk_register_clkdev(clk, "pll_e", NULL);
26596b301a05SRhyland Klein 	clks[TEGRA210_CLK_PLL_E] = clk;
26606b301a05SRhyland Klein 
26616b301a05SRhyland Klein 	/* PLLC4 */
26626b301a05SRhyland Klein 	clk = tegra_clk_register_pllre("pll_c4_vco", "pll_ref", clk_base, pmc,
26636b301a05SRhyland Klein 			     0, &pll_c4_vco_params, NULL, pll_ref_freq);
26646b301a05SRhyland Klein 	clk_register_clkdev(clk, "pll_c4_vco", NULL);
26656b301a05SRhyland Klein 	clks[TEGRA210_CLK_PLL_C4] = clk;
26666b301a05SRhyland Klein 
26676b301a05SRhyland Klein 	/* PLLC4_OUT0 */
26686b301a05SRhyland Klein 	clk = clk_register_divider_table(NULL, "pll_c4_out0", "pll_c4_vco", 0,
26696b301a05SRhyland Klein 					 clk_base + PLLC4_BASE, 19, 4, 0,
26706b301a05SRhyland Klein 					 pll_vco_post_div_table, NULL);
26716b301a05SRhyland Klein 	clk_register_clkdev(clk, "pll_c4_out0", NULL);
26726b301a05SRhyland Klein 	clks[TEGRA210_CLK_PLL_C4_OUT0] = clk;
26736b301a05SRhyland Klein 
26746b301a05SRhyland Klein 	/* PLLC4_OUT1 */
26756b301a05SRhyland Klein 	clk = clk_register_fixed_factor(NULL, "pll_c4_out1", "pll_c4_vco",
26766b301a05SRhyland Klein 					CLK_SET_RATE_PARENT, 1, 3);
26776b301a05SRhyland Klein 	clk_register_clkdev(clk, "pll_c4_out1", NULL);
26786b301a05SRhyland Klein 	clks[TEGRA210_CLK_PLL_C4_OUT1] = clk;
26796b301a05SRhyland Klein 
26806b301a05SRhyland Klein 	/* PLLC4_OUT2 */
26816b301a05SRhyland Klein 	clk = clk_register_fixed_factor(NULL, "pll_c4_out2", "pll_c4_vco",
26826b301a05SRhyland Klein 					CLK_SET_RATE_PARENT, 1, 5);
26836b301a05SRhyland Klein 	clk_register_clkdev(clk, "pll_c4_out2", NULL);
26846b301a05SRhyland Klein 	clks[TEGRA210_CLK_PLL_C4_OUT2] = clk;
26856b301a05SRhyland Klein 
26866b301a05SRhyland Klein 	/* PLLC4_OUT3 */
26876b301a05SRhyland Klein 	clk = tegra_clk_register_divider("pll_c4_out3_div", "pll_c4_out0",
26886b301a05SRhyland Klein 			clk_base + PLLC4_OUT, 0, TEGRA_DIVIDER_ROUND_UP,
26896b301a05SRhyland Klein 			8, 8, 1, NULL);
26906b301a05SRhyland Klein 	clk = tegra_clk_register_pll_out("pll_c4_out3", "pll_c4_out3_div",
26916b301a05SRhyland Klein 				clk_base + PLLC4_OUT, 1, 0,
26926b301a05SRhyland Klein 				CLK_SET_RATE_PARENT, 0, NULL);
26936b301a05SRhyland Klein 	clk_register_clkdev(clk, "pll_c4_out3", NULL);
26946b301a05SRhyland Klein 	clks[TEGRA210_CLK_PLL_C4_OUT3] = clk;
26956b301a05SRhyland Klein 
26966b301a05SRhyland Klein 	/* PLLDP */
26976b301a05SRhyland Klein 	clk = tegra_clk_register_pllss_tegra210("pll_dp", "pll_ref", clk_base,
26986b301a05SRhyland Klein 					0, &pll_dp_params, NULL);
26996b301a05SRhyland Klein 	clk_register_clkdev(clk, "pll_dp", NULL);
27006b301a05SRhyland Klein 	clks[TEGRA210_CLK_PLL_DP] = clk;
27016b301a05SRhyland Klein 
27026b301a05SRhyland Klein 	/* PLLD2 */
27036b301a05SRhyland Klein 	clk = tegra_clk_register_pllss_tegra210("pll_d2", "pll_ref", clk_base,
27046b301a05SRhyland Klein 					0, &pll_d2_params, NULL);
27056b301a05SRhyland Klein 	clk_register_clkdev(clk, "pll_d2", NULL);
27066b301a05SRhyland Klein 	clks[TEGRA210_CLK_PLL_D2] = clk;
27076b301a05SRhyland Klein 
27086b301a05SRhyland Klein 	/* PLLD2_OUT0 */
27096b301a05SRhyland Klein 	clk = clk_register_fixed_factor(NULL, "pll_d2_out0", "pll_d2",
27106b301a05SRhyland Klein 					CLK_SET_RATE_PARENT, 1, 1);
27116b301a05SRhyland Klein 	clk_register_clkdev(clk, "pll_d2_out0", NULL);
27126b301a05SRhyland Klein 	clks[TEGRA210_CLK_PLL_D2_OUT0] = clk;
27136b301a05SRhyland Klein 
27146b301a05SRhyland Klein 	/* PLLP_OUT2 */
27156b301a05SRhyland Klein 	clk = clk_register_fixed_factor(NULL, "pll_p_out2", "pll_p",
27166b301a05SRhyland Klein 					CLK_SET_RATE_PARENT, 1, 2);
27176b301a05SRhyland Klein 	clk_register_clkdev(clk, "pll_p_out2", NULL);
27186b301a05SRhyland Klein 	clks[TEGRA210_CLK_PLL_P_OUT2] = clk;
27196b301a05SRhyland Klein 
27206b301a05SRhyland Klein }
27216b301a05SRhyland Klein 
27226b301a05SRhyland Klein /* Tegra210 CPU clock and reset control functions */
27236b301a05SRhyland Klein static void tegra210_wait_cpu_in_reset(u32 cpu)
27246b301a05SRhyland Klein {
27256b301a05SRhyland Klein 	unsigned int reg;
27266b301a05SRhyland Klein 
27276b301a05SRhyland Klein 	do {
27286b301a05SRhyland Klein 		reg = readl(clk_base + CLK_RST_CONTROLLER_CPU_CMPLX_STATUS);
27296b301a05SRhyland Klein 		cpu_relax();
27306b301a05SRhyland Klein 	} while (!(reg & (1 << cpu)));  /* check CPU been reset or not */
27316b301a05SRhyland Klein }
27326b301a05SRhyland Klein 
27336b301a05SRhyland Klein static void tegra210_disable_cpu_clock(u32 cpu)
27346b301a05SRhyland Klein {
27356b301a05SRhyland Klein 	/* flow controller would take care in the power sequence. */
27366b301a05SRhyland Klein }
27376b301a05SRhyland Klein 
27386b301a05SRhyland Klein #ifdef CONFIG_PM_SLEEP
27396b301a05SRhyland Klein static void tegra210_cpu_clock_suspend(void)
27406b301a05SRhyland Klein {
27416b301a05SRhyland Klein 	/* switch coresite to clk_m, save off original source */
27426b301a05SRhyland Klein 	tegra210_cpu_clk_sctx.clk_csite_src =
27436b301a05SRhyland Klein 				readl(clk_base + CLK_SOURCE_CSITE);
27446b301a05SRhyland Klein 	writel(3 << 30, clk_base + CLK_SOURCE_CSITE);
27456b301a05SRhyland Klein }
27466b301a05SRhyland Klein 
27476b301a05SRhyland Klein static void tegra210_cpu_clock_resume(void)
27486b301a05SRhyland Klein {
27496b301a05SRhyland Klein 	writel(tegra210_cpu_clk_sctx.clk_csite_src,
27506b301a05SRhyland Klein 				clk_base + CLK_SOURCE_CSITE);
27516b301a05SRhyland Klein }
27526b301a05SRhyland Klein #endif
27536b301a05SRhyland Klein 
27546b301a05SRhyland Klein static struct tegra_cpu_car_ops tegra210_cpu_car_ops = {
27556b301a05SRhyland Klein 	.wait_for_reset	= tegra210_wait_cpu_in_reset,
27566b301a05SRhyland Klein 	.disable_clock	= tegra210_disable_cpu_clock,
27576b301a05SRhyland Klein #ifdef CONFIG_PM_SLEEP
27586b301a05SRhyland Klein 	.suspend	= tegra210_cpu_clock_suspend,
27596b301a05SRhyland Klein 	.resume		= tegra210_cpu_clock_resume,
27606b301a05SRhyland Klein #endif
27616b301a05SRhyland Klein };
27626b301a05SRhyland Klein 
27636b301a05SRhyland Klein static const struct of_device_id pmc_match[] __initconst = {
27646b301a05SRhyland Klein 	{ .compatible = "nvidia,tegra210-pmc" },
27656b301a05SRhyland Klein 	{ },
27666b301a05SRhyland Klein };
27676b301a05SRhyland Klein 
27686b301a05SRhyland Klein static struct tegra_clk_init_table init_table[] __initdata = {
27696b301a05SRhyland Klein 	{ TEGRA210_CLK_UARTA, TEGRA210_CLK_PLL_P, 408000000, 0 },
27706b301a05SRhyland Klein 	{ TEGRA210_CLK_UARTB, TEGRA210_CLK_PLL_P, 408000000, 0 },
27716b301a05SRhyland Klein 	{ TEGRA210_CLK_UARTC, TEGRA210_CLK_PLL_P, 408000000, 0 },
27726b301a05SRhyland Klein 	{ TEGRA210_CLK_UARTD, TEGRA210_CLK_PLL_P, 408000000, 0 },
27736b301a05SRhyland Klein 	{ TEGRA210_CLK_PLL_A, TEGRA210_CLK_CLK_MAX, 564480000, 1 },
27746b301a05SRhyland Klein 	{ TEGRA210_CLK_PLL_A_OUT0, TEGRA210_CLK_CLK_MAX, 11289600, 1 },
27756b301a05SRhyland Klein 	{ TEGRA210_CLK_EXTERN1, TEGRA210_CLK_PLL_A_OUT0, 0, 1 },
27766b301a05SRhyland Klein 	{ TEGRA210_CLK_CLK_OUT_1_MUX, TEGRA210_CLK_EXTERN1, 0, 1 },
27776b301a05SRhyland Klein 	{ TEGRA210_CLK_CLK_OUT_1, TEGRA210_CLK_CLK_MAX, 0, 1 },
27786b301a05SRhyland Klein 	{ TEGRA210_CLK_I2S0, TEGRA210_CLK_PLL_A_OUT0, 11289600, 0 },
27796b301a05SRhyland Klein 	{ TEGRA210_CLK_I2S1, TEGRA210_CLK_PLL_A_OUT0, 11289600, 0 },
27806b301a05SRhyland Klein 	{ TEGRA210_CLK_I2S2, TEGRA210_CLK_PLL_A_OUT0, 11289600, 0 },
27816b301a05SRhyland Klein 	{ TEGRA210_CLK_I2S3, TEGRA210_CLK_PLL_A_OUT0, 11289600, 0 },
27826b301a05SRhyland Klein 	{ TEGRA210_CLK_I2S4, TEGRA210_CLK_PLL_A_OUT0, 11289600, 0 },
27836b301a05SRhyland Klein 	{ TEGRA210_CLK_HOST1X, TEGRA210_CLK_PLL_P, 136000000, 1 },
27846b301a05SRhyland Klein 	{ TEGRA210_CLK_SCLK_MUX, TEGRA210_CLK_PLL_P, 0, 1 },
27856b301a05SRhyland Klein 	{ TEGRA210_CLK_SCLK, TEGRA210_CLK_CLK_MAX, 102000000, 1 },
27866b301a05SRhyland Klein 	{ TEGRA210_CLK_DFLL_SOC, TEGRA210_CLK_PLL_P, 51000000, 1 },
27876b301a05SRhyland Klein 	{ TEGRA210_CLK_DFLL_REF, TEGRA210_CLK_PLL_P, 51000000, 1 },
27886b301a05SRhyland Klein 	{ TEGRA210_CLK_SBC4, TEGRA210_CLK_PLL_P, 12000000, 1 },
27896b301a05SRhyland Klein 	{ TEGRA210_CLK_PLL_RE_VCO, TEGRA210_CLK_CLK_MAX, 672000000, 1 },
27906b301a05SRhyland Klein 	{ TEGRA210_CLK_XUSB_GATE, TEGRA210_CLK_CLK_MAX, 0, 1 },
27916b301a05SRhyland Klein 	{ TEGRA210_CLK_XUSB_SS_SRC, TEGRA210_CLK_PLL_U_480M, 120000000, 0 },
27926b301a05SRhyland Klein 	{ TEGRA210_CLK_XUSB_FS_SRC, TEGRA210_CLK_PLL_U_48M, 48000000, 0 },
27936b301a05SRhyland Klein 	{ TEGRA210_CLK_XUSB_HS_SRC, TEGRA210_CLK_XUSB_SS_SRC, 120000000, 0 },
27946b301a05SRhyland Klein 	{ TEGRA210_CLK_XUSB_SSP_SRC, TEGRA210_CLK_XUSB_SS_SRC, 120000000, 0 },
27956b301a05SRhyland Klein 	{ TEGRA210_CLK_XUSB_FALCON_SRC, TEGRA210_CLK_PLL_P_OUT_XUSB, 204000000, 0 },
27966b301a05SRhyland Klein 	{ TEGRA210_CLK_XUSB_HOST_SRC, TEGRA210_CLK_PLL_P_OUT_XUSB, 102000000, 0 },
27976b301a05SRhyland Klein 	{ TEGRA210_CLK_XUSB_DEV_SRC, TEGRA210_CLK_PLL_P_OUT_XUSB, 102000000, 0 },
27986b301a05SRhyland Klein 	{ TEGRA210_CLK_SATA, TEGRA210_CLK_PLL_P, 104000000, 0 },
27996b301a05SRhyland Klein 	{ TEGRA210_CLK_SATA_OOB, TEGRA210_CLK_PLL_P, 204000000, 0 },
28006b301a05SRhyland Klein 	{ TEGRA210_CLK_EMC, TEGRA210_CLK_CLK_MAX, 0, 1 },
28016b301a05SRhyland Klein 	{ TEGRA210_CLK_MSELECT, TEGRA210_CLK_CLK_MAX, 0, 1 },
28026b301a05SRhyland Klein 	{ TEGRA210_CLK_CSITE, TEGRA210_CLK_CLK_MAX, 0, 1 },
28036b301a05SRhyland Klein 	{ TEGRA210_CLK_TSENSOR, TEGRA210_CLK_CLK_M, 400000, 0 },
28046b301a05SRhyland Klein 	{ TEGRA210_CLK_I2C1, TEGRA210_CLK_PLL_P, 0, 0 },
28056b301a05SRhyland Klein 	{ TEGRA210_CLK_I2C2, TEGRA210_CLK_PLL_P, 0, 0 },
28066b301a05SRhyland Klein 	{ TEGRA210_CLK_I2C3, TEGRA210_CLK_PLL_P, 0, 0 },
28076b301a05SRhyland Klein 	{ TEGRA210_CLK_I2C4, TEGRA210_CLK_PLL_P, 0, 0 },
28086b301a05SRhyland Klein 	{ TEGRA210_CLK_I2C5, TEGRA210_CLK_PLL_P, 0, 0 },
28096b301a05SRhyland Klein 	{ TEGRA210_CLK_I2C6, TEGRA210_CLK_PLL_P, 0, 0 },
28106b301a05SRhyland Klein 	{ TEGRA210_CLK_PLL_DP, TEGRA210_CLK_CLK_MAX, 270000000, 0 },
28116b301a05SRhyland Klein 	{ TEGRA210_CLK_SOC_THERM, TEGRA210_CLK_PLL_P, 51000000, 0 },
28126b301a05SRhyland Klein 	{ TEGRA210_CLK_CCLK_G, TEGRA210_CLK_CLK_MAX, 0, 1 },
28136b301a05SRhyland Klein 	/* This MUST be the last entry. */
28146b301a05SRhyland Klein 	{ TEGRA210_CLK_CLK_MAX, TEGRA210_CLK_CLK_MAX, 0, 0 },
28156b301a05SRhyland Klein };
28166b301a05SRhyland Klein 
28176b301a05SRhyland Klein /**
28186b301a05SRhyland Klein  * tegra210_clock_apply_init_table - initialize clocks on Tegra210 SoCs
28196b301a05SRhyland Klein  *
28206b301a05SRhyland Klein  * Program an initial clock rate and enable or disable clocks needed
28216b301a05SRhyland Klein  * by the rest of the kernel, for Tegra210 SoCs.  It is intended to be
28226b301a05SRhyland Klein  * called by assigning a pointer to it to tegra_clk_apply_init_table -
28236b301a05SRhyland Klein  * this will be called as an arch_initcall.  No return value.
28246b301a05SRhyland Klein  */
28256b301a05SRhyland Klein static void __init tegra210_clock_apply_init_table(void)
28266b301a05SRhyland Klein {
28276b301a05SRhyland Klein 	tegra_init_from_table(init_table, clks, TEGRA210_CLK_CLK_MAX);
28286b301a05SRhyland Klein }
28296b301a05SRhyland Klein 
28306b301a05SRhyland Klein /**
28316b301a05SRhyland Klein  * tegra210_clock_init - Tegra210-specific clock initialization
28326b301a05SRhyland Klein  * @np: struct device_node * of the DT node for the SoC CAR IP block
28336b301a05SRhyland Klein  *
28346b301a05SRhyland Klein  * Register most SoC clocks for the Tegra210 system-on-chip.  Intended
28356b301a05SRhyland Klein  * to be called by the OF init code when a DT node with the
28366b301a05SRhyland Klein  * "nvidia,tegra210-car" string is encountered, and declared with
28376b301a05SRhyland Klein  * CLK_OF_DECLARE.  No return value.
28386b301a05SRhyland Klein  */
28396b301a05SRhyland Klein static void __init tegra210_clock_init(struct device_node *np)
28406b301a05SRhyland Klein {
28416b301a05SRhyland Klein 	struct device_node *node;
28426b301a05SRhyland Klein 	u32 value, clk_m_div;
28436b301a05SRhyland Klein 
28446b301a05SRhyland Klein 	clk_base = of_iomap(np, 0);
28456b301a05SRhyland Klein 	if (!clk_base) {
28466b301a05SRhyland Klein 		pr_err("ioremap tegra210 CAR failed\n");
28476b301a05SRhyland Klein 		return;
28486b301a05SRhyland Klein 	}
28496b301a05SRhyland Klein 
28506b301a05SRhyland Klein 	node = of_find_matching_node(NULL, pmc_match);
28516b301a05SRhyland Klein 	if (!node) {
28526b301a05SRhyland Klein 		pr_err("Failed to find pmc node\n");
28536b301a05SRhyland Klein 		WARN_ON(1);
28546b301a05SRhyland Klein 		return;
28556b301a05SRhyland Klein 	}
28566b301a05SRhyland Klein 
28576b301a05SRhyland Klein 	pmc_base = of_iomap(node, 0);
28586b301a05SRhyland Klein 	if (!pmc_base) {
28596b301a05SRhyland Klein 		pr_err("Can't map pmc registers\n");
28606b301a05SRhyland Klein 		WARN_ON(1);
28616b301a05SRhyland Klein 		return;
28626b301a05SRhyland Klein 	}
28636b301a05SRhyland Klein 
28646b301a05SRhyland Klein 	clks = tegra_clk_init(clk_base, TEGRA210_CLK_CLK_MAX,
28656b301a05SRhyland Klein 			      TEGRA210_CAR_BANK_COUNT);
28666b301a05SRhyland Klein 	if (!clks)
28676b301a05SRhyland Klein 		return;
28686b301a05SRhyland Klein 
28696b301a05SRhyland Klein 	value = clk_readl(clk_base + SPARE_REG0) >> CLK_M_DIVISOR_SHIFT;
28706b301a05SRhyland Klein 	clk_m_div = (value & CLK_M_DIVISOR_MASK) + 1;
28716b301a05SRhyland Klein 
28726b301a05SRhyland Klein 	if (tegra_osc_clk_init(clk_base, tegra210_clks, tegra210_input_freq,
28736b301a05SRhyland Klein 			       ARRAY_SIZE(tegra210_input_freq), clk_m_div,
28746b301a05SRhyland Klein 			       &osc_freq, &pll_ref_freq) < 0)
28756b301a05SRhyland Klein 		return;
28766b301a05SRhyland Klein 
28776b301a05SRhyland Klein 	tegra_fixed_clk_init(tegra210_clks);
28786b301a05SRhyland Klein 	tegra210_pll_init(clk_base, pmc_base);
28796b301a05SRhyland Klein 	tegra210_periph_clk_init(clk_base, pmc_base);
28806b301a05SRhyland Klein 	tegra_audio_clk_init(clk_base, pmc_base, tegra210_clks,
28816b301a05SRhyland Klein 			     tegra210_audio_plls,
28826b301a05SRhyland Klein 			     ARRAY_SIZE(tegra210_audio_plls));
28836b301a05SRhyland Klein 	tegra_pmc_clk_init(pmc_base, tegra210_clks);
28846b301a05SRhyland Klein 
28856b301a05SRhyland Klein 	/* For Tegra210, PLLD is the only source for DSIA & DSIB */
28866b301a05SRhyland Klein 	value = clk_readl(clk_base + PLLD_BASE);
28876b301a05SRhyland Klein 	value &= ~BIT(25);
28886b301a05SRhyland Klein 	clk_writel(value, clk_base + PLLD_BASE);
28896b301a05SRhyland Klein 
28906b301a05SRhyland Klein 	tegra_clk_apply_init_table = tegra210_clock_apply_init_table;
28916b301a05SRhyland Klein 
28926b301a05SRhyland Klein 	tegra_super_clk_gen5_init(clk_base, pmc_base, tegra210_clks,
28936b301a05SRhyland Klein 				  &pll_x_params);
28946b301a05SRhyland Klein 	tegra_add_of_provider(np);
28956b301a05SRhyland Klein 	tegra_register_devclks(devclks, ARRAY_SIZE(devclks));
28966b301a05SRhyland Klein 
28976b301a05SRhyland Klein 	tegra_cpu_car_ops = &tegra210_cpu_car_ops;
28986b301a05SRhyland Klein }
28996b301a05SRhyland Klein CLK_OF_DECLARE(tegra210, "nvidia,tegra210-car", tegra210_clock_init);
2900