Commit a15525b5 authored by Amit Kucheria's avatar Amit Kucheria Committed by Eduardo Valentin

thermal: tsens: Add the SROT address map

On platforms whose device trees specify two address spaces for TSENS, the
second one points to the SROT registers. Initialise the SROT map on those
platforms.
Signed-off-by: default avatarAmit Kucheria <amit.kucheria@linaro.org>
Reviewed-by: default avatarMatthias Kaehlcke <mka@chromium.org>
Reviewed-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: default avatarEduardo Valentin <edubezval@gmail.com>
parent 67b0f5e0
...@@ -117,16 +117,26 @@ static const struct regmap_config tsens_config = { ...@@ -117,16 +117,26 @@ static const struct regmap_config tsens_config = {
int __init init_common(struct tsens_device *tmdev) int __init init_common(struct tsens_device *tmdev)
{ {
void __iomem *tm_base; void __iomem *tm_base, *srot_base;
struct resource *res; struct resource *res;
struct platform_device *op = of_find_device_by_node(tmdev->dev->of_node); struct platform_device *op = of_find_device_by_node(tmdev->dev->of_node);
if (!op) if (!op)
return -EINVAL; return -EINVAL;
/* The driver only uses the TM register address space for now */
if (op->num_resources > 1) { if (op->num_resources > 1) {
/* DT with separate SROT and TM address space */
tmdev->tm_offset = 0; tmdev->tm_offset = 0;
res = platform_get_resource(op, IORESOURCE_MEM, 1);
srot_base = devm_ioremap_resource(&op->dev, res);
if (IS_ERR(srot_base))
return PTR_ERR(srot_base);
tmdev->srot_map = devm_regmap_init_mmio(tmdev->dev,
srot_base, &tsens_config);
if (IS_ERR(tmdev->srot_map))
return PTR_ERR(tmdev->srot_map);
} else { } else {
/* old DTs where SROT and TM were in a contiguous 2K block */ /* old DTs where SROT and TM were in a contiguous 2K block */
tmdev->tm_offset = 0x1000; tmdev->tm_offset = 0x1000;
......
...@@ -70,6 +70,7 @@ struct tsens_device { ...@@ -70,6 +70,7 @@ struct tsens_device {
struct device *dev; struct device *dev;
u32 num_sensors; u32 num_sensors;
struct regmap *tm_map; struct regmap *tm_map;
struct regmap *srot_map;
u32 tm_offset; u32 tm_offset;
struct tsens_context ctx; struct tsens_context ctx;
const struct tsens_ops *ops; const struct tsens_ops *ops;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment