• Home
  • Raw
  • Download

Lines Matching refs:tegra

219 static u32 actmon_readl(struct tegra_devfreq *tegra, u32 offset)  in actmon_readl()  argument
221 return readl_relaxed(tegra->regs + offset); in actmon_readl()
224 static void actmon_writel(struct tegra_devfreq *tegra, u32 val, u32 offset) in actmon_writel() argument
226 writel_relaxed(val, tegra->regs + offset); in actmon_writel()
252 static void tegra_devfreq_update_avg_wmark(struct tegra_devfreq *tegra, in tegra_devfreq_update_avg_wmark() argument
255 u32 avg_band_freq = tegra->max_freq * ACTMON_DEFAULT_AVG_BAND / KHZ; in tegra_devfreq_update_avg_wmark()
256 u32 band = avg_band_freq * tegra->devfreq->profile->polling_ms; in tegra_devfreq_update_avg_wmark()
266 static void tegra_devfreq_update_wmark(struct tegra_devfreq *tegra, in tegra_devfreq_update_wmark() argument
269 u32 val = tegra->cur_freq * tegra->devfreq->profile->polling_ms; in tegra_devfreq_update_wmark()
278 static void actmon_isr_device(struct tegra_devfreq *tegra, in actmon_isr_device() argument
284 tegra_devfreq_update_avg_wmark(tegra, dev); in actmon_isr_device()
299 if (dev->boost_freq >= tegra->max_freq) { in actmon_isr_device()
301 dev->boost_freq = tegra->max_freq; in actmon_isr_device()
324 static unsigned long actmon_cpu_to_emc_rate(struct tegra_devfreq *tegra, in actmon_cpu_to_emc_rate() argument
332 if (ratio->emc_freq >= tegra->max_freq) in actmon_cpu_to_emc_rate()
333 return tegra->max_freq; in actmon_cpu_to_emc_rate()
342 static unsigned long actmon_device_target_freq(struct tegra_devfreq *tegra, in actmon_device_target_freq() argument
348 target_freq = dev->avg_count / tegra->devfreq->profile->polling_ms; in actmon_device_target_freq()
355 static void actmon_update_target(struct tegra_devfreq *tegra, in actmon_update_target() argument
361 dev->target_freq = actmon_device_target_freq(tegra, dev); in actmon_update_target()
366 static_cpu_emc_freq = actmon_cpu_to_emc_rate(tegra, cpu_freq); in actmon_update_target()
377 struct tegra_devfreq *tegra = data; in actmon_thread_isr() local
382 mutex_lock(&tegra->devfreq->lock); in actmon_thread_isr()
384 val = actmon_readl(tegra, ACTMON_GLB_STATUS); in actmon_thread_isr()
385 for (i = 0; i < ARRAY_SIZE(tegra->devices); i++) { in actmon_thread_isr()
386 if (val & tegra->devices[i].config->irq_mask) { in actmon_thread_isr()
387 actmon_isr_device(tegra, tegra->devices + i); in actmon_thread_isr()
393 update_devfreq(tegra->devfreq); in actmon_thread_isr()
395 mutex_unlock(&tegra->devfreq->lock); in actmon_thread_isr()
404 struct tegra_devfreq *tegra; in tegra_actmon_clk_notify_cb() local
411 tegra = container_of(nb, struct tegra_devfreq, clk_rate_change_nb); in tegra_actmon_clk_notify_cb()
413 tegra->cur_freq = data->new_rate / KHZ; in tegra_actmon_clk_notify_cb()
415 for (i = 0; i < ARRAY_SIZE(tegra->devices); i++) { in tegra_actmon_clk_notify_cb()
416 dev = &tegra->devices[i]; in tegra_actmon_clk_notify_cb()
418 tegra_devfreq_update_wmark(tegra, dev); in tegra_actmon_clk_notify_cb()
426 struct tegra_devfreq *tegra = container_of(work, struct tegra_devfreq, in tegra_actmon_delayed_update() local
429 mutex_lock(&tegra->devfreq->lock); in tegra_actmon_delayed_update()
430 update_devfreq(tegra->devfreq); in tegra_actmon_delayed_update()
431 mutex_unlock(&tegra->devfreq->lock); in tegra_actmon_delayed_update()
435 tegra_actmon_cpufreq_contribution(struct tegra_devfreq *tegra, in tegra_actmon_cpufreq_contribution() argument
438 struct tegra_devfreq_device *actmon_dev = &tegra->devices[MCCPU]; in tegra_actmon_cpufreq_contribution()
441 dev_freq = actmon_device_target_freq(tegra, actmon_dev); in tegra_actmon_cpufreq_contribution()
447 static_cpu_emc_freq = actmon_cpu_to_emc_rate(tegra, cpu_freq); in tegra_actmon_cpufreq_contribution()
459 struct tegra_devfreq *tegra; in tegra_actmon_cpu_notify_cb() local
465 tegra = container_of(nb, struct tegra_devfreq, cpu_rate_change_nb); in tegra_actmon_cpu_notify_cb()
471 if (mutex_trylock(&tegra->devfreq->lock)) { in tegra_actmon_cpu_notify_cb()
472 old = tegra_actmon_cpufreq_contribution(tegra, freqs->old); in tegra_actmon_cpu_notify_cb()
473 new = tegra_actmon_cpufreq_contribution(tegra, freqs->new); in tegra_actmon_cpu_notify_cb()
474 mutex_unlock(&tegra->devfreq->lock); in tegra_actmon_cpu_notify_cb()
493 schedule_delayed_work(&tegra->cpufreq_update_work, delay); in tegra_actmon_cpu_notify_cb()
498 static void tegra_actmon_configure_device(struct tegra_devfreq *tegra, in tegra_actmon_configure_device() argument
506 dev->target_freq = tegra->cur_freq; in tegra_actmon_configure_device()
508 dev->avg_count = tegra->cur_freq * tegra->devfreq->profile->polling_ms; in tegra_actmon_configure_device()
511 tegra_devfreq_update_avg_wmark(tegra, dev); in tegra_actmon_configure_device()
512 tegra_devfreq_update_wmark(tegra, dev); in tegra_actmon_configure_device()
514 device_writel(dev, tegra->soc->count_weight, ACTMON_DEV_COUNT_WEIGHT); in tegra_actmon_configure_device()
532 static void tegra_actmon_stop_devices(struct tegra_devfreq *tegra) in tegra_actmon_stop_devices() argument
534 struct tegra_devfreq_device *dev = tegra->devices; in tegra_actmon_stop_devices()
537 for (i = 0; i < ARRAY_SIZE(tegra->devices); i++, dev++) { in tegra_actmon_stop_devices()
544 static int tegra_actmon_resume(struct tegra_devfreq *tegra) in tegra_actmon_resume() argument
549 if (!tegra->devfreq->profile->polling_ms || !tegra->started) in tegra_actmon_resume()
552 actmon_writel(tegra, tegra->devfreq->profile->polling_ms - 1, in tegra_actmon_resume()
560 err = clk_notifier_register(tegra->emc_clock, in tegra_actmon_resume()
561 &tegra->clk_rate_change_nb); in tegra_actmon_resume()
563 dev_err(tegra->devfreq->dev.parent, in tegra_actmon_resume()
568 tegra->cur_freq = clk_get_rate(tegra->emc_clock) / KHZ; in tegra_actmon_resume()
570 for (i = 0; i < ARRAY_SIZE(tegra->devices); i++) in tegra_actmon_resume()
571 tegra_actmon_configure_device(tegra, &tegra->devices[i]); in tegra_actmon_resume()
580 err = cpufreq_register_notifier(&tegra->cpu_rate_change_nb, in tegra_actmon_resume()
583 dev_err(tegra->devfreq->dev.parent, in tegra_actmon_resume()
588 enable_irq(tegra->irq); in tegra_actmon_resume()
593 tegra_actmon_stop_devices(tegra); in tegra_actmon_resume()
595 clk_notifier_unregister(tegra->emc_clock, &tegra->clk_rate_change_nb); in tegra_actmon_resume()
600 static int tegra_actmon_start(struct tegra_devfreq *tegra) in tegra_actmon_start() argument
604 if (!tegra->started) { in tegra_actmon_start()
605 tegra->started = true; in tegra_actmon_start()
607 ret = tegra_actmon_resume(tegra); in tegra_actmon_start()
609 tegra->started = false; in tegra_actmon_start()
615 static void tegra_actmon_pause(struct tegra_devfreq *tegra) in tegra_actmon_pause() argument
617 if (!tegra->devfreq->profile->polling_ms || !tegra->started) in tegra_actmon_pause()
620 disable_irq(tegra->irq); in tegra_actmon_pause()
622 cpufreq_unregister_notifier(&tegra->cpu_rate_change_nb, in tegra_actmon_pause()
625 cancel_delayed_work_sync(&tegra->cpufreq_update_work); in tegra_actmon_pause()
627 tegra_actmon_stop_devices(tegra); in tegra_actmon_pause()
629 clk_notifier_unregister(tegra->emc_clock, &tegra->clk_rate_change_nb); in tegra_actmon_pause()
632 static void tegra_actmon_stop(struct tegra_devfreq *tegra) in tegra_actmon_stop() argument
634 tegra_actmon_pause(tegra); in tegra_actmon_stop()
635 tegra->started = false; in tegra_actmon_stop()
659 struct tegra_devfreq *tegra = dev_get_drvdata(dev); in tegra_devfreq_get_dev_status() local
663 cur_freq = READ_ONCE(tegra->cur_freq); in tegra_devfreq_get_dev_status()
666 stat->private_data = tegra; in tegra_devfreq_get_dev_status()
671 actmon_dev = &tegra->devices[MCALL]; in tegra_devfreq_get_dev_status()
680 stat->total_time = tegra->devfreq->profile->polling_ms * cur_freq; in tegra_devfreq_get_dev_status()
698 struct tegra_devfreq *tegra; in tegra_governor_get_target() local
710 tegra = stat->private_data; in tegra_governor_get_target()
712 for (i = 0; i < ARRAY_SIZE(tegra->devices); i++) { in tegra_governor_get_target()
713 dev = &tegra->devices[i]; in tegra_governor_get_target()
715 actmon_update_target(tegra, dev); in tegra_governor_get_target()
733 struct tegra_devfreq *tegra = dev_get_drvdata(devfreq->dev.parent); in tegra_governor_event_handler() local
741 tegra->devfreq = devfreq; in tegra_governor_event_handler()
746 ret = tegra_actmon_start(tegra); in tegra_governor_event_handler()
750 tegra_actmon_stop(tegra); in tegra_governor_event_handler()
764 tegra_actmon_pause(tegra); in tegra_governor_event_handler()
766 ret = tegra_actmon_resume(tegra); in tegra_governor_event_handler()
770 tegra_actmon_stop(tegra); in tegra_governor_event_handler()
776 ret = tegra_actmon_start(tegra); in tegra_governor_event_handler()
796 struct tegra_devfreq *tegra; in tegra_devfreq_probe() local
802 tegra = devm_kzalloc(&pdev->dev, sizeof(*tegra), GFP_KERNEL); in tegra_devfreq_probe()
803 if (!tegra) in tegra_devfreq_probe()
806 tegra->soc = of_device_get_match_data(&pdev->dev); in tegra_devfreq_probe()
808 tegra->regs = devm_platform_ioremap_resource(pdev, 0); in tegra_devfreq_probe()
809 if (IS_ERR(tegra->regs)) in tegra_devfreq_probe()
810 return PTR_ERR(tegra->regs); in tegra_devfreq_probe()
812 tegra->reset = devm_reset_control_get(&pdev->dev, "actmon"); in tegra_devfreq_probe()
813 if (IS_ERR(tegra->reset)) { in tegra_devfreq_probe()
815 return PTR_ERR(tegra->reset); in tegra_devfreq_probe()
818 tegra->clock = devm_clk_get(&pdev->dev, "actmon"); in tegra_devfreq_probe()
819 if (IS_ERR(tegra->clock)) { in tegra_devfreq_probe()
821 return PTR_ERR(tegra->clock); in tegra_devfreq_probe()
824 tegra->emc_clock = devm_clk_get(&pdev->dev, "emc"); in tegra_devfreq_probe()
825 if (IS_ERR(tegra->emc_clock)) in tegra_devfreq_probe()
826 return dev_err_probe(&pdev->dev, PTR_ERR(tegra->emc_clock), in tegra_devfreq_probe()
833 tegra->irq = err; in tegra_devfreq_probe()
835 irq_set_status_flags(tegra->irq, IRQ_NOAUTOEN); in tegra_devfreq_probe()
837 err = devm_request_threaded_irq(&pdev->dev, tegra->irq, NULL, in tegra_devfreq_probe()
839 "tegra-devfreq", tegra); in tegra_devfreq_probe()
845 tegra->opp_table = dev_pm_opp_set_supported_hw(&pdev->dev, in tegra_devfreq_probe()
847 err = PTR_ERR_OR_ZERO(tegra->opp_table); in tegra_devfreq_probe()
859 err = clk_prepare_enable(tegra->clock); in tegra_devfreq_probe()
866 err = reset_control_reset(tegra->reset); in tegra_devfreq_probe()
872 rate = clk_round_rate(tegra->emc_clock, ULONG_MAX); in tegra_devfreq_probe()
879 tegra->max_freq = rate / KHZ; in tegra_devfreq_probe()
881 for (i = 0; i < ARRAY_SIZE(tegra->devices); i++) { in tegra_devfreq_probe()
882 dev = tegra->devices + i; in tegra_devfreq_probe()
883 dev->config = tegra->soc->configs + i; in tegra_devfreq_probe()
884 dev->regs = tegra->regs + dev->config->offset; in tegra_devfreq_probe()
887 platform_set_drvdata(pdev, tegra); in tegra_devfreq_probe()
889 tegra->clk_rate_change_nb.notifier_call = tegra_actmon_clk_notify_cb; in tegra_devfreq_probe()
890 tegra->cpu_rate_change_nb.notifier_call = tegra_actmon_cpu_notify_cb; in tegra_devfreq_probe()
892 INIT_DELAYED_WORK(&tegra->cpufreq_update_work, in tegra_devfreq_probe()
901 tegra_devfreq_profile.initial_freq = clk_get_rate(tegra->emc_clock); in tegra_devfreq_probe()
918 reset_control_reset(tegra->reset); in tegra_devfreq_probe()
920 clk_disable_unprepare(tegra->clock); in tegra_devfreq_probe()
924 dev_pm_opp_put_supported_hw(tegra->opp_table); in tegra_devfreq_probe()
931 struct tegra_devfreq *tegra = platform_get_drvdata(pdev); in tegra_devfreq_remove() local
933 devfreq_remove_device(tegra->devfreq); in tegra_devfreq_remove()
936 reset_control_reset(tegra->reset); in tegra_devfreq_remove()
937 clk_disable_unprepare(tegra->clock); in tegra_devfreq_remove()
940 dev_pm_opp_put_supported_hw(tegra->opp_table); in tegra_devfreq_remove()