nvmem: qfprom: Don't touch certain fuses

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, and the newly introduced
nvmem keepout support to attach the set of regions
we should not access.

Reviewed-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Evan Green <evgreen@chromium.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20201127102837.19366-5-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Evan Green
2020-11-27 10:28:36 +00:00
committed by Greg Kroah-Hartman
parent c8b336bb1a
commit 044ee8f852

View File

@@ -12,6 +12,7 @@
#include <linux/mod_devicetable.h> #include <linux/mod_devicetable.h>
#include <linux/nvmem-provider.h> #include <linux/nvmem-provider.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/property.h>
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
/* Blow timer clock frequency in Mhz */ /* Blow timer clock frequency in Mhz */
@@ -88,6 +89,28 @@ struct qfprom_touched_values {
u32 timer_val; u32 timer_val;
}; };
/**
* struct qfprom_soc_compatible_data - Data matched against the SoC
* compatible string.
*
* @keepout: Array of keepout regions for this SoC.
* @nkeepout: Number of elements in the keepout array.
*/
struct qfprom_soc_compatible_data {
const struct nvmem_keepout *keepout;
unsigned int nkeepout;
};
static const struct nvmem_keepout sc7180_qfprom_keepout[] = {
{.start = 0x128, .end = 0x148},
{.start = 0x220, .end = 0x228}
};
static const struct qfprom_soc_compatible_data sc7180_qfprom = {
.keepout = sc7180_qfprom_keepout,
.nkeepout = ARRAY_SIZE(sc7180_qfprom_keepout)
};
/** /**
* qfprom_disable_fuse_blowing() - Undo enabling of fuse blowing. * qfprom_disable_fuse_blowing() - Undo enabling of fuse blowing.
* @priv: Our driver data. * @priv: Our driver data.
@@ -281,6 +304,7 @@ static int qfprom_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct resource *res; struct resource *res;
struct nvmem_device *nvmem; struct nvmem_device *nvmem;
const struct qfprom_soc_compatible_data *soc_data;
struct qfprom_priv *priv; struct qfprom_priv *priv;
int ret; int ret;
@@ -299,6 +323,11 @@ static int qfprom_probe(struct platform_device *pdev)
econfig.priv = priv; econfig.priv = priv;
priv->dev = dev; priv->dev = dev;
soc_data = device_get_match_data(dev);
if (soc_data) {
econfig.keepout = soc_data->keepout;
econfig.nkeepout = soc_data->nkeepout;
}
/* /*
* If more than one region is provided then the OS has the ability * If more than one region is provided then the OS has the ability
@@ -354,6 +383,7 @@ static int qfprom_probe(struct platform_device *pdev)
static const struct of_device_id qfprom_of_match[] = { static const struct of_device_id qfprom_of_match[] = {
{ .compatible = "qcom,qfprom",}, { .compatible = "qcom,qfprom",},
{ .compatible = "qcom,sc7180-qfprom", .data = &sc7180_qfprom},
{/* sentinel */}, {/* sentinel */},
}; };
MODULE_DEVICE_TABLE(of, qfprom_of_match); MODULE_DEVICE_TABLE(of, qfprom_of_match);