Lines Matching +full:clk +full:- +full:out +full:- +full:frequency

1 // SPDX-License-Identifier: GPL-2.0+
3 * CPU frequency scaling support for Armada 37xx platform.
7 * Gregory CLEMENT <gregory.clement@free-electrons.com>
10 #include <linux/clk.h>
24 #include "cpufreq-dt.h"
26 /* Clk register set */
124 pr_err("Unsupported CPU frequency %d MHz\n", freq/1000000); in armada_37xx_cpu_freq_info_get()
166 * Set cpu divider based on the pre-computed array in in armada37xx_cpufreq_dvfs_setup()
186 * Find out the armada 37x supported AVS value whose voltage value is
187 * the round-up closest to the target voltage value.
193 /* Find out the round-up closest supported voltage value */ in armada_37xx_avs_val_match()
203 avs = ARRAY_SIZE(avs_map) - 1; in armada_37xx_avs_val_match()
211 * - L0 can be read out from the register of AVS_CTRL_0 and L0 voltage
213 * - L1 voltage should be about 100mv smaller than L0 voltage
214 * - L2 & L3 voltage should be about 150mv smaller than L0 voltage.
217 * When base CPU frequency is 1000 or 1200 MHz then there is additional
238 dvfs->avs[0] = l0_vdd_min; in armada37xx_cpufreq_avs_configure()
248 dvfs->avs[load_level] = avs_min; in armada37xx_cpufreq_avs_configure()
251 * Set the avs values for load L0 and L1 when base CPU frequency in armada37xx_cpufreq_avs_configure()
255 if (dvfs->cpu_freq_max >= 1000*1000*1000) { in armada37xx_cpufreq_avs_configure()
256 if (dvfs->cpu_freq_max >= 1200*1000*1000) in armada37xx_cpufreq_avs_configure()
260 dvfs->avs[0] = dvfs->avs[1] = avs_min; in armada37xx_cpufreq_avs_configure()
267 * L1 voltage is equal to L0 voltage - 100mv and it must be in armada37xx_cpufreq_avs_configure()
271 target_vm = avs_map[l0_vdd_min] - 100; in armada37xx_cpufreq_avs_configure()
273 dvfs->avs[1] = armada_37xx_avs_val_match(target_vm); in armada37xx_cpufreq_avs_configure()
276 * L2 & L3 voltage is equal to L0 voltage - 150mv and it must in armada37xx_cpufreq_avs_configure()
279 target_vm = avs_map[l0_vdd_min] - 150; in armada37xx_cpufreq_avs_configure()
281 dvfs->avs[2] = dvfs->avs[3] = armada_37xx_avs_val_match(target_vm); in armada37xx_cpufreq_avs_configure()
284 * Fix the avs value for load L1 when base CPU frequency is 1000/1200 MHz, in armada37xx_cpufreq_avs_configure()
288 if (dvfs->cpu_freq_max >= 1000*1000*1000) { in armada37xx_cpufreq_avs_configure()
291 if (dvfs->cpu_freq_max >= 1200*1000*1000) in armada37xx_cpufreq_avs_configure()
296 if (avs_min_l1 > dvfs->avs[0]) in armada37xx_cpufreq_avs_configure()
297 avs_min_l1 = dvfs->avs[0]; in armada37xx_cpufreq_avs_configure()
299 if (dvfs->avs[1] < avs_min_l1) in armada37xx_cpufreq_avs_configure()
300 dvfs->avs[1] = avs_min_l1; in armada37xx_cpufreq_avs_configure()
325 avs_val = dvfs->avs[load_level]; in armada37xx_cpufreq_avs_setup()
326 regmap_update_bits(base, ARMADA_37XX_AVS_VSET(load_level-1), in armada37xx_cpufreq_avs_setup()
370 regmap_read(state->regmap, ARMADA_37XX_NB_L0L1, &state->nb_l0l1); in armada37xx_cpufreq_suspend()
371 regmap_read(state->regmap, ARMADA_37XX_NB_L2L3, &state->nb_l2l3); in armada37xx_cpufreq_suspend()
372 regmap_read(state->regmap, ARMADA_37XX_NB_CPU_LOAD, in armada37xx_cpufreq_suspend()
373 &state->nb_cpu_load); in armada37xx_cpufreq_suspend()
374 regmap_read(state->regmap, ARMADA_37XX_NB_DYN_MOD, &state->nb_dyn_mod); in armada37xx_cpufreq_suspend()
384 armada37xx_cpufreq_disable_dvfs(state->regmap); in armada37xx_cpufreq_resume()
386 regmap_write(state->regmap, ARMADA_37XX_NB_L0L1, state->nb_l0l1); in armada37xx_cpufreq_resume()
387 regmap_write(state->regmap, ARMADA_37XX_NB_L2L3, state->nb_l2l3); in armada37xx_cpufreq_resume()
388 regmap_write(state->regmap, ARMADA_37XX_NB_CPU_LOAD, in armada37xx_cpufreq_resume()
389 state->nb_cpu_load); in armada37xx_cpufreq_resume()
396 regmap_write(state->regmap, ARMADA_37XX_NB_DYN_MOD, state->nb_dyn_mod); in armada37xx_cpufreq_resume()
411 struct clk *clk, *parent; in armada37xx_cpufreq_driver_init() local
414 syscon_regmap_lookup_by_compatible("marvell,armada-3700-periph-clock-nb"); in armada37xx_cpufreq_driver_init()
416 return -ENODEV; in armada37xx_cpufreq_driver_init()
419 syscon_regmap_lookup_by_compatible("marvell,armada-3700-nb-pm"); in armada37xx_cpufreq_driver_init()
422 return -ENODEV; in armada37xx_cpufreq_driver_init()
425 syscon_regmap_lookup_by_compatible("marvell,armada-3700-avs"); in armada37xx_cpufreq_driver_init()
437 * the nominal CPU frequency and full integer divisions of in armada37xx_cpufreq_driver_init()
443 return -ENODEV; in armada37xx_cpufreq_driver_init()
446 clk = clk_get(cpu_dev, NULL); in armada37xx_cpufreq_driver_init()
447 if (IS_ERR(clk)) { in armada37xx_cpufreq_driver_init()
449 return PTR_ERR(clk); in armada37xx_cpufreq_driver_init()
452 parent = clk_get_parent(clk); in armada37xx_cpufreq_driver_init()
455 clk_put(clk); in armada37xx_cpufreq_driver_init()
459 /* Get parent CPU frequency */ in armada37xx_cpufreq_driver_init()
464 clk_put(clk); in armada37xx_cpufreq_driver_init()
465 return -EINVAL; in armada37xx_cpufreq_driver_init()
470 clk_put(clk); in armada37xx_cpufreq_driver_init()
471 return -EINVAL; in armada37xx_cpufreq_driver_init()
477 clk_put(clk); in armada37xx_cpufreq_driver_init()
478 return -ENOMEM; in armada37xx_cpufreq_driver_init()
481 armada37xx_cpufreq_state->regmap = nb_pm_base; in armada37xx_cpufreq_driver_init()
486 armada37xx_cpufreq_dvfs_setup(nb_pm_base, nb_clk_base, dvfs->divider); in armada37xx_cpufreq_driver_init()
487 clk_put(clk); in armada37xx_cpufreq_driver_init()
491 unsigned long u_volt = avs_map[dvfs->avs[load_lvl]] * 1000; in armada37xx_cpufreq_driver_init()
492 freq = base_frequency / dvfs->divider[load_lvl]; in armada37xx_cpufreq_driver_init()
507 pdev = platform_device_register_data(NULL, "cpufreq-dt", -1, &pdata, in armada37xx_cpufreq_driver_init()
513 armada37xx_cpufreq_state->cpu_dev = cpu_dev; in armada37xx_cpufreq_driver_init()
514 armada37xx_cpufreq_state->pdev = pdev; in armada37xx_cpufreq_driver_init()
521 /* clean-up the already added opp before leaving */ in armada37xx_cpufreq_driver_init()
522 while (load_lvl-- > ARMADA_37XX_DVFS_LOAD_0) { in armada37xx_cpufreq_driver_init()
523 freq = base_frequency / dvfs->divider[load_lvl]; in armada37xx_cpufreq_driver_init()
536 struct platform_device *pdev = armada37xx_cpufreq_state->pdev; in armada37xx_cpufreq_driver_exit()
543 armada37xx_cpufreq_disable_dvfs(armada37xx_cpufreq_state->regmap); in armada37xx_cpufreq_driver_exit()
546 freq = dvfs->cpu_freq_max / dvfs->divider[load_lvl]; in armada37xx_cpufreq_driver_exit()
547 dev_pm_opp_remove(armada37xx_cpufreq_state->cpu_dev, freq); in armada37xx_cpufreq_driver_exit()
555 { .compatible = "marvell,armada-3700-nb-pm" },
560 MODULE_AUTHOR("Gregory CLEMENT <gregory.clement@free-electrons.com>");