summaryrefslogtreecommitdiffstats
path: root/drivers/devfreq/tegra-devfreq.c
AgeCommit message (Collapse)AuthorFilesLines
2019-08-24PM / devfreq: tegra: Rename tegra-devfreq.c to tegra30-devfreq.cDmitry Osipenko1-748/+0
In order to reflect that driver serves NVIDIA Tegra30 and later SoC generations, let's rename the driver's source file to "tegra30-devfreq.c". This will make driver files to look more consistent after addition of a driver for Tegra20. Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2019-08-24PM / devfreq: tegra: Support Tegra30Dmitry Osipenko1-0/+1
The devfreq driver can be used on Tegra30 without any code change and it works perfectly fine, the default Tegra124 parameters are good enough for Tegra30. Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com> [Modified by MyungJoo to depends on Tegra30/114/124/210 only] Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2019-08-24PM / devfreq: tegra: Reconfigure hardware on governor's restartDmitry Osipenko1-58/+40
Move hardware configuration to governor's start/resume methods. This allows to re-initialize hardware counters and reconfigure cleanly if governor was stopped/paused. That is needed because we are not aware of all hardware changes that happened while governor was stopped and the paused state may get out of sync with reality, hence it's better to start with a clean slate after the pause. In a result there is no memory bandwidth starvation after resume from suspend-to-ram that results in display controller underflowing that happens on resume because of improper decision made by devfreq about the required memory frequency. This change also cleans up code a tad by moving hardware-configuration code into a single location. Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Acked-by: Thierry Reding <treding@nvidia.com> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2019-08-24PM / devfreq: tegra: Move governor registration to driver's probeDmitry Osipenko1-31/+12
There is no need to register the ACTMON's governor separately from the driver, hence let's move the registration into the driver's probe function for consistency and to make code cleaner a tad. Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Acked-by: Thierry Reding <treding@nvidia.com> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2019-08-24PM / devfreq: tegra: Mark ACTMON's governor as immutableDmitry Osipenko1-0/+1
The ACTMON's governor supports only the Tegra's devfreq device and there is no need to use any other governor, hence let's mark Tegra governor as immutable to permanently stick it with Tegra's devfreq device. Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Acked-by: Thierry Reding <treding@nvidia.com> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2019-08-24PM / devfreq: tegra: Avoid inconsistency of current frequency valueDmitry Osipenko1-2/+4
The frequency value potentially could change in-between. It doesn't cause any real problem at all right now, but that could change in the future. Hence let's avoid the inconsistency. Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Acked-by: Thierry Reding <treding@nvidia.com> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2019-08-24PM / devfreq: tegra: Clean up driver's probe / removeDmitry Osipenko1-36/+47
Reset hardware, disable ACTMON clock, release OPP's and handle all possible error cases correctly, maintaining the correct tear down order. Also use devm_platform_ioremap_resource() which is now available in the kernel. Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Acked-by: Thierry Reding <treding@nvidia.com> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2019-08-24PM / devfreq: tegra: Properly disable interruptsDmitry Osipenko1-6/+15
There is no guarantee that interrupt handling isn't running in parallel with tegra_actmon_disable_interrupts(), hence it is necessary to protect DEV_CTRL register accesses and clear IRQ status with ACTMON's IRQ being disabled in the Interrupt Controller in order to ensure that device interrupt is indeed being disabled. Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Acked-by: Thierry Reding <treding@nvidia.com> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2019-08-24PM / devfreq: tegra: Drop primary interrupt handlerDmitry Osipenko1-37/+18
There is no real need in the primary interrupt handler, hence move everything to the secondary (threaded) handler. In a result locking is consistent now and there are no potential races with the interrupt handler because it is protected with the devfreq's mutex. Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Acked-by: Thierry Reding <treding@nvidia.com> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2019-08-24PM / devfreq: tegra: Don't set EMC clock rate to maximum on probeDmitry Osipenko1-2/+0
There is no real benefit from doing so, hence let's drop that rate setting for consistency. Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Acked-by: Thierry Reding <treding@nvidia.com> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2019-08-24PM / devfreq: tegra: Don't ignore clk errorsDmitry Osipenko1-2/+14
The clk_set_min_rate() could fail and in this case clk_set_rate() sets rate to 0, which may drop EMC rate to minimum and make machine very difficult to use. Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Acked-by: Thierry Reding <treding@nvidia.com> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2019-08-24PM / devfreq: tegra: Replace write memory barrier with the read barrierDmitry Osipenko1-2/+1
The write memory barrier isn't needed because the BUS buffer is flushed by read after write that happens after the removed wmb(), we will also use readl() instead of the relaxed version to ensure that read is indeed completed. Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Acked-by: Thierry Reding <treding@nvidia.com> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2019-08-24PM / devfreq: tegra: Replace readl-writel with relaxed versionsDmitry Osipenko1-4/+4
There is no need to insert memory barrier on each readl/writel invocation, hence use the relaxed versions. Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Acked-by: Thierry Reding <treding@nvidia.com> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2019-08-24PM / devfreq: tegra: Fix kHz to Hz conversionDmitry Osipenko1-7/+5
The kHz to Hz is incorrectly converted in a few places in the code, this results in a wrong frequency being calculated because devfreq core uses OPP frequencies that are given in Hz to clamp the rate, while tegra-devfreq gives to the core value in kHz and then it also expects to receive value in kHz from the core. In a result memory freq is always set to a value which is close to ULONG_MAX because of the bug. Hence the EMC frequency is always capped to the maximum and the driver doesn't do anything useful. This patch was tested on Tegra30 and Tegra124 SoC's, EMC frequency scaling works properly now. Cc: <stable@vger.kernel.org> # 4.14+ Tested-by: Steev Klimaszewski <steev@kali.org> Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Acked-by: Thierry Reding <treding@nvidia.com> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2019-05-30treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 201Thomas Gleixner1-13/+1
Based on 1 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms and conditions of the gnu general public license version 2 as published by the free software foundation this program is distributed in the hope it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details you should have received a copy of the gnu general public license along with this program if not see http www gnu org licenses extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 228 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Allison Randal <allison@lohutok.net> Reviewed-by: Steve Winslow <swinslow@gmail.com> Reviewed-by: Richard Fontana <rfontana@redhat.com> Reviewed-by: Alexios Zavras <alexios.zavras@intel.com> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190528171438.107155473@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-04-16PM / devfreq: tegra: remove unneeded variableYangtao Li1-5/+2
This variable is not used after initialization, so remove it. And in order to unify the code style, move the location where the dev_get_drvdata is called by the way. Signed-off-by: Yangtao Li <tiny.windzz@gmail.com> Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com> Acked-by: Jon Hunter <jonathanh@nvidia.com> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2018-07-07headers: separate linux/mod_devicetable.h from linux/platform_device.hRandy Dunlap1-0/+1
At over 4000 #includes, <linux/platform_device.h> is the 9th most #included header file in the Linux kernel. It does not need <linux/mod_devicetable.h>, so drop that header and explicitly add <linux/mod_devicetable.h> to source files that need it. 4146 #include <linux/platform_device.h> After this patch, there are 225 files that use <linux/mod_devicetable.h>, for a reduction of around 3900 times that <linux/mod_devicetable.h> does not have to be read & parsed. 225 #include <linux/mod_devicetable.h> This patch was build-tested on 20 different arch-es. It also makes these drivers SubmitChecklist#1 compliant. Signed-off-by: Randy Dunlap <rdunlap@infradead.org> Reported-by: kbuild test robot <lkp@intel.com> # drivers/media/platform/vimc/ Reported-by: kbuild test robot <lkp@intel.com> # drivers/pinctrl/pinctrl-u300.c Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-07-06PM / devfreq: tegra: fix error return code in tegra_devfreq_probe()Gustavo A. R. Silva1-3/+3
platform_get_irq() returns an error code, but the tegra-devfreq driver ignores it and always returns -ENODEV. This is not correct, and prevents -EPROBE_DEFER from being propagated properly. Notice that platform_get_irq() no longer returns 0 on error: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e330b9a6bb35dc7097a4f02cb1ae7b6f96df92af Print and propagate the return value of platform_get_irq on failure. Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2017-01-30PM / OPP: Update OPP users to put referenceViresh Kumar1-3/+1
This patch updates dev_pm_opp_find_freq_*() routines to get a reference to the OPPs returned by them. Also updates the users of dev_pm_opp_find_freq_*() routines to call dev_pm_opp_put() after they are done using the OPPs. As it is guaranteed the that OPPs wouldn't get freed while being used, the RCU read side locking present with the users isn't required anymore. Drop it as well. This patch also updates all users of devfreq_recommended_opp() which was returning an OPP received from the OPP core. Note that some of the OPP core routines have gained rcu_read_{lock|unlock}() calls, as those still use RCU specific APIs within them. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com> [Devfreq] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2016-02-23PM / devfreq: tegra: Set freq in rate callbackTomeu Vizoso1-0/+2
As per the documentation of the devfreq_dev_profile.target callback, set the freq argument to the new frequency before returning. This caused endless messages like this after recent changes in the core: devfreq 6000c800.actmon: Couldn't update frequency transition information. Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Reported-by: Tyler Baker <tyler.baker@linaro.org> Tested-by: Thierry Reding <treding@nvidia.com> Acked-by: Thierry Reding <treding@nvidia.com> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2015-09-11PM / devfreq: tegra: Update governor to use devfreq_update_stats()MyungJoo Ham1-3/+5
Direct invocation of get_dev_status() is no more recommended. Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2015-03-31PM / devfreq: tegra: Register governor on module initTomeu Vizoso1-7/+30
So this driver builds as a module. Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2015-03-31PM / devfreq: tegra: Enable interrupts after resuming the devfreq monitorTomeu Vizoso1-2/+2
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2015-03-31PM / devfreq: tegra: Set drvdata before enabling the irqTomeu Vizoso1-2/+2
To avoid a race in which the interrupt will be handled before the drvdata has been set up. Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2015-03-31PM / devfreq: tegra: remove operating-pointsTomeu Vizoso1-6/+6
As the DT bindings don't have an operating-points property any more, build the OPP table from the frequencies supported by the EMC clock. Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2015-03-31PM / devfreq: tegra: Use clock rate constraintsTomeu Vizoso1-10/+5
Now that we have per-user clocks and the possibility to set constraints in a clock, set a floor constraint on the EMC clock. Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2015-03-31PM / devfreq: tegra: Update to v5 of the submitted patchesTomeu Vizoso1-204/+253
There seemed to be some miscommunication and an old version of the submitted patches was merged. This commit updates the driver to v5, which had this changelog: * Clarify the units of avg_dependency_threshold * Remove unused references to platform_device * Enable and disable interrupts on governor events * Make sure we handle all interrupts for any of the devices we are sampling * Move locking to be per-actmon-device Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> CC: Alex Frid <afrid@nvidia.com> CC: Mikko Perttunen <mikko.perttunen@kapsi.fi> [Added const to device ID by MyungJoo] Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2015-01-29PM / devfreq: tegra: add devfreq driver for Tegra Activity MonitorTomeu Vizoso1-0/+718
The ACTMON block can monitor several counters, providing averaging and firing interrupts based on watermarking configuration. This implementation monitors the MCALL and MCCPU counters to choose an appropriate frequency for the external memory clock. This patch is based on work by Alex Frid <afrid@nvidia.com> and Mikko Perttunen <mikko.perttunen@kapsi.fi>. Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>