blob: c2290800503afdbd506fa6955f47feec47d3b62b [file] [log] [blame]
Viresh Kumar55b8fd42012-04-10 09:02:35 +05301/*
2 * Clock framework definitions for SPEAr platform
3 *
4 * Copyright (C) 2012 ST Microelectronics
5 * Viresh Kumar <viresh.kumar@st.com>
6 *
7 * This file is licensed under the terms of the GNU General Public
8 * License version 2. This program is licensed "as is" without any
9 * warranty of any kind, whether express or implied.
10 */
11
12#ifndef __SPEAR_CLK_H
13#define __SPEAR_CLK_H
14
15#include <linux/clk-provider.h>
16#include <linux/spinlock_types.h>
17#include <linux/types.h>
18
Viresh Kumar5335a632012-04-11 18:04:23 +053019/* Auxiliary Synth clk */
20/* Default masks */
21#define AUX_EQ_SEL_SHIFT 30
22#define AUX_EQ_SEL_MASK 1
23#define AUX_EQ1_SEL 0
24#define AUX_EQ2_SEL 1
25#define AUX_XSCALE_SHIFT 16
26#define AUX_XSCALE_MASK 0xFFF
27#define AUX_YSCALE_SHIFT 0
28#define AUX_YSCALE_MASK 0xFFF
29#define AUX_SYNT_ENB 31
30
31struct aux_clk_masks {
32 u32 eq_sel_mask;
33 u32 eq_sel_shift;
34 u32 eq1_mask;
35 u32 eq2_mask;
36 u32 xscale_sel_mask;
37 u32 xscale_sel_shift;
38 u32 yscale_sel_mask;
39 u32 yscale_sel_shift;
40 u32 enable_bit;
41};
42
43struct aux_rate_tbl {
44 u16 xscale;
45 u16 yscale;
46 u8 eq;
47};
48
49struct clk_aux {
50 struct clk_hw hw;
51 void __iomem *reg;
52 struct aux_clk_masks *masks;
53 struct aux_rate_tbl *rtbl;
54 u8 rtbl_cnt;
55 spinlock_t *lock;
56};
57
Viresh Kumar55b8fd42012-04-10 09:02:35 +053058/* VCO-PLL clk */
59struct pll_rate_tbl {
60 u8 mode;
61 u16 m;
62 u8 n;
63 u8 p;
64};
65
66struct clk_vco {
67 struct clk_hw hw;
68 void __iomem *mode_reg;
69 void __iomem *cfg_reg;
70 struct pll_rate_tbl *rtbl;
71 u8 rtbl_cnt;
72 spinlock_t *lock;
73};
74
75struct clk_pll {
76 struct clk_hw hw;
77 struct clk_vco *vco;
78 const char *parent[1];
79 spinlock_t *lock;
80};
81
82typedef unsigned long (*clk_calc_rate)(struct clk_hw *hw, unsigned long prate,
83 int index);
84
85/* clk register routines */
Viresh Kumar5335a632012-04-11 18:04:23 +053086struct clk *clk_register_aux(const char *aux_name, const char *gate_name,
87 const char *parent_name, unsigned long flags, void __iomem *reg,
88 struct aux_clk_masks *masks, struct aux_rate_tbl *rtbl,
89 u8 rtbl_cnt, spinlock_t *lock, struct clk **gate_clk);
Viresh Kumar55b8fd42012-04-10 09:02:35 +053090struct clk *clk_register_vco_pll(const char *vco_name, const char *pll_name,
91 const char *vco_gate_name, const char *parent_name,
92 unsigned long flags, void __iomem *mode_reg, void __iomem
93 *cfg_reg, struct pll_rate_tbl *rtbl, u8 rtbl_cnt,
94 spinlock_t *lock, struct clk **pll_clk,
95 struct clk **vco_gate_clk);
96
97long clk_round_rate_index(struct clk_hw *hw, unsigned long drate,
98 unsigned long parent_rate, clk_calc_rate calc_rate, u8 rtbl_cnt,
99 int *index);
100
101#endif /* __SPEAR_CLK_H */