Lines Matching +full:12 +full:bit +full:- +full:clk +full:- +full:divider
1 // SPDX-License-Identifier: GPL-2.0+
11 #define pr_fmt(fmt) "ap-cpu-clk: " fmt
13 #include <linux/clk-provider.h>
14 #include <linux/clk.h>
29 #define APN806_CLUSTER_NUM_MASK BIT(APN806_CLUSTER_NUM_OFFSET)
100 #define AP807_PLL_CR_1_CPU_CLK_DIV_RATIO_OFFSET 12
147 struct ap_cpu_clk *clk = to_ap_cpu_clk(hw); in ap_cpu_clk_recalc_rate() local
151 cpu_clkdiv_reg = clk->pll_regs->divider_reg + in ap_cpu_clk_recalc_rate()
152 (clk->cluster * clk->pll_regs->cluster_offset); in ap_cpu_clk_recalc_rate()
153 regmap_read(clk->pll_cr_base, cpu_clkdiv_reg, &cpu_clkdiv_ratio); in ap_cpu_clk_recalc_rate()
154 cpu_clkdiv_ratio &= clk->pll_regs->divider_mask; in ap_cpu_clk_recalc_rate()
155 cpu_clkdiv_ratio >>= clk->pll_regs->divider_offset; in ap_cpu_clk_recalc_rate()
163 struct ap_cpu_clk *clk = to_ap_cpu_clk(hw); in ap_cpu_clk_set_rate() local
164 int ret, reg, divider = parent_rate / rate; in ap_cpu_clk_set_rate() local
167 cpu_clkdiv_reg = clk->pll_regs->divider_reg + in ap_cpu_clk_set_rate()
168 (clk->cluster * clk->pll_regs->cluster_offset); in ap_cpu_clk_set_rate()
169 cpu_force_reg = clk->pll_regs->force_reg + in ap_cpu_clk_set_rate()
170 (clk->cluster * clk->pll_regs->cluster_offset); in ap_cpu_clk_set_rate()
171 cpu_ratio_reg = clk->pll_regs->ratio_reg + in ap_cpu_clk_set_rate()
172 (clk->cluster * clk->pll_regs->cluster_offset); in ap_cpu_clk_set_rate()
174 regmap_read(clk->pll_cr_base, cpu_clkdiv_reg, ®); in ap_cpu_clk_set_rate()
175 reg &= ~(clk->pll_regs->divider_mask); in ap_cpu_clk_set_rate()
176 reg |= (divider << clk->pll_regs->divider_offset); in ap_cpu_clk_set_rate()
179 * AP807 CPU divider has two channels with ratio 1:3 and divider_ratio in ap_cpu_clk_set_rate()
182 if (clk->pll_regs->divider_ratio) { in ap_cpu_clk_set_rate()
184 reg |= ((divider * clk->pll_regs->divider_ratio) << in ap_cpu_clk_set_rate()
187 regmap_write(clk->pll_cr_base, cpu_clkdiv_reg, reg); in ap_cpu_clk_set_rate()
190 regmap_update_bits(clk->pll_cr_base, cpu_force_reg, in ap_cpu_clk_set_rate()
191 clk->pll_regs->force_mask, in ap_cpu_clk_set_rate()
192 clk->pll_regs->force_mask); in ap_cpu_clk_set_rate()
194 regmap_update_bits(clk->pll_cr_base, cpu_ratio_reg, in ap_cpu_clk_set_rate()
195 BIT(clk->pll_regs->ratio_offset), in ap_cpu_clk_set_rate()
196 BIT(clk->pll_regs->ratio_offset)); in ap_cpu_clk_set_rate()
198 stable_bit = BIT(clk->pll_regs->ratio_state_offset + in ap_cpu_clk_set_rate()
199 clk->cluster * in ap_cpu_clk_set_rate()
200 clk->pll_regs->ratio_state_cluster_offset); in ap_cpu_clk_set_rate()
201 ret = regmap_read_poll_timeout(clk->pll_cr_base, in ap_cpu_clk_set_rate()
202 clk->pll_regs->ratio_state_reg, reg, in ap_cpu_clk_set_rate()
208 regmap_update_bits(clk->pll_cr_base, cpu_ratio_reg, in ap_cpu_clk_set_rate()
209 BIT(clk->pll_regs->ratio_offset), 0); in ap_cpu_clk_set_rate()
217 int divider = *parent_rate / rate; in ap_cpu_clk_round_rate() local
219 divider = min(divider, APN806_MAX_DIVIDER); in ap_cpu_clk_round_rate()
221 return *parent_rate / divider; in ap_cpu_clk_round_rate()
233 struct device *dev = &pdev->dev; in ap_cpu_clock_probe()
234 struct device_node *dn, *np = dev->of_node; in ap_cpu_clock_probe()
239 regmap = syscon_node_to_regmap(np->parent); in ap_cpu_clock_probe()
278 return -ENOMEM; in ap_cpu_clock_probe()
284 return -ENOMEM; in ap_cpu_clock_probe()
287 char *clk_name = "cpu-cluster-0"; in ap_cpu_clock_probe()
290 struct clk *parent; in ap_cpu_clock_probe()
303 if (ap_cpu_data->hws[cluster_index]) in ap_cpu_clock_probe()
310 return -EINVAL; in ap_cpu_clock_probe()
313 clk_name[12] += cluster_index; in ap_cpu_clock_probe()
315 ap_cp_unique_name(dev, np->parent, clk_name); in ap_cpu_clock_probe()
320 ap_cpu_clk[cluster_index].pll_regs = of_device_get_match_data(&pdev->dev); in ap_cpu_clock_probe()
332 ap_cpu_data->hws[cluster_index] = &ap_cpu_clk[cluster_index].hw; in ap_cpu_clock_probe()
335 ap_cpu_data->num = cluster_index + 1; in ap_cpu_clock_probe()
346 .compatible = "marvell,ap806-cpu-clock",
350 .compatible = "marvell,ap807-cpu-clock",
359 .name = "marvell-ap-cpu-clock",