• Home
  • Raw
  • Download

Lines Matching refs:tegra

193 static u32 actmon_readl(struct tegra_devfreq *tegra, u32 offset)  in actmon_readl()  argument
195 return readl_relaxed(tegra->regs + offset); in actmon_readl()
198 static void actmon_writel(struct tegra_devfreq *tegra, u32 val, u32 offset) in actmon_writel() argument
200 writel_relaxed(val, tegra->regs + offset); in actmon_writel()
226 static void tegra_devfreq_update_avg_wmark(struct tegra_devfreq *tegra, in tegra_devfreq_update_avg_wmark() argument
229 u32 avg_band_freq = tegra->max_freq * ACTMON_DEFAULT_AVG_BAND / KHZ; in tegra_devfreq_update_avg_wmark()
230 u32 band = avg_band_freq * tegra->devfreq->profile->polling_ms; in tegra_devfreq_update_avg_wmark()
240 static void tegra_devfreq_update_wmark(struct tegra_devfreq *tegra, in tegra_devfreq_update_wmark() argument
243 u32 val = tegra->cur_freq * tegra->devfreq->profile->polling_ms; in tegra_devfreq_update_wmark()
252 static void actmon_isr_device(struct tegra_devfreq *tegra, in actmon_isr_device() argument
258 tegra_devfreq_update_avg_wmark(tegra, dev); in actmon_isr_device()
273 if (dev->boost_freq >= tegra->max_freq) { in actmon_isr_device()
275 dev->boost_freq = tegra->max_freq; in actmon_isr_device()
298 static unsigned long actmon_cpu_to_emc_rate(struct tegra_devfreq *tegra, in actmon_cpu_to_emc_rate() argument
306 if (ratio->emc_freq >= tegra->max_freq) in actmon_cpu_to_emc_rate()
307 return tegra->max_freq; in actmon_cpu_to_emc_rate()
316 static unsigned long actmon_device_target_freq(struct tegra_devfreq *tegra, in actmon_device_target_freq() argument
322 target_freq = dev->avg_count / tegra->devfreq->profile->polling_ms; in actmon_device_target_freq()
329 static void actmon_update_target(struct tegra_devfreq *tegra, in actmon_update_target() argument
335 dev->target_freq = actmon_device_target_freq(tegra, dev); in actmon_update_target()
340 static_cpu_emc_freq = actmon_cpu_to_emc_rate(tegra, cpu_freq); in actmon_update_target()
351 struct tegra_devfreq *tegra = data; in actmon_thread_isr() local
356 mutex_lock(&tegra->devfreq->lock); in actmon_thread_isr()
358 val = actmon_readl(tegra, ACTMON_GLB_STATUS); in actmon_thread_isr()
359 for (i = 0; i < ARRAY_SIZE(tegra->devices); i++) { in actmon_thread_isr()
360 if (val & tegra->devices[i].config->irq_mask) { in actmon_thread_isr()
361 actmon_isr_device(tegra, tegra->devices + i); in actmon_thread_isr()
367 update_devfreq(tegra->devfreq); in actmon_thread_isr()
369 mutex_unlock(&tegra->devfreq->lock); in actmon_thread_isr()
378 struct tegra_devfreq *tegra; in tegra_actmon_clk_notify_cb() local
385 tegra = container_of(nb, struct tegra_devfreq, clk_rate_change_nb); in tegra_actmon_clk_notify_cb()
387 tegra->cur_freq = data->new_rate / KHZ; in tegra_actmon_clk_notify_cb()
389 for (i = 0; i < ARRAY_SIZE(tegra->devices); i++) { in tegra_actmon_clk_notify_cb()
390 dev = &tegra->devices[i]; in tegra_actmon_clk_notify_cb()
392 tegra_devfreq_update_wmark(tegra, dev); in tegra_actmon_clk_notify_cb()
400 struct tegra_devfreq *tegra = container_of(work, struct tegra_devfreq, in tegra_actmon_delayed_update() local
403 mutex_lock(&tegra->devfreq->lock); in tegra_actmon_delayed_update()
404 update_devfreq(tegra->devfreq); in tegra_actmon_delayed_update()
405 mutex_unlock(&tegra->devfreq->lock); in tegra_actmon_delayed_update()
409 tegra_actmon_cpufreq_contribution(struct tegra_devfreq *tegra, in tegra_actmon_cpufreq_contribution() argument
412 struct tegra_devfreq_device *actmon_dev = &tegra->devices[MCCPU]; in tegra_actmon_cpufreq_contribution()
415 dev_freq = actmon_device_target_freq(tegra, actmon_dev); in tegra_actmon_cpufreq_contribution()
421 static_cpu_emc_freq = actmon_cpu_to_emc_rate(tegra, cpu_freq); in tegra_actmon_cpufreq_contribution()
433 struct tegra_devfreq *tegra; in tegra_actmon_cpu_notify_cb() local
439 tegra = container_of(nb, struct tegra_devfreq, cpu_rate_change_nb); in tegra_actmon_cpu_notify_cb()
445 if (mutex_trylock(&tegra->devfreq->lock)) { in tegra_actmon_cpu_notify_cb()
446 old = tegra_actmon_cpufreq_contribution(tegra, freqs->old); in tegra_actmon_cpu_notify_cb()
447 new = tegra_actmon_cpufreq_contribution(tegra, freqs->new); in tegra_actmon_cpu_notify_cb()
448 mutex_unlock(&tegra->devfreq->lock); in tegra_actmon_cpu_notify_cb()
467 schedule_delayed_work(&tegra->cpufreq_update_work, delay); in tegra_actmon_cpu_notify_cb()
472 static void tegra_actmon_configure_device(struct tegra_devfreq *tegra, in tegra_actmon_configure_device() argument
480 dev->target_freq = tegra->cur_freq; in tegra_actmon_configure_device()
482 dev->avg_count = tegra->cur_freq * tegra->devfreq->profile->polling_ms; in tegra_actmon_configure_device()
485 tegra_devfreq_update_avg_wmark(tegra, dev); in tegra_actmon_configure_device()
486 tegra_devfreq_update_wmark(tegra, dev); in tegra_actmon_configure_device()
506 static void tegra_actmon_stop_devices(struct tegra_devfreq *tegra) in tegra_actmon_stop_devices() argument
508 struct tegra_devfreq_device *dev = tegra->devices; in tegra_actmon_stop_devices()
511 for (i = 0; i < ARRAY_SIZE(tegra->devices); i++, dev++) { in tegra_actmon_stop_devices()
518 static int tegra_actmon_resume(struct tegra_devfreq *tegra) in tegra_actmon_resume() argument
523 if (!tegra->devfreq->profile->polling_ms || !tegra->started) in tegra_actmon_resume()
526 actmon_writel(tegra, tegra->devfreq->profile->polling_ms - 1, in tegra_actmon_resume()
534 err = clk_notifier_register(tegra->emc_clock, in tegra_actmon_resume()
535 &tegra->clk_rate_change_nb); in tegra_actmon_resume()
537 dev_err(tegra->devfreq->dev.parent, in tegra_actmon_resume()
542 tegra->cur_freq = clk_get_rate(tegra->emc_clock) / KHZ; in tegra_actmon_resume()
544 for (i = 0; i < ARRAY_SIZE(tegra->devices); i++) in tegra_actmon_resume()
545 tegra_actmon_configure_device(tegra, &tegra->devices[i]); in tegra_actmon_resume()
554 err = cpufreq_register_notifier(&tegra->cpu_rate_change_nb, in tegra_actmon_resume()
557 dev_err(tegra->devfreq->dev.parent, in tegra_actmon_resume()
562 enable_irq(tegra->irq); in tegra_actmon_resume()
567 tegra_actmon_stop_devices(tegra); in tegra_actmon_resume()
569 clk_notifier_unregister(tegra->emc_clock, &tegra->clk_rate_change_nb); in tegra_actmon_resume()
574 static int tegra_actmon_start(struct tegra_devfreq *tegra) in tegra_actmon_start() argument
578 if (!tegra->started) { in tegra_actmon_start()
579 tegra->started = true; in tegra_actmon_start()
581 ret = tegra_actmon_resume(tegra); in tegra_actmon_start()
583 tegra->started = false; in tegra_actmon_start()
589 static void tegra_actmon_pause(struct tegra_devfreq *tegra) in tegra_actmon_pause() argument
591 if (!tegra->devfreq->profile->polling_ms || !tegra->started) in tegra_actmon_pause()
594 disable_irq(tegra->irq); in tegra_actmon_pause()
596 cpufreq_unregister_notifier(&tegra->cpu_rate_change_nb, in tegra_actmon_pause()
599 cancel_delayed_work_sync(&tegra->cpufreq_update_work); in tegra_actmon_pause()
601 tegra_actmon_stop_devices(tegra); in tegra_actmon_pause()
603 clk_notifier_unregister(tegra->emc_clock, &tegra->clk_rate_change_nb); in tegra_actmon_pause()
606 static void tegra_actmon_stop(struct tegra_devfreq *tegra) in tegra_actmon_stop() argument
608 tegra_actmon_pause(tegra); in tegra_actmon_stop()
609 tegra->started = false; in tegra_actmon_stop()
615 struct tegra_devfreq *tegra = dev_get_drvdata(dev); in tegra_devfreq_target() local
616 struct devfreq *devfreq = tegra->devfreq; in tegra_devfreq_target()
629 err = clk_set_min_rate(tegra->emc_clock, rate * KHZ); in tegra_devfreq_target()
633 err = clk_set_rate(tegra->emc_clock, 0); in tegra_devfreq_target()
640 clk_set_min_rate(tegra->emc_clock, devfreq->previous_freq); in tegra_devfreq_target()
648 struct tegra_devfreq *tegra = dev_get_drvdata(dev); in tegra_devfreq_get_dev_status() local
652 cur_freq = READ_ONCE(tegra->cur_freq); in tegra_devfreq_get_dev_status()
655 stat->private_data = tegra; in tegra_devfreq_get_dev_status()
660 actmon_dev = &tegra->devices[MCALL]; in tegra_devfreq_get_dev_status()
669 stat->total_time = tegra->devfreq->profile->polling_ms * cur_freq; in tegra_devfreq_get_dev_status()
686 struct tegra_devfreq *tegra; in tegra_governor_get_target() local
698 tegra = stat->private_data; in tegra_governor_get_target()
700 for (i = 0; i < ARRAY_SIZE(tegra->devices); i++) { in tegra_governor_get_target()
701 dev = &tegra->devices[i]; in tegra_governor_get_target()
703 actmon_update_target(tegra, dev); in tegra_governor_get_target()
716 struct tegra_devfreq *tegra = dev_get_drvdata(devfreq->dev.parent); in tegra_governor_event_handler() local
724 tegra->devfreq = devfreq; in tegra_governor_event_handler()
729 ret = tegra_actmon_start(tegra); in tegra_governor_event_handler()
733 tegra_actmon_stop(tegra); in tegra_governor_event_handler()
747 tegra_actmon_pause(tegra); in tegra_governor_event_handler()
749 ret = tegra_actmon_resume(tegra); in tegra_governor_event_handler()
753 tegra_actmon_stop(tegra); in tegra_governor_event_handler()
759 ret = tegra_actmon_start(tegra); in tegra_governor_event_handler()
777 struct tegra_devfreq *tegra; in tegra_devfreq_probe() local
783 tegra = devm_kzalloc(&pdev->dev, sizeof(*tegra), GFP_KERNEL); in tegra_devfreq_probe()
784 if (!tegra) in tegra_devfreq_probe()
787 tegra->regs = devm_platform_ioremap_resource(pdev, 0); in tegra_devfreq_probe()
788 if (IS_ERR(tegra->regs)) in tegra_devfreq_probe()
789 return PTR_ERR(tegra->regs); in tegra_devfreq_probe()
791 tegra->reset = devm_reset_control_get(&pdev->dev, "actmon"); in tegra_devfreq_probe()
792 if (IS_ERR(tegra->reset)) { in tegra_devfreq_probe()
794 return PTR_ERR(tegra->reset); in tegra_devfreq_probe()
797 tegra->clock = devm_clk_get(&pdev->dev, "actmon"); in tegra_devfreq_probe()
798 if (IS_ERR(tegra->clock)) { in tegra_devfreq_probe()
800 return PTR_ERR(tegra->clock); in tegra_devfreq_probe()
803 tegra->emc_clock = devm_clk_get(&pdev->dev, "emc"); in tegra_devfreq_probe()
804 if (IS_ERR(tegra->emc_clock)) { in tegra_devfreq_probe()
806 return PTR_ERR(tegra->emc_clock); in tegra_devfreq_probe()
813 tegra->irq = err; in tegra_devfreq_probe()
815 irq_set_status_flags(tegra->irq, IRQ_NOAUTOEN); in tegra_devfreq_probe()
817 err = devm_request_threaded_irq(&pdev->dev, tegra->irq, NULL, in tegra_devfreq_probe()
819 "tegra-devfreq", tegra); in tegra_devfreq_probe()
825 err = clk_prepare_enable(tegra->clock); in tegra_devfreq_probe()
832 err = reset_control_reset(tegra->reset); in tegra_devfreq_probe()
838 rate = clk_round_rate(tegra->emc_clock, ULONG_MAX); in tegra_devfreq_probe()
845 tegra->max_freq = rate / KHZ; in tegra_devfreq_probe()
848 dev = tegra->devices + i; in tegra_devfreq_probe()
850 dev->regs = tegra->regs + dev->config->offset; in tegra_devfreq_probe()
853 for (rate = 0; rate <= tegra->max_freq * KHZ; rate++) { in tegra_devfreq_probe()
854 rate = clk_round_rate(tegra->emc_clock, rate); in tegra_devfreq_probe()
870 platform_set_drvdata(pdev, tegra); in tegra_devfreq_probe()
872 tegra->clk_rate_change_nb.notifier_call = tegra_actmon_clk_notify_cb; in tegra_devfreq_probe()
873 tegra->cpu_rate_change_nb.notifier_call = tegra_actmon_cpu_notify_cb; in tegra_devfreq_probe()
875 INIT_DELAYED_WORK(&tegra->cpufreq_update_work, in tegra_devfreq_probe()
884 tegra_devfreq_profile.initial_freq = clk_get_rate(tegra->emc_clock); in tegra_devfreq_probe()
902 reset_control_reset(tegra->reset); in tegra_devfreq_probe()
904 clk_disable_unprepare(tegra->clock); in tegra_devfreq_probe()
911 struct tegra_devfreq *tegra = platform_get_drvdata(pdev); in tegra_devfreq_remove() local
913 devfreq_remove_device(tegra->devfreq); in tegra_devfreq_remove()
918 reset_control_reset(tegra->reset); in tegra_devfreq_remove()
919 clk_disable_unprepare(tegra->clock); in tegra_devfreq_remove()