Skip to content

Commit

Permalink
aiodev: imx_thermal: fix breakage after device tree sync
Browse files Browse the repository at this point in the history
fsl,tempmon-data is a deprecated property that has been replaced
upstream by a NVMEM cell pointing at the calibration value and so
made it into barebox breaking the driver.

Switch to using the new property to fix the regression.

We do not keep support for the old binding around as it would be dead code:
barebox, unlike Linux, is always bundled with a device tree originating
from its build tree and so we only need to ensure the driver matches that
version.

Fixes: abef603 ("dts: update to v5.8-rc1")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>
Link: https://lore.barebox.org/20230911124808.2748160-1-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
  • Loading branch information
a3f authored and saschahauer committed Sep 12, 2023
1 parent e1f79b6 commit 451c25b
Showing 1 changed file with 4 additions and 21 deletions.
25 changes: 4 additions & 21 deletions drivers/aiodev/imx_thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
#include <linux/math64.h>
#include <linux/log2.h>
#include <linux/clk.h>
#include <linux/nvmem-consumer.h>
#include <mach/imx/imx6-anadig.h>
#include <io.h>
#include <aiodev.h>
#include <mfd/syscon.h>

#define FACTOR0 10000000
#define MEASURE_FREQ 327
#define OCOTP_ANA1_OFFSET (0xE * sizeof(uint32_t))

struct imx_thermal_data {
int c1, c2;
Expand Down Expand Up @@ -109,30 +109,13 @@ static int imx_thermal_read(struct aiochannel *chan, int *val)
static int imx_thermal_probe(struct device *dev)
{
uint32_t ocotp_ana1;
struct device_node *node;
struct imx_thermal_data *imx_thermal;
struct cdev *ocotp;
int t1, n1, t2, n2;
int ret;

node = of_parse_phandle(dev->of_node, "fsl,tempmon-data", 0);
if (!node) {
dev_err(dev, "No calibration data source\n");
return -ENODEV;
}

ocotp = cdev_by_device_node(node);
if (!ocotp) {
dev_err(dev, "No OCOTP character device\n");
return -ENODEV;
}

ret = cdev_read(ocotp, &ocotp_ana1, sizeof(ocotp_ana1),
OCOTP_ANA1_OFFSET, 0);
if (ret != sizeof(ocotp_ana1)) {
dev_err(dev, "Failed to read calibration data\n");
return ret < 0 ? ret : -EIO;
}
ret = nvmem_cell_read_variable_le_u32(dev, "calib", &ocotp_ana1);
if (ret)
return ret;

imx_thermal = xzalloc(sizeof(*imx_thermal));
imx_thermal->base = syscon_base_lookup_by_phandle(dev->of_node,
Expand Down

0 comments on commit 451c25b

Please sign in to comment.