2 * Hisilicon Hi3620 clock gate driver
4 * Copyright (c) 2012-2013 Hisilicon Limited.
5 * Copyright (c) 2012-2013 Linaro Limited.
7 * Author: Haojian Zhuang <haojian.zhuang@linaro.org>
8 * Xin Li <li.xin@linaro.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 #include <linux/clk-provider.h>
31 #include <linux/spinlock.h>
33 struct platform_device
;
35 struct hisi_clock_data
{
36 struct clk_onecell_data clk_data
;
40 struct hisi_fixed_rate_clock
{
43 const char *parent_name
;
45 unsigned long fixed_rate
;
48 struct hisi_fixed_factor_clock
{
51 const char *parent_name
;
57 struct hisi_mux_clock
{
60 const char *const *parent_names
;
71 struct hisi_phase_clock
{
74 const char *parent_names
;
84 struct hisi_divider_clock
{
87 const char *parent_name
;
93 struct clk_div_table
*table
;
97 struct hi6220_divider_clock
{
100 const char *parent_name
;
102 unsigned long offset
;
109 struct hisi_gate_clock
{
112 const char *parent_name
;
114 unsigned long offset
;
120 struct clk
*hisi_register_clkgate_sep(struct device
*, const char *,
121 const char *, unsigned long,
124 struct clk
*hi6220_register_clkdiv(struct device
*dev
, const char *name
,
125 const char *parent_name
, unsigned long flags
, void __iomem
*reg
,
126 u8 shift
, u8 width
, u32 mask_bit
, spinlock_t
*lock
);
128 struct hisi_clock_data
*hisi_clk_alloc(struct platform_device
*, int);
129 struct hisi_clock_data
*hisi_clk_init(struct device_node
*, int);
130 int hisi_clk_register_fixed_rate(const struct hisi_fixed_rate_clock
*,
131 int, struct hisi_clock_data
*);
132 int hisi_clk_register_fixed_factor(const struct hisi_fixed_factor_clock
*,
133 int, struct hisi_clock_data
*);
134 int hisi_clk_register_mux(const struct hisi_mux_clock
*, int,
135 struct hisi_clock_data
*);
136 struct clk
*clk_register_hisi_phase(struct device
*dev
,
137 const struct hisi_phase_clock
*clks
,
138 void __iomem
*base
, spinlock_t
*lock
);
139 int hisi_clk_register_phase(struct device
*dev
,
140 const struct hisi_phase_clock
*clks
,
141 int nums
, struct hisi_clock_data
*data
);
142 int hisi_clk_register_divider(const struct hisi_divider_clock
*,
143 int, struct hisi_clock_data
*);
144 int hisi_clk_register_gate(const struct hisi_gate_clock
*,
145 int, struct hisi_clock_data
*);
146 void hisi_clk_register_gate_sep(const struct hisi_gate_clock
*,
147 int, struct hisi_clock_data
*);
148 void hi6220_clk_register_divider(const struct hi6220_divider_clock
*,
149 int, struct hisi_clock_data
*);
151 #define hisi_clk_unregister(type) \
153 void hisi_clk_unregister_##type(const struct hisi_##type##_clock *clks, \
154 int nums, struct hisi_clock_data *data) \
156 struct clk **clocks = data->clk_data.clks; \
158 for (i = 0; i < nums; i++) { \
159 int id = clks[i].id; \
161 clk_unregister_##type(clocks[id]); \
165 hisi_clk_unregister(fixed_rate
)
166 hisi_clk_unregister(fixed_factor
)
167 hisi_clk_unregister(mux
)
168 hisi_clk_unregister(divider
)
169 hisi_clk_unregister(gate
)
171 #endif /* __HISI_CLK_H */