1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Hisilicon Hi3620 clock gate driver
5 * Copyright (c) 2012-2013 Hisilicon Limited.
6 * Copyright (c) 2012-2013 Linaro Limited.
8 * Author: Haojian Zhuang <haojian.zhuang@linaro.org>
9 * Xin Li <li.xin@linaro.org>
15 #include <linux/clk-provider.h>
17 #include <linux/spinlock.h>
19 struct platform_device
;
21 struct hisi_clock_data
{
22 struct clk_onecell_data clk_data
;
26 struct hisi_fixed_rate_clock
{
29 const char *parent_name
;
31 unsigned long fixed_rate
;
34 struct hisi_fixed_factor_clock
{
37 const char *parent_name
;
43 struct hisi_mux_clock
{
46 const char *const *parent_names
;
57 struct hisi_phase_clock
{
60 const char *parent_names
;
70 struct hisi_divider_clock
{
73 const char *parent_name
;
79 struct clk_div_table
*table
;
83 struct hi6220_divider_clock
{
86 const char *parent_name
;
95 struct hisi_gate_clock
{
98 const char *parent_name
;
100 unsigned long offset
;
106 struct clk
*hisi_register_clkgate_sep(struct device
*, const char *,
107 const char *, unsigned long,
110 struct clk
*hi6220_register_clkdiv(struct device
*dev
, const char *name
,
111 const char *parent_name
, unsigned long flags
, void __iomem
*reg
,
112 u8 shift
, u8 width
, u32 mask_bit
, spinlock_t
*lock
);
114 struct hisi_clock_data
*hisi_clk_alloc(struct platform_device
*, int);
115 struct hisi_clock_data
*hisi_clk_init(struct device_node
*, int);
116 int hisi_clk_register_fixed_rate(const struct hisi_fixed_rate_clock
*,
117 int, struct hisi_clock_data
*);
118 int hisi_clk_register_fixed_factor(const struct hisi_fixed_factor_clock
*,
119 int, struct hisi_clock_data
*);
120 int hisi_clk_register_mux(const struct hisi_mux_clock
*, int,
121 struct hisi_clock_data
*);
122 struct clk
*clk_register_hisi_phase(struct device
*dev
,
123 const struct hisi_phase_clock
*clks
,
124 void __iomem
*base
, spinlock_t
*lock
);
125 int hisi_clk_register_phase(struct device
*dev
,
126 const struct hisi_phase_clock
*clks
,
127 int nums
, struct hisi_clock_data
*data
);
128 int hisi_clk_register_divider(const struct hisi_divider_clock
*,
129 int, struct hisi_clock_data
*);
130 int hisi_clk_register_gate(const struct hisi_gate_clock
*,
131 int, struct hisi_clock_data
*);
132 void hisi_clk_register_gate_sep(const struct hisi_gate_clock
*,
133 int, struct hisi_clock_data
*);
134 void hi6220_clk_register_divider(const struct hi6220_divider_clock
*,
135 int, struct hisi_clock_data
*);
137 #define hisi_clk_unregister(type) \
139 void hisi_clk_unregister_##type(const struct hisi_##type##_clock *clks, \
140 int nums, struct hisi_clock_data *data) \
142 struct clk **clocks = data->clk_data.clks; \
144 for (i = 0; i < nums; i++) { \
145 int id = clks[i].id; \
147 clk_unregister_##type(clocks[id]); \
151 hisi_clk_unregister(fixed_rate
)
152 hisi_clk_unregister(fixed_factor
)
153 hisi_clk_unregister(mux
)
154 hisi_clk_unregister(divider
)
155 hisi_clk_unregister(gate
)
157 #endif /* __HISI_CLK_H */