From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
To: Evan Green <evgreen@chromium.org>,
Rob Herring <robh+dt@kernel.org>,
Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Douglas Anderson <dianders@chromium.org>,
Stephen Boyd <swboyd@chromium.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] nvmem: qfprom: Don't touch certain fuses
Date: Thu, 1 Oct 2020 15:17:09 +0100 [thread overview]
Message-ID: <8f467220-3ac8-c8fc-33fe-8d86904571fe@linaro.org> (raw)
In-Reply-To: <20200929135741.3.I1bb1b0e94be3b792804e08831d6a55481e162d63@changeid>
Hi Evan,
On 29/09/2020 21:58, Evan Green wrote:
> Some fuse ranges are protected by the XPU such that the AP cannot
> access them. Attempting to do so causes an SError. Use the newly
> introduced per-soc compatible string to attach the set of regions
> we should not access. Then tiptoe around those regions.
>
This is a generic feature that can be used by any nvmem provider, can
you move this logic to nvmem core instead of having it in qfprom!
thanks,
srini
> Signed-off-by: Evan Green <evgreen@chromium.org>
> ---
>
> drivers/nvmem/qfprom.c | 55 +++++++++++++++++++++++++++++++++++++++---
> 1 file changed, 51 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/nvmem/qfprom.c b/drivers/nvmem/qfprom.c
> index 5e9e60e2e591d..feea39ae52164 100644
> --- a/drivers/nvmem/qfprom.c
> +++ b/drivers/nvmem/qfprom.c
> @@ -12,6 +12,7 @@
> #include <linux/mod_devicetable.h>
> #include <linux/nvmem-provider.h>
> #include <linux/platform_device.h>
> +#include <linux/property.h>
> #include <linux/regulator/consumer.h>
>
> /* Blow timer clock frequency in Mhz */
> @@ -51,6 +52,17 @@ struct qfprom_soc_data {
> u32 qfprom_blow_set_freq;
> };
>
> +/**
> + * struct qfprom_keepout_region - registers to avoid touching.
> + *
> + * @start: The first byte offset to avoid.
> + * @end: One after the last byte offset to avoid.
> + */
> +struct qfprom_keepout_region {
> + u32 start;
> + u32 end;
> +};
> +
> /**
> * struct qfprom_priv - structure holding qfprom attributes
> *
> @@ -63,6 +75,7 @@ struct qfprom_soc_data {
> * @secclk: Clock supply.
> * @vcc: Regulator supply.
> * @soc_data: Data that for things that varies from SoC to SoC.
> + * @keepout: Fuse regions not to access, as they may cause SErrors.
> */
> struct qfprom_priv {
> void __iomem *qfpraw;
> @@ -73,6 +86,7 @@ struct qfprom_priv {
> struct clk *secclk;
> struct regulator *vcc;
> const struct qfprom_soc_data *soc_data;
> + const struct qfprom_keepout_region *keepout;
> };
>
> /**
> @@ -88,6 +102,12 @@ struct qfprom_touched_values {
> u32 timer_val;
> };
>
> +const struct qfprom_keepout_region sc7180_qfprom[] = {
> + {.start = 0x128, .end = 0x148},
> + {.start = 0x220, .end = 0x228},
> + {} /* Sentinal where start == end. */
> +};
> +
> /**
> * qfprom_disable_fuse_blowing() - Undo enabling of fuse blowing.
> * @priv: Our driver data.
> @@ -171,6 +191,23 @@ static int qfprom_enable_fuse_blowing(const struct qfprom_priv *priv,
> return ret;
> }
>
> +static int qfprom_check_reg(struct qfprom_priv *priv, unsigned int reg)
> +{
> + const struct qfprom_keepout_region *keepout = priv->keepout;
> +
> + if (!keepout)
> + return 1;
> +
> + while (keepout->start != keepout->end) {
> + if ((reg >= keepout->start) && (reg < keepout->end))
> + return 0;
> +
> + keepout++;
> + }
> +
> + return 1;
> +}
> +
> /**
> * qfprom_efuse_reg_write() - Write to fuses.
> * @context: Our driver data.
> @@ -228,8 +265,10 @@ static int qfprom_reg_write(void *context, unsigned int reg, void *_val,
> goto exit_enabled_fuse_blowing;
> }
>
> - for (i = 0; i < words; i++)
> - writel(value[i], priv->qfpraw + reg + (i * 4));
> + for (i = 0; i < words; i++) {
> + if (qfprom_check_reg(priv, reg + (i * 4)))
> + writel(value[i], priv->qfpraw + reg + (i * 4));
> + }
>
> ret = readl_relaxed_poll_timeout(
> priv->qfpconf + QFPROM_BLOW_STATUS_OFFSET,
> @@ -257,8 +296,14 @@ static int qfprom_reg_read(void *context,
> if (read_raw_data && priv->qfpraw)
> base = priv->qfpraw;
>
> - while (words--)
> - *val++ = readb(base + reg + i++);
> + while (words--) {
> + if (qfprom_check_reg(priv, reg + i))
> + *val++ = readb(base + reg + i);
> + else
> + *val++ = 0;
> +
> + i++;
> + }
>
> return 0;
> }
> @@ -299,6 +344,7 @@ static int qfprom_probe(struct platform_device *pdev)
> econfig.priv = priv;
>
> priv->dev = dev;
> + priv->keepout = device_get_match_data(dev);
>
> /*
> * If more than one region is provided then the OS has the ability
> @@ -354,6 +400,7 @@ static int qfprom_probe(struct platform_device *pdev)
>
> static const struct of_device_id qfprom_of_match[] = {
> { .compatible = "qcom,qfprom",},
> + { .compatible = "qcom,sc7180-qfprom", .data = &sc7180_qfprom},
> {/* sentinel */},
> };
> MODULE_DEVICE_TABLE(of, qfprom_of_match);
>
next prev parent reply other threads:[~2020-10-01 14:17 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-29 20:58 [PATCH 0/3] nvmem: qfprom: Avoid untouchable regions Evan Green
2020-09-29 20:58 ` [PATCH 1/3] dt-bindings: nvmem: Add qcom,sc7180-qfprom compatible string Evan Green
2020-10-02 22:20 ` Doug Anderson
2020-10-02 23:14 ` Evan Green
2020-10-05 9:15 ` Srinivas Kandagatla
2020-09-29 20:58 ` [PATCH 2/3] arm64: dts: qcom: sc7180: Add soc-specific qfprom compat string Evan Green
2020-10-02 22:24 ` Doug Anderson
2020-09-29 20:58 ` [PATCH 3/3] nvmem: qfprom: Don't touch certain fuses Evan Green
2020-10-01 14:17 ` Srinivas Kandagatla [this message]
2020-10-01 16:27 ` Evan Green
2020-10-01 16:30 ` Srinivas Kandagatla
2020-10-01 21:49 ` Evan Green
2020-10-05 9:12 ` Srinivas Kandagatla
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8f467220-3ac8-c8fc-33fe-8d86904571fe@linaro.org \
--to=srinivas.kandagatla@linaro.org \
--cc=bjorn.andersson@linaro.org \
--cc=dianders@chromium.org \
--cc=evgreen@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=swboyd@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®