[RFC PATCH 1/1] nvmem: microchip-otpc: Add support for SAM9X60
Alexander Dahl
ada at thorsis.com
Fri Apr 12 07:08:02 PDT 2024
---
.../dts/microchip/at91-sam9x60_curiosity.dts | 4 ++++
arch/arm/boot/dts/microchip/sam9x60.dtsi | 7 +++++++
drivers/nvmem/microchip-otpc.c | 16 +++++++++++++---
3 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/arch/arm/boot/dts/microchip/at91-sam9x60_curiosity.dts b/arch/arm/boot/dts/microchip/at91-sam9x60_curiosity.dts
index c6fbdd29019f..754ce8134f73 100644
--- a/arch/arm/boot/dts/microchip/at91-sam9x60_curiosity.dts
+++ b/arch/arm/boot/dts/microchip/at91-sam9x60_curiosity.dts
@@ -254,6 +254,10 @@ ethernet-phy at 0 {
};
};
+&otpc {
+ status = "okay";
+};
+
&pinctrl {
adc {
pinctrl_adc_default: adc-default {
diff --git a/arch/arm/boot/dts/microchip/sam9x60.dtsi b/arch/arm/boot/dts/microchip/sam9x60.dtsi
index 291540e5d81e..010c45f533fe 100644
--- a/arch/arm/boot/dts/microchip/sam9x60.dtsi
+++ b/arch/arm/boot/dts/microchip/sam9x60.dtsi
@@ -156,6 +156,13 @@ sdmmc1: sdio-host at 90000000 {
status = "disabled";
};
+ otpc: efuse at eff00000 {
+ compatible = "microchip,sam9x60-otpc", "syscon";
+ reg = <0xeff00000 0xec>;
+ #address-cells = <1>;
+ #size-cells = <1>;
+ };
+
apb {
compatible = "simple-bus";
#address-cells = <1>;
diff --git a/drivers/nvmem/microchip-otpc.c b/drivers/nvmem/microchip-otpc.c
index 7cf81738a3e0..af9ab1158a2b 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>
@@ -248,29 +249,38 @@ static int mchp_otpc_probe(struct platform_device *pdev)
int ret;
otpc = devm_kzalloc(&pdev->dev, sizeof(*otpc), GFP_KERNEL);
- if (!otpc)
+ if (!otpc) {
+ dev_err(&pdev->dev, "devm_kzalloc() error\n");
return -ENOMEM;
+ }
otpc->base = devm_platform_ioremap_resource(pdev, 0);
- if (IS_ERR(otpc->base))
+ if (IS_ERR(otpc->base)) {
+ dev_err(&pdev->dev, "devm_platform_ioremap_resource() error\n");
return PTR_ERR(otpc->base);
+ }
otpc->dev = &pdev->dev;
ret = mchp_otpc_init_packets_list(otpc, &size);
- if (ret)
+ if (ret) {
+ dev_err(&pdev->dev, "mchp_otpc_init_packets_list() error (%d)\n", ret);
return ret;
+ }
mchp_nvmem_config.dev = otpc->dev;
mchp_nvmem_config.add_legacy_fixed_of_cells = true;
mchp_nvmem_config.size = size;
mchp_nvmem_config.priv = otpc;
nvmem = devm_nvmem_register(&pdev->dev, &mchp_nvmem_config);
+ if (!nvmem)
+ dev_err(&pdev->dev, "devm_nvmem_register() error\n");
return PTR_ERR_OR_ZERO(nvmem);
}
static const struct of_device_id __maybe_unused mchp_otpc_ids[] = {
{ .compatible = "microchip,sama7g5-otpc", },
+ { .compatible = "microchip,sam9x60-otpc", },
{ },
};
MODULE_DEVICE_TABLE(of, mchp_otpc_ids);
--
2.39.2
More information about the linux-arm-kernel
mailing list