[PATCH v1 08/12] nvmem: microchip-otpc: Add warnings for bad OTPC conditions on probe

Alexander Dahl ada at thorsis.com
Wed Aug 21 03:59:39 PDT 2024


These conditions could affect correct function of the driver.

Signed-off-by: Alexander Dahl <ada at thorsis.com>
---
 drivers/nvmem/microchip-otpc.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/nvmem/microchip-otpc.c b/drivers/nvmem/microchip-otpc.c
index 4630e96243ac..a80535c3d162 100644
--- a/drivers/nvmem/microchip-otpc.c
+++ b/drivers/nvmem/microchip-otpc.c
@@ -8,6 +8,7 @@
  */
 
 #include <linux/bitfield.h>
+#include <linux/dev_printk.h>
 #include <linux/iopoll.h>
 #include <linux/module.h>
 #include <linux/nvmem-provider.h>
@@ -260,6 +261,7 @@ static int mchp_otpc_probe(struct platform_device *pdev)
 	struct nvmem_device *nvmem;
 	struct mchp_otpc *otpc;
 	u32 size;
+	u32 reg;
 	int ret;
 
 	otpc = devm_kzalloc(&pdev->dev, sizeof(*otpc), GFP_KERNEL);
@@ -270,6 +272,16 @@ static int mchp_otpc_probe(struct platform_device *pdev)
 	if (IS_ERR(otpc->base))
 		return PTR_ERR(otpc->base);
 
+	reg = readl_relaxed(otpc->base + MCHP_OTPC_WPSR);
+	if (reg)
+		dev_warn(&pdev->dev,
+			 "Write Protection Status Register Bit set: 0x%08x\n", reg);
+
+	reg = readl_relaxed(otpc->base + MCHP_OTPC_ISR);
+	if (reg & MCHP_OTPC_ISR_COERR)
+		dev_warn(&pdev->dev,
+			 "A corruption occurred since the last read of OTPC_ISR.\n");
+
 	otpc->dev = &pdev->dev;
 	ret = mchp_otpc_init_packets_list(otpc, &size);
 	if (ret)
-- 
2.39.2




More information about the linux-arm-kernel mailing list