Lines Matching +full:- +full:30 +full:mv

1 // SPDX-License-Identifier: GPL-2.0+
7 * Gregory CLEMENT <gregory.clement@free-electrons.com>
24 #include "cpufreq-dt.h"
47 #define ARMADA_37XX_NB_VDD_EN BIT(30)
58 #define ARMADA_37XX_AVS_ENABLE BIT(30)
77 /* AVS value for the corresponding voltage (in mV) */
166 * Set cpu divider based on the pre-computed array in in armada37xx_cpufreq_dvfs_setup()
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.
238 dvfs->avs[0] = l0_vdd_min; in armada37xx_cpufreq_avs_configure()
242 * If L0 voltage is smaller than 1000mv, then all VDD sets in armada37xx_cpufreq_avs_configure()
248 dvfs->avs[load_level] = avs_min; 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()
268 * larger than 1000mv 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()
277 * be larger than 1000mv 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()
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()
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()
443 return -ENODEV; in armada37xx_cpufreq_driver_init()
465 return -EINVAL; in armada37xx_cpufreq_driver_init()
471 return -EINVAL; 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()
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>");