Lines Matching +full:csi +full:- +full:pclk
1 // SPDX-License-Identifier: GPL-2.0
8 #include <linux/clk-provider.h>
18 #include <dt-bindings/clock/stm32h7-clks.h>
139 /* Micro-controller output clock parent */
178 bit_status = !(readl(gate->reg) & BIT(rgate->bit_rdy)); in ready_gate_clk_enable()
183 } while (bit_status && --timeout); in ready_gate_clk_enable()
201 bit_status = !!(readl(gate->reg) & BIT(rgate->bit_rdy)); in ready_gate_clk_disable()
206 } while (bit_status && --timeout); in ready_gate_clk_disable()
227 return ERR_PTR(-ENOMEM); in clk_register_ready_gate()
235 rgate->bit_rdy = bit_rdy; in clk_register_ready_gate()
236 rgate->gate.lock = lock; in clk_register_ready_gate()
237 rgate->gate.reg = reg; in clk_register_ready_gate()
238 rgate->gate.bit_idx = bit_idx; in clk_register_ready_gate()
239 rgate->gate.hw.init = &init; in clk_register_ready_gate()
241 hw = &rgate->gate.hw; in clk_register_ready_gate()
302 return ERR_PTR(-ENOMEM); in _get_cmux()
304 mux->reg = reg; in _get_cmux()
305 mux->shift = shift; in _get_cmux()
306 mux->mask = (1 << width) - 1; in _get_cmux()
307 mux->flags = flags; in _get_cmux()
308 mux->lock = lock; in _get_cmux()
321 return ERR_PTR(-ENOMEM); in _get_cdiv()
323 div->reg = reg; in _get_cdiv()
324 div->shift = shift; in _get_cdiv()
325 div->width = width; in _get_cdiv()
326 div->flags = flags; in _get_cdiv()
327 div->lock = lock; in _get_cdiv()
339 return ERR_PTR(-ENOMEM); in _get_cgate()
341 gate->reg = reg; in _get_cgate()
342 gate->bit_idx = bit_idx; in _get_cgate()
343 gate->flags = flags; in _get_cgate()
344 gate->lock = lock; in _get_cgate()
374 if (gcfg->mux && cfg->mux) { in get_cfg_composite_div()
375 mux = _get_cmux(base + cfg->mux->offset, in get_cfg_composite_div()
376 cfg->mux->shift, in get_cfg_composite_div()
377 cfg->mux->width, in get_cfg_composite_div()
378 gcfg->mux->flags, lock); in get_cfg_composite_div()
381 mux_hw = &mux->hw; in get_cfg_composite_div()
382 mux_ops = gcfg->mux->ops ? in get_cfg_composite_div()
383 gcfg->mux->ops : &clk_mux_ops; in get_cfg_composite_div()
387 if (gcfg->div && cfg->div) { in get_cfg_composite_div()
388 div = _get_cdiv(base + cfg->div->offset, in get_cfg_composite_div()
389 cfg->div->shift, in get_cfg_composite_div()
390 cfg->div->width, in get_cfg_composite_div()
391 gcfg->div->flags, lock); in get_cfg_composite_div()
394 div_hw = &div->hw; in get_cfg_composite_div()
395 div_ops = gcfg->div->ops ? in get_cfg_composite_div()
396 gcfg->div->ops : &clk_divider_ops; in get_cfg_composite_div()
400 if (gcfg->gate && cfg->gate) { in get_cfg_composite_div()
401 gate = _get_cgate(base + cfg->gate->offset, in get_cfg_composite_div()
402 cfg->gate->bit_idx, in get_cfg_composite_div()
403 gcfg->gate->flags, lock); in get_cfg_composite_div()
406 gate_hw = &gate->hw; in get_cfg_composite_div()
407 gate_ops = gcfg->gate->ops ? in get_cfg_composite_div()
408 gcfg->gate->ops : &clk_gate_ops; in get_cfg_composite_div()
412 composite->mux_hw = mux_hw; in get_cfg_composite_div()
413 composite->mux_ops = mux_ops; in get_cfg_composite_div()
415 composite->div_hw = div_hw; in get_cfg_composite_div()
416 composite->div_ops = div_ops; in get_cfg_composite_div()
418 composite->gate_hw = gate_hw; in get_cfg_composite_div()
419 composite->gate_ops = gate_ops; in get_cfg_composite_div()
436 u32 dppre_shift = clk_elem->dppre_shift; in timer_ker_recalc_rate()
472 return ERR_PTR(-ENOMEM); in clk_register_stm32_timer_ker()
480 element->hw.init = &init; in clk_register_stm32_timer_ker()
481 element->lock = lock; in clk_register_stm32_timer_ker()
482 element->dppre_shift = dppre_shift; in clk_register_stm32_timer_ker()
484 hw = &element->hw; in clk_register_stm32_timer_ker()
614 OSC_CLKF("csi_ck", "clk-csi", RCC_CR, 7, 8, CLK_IGNORE_UNUSED),
615 OSC_CLKF("csi_ker", "clk-csi", RCC_CR, 9, 8, CLK_IGNORE_UNUSED),
616 OSC_CLKF("rc48_ck", "clk-rc48", RCC_CR, 12, 13, CLK_IGNORE_UNUSED),
617 OSC_CLKF("lsi_ck", "clk-lsi", RCC_CSR, 0, 1, CLK_IGNORE_UNUSED),
698 struct clk_hw *_hw = &clk_elem->rgate.gate.hw; in pll_is_enabled()
708 struct clk_hw *_hw = &clk_elem->rgate.gate.hw; in pll_enable()
718 struct clk_hw *_hw = &clk_elem->rgate.gate.hw; in pll_disable()
728 struct stm32_fractional_divider *fd = &clk_elem->div; in pll_frac_is_enabled()
730 return (readl(fd->freg_status) >> fd->freg_bit) & 0x01; in pll_frac_is_enabled()
736 struct stm32_fractional_divider *fd = &clk_elem->div; in pll_read_frac()
738 return (readl(fd->freg_value) >> fd->fshift) & in pll_read_frac()
739 GENMASK(fd->fwidth - 1, 0); in pll_read_frac()
746 struct stm32_fractional_divider *fd = &clk_elem->div; in pll_fd_recalc_rate()
751 val = readl(fd->mreg); in pll_fd_recalc_rate()
752 mask = GENMASK(fd->mwidth - 1, 0) << fd->mshift; in pll_fd_recalc_rate()
753 m = (val & mask) >> fd->mshift; in pll_fd_recalc_rate()
755 val = readl(fd->nreg); in pll_fd_recalc_rate()
756 mask = GENMASK(fd->nwidth - 1, 0) << fd->nshift; in pll_fd_recalc_rate()
757 n = ((val & mask) >> fd->nshift) + 1; in pll_fd_recalc_rate()
797 return ERR_PTR(-ENOMEM); in clk_register_stm32_pll()
804 pll->hw.init = &init; in clk_register_stm32_pll()
806 hw = &pll->hw; in clk_register_stm32_pll()
807 rgate = &pll->rgate; in clk_register_stm32_pll()
809 rgate->bit_rdy = cfg->bit_idx + 1; in clk_register_stm32_pll()
810 rgate->gate.lock = lock; in clk_register_stm32_pll()
811 rgate->gate.reg = base + RCC_CR; in clk_register_stm32_pll()
812 rgate->gate.bit_idx = cfg->bit_idx; in clk_register_stm32_pll()
814 div = &pll->div; in clk_register_stm32_pll()
815 div->flags = 0; in clk_register_stm32_pll()
816 div->mreg = base + RCC_PLLCKSELR; in clk_register_stm32_pll()
817 div->mshift = cfg->divm; in clk_register_stm32_pll()
818 div->mwidth = 6; in clk_register_stm32_pll()
819 div->nreg = base + cfg->offset_divr; in clk_register_stm32_pll()
820 div->nshift = 0; in clk_register_stm32_pll()
821 div->nwidth = 9; in clk_register_stm32_pll()
823 div->freg_status = base + RCC_PLLCFGR; in clk_register_stm32_pll()
824 div->freg_bit = cfg->bit_frac_en; in clk_register_stm32_pll()
825 div->freg_value = base + cfg->offset_frac; in clk_register_stm32_pll()
826 div->fshift = 3; in clk_register_stm32_pll()
827 div->fwidth = 13; in clk_register_stm32_pll()
829 div->lock = lock; in clk_register_stm32_pll()
997 static const struct pclk_t pclk[] = { variable
1171 /* Micro-controller output clock */
1208 clk_data->num = STM32H7_MAX_CLKS; in stm32h7_rcc_init()
1210 hws = clk_data->hws; in stm32h7_rcc_init()
1213 hws[n] = ERR_PTR(-ENOENT); in stm32h7_rcc_init()
1241 clk_hw_register_fixed_rate(NULL, "clk-hsi", NULL, 0, 64000000); in stm32h7_rcc_init()
1242 clk_hw_register_fixed_rate(NULL, "clk-csi", NULL, 0, 4000000); in stm32h7_rcc_init()
1243 clk_hw_register_fixed_rate(NULL, "clk-lsi", NULL, 0, 32000); in stm32h7_rcc_init()
1244 clk_hw_register_fixed_rate(NULL, "clk-rc48", NULL, 0, 48000); in stm32h7_rcc_init()
1250 hws[HSI_DIV] = clk_hw_register_divider(NULL, "hsidiv", "clk-hsi", 0, in stm32h7_rcc_init()
1333 for (n = 0; n < ARRAY_SIZE(pclk); n++) in stm32h7_rcc_init()
1334 hws[PERIF_BANK + n] = clk_hw_register_gate(NULL, pclk[n].name, in stm32h7_rcc_init()
1335 pclk[n].parent, in stm32h7_rcc_init()
1336 pclk[n].flags, base + pclk[n].gate_offset, in stm32h7_rcc_init()
1337 pclk[n].bit_idx, pclk[n].flags, &stm32rcc_lock); in stm32h7_rcc_init()
1368 /* Micro-controller clocks */ in stm32h7_rcc_init()
1395 CLK_OF_DECLARE_DRIVER(stm32h7_rcc, "st,stm32h743-rcc", stm32h7_rcc_init);