* [PATCH 01/16] nvmem: core: support passing DT node in cell info
2022-04-29 16:26 [PATCH 00/16] nvmem: patches (set 1) for 5.19 Srinivas Kandagatla
@ 2022-04-29 16:26 ` Srinivas Kandagatla
2022-04-29 16:26 ` [PATCH 02/16] nvmem: brcm_nvram: find Device Tree nodes for NVMEM cells Srinivas Kandagatla
` (15 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: Srinivas Kandagatla @ 2022-04-29 16:26 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, Rafał Miłecki, Srinivas Kandagatla
From: Rafał Miłecki <rafal@milecki.pl>
Some hardware may have NVMEM cells described in Device Tree using
individual nodes. Let drivers pass such nodes to the NVMEM subsystem so
they can be later used by NVMEM consumers.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
drivers/nvmem/core.c | 1 +
include/linux/nvmem-consumer.h | 1 +
2 files changed, 2 insertions(+)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index f58d9bc7aa08..1e3c754efd0d 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -467,6 +467,7 @@ static int nvmem_cell_info_to_nvmem_cell_entry_nodup(struct nvmem_device *nvmem,
cell->bit_offset = info->bit_offset;
cell->nbits = info->nbits;
+ cell->np = info->np;
if (cell->nbits)
cell->bytes = DIV_ROUND_UP(cell->nbits + cell->bit_offset,
diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h
index c0c0cefc3b92..980f9c9ac0bc 100644
--- a/include/linux/nvmem-consumer.h
+++ b/include/linux/nvmem-consumer.h
@@ -25,6 +25,7 @@ struct nvmem_cell_info {
unsigned int bytes;
unsigned int bit_offset;
unsigned int nbits;
+ struct device_node *np;
};
/**
--
2.21.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 02/16] nvmem: brcm_nvram: find Device Tree nodes for NVMEM cells
2022-04-29 16:26 [PATCH 00/16] nvmem: patches (set 1) for 5.19 Srinivas Kandagatla
2022-04-29 16:26 ` [PATCH 01/16] nvmem: core: support passing DT node in cell info Srinivas Kandagatla
@ 2022-04-29 16:26 ` Srinivas Kandagatla
2022-04-29 16:26 ` [PATCH 03/16] MAINTAINERS: Add apple efuses nvmem files to ARM/APPLE MACHINE Srinivas Kandagatla
` (14 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: Srinivas Kandagatla @ 2022-04-29 16:26 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, Rafał Miłecki, Srinivas Kandagatla
From: Rafał Miłecki <rafal@milecki.pl>
DT binding for Broadcom's NVRAM supports specifying NVMEM cells as NVMEM
device (provider) subnodes. Look for such subnodes when collecing NVMEM
cells. This allows NVMEM consumers to use NVRAM variables.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
drivers/nvmem/brcm_nvram.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/nvmem/brcm_nvram.c b/drivers/nvmem/brcm_nvram.c
index 439f00b9eef6..450b927691c3 100644
--- a/drivers/nvmem/brcm_nvram.c
+++ b/drivers/nvmem/brcm_nvram.c
@@ -8,6 +8,7 @@
#include <linux/module.h>
#include <linux/nvmem-consumer.h>
#include <linux/nvmem-provider.h>
+#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
@@ -72,6 +73,7 @@ static int brcm_nvram_add_cells(struct brcm_nvram *priv, uint8_t *data,
return -ENOMEM;
priv->cells[idx].offset = value - (char *)data;
priv->cells[idx].bytes = strlen(value);
+ priv->cells[idx].np = of_get_child_by_name(dev->of_node, priv->cells[idx].name);
}
return 0;
--
2.21.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 03/16] MAINTAINERS: Add apple efuses nvmem files to ARM/APPLE MACHINE
2022-04-29 16:26 [PATCH 00/16] nvmem: patches (set 1) for 5.19 Srinivas Kandagatla
2022-04-29 16:26 ` [PATCH 01/16] nvmem: core: support passing DT node in cell info Srinivas Kandagatla
2022-04-29 16:26 ` [PATCH 02/16] nvmem: brcm_nvram: find Device Tree nodes for NVMEM cells Srinivas Kandagatla
@ 2022-04-29 16:26 ` Srinivas Kandagatla
2022-04-29 16:26 ` [PATCH 04/16] dt-bindings: nvmem: Add apple,efuses Srinivas Kandagatla
` (13 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: Srinivas Kandagatla @ 2022-04-29 16:26 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, Sven Peter, Srinivas Kandagatla
From: Sven Peter <sven@svenpeter.dev>
Signed-off-by: Sven Peter <sven@svenpeter.dev>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
MAINTAINERS | 2 ++
1 file changed, 2 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index fd768d43e048..1bf57fd937b5 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1837,6 +1837,7 @@ F: Documentation/devicetree/bindings/clock/apple,nco.yaml
F: Documentation/devicetree/bindings/i2c/apple,i2c.yaml
F: Documentation/devicetree/bindings/interrupt-controller/apple,*
F: Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml
+F: Documentation/devicetree/bindings/nvmem/apple,efuses.yaml
F: Documentation/devicetree/bindings/pci/apple,pcie.yaml
F: Documentation/devicetree/bindings/pinctrl/apple,pinctrl.yaml
F: Documentation/devicetree/bindings/power/apple*
@@ -1847,6 +1848,7 @@ F: drivers/i2c/busses/i2c-pasemi-core.c
F: drivers/i2c/busses/i2c-pasemi-platform.c
F: drivers/irqchip/irq-apple-aic.c
F: drivers/mailbox/apple-mailbox.c
+F: drivers/nvmem/apple-efuses.c
F: drivers/pinctrl/pinctrl-apple-gpio.c
F: drivers/soc/apple/*
F: drivers/watchdog/apple_wdt.c
--
2.21.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 04/16] dt-bindings: nvmem: Add apple,efuses
2022-04-29 16:26 [PATCH 00/16] nvmem: patches (set 1) for 5.19 Srinivas Kandagatla
` (2 preceding siblings ...)
2022-04-29 16:26 ` [PATCH 03/16] MAINTAINERS: Add apple efuses nvmem files to ARM/APPLE MACHINE Srinivas Kandagatla
@ 2022-04-29 16:26 ` Srinivas Kandagatla
2022-04-29 16:26 ` [PATCH 05/16] nvmem: Add Apple eFuse driver Srinivas Kandagatla
` (12 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: Srinivas Kandagatla @ 2022-04-29 16:26 UTC (permalink / raw)
To: gregkh
Cc: linux-kernel, Sven Peter, Krzysztof Kozlowski, Rob Herring,
Srinivas Kandagatla
From: Sven Peter <sven@svenpeter.dev>
Apple SoCs come with eFuses used to store factory-programmed data
such as calibration settings for the PCIe and Type-C PHY.
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sven Peter <sven@svenpeter.dev>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
.../bindings/nvmem/apple,efuses.yaml | 50 +++++++++++++++++++
1 file changed, 50 insertions(+)
create mode 100644 Documentation/devicetree/bindings/nvmem/apple,efuses.yaml
diff --git a/Documentation/devicetree/bindings/nvmem/apple,efuses.yaml b/Documentation/devicetree/bindings/nvmem/apple,efuses.yaml
new file mode 100644
index 000000000000..5ec8f2bdb3a5
--- /dev/null
+++ b/Documentation/devicetree/bindings/nvmem/apple,efuses.yaml
@@ -0,0 +1,50 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/nvmem/apple,efuses.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Apple SoC eFuse-based NVMEM
+
+description: |
+ Apple SoCs such as the M1 contain factory-programmed eFuses used to e.g. store
+ calibration data for the PCIe and the Type-C PHY or unique chip identifiers
+ such as the ECID.
+
+maintainers:
+ - Sven Peter <sven@svenpeter.dev>
+
+allOf:
+ - $ref: "nvmem.yaml#"
+
+properties:
+ compatible:
+ items:
+ - enum:
+ - apple,t8103-efuses
+ - apple,t6000-efuses
+ - const: apple,efuses
+
+ reg:
+ maxItems: 1
+
+required:
+ - compatible
+ - reg
+
+unevaluatedProperties: false
+
+examples:
+ - |
+ efuse@3d2bc000 {
+ compatible = "apple,t8103-efuses", "apple,efuses";
+ reg = <0x3d2bc000 0x1000>;
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ ecid: efuse@500 {
+ reg = <0x500 0x8>;
+ };
+ };
+
+...
--
2.21.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 05/16] nvmem: Add Apple eFuse driver
2022-04-29 16:26 [PATCH 00/16] nvmem: patches (set 1) for 5.19 Srinivas Kandagatla
` (3 preceding siblings ...)
2022-04-29 16:26 ` [PATCH 04/16] dt-bindings: nvmem: Add apple,efuses Srinivas Kandagatla
@ 2022-04-29 16:26 ` Srinivas Kandagatla
2022-04-29 16:26 ` [PATCH 06/16] nvmem: bcm-ocotp: mark ACPI device ID table as maybe unused Srinivas Kandagatla
` (11 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: Srinivas Kandagatla @ 2022-04-29 16:26 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, Sven Peter, Srinivas Kandagatla
From: Sven Peter <sven@svenpeter.dev>
Apple SoCs contain eFuses used to store factory-programmed data such
as calibration values for the PCIe or the Type-C PHY. They are organized
as 32bit values exposed as MMIO.
Signed-off-by: Sven Peter <sven@svenpeter.dev>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
drivers/nvmem/Kconfig | 12 ++++++
drivers/nvmem/Makefile | 2 +
drivers/nvmem/apple-efuses.c | 80 ++++++++++++++++++++++++++++++++++++
3 files changed, 94 insertions(+)
create mode 100644 drivers/nvmem/apple-efuses.c
diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig
index 555aa77a574d..6283e09cc1e9 100644
--- a/drivers/nvmem/Kconfig
+++ b/drivers/nvmem/Kconfig
@@ -324,4 +324,16 @@ config NVMEM_SUNPLUS_OCOTP
This driver can also be built as a module. If so, the module
will be called nvmem-sunplus-ocotp.
+config NVMEM_APPLE_EFUSES
+ tristate "Apple eFuse support"
+ depends on ARCH_APPLE || COMPILE_TEST
+ default ARCH_APPLE
+ help
+ Say y here to enable support for reading eFuses on Apple SoCs
+ such as the M1. These are e.g. used to store factory programmed
+ calibration data required for the PCIe or the USB-C PHY.
+
+ This driver can also be built as a module. If so, the module will
+ be called nvmem-apple-efuses.
+
endif
diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile
index 891958e29d25..00e136a0a123 100644
--- a/drivers/nvmem/Makefile
+++ b/drivers/nvmem/Makefile
@@ -65,3 +65,5 @@ obj-$(CONFIG_NVMEM_LAYERSCAPE_SFP) += nvmem-layerscape-sfp.o
nvmem-layerscape-sfp-y := layerscape-sfp.o
obj-$(CONFIG_NVMEM_SUNPLUS_OCOTP) += nvmem_sunplus_ocotp.o
nvmem_sunplus_ocotp-y := sunplus-ocotp.o
+obj-$(CONFIG_NVMEM_APPLE_EFUSES) += nvmem-apple-efuses.o
+nvmem-apple-efuses-y := apple-efuses.o
diff --git a/drivers/nvmem/apple-efuses.c b/drivers/nvmem/apple-efuses.c
new file mode 100644
index 000000000000..9b7c87102104
--- /dev/null
+++ b/drivers/nvmem/apple-efuses.c
@@ -0,0 +1,80 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Apple SoC eFuse driver
+ *
+ * Copyright (C) The Asahi Linux Contributors
+ */
+
+#include <linux/io.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/nvmem-provider.h>
+#include <linux/platform_device.h>
+
+struct apple_efuses_priv {
+ void __iomem *fuses;
+};
+
+static int apple_efuses_read(void *context, unsigned int offset, void *val,
+ size_t bytes)
+{
+ struct apple_efuses_priv *priv = context;
+ u32 *dst = val;
+
+ while (bytes >= sizeof(u32)) {
+ *dst++ = readl_relaxed(priv->fuses + offset);
+ bytes -= sizeof(u32);
+ offset += sizeof(u32);
+ }
+
+ return 0;
+}
+
+static int apple_efuses_probe(struct platform_device *pdev)
+{
+ struct apple_efuses_priv *priv;
+ struct resource *res;
+ struct nvmem_config config = {
+ .dev = &pdev->dev,
+ .read_only = true,
+ .reg_read = apple_efuses_read,
+ .stride = sizeof(u32),
+ .word_size = sizeof(u32),
+ .name = "apple_efuses_nvmem",
+ .id = NVMEM_DEVID_AUTO,
+ .root_only = true,
+ };
+
+ priv = devm_kzalloc(config.dev, sizeof(*priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ priv->fuses = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
+ if (IS_ERR(priv->fuses))
+ return PTR_ERR(priv->fuses);
+
+ config.priv = priv;
+ config.size = resource_size(res);
+
+ return PTR_ERR_OR_ZERO(devm_nvmem_register(config.dev, &config));
+}
+
+static const struct of_device_id apple_efuses_of_match[] = {
+ { .compatible = "apple,efuses", },
+ {}
+};
+
+MODULE_DEVICE_TABLE(of, apple_efuses_of_match);
+
+static struct platform_driver apple_efuses_driver = {
+ .driver = {
+ .name = "apple_efuses",
+ .of_match_table = apple_efuses_of_match,
+ },
+ .probe = apple_efuses_probe,
+};
+
+module_platform_driver(apple_efuses_driver);
+
+MODULE_AUTHOR("Sven Peter <sven@svenpeter.dev>");
+MODULE_LICENSE("GPL");
--
2.21.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 06/16] nvmem: bcm-ocotp: mark ACPI device ID table as maybe unused
2022-04-29 16:26 [PATCH 00/16] nvmem: patches (set 1) for 5.19 Srinivas Kandagatla
` (4 preceding siblings ...)
2022-04-29 16:26 ` [PATCH 05/16] nvmem: Add Apple eFuse driver Srinivas Kandagatla
@ 2022-04-29 16:26 ` Srinivas Kandagatla
2022-04-29 16:26 ` [PATCH 07/16] nvmem: sunplus-ocotp: drop useless probe confirmation Srinivas Kandagatla
` (10 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: Srinivas Kandagatla @ 2022-04-29 16:26 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, Krzysztof Kozlowski, Srinivas Kandagatla
From: Krzysztof Kozlowski <krzk@kernel.org>
"bcm_otpc_acpi_ids" is used with ACPI_PTR, so a build with !CONFIG_ACPI
has a warning:
drivers/nvmem/bcm-ocotp.c:247:36: error:
‘bcm_otpc_acpi_ids’ defined but not used [-Werror=unused-const-variable=]
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
drivers/nvmem/bcm-ocotp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvmem/bcm-ocotp.c b/drivers/nvmem/bcm-ocotp.c
index a8097511582a..dfea96c52463 100644
--- a/drivers/nvmem/bcm-ocotp.c
+++ b/drivers/nvmem/bcm-ocotp.c
@@ -244,7 +244,7 @@ static const struct of_device_id bcm_otpc_dt_ids[] = {
};
MODULE_DEVICE_TABLE(of, bcm_otpc_dt_ids);
-static const struct acpi_device_id bcm_otpc_acpi_ids[] = {
+static const struct acpi_device_id bcm_otpc_acpi_ids[] __maybe_unused = {
{ .id = "BRCM0700", .driver_data = (kernel_ulong_t)&otp_map },
{ .id = "BRCM0701", .driver_data = (kernel_ulong_t)&otp_map_v2 },
{ /* sentinel */ }
--
2.21.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 07/16] nvmem: sunplus-ocotp: drop useless probe confirmation
2022-04-29 16:26 [PATCH 00/16] nvmem: patches (set 1) for 5.19 Srinivas Kandagatla
` (5 preceding siblings ...)
2022-04-29 16:26 ` [PATCH 06/16] nvmem: bcm-ocotp: mark ACPI device ID table as maybe unused Srinivas Kandagatla
@ 2022-04-29 16:26 ` Srinivas Kandagatla
2022-04-29 16:26 ` [PATCH 08/16] nvmem: sunplus-ocotp: staticize sp_otp_v0 Srinivas Kandagatla
` (9 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: Srinivas Kandagatla @ 2022-04-29 16:26 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, Krzysztof Kozlowski, Srinivas Kandagatla
From: Krzysztof Kozlowski <krzk@kernel.org>
Printing probe success is discouraged, because we can use tracing for
this purpose. Remove useless print message after Sunplus OCOTP driver
probe.
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
drivers/nvmem/sunplus-ocotp.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/nvmem/sunplus-ocotp.c b/drivers/nvmem/sunplus-ocotp.c
index 2dc59c22eb55..81aba80bdd10 100644
--- a/drivers/nvmem/sunplus-ocotp.c
+++ b/drivers/nvmem/sunplus-ocotp.c
@@ -202,8 +202,6 @@ static int sp_ocotp_probe(struct platform_device *pdev)
(int)QAC628_OTP_NUM_BANKS, (int)OTP_WORDS_PER_BANK,
(int)OTP_WORD_SIZE, (int)QAC628_OTP_SIZE);
- dev_info(dev, "by Sunplus (C) 2020");
-
return 0;
}
--
2.21.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 08/16] nvmem: sunplus-ocotp: staticize sp_otp_v0
2022-04-29 16:26 [PATCH 00/16] nvmem: patches (set 1) for 5.19 Srinivas Kandagatla
` (6 preceding siblings ...)
2022-04-29 16:26 ` [PATCH 07/16] nvmem: sunplus-ocotp: drop useless probe confirmation Srinivas Kandagatla
@ 2022-04-29 16:26 ` Srinivas Kandagatla
2022-04-29 16:26 ` [PATCH 09/16] nvmem: qfprom: using pm_runtime_resume_and_get instead of pm_runtime_get_sync Srinivas Kandagatla
` (8 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: Srinivas Kandagatla @ 2022-04-29 16:26 UTC (permalink / raw)
To: gregkh
Cc: linux-kernel, Krzysztof Kozlowski, kernel test robot,
Srinivas Kandagatla
From: Krzysztof Kozlowski <krzk@kernel.org>
The "sp_otp_v0" file scope variable is not used outside, so make it
static to fix warning:
drivers/nvmem/sunplus-ocotp.c:74:29: sparse:
sparse: symbol 'sp_otp_v0' was not declared. Should it be static?
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
drivers/nvmem/sunplus-ocotp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvmem/sunplus-ocotp.c b/drivers/nvmem/sunplus-ocotp.c
index 81aba80bdd10..52b928a7a6d5 100644
--- a/drivers/nvmem/sunplus-ocotp.c
+++ b/drivers/nvmem/sunplus-ocotp.c
@@ -71,7 +71,7 @@ struct sp_ocotp_data {
int size;
};
-const struct sp_ocotp_data sp_otp_v0 = {
+static const struct sp_ocotp_data sp_otp_v0 = {
.size = QAC628_OTP_SIZE,
};
--
2.21.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 09/16] nvmem: qfprom: using pm_runtime_resume_and_get instead of pm_runtime_get_sync
2022-04-29 16:26 [PATCH 00/16] nvmem: patches (set 1) for 5.19 Srinivas Kandagatla
` (7 preceding siblings ...)
2022-04-29 16:26 ` [PATCH 08/16] nvmem: sunplus-ocotp: staticize sp_otp_v0 Srinivas Kandagatla
@ 2022-04-29 16:26 ` Srinivas Kandagatla
2022-04-29 16:26 ` [PATCH 10/16] nvmem: brcm_nvram: check for allocation failure Srinivas Kandagatla
` (7 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: Srinivas Kandagatla @ 2022-04-29 16:26 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, Minghao Chi, Zeal Robot, Srinivas Kandagatla
From: Minghao Chi <chi.minghao@zte.com.cn>
Using pm_runtime_resume_and_get is more appropriate
for simplifing code
Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
drivers/nvmem/qfprom.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/nvmem/qfprom.c b/drivers/nvmem/qfprom.c
index 162132c7dab9..c1e893c8a247 100644
--- a/drivers/nvmem/qfprom.c
+++ b/drivers/nvmem/qfprom.c
@@ -217,9 +217,8 @@ static int qfprom_enable_fuse_blowing(const struct qfprom_priv *priv,
goto err_clk_rate_set;
}
- ret = pm_runtime_get_sync(priv->dev);
+ ret = pm_runtime_resume_and_get(priv->dev);
if (ret < 0) {
- pm_runtime_put_noidle(priv->dev);
dev_err(priv->dev, "Failed to enable power-domain\n");
goto err_reg_enable;
}
--
2.21.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 10/16] nvmem: brcm_nvram: check for allocation failure
2022-04-29 16:26 [PATCH 00/16] nvmem: patches (set 1) for 5.19 Srinivas Kandagatla
` (8 preceding siblings ...)
2022-04-29 16:26 ` [PATCH 09/16] nvmem: qfprom: using pm_runtime_resume_and_get instead of pm_runtime_get_sync Srinivas Kandagatla
@ 2022-04-29 16:26 ` Srinivas Kandagatla
2022-04-29 16:26 ` [PATCH 11/16] dt-bindings: nvmem: sfp: Fix typo Srinivas Kandagatla
` (6 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: Srinivas Kandagatla @ 2022-04-29 16:26 UTC (permalink / raw)
To: gregkh
Cc: linux-kernel, Dan Carpenter, Rafał Miłecki,
Srinivas Kandagatla
From: Dan Carpenter <dan.carpenter@oracle.com>
Check for if the kcalloc() fails.
Fixes: 299dc152721f ("nvmem: brcm_nvram: parse NVRAM content into NVMEM cells")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Rafał Miłecki <rafal@milecki.pl>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
drivers/nvmem/brcm_nvram.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/nvmem/brcm_nvram.c b/drivers/nvmem/brcm_nvram.c
index 450b927691c3..48bb8c62cbbf 100644
--- a/drivers/nvmem/brcm_nvram.c
+++ b/drivers/nvmem/brcm_nvram.c
@@ -97,6 +97,8 @@ static int brcm_nvram_parse(struct brcm_nvram *priv)
len = le32_to_cpu(header.len);
data = kcalloc(1, len, GFP_KERNEL);
+ if (!data)
+ return -ENOMEM;
memcpy_fromio(data, priv->base, len);
data[len - 1] = '\0';
--
2.21.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 11/16] dt-bindings: nvmem: sfp: Fix typo
2022-04-29 16:26 [PATCH 00/16] nvmem: patches (set 1) for 5.19 Srinivas Kandagatla
` (9 preceding siblings ...)
2022-04-29 16:26 ` [PATCH 10/16] nvmem: brcm_nvram: check for allocation failure Srinivas Kandagatla
@ 2022-04-29 16:26 ` Srinivas Kandagatla
2022-04-29 16:26 ` [PATCH 12/16] dt-bindings: nvmem: sfp: Add clock properties Srinivas Kandagatla
` (5 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: Srinivas Kandagatla @ 2022-04-29 16:26 UTC (permalink / raw)
To: gregkh
Cc: linux-kernel, Sean Anderson, Michael Walle, Andrew Lunn,
Srinivas Kandagatla
From: Sean Anderson <sean.anderson@seco.com>
There is a small grammatical error in the description. Fix it.
Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Reviewed-by: Michael Walle <michael@walle.cc>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
Documentation/devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml b/Documentation/devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml
index 80914b93638e..b7798e903191 100644
--- a/Documentation/devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml
+++ b/Documentation/devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml
@@ -10,7 +10,7 @@ maintainers:
- Michael Walle <michael@walle.cc>
description: |
- SFP is the security fuse processor which among other things provide a
+ SFP is the security fuse processor which among other things provides a
unique identifier per part.
allOf:
--
2.21.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 12/16] dt-bindings: nvmem: sfp: Add clock properties
2022-04-29 16:26 [PATCH 00/16] nvmem: patches (set 1) for 5.19 Srinivas Kandagatla
` (10 preceding siblings ...)
2022-04-29 16:26 ` [PATCH 11/16] dt-bindings: nvmem: sfp: Fix typo Srinivas Kandagatla
@ 2022-04-29 16:26 ` Srinivas Kandagatla
2022-04-29 16:26 ` [PATCH 13/16] dt-bindings: nvmem: sfp: Add TA_PROG_SFP supply Srinivas Kandagatla
` (4 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: Srinivas Kandagatla @ 2022-04-29 16:26 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, Sean Anderson, Srinivas Kandagatla
From: Sean Anderson <sean.anderson@seco.com>
To program fuses, it is necessary to set the fuse programming time. This
is determined based on the value of the platform clock. Add a clock
property.
Because this property is necessary for programming, it is made
mandatory. Since these bindings have not yet been present in a stable
release (though they are on track for 5.18), it is not an ABI break to
change them in this manner.
Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
.../bindings/nvmem/fsl,layerscape-sfp.yaml | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/Documentation/devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml b/Documentation/devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml
index b7798e903191..54086f50157d 100644
--- a/Documentation/devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml
+++ b/Documentation/devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml
@@ -24,15 +24,29 @@ properties:
reg:
maxItems: 1
+ clocks:
+ maxItems: 1
+ description:
+ The SFP clock. Typically, this is the platform clock divided by 4.
+
+ clock-names:
+ const: sfp
+
required:
- compatible
- reg
+ - clock-names
+ - clocks
unevaluatedProperties: false
examples:
- |
+ #include <dt-bindings/clock/fsl,qoriq-clockgen.h>
efuse@1e80000 {
compatible = "fsl,ls1028a-sfp";
reg = <0x1e80000 0x8000>;
+ clocks = <&clockgen QORIQ_CLK_PLATFORM_PLL
+ QORIQ_CLK_PLL_DIV(4)>;
+ clock-names = "sfp";
};
--
2.21.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 13/16] dt-bindings: nvmem: sfp: Add TA_PROG_SFP supply
2022-04-29 16:26 [PATCH 00/16] nvmem: patches (set 1) for 5.19 Srinivas Kandagatla
` (11 preceding siblings ...)
2022-04-29 16:26 ` [PATCH 12/16] dt-bindings: nvmem: sfp: Add clock properties Srinivas Kandagatla
@ 2022-04-29 16:26 ` Srinivas Kandagatla
2022-04-29 16:26 ` [PATCH 14/16] dt-bindings: nvmem: sfp: Add compatible binding for TA 2.1 SFPs Srinivas Kandagatla
` (3 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: Srinivas Kandagatla @ 2022-04-29 16:26 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, Sean Anderson, Andrew Lunn, Srinivas Kandagatla
From: Sean Anderson <sean.anderson@seco.com>
The TA_PROG_SFP supply must be enabled to program the fuses, and
disabled to read the fuses (such as at power-on-reset). On many boards,
this supply is controlled by a jumper. The user must manually insert or
remove it at the appropriate time in the programming process. However,
on other boards this supply is controlled by an FPGA or a GPIO. In
these cases, the driver can automatically enable and disable it as
necessary.
Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
.../devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/Documentation/devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml b/Documentation/devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml
index 54086f50157d..c5d7375b840a 100644
--- a/Documentation/devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml
+++ b/Documentation/devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml
@@ -32,6 +32,11 @@ properties:
clock-names:
const: sfp
+ ta-prog-sfp-supply:
+ description:
+ The regulator for the TA_PROG_SFP pin. It will be enabled for programming
+ and disabled for reading.
+
required:
- compatible
- reg
--
2.21.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 14/16] dt-bindings: nvmem: sfp: Add compatible binding for TA 2.1 SFPs
2022-04-29 16:26 [PATCH 00/16] nvmem: patches (set 1) for 5.19 Srinivas Kandagatla
` (12 preceding siblings ...)
2022-04-29 16:26 ` [PATCH 13/16] dt-bindings: nvmem: sfp: Add TA_PROG_SFP supply Srinivas Kandagatla
@ 2022-04-29 16:26 ` Srinivas Kandagatla
2022-04-29 16:27 ` [PATCH 15/16] nvmem: sfp: Use regmap Srinivas Kandagatla
` (2 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: Srinivas Kandagatla @ 2022-04-29 16:26 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, Sean Anderson, Srinivas Kandagatla
From: Sean Anderson <sean.anderson@seco.com>
Trust Architecture (TA) 2.1 devices include the LS1012A, LS1021A,
LS1043A, and LS1046A. The SFP device on TA 2.1 devices is very similar
to the SFP on TA 3.0 devices. The primary difference is a few fields in
the control register. Add a compatible string.
Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
.../devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml b/Documentation/devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml
index c5d7375b840a..3b4e6e94cb81 100644
--- a/Documentation/devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml
+++ b/Documentation/devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml
@@ -18,8 +18,13 @@ allOf:
properties:
compatible:
- enum:
- - fsl,ls1028a-sfp
+ oneOf:
+ - description: Trust architecture 2.1 SFP
+ items:
+ - const: fsl,ls1021a-sfp
+ - description: Trust architecture 3.0 SFP
+ items:
+ - const: fsl,ls1028a-sfp
reg:
maxItems: 1
--
2.21.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 15/16] nvmem: sfp: Use regmap
2022-04-29 16:26 [PATCH 00/16] nvmem: patches (set 1) for 5.19 Srinivas Kandagatla
` (13 preceding siblings ...)
2022-04-29 16:26 ` [PATCH 14/16] dt-bindings: nvmem: sfp: Add compatible binding for TA 2.1 SFPs Srinivas Kandagatla
@ 2022-04-29 16:27 ` Srinivas Kandagatla
2022-04-29 16:27 ` [PATCH 16/16] nvmem: sfp: Add support for TA 2.1 devices Srinivas Kandagatla
2022-05-09 13:47 ` [PATCH 00/16] nvmem: patches (set 1) for 5.19 Greg KH
16 siblings, 0 replies; 19+ messages in thread
From: Srinivas Kandagatla @ 2022-04-29 16:27 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, Sean Anderson, Srinivas Kandagatla
From: Sean Anderson <sean.anderson@seco.com>
This converts the SFP driver to use regmap. This will allow easily
supporting devices with different endians. We disallow byte-level
access, as regmap_bulk_read doesn't support it (and it's unclear what
the correct result would be when we have an endianness difference).
Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
drivers/nvmem/Kconfig | 1 +
drivers/nvmem/layerscape-sfp.c | 30 ++++++++++++++++++++++--------
2 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig
index 6283e09cc1e9..967d0084800e 100644
--- a/drivers/nvmem/Kconfig
+++ b/drivers/nvmem/Kconfig
@@ -304,6 +304,7 @@ config NVMEM_LAYERSCAPE_SFP
tristate "Layerscape SFP (Security Fuse Processor) support"
depends on ARCH_LAYERSCAPE || COMPILE_TEST
depends on HAS_IOMEM
+ select REGMAP_MMIO
help
This driver provides support to read the eFuses on Freescale
Layerscape SoC's. For example, the vendor provides a per part
diff --git a/drivers/nvmem/layerscape-sfp.c b/drivers/nvmem/layerscape-sfp.c
index e591c1511e33..59083f048921 100644
--- a/drivers/nvmem/layerscape-sfp.c
+++ b/drivers/nvmem/layerscape-sfp.c
@@ -13,15 +13,17 @@
#include <linux/nvmem-provider.h>
#include <linux/platform_device.h>
#include <linux/property.h>
+#include <linux/regmap.h>
#define LAYERSCAPE_SFP_OTP_OFFSET 0x0200
struct layerscape_sfp_priv {
- void __iomem *base;
+ struct regmap *regmap;
};
struct layerscape_sfp_data {
int size;
+ enum regmap_endian endian;
};
static int layerscape_sfp_read(void *context, unsigned int offset, void *val,
@@ -29,15 +31,16 @@ static int layerscape_sfp_read(void *context, unsigned int offset, void *val,
{
struct layerscape_sfp_priv *priv = context;
- memcpy_fromio(val, priv->base + LAYERSCAPE_SFP_OTP_OFFSET + offset,
- bytes);
-
- return 0;
+ return regmap_bulk_read(priv->regmap,
+ LAYERSCAPE_SFP_OTP_OFFSET + offset, val,
+ bytes / 4);
}
static struct nvmem_config layerscape_sfp_nvmem_config = {
.name = "fsl-sfp",
.reg_read = layerscape_sfp_read,
+ .word_size = 4,
+ .stride = 4,
};
static int layerscape_sfp_probe(struct platform_device *pdev)
@@ -45,16 +48,26 @@ static int layerscape_sfp_probe(struct platform_device *pdev)
const struct layerscape_sfp_data *data;
struct layerscape_sfp_priv *priv;
struct nvmem_device *nvmem;
+ struct regmap_config config = { 0 };
+ void __iomem *base;
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
- priv->base = devm_platform_ioremap_resource(pdev, 0);
- if (IS_ERR(priv->base))
- return PTR_ERR(priv->base);
+ base = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(base))
+ return PTR_ERR(base);
data = device_get_match_data(&pdev->dev);
+ config.reg_bits = 32;
+ config.reg_stride = 4;
+ config.val_bits = 32;
+ config.val_format_endian = data->endian;
+ config.max_register = LAYERSCAPE_SFP_OTP_OFFSET + data->size - 4;
+ priv->regmap = devm_regmap_init_mmio(&pdev->dev, base, &config);
+ if (IS_ERR(priv->regmap))
+ return PTR_ERR(priv->regmap);
layerscape_sfp_nvmem_config.size = data->size;
layerscape_sfp_nvmem_config.dev = &pdev->dev;
@@ -67,6 +80,7 @@ static int layerscape_sfp_probe(struct platform_device *pdev)
static const struct layerscape_sfp_data ls1028a_data = {
.size = 0x88,
+ .endian = REGMAP_ENDIAN_LITTLE,
};
static const struct of_device_id layerscape_sfp_dt_ids[] = {
--
2.21.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 16/16] nvmem: sfp: Add support for TA 2.1 devices
2022-04-29 16:26 [PATCH 00/16] nvmem: patches (set 1) for 5.19 Srinivas Kandagatla
` (14 preceding siblings ...)
2022-04-29 16:27 ` [PATCH 15/16] nvmem: sfp: Use regmap Srinivas Kandagatla
@ 2022-04-29 16:27 ` Srinivas Kandagatla
2022-05-09 13:47 ` [PATCH 00/16] nvmem: patches (set 1) for 5.19 Greg KH
16 siblings, 0 replies; 19+ messages in thread
From: Srinivas Kandagatla @ 2022-04-29 16:27 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, Sean Anderson, Srinivas Kandagatla
From: Sean Anderson <sean.anderson@seco.com>
This adds support for Trust Architecture (TA) 2.1 devices to the SFP driver.
There are few differences between TA 2.1 and TA 3.0, especially for
read-only support, so just re-use the existing data.
Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
drivers/nvmem/layerscape-sfp.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/nvmem/layerscape-sfp.c b/drivers/nvmem/layerscape-sfp.c
index 59083f048921..e2b424561949 100644
--- a/drivers/nvmem/layerscape-sfp.c
+++ b/drivers/nvmem/layerscape-sfp.c
@@ -78,12 +78,18 @@ static int layerscape_sfp_probe(struct platform_device *pdev)
return PTR_ERR_OR_ZERO(nvmem);
}
+static const struct layerscape_sfp_data ls1021a_data = {
+ .size = 0x88,
+ .endian = REGMAP_ENDIAN_BIG,
+};
+
static const struct layerscape_sfp_data ls1028a_data = {
.size = 0x88,
.endian = REGMAP_ENDIAN_LITTLE,
};
static const struct of_device_id layerscape_sfp_dt_ids[] = {
+ { .compatible = "fsl,ls1021a-sfp", .data = &ls1021a_data },
{ .compatible = "fsl,ls1028a-sfp", .data = &ls1028a_data },
{},
};
--
2.21.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH 00/16] nvmem: patches (set 1) for 5.19
2022-04-29 16:26 [PATCH 00/16] nvmem: patches (set 1) for 5.19 Srinivas Kandagatla
` (15 preceding siblings ...)
2022-04-29 16:27 ` [PATCH 16/16] nvmem: sfp: Add support for TA 2.1 devices Srinivas Kandagatla
@ 2022-05-09 13:47 ` Greg KH
2022-05-10 9:29 ` Srinivas Kandagatla
16 siblings, 1 reply; 19+ messages in thread
From: Greg KH @ 2022-05-09 13:47 UTC (permalink / raw)
To: Srinivas Kandagatla; +Cc: linux-kernel
On Fri, Apr 29, 2022 at 05:26:45PM +0100, Srinivas Kandagatla wrote:
> Hi Greg,
>
> Here are some nvmem patches for 5.19 which includes
>
> - new nvmem provider for Apple efuses.
> - support for regmap and TA 2.1 devices in sfp provider
> - add device tree node support in nvmem cell info
> - brcm_nvram provider to parse cells from dt.
> - few minor clean ups in qfprom, bcm-ocotp and sunplus-ocotp
>
> Can you please queue them up for 5.19.
Not all of these applied cleanly. Can you please rebase and resend the
remaining ones?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 00/16] nvmem: patches (set 1) for 5.19
2022-05-09 13:47 ` [PATCH 00/16] nvmem: patches (set 1) for 5.19 Greg KH
@ 2022-05-10 9:29 ` Srinivas Kandagatla
0 siblings, 0 replies; 19+ messages in thread
From: Srinivas Kandagatla @ 2022-05-10 9:29 UTC (permalink / raw)
To: Greg KH; +Cc: linux-kernel
On 09/05/2022 14:47, Greg KH wrote:
> On Fri, Apr 29, 2022 at 05:26:45PM +0100, Srinivas Kandagatla wrote:
>> Hi Greg,
>>
>> Here are some nvmem patches for 5.19 which includes
>>
>> - new nvmem provider for Apple efuses.
>> - support for regmap and TA 2.1 devices in sfp provider
>> - add device tree node support in nvmem cell info
>> - brcm_nvram provider to parse cells from dt.
>> - few minor clean ups in qfprom, bcm-ocotp and sunplus-ocotp
>>
>> Can you please queue them up for 5.19.
>
> Not all of these applied cleanly. Can you please rebase and resend the
> remaining ones?
Sure, looks like there is only one patch("nvmem: brcm_nvram: check for
allocation failure") that needs to be resent and I confirmed that all
the other patches are already applied.
will resend that one.
--srini
>
> thanks,
>
> greg k-h
^ permalink raw reply [flat|nested] 19+ messages in thread