2 * Copyright (c) 2015 Endless Mobile, Inc.
3 * Author: Carlo Caione <carlo@endlessm.com>
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program. If not, see <http://www.gnu.org/licenses/>.
21 #define PMASK(width) GENMASK(width - 1, 0)
22 #define SETPMASK(width, shift) GENMASK(shift + width - 1, shift)
23 #define CLRPMASK(width, shift) (~SETPMASK(width, shift))
25 #define PARM_GET(width, shift, reg) \
26 (((reg) & SETPMASK(width, shift)) >> (shift))
27 #define PARM_SET(width, shift, reg, val) \
28 (((reg) & CLRPMASK(width, shift)) | (val << (shift)))
30 #define MESON_PARM_APPLICABLE(p) (!!((p)->width))
38 #define PARM(_r, _s, _w) \
45 struct pll_rate_table {
51 #define PLL_RATE(_r, _m, _n, _od) \
59 struct meson_clk_pll {
65 const struct pll_rate_table *rate_table;
66 unsigned int rate_count;
70 #define to_meson_clk_pll(_hw) container_of(_hw, struct meson_clk_pll, hw)
72 struct meson_clk_cpu {
76 struct notifier_block clk_nb;
77 const struct clk_div_table *div_table;
80 struct composite_conf {
83 struct parm gate_parm;
84 struct clk_div_table *div_table;
91 #define PNAME(x) static const char *x[]
99 enum clk_type clk_type;
101 const char *clk_name;
102 const char **clks_parent;
106 const struct composite_conf *composite;
107 const struct clk_div_table *div_table;
111 #define COMPOSITE(_ro, _ci, _cn, _cp, _f, _c) \
114 .clk_type = CLK_COMPOSITE, \
117 .clks_parent = (_cp), \
118 .num_parents = ARRAY_SIZE(_cp), \
120 .conf.composite = (_c), \
123 struct clk **meson_clk_init(struct device_node *np, unsigned long nr_clks);
124 void meson_clk_register_clks(const struct clk_conf *clk_confs,
125 unsigned int nr_confs, void __iomem *clk_base);
126 int meson_clk_cpu_notifier_cb(struct notifier_block *nb, unsigned long event,
130 extern spinlock_t clk_lock;
133 extern const struct clk_ops meson_clk_pll_ro_ops;
134 extern const struct clk_ops meson_clk_pll_ops;
135 extern const struct clk_ops meson_clk_cpu_ops;
137 #endif /* __CLKC_H */