2 * Copyright (C) 2014 Google, Inc.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
9 #ifndef __PISTACHIO_CLK_H
10 #define __PISTACHIO_CLK_H
12 #include <linux/clk-provider.h>
14 struct pistachio_gate
{
22 #define GATE(_id, _name, _pname, _reg, _shift) \
31 struct pistachio_mux
{
35 unsigned int num_parents
;
40 #define PNAME(x) static const char *x[] __initconst
42 #define MUX(_id, _name, _pnames, _reg, _shift) \
49 .num_parents = ARRAY_SIZE(_pnames) \
53 struct pistachio_div
{
57 unsigned int div_flags
;
62 #define DIV(_id, _name, _pname, _reg, _width) \
72 #define DIV_F(_id, _name, _pname, _reg, _width, _div_flags) \
77 .div_flags = _div_flags, \
82 struct pistachio_fixed_factor
{
89 #define FIXED_FACTOR(_id, _name, _pname, _div) \
97 struct pistachio_pll_rate_table
{
98 unsigned long long fref
;
99 unsigned long long fout
;
100 unsigned long long refdiv
;
101 unsigned long long fbdiv
;
102 unsigned long long postdiv1
;
103 unsigned long long postdiv2
;
104 unsigned long long frac
;
107 enum pistachio_pll_type
{
112 struct pistachio_pll
{
114 unsigned long reg_base
;
115 enum pistachio_pll_type type
;
116 struct pistachio_pll_rate_table
*rates
;
117 unsigned int nr_rates
;
122 #define PLL(_id, _name, _pname, _type, _reg, _rates) \
128 .nr_rates = ARRAY_SIZE(_rates), \
133 #define PLL_FIXED(_id, _name, _pname, _type, _reg) \
144 struct pistachio_clk_provider
{
145 struct device_node
*node
;
147 struct clk_onecell_data clk_data
;
150 extern struct pistachio_clk_provider
*
151 pistachio_clk_alloc_provider(struct device_node
*node
, unsigned int num_clks
);
152 extern void pistachio_clk_register_provider(struct pistachio_clk_provider
*p
);
154 extern void pistachio_clk_register_gate(struct pistachio_clk_provider
*p
,
155 struct pistachio_gate
*gate
,
157 extern void pistachio_clk_register_mux(struct pistachio_clk_provider
*p
,
158 struct pistachio_mux
*mux
,
160 extern void pistachio_clk_register_div(struct pistachio_clk_provider
*p
,
161 struct pistachio_div
*div
,
164 pistachio_clk_register_fixed_factor(struct pistachio_clk_provider
*p
,
165 struct pistachio_fixed_factor
*ff
,
167 extern void pistachio_clk_register_pll(struct pistachio_clk_provider
*p
,
168 struct pistachio_pll
*pll
,
171 extern void pistachio_clk_force_enable(struct pistachio_clk_provider
*p
,
172 unsigned int *clk_ids
, unsigned int num
);