Lines Matching refs:info
68 struct mtk_cpu_dvfs_info *info; in mtk_cpu_dvfs_info_lookup() local
70 list_for_each_entry(info, &dvfs_info_list, list_head) { in mtk_cpu_dvfs_info_lookup()
71 if (cpumask_test_cpu(cpu, &info->cpus)) in mtk_cpu_dvfs_info_lookup()
72 return info; in mtk_cpu_dvfs_info_lookup()
78 static int mtk_cpufreq_voltage_tracking(struct mtk_cpu_dvfs_info *info, in mtk_cpufreq_voltage_tracking() argument
81 const struct mtk_cpufreq_platform_data *soc_data = info->soc_data; in mtk_cpufreq_voltage_tracking()
82 struct regulator *proc_reg = info->proc_reg; in mtk_cpufreq_voltage_tracking()
83 struct regulator *sram_reg = info->sram_reg; in mtk_cpufreq_voltage_tracking()
85 int retry = info->vtrack_max; in mtk_cpufreq_voltage_tracking()
89 dev_err(info->cpu_dev, in mtk_cpufreq_voltage_tracking()
96 dev_err(info->cpu_dev, "invalid Vsram value: %d\n", pre_vsram); in mtk_cpufreq_voltage_tracking()
153 dev_err(info->cpu_dev, in mtk_cpufreq_voltage_tracking()
162 static int mtk_cpufreq_set_voltage(struct mtk_cpu_dvfs_info *info, int vproc) in mtk_cpufreq_set_voltage() argument
164 const struct mtk_cpufreq_platform_data *soc_data = info->soc_data; in mtk_cpufreq_set_voltage()
167 if (info->need_voltage_tracking) in mtk_cpufreq_set_voltage()
168 ret = mtk_cpufreq_voltage_tracking(info, vproc); in mtk_cpufreq_set_voltage()
170 ret = regulator_set_voltage(info->proc_reg, vproc, in mtk_cpufreq_set_voltage()
173 info->pre_vproc = vproc; in mtk_cpufreq_set_voltage()
178 static bool is_ccifreq_ready(struct mtk_cpu_dvfs_info *info) in is_ccifreq_ready() argument
182 if (info->ccifreq_bound) in is_ccifreq_ready()
185 sup_link = device_link_add(info->cpu_dev, info->cci_dev, in is_ccifreq_ready()
188 dev_err(info->cpu_dev, "cpu%d: sup_link is NULL\n", info->opp_cpu); in is_ccifreq_ready()
195 info->ccifreq_bound = true; in is_ccifreq_ready()
206 struct mtk_cpu_dvfs_info *info = policy->driver_data; in mtk_cpufreq_set_target() local
207 struct device *cpu_dev = info->cpu_dev; in mtk_cpufreq_set_target()
212 inter_vproc = info->intermediate_voltage; in mtk_cpufreq_set_target()
216 mutex_lock(&info->reg_lock); in mtk_cpufreq_set_target()
218 if (unlikely(info->pre_vproc <= 0)) in mtk_cpufreq_set_target()
219 pre_vproc = regulator_get_voltage(info->proc_reg); in mtk_cpufreq_set_target()
221 pre_vproc = info->pre_vproc; in mtk_cpufreq_set_target()
246 if (info->soc_data->ccifreq_supported && !is_ccifreq_ready(info)) in mtk_cpufreq_set_target()
247 vproc = max(vproc, info->vproc_on_boot); in mtk_cpufreq_set_target()
255 ret = mtk_cpufreq_set_voltage(info, target_vproc); in mtk_cpufreq_set_target()
259 mtk_cpufreq_set_voltage(info, pre_vproc); in mtk_cpufreq_set_target()
265 ret = clk_set_parent(cpu_clk, info->inter_clk); in mtk_cpufreq_set_target()
269 mtk_cpufreq_set_voltage(info, pre_vproc); in mtk_cpufreq_set_target()
279 mtk_cpufreq_set_voltage(info, pre_vproc); in mtk_cpufreq_set_target()
288 mtk_cpufreq_set_voltage(info, inter_vproc); in mtk_cpufreq_set_target()
297 ret = mtk_cpufreq_set_voltage(info, vproc); in mtk_cpufreq_set_target()
301 clk_set_parent(cpu_clk, info->inter_clk); in mtk_cpufreq_set_target()
308 info->current_freq = freq_hz; in mtk_cpufreq_set_target()
311 mutex_unlock(&info->reg_lock); in mtk_cpufreq_set_target()
323 struct mtk_cpu_dvfs_info *info; in mtk_cpufreq_opp_notifier() local
328 info = container_of(nb, struct mtk_cpu_dvfs_info, opp_nb); in mtk_cpufreq_opp_notifier()
333 mutex_lock(&info->reg_lock); in mtk_cpufreq_opp_notifier()
334 if (info->current_freq == freq) { in mtk_cpufreq_opp_notifier()
336 ret = mtk_cpufreq_set_voltage(info, volt); in mtk_cpufreq_opp_notifier()
338 dev_err(info->cpu_dev, in mtk_cpufreq_opp_notifier()
341 mutex_unlock(&info->reg_lock); in mtk_cpufreq_opp_notifier()
346 if (info->current_freq == freq) { in mtk_cpufreq_opp_notifier()
348 new_opp = dev_pm_opp_find_freq_ceil(info->cpu_dev, in mtk_cpufreq_opp_notifier()
351 dev_err(info->cpu_dev, in mtk_cpufreq_opp_notifier()
358 policy = cpufreq_cpu_get(info->opp_cpu); in mtk_cpufreq_opp_notifier()
387 static int mtk_cpu_dvfs_info_init(struct mtk_cpu_dvfs_info *info, int cpu) in mtk_cpu_dvfs_info_init() argument
399 info->cpu_dev = cpu_dev; in mtk_cpu_dvfs_info_init()
401 info->ccifreq_bound = false; in mtk_cpu_dvfs_info_init()
402 if (info->soc_data->ccifreq_supported) { in mtk_cpu_dvfs_info_init()
403 info->cci_dev = of_get_cci(info->cpu_dev); in mtk_cpu_dvfs_info_init()
404 if (IS_ERR(info->cci_dev)) { in mtk_cpu_dvfs_info_init()
405 ret = PTR_ERR(info->cci_dev); in mtk_cpu_dvfs_info_init()
411 info->cpu_clk = clk_get(cpu_dev, "cpu"); in mtk_cpu_dvfs_info_init()
412 if (IS_ERR(info->cpu_clk)) { in mtk_cpu_dvfs_info_init()
413 ret = PTR_ERR(info->cpu_clk); in mtk_cpu_dvfs_info_init()
418 info->inter_clk = clk_get(cpu_dev, "intermediate"); in mtk_cpu_dvfs_info_init()
419 if (IS_ERR(info->inter_clk)) { in mtk_cpu_dvfs_info_init()
420 ret = PTR_ERR(info->inter_clk); in mtk_cpu_dvfs_info_init()
426 info->proc_reg = regulator_get_optional(cpu_dev, "proc"); in mtk_cpu_dvfs_info_init()
427 if (IS_ERR(info->proc_reg)) { in mtk_cpu_dvfs_info_init()
428 ret = PTR_ERR(info->proc_reg); in mtk_cpu_dvfs_info_init()
434 ret = regulator_enable(info->proc_reg); in mtk_cpu_dvfs_info_init()
441 info->sram_reg = regulator_get_optional(cpu_dev, "sram"); in mtk_cpu_dvfs_info_init()
442 if (IS_ERR(info->sram_reg)) { in mtk_cpu_dvfs_info_init()
443 ret = PTR_ERR(info->sram_reg); in mtk_cpu_dvfs_info_init()
447 info->sram_reg = NULL; in mtk_cpu_dvfs_info_init()
449 ret = regulator_enable(info->sram_reg); in mtk_cpu_dvfs_info_init()
457 ret = dev_pm_opp_of_get_sharing_cpus(cpu_dev, &info->cpus); in mtk_cpu_dvfs_info_init()
464 ret = dev_pm_opp_of_cpumask_add_table(&info->cpus); in mtk_cpu_dvfs_info_init()
470 ret = clk_prepare_enable(info->cpu_clk); in mtk_cpu_dvfs_info_init()
474 ret = clk_prepare_enable(info->inter_clk); in mtk_cpu_dvfs_info_init()
478 if (info->soc_data->ccifreq_supported) { in mtk_cpu_dvfs_info_init()
479 info->vproc_on_boot = regulator_get_voltage(info->proc_reg); in mtk_cpu_dvfs_info_init()
480 if (info->vproc_on_boot < 0) { in mtk_cpu_dvfs_info_init()
481 ret = info->vproc_on_boot; in mtk_cpu_dvfs_info_init()
482 dev_err(info->cpu_dev, in mtk_cpu_dvfs_info_init()
483 "invalid Vproc value: %d\n", info->vproc_on_boot); in mtk_cpu_dvfs_info_init()
489 rate = clk_get_rate(info->inter_clk); in mtk_cpu_dvfs_info_init()
496 info->intermediate_voltage = dev_pm_opp_get_voltage(opp); in mtk_cpu_dvfs_info_init()
499 mutex_init(&info->reg_lock); in mtk_cpu_dvfs_info_init()
500 info->current_freq = clk_get_rate(info->cpu_clk); in mtk_cpu_dvfs_info_init()
502 info->opp_cpu = cpu; in mtk_cpu_dvfs_info_init()
503 info->opp_nb.notifier_call = mtk_cpufreq_opp_notifier; in mtk_cpu_dvfs_info_init()
504 ret = dev_pm_opp_register_notifier(cpu_dev, &info->opp_nb); in mtk_cpu_dvfs_info_init()
514 info->need_voltage_tracking = (info->sram_reg != NULL); in mtk_cpu_dvfs_info_init()
521 info->vtrack_max = 3 * DIV_ROUND_UP(max(info->soc_data->sram_max_volt, in mtk_cpu_dvfs_info_init()
522 info->soc_data->proc_max_volt), in mtk_cpu_dvfs_info_init()
523 info->soc_data->min_volt_shift); in mtk_cpu_dvfs_info_init()
528 clk_disable_unprepare(info->inter_clk); in mtk_cpu_dvfs_info_init()
531 clk_disable_unprepare(info->cpu_clk); in mtk_cpu_dvfs_info_init()
534 dev_pm_opp_of_cpumask_remove_table(&info->cpus); in mtk_cpu_dvfs_info_init()
537 if (info->sram_reg) in mtk_cpu_dvfs_info_init()
538 regulator_disable(info->sram_reg); in mtk_cpu_dvfs_info_init()
541 if (info->sram_reg) in mtk_cpu_dvfs_info_init()
542 regulator_put(info->sram_reg); in mtk_cpu_dvfs_info_init()
545 regulator_disable(info->proc_reg); in mtk_cpu_dvfs_info_init()
548 regulator_put(info->proc_reg); in mtk_cpu_dvfs_info_init()
551 clk_put(info->inter_clk); in mtk_cpu_dvfs_info_init()
554 clk_put(info->cpu_clk); in mtk_cpu_dvfs_info_init()
559 static void mtk_cpu_dvfs_info_release(struct mtk_cpu_dvfs_info *info) in mtk_cpu_dvfs_info_release() argument
561 regulator_disable(info->proc_reg); in mtk_cpu_dvfs_info_release()
562 regulator_put(info->proc_reg); in mtk_cpu_dvfs_info_release()
563 if (info->sram_reg) { in mtk_cpu_dvfs_info_release()
564 regulator_disable(info->sram_reg); in mtk_cpu_dvfs_info_release()
565 regulator_put(info->sram_reg); in mtk_cpu_dvfs_info_release()
567 clk_disable_unprepare(info->cpu_clk); in mtk_cpu_dvfs_info_release()
568 clk_put(info->cpu_clk); in mtk_cpu_dvfs_info_release()
569 clk_disable_unprepare(info->inter_clk); in mtk_cpu_dvfs_info_release()
570 clk_put(info->inter_clk); in mtk_cpu_dvfs_info_release()
571 dev_pm_opp_of_cpumask_remove_table(&info->cpus); in mtk_cpu_dvfs_info_release()
572 dev_pm_opp_unregister_notifier(info->cpu_dev, &info->opp_nb); in mtk_cpu_dvfs_info_release()
577 struct mtk_cpu_dvfs_info *info; in mtk_cpufreq_init() local
581 info = mtk_cpu_dvfs_info_lookup(policy->cpu); in mtk_cpufreq_init()
582 if (!info) { in mtk_cpufreq_init()
588 ret = dev_pm_opp_init_cpufreq_table(info->cpu_dev, &freq_table); in mtk_cpufreq_init()
590 dev_err(info->cpu_dev, in mtk_cpufreq_init()
596 cpumask_copy(policy->cpus, &info->cpus); in mtk_cpufreq_init()
598 policy->driver_data = info; in mtk_cpufreq_init()
599 policy->clk = info->cpu_clk; in mtk_cpufreq_init()
606 struct mtk_cpu_dvfs_info *info = policy->driver_data; in mtk_cpufreq_exit() local
608 dev_pm_opp_free_cpufreq_table(info->cpu_dev, &policy->freq_table); in mtk_cpufreq_exit()
630 struct mtk_cpu_dvfs_info *info, *tmp; in mtk_cpufreq_probe() local
641 info = mtk_cpu_dvfs_info_lookup(cpu); in mtk_cpufreq_probe()
642 if (info) in mtk_cpufreq_probe()
645 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); in mtk_cpufreq_probe()
646 if (!info) { in mtk_cpufreq_probe()
651 info->soc_data = data; in mtk_cpufreq_probe()
652 ret = mtk_cpu_dvfs_info_init(info, cpu); in mtk_cpufreq_probe()
660 list_add(&info->list_head, &dvfs_info_list); in mtk_cpufreq_probe()
672 list_for_each_entry_safe(info, tmp, &dvfs_info_list, list_head) { in mtk_cpufreq_probe()
673 mtk_cpu_dvfs_info_release(info); in mtk_cpufreq_probe()
674 list_del(&info->list_head); in mtk_cpufreq_probe()