Lines Matching refs:tegra

192 static u32 actmon_readl(struct tegra_devfreq *tegra, u32 offset)  in actmon_readl()  argument
194 return readl(tegra->regs + offset); in actmon_readl()
197 static void actmon_writel(struct tegra_devfreq *tegra, u32 val, u32 offset) in actmon_writel() argument
199 writel(val, tegra->regs + offset); in actmon_writel()
218 static void tegra_devfreq_update_avg_wmark(struct tegra_devfreq *tegra, in tegra_devfreq_update_avg_wmark() argument
222 u32 avg_band_freq = tegra->max_freq * ACTMON_DEFAULT_AVG_BAND / KHZ; in tegra_devfreq_update_avg_wmark()
231 static void tegra_devfreq_update_wmark(struct tegra_devfreq *tegra, in tegra_devfreq_update_wmark() argument
234 u32 val = tegra->cur_freq * ACTMON_SAMPLING_PERIOD; in tegra_devfreq_update_wmark()
243 static void actmon_write_barrier(struct tegra_devfreq *tegra) in actmon_write_barrier() argument
247 actmon_readl(tegra, ACTMON_GLB_STATUS); in actmon_write_barrier()
250 static void actmon_isr_device(struct tegra_devfreq *tegra, in actmon_isr_device() argument
259 tegra_devfreq_update_avg_wmark(tegra, dev); in actmon_isr_device()
274 if (dev->boost_freq >= tegra->max_freq) in actmon_isr_device()
275 dev->boost_freq = tegra->max_freq; in actmon_isr_device()
305 actmon_write_barrier(tegra); in actmon_isr_device()
312 struct tegra_devfreq *tegra = data; in actmon_isr() local
317 val = actmon_readl(tegra, ACTMON_GLB_STATUS); in actmon_isr()
318 for (i = 0; i < ARRAY_SIZE(tegra->devices); i++) { in actmon_isr()
319 if (val & tegra->devices[i].config->irq_mask) { in actmon_isr()
320 actmon_isr_device(tegra, tegra->devices + i); in actmon_isr()
328 static unsigned long actmon_cpu_to_emc_rate(struct tegra_devfreq *tegra, in actmon_cpu_to_emc_rate() argument
336 if (ratio->emc_freq >= tegra->max_freq) in actmon_cpu_to_emc_rate()
337 return tegra->max_freq; in actmon_cpu_to_emc_rate()
346 static void actmon_update_target(struct tegra_devfreq *tegra, in actmon_update_target() argument
356 static_cpu_emc_freq = actmon_cpu_to_emc_rate(tegra, cpu_freq); in actmon_update_target()
374 struct tegra_devfreq *tegra = data; in actmon_thread_isr() local
376 mutex_lock(&tegra->devfreq->lock); in actmon_thread_isr()
377 update_devfreq(tegra->devfreq); in actmon_thread_isr()
378 mutex_unlock(&tegra->devfreq->lock); in actmon_thread_isr()
387 struct tegra_devfreq *tegra; in tegra_actmon_rate_notify_cb() local
395 tegra = container_of(nb, struct tegra_devfreq, rate_change_nb); in tegra_actmon_rate_notify_cb()
397 tegra->cur_freq = data->new_rate / KHZ; in tegra_actmon_rate_notify_cb()
399 for (i = 0; i < ARRAY_SIZE(tegra->devices); i++) { in tegra_actmon_rate_notify_cb()
400 dev = &tegra->devices[i]; in tegra_actmon_rate_notify_cb()
403 tegra_devfreq_update_wmark(tegra, dev); in tegra_actmon_rate_notify_cb()
407 actmon_write_barrier(tegra); in tegra_actmon_rate_notify_cb()
412 static void tegra_actmon_enable_interrupts(struct tegra_devfreq *tegra) in tegra_actmon_enable_interrupts() argument
418 for (i = 0; i < ARRAY_SIZE(tegra->devices); i++) { in tegra_actmon_enable_interrupts()
419 dev = &tegra->devices[i]; in tegra_actmon_enable_interrupts()
430 actmon_write_barrier(tegra); in tegra_actmon_enable_interrupts()
433 static void tegra_actmon_disable_interrupts(struct tegra_devfreq *tegra) in tegra_actmon_disable_interrupts() argument
439 for (i = 0; i < ARRAY_SIZE(tegra->devices); i++) { in tegra_actmon_disable_interrupts()
440 dev = &tegra->devices[i]; in tegra_actmon_disable_interrupts()
451 actmon_write_barrier(tegra); in tegra_actmon_disable_interrupts()
454 static void tegra_actmon_configure_device(struct tegra_devfreq *tegra, in tegra_actmon_configure_device() argument
459 dev->target_freq = tegra->cur_freq; in tegra_actmon_configure_device()
461 dev->avg_count = tegra->cur_freq * ACTMON_SAMPLING_PERIOD; in tegra_actmon_configure_device()
464 tegra_devfreq_update_avg_wmark(tegra, dev); in tegra_actmon_configure_device()
465 tegra_devfreq_update_wmark(tegra, dev); in tegra_actmon_configure_device()
481 actmon_write_barrier(tegra); in tegra_actmon_configure_device()
487 struct tegra_devfreq *tegra = dev_get_drvdata(dev); in tegra_devfreq_target() local
499 clk_set_min_rate(tegra->emc_clock, rate); in tegra_devfreq_target()
500 clk_set_rate(tegra->emc_clock, 0); in tegra_devfreq_target()
510 struct tegra_devfreq *tegra = dev_get_drvdata(dev); in tegra_devfreq_get_dev_status() local
513 stat->current_frequency = tegra->cur_freq; in tegra_devfreq_get_dev_status()
516 stat->private_data = tegra; in tegra_devfreq_get_dev_status()
520 actmon_dev = &tegra->devices[MCALL]; in tegra_devfreq_get_dev_status()
529 stat->total_time = ACTMON_SAMPLING_PERIOD * tegra->cur_freq; in tegra_devfreq_get_dev_status()
546 struct tegra_devfreq *tegra; in tegra_governor_get_target() local
558 tegra = stat->private_data; in tegra_governor_get_target()
560 for (i = 0; i < ARRAY_SIZE(tegra->devices); i++) { in tegra_governor_get_target()
561 dev = &tegra->devices[i]; in tegra_governor_get_target()
563 actmon_update_target(tegra, dev); in tegra_governor_get_target()
576 struct tegra_devfreq *tegra; in tegra_governor_event_handler() local
579 tegra = dev_get_drvdata(devfreq->dev.parent); in tegra_governor_event_handler()
584 tegra_actmon_enable_interrupts(tegra); in tegra_governor_event_handler()
588 tegra_actmon_disable_interrupts(tegra); in tegra_governor_event_handler()
593 tegra_actmon_disable_interrupts(tegra); in tegra_governor_event_handler()
599 tegra_actmon_enable_interrupts(tegra); in tegra_governor_event_handler()
614 struct tegra_devfreq *tegra; in tegra_devfreq_probe() local
622 tegra = devm_kzalloc(&pdev->dev, sizeof(*tegra), GFP_KERNEL); in tegra_devfreq_probe()
623 if (!tegra) in tegra_devfreq_probe()
628 tegra->regs = devm_ioremap_resource(&pdev->dev, res); in tegra_devfreq_probe()
629 if (IS_ERR(tegra->regs)) in tegra_devfreq_probe()
630 return PTR_ERR(tegra->regs); in tegra_devfreq_probe()
632 tegra->reset = devm_reset_control_get(&pdev->dev, "actmon"); in tegra_devfreq_probe()
633 if (IS_ERR(tegra->reset)) { in tegra_devfreq_probe()
635 return PTR_ERR(tegra->reset); in tegra_devfreq_probe()
638 tegra->clock = devm_clk_get(&pdev->dev, "actmon"); in tegra_devfreq_probe()
639 if (IS_ERR(tegra->clock)) { in tegra_devfreq_probe()
641 return PTR_ERR(tegra->clock); in tegra_devfreq_probe()
644 tegra->emc_clock = devm_clk_get(&pdev->dev, "emc"); in tegra_devfreq_probe()
645 if (IS_ERR(tegra->emc_clock)) { in tegra_devfreq_probe()
647 return PTR_ERR(tegra->emc_clock); in tegra_devfreq_probe()
650 clk_set_rate(tegra->emc_clock, ULONG_MAX); in tegra_devfreq_probe()
652 tegra->rate_change_nb.notifier_call = tegra_actmon_rate_notify_cb; in tegra_devfreq_probe()
653 err = clk_notifier_register(tegra->emc_clock, &tegra->rate_change_nb); in tegra_devfreq_probe()
660 reset_control_assert(tegra->reset); in tegra_devfreq_probe()
662 err = clk_prepare_enable(tegra->clock); in tegra_devfreq_probe()
669 reset_control_deassert(tegra->reset); in tegra_devfreq_probe()
671 tegra->max_freq = clk_round_rate(tegra->emc_clock, ULONG_MAX) / KHZ; in tegra_devfreq_probe()
672 tegra->cur_freq = clk_get_rate(tegra->emc_clock) / KHZ; in tegra_devfreq_probe()
674 actmon_writel(tegra, ACTMON_SAMPLING_PERIOD - 1, in tegra_devfreq_probe()
678 dev = tegra->devices + i; in tegra_devfreq_probe()
680 dev->regs = tegra->regs + dev->config->offset; in tegra_devfreq_probe()
683 tegra_actmon_configure_device(tegra, dev); in tegra_devfreq_probe()
686 for (rate = 0; rate <= tegra->max_freq * KHZ; rate++) { in tegra_devfreq_probe()
687 rate = clk_round_rate(tegra->emc_clock, rate); in tegra_devfreq_probe()
697 platform_set_drvdata(pdev, tegra); in tegra_devfreq_probe()
701 "tegra-devfreq", tegra); in tegra_devfreq_probe()
707 tegra_devfreq_profile.initial_freq = clk_get_rate(tegra->emc_clock); in tegra_devfreq_probe()
708 tegra->devfreq = devm_devfreq_add_device(&pdev->dev, in tegra_devfreq_probe()
718 struct tegra_devfreq *tegra = platform_get_drvdata(pdev); in tegra_devfreq_remove() local
724 val = device_readl(&tegra->devices[i], ACTMON_DEV_CTRL); in tegra_devfreq_remove()
726 device_writel(&tegra->devices[i], val, ACTMON_DEV_CTRL); in tegra_devfreq_remove()
729 actmon_write_barrier(tegra); in tegra_devfreq_remove()
731 devm_free_irq(&pdev->dev, irq, tegra); in tegra_devfreq_remove()
733 clk_notifier_unregister(tegra->emc_clock, &tegra->rate_change_nb); in tegra_devfreq_remove()
735 clk_disable_unprepare(tegra->clock); in tegra_devfreq_remove()