Lines Matching +full:osc +full:- +full:bypass

1 // SPDX-License-Identifier: GPL-2.0-or-later
8 #include <linux/clk-provider.h>
70 struct clk_slow_osc *osc = to_clk_slow_osc(hw); in clk_slow_osc_prepare() local
71 void __iomem *sckcr = osc->sckcr; in clk_slow_osc_prepare()
74 if (tmp & (osc->bits->cr_osc32byp | osc->bits->cr_osc32en)) in clk_slow_osc_prepare()
77 writel(tmp | osc->bits->cr_osc32en, sckcr); in clk_slow_osc_prepare()
80 udelay(osc->startup_usec); in clk_slow_osc_prepare()
82 usleep_range(osc->startup_usec, osc->startup_usec + 1); in clk_slow_osc_prepare()
89 struct clk_slow_osc *osc = to_clk_slow_osc(hw); in clk_slow_osc_unprepare() local
90 void __iomem *sckcr = osc->sckcr; in clk_slow_osc_unprepare()
93 if (tmp & osc->bits->cr_osc32byp) in clk_slow_osc_unprepare()
96 writel(tmp & ~osc->bits->cr_osc32en, sckcr); in clk_slow_osc_unprepare()
101 struct clk_slow_osc *osc = to_clk_slow_osc(hw); in clk_slow_osc_is_prepared() local
102 void __iomem *sckcr = osc->sckcr; in clk_slow_osc_is_prepared()
105 if (tmp & osc->bits->cr_osc32byp) in clk_slow_osc_is_prepared()
108 return !!(tmp & osc->bits->cr_osc32en); in clk_slow_osc_is_prepared()
122 bool bypass, in at91_clk_register_slow_osc() argument
125 struct clk_slow_osc *osc; in at91_clk_register_slow_osc() local
131 return ERR_PTR(-EINVAL); in at91_clk_register_slow_osc()
133 osc = kzalloc(sizeof(*osc), GFP_KERNEL); in at91_clk_register_slow_osc()
134 if (!osc) in at91_clk_register_slow_osc()
135 return ERR_PTR(-ENOMEM); in at91_clk_register_slow_osc()
143 osc->hw.init = &init; in at91_clk_register_slow_osc()
144 osc->sckcr = sckcr; in at91_clk_register_slow_osc()
145 osc->startup_usec = startup; in at91_clk_register_slow_osc()
146 osc->bits = bits; in at91_clk_register_slow_osc()
148 if (bypass) in at91_clk_register_slow_osc()
149 writel((readl(sckcr) & ~osc->bits->cr_osc32en) | in at91_clk_register_slow_osc()
150 osc->bits->cr_osc32byp, sckcr); in at91_clk_register_slow_osc()
152 hw = &osc->hw; in at91_clk_register_slow_osc()
153 ret = clk_hw_register(NULL, &osc->hw); in at91_clk_register_slow_osc()
155 kfree(osc); in at91_clk_register_slow_osc()
164 struct clk_slow_osc *osc = to_clk_slow_osc(hw); in at91_clk_unregister_slow_osc() local
167 kfree(osc); in at91_clk_unregister_slow_osc()
173 struct clk_slow_rc_osc *osc = to_clk_slow_rc_osc(hw); in clk_slow_rc_osc_recalc_rate() local
175 return osc->frequency; in clk_slow_rc_osc_recalc_rate()
181 struct clk_slow_rc_osc *osc = to_clk_slow_rc_osc(hw); in clk_slow_rc_osc_recalc_accuracy() local
183 return osc->accuracy; in clk_slow_rc_osc_recalc_accuracy()
188 struct clk_slow_rc_osc *osc = to_clk_slow_rc_osc(hw); in clk_slow_rc_osc_prepare() local
189 void __iomem *sckcr = osc->sckcr; in clk_slow_rc_osc_prepare()
191 writel(readl(sckcr) | osc->bits->cr_rcen, sckcr); in clk_slow_rc_osc_prepare()
194 udelay(osc->startup_usec); in clk_slow_rc_osc_prepare()
196 usleep_range(osc->startup_usec, osc->startup_usec + 1); in clk_slow_rc_osc_prepare()
203 struct clk_slow_rc_osc *osc = to_clk_slow_rc_osc(hw); in clk_slow_rc_osc_unprepare() local
204 void __iomem *sckcr = osc->sckcr; in clk_slow_rc_osc_unprepare()
206 writel(readl(sckcr) & ~osc->bits->cr_rcen, sckcr); in clk_slow_rc_osc_unprepare()
211 struct clk_slow_rc_osc *osc = to_clk_slow_rc_osc(hw); in clk_slow_rc_osc_is_prepared() local
213 return !!(readl(osc->sckcr) & osc->bits->cr_rcen); in clk_slow_rc_osc_is_prepared()
232 struct clk_slow_rc_osc *osc; in at91_clk_register_slow_rc_osc() local
238 return ERR_PTR(-EINVAL); in at91_clk_register_slow_rc_osc()
240 osc = kzalloc(sizeof(*osc), GFP_KERNEL); in at91_clk_register_slow_rc_osc()
241 if (!osc) in at91_clk_register_slow_rc_osc()
242 return ERR_PTR(-ENOMEM); in at91_clk_register_slow_rc_osc()
250 osc->hw.init = &init; in at91_clk_register_slow_rc_osc()
251 osc->sckcr = sckcr; in at91_clk_register_slow_rc_osc()
252 osc->bits = bits; in at91_clk_register_slow_rc_osc()
253 osc->frequency = frequency; in at91_clk_register_slow_rc_osc()
254 osc->accuracy = accuracy; in at91_clk_register_slow_rc_osc()
255 osc->startup_usec = startup; in at91_clk_register_slow_rc_osc()
257 hw = &osc->hw; in at91_clk_register_slow_rc_osc()
258 ret = clk_hw_register(NULL, &osc->hw); in at91_clk_register_slow_rc_osc()
260 kfree(osc); in at91_clk_register_slow_rc_osc()
269 struct clk_slow_rc_osc *osc = to_clk_slow_rc_osc(hw); in at91_clk_unregister_slow_rc_osc() local
272 kfree(osc); in at91_clk_unregister_slow_rc_osc()
278 void __iomem *sckcr = slowck->sckcr; in clk_sam9x5_slow_set_parent()
282 return -EINVAL; in clk_sam9x5_slow_set_parent()
286 if ((!index && !(tmp & slowck->bits->cr_oscsel)) || in clk_sam9x5_slow_set_parent()
287 (index && (tmp & slowck->bits->cr_oscsel))) in clk_sam9x5_slow_set_parent()
291 tmp |= slowck->bits->cr_oscsel; in clk_sam9x5_slow_set_parent()
293 tmp &= ~slowck->bits->cr_oscsel; in clk_sam9x5_slow_set_parent()
309 return !!(readl(slowck->sckcr) & slowck->bits->cr_oscsel); in clk_sam9x5_slow_get_parent()
331 return ERR_PTR(-EINVAL); in at91_clk_register_sam9x5_slow()
335 return ERR_PTR(-ENOMEM); in at91_clk_register_sam9x5_slow()
343 slowck->hw.init = &init; in at91_clk_register_sam9x5_slow()
344 slowck->sckcr = sckcr; in at91_clk_register_sam9x5_slow()
345 slowck->bits = bits; in at91_clk_register_sam9x5_slow()
346 slowck->parent = !!(readl(sckcr) & slowck->bits->cr_oscsel); in at91_clk_register_sam9x5_slow()
348 hw = &slowck->hw; in at91_clk_register_sam9x5_slow()
349 ret = clk_hw_register(NULL, &slowck->hw); in at91_clk_register_sam9x5_slow()
378 bool bypass; in at91sam9x5_sckc_register() local
393 child = of_get_compatible_child(np, "atmel,at91sam9x5-clk-slow-osc"); in at91sam9x5_sckc_register()
398 bypass = of_property_read_bool(child, "atmel,osc-bypass"); in at91sam9x5_sckc_register()
400 child = of_get_compatible_child(np, "atmel,at91sam9x5-clk-slow"); in at91sam9x5_sckc_register()
402 bypass = of_property_read_bool(np, "atmel,osc-bypass"); in at91sam9x5_sckc_register()
411 &parent_data, 1200000, bypass, bits); in at91sam9x5_sckc_register()
453 CLK_OF_DECLARE(at91sam9x5_clk_sckc, "atmel,at91sam9x5-sckc",
460 CLK_OF_DECLARE(sama5d3_clk_sckc, "atmel,sama5d3-sckc",
479 bool bypass; in of_sam9x60_sckc_setup() local
496 bypass = of_property_read_bool(np, "atmel,osc-bypass"); in of_sam9x60_sckc_setup()
498 &parent_data, 5000000, bypass, in of_sam9x60_sckc_setup()
508 clk_data->num = 2; in of_sam9x60_sckc_setup()
509 clk_data->hws[0] = clk_hw_register_fixed_rate_parent_hw(NULL, "md_slck", in of_sam9x60_sckc_setup()
512 if (IS_ERR(clk_data->hws[0])) in of_sam9x60_sckc_setup()
517 clk_data->hws[1] = at91_clk_register_sam9x5_slow(regbase, "td_slck", in of_sam9x60_sckc_setup()
520 if (IS_ERR(clk_data->hws[1])) in of_sam9x60_sckc_setup()
530 at91_clk_unregister_sam9x5_slow(clk_data->hws[1]); in of_sam9x60_sckc_setup()
532 clk_hw_unregister(clk_data->hws[0]); in of_sam9x60_sckc_setup()
540 CLK_OF_DECLARE(sam9x60_clk_sckc, "microchip,sam9x60-sckc",
545 struct clk_sama5d4_slow_osc *osc = to_clk_sama5d4_slow_osc(hw); in clk_sama5d4_slow_osc_prepare() local
547 if (osc->prepared) in clk_sama5d4_slow_osc_prepare()
554 if ((readl(osc->sckcr) & osc->bits->cr_oscsel)) { in clk_sama5d4_slow_osc_prepare()
555 osc->prepared = true; in clk_sama5d4_slow_osc_prepare()
560 udelay(osc->startup_usec); in clk_sama5d4_slow_osc_prepare()
562 usleep_range(osc->startup_usec, osc->startup_usec + 1); in clk_sama5d4_slow_osc_prepare()
563 osc->prepared = true; in clk_sama5d4_slow_osc_prepare()
570 struct clk_sama5d4_slow_osc *osc = to_clk_sama5d4_slow_osc(hw); in clk_sama5d4_slow_osc_is_prepared() local
572 return osc->prepared; in clk_sama5d4_slow_osc_is_prepared()
588 struct clk_sama5d4_slow_osc *osc; in of_sama5d4_sckc_setup() local
612 osc = kzalloc(sizeof(*osc), GFP_KERNEL); in of_sama5d4_sckc_setup()
613 if (!osc) in of_sama5d4_sckc_setup()
622 osc->hw.init = &init; in of_sama5d4_sckc_setup()
623 osc->sckcr = regbase; in of_sama5d4_sckc_setup()
624 osc->startup_usec = 1200000; in of_sama5d4_sckc_setup()
625 osc->bits = &at91sama5d4_bits; in of_sama5d4_sckc_setup()
627 ret = clk_hw_register(NULL, &osc->hw); in of_sama5d4_sckc_setup()
632 parent_hws[1] = &osc->hw; in of_sama5d4_sckc_setup()
648 clk_hw_unregister(&osc->hw); in of_sama5d4_sckc_setup()
650 kfree(osc); in of_sama5d4_sckc_setup()
654 CLK_OF_DECLARE(sama5d4_clk_sckc, "atmel,sama5d4-sckc",