@@ -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,6 +127,12 @@ 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->num_resources > 1)
+ tmdev->status_offset = 0xa0;
+ else
+ tmdev->status_offset = 0x10a0;
base = of_iomap(tmdev->dev->of_node, 0);
if (!base)
@@ -10,7 +10,6 @@
#define TRDY_OFFSET 0xe4
#define TRDY_READY_BIT BIT(0)
-#define STATUS_OFFSET 0xa0
#define LAST_TEMP_MASK 0xfff
#define STATUS_VALID_BIT BIT(21)
#define CODE_SIGN_BIT BIT(11)
@@ -28,7 +27,7 @@ static int get_temp_tsens_v2(struct tsens_device *tmdev, int id, int *temp)
if (code & TRDY_READY_BIT)
return -ENODATA;
- sensor_addr = STATUS_OFFSET + s->hw_id * 4;
+ sensor_addr = tmdev->status_offset + s->hw_id * 4;
ret = regmap_read(tmdev->map, sensor_addr, &code);
if (ret)
return ret;
@@ -77,6 +77,7 @@ struct tsens_device {
struct device *dev;
u32 num_sensors;
struct regmap *map;
+ u32 status_offset;
struct tsens_context ctx;
const struct tsens_ops *ops;
struct tsens_sensor sensor[0];