summaryrefslogtreecommitdiff
path: root/arch/arm/include/asm/arch-rockchip
diff options
context:
space:
mode:
authorElaine Zhang <zhangqing@rock-chips.com>2019-10-25 09:42:17 +0800
committerKever Yang <kever.yang@rock-chips.com>2019-11-17 17:22:53 +0800
commitbbda2ed5840c67758fb172fbcdd6398f6ab5fe25 (patch)
tree083f3ee26388653bbc4679fbbaf89c3461291ef1 /arch/arm/include/asm/arch-rockchip
parent7acd0302108e9e100d92264a850b0146f5823594 (diff)
rockchip: clk: pll: add common pll setting funcs
Common PLL setup function, compatible with different SOC. Mainly for the subsequent new SOC use. Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com> Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
Diffstat (limited to 'arch/arm/include/asm/arch-rockchip')
-rw-r--r--arch/arm/include/asm/arch-rockchip/clock.h76
1 files changed, 76 insertions, 0 deletions
diff --git a/arch/arm/include/asm/arch-rockchip/clock.h b/arch/arm/include/asm/arch-rockchip/clock.h
index 1d5b3a07d0..8f7fc86a9e 100644
--- a/arch/arm/include/asm/arch-rockchip/clock.h
+++ b/arch/arm/include/asm/arch-rockchip/clock.h
@@ -9,6 +9,7 @@
/* define pll mode */
#define RKCLK_PLL_MODE_SLOW 0
#define RKCLK_PLL_MODE_NORMAL 1
+#define RKCLK_PLL_MODE_DEEP 2
enum {
ROCKCHIP_SYSCON_NOC,
@@ -33,6 +34,81 @@ enum rk_clk_id {
CLK_COUNT,
};
+#define PLL(_type, _id, _con, _mode, _mshift, \
+ _lshift, _pflags, _rtable) \
+ { \
+ .id = _id, \
+ .type = _type, \
+ .con_offset = _con, \
+ .mode_offset = _mode, \
+ .mode_shift = _mshift, \
+ .lock_shift = _lshift, \
+ .pll_flags = _pflags, \
+ .rate_table = _rtable, \
+ }
+
+#define RK3036_PLL_RATE(_rate, _refdiv, _fbdiv, _postdiv1, \
+ _postdiv2, _dsmpd, _frac) \
+{ \
+ .rate = _rate##U, \
+ .fbdiv = _fbdiv, \
+ .postdiv1 = _postdiv1, \
+ .refdiv = _refdiv, \
+ .postdiv2 = _postdiv2, \
+ .dsmpd = _dsmpd, \
+ .frac = _frac, \
+}
+
+struct rockchip_pll_rate_table {
+ unsigned long rate;
+ unsigned int nr;
+ unsigned int nf;
+ unsigned int no;
+ unsigned int nb;
+ /* for RK3036/RK3399 */
+ unsigned int fbdiv;
+ unsigned int postdiv1;
+ unsigned int refdiv;
+ unsigned int postdiv2;
+ unsigned int dsmpd;
+ unsigned int frac;
+};
+
+enum rockchip_pll_type {
+ pll_rk3036,
+ pll_rk3066,
+ pll_rk3328,
+ pll_rk3366,
+ pll_rk3399,
+};
+
+struct rockchip_pll_clock {
+ unsigned int id;
+ unsigned int con_offset;
+ unsigned int mode_offset;
+ unsigned int mode_shift;
+ unsigned int lock_shift;
+ enum rockchip_pll_type type;
+ unsigned int pll_flags;
+ struct rockchip_pll_rate_table *rate_table;
+ unsigned int mode_mask;
+};
+
+struct rockchip_cpu_rate_table {
+ unsigned long rate;
+ unsigned int aclk_div;
+ unsigned int pclk_div;
+};
+
+int rockchip_pll_set_rate(struct rockchip_pll_clock *pll,
+ void __iomem *base, ulong clk_id,
+ ulong drate);
+ulong rockchip_pll_get_rate(struct rockchip_pll_clock *pll,
+ void __iomem *base, ulong clk_id);
+const struct rockchip_cpu_rate_table *
+rockchip_get_cpu_settings(struct rockchip_cpu_rate_table *cpu_table,
+ ulong rate);
+
static inline int rk_pll_id(enum rk_clk_id clk_id)
{
return clk_id - 1;