xref: /linux/drivers/clk/ti/fapll.c (revision 33ca29c99e8680b4c921c6eafb9fc1603c5b9779)
1163152cbSTony Lindgren /*
2163152cbSTony Lindgren  * This program is free software; you can redistribute it and/or
3163152cbSTony Lindgren  * modify it under the terms of the GNU General Public License as
4163152cbSTony Lindgren  * published by the Free Software Foundation version 2.
5163152cbSTony Lindgren  *
6163152cbSTony Lindgren  * This program is distributed "as is" WITHOUT ANY WARRANTY of any
7163152cbSTony Lindgren  * kind, whether express or implied; without even the implied warranty
8163152cbSTony Lindgren  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9163152cbSTony Lindgren  * GNU General Public License for more details.
10163152cbSTony Lindgren  */
11163152cbSTony Lindgren 
12163152cbSTony Lindgren #include <linux/clk-provider.h>
13163152cbSTony Lindgren #include <linux/delay.h>
14163152cbSTony Lindgren #include <linux/err.h>
15163152cbSTony Lindgren #include <linux/of.h>
16163152cbSTony Lindgren #include <linux/of_address.h>
17163152cbSTony Lindgren #include <linux/clk/ti.h>
18163152cbSTony Lindgren 
19163152cbSTony Lindgren /* FAPLL Control Register PLL_CTRL */
20163152cbSTony Lindgren #define FAPLL_MAIN_LOCK		BIT(7)
21163152cbSTony Lindgren #define FAPLL_MAIN_PLLEN	BIT(3)
22163152cbSTony Lindgren #define FAPLL_MAIN_BP		BIT(2)
23163152cbSTony Lindgren #define FAPLL_MAIN_LOC_CTL	BIT(0)
24163152cbSTony Lindgren 
25163152cbSTony Lindgren /* FAPLL powerdown register PWD */
26163152cbSTony Lindgren #define FAPLL_PWD_OFFSET	4
27163152cbSTony Lindgren 
28163152cbSTony Lindgren #define MAX_FAPLL_OUTPUTS	7
29163152cbSTony Lindgren #define FAPLL_MAX_RETRIES	1000
30163152cbSTony Lindgren 
31163152cbSTony Lindgren #define to_fapll(_hw)		container_of(_hw, struct fapll_data, hw)
32163152cbSTony Lindgren #define to_synth(_hw)		container_of(_hw, struct fapll_synth, hw)
33163152cbSTony Lindgren 
34163152cbSTony Lindgren /* The bypass bit is inverted on the ddr_pll.. */
35163152cbSTony Lindgren #define fapll_is_ddr_pll(va)	(((u32)(va) & 0xffff) == 0x0440)
36163152cbSTony Lindgren 
37163152cbSTony Lindgren /*
38163152cbSTony Lindgren  * The audio_pll_clk1 input is hard wired to the 27MHz bypass clock,
39163152cbSTony Lindgren  * and the audio_pll_clk1 synthesizer is hardwared to 32KiHz output.
40163152cbSTony Lindgren  */
41163152cbSTony Lindgren #define is_ddr_pll_clk1(va)	(((u32)(va) & 0xffff) == 0x044c)
42163152cbSTony Lindgren #define is_audio_pll_clk1(va)	(((u32)(va) & 0xffff) == 0x04a8)
43163152cbSTony Lindgren 
44163152cbSTony Lindgren /* Synthesizer divider register */
45163152cbSTony Lindgren #define SYNTH_LDMDIV1		BIT(8)
46163152cbSTony Lindgren 
47163152cbSTony Lindgren /* Synthesizer frequency register */
48163152cbSTony Lindgren #define SYNTH_LDFREQ		BIT(31)
49163152cbSTony Lindgren 
50*33ca29c9STony Lindgren #define SYNTH_MAX_DIV_M		0xff
51*33ca29c9STony Lindgren 
52163152cbSTony Lindgren struct fapll_data {
53163152cbSTony Lindgren 	struct clk_hw hw;
54163152cbSTony Lindgren 	void __iomem *base;
55163152cbSTony Lindgren 	const char *name;
56163152cbSTony Lindgren 	struct clk *clk_ref;
57163152cbSTony Lindgren 	struct clk *clk_bypass;
58163152cbSTony Lindgren 	struct clk_onecell_data outputs;
59163152cbSTony Lindgren 	bool bypass_bit_inverted;
60163152cbSTony Lindgren };
61163152cbSTony Lindgren 
62163152cbSTony Lindgren struct fapll_synth {
63163152cbSTony Lindgren 	struct clk_hw hw;
64163152cbSTony Lindgren 	struct fapll_data *fd;
65163152cbSTony Lindgren 	int index;
66163152cbSTony Lindgren 	void __iomem *freq;
67163152cbSTony Lindgren 	void __iomem *div;
68163152cbSTony Lindgren 	const char *name;
69163152cbSTony Lindgren 	struct clk *clk_pll;
70163152cbSTony Lindgren };
71163152cbSTony Lindgren 
72163152cbSTony Lindgren static bool ti_fapll_clock_is_bypass(struct fapll_data *fd)
73163152cbSTony Lindgren {
74163152cbSTony Lindgren 	u32 v = readl_relaxed(fd->base);
75163152cbSTony Lindgren 
76163152cbSTony Lindgren 	if (fd->bypass_bit_inverted)
77163152cbSTony Lindgren 		return !(v & FAPLL_MAIN_BP);
78163152cbSTony Lindgren 	else
79163152cbSTony Lindgren 		return !!(v & FAPLL_MAIN_BP);
80163152cbSTony Lindgren }
81163152cbSTony Lindgren 
82163152cbSTony Lindgren static int ti_fapll_enable(struct clk_hw *hw)
83163152cbSTony Lindgren {
84163152cbSTony Lindgren 	struct fapll_data *fd = to_fapll(hw);
85163152cbSTony Lindgren 	u32 v = readl_relaxed(fd->base);
86163152cbSTony Lindgren 
87163152cbSTony Lindgren 	v |= (1 << FAPLL_MAIN_PLLEN);
88163152cbSTony Lindgren 	writel_relaxed(v, fd->base);
89163152cbSTony Lindgren 
90163152cbSTony Lindgren 	return 0;
91163152cbSTony Lindgren }
92163152cbSTony Lindgren 
93163152cbSTony Lindgren static void ti_fapll_disable(struct clk_hw *hw)
94163152cbSTony Lindgren {
95163152cbSTony Lindgren 	struct fapll_data *fd = to_fapll(hw);
96163152cbSTony Lindgren 	u32 v = readl_relaxed(fd->base);
97163152cbSTony Lindgren 
98163152cbSTony Lindgren 	v &= ~(1 << FAPLL_MAIN_PLLEN);
99163152cbSTony Lindgren 	writel_relaxed(v, fd->base);
100163152cbSTony Lindgren }
101163152cbSTony Lindgren 
102163152cbSTony Lindgren static int ti_fapll_is_enabled(struct clk_hw *hw)
103163152cbSTony Lindgren {
104163152cbSTony Lindgren 	struct fapll_data *fd = to_fapll(hw);
105163152cbSTony Lindgren 	u32 v = readl_relaxed(fd->base);
106163152cbSTony Lindgren 
107163152cbSTony Lindgren 	return v & (1 << FAPLL_MAIN_PLLEN);
108163152cbSTony Lindgren }
109163152cbSTony Lindgren 
110163152cbSTony Lindgren static unsigned long ti_fapll_recalc_rate(struct clk_hw *hw,
111163152cbSTony Lindgren 					  unsigned long parent_rate)
112163152cbSTony Lindgren {
113163152cbSTony Lindgren 	struct fapll_data *fd = to_fapll(hw);
114163152cbSTony Lindgren 	u32 fapll_n, fapll_p, v;
115163152cbSTony Lindgren 	long long rate;
116163152cbSTony Lindgren 
117163152cbSTony Lindgren 	if (ti_fapll_clock_is_bypass(fd))
118163152cbSTony Lindgren 		return parent_rate;
119163152cbSTony Lindgren 
120163152cbSTony Lindgren 	rate = parent_rate;
121163152cbSTony Lindgren 
122163152cbSTony Lindgren 	/* PLL pre-divider is P and multiplier is N */
123163152cbSTony Lindgren 	v = readl_relaxed(fd->base);
124163152cbSTony Lindgren 	fapll_p = (v >> 8) & 0xff;
125163152cbSTony Lindgren 	if (fapll_p)
126163152cbSTony Lindgren 		do_div(rate, fapll_p);
127163152cbSTony Lindgren 	fapll_n = v >> 16;
128163152cbSTony Lindgren 	if (fapll_n)
129163152cbSTony Lindgren 		rate *= fapll_n;
130163152cbSTony Lindgren 
131163152cbSTony Lindgren 	return rate;
132163152cbSTony Lindgren }
133163152cbSTony Lindgren 
134163152cbSTony Lindgren static u8 ti_fapll_get_parent(struct clk_hw *hw)
135163152cbSTony Lindgren {
136163152cbSTony Lindgren 	struct fapll_data *fd = to_fapll(hw);
137163152cbSTony Lindgren 
138163152cbSTony Lindgren 	if (ti_fapll_clock_is_bypass(fd))
139163152cbSTony Lindgren 		return 1;
140163152cbSTony Lindgren 
141163152cbSTony Lindgren 	return 0;
142163152cbSTony Lindgren }
143163152cbSTony Lindgren 
144163152cbSTony Lindgren static struct clk_ops ti_fapll_ops = {
145163152cbSTony Lindgren 	.enable = ti_fapll_enable,
146163152cbSTony Lindgren 	.disable = ti_fapll_disable,
147163152cbSTony Lindgren 	.is_enabled = ti_fapll_is_enabled,
148163152cbSTony Lindgren 	.recalc_rate = ti_fapll_recalc_rate,
149163152cbSTony Lindgren 	.get_parent = ti_fapll_get_parent,
150163152cbSTony Lindgren };
151163152cbSTony Lindgren 
152163152cbSTony Lindgren static int ti_fapll_synth_enable(struct clk_hw *hw)
153163152cbSTony Lindgren {
154163152cbSTony Lindgren 	struct fapll_synth *synth = to_synth(hw);
155163152cbSTony Lindgren 	u32 v = readl_relaxed(synth->fd->base + FAPLL_PWD_OFFSET);
156163152cbSTony Lindgren 
157163152cbSTony Lindgren 	v &= ~(1 << synth->index);
158163152cbSTony Lindgren 	writel_relaxed(v, synth->fd->base + FAPLL_PWD_OFFSET);
159163152cbSTony Lindgren 
160163152cbSTony Lindgren 	return 0;
161163152cbSTony Lindgren }
162163152cbSTony Lindgren 
163163152cbSTony Lindgren static void ti_fapll_synth_disable(struct clk_hw *hw)
164163152cbSTony Lindgren {
165163152cbSTony Lindgren 	struct fapll_synth *synth = to_synth(hw);
166163152cbSTony Lindgren 	u32 v = readl_relaxed(synth->fd->base + FAPLL_PWD_OFFSET);
167163152cbSTony Lindgren 
168163152cbSTony Lindgren 	v |= 1 << synth->index;
169163152cbSTony Lindgren 	writel_relaxed(v, synth->fd->base + FAPLL_PWD_OFFSET);
170163152cbSTony Lindgren }
171163152cbSTony Lindgren 
172163152cbSTony Lindgren static int ti_fapll_synth_is_enabled(struct clk_hw *hw)
173163152cbSTony Lindgren {
174163152cbSTony Lindgren 	struct fapll_synth *synth = to_synth(hw);
175163152cbSTony Lindgren 	u32 v = readl_relaxed(synth->fd->base + FAPLL_PWD_OFFSET);
176163152cbSTony Lindgren 
177163152cbSTony Lindgren 	return !(v & (1 << synth->index));
178163152cbSTony Lindgren }
179163152cbSTony Lindgren 
180163152cbSTony Lindgren /*
181163152cbSTony Lindgren  * See dm816x TRM chapter 1.10.3 Flying Adder PLL fore more info
182163152cbSTony Lindgren  */
183163152cbSTony Lindgren static unsigned long ti_fapll_synth_recalc_rate(struct clk_hw *hw,
184163152cbSTony Lindgren 						unsigned long parent_rate)
185163152cbSTony Lindgren {
186163152cbSTony Lindgren 	struct fapll_synth *synth = to_synth(hw);
187163152cbSTony Lindgren 	u32 synth_div_m;
188163152cbSTony Lindgren 	long long rate;
189163152cbSTony Lindgren 
190163152cbSTony Lindgren 	/* The audio_pll_clk1 is hardwired to produce 32.768KiHz clock */
191163152cbSTony Lindgren 	if (!synth->div)
192163152cbSTony Lindgren 		return 32768;
193163152cbSTony Lindgren 
194163152cbSTony Lindgren 	/*
195163152cbSTony Lindgren 	 * PLL in bypass sets the synths in bypass mode too. The PLL rate
196163152cbSTony Lindgren 	 * can be also be set to 27MHz, so we can't use parent_rate to
197163152cbSTony Lindgren 	 * check for bypass mode.
198163152cbSTony Lindgren 	 */
199163152cbSTony Lindgren 	if (ti_fapll_clock_is_bypass(synth->fd))
200163152cbSTony Lindgren 		return parent_rate;
201163152cbSTony Lindgren 
202163152cbSTony Lindgren 	rate = parent_rate;
203163152cbSTony Lindgren 
204163152cbSTony Lindgren 	/*
205163152cbSTony Lindgren 	 * Synth frequency integer and fractional divider.
206163152cbSTony Lindgren 	 * Note that the phase output K is 8, so the result needs
207163152cbSTony Lindgren 	 * to be multiplied by 8.
208163152cbSTony Lindgren 	 */
209163152cbSTony Lindgren 	if (synth->freq) {
210163152cbSTony Lindgren 		u32 v, synth_int_div, synth_frac_div, synth_div_freq;
211163152cbSTony Lindgren 
212163152cbSTony Lindgren 		v = readl_relaxed(synth->freq);
213163152cbSTony Lindgren 		synth_int_div = (v >> 24) & 0xf;
214163152cbSTony Lindgren 		synth_frac_div = v & 0xffffff;
215163152cbSTony Lindgren 		synth_div_freq = (synth_int_div * 10000000) + synth_frac_div;
216163152cbSTony Lindgren 		rate *= 10000000;
217163152cbSTony Lindgren 		do_div(rate, synth_div_freq);
218163152cbSTony Lindgren 		rate *= 8;
219163152cbSTony Lindgren 	}
220163152cbSTony Lindgren 
221*33ca29c9STony Lindgren 	/* Synth post-divider M */
222*33ca29c9STony Lindgren 	synth_div_m = readl_relaxed(synth->div) & SYNTH_MAX_DIV_M;
223163152cbSTony Lindgren 
224*33ca29c9STony Lindgren 	return DIV_ROUND_UP_ULL(rate, synth_div_m);
225163152cbSTony Lindgren }
226163152cbSTony Lindgren 
227163152cbSTony Lindgren static struct clk_ops ti_fapll_synt_ops = {
228163152cbSTony Lindgren 	.enable = ti_fapll_synth_enable,
229163152cbSTony Lindgren 	.disable = ti_fapll_synth_disable,
230163152cbSTony Lindgren 	.is_enabled = ti_fapll_synth_is_enabled,
231163152cbSTony Lindgren 	.recalc_rate = ti_fapll_synth_recalc_rate,
232163152cbSTony Lindgren };
233163152cbSTony Lindgren 
234163152cbSTony Lindgren static struct clk * __init ti_fapll_synth_setup(struct fapll_data *fd,
235163152cbSTony Lindgren 						void __iomem *freq,
236163152cbSTony Lindgren 						void __iomem *div,
237163152cbSTony Lindgren 						int index,
238163152cbSTony Lindgren 						const char *name,
239163152cbSTony Lindgren 						const char *parent,
240163152cbSTony Lindgren 						struct clk *pll_clk)
241163152cbSTony Lindgren {
242163152cbSTony Lindgren 	struct clk_init_data *init;
243163152cbSTony Lindgren 	struct fapll_synth *synth;
244163152cbSTony Lindgren 
245163152cbSTony Lindgren 	init = kzalloc(sizeof(*init), GFP_KERNEL);
246163152cbSTony Lindgren 	if (!init)
247163152cbSTony Lindgren 		return ERR_PTR(-ENOMEM);
248163152cbSTony Lindgren 
249163152cbSTony Lindgren 	init->ops = &ti_fapll_synt_ops;
250163152cbSTony Lindgren 	init->name = name;
251163152cbSTony Lindgren 	init->parent_names = &parent;
252163152cbSTony Lindgren 	init->num_parents = 1;
253163152cbSTony Lindgren 
254163152cbSTony Lindgren 	synth = kzalloc(sizeof(*synth), GFP_KERNEL);
255163152cbSTony Lindgren 	if (!synth)
256163152cbSTony Lindgren 		goto free;
257163152cbSTony Lindgren 
258163152cbSTony Lindgren 	synth->fd = fd;
259163152cbSTony Lindgren 	synth->index = index;
260163152cbSTony Lindgren 	synth->freq = freq;
261163152cbSTony Lindgren 	synth->div = div;
262163152cbSTony Lindgren 	synth->name = name;
263163152cbSTony Lindgren 	synth->hw.init = init;
264163152cbSTony Lindgren 	synth->clk_pll = pll_clk;
265163152cbSTony Lindgren 
266163152cbSTony Lindgren 	return clk_register(NULL, &synth->hw);
267163152cbSTony Lindgren 
268163152cbSTony Lindgren free:
269163152cbSTony Lindgren 	kfree(synth);
270163152cbSTony Lindgren 	kfree(init);
271163152cbSTony Lindgren 
272163152cbSTony Lindgren 	return ERR_PTR(-ENOMEM);
273163152cbSTony Lindgren }
274163152cbSTony Lindgren 
275163152cbSTony Lindgren static void __init ti_fapll_setup(struct device_node *node)
276163152cbSTony Lindgren {
277163152cbSTony Lindgren 	struct fapll_data *fd;
278163152cbSTony Lindgren 	struct clk_init_data *init = NULL;
279163152cbSTony Lindgren 	const char *parent_name[2];
280163152cbSTony Lindgren 	struct clk *pll_clk;
281163152cbSTony Lindgren 	int i;
282163152cbSTony Lindgren 
283163152cbSTony Lindgren 	fd = kzalloc(sizeof(*fd), GFP_KERNEL);
284163152cbSTony Lindgren 	if (!fd)
285163152cbSTony Lindgren 		return;
286163152cbSTony Lindgren 
287163152cbSTony Lindgren 	fd->outputs.clks = kzalloc(sizeof(struct clk *) *
288163152cbSTony Lindgren 				   MAX_FAPLL_OUTPUTS + 1,
289163152cbSTony Lindgren 				   GFP_KERNEL);
290163152cbSTony Lindgren 	if (!fd->outputs.clks)
291163152cbSTony Lindgren 		goto free;
292163152cbSTony Lindgren 
293163152cbSTony Lindgren 	init = kzalloc(sizeof(*init), GFP_KERNEL);
294163152cbSTony Lindgren 	if (!init)
295163152cbSTony Lindgren 		goto free;
296163152cbSTony Lindgren 
297163152cbSTony Lindgren 	init->ops = &ti_fapll_ops;
298163152cbSTony Lindgren 	init->name = node->name;
299163152cbSTony Lindgren 
300163152cbSTony Lindgren 	init->num_parents = of_clk_get_parent_count(node);
301163152cbSTony Lindgren 	if (init->num_parents != 2) {
302163152cbSTony Lindgren 		pr_err("%s must have two parents\n", node->name);
303163152cbSTony Lindgren 		goto free;
304163152cbSTony Lindgren 	}
305163152cbSTony Lindgren 
306163152cbSTony Lindgren 	parent_name[0] = of_clk_get_parent_name(node, 0);
307163152cbSTony Lindgren 	parent_name[1] = of_clk_get_parent_name(node, 1);
308163152cbSTony Lindgren 	init->parent_names = parent_name;
309163152cbSTony Lindgren 
310163152cbSTony Lindgren 	fd->clk_ref = of_clk_get(node, 0);
311163152cbSTony Lindgren 	if (IS_ERR(fd->clk_ref)) {
312163152cbSTony Lindgren 		pr_err("%s could not get clk_ref\n", node->name);
313163152cbSTony Lindgren 		goto free;
314163152cbSTony Lindgren 	}
315163152cbSTony Lindgren 
316163152cbSTony Lindgren 	fd->clk_bypass = of_clk_get(node, 1);
317163152cbSTony Lindgren 	if (IS_ERR(fd->clk_bypass)) {
318163152cbSTony Lindgren 		pr_err("%s could not get clk_bypass\n", node->name);
319163152cbSTony Lindgren 		goto free;
320163152cbSTony Lindgren 	}
321163152cbSTony Lindgren 
322163152cbSTony Lindgren 	fd->base = of_iomap(node, 0);
323163152cbSTony Lindgren 	if (!fd->base) {
324163152cbSTony Lindgren 		pr_err("%s could not get IO base\n", node->name);
325163152cbSTony Lindgren 		goto free;
326163152cbSTony Lindgren 	}
327163152cbSTony Lindgren 
328163152cbSTony Lindgren 	if (fapll_is_ddr_pll(fd->base))
329163152cbSTony Lindgren 		fd->bypass_bit_inverted = true;
330163152cbSTony Lindgren 
331163152cbSTony Lindgren 	fd->name = node->name;
332163152cbSTony Lindgren 	fd->hw.init = init;
333163152cbSTony Lindgren 
334163152cbSTony Lindgren 	/* Register the parent PLL */
335163152cbSTony Lindgren 	pll_clk = clk_register(NULL, &fd->hw);
336163152cbSTony Lindgren 	if (IS_ERR(pll_clk))
337163152cbSTony Lindgren 		goto unmap;
338163152cbSTony Lindgren 
339163152cbSTony Lindgren 	fd->outputs.clks[0] = pll_clk;
340163152cbSTony Lindgren 	fd->outputs.clk_num++;
341163152cbSTony Lindgren 
342163152cbSTony Lindgren 	/*
343163152cbSTony Lindgren 	 * Set up the child synthesizers starting at index 1 as the
344163152cbSTony Lindgren 	 * PLL output is at index 0. We need to check the clock-indices
345163152cbSTony Lindgren 	 * for numbering in case there are holes in the synth mapping,
346163152cbSTony Lindgren 	 * and then probe the synth register to see if it has a FREQ
347163152cbSTony Lindgren 	 * register available.
348163152cbSTony Lindgren 	 */
349163152cbSTony Lindgren 	for (i = 0; i < MAX_FAPLL_OUTPUTS; i++) {
350163152cbSTony Lindgren 		const char *output_name;
351163152cbSTony Lindgren 		void __iomem *freq, *div;
352163152cbSTony Lindgren 		struct clk *synth_clk;
353163152cbSTony Lindgren 		int output_instance;
354163152cbSTony Lindgren 		u32 v;
355163152cbSTony Lindgren 
356163152cbSTony Lindgren 		if (of_property_read_string_index(node, "clock-output-names",
357163152cbSTony Lindgren 						  i, &output_name))
358163152cbSTony Lindgren 			continue;
359163152cbSTony Lindgren 
360163152cbSTony Lindgren 		if (of_property_read_u32_index(node, "clock-indices", i,
361163152cbSTony Lindgren 					       &output_instance))
362163152cbSTony Lindgren 			output_instance = i;
363163152cbSTony Lindgren 
364163152cbSTony Lindgren 		freq = fd->base + (output_instance * 8);
365163152cbSTony Lindgren 		div = freq + 4;
366163152cbSTony Lindgren 
367163152cbSTony Lindgren 		/* Check for hardwired audio_pll_clk1 */
368163152cbSTony Lindgren 		if (is_audio_pll_clk1(freq)) {
369163152cbSTony Lindgren 			freq = 0;
370163152cbSTony Lindgren 			div = 0;
371163152cbSTony Lindgren 		} else {
372163152cbSTony Lindgren 			/* Does the synthesizer have a FREQ register? */
373163152cbSTony Lindgren 			v = readl_relaxed(freq);
374163152cbSTony Lindgren 			if (!v)
375163152cbSTony Lindgren 				freq = 0;
376163152cbSTony Lindgren 		}
377163152cbSTony Lindgren 		synth_clk = ti_fapll_synth_setup(fd, freq, div, output_instance,
378163152cbSTony Lindgren 						 output_name, node->name,
379163152cbSTony Lindgren 						 pll_clk);
380163152cbSTony Lindgren 		if (IS_ERR(synth_clk))
381163152cbSTony Lindgren 			continue;
382163152cbSTony Lindgren 
383163152cbSTony Lindgren 		fd->outputs.clks[output_instance] = synth_clk;
384163152cbSTony Lindgren 		fd->outputs.clk_num++;
385163152cbSTony Lindgren 
386163152cbSTony Lindgren 		clk_register_clkdev(synth_clk, output_name, NULL);
387163152cbSTony Lindgren 	}
388163152cbSTony Lindgren 
389163152cbSTony Lindgren 	/* Register the child synthesizers as the FAPLL outputs */
390163152cbSTony Lindgren 	of_clk_add_provider(node, of_clk_src_onecell_get, &fd->outputs);
391163152cbSTony Lindgren 	/* Add clock alias for the outputs */
392163152cbSTony Lindgren 
393163152cbSTony Lindgren 	kfree(init);
394163152cbSTony Lindgren 
395163152cbSTony Lindgren 	return;
396163152cbSTony Lindgren 
397163152cbSTony Lindgren unmap:
398163152cbSTony Lindgren 	iounmap(fd->base);
399163152cbSTony Lindgren free:
400163152cbSTony Lindgren 	if (fd->clk_bypass)
401163152cbSTony Lindgren 		clk_put(fd->clk_bypass);
402163152cbSTony Lindgren 	if (fd->clk_ref)
403163152cbSTony Lindgren 		clk_put(fd->clk_ref);
404163152cbSTony Lindgren 	kfree(fd->outputs.clks);
405163152cbSTony Lindgren 	kfree(fd);
406163152cbSTony Lindgren 	kfree(init);
407163152cbSTony Lindgren }
408163152cbSTony Lindgren 
409163152cbSTony Lindgren CLK_OF_DECLARE(ti_fapll_clock, "ti,dm816-fapll-clock", ti_fapll_setup);
410