Lines Matching +full:fu740 +full:- +full:pcie

1 // SPDX-License-Identifier: GPL-2.0
10 #include "sifive-prci.h"
11 #include "fu540-prci.h"
12 #include "fu740-prci.h"
19 * __prci_readl() - read from a PRCI register
33 return readl_relaxed(pd->va + offs); in __prci_readl()
38 writel_relaxed(v, pd->va + offs); in __prci_writel()
41 /* WRPLL-related private functions */
44 * __prci_wrpll_unpack() - unpack WRPLL configuration registers into parameters
48 * Given a value @r read from an FU740 PRCI PLL configuration register,
63 c->divr = v; in __prci_wrpll_unpack()
67 c->divf = v; in __prci_wrpll_unpack()
71 c->divq = v; in __prci_wrpll_unpack()
75 c->range = v; in __prci_wrpll_unpack()
77 c->flags &= in __prci_wrpll_unpack()
81 c->flags |= WRPLL_FLAGS_INT_FEEDBACK_MASK; in __prci_wrpll_unpack()
85 * __prci_wrpll_pack() - pack PLL configuration parameters into a register value
103 r |= c->divr << PRCI_COREPLLCFG0_DIVR_SHIFT; in __prci_wrpll_pack()
104 r |= c->divf << PRCI_COREPLLCFG0_DIVF_SHIFT; in __prci_wrpll_pack()
105 r |= c->divq << PRCI_COREPLLCFG0_DIVQ_SHIFT; in __prci_wrpll_pack()
106 r |= c->range << PRCI_COREPLLCFG0_RANGE_SHIFT; in __prci_wrpll_pack()
115 * __prci_wrpll_read_cfg0() - read the WRPLL configuration from the PRCI
129 __prci_wrpll_unpack(&pwd->c, __prci_readl(pd, pwd->cfg0_offs)); in __prci_wrpll_read_cfg0()
133 * __prci_wrpll_write_cfg0() - write WRPLL configuration into the PRCI
150 __prci_writel(__prci_wrpll_pack(c), pwd->cfg0_offs, pd); in __prci_wrpll_write_cfg0()
152 memcpy(&pwd->c, c, sizeof(*c)); in __prci_wrpll_write_cfg0()
156 * __prci_wrpll_write_cfg1() - write Clock enable/disable configuration
166 __prci_writel(enable, pwd->cfg1_offs, pd); in __prci_wrpll_write_cfg1()
180 struct __prci_wrpll_data *pwd = pc->pwd; in sifive_prci_wrpll_recalc_rate()
182 return wrpll_calc_output_rate(&pwd->c, parent_rate); in sifive_prci_wrpll_recalc_rate()
190 struct __prci_wrpll_data *pwd = pc->pwd; in sifive_prci_wrpll_round_rate()
193 memcpy(&c, &pwd->c, sizeof(c)); in sifive_prci_wrpll_round_rate()
204 struct __prci_wrpll_data *pwd = pc->pwd; in sifive_prci_wrpll_set_rate()
205 struct __prci_data *pd = pc->pd; in sifive_prci_wrpll_set_rate()
208 r = wrpll_configure_for_rate(&pwd->c, rate, parent_rate); in sifive_prci_wrpll_set_rate()
212 if (pwd->enable_bypass) in sifive_prci_wrpll_set_rate()
213 pwd->enable_bypass(pd); in sifive_prci_wrpll_set_rate()
215 __prci_wrpll_write_cfg0(pd, pwd, &pwd->c); in sifive_prci_wrpll_set_rate()
217 udelay(wrpll_calc_max_lock_us(&pwd->c)); in sifive_prci_wrpll_set_rate()
225 struct __prci_wrpll_data *pwd = pc->pwd; in sifive_clk_is_enabled()
226 struct __prci_data *pd = pc->pd; in sifive_clk_is_enabled()
229 r = __prci_readl(pd, pwd->cfg1_offs); in sifive_clk_is_enabled()
240 struct __prci_wrpll_data *pwd = pc->pwd; in sifive_prci_clock_enable()
241 struct __prci_data *pd = pc->pd; in sifive_prci_clock_enable()
248 if (pwd->disable_bypass) in sifive_prci_clock_enable()
249 pwd->disable_bypass(pd); in sifive_prci_clock_enable()
257 struct __prci_wrpll_data *pwd = pc->pwd; in sifive_prci_clock_disable()
258 struct __prci_data *pd = pc->pd; in sifive_prci_clock_disable()
261 if (pwd->enable_bypass) in sifive_prci_clock_disable()
262 pwd->enable_bypass(pd); in sifive_prci_clock_disable()
264 r = __prci_readl(pd, pwd->cfg1_offs); in sifive_prci_clock_disable()
276 struct __prci_data *pd = pc->pd; in sifive_prci_tlclksel_recalc_rate()
293 struct __prci_data *pd = pc->pd; in sifive_prci_hfpclkplldiv_recalc_rate()
304 * sifive_prci_coreclksel_use_hfclk() - switch the CORECLK mux to output HFCLK
324 * sifive_prci_coreclksel_use_corepll() - switch the CORECLK mux to output
345 * sifive_prci_coreclksel_use_final_corepll() - switch the CORECLK mux to output
367 * sifive_prci_corepllsel_use_dvfscorepll() - switch the COREPLL mux to
388 * sifive_prci_corepllsel_use_corepll() - switch the COREPLL mux to
409 * sifive_prci_hfpclkpllsel_use_hfclk() - switch the HFPCLKPLL mux to
430 * sifive_prci_hfpclkpllsel_use_hfpclkpll() - switch the HFPCLKPLL mux to
450 /* PCIE AUX clock APIs for enable, disable. */
454 struct __prci_data *pd = pc->pd; in sifive_prci_pcie_aux_clock_is_enabled()
468 struct __prci_data *pd = pc->pd; in sifive_prci_pcie_aux_clock_enable()
483 struct __prci_data *pd = pc->pd; in sifive_prci_pcie_aux_clock_disable()
492 * __prci_register_clocks() - register clock controls in the PRCI
494 * @pd: The pointer for PRCI per-device instance data
509 parent_count = of_clk_get_parent_count(dev->of_node); in __prci_register_clocks()
513 return -EINVAL; in __prci_register_clocks()
517 for (i = 0; i < desc->num_clks; ++i) { in __prci_register_clocks()
518 pic = &(desc->clks[i]); in __prci_register_clocks()
520 init.name = pic->name; in __prci_register_clocks()
521 init.parent_names = &pic->parent_name; in __prci_register_clocks()
523 init.ops = pic->ops; in __prci_register_clocks()
524 pic->hw.init = &init; in __prci_register_clocks()
526 pic->pd = pd; in __prci_register_clocks()
528 if (pic->pwd) in __prci_register_clocks()
529 __prci_wrpll_read_cfg0(pd, pic->pwd); in __prci_register_clocks()
531 r = devm_clk_hw_register(dev, &pic->hw); in __prci_register_clocks()
538 pd->hw_clks.hws[i] = &pic->hw; in __prci_register_clocks()
541 pd->hw_clks.num = i; in __prci_register_clocks()
544 &pd->hw_clks); in __prci_register_clocks()
554 * sifive_prci_probe() - initialize prci data and check parent count
561 struct device *dev = &pdev->dev; in sifive_prci_probe()
566 desc = of_device_get_match_data(&pdev->dev); in sifive_prci_probe()
568 pd = devm_kzalloc(dev, struct_size(pd, hw_clks.hws, desc->num_clks), GFP_KERNEL); in sifive_prci_probe()
570 return -ENOMEM; in sifive_prci_probe()
572 pd->va = devm_platform_ioremap_resource(pdev, 0); in sifive_prci_probe()
573 if (IS_ERR(pd->va)) in sifive_prci_probe()
574 return PTR_ERR(pd->va); in sifive_prci_probe()
576 pd->reset.rcdev.owner = THIS_MODULE; in sifive_prci_probe()
577 pd->reset.rcdev.nr_resets = PRCI_RST_NR; in sifive_prci_probe()
578 pd->reset.rcdev.ops = &reset_simple_ops; in sifive_prci_probe()
579 pd->reset.rcdev.of_node = pdev->dev.of_node; in sifive_prci_probe()
580 pd->reset.active_low = true; in sifive_prci_probe()
581 pd->reset.membase = pd->va + PRCI_DEVICESRESETREG_OFFSET; in sifive_prci_probe()
582 spin_lock_init(&pd->reset.lock); in sifive_prci_probe()
584 r = devm_reset_controller_register(&pdev->dev, &pd->reset.rcdev); in sifive_prci_probe()
601 {.compatible = "sifive,fu540-c000-prci", .data = &prci_clk_fu540},
602 {.compatible = "sifive,fu740-c000-prci", .data = &prci_clk_fu740},
608 .name = "sifive-clk-prci",