ath25: switch default kernel to 5.15
[openwrt/openwrt.git] / target / linux / generic / backport-5.10 / 801-v5.11-0002-nvmem-qfprom-Don-t-touch-certain-fuses.patch
1 From 044ee8f85267599a9b0112911f5c16d4548b4289 Mon Sep 17 00:00:00 2001
2 From: Evan Green <evgreen@chromium.org>
3 Date: Fri, 27 Nov 2020 10:28:36 +0000
4 Subject: [PATCH] nvmem: qfprom: Don't touch certain fuses
5
6 Some fuse ranges are protected by the XPU such that the AP cannot
7 access them. Attempting to do so causes an SError. Use the newly
8 introduced per-soc compatible string, and the newly introduced
9 nvmem keepout support to attach the set of regions
10 we should not access.
11
12 Reviewed-by: Douglas Anderson <dianders@chromium.org>
13 Signed-off-by: Evan Green <evgreen@chromium.org>
14 Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
15 Link: https://lore.kernel.org/r/20201127102837.19366-5-srinivas.kandagatla@linaro.org
16 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
17 ---
18 drivers/nvmem/qfprom.c | 30 ++++++++++++++++++++++++++++++
19 1 file changed, 30 insertions(+)
20
21 --- a/drivers/nvmem/qfprom.c
22 +++ b/drivers/nvmem/qfprom.c
23 @@ -12,6 +12,7 @@
24 #include <linux/mod_devicetable.h>
25 #include <linux/nvmem-provider.h>
26 #include <linux/platform_device.h>
27 +#include <linux/property.h>
28 #include <linux/regulator/consumer.h>
29
30 /* Blow timer clock frequency in Mhz */
31 @@ -89,6 +90,28 @@ struct qfprom_touched_values {
32 };
33
34 /**
35 + * struct qfprom_soc_compatible_data - Data matched against the SoC
36 + * compatible string.
37 + *
38 + * @keepout: Array of keepout regions for this SoC.
39 + * @nkeepout: Number of elements in the keepout array.
40 + */
41 +struct qfprom_soc_compatible_data {
42 + const struct nvmem_keepout *keepout;
43 + unsigned int nkeepout;
44 +};
45 +
46 +static const struct nvmem_keepout sc7180_qfprom_keepout[] = {
47 + {.start = 0x128, .end = 0x148},
48 + {.start = 0x220, .end = 0x228}
49 +};
50 +
51 +static const struct qfprom_soc_compatible_data sc7180_qfprom = {
52 + .keepout = sc7180_qfprom_keepout,
53 + .nkeepout = ARRAY_SIZE(sc7180_qfprom_keepout)
54 +};
55 +
56 +/**
57 * qfprom_disable_fuse_blowing() - Undo enabling of fuse blowing.
58 * @priv: Our driver data.
59 * @old: The data that was stashed from before fuse blowing.
60 @@ -302,6 +325,7 @@ static int qfprom_probe(struct platform_
61 struct device *dev = &pdev->dev;
62 struct resource *res;
63 struct nvmem_device *nvmem;
64 + const struct qfprom_soc_compatible_data *soc_data;
65 struct qfprom_priv *priv;
66 int ret;
67
68 @@ -320,6 +344,11 @@ static int qfprom_probe(struct platform_
69 econfig.priv = priv;
70
71 priv->dev = dev;
72 + soc_data = device_get_match_data(dev);
73 + if (soc_data) {
74 + econfig.keepout = soc_data->keepout;
75 + econfig.nkeepout = soc_data->nkeepout;
76 + }
77
78 /*
79 * If more than one region is provided then the OS has the ability
80 @@ -375,6 +404,7 @@ static int qfprom_probe(struct platform_
81
82 static const struct of_device_id qfprom_of_match[] = {
83 { .compatible = "qcom,qfprom",},
84 + { .compatible = "qcom,sc7180-qfprom", .data = &sc7180_qfprom},
85 {/* sentinel */},
86 };
87 MODULE_DEVICE_TABLE(of, qfprom_of_match);