2022-05-01 10:37:49

by Srinivas Kandagatla

[permalink] [raw]
Subject: [PATCH 00/16] nvmem: patches (set 1) for 5.19

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.

thanks for you help,
srini

Dan Carpenter (1):
nvmem: brcm_nvram: check for allocation failure

Krzysztof Kozlowski (3):
nvmem: bcm-ocotp: mark ACPI device ID table as maybe unused
nvmem: sunplus-ocotp: drop useless probe confirmation
nvmem: sunplus-ocotp: staticize sp_otp_v0

Minghao Chi (1):
nvmem: qfprom: using pm_runtime_resume_and_get instead of
pm_runtime_get_sync

Rafał Miłecki (2):
nvmem: core: support passing DT node in cell info
nvmem: brcm_nvram: find Device Tree nodes for NVMEM cells

Sean Anderson (6):
dt-bindings: nvmem: sfp: Fix typo
dt-bindings: nvmem: sfp: Add clock properties
dt-bindings: nvmem: sfp: Add TA_PROG_SFP supply
dt-bindings: nvmem: sfp: Add compatible binding for TA 2.1 SFPs
nvmem: sfp: Use regmap
nvmem: sfp: Add support for TA 2.1 devices

Sven Peter (3):
MAINTAINERS: Add apple efuses nvmem files to ARM/APPLE MACHINE
dt-bindings: nvmem: Add apple,efuses
nvmem: Add Apple eFuse driver

.../bindings/nvmem/apple,efuses.yaml | 50 ++++++++++++
.../bindings/nvmem/fsl,layerscape-sfp.yaml | 30 ++++++-
MAINTAINERS | 2 +
drivers/nvmem/Kconfig | 13 +++
drivers/nvmem/Makefile | 2 +
drivers/nvmem/apple-efuses.c | 80 +++++++++++++++++++
drivers/nvmem/bcm-ocotp.c | 2 +-
drivers/nvmem/brcm_nvram.c | 4 +
drivers/nvmem/core.c | 1 +
drivers/nvmem/layerscape-sfp.c | 36 +++++++--
drivers/nvmem/qfprom.c | 3 +-
drivers/nvmem/sunplus-ocotp.c | 4 +-
include/linux/nvmem-consumer.h | 1 +
13 files changed, 211 insertions(+), 17 deletions(-)
create mode 100644 Documentation/devicetree/bindings/nvmem/apple,efuses.yaml
create mode 100644 drivers/nvmem/apple-efuses.c

--
2.21.0


2022-05-02 17:46:08

by Srinivas Kandagatla

[permalink] [raw]
Subject: [PATCH 10/16] nvmem: brcm_nvram: check for allocation failure

From: Dan Carpenter <[email protected]>

Check for if the kcalloc() fails.

Fixes: 299dc152721f ("nvmem: brcm_nvram: parse NVRAM content into NVMEM cells")
Signed-off-by: Dan Carpenter <[email protected]>
Acked-by: Rafał Miłecki <[email protected]>
Signed-off-by: Srinivas Kandagatla <[email protected]>
---
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

2022-05-02 22:43:27

by Srinivas Kandagatla

[permalink] [raw]
Subject: [PATCH 05/16] nvmem: Add Apple eFuse driver

From: Sven Peter <[email protected]>

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 <[email protected]>
Signed-off-by: Srinivas Kandagatla <[email protected]>
---
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 <[email protected]>");
+MODULE_LICENSE("GPL");
--
2.21.0

2022-05-02 23:06:09

by Srinivas Kandagatla

[permalink] [raw]
Subject: [PATCH 01/16] nvmem: core: support passing DT node in cell info

From: Rafał Miłecki <[email protected]>

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 <[email protected]>
Signed-off-by: Srinivas Kandagatla <[email protected]>
---
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

2022-05-02 23:08:25

by Srinivas Kandagatla

[permalink] [raw]
Subject: [PATCH 16/16] nvmem: sfp: Add support for TA 2.1 devices

From: Sean Anderson <[email protected]>

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 <[email protected]>
Signed-off-by: Srinivas Kandagatla <[email protected]>
---
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

2022-05-02 23:11:20

by Srinivas Kandagatla

[permalink] [raw]
Subject: [PATCH 11/16] dt-bindings: nvmem: sfp: Fix typo

From: Sean Anderson <[email protected]>

There is a small grammatical error in the description. Fix it.

Signed-off-by: Sean Anderson <[email protected]>
Reviewed-by: Michael Walle <[email protected]>
Reviewed-by: Andrew Lunn <[email protected]>
Signed-off-by: Srinivas Kandagatla <[email protected]>
---
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 <[email protected]>

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

2022-05-02 23:18:58

by Srinivas Kandagatla

[permalink] [raw]
Subject: [PATCH 08/16] nvmem: sunplus-ocotp: staticize sp_otp_v0

From: Krzysztof Kozlowski <[email protected]>

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 <[email protected]>
Signed-off-by: Krzysztof Kozlowski <[email protected]>
Signed-off-by: Srinivas Kandagatla <[email protected]>
---
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

2022-05-02 23:22:21

by Srinivas Kandagatla

[permalink] [raw]
Subject: [PATCH 04/16] dt-bindings: nvmem: Add apple,efuses

From: Sven Peter <[email protected]>

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 <[email protected]>
Acked-by: Rob Herring <[email protected]>
Signed-off-by: Sven Peter <[email protected]>
Signed-off-by: Srinivas Kandagatla <[email protected]>
---
.../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 <[email protected]>
+
+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

2022-05-02 23:58:14

by Srinivas Kandagatla

[permalink] [raw]
Subject: [PATCH 13/16] dt-bindings: nvmem: sfp: Add TA_PROG_SFP supply

From: Sean Anderson <[email protected]>

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 <[email protected]>
Reviewed-by: Andrew Lunn <[email protected]>
Signed-off-by: Srinivas Kandagatla <[email protected]>
---
.../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

2022-05-03 00:45:18

by Srinivas Kandagatla

[permalink] [raw]
Subject: [PATCH 02/16] nvmem: brcm_nvram: find Device Tree nodes for NVMEM cells

From: Rafał Miłecki <[email protected]>

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 <[email protected]>
Signed-off-by: Srinivas Kandagatla <[email protected]>
---
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

2022-05-03 00:49:10

by Srinivas Kandagatla

[permalink] [raw]
Subject: [PATCH 14/16] dt-bindings: nvmem: sfp: Add compatible binding for TA 2.1 SFPs

From: Sean Anderson <[email protected]>

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 <[email protected]>
Signed-off-by: Srinivas Kandagatla <[email protected]>
---
.../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

2022-05-03 01:17:21

by Srinivas Kandagatla

[permalink] [raw]
Subject: [PATCH 15/16] nvmem: sfp: Use regmap

From: Sean Anderson <[email protected]>

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 <[email protected]>
Signed-off-by: Srinivas Kandagatla <[email protected]>
---
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

2022-05-09 13:59:38

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 00/16] nvmem: patches (set 1) for 5.19

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

2022-05-10 12:18:13

by Srinivas Kandagatla

[permalink] [raw]
Subject: Re: [PATCH 00/16] nvmem: patches (set 1) for 5.19



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