tools/elfutils: refresh portability patch for macOS
[openwrt/openwrt.git] / target / linux / ipq806x / patches-5.4 / 0063-3-tsens-fix-kernel-5_4.patch
1 --- a/drivers/thermal/qcom/tsens-ipq8064.c
2 +++ b/drivers/thermal/qcom/tsens-ipq8064.c
3 @@ -18,6 +18,7 @@
4 #include <linux/regmap.h>
5 #include <linux/thermal.h>
6 #include <linux/nvmem-consumer.h>
7 +#include <linux/of_platform.h>
8 #include <linux/io.h>
9 #include <linux/interrupt.h>
10 #include "tsens.h"
11 @@ -320,15 +321,42 @@ static void hw_init(struct tsens_priv *p
12 INIT_WORK(&priv->tsens_work, tsens_scheduler_fn);
13 }
14
15 +static const struct regmap_config tsens_config = {
16 + .name = "tm",
17 + .reg_bits = 32,
18 + .val_bits = 32,
19 + .reg_stride = 4,
20 +};
21 +
22 static int init_ipq8064(struct tsens_priv *priv)
23 {
24 - int ret, i;
25 + struct device *dev = priv->dev;
26 u32 reg_cntl, offset = 0;
27 + struct resource *res;
28 + resource_size_t size;
29 + void __iomem *base;
30 + int ret, i;
31 + struct platform_device *op = of_find_device_by_node(priv->dev->of_node);
32 +
33 + if (!op)
34 + return -EINVAL;
35
36 - init_common(priv);
37 - if (!priv->tm_map)
38 - return -ENODEV;
39 + /* old DTs where SROT and TM were in a contiguous 2K block */
40 + priv->tm_offset = 0x1000;
41
42 + res = platform_get_resource(op, IORESOURCE_MEM, 0);
43 + size = resource_size(res);
44 + base = devm_ioremap(&op->dev, res->start, size);
45 + if (IS_ERR(base)) {
46 + ret = PTR_ERR(base);
47 + goto err_put_device;
48 + }
49 +
50 + priv->tm_map = devm_regmap_init_mmio(dev, base, &tsens_config);
51 + if (IS_ERR(priv->tm_map)) {
52 + ret = PTR_ERR(priv->tm_map);
53 + goto err_put_device;
54 + }
55 /*
56 * The status registers for each sensor are discontiguous
57 * because some SoCs have 5 sensors while others have more
58 @@ -367,6 +395,10 @@ static int init_ipq8064(struct tsens_pri
59 return ret;
60
61 return 0;
62 +
63 +err_put_device:
64 + put_device(&op->dev);
65 + return ret;
66 }
67
68 static int calibrate_ipq8064(struct tsens_priv *priv)