1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2014 Google, Inc.
6 #ifndef __PISTACHIO_CLK_H
7 #define __PISTACHIO_CLK_H
9 #include <linux/clk-provider.h>
11 struct pistachio_gate
{
19 #define GATE(_id, _name, _pname, _reg, _shift) \
28 struct pistachio_mux
{
32 unsigned int num_parents
;
34 const char *const *parents
;
37 #define PNAME(x) static const char *const x[] __initconst
39 #define MUX(_id, _name, _pnames, _reg, _shift) \
46 .num_parents = ARRAY_SIZE(_pnames) \
50 struct pistachio_div
{
54 unsigned int div_flags
;
59 #define DIV(_id, _name, _pname, _reg, _width) \
69 #define DIV_F(_id, _name, _pname, _reg, _width, _div_flags) \
74 .div_flags = _div_flags, \
79 struct pistachio_fixed_factor
{
86 #define FIXED_FACTOR(_id, _name, _pname, _div) \
94 struct pistachio_pll_rate_table
{
95 unsigned long long fref
;
96 unsigned long long fout
;
97 unsigned long long refdiv
;
98 unsigned long long fbdiv
;
99 unsigned long long postdiv1
;
100 unsigned long long postdiv2
;
101 unsigned long long frac
;
104 enum pistachio_pll_type
{
109 struct pistachio_pll
{
111 unsigned long reg_base
;
112 enum pistachio_pll_type type
;
113 struct pistachio_pll_rate_table
*rates
;
114 unsigned int nr_rates
;
119 #define PLL(_id, _name, _pname, _type, _reg, _rates) \
125 .nr_rates = ARRAY_SIZE(_rates), \
130 #define PLL_FIXED(_id, _name, _pname, _type, _reg) \
141 struct pistachio_clk_provider
{
142 struct device_node
*node
;
144 struct clk_onecell_data clk_data
;
147 extern struct pistachio_clk_provider
*
148 pistachio_clk_alloc_provider(struct device_node
*node
, unsigned int num_clks
);
149 extern void pistachio_clk_register_provider(struct pistachio_clk_provider
*p
);
151 extern void pistachio_clk_register_gate(struct pistachio_clk_provider
*p
,
152 struct pistachio_gate
*gate
,
154 extern void pistachio_clk_register_mux(struct pistachio_clk_provider
*p
,
155 struct pistachio_mux
*mux
,
157 extern void pistachio_clk_register_div(struct pistachio_clk_provider
*p
,
158 struct pistachio_div
*div
,
161 pistachio_clk_register_fixed_factor(struct pistachio_clk_provider
*p
,
162 struct pistachio_fixed_factor
*ff
,
164 extern void pistachio_clk_register_pll(struct pistachio_clk_provider
*p
,
165 struct pistachio_pll
*pll
,
168 extern void pistachio_clk_force_enable(struct pistachio_clk_provider
*p
,
169 unsigned int *clk_ids
, unsigned int num
);