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 extern spinlock_t pmc_pcr_lock
;
28 struct clk_hw
**pchws
;
30 struct clk_hw
*hwtable
[];
38 #define CLK_RANGE(MIN, MAX) {.min = MIN, .max = MAX,}
40 struct clk_master_layout
{
46 extern const struct clk_master_layout at91rm9200_master_layout
;
47 extern const struct clk_master_layout at91sam9x5_master_layout
;
49 struct clk_master_characteristics
{
50 struct clk_range output
;
55 struct clk_pll_layout
{
67 extern const struct clk_pll_layout at91rm9200_pll_layout
;
68 extern const struct clk_pll_layout at91sam9g45_pll_layout
;
69 extern const struct clk_pll_layout at91sam9g20_pllb_layout
;
70 extern const struct clk_pll_layout sama5d3_pll_layout
;
72 struct clk_pll_characteristics
{
73 struct clk_range input
;
75 const struct clk_range
*output
;
81 struct clk_programmable_layout
{
89 extern const struct clk_programmable_layout at91rm9200_programmable_layout
;
90 extern const struct clk_programmable_layout at91sam9g45_programmable_layout
;
91 extern const struct clk_programmable_layout at91sam9x5_programmable_layout
;
93 struct clk_pcr_layout
{
101 #define field_get(_mask, _reg) (((_reg) & (_mask)) >> (ffs(_mask) - 1))
102 #define field_prep(_mask, _val) (((_val) << (ffs(_mask) - 1)) & (_mask))
104 #define ndck(a, s) (a[s - 1].id + 1)
105 #define nck(a) (a[ARRAY_SIZE(a) - 1].id + 1)
106 struct pmc_data
*pmc_data_allocate(unsigned int ncore
, unsigned int nsystem
,
107 unsigned int nperiph
, unsigned int ngck
,
110 int of_at91_get_clk_range(struct device_node
*np
, const char *propname
,
111 struct clk_range
*range
);
113 struct clk_hw
*of_clk_hw_pmc_get(struct of_phandle_args
*clkspec
, void *data
);
115 struct clk_hw
* __init
116 at91_clk_register_audio_pll_frac(struct regmap
*regmap
, const char *name
,
117 const char *parent_name
);
119 struct clk_hw
* __init
120 at91_clk_register_audio_pll_pad(struct regmap
*regmap
, const char *name
,
121 const char *parent_name
);
123 struct clk_hw
* __init
124 at91_clk_register_audio_pll_pmc(struct regmap
*regmap
, const char *name
,
125 const char *parent_name
);
127 struct clk_hw
* __init
128 at91_clk_register_generated(struct regmap
*regmap
, spinlock_t
*lock
,
129 const struct clk_pcr_layout
*layout
,
130 const char *name
, const char **parent_names
,
131 u32
*mux_table
, u8 num_parents
, u8 id
,
132 const struct clk_range
*range
, int chg_pid
);
134 struct clk_hw
* __init
135 at91_clk_register_h32mx(struct regmap
*regmap
, const char *name
,
136 const char *parent_name
);
138 struct clk_hw
* __init
139 at91_clk_i2s_mux_register(struct regmap
*regmap
, const char *name
,
140 const char * const *parent_names
,
141 unsigned int num_parents
, u8 bus_id
);
143 struct clk_hw
* __init
144 at91_clk_register_main_rc_osc(struct regmap
*regmap
, const char *name
,
145 u32 frequency
, u32 accuracy
);
146 struct clk_hw
* __init
147 at91_clk_register_main_osc(struct regmap
*regmap
, const char *name
,
148 const char *parent_name
, bool bypass
);
149 struct clk_hw
* __init
150 at91_clk_register_rm9200_main(struct regmap
*regmap
,
152 const char *parent_name
);
153 struct clk_hw
* __init
154 at91_clk_register_sam9x5_main(struct regmap
*regmap
, const char *name
,
155 const char **parent_names
, int num_parents
);
157 struct clk_hw
* __init
158 at91_clk_register_master_pres(struct regmap
*regmap
, const char *name
,
159 int num_parents
, const char **parent_names
,
160 const struct clk_master_layout
*layout
,
161 const struct clk_master_characteristics
*characteristics
,
162 spinlock_t
*lock
, u32 flags
, int chg_pid
);
164 struct clk_hw
* __init
165 at91_clk_register_master_div(struct regmap
*regmap
, const char *name
,
166 const char *parent_names
,
167 const struct clk_master_layout
*layout
,
168 const struct clk_master_characteristics
*characteristics
,
169 spinlock_t
*lock
, u32 flags
);
171 struct clk_hw
* __init
172 at91_clk_sama7g5_register_master(struct regmap
*regmap
,
173 const char *name
, int num_parents
,
174 const char **parent_names
, u32
*mux_table
,
175 spinlock_t
*lock
, u8 id
, bool critical
,
178 struct clk_hw
* __init
179 at91_clk_register_peripheral(struct regmap
*regmap
, const char *name
,
180 const char *parent_name
, u32 id
);
181 struct clk_hw
* __init
182 at91_clk_register_sam9x5_peripheral(struct regmap
*regmap
, spinlock_t
*lock
,
183 const struct clk_pcr_layout
*layout
,
184 const char *name
, const char *parent_name
,
185 u32 id
, const struct clk_range
*range
,
188 struct clk_hw
* __init
189 at91_clk_register_pll(struct regmap
*regmap
, const char *name
,
190 const char *parent_name
, u8 id
,
191 const struct clk_pll_layout
*layout
,
192 const struct clk_pll_characteristics
*characteristics
);
193 struct clk_hw
* __init
194 at91_clk_register_plldiv(struct regmap
*regmap
, const char *name
,
195 const char *parent_name
);
197 struct clk_hw
* __init
198 sam9x60_clk_register_div_pll(struct regmap
*regmap
, spinlock_t
*lock
,
199 const char *name
, const char *parent_name
, u8 id
,
200 const struct clk_pll_characteristics
*characteristics
,
201 const struct clk_pll_layout
*layout
, u32 flags
);
203 struct clk_hw
* __init
204 sam9x60_clk_register_frac_pll(struct regmap
*regmap
, spinlock_t
*lock
,
205 const char *name
, const char *parent_name
,
206 struct clk_hw
*parent_hw
, u8 id
,
207 const struct clk_pll_characteristics
*characteristics
,
208 const struct clk_pll_layout
*layout
, u32 flags
);
210 struct clk_hw
* __init
211 at91_clk_register_programmable(struct regmap
*regmap
, const char *name
,
212 const char **parent_names
, u8 num_parents
, u8 id
,
213 const struct clk_programmable_layout
*layout
,
216 struct clk_hw
* __init
217 at91_clk_register_sam9260_slow(struct regmap
*regmap
,
219 const char **parent_names
,
222 struct clk_hw
* __init
223 at91sam9x5_clk_register_smd(struct regmap
*regmap
, const char *name
,
224 const char **parent_names
, u8 num_parents
);
226 struct clk_hw
* __init
227 at91_clk_register_system(struct regmap
*regmap
, const char *name
,
228 const char *parent_name
, u8 id
);
230 struct clk_hw
* __init
231 at91sam9x5_clk_register_usb(struct regmap
*regmap
, const char *name
,
232 const char **parent_names
, u8 num_parents
);
233 struct clk_hw
* __init
234 at91sam9n12_clk_register_usb(struct regmap
*regmap
, const char *name
,
235 const char *parent_name
);
236 struct clk_hw
* __init
237 sam9x60_clk_register_usb(struct regmap
*regmap
, const char *name
,
238 const char **parent_names
, u8 num_parents
);
239 struct clk_hw
* __init
240 at91rm9200_clk_register_usb(struct regmap
*regmap
, const char *name
,
241 const char *parent_name
, const u32
*divisors
);
243 struct clk_hw
* __init
244 at91_clk_register_utmi(struct regmap
*regmap_pmc
, struct regmap
*regmap_sfr
,
245 const char *name
, const char *parent_name
);
247 struct clk_hw
* __init
248 at91_clk_sama7g5_register_utmi(struct regmap
*regmap
, const char *name
,
249 const char *parent_name
);
252 void pmc_register_id(u8 id
);
253 void pmc_register_pck(u8 pck
);
255 static inline void pmc_register_id(u8 id
) {}
256 static inline void pmc_register_pck(u8 pck
) {}
259 #endif /* __PMC_H_ */