Skip to content

Commit 0861110

Browse files
ricalgregkh
authored andcommitted
nvmem: add new NXP QorIQ eFuse driver
Add SFP (Security Fuse Processor) read support for NXP (Freescale) QorIQ series SOC's. This patch adds support for the T1023 SOC using the SFP offset from the existing T1023 device tree. In theory this should also work for T1024, T1014 and T1013 which uses the same SFP base offset. Signed-off-by: Richard Alpe <[email protected]> Reviewed-by: Niklas Söderlund <[email protected]> Signed-off-by: Srinivas Kandagatla <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent aa1ed60 commit 0861110

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed

drivers/nvmem/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,4 +392,16 @@ config NVMEM_ZYNQMP
392392

393393
If sure, say yes. If unsure, say no.
394394

395+
config NVMEM_QORIQ_EFUSE
396+
tristate "NXP QorIQ eFuse support"
397+
depends on PPC_85xx || COMPILE_TEST
398+
depends on HAS_IOMEM
399+
help
400+
This driver provides read support for the eFuses (SFP) on NXP QorIQ
401+
series SoC's. This includes secure boot settings, the globally unique
402+
NXP ID 'FUIDR' and the OEM unique ID 'OUIDR'.
403+
404+
This driver can also be built as a module. If so, the module
405+
will be called nvmem_qoriq_efuse.
406+
395407
endif

drivers/nvmem/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,5 @@ obj-$(CONFIG_NVMEM_VF610_OCOTP) += nvmem-vf610-ocotp.o
7777
nvmem-vf610-ocotp-y := vf610-ocotp.o
7878
obj-$(CONFIG_NVMEM_ZYNQMP) += nvmem_zynqmp_nvmem.o
7979
nvmem_zynqmp_nvmem-y := zynqmp_nvmem.o
80+
obj-$(CONFIG_NVMEM_QORIQ_EFUSE) += nvmem-qoriq-efuse.o
81+
nvmem-qoriq-efuse-y := qoriq-efuse.o

drivers/nvmem/qoriq-efuse.c

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Copyright (C) 2023 Westermo Network Technologies AB
4+
*/
5+
6+
#include <linux/device.h>
7+
#include <linux/io.h>
8+
#include <linux/module.h>
9+
#include <linux/mod_devicetable.h>
10+
#include <linux/nvmem-provider.h>
11+
#include <linux/platform_device.h>
12+
13+
struct qoriq_efuse_priv {
14+
void __iomem *base;
15+
};
16+
17+
static int qoriq_efuse_read(void *context, unsigned int offset, void *val,
18+
size_t bytes)
19+
{
20+
struct qoriq_efuse_priv *priv = context;
21+
22+
/* .stride = 4 so offset is guaranteed to be aligned */
23+
__ioread32_copy(val, priv->base + offset, bytes / 4);
24+
25+
/* Ignore trailing bytes (there shouldn't be any) */
26+
27+
return 0;
28+
}
29+
30+
static int qoriq_efuse_probe(struct platform_device *pdev)
31+
{
32+
struct nvmem_config config = {
33+
.dev = &pdev->dev,
34+
.read_only = true,
35+
.reg_read = qoriq_efuse_read,
36+
.stride = sizeof(u32),
37+
.word_size = sizeof(u32),
38+
.name = "qoriq_efuse_read",
39+
.id = NVMEM_DEVID_AUTO,
40+
.root_only = true,
41+
};
42+
struct qoriq_efuse_priv *priv;
43+
struct nvmem_device *nvmem;
44+
struct resource *res;
45+
46+
priv = devm_kzalloc(config.dev, sizeof(*priv), GFP_KERNEL);
47+
if (!priv)
48+
return -ENOMEM;
49+
50+
priv->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
51+
if (IS_ERR(priv->base))
52+
return PTR_ERR(priv->base);
53+
54+
config.size = resource_size(res);
55+
config.priv = priv;
56+
nvmem = devm_nvmem_register(config.dev, &config);
57+
58+
return PTR_ERR_OR_ZERO(nvmem);
59+
}
60+
61+
static const struct of_device_id qoriq_efuse_of_match[] = {
62+
{ .compatible = "fsl,t1023-sfp", },
63+
{/* sentinel */},
64+
};
65+
MODULE_DEVICE_TABLE(of, qoriq_efuse_of_match);
66+
67+
static struct platform_driver qoriq_efuse_driver = {
68+
.probe = qoriq_efuse_probe,
69+
.driver = {
70+
.name = "qoriq-efuse",
71+
.of_match_table = qoriq_efuse_of_match,
72+
},
73+
};
74+
module_platform_driver(qoriq_efuse_driver);
75+
76+
MODULE_AUTHOR("Richard Alpe <[email protected]>");
77+
MODULE_DESCRIPTION("NXP QorIQ Security Fuse Processor (SFP) Reader");
78+
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)