1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * drivers/clk/at91/pmc.h
5 * Copyright (C) 2013 Boris BREZILLON <b.brezillon@overkiz.com>
12 #include <linux/irqdomain.h>
13 #include <linux/regmap.h>
14 #include <linux/spinlock.h>
16 #include <dt-bindings/clock/at91.h>
18 extern spinlock_t pmc_pcr_lock;
30 struct clk_hw **pchws;
32 struct clk_hw *hwtable[];
40 #define CLK_RANGE(MIN, MAX) {.min = MIN, .max = MAX,}
42 struct clk_master_layout {
48 extern const struct clk_master_layout at91rm9200_master_layout;
49 extern const struct clk_master_layout at91sam9x5_master_layout;
51 struct clk_master_characteristics {
52 struct clk_range output;
57 struct clk_pll_layout {
69 extern const struct clk_pll_layout at91rm9200_pll_layout;
70 extern const struct clk_pll_layout at91sam9g45_pll_layout;
71 extern const struct clk_pll_layout at91sam9g20_pllb_layout;
72 extern const struct clk_pll_layout sama5d3_pll_layout;
74 struct clk_pll_characteristics {
75 struct clk_range input;
77 const struct clk_range *output;
83 struct clk_programmable_layout {
91 extern const struct clk_programmable_layout at91rm9200_programmable_layout;
92 extern const struct clk_programmable_layout at91sam9g45_programmable_layout;
93 extern const struct clk_programmable_layout at91sam9x5_programmable_layout;
95 struct clk_pcr_layout {
104 * struct at91_clk_pms - Power management state for AT91 clock
106 * @parent_rate: clock parent rate
107 * @status: clock status (enabled or disabled)
108 * @parent: clock parent index
110 struct at91_clk_pms {
112 unsigned long parent_rate;
117 #define field_get(_mask, _reg) (((_reg) & (_mask)) >> (ffs(_mask) - 1))
118 #define field_prep(_mask, _val) (((_val) << (ffs(_mask) - 1)) & (_mask))
120 #define ndck(a, s) (a[s - 1].id + 1)
121 #define nck(a) (a[ARRAY_SIZE(a) - 1].id + 1)
122 struct pmc_data *pmc_data_allocate(unsigned int ncore, unsigned int nsystem,
123 unsigned int nperiph, unsigned int ngck,
126 int of_at91_get_clk_range(struct device_node *np, const char *propname,
127 struct clk_range *range);
129 struct clk_hw *of_clk_hw_pmc_get(struct of_phandle_args *clkspec, void *data);
131 struct clk_hw * __init
132 at91_clk_register_audio_pll_frac(struct regmap *regmap, const char *name,
133 const char *parent_name);
135 struct clk_hw * __init
136 at91_clk_register_audio_pll_pad(struct regmap *regmap, const char *name,
137 const char *parent_name);
139 struct clk_hw * __init
140 at91_clk_register_audio_pll_pmc(struct regmap *regmap, const char *name,
141 const char *parent_name);
143 struct clk_hw * __init
144 at91_clk_register_generated(struct regmap *regmap, spinlock_t *lock,
145 const struct clk_pcr_layout *layout,
146 const char *name, const char **parent_names,
147 u32 *mux_table, u8 num_parents, u8 id,
148 const struct clk_range *range, int chg_pid);
150 struct clk_hw * __init
151 at91_clk_register_h32mx(struct regmap *regmap, const char *name,
152 const char *parent_name);
154 struct clk_hw * __init
155 at91_clk_i2s_mux_register(struct regmap *regmap, const char *name,
156 const char * const *parent_names,
157 unsigned int num_parents, u8 bus_id);
159 struct clk_hw * __init
160 at91_clk_register_main_rc_osc(struct regmap *regmap, const char *name,
161 u32 frequency, u32 accuracy);
162 struct clk_hw * __init
163 at91_clk_register_main_osc(struct regmap *regmap, const char *name,
164 const char *parent_name, bool bypass);
165 struct clk_hw * __init
166 at91_clk_register_rm9200_main(struct regmap *regmap,
168 const char *parent_name);
169 struct clk_hw * __init
170 at91_clk_register_sam9x5_main(struct regmap *regmap, const char *name,
171 const char **parent_names, int num_parents);
173 struct clk_hw * __init
174 at91_clk_register_master_pres(struct regmap *regmap, const char *name,
175 int num_parents, const char **parent_names,
176 const struct clk_master_layout *layout,
177 const struct clk_master_characteristics *characteristics,
180 struct clk_hw * __init
181 at91_clk_register_master_div(struct regmap *regmap, const char *name,
182 const char *parent_names,
183 const struct clk_master_layout *layout,
184 const struct clk_master_characteristics *characteristics,
185 spinlock_t *lock, u32 flags, u32 safe_div);
187 struct clk_hw * __init
188 at91_clk_sama7g5_register_master(struct regmap *regmap,
189 const char *name, int num_parents,
190 const char **parent_names, u32 *mux_table,
191 spinlock_t *lock, u8 id, bool critical,
194 struct clk_hw * __init
195 at91_clk_register_peripheral(struct regmap *regmap, const char *name,
196 const char *parent_name, u32 id);
197 struct clk_hw * __init
198 at91_clk_register_sam9x5_peripheral(struct regmap *regmap, spinlock_t *lock,
199 const struct clk_pcr_layout *layout,
200 const char *name, const char *parent_name,
201 u32 id, const struct clk_range *range,
204 struct clk_hw * __init
205 at91_clk_register_pll(struct regmap *regmap, const char *name,
206 const char *parent_name, u8 id,
207 const struct clk_pll_layout *layout,
208 const struct clk_pll_characteristics *characteristics);
209 struct clk_hw * __init
210 at91_clk_register_plldiv(struct regmap *regmap, const char *name,
211 const char *parent_name);
213 struct clk_hw * __init
214 sam9x60_clk_register_div_pll(struct regmap *regmap, spinlock_t *lock,
215 const char *name, const char *parent_name, u8 id,
216 const struct clk_pll_characteristics *characteristics,
217 const struct clk_pll_layout *layout, u32 flags,
220 struct clk_hw * __init
221 sam9x60_clk_register_frac_pll(struct regmap *regmap, spinlock_t *lock,
222 const char *name, const char *parent_name,
223 struct clk_hw *parent_hw, u8 id,
224 const struct clk_pll_characteristics *characteristics,
225 const struct clk_pll_layout *layout, u32 flags);
227 struct clk_hw * __init
228 at91_clk_register_programmable(struct regmap *regmap, const char *name,
229 const char **parent_names, u8 num_parents, u8 id,
230 const struct clk_programmable_layout *layout,
233 struct clk_hw * __init
234 at91_clk_register_sam9260_slow(struct regmap *regmap,
236 const char **parent_names,
239 struct clk_hw * __init
240 at91sam9x5_clk_register_smd(struct regmap *regmap, const char *name,
241 const char **parent_names, u8 num_parents);
243 struct clk_hw * __init
244 at91_clk_register_system(struct regmap *regmap, const char *name,
245 const char *parent_name, u8 id);
247 struct clk_hw * __init
248 at91sam9x5_clk_register_usb(struct regmap *regmap, const char *name,
249 const char **parent_names, u8 num_parents);
250 struct clk_hw * __init
251 at91sam9n12_clk_register_usb(struct regmap *regmap, const char *name,
252 const char *parent_name);
253 struct clk_hw * __init
254 sam9x60_clk_register_usb(struct regmap *regmap, const char *name,
255 const char **parent_names, u8 num_parents);
256 struct clk_hw * __init
257 at91rm9200_clk_register_usb(struct regmap *regmap, const char *name,
258 const char *parent_name, const u32 *divisors);
260 struct clk_hw * __init
261 at91_clk_register_utmi(struct regmap *regmap_pmc, struct regmap *regmap_sfr,
262 const char *name, const char *parent_name);
264 struct clk_hw * __init
265 at91_clk_sama7g5_register_utmi(struct regmap *regmap, const char *name,
266 const char *parent_name);
268 #endif /* __PMC_H_ */