summaryrefslogtreecommitdiffstats
path: root/drivers/thermal/qcom/tsens-common.c
diff options
context:
space:
mode:
authorAmit Kucheria2018-07-18 08:43:09 +0200
committerEduardo Valentin2018-07-28 00:02:37 +0200
commit5b1283984fa39933e094d237387ad8fd39527fc1 (patch)
tree3b31d82ac01f3dc19762318878caa8aa78008263 /drivers/thermal/qcom/tsens-common.c
parentdt: thermal: tsens: Document the fallback DT property for v2 of TSENS IP (diff)
downloadkernel-qcow2-linux-5b1283984fa39933e094d237387ad8fd39527fc1.tar.gz
kernel-qcow2-linux-5b1283984fa39933e094d237387ad8fd39527fc1.tar.xz
kernel-qcow2-linux-5b1283984fa39933e094d237387ad8fd39527fc1.zip
thermal: tsens: Add support to split up register address space into two
There are two banks of registers for v2 TSENS IPs: SROT and TM. On older SoCs these were contiguous, leading to DTs mapping them as one register address space of size 0x2000. In newer SoCs, these two banks are not contiguous anymore. Add logic to init_common() to differentiate between old and new DTs and adjust associated offsets for the TM register bank so that the old DTs will continue to function correctly. Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org> Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org> Tested-by: Matthias Kaehlcke <mka@chromium.org> Reviewed-by: Matthias Kaehlcke <mka@chromium.org> Reviewed-by: Douglas Anderson <dianders@chromium.org> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
Diffstat (limited to 'drivers/thermal/qcom/tsens-common.c')
-rw-r--r--drivers/thermal/qcom/tsens-common.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c
index b1449ad67fc0..c22dc18c7c65 100644
--- a/drivers/thermal/qcom/tsens-common.c
+++ b/drivers/thermal/qcom/tsens-common.c
@@ -16,6 +16,7 @@
#include <linux/io.h>
#include <linux/nvmem-consumer.h>
#include <linux/of_address.h>
+#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include "tsens.h"
@@ -126,11 +127,22 @@ static const struct regmap_config tsens_config = {
int __init init_common(struct tsens_device *tmdev)
{
void __iomem *base;
+ struct platform_device *op = of_find_device_by_node(tmdev->dev->of_node);
+ if (!op)
+ return -EINVAL;
base = of_iomap(tmdev->dev->of_node, 0);
if (!base)
return -EINVAL;
+ /* The driver only uses the TM register address space for now */
+ if (op->num_resources > 1) {
+ tmdev->tm_offset = 0;
+ } else {
+ /* old DTs where SROT and TM were in a contiguous 2K block */
+ tmdev->tm_offset = 0x1000;
+ }
+
tmdev->map = devm_regmap_init_mmio(tmdev->dev, base, &tsens_config);
if (IS_ERR(tmdev->map)) {
iounmap(base);