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