xref: /openbmc/u-boot/arch/arm/mach-keystone/include/mach/clock_defs.h (revision 83d290c56fab2d38cd1ab4c4cc7099559c1d5046)
1*83d290c5STom Rini /* SPDX-License-Identifier: GPL-2.0+ */
2dc7de222SMasahiro Yamada /*
3dc7de222SMasahiro Yamada  * keystone2: common pll clock definitions
4dc7de222SMasahiro Yamada  * (C) Copyright 2012-2014
5dc7de222SMasahiro Yamada  *     Texas Instruments Incorporated, <www.ti.com>
6dc7de222SMasahiro Yamada  */
7dc7de222SMasahiro Yamada 
8dc7de222SMasahiro Yamada #ifndef _CLOCK_DEFS_H_
9dc7de222SMasahiro Yamada #define _CLOCK_DEFS_H_
10dc7de222SMasahiro Yamada 
11dc7de222SMasahiro Yamada #include <asm/arch/hardware.h>
12dc7de222SMasahiro Yamada 
13dc7de222SMasahiro Yamada /* PLL Control Registers */
14dc7de222SMasahiro Yamada struct pllctl_regs {
15dc7de222SMasahiro Yamada 	u32	ctl;		/* 00 */
16dc7de222SMasahiro Yamada 	u32	ocsel;		/* 04 */
17dc7de222SMasahiro Yamada 	u32	secctl;		/* 08 */
18dc7de222SMasahiro Yamada 	u32	resv0;
19dc7de222SMasahiro Yamada 	u32	mult;		/* 10 */
20dc7de222SMasahiro Yamada 	u32	prediv;		/* 14 */
21dc7de222SMasahiro Yamada 	u32	div1;		/* 18 */
22dc7de222SMasahiro Yamada 	u32	div2;		/* 1c */
23dc7de222SMasahiro Yamada 	u32	div3;		/* 20 */
24dc7de222SMasahiro Yamada 	u32	oscdiv1;	/* 24 */
25dc7de222SMasahiro Yamada 	u32	resv1;		/* 28 */
26dc7de222SMasahiro Yamada 	u32	bpdiv;		/* 2c */
27dc7de222SMasahiro Yamada 	u32	wakeup;		/* 30 */
28dc7de222SMasahiro Yamada 	u32	resv2;
29dc7de222SMasahiro Yamada 	u32	cmd;		/* 38 */
30dc7de222SMasahiro Yamada 	u32	stat;		/* 3c */
31dc7de222SMasahiro Yamada 	u32	alnctl;		/* 40 */
32dc7de222SMasahiro Yamada 	u32	dchange;	/* 44 */
33dc7de222SMasahiro Yamada 	u32	cken;		/* 48 */
34dc7de222SMasahiro Yamada 	u32	ckstat;		/* 4c */
35dc7de222SMasahiro Yamada 	u32	systat;		/* 50 */
36dc7de222SMasahiro Yamada 	u32	ckctl;		/* 54 */
37dc7de222SMasahiro Yamada 	u32	resv3[2];
38dc7de222SMasahiro Yamada 	u32	div4;		/* 60 */
39dc7de222SMasahiro Yamada 	u32	div5;		/* 64 */
40dc7de222SMasahiro Yamada 	u32	div6;		/* 68 */
41dc7de222SMasahiro Yamada 	u32	div7;		/* 6c */
42dc7de222SMasahiro Yamada 	u32	div8;		/* 70 */
43dc7de222SMasahiro Yamada 	u32	div9;		/* 74 */
44dc7de222SMasahiro Yamada 	u32	div10;		/* 78 */
45dc7de222SMasahiro Yamada 	u32	div11;		/* 7c */
46dc7de222SMasahiro Yamada 	u32	div12;		/* 80 */
47dc7de222SMasahiro Yamada };
48dc7de222SMasahiro Yamada 
49dc7de222SMasahiro Yamada static struct pllctl_regs *pllctl_regs[] = {
50dc7de222SMasahiro Yamada 	(struct pllctl_regs *)(KS2_CLOCK_BASE + 0x100)
51dc7de222SMasahiro Yamada };
52dc7de222SMasahiro Yamada 
53dc7de222SMasahiro Yamada #define pllctl_reg(pll, reg)            (&(pllctl_regs[pll]->reg))
54dc7de222SMasahiro Yamada #define pllctl_reg_read(pll, reg)       __raw_readl(pllctl_reg(pll, reg))
55dc7de222SMasahiro Yamada #define pllctl_reg_write(pll, reg, val) __raw_writel(val, pllctl_reg(pll, reg))
56dc7de222SMasahiro Yamada 
57dc7de222SMasahiro Yamada #define pllctl_reg_rmw(pll, reg, mask, val) \
58dc7de222SMasahiro Yamada 	pllctl_reg_write(pll, reg, \
59dc7de222SMasahiro Yamada 		(pllctl_reg_read(pll, reg) & ~(mask)) | val)
60dc7de222SMasahiro Yamada 
61dc7de222SMasahiro Yamada #define pllctl_reg_setbits(pll, reg, mask) \
62dc7de222SMasahiro Yamada 	pllctl_reg_rmw(pll, reg, 0, mask)
63dc7de222SMasahiro Yamada 
64dc7de222SMasahiro Yamada #define pllctl_reg_clrbits(pll, reg, mask) \
65dc7de222SMasahiro Yamada 	pllctl_reg_rmw(pll, reg, mask, 0)
66dc7de222SMasahiro Yamada 
67dc7de222SMasahiro Yamada #define pll0div_read(N) ((pllctl_reg_read(CORE_PLL, div##N) & 0xff) + 1)
68dc7de222SMasahiro Yamada 
69c321a236SLokesh Vutla /* PLLCTL Bits */
70c321a236SLokesh Vutla #define PLLCTL_PLLENSRC_SHIF	5
71c321a236SLokesh Vutla #define PLLCTL_PLLENSRC_MASK	BIT(5)
72c321a236SLokesh Vutla #define PLLCTL_PLLRST_SHIFT	3
73c321a236SLokesh Vutla #define PLLCTL_PLLRST_MASK	BIT(3)
74c321a236SLokesh Vutla #define PLLCTL_PLLPWRDN_SHIFT	1
75c321a236SLokesh Vutla #define PLLCTL_PLLPWRDN_MASK	BIT(1)
76c321a236SLokesh Vutla #define PLLCTL_PLLEN_SHIFT	0
77c321a236SLokesh Vutla #define PLLCTL_PLLEN_MASK	BIT(0)
78c321a236SLokesh Vutla 
79c321a236SLokesh Vutla /* SECCTL Bits */
80c321a236SLokesh Vutla #define SECCTL_BYPASS_SHIFT	23
81c321a236SLokesh Vutla #define SECCTL_BYPASS_MASK	BIT(23)
82c321a236SLokesh Vutla #define SECCTL_OP_DIV_SHIFT	19
83c321a236SLokesh Vutla #define SECCTL_OP_DIV_MASK	(0xf << 19)
84c321a236SLokesh Vutla 
85c321a236SLokesh Vutla /* PLLM Bits */
86c321a236SLokesh Vutla #define PLLM_MULT_LO_SHIFT	0
87c321a236SLokesh Vutla #define PLLM_MULT_LO_MASK	0x3f
88c321a236SLokesh Vutla #define PLLM_MULT_LO_BITS	6
89c321a236SLokesh Vutla 
90c321a236SLokesh Vutla /* PLLDIVn Bits */
91c321a236SLokesh Vutla #define PLLDIV_ENABLE_SHIFT	15
92c321a236SLokesh Vutla #define PLLDIV_ENABLE_MASK	BIT(15)
93c321a236SLokesh Vutla #define PLLDIV_RATIO_SHIFT	0x0
94c321a236SLokesh Vutla #define PLLDIV_RATIO_MASK	0xff
95c321a236SLokesh Vutla #define PLLDIV_MAX		16
96c321a236SLokesh Vutla 
97c321a236SLokesh Vutla /* PLLCMD Bits */
98c321a236SLokesh Vutla #define PLLCMD_GOSET_SHIFT	0
99c321a236SLokesh Vutla #define PLLCMD_GOSET_MASK	BIT(0)
100c321a236SLokesh Vutla 
101c321a236SLokesh Vutla /* PLLSTAT Bits */
102c321a236SLokesh Vutla #define PLLSTAT_GOSTAT_SHIFT	0
103c321a236SLokesh Vutla #define PLLSTAT_GOSTAT_MASK	BIT(0)
104c321a236SLokesh Vutla 
105c321a236SLokesh Vutla /* Device Config PLLCTL0 */
106c321a236SLokesh Vutla #define CFG_PLLCTL0_BWADJ_SHIFT		24
107c321a236SLokesh Vutla #define CFG_PLLCTL0_BWADJ_MASK		(0xff << 24)
108c321a236SLokesh Vutla #define CFG_PLLCTL0_BWADJ_BITS		8
109c321a236SLokesh Vutla #define CFG_PLLCTL0_BYPASS_SHIFT	23
110c321a236SLokesh Vutla #define CFG_PLLCTL0_BYPASS_MASK		BIT(23)
111c321a236SLokesh Vutla #define CFG_PLLCTL0_CLKOD_SHIFT		19
112c321a236SLokesh Vutla #define CFG_PLLCTL0_CLKOD_MASK		(0xf << 19)
113c321a236SLokesh Vutla #define CFG_PLLCTL0_PLLM_HI_SHIFT	12
114c321a236SLokesh Vutla #define CFG_PLLCTL0_PLLM_HI_MASK	(0x7f << 12)
115c321a236SLokesh Vutla #define CFG_PLLCTL0_PLLM_SHIFT		6
116c321a236SLokesh Vutla #define CFG_PLLCTL0_PLLM_MASK		(0x1fff << 6)
117c321a236SLokesh Vutla #define CFG_PLLCTL0_PLLD_SHIFT		0
118c321a236SLokesh Vutla #define CFG_PLLCTL0_PLLD_MASK		0x3f
119c321a236SLokesh Vutla 
120c321a236SLokesh Vutla /* Device Config PLLCTL1 */
121c321a236SLokesh Vutla #define CFG_PLLCTL1_RST_SHIFT	14
122c321a236SLokesh Vutla #define CFG_PLLCTL1_RST_MASK	BIT(14)
123c321a236SLokesh Vutla #define CFG_PLLCTL1_PAPLL_SHIFT	13
124c321a236SLokesh Vutla #define CFG_PLLCTL1_PAPLL_MASK	BIT(13)
125c321a236SLokesh Vutla #define CFG_PLLCTL1_ENSAT_SHIFT	6
126c321a236SLokesh Vutla #define CFG_PLLCTL1_ENSAT_MASK	BIT(6)
127c321a236SLokesh Vutla #define CFG_PLLCTL1_BWADJ_SHIFT	0
128c321a236SLokesh Vutla #define CFG_PLLCTL1_BWADJ_MASK	0xf
129c321a236SLokesh Vutla 
130c321a236SLokesh Vutla #define MISC_CTL1_ARM_PLL_EN	BIT(13)
131dc7de222SMasahiro Yamada 
132dc7de222SMasahiro Yamada #endif  /* _CLOCK_DEFS_H_ */
133