[PATCH 2/2] soc: nxp: Add a simple NXP LPC32xx socinfo driver

Vladimir Zapolskiy posted 2 patches 1 month, 1 week ago
[PATCH 2/2] soc: nxp: Add a simple NXP LPC32xx socinfo driver
Posted by Vladimir Zapolskiy 1 month, 1 week ago
Add NXP LPC32xx specific driver to get unique SoC ID from System Control
Block registers and export it to userspace.

Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
---
 drivers/soc/Kconfig           |   1 +
 drivers/soc/Makefile          |   1 +
 drivers/soc/nxp/Kconfig       |  16 +++++
 drivers/soc/nxp/Makefile      |   2 +
 drivers/soc/nxp/lpc32xx-soc.c | 114 ++++++++++++++++++++++++++++++++++
 5 files changed, 134 insertions(+)
 create mode 100644 drivers/soc/nxp/Kconfig
 create mode 100644 drivers/soc/nxp/Makefile
 create mode 100644 drivers/soc/nxp/lpc32xx-soc.c

diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig
index a2d65adffb80..c21b0d2f58fc 100644
--- a/drivers/soc/Kconfig
+++ b/drivers/soc/Kconfig
@@ -18,6 +18,7 @@ source "drivers/soc/loongson/Kconfig"
 source "drivers/soc/mediatek/Kconfig"
 source "drivers/soc/microchip/Kconfig"
 source "drivers/soc/nuvoton/Kconfig"
+source "drivers/soc/nxp/Kconfig"
 source "drivers/soc/pxa/Kconfig"
 source "drivers/soc/qcom/Kconfig"
 source "drivers/soc/renesas/Kconfig"
diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile
index 47a3925ff84c..a04c21a8a5a4 100644
--- a/drivers/soc/Makefile
+++ b/drivers/soc/Makefile
@@ -24,6 +24,7 @@ obj-y				+= loongson/
 obj-y				+= mediatek/
 obj-y				+= microchip/
 obj-y				+= nuvoton/
+obj-y				+= nxp/
 obj-y				+= pxa/
 obj-y				+= qcom/
 obj-y				+= renesas/
diff --git a/drivers/soc/nxp/Kconfig b/drivers/soc/nxp/Kconfig
new file mode 100644
index 000000000000..84be69272011
--- /dev/null
+++ b/drivers/soc/nxp/Kconfig
@@ -0,0 +1,16 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+if ARCH_LPC32XX || COMPILE_TEST
+
+menu "NXP LPC32xx SoC drivers"
+
+config LPC32XX_SOCINFO
+	tristate "NXP LPC32xx SoC information driver"
+	default ARCH_LPC32XX
+	select SOC_BUS
+	help
+	  NXP LPC32xx specific driver to get unique SoC ID from SCB registers.
+
+endmenu
+
+endif
diff --git a/drivers/soc/nxp/Makefile b/drivers/soc/nxp/Makefile
new file mode 100644
index 000000000000..466fbf946dee
--- /dev/null
+++ b/drivers/soc/nxp/Makefile
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0-only
+obj-$(CONFIG_LPC32XX_SOCINFO) += lpc32xx-soc.o
diff --git a/drivers/soc/nxp/lpc32xx-soc.c b/drivers/soc/nxp/lpc32xx-soc.c
new file mode 100644
index 000000000000..06b10310da76
--- /dev/null
+++ b/drivers/soc/nxp/lpc32xx-soc.c
@@ -0,0 +1,114 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2025 Vladimir Zapolskiy <vz@mleia.com>
+ */
+
+#include <linux/mfd/syscon.h>
+#include <linux/of_address.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/sys_soc.h>
+
+#define SERIAL_ID0	0x130
+
+static int lpc32xx_soc_probe(struct platform_device *pdev)
+{
+	struct soc_device_attribute *soc_dev_attr;
+	struct device *dev = &pdev->dev;
+	struct soc_device *soc_dev;
+	struct regmap *scb;
+	u32 serial_id[4];
+	int ret;
+
+	soc_dev_attr = devm_kzalloc(dev, sizeof(*soc_dev_attr), GFP_KERNEL);
+	if (!soc_dev_attr)
+		return -ENOMEM;
+
+	soc_dev_attr->family = "NXP LPC32xx";
+
+	ret = of_property_read_string(of_root, "model", &soc_dev_attr->machine);
+	if (ret)
+		return ret;
+
+	scb = syscon_regmap_lookup_by_compatible("nxp,lpc3220-scb");
+	if (!IS_ERR(scb)) {
+		/* Do not bail out on error, if SCB device tree node is found */
+		ret = regmap_bulk_read(scb, SERIAL_ID0, serial_id, 4);
+		if (ret)
+			return ret;
+
+		soc_dev_attr->serial_number = devm_kasprintf(dev, GFP_KERNEL,
+							     "%08x%08x%08x%08x",
+							     serial_id[3],
+							     serial_id[2],
+							     serial_id[1],
+							     serial_id[0]);
+		if (!soc_dev_attr->serial_number)
+			return -ENOMEM;
+	} else {
+		dev_info(dev, "failed to get SCB regmap: %ld\n", PTR_ERR(scb));
+	}
+
+	soc_dev = soc_device_register(soc_dev_attr);
+	if (IS_ERR(soc_dev))
+		return PTR_ERR(soc_dev);
+
+	platform_set_drvdata(pdev, soc_dev);
+
+	return 0;
+}
+
+static void lpc32xx_soc_remove(struct platform_device *pdev)
+{
+	struct soc_device *soc_dev = platform_get_drvdata(pdev);
+
+	soc_device_unregister(soc_dev);
+}
+
+static const struct of_device_id lpc32xx_soc[] = {
+	{ .compatible = "nxp,lpc3220", },
+	{ .compatible = "nxp,lpc3230", },
+	{ .compatible = "nxp,lpc3240", },
+	{ .compatible = "nxp,lpc3250", },
+	{ }
+};
+
+static struct platform_driver lpc32xx_soc_driver = {
+	.probe = lpc32xx_soc_probe,
+	.remove = lpc32xx_soc_remove,
+	.driver = {
+		.name = "lpc32xx-soc",
+		.of_match_table = lpc32xx_soc,
+	},
+};
+
+static int __init lpc32xx_soc_device_init(void)
+{
+	struct platform_device *pdev;
+	int ret;
+
+	if (!of_match_node(lpc32xx_soc, of_root))
+		return 0;
+
+	ret = platform_driver_register(&lpc32xx_soc_driver);
+	if (ret) {
+		pr_info("Failed to register lpc32xx-soc platform driver: %d\n",
+			ret);
+		return ret;
+	}
+
+	pdev = platform_device_register_simple("lpc32xx-soc", -1, NULL, 0);
+	if (IS_ERR(pdev)) {
+		pr_info("Failed to register lpc32xx-soc platform device: %ld\n",
+			PTR_ERR(pdev));
+		platform_driver_unregister(&lpc32xx_soc_driver);
+		return PTR_ERR(pdev);
+	};
+
+	return 0;
+}
+device_initcall(lpc32xx_soc_device_init);
+
+MODULE_AUTHOR("Vladimir Zapolskiy <vz@mleia.com>");
+MODULE_DESCRIPTION("NXP LPC32xx SoC driver");
+MODULE_LICENSE("GPL");
-- 
2.43.0
Re: [PATCH 2/2] soc: nxp: Add a simple NXP LPC32xx socinfo driver
Posted by Krzysztof Kozlowski 1 month, 1 week ago
On 02/01/2026 00:56, Vladimir Zapolskiy wrote:
> Add NXP LPC32xx specific driver to get unique SoC ID from System Control
> Block registers and export it to userspace.
> 
> Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
> ---
>  drivers/soc/Kconfig           |   1 +
>  drivers/soc/Makefile          |   1 +
>  drivers/soc/nxp/Kconfig       |  16 +++++
>  drivers/soc/nxp/Makefile      |   2 +
>  drivers/soc/nxp/lpc32xx-soc.c | 114 ++++++++++++++++++++++++++++++++++
>  5 files changed, 134 insertions(+)
>  create mode 100644 drivers/soc/nxp/Kconfig
>  create mode 100644 drivers/soc/nxp/Makefile
>  create mode 100644 drivers/soc/nxp/lpc32xx-soc.c
> 
> diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig
> index a2d65adffb80..c21b0d2f58fc 100644
> --- a/drivers/soc/Kconfig
> +++ b/drivers/soc/Kconfig
> @@ -18,6 +18,7 @@ source "drivers/soc/loongson/Kconfig"
>  source "drivers/soc/mediatek/Kconfig"
>  source "drivers/soc/microchip/Kconfig"
>  source "drivers/soc/nuvoton/Kconfig"
> +source "drivers/soc/nxp/Kconfig"
>  source "drivers/soc/pxa/Kconfig"
>  source "drivers/soc/qcom/Kconfig"
>  source "drivers/soc/renesas/Kconfig"
> diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile
> index 47a3925ff84c..a04c21a8a5a4 100644
> --- a/drivers/soc/Makefile
> +++ b/drivers/soc/Makefile
> @@ -24,6 +24,7 @@ obj-y				+= loongson/
>  obj-y				+= mediatek/
>  obj-y				+= microchip/
>  obj-y				+= nuvoton/
> +obj-y				+= nxp/
>  obj-y				+= pxa/
>  obj-y				+= qcom/
>  obj-y				+= renesas/

Missing maintainers entry.


> +
> +static int lpc32xx_soc_probe(struct platform_device *pdev)
> +{
> +	struct soc_device_attribute *soc_dev_attr;
> +	struct device *dev = &pdev->dev;
> +	struct soc_device *soc_dev;
> +	struct regmap *scb;
> +	u32 serial_id[4];
> +	int ret;
> +
> +	soc_dev_attr = devm_kzalloc(dev, sizeof(*soc_dev_attr), GFP_KERNEL);
> +	if (!soc_dev_attr)
> +		return -ENOMEM;
> +
> +	soc_dev_attr->family = "NXP LPC32xx";
> +
> +	ret = of_property_read_string(of_root, "model", &soc_dev_attr->machine);
> +	if (ret)
> +		return ret;
> +
> +	scb = syscon_regmap_lookup_by_compatible("nxp,lpc3220-scb");

This is undocumented ABI.

Anyway, you should look up devices via phandles.


Best regards,
Krzysztof
Re: [PATCH 2/2] soc: nxp: Add a simple NXP LPC32xx socinfo driver
Posted by Vladimir Zapolskiy 1 month, 1 week ago
On 1/2/26 11:58, Krzysztof Kozlowski wrote:
> On 02/01/2026 00:56, Vladimir Zapolskiy wrote:
>> Add NXP LPC32xx specific driver to get unique SoC ID from System Control
>> Block registers and export it to userspace.
>>
>> Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
>> ---
>>   drivers/soc/Kconfig           |   1 +
>>   drivers/soc/Makefile          |   1 +
>>   drivers/soc/nxp/Kconfig       |  16 +++++
>>   drivers/soc/nxp/Makefile      |   2 +
>>   drivers/soc/nxp/lpc32xx-soc.c | 114 ++++++++++++++++++++++++++++++++++
>>   5 files changed, 134 insertions(+)
>>   create mode 100644 drivers/soc/nxp/Kconfig
>>   create mode 100644 drivers/soc/nxp/Makefile
>>   create mode 100644 drivers/soc/nxp/lpc32xx-soc.c
>>
>> diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig
>> index a2d65adffb80..c21b0d2f58fc 100644
>> --- a/drivers/soc/Kconfig
>> +++ b/drivers/soc/Kconfig
>> @@ -18,6 +18,7 @@ source "drivers/soc/loongson/Kconfig"
>>   source "drivers/soc/mediatek/Kconfig"
>>   source "drivers/soc/microchip/Kconfig"
>>   source "drivers/soc/nuvoton/Kconfig"
>> +source "drivers/soc/nxp/Kconfig"
>>   source "drivers/soc/pxa/Kconfig"
>>   source "drivers/soc/qcom/Kconfig"
>>   source "drivers/soc/renesas/Kconfig"
>> diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile
>> index 47a3925ff84c..a04c21a8a5a4 100644
>> --- a/drivers/soc/Makefile
>> +++ b/drivers/soc/Makefile
>> @@ -24,6 +24,7 @@ obj-y				+= loongson/
>>   obj-y				+= mediatek/
>>   obj-y				+= microchip/
>>   obj-y				+= nuvoton/
>> +obj-y				+= nxp/
>>   obj-y				+= pxa/
>>   obj-y				+= qcom/
>>   obj-y				+= renesas/
> 
> Missing maintainers entry.
> 
> 
>> +
>> +static int lpc32xx_soc_probe(struct platform_device *pdev)
>> +{
>> +	struct soc_device_attribute *soc_dev_attr;
>> +	struct device *dev = &pdev->dev;
>> +	struct soc_device *soc_dev;
>> +	struct regmap *scb;
>> +	u32 serial_id[4];
>> +	int ret;
>> +
>> +	soc_dev_attr = devm_kzalloc(dev, sizeof(*soc_dev_attr), GFP_KERNEL);
>> +	if (!soc_dev_attr)
>> +		return -ENOMEM;
>> +
>> +	soc_dev_attr->family = "NXP LPC32xx";
>> +
>> +	ret = of_property_read_string(of_root, "model", &soc_dev_attr->machine);
>> +	if (ret)
>> +		return ret;
>> +
>> +	scb = syscon_regmap_lookup_by_compatible("nxp,lpc3220-scb");
> 
> This is undocumented ABI.

What is the expected level of documentation for syscon?

The mfd/syscon.yaml states:

   System controller node represents a register region containing a set
   of miscellaneous registers. The registers are not cohesive enough to
   represent as any specific type of device.

This particular SCB has been documented, the review is pending.

> Anyway, you should look up devices via phandles.
> 

I may miss the context, was syscon_regmap_lookup_by_compatible() deprecated?

Most of drivers/soc uses syscon_regmap_lookup_by_compatible() variant over
syscon_regmap_lookup_by_phandle(), and overall

% git grep syscon_regmap_lookup_by_compatible v6.19-rc1 | wc -l
105

-- 
Best wishes,
Vladimir
Re: [PATCH 2/2] soc: nxp: Add a simple NXP LPC32xx socinfo driver
Posted by Krzysztof Kozlowski 1 month, 1 week ago
On 02/01/2026 13:36, Vladimir Zapolskiy wrote:
> On 1/2/26 11:58, Krzysztof Kozlowski wrote:
>> On 02/01/2026 00:56, Vladimir Zapolskiy wrote:
>>> Add NXP LPC32xx specific driver to get unique SoC ID from System Control
>>> Block registers and export it to userspace.
>>>
>>> Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
>>> ---
>>>   drivers/soc/Kconfig           |   1 +
>>>   drivers/soc/Makefile          |   1 +
>>>   drivers/soc/nxp/Kconfig       |  16 +++++
>>>   drivers/soc/nxp/Makefile      |   2 +
>>>   drivers/soc/nxp/lpc32xx-soc.c | 114 ++++++++++++++++++++++++++++++++++
>>>   5 files changed, 134 insertions(+)
>>>   create mode 100644 drivers/soc/nxp/Kconfig
>>>   create mode 100644 drivers/soc/nxp/Makefile
>>>   create mode 100644 drivers/soc/nxp/lpc32xx-soc.c
>>>
>>> diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig
>>> index a2d65adffb80..c21b0d2f58fc 100644
>>> --- a/drivers/soc/Kconfig
>>> +++ b/drivers/soc/Kconfig
>>> @@ -18,6 +18,7 @@ source "drivers/soc/loongson/Kconfig"
>>>   source "drivers/soc/mediatek/Kconfig"
>>>   source "drivers/soc/microchip/Kconfig"
>>>   source "drivers/soc/nuvoton/Kconfig"
>>> +source "drivers/soc/nxp/Kconfig"
>>>   source "drivers/soc/pxa/Kconfig"
>>>   source "drivers/soc/qcom/Kconfig"
>>>   source "drivers/soc/renesas/Kconfig"
>>> diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile
>>> index 47a3925ff84c..a04c21a8a5a4 100644
>>> --- a/drivers/soc/Makefile
>>> +++ b/drivers/soc/Makefile
>>> @@ -24,6 +24,7 @@ obj-y				+= loongson/
>>>   obj-y				+= mediatek/
>>>   obj-y				+= microchip/
>>>   obj-y				+= nuvoton/
>>> +obj-y				+= nxp/
>>>   obj-y				+= pxa/
>>>   obj-y				+= qcom/
>>>   obj-y				+= renesas/
>>
>> Missing maintainers entry.
>>
>>
>>> +
>>> +static int lpc32xx_soc_probe(struct platform_device *pdev)
>>> +{
>>> +	struct soc_device_attribute *soc_dev_attr;
>>> +	struct device *dev = &pdev->dev;
>>> +	struct soc_device *soc_dev;
>>> +	struct regmap *scb;
>>> +	u32 serial_id[4];
>>> +	int ret;
>>> +
>>> +	soc_dev_attr = devm_kzalloc(dev, sizeof(*soc_dev_attr), GFP_KERNEL);
>>> +	if (!soc_dev_attr)
>>> +		return -ENOMEM;
>>> +
>>> +	soc_dev_attr->family = "NXP LPC32xx";
>>> +
>>> +	ret = of_property_read_string(of_root, "model", &soc_dev_attr->machine);
>>> +	if (ret)
>>> +		return ret;
>>> +
>>> +	scb = syscon_regmap_lookup_by_compatible("nxp,lpc3220-scb");
>>
>> This is undocumented ABI.
> 
> What is the expected level of documentation for syscon?

git grep nxp,lpc3220-scb

gives me 0 results.

Documentation is supposed to be in this patchset. If it is not, you have
changelog part to explain dependencies and unusual things.
> 
>> Anyway, you should look up devices via phandles.
>>
> 
> I may miss the context, was syscon_regmap_lookup_by_compatible() deprecated?

Not deprecated. It has its own purpose, so you can explain why here you
cannot have phandle.

Without phandle you do not have proper device probe ordering and you do
not properly express the dependency between hardware modules. Maybe this
is not even real hardware, which you attach your driver to, so that's
another thing to consider. Anyway, commit msg should explain all these.

> 
> Most of drivers/soc uses syscon_regmap_lookup_by_compatible() variant over
> syscon_regmap_lookup_by_phandle(), and overall

They have their own reason.

> 
> % git grep syscon_regmap_lookup_by_compatible v6.19-rc1 | wc -l
> 105
> 


Best regards,
Krzysztof
Re: [PATCH 2/2] soc: nxp: Add a simple NXP LPC32xx socinfo driver
Posted by Vladimir Zapolskiy 1 month, 1 week ago
On 1/2/26 14:54, Krzysztof Kozlowski wrote:
> On 02/01/2026 13:36, Vladimir Zapolskiy wrote:
>> On 1/2/26 11:58, Krzysztof Kozlowski wrote:
>>> On 02/01/2026 00:56, Vladimir Zapolskiy wrote:
>>>> Add NXP LPC32xx specific driver to get unique SoC ID from System Control
>>>> Block registers and export it to userspace.
>>>>
>>>> Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
>>>> ---
>>>>    drivers/soc/Kconfig           |   1 +
>>>>    drivers/soc/Makefile          |   1 +
>>>>    drivers/soc/nxp/Kconfig       |  16 +++++
>>>>    drivers/soc/nxp/Makefile      |   2 +
>>>>    drivers/soc/nxp/lpc32xx-soc.c | 114 ++++++++++++++++++++++++++++++++++
>>>>    5 files changed, 134 insertions(+)
>>>>    create mode 100644 drivers/soc/nxp/Kconfig
>>>>    create mode 100644 drivers/soc/nxp/Makefile
>>>>    create mode 100644 drivers/soc/nxp/lpc32xx-soc.c
>>>>
>>>> diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig
>>>> index a2d65adffb80..c21b0d2f58fc 100644
>>>> --- a/drivers/soc/Kconfig
>>>> +++ b/drivers/soc/Kconfig
>>>> @@ -18,6 +18,7 @@ source "drivers/soc/loongson/Kconfig"
>>>>    source "drivers/soc/mediatek/Kconfig"
>>>>    source "drivers/soc/microchip/Kconfig"
>>>>    source "drivers/soc/nuvoton/Kconfig"
>>>> +source "drivers/soc/nxp/Kconfig"
>>>>    source "drivers/soc/pxa/Kconfig"
>>>>    source "drivers/soc/qcom/Kconfig"
>>>>    source "drivers/soc/renesas/Kconfig"
>>>> diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile
>>>> index 47a3925ff84c..a04c21a8a5a4 100644
>>>> --- a/drivers/soc/Makefile
>>>> +++ b/drivers/soc/Makefile
>>>> @@ -24,6 +24,7 @@ obj-y				+= loongson/
>>>>    obj-y				+= mediatek/
>>>>    obj-y				+= microchip/
>>>>    obj-y				+= nuvoton/
>>>> +obj-y				+= nxp/
>>>>    obj-y				+= pxa/
>>>>    obj-y				+= qcom/
>>>>    obj-y				+= renesas/
>>>
>>> Missing maintainers entry.
>>>
>>>
>>>> +
>>>> +static int lpc32xx_soc_probe(struct platform_device *pdev)
>>>> +{
>>>> +	struct soc_device_attribute *soc_dev_attr;
>>>> +	struct device *dev = &pdev->dev;
>>>> +	struct soc_device *soc_dev;
>>>> +	struct regmap *scb;
>>>> +	u32 serial_id[4];
>>>> +	int ret;
>>>> +
>>>> +	soc_dev_attr = devm_kzalloc(dev, sizeof(*soc_dev_attr), GFP_KERNEL);
>>>> +	if (!soc_dev_attr)
>>>> +		return -ENOMEM;
>>>> +
>>>> +	soc_dev_attr->family = "NXP LPC32xx";
>>>> +
>>>> +	ret = of_property_read_string(of_root, "model", &soc_dev_attr->machine);
>>>> +	if (ret)
>>>> +		return ret;
>>>> +
>>>> +	scb = syscon_regmap_lookup_by_compatible("nxp,lpc3220-scb");
>>>
>>> This is undocumented ABI.
>>
>> What is the expected level of documentation for syscon?
> 
> git grep nxp,lpc3220-scb
> 
> gives me 0 results.
> 
> Documentation is supposed to be in this patchset. If it is not, you have
> changelog part to explain dependencies and unusual things.

The documentation is under review, as a DT maintainer you are in To: list
and should have it in the mailbox, for anyone's convenience the dependency
is mentioned in the cover letter to this changeset also.

>>
>>> Anyway, you should look up devices via phandles.
>>>
>>
>> I may miss the context, was syscon_regmap_lookup_by_compatible() deprecated?
> 
> Not deprecated. It has its own purpose, so you can explain why here you
> cannot have phandle.
> 
> Without phandle you do not have proper device probe ordering and you do
> not properly express the dependency between hardware modules. Maybe this
> is not even real hardware, which you attach your driver to, so that's
> another thing to consider. Anyway, commit msg should explain all these.

Ack.

>>
>> Most of drivers/soc uses syscon_regmap_lookup_by_compatible() variant over
>> syscon_regmap_lookup_by_phandle(), and overall
> 
> They have their own reason.

Here the reason to use syscon by a compatible is the same reason as it's
among the sibling drivers, I'll specify it in the commit message, thanks.

FWIW there is no intention to convert the SCB register region into its
owm device.

>>
>> % git grep syscon_regmap_lookup_by_compatible v6.19-rc1 | wc -l
>> 105
>>

-- 
Best wishes,
Vladimir
Re: [PATCH 2/2] soc: nxp: Add a simple NXP LPC32xx socinfo driver
Posted by Krzysztof Kozlowski 1 month ago
On 02/01/2026 14:21, Vladimir Zapolskiy wrote:
> On 1/2/26 14:54, Krzysztof Kozlowski wrote:
>> On 02/01/2026 13:36, Vladimir Zapolskiy wrote:
>>> On 1/2/26 11:58, Krzysztof Kozlowski wrote:
>>>> On 02/01/2026 00:56, Vladimir Zapolskiy wrote:
>>>>> Add NXP LPC32xx specific driver to get unique SoC ID from System Control
>>>>> Block registers and export it to userspace.
>>>>>
>>>>> Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
>>>>> ---
>>>>>    drivers/soc/Kconfig           |   1 +
>>>>>    drivers/soc/Makefile          |   1 +
>>>>>    drivers/soc/nxp/Kconfig       |  16 +++++
>>>>>    drivers/soc/nxp/Makefile      |   2 +
>>>>>    drivers/soc/nxp/lpc32xx-soc.c | 114 ++++++++++++++++++++++++++++++++++
>>>>>    5 files changed, 134 insertions(+)
>>>>>    create mode 100644 drivers/soc/nxp/Kconfig
>>>>>    create mode 100644 drivers/soc/nxp/Makefile
>>>>>    create mode 100644 drivers/soc/nxp/lpc32xx-soc.c
>>>>>
>>>>> diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig
>>>>> index a2d65adffb80..c21b0d2f58fc 100644
>>>>> --- a/drivers/soc/Kconfig
>>>>> +++ b/drivers/soc/Kconfig
>>>>> @@ -18,6 +18,7 @@ source "drivers/soc/loongson/Kconfig"
>>>>>    source "drivers/soc/mediatek/Kconfig"
>>>>>    source "drivers/soc/microchip/Kconfig"
>>>>>    source "drivers/soc/nuvoton/Kconfig"
>>>>> +source "drivers/soc/nxp/Kconfig"
>>>>>    source "drivers/soc/pxa/Kconfig"
>>>>>    source "drivers/soc/qcom/Kconfig"
>>>>>    source "drivers/soc/renesas/Kconfig"
>>>>> diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile
>>>>> index 47a3925ff84c..a04c21a8a5a4 100644
>>>>> --- a/drivers/soc/Makefile
>>>>> +++ b/drivers/soc/Makefile
>>>>> @@ -24,6 +24,7 @@ obj-y				+= loongson/
>>>>>    obj-y				+= mediatek/
>>>>>    obj-y				+= microchip/
>>>>>    obj-y				+= nuvoton/
>>>>> +obj-y				+= nxp/
>>>>>    obj-y				+= pxa/
>>>>>    obj-y				+= qcom/
>>>>>    obj-y				+= renesas/
>>>>
>>>> Missing maintainers entry.
>>>>
>>>>
>>>>> +
>>>>> +static int lpc32xx_soc_probe(struct platform_device *pdev)
>>>>> +{
>>>>> +	struct soc_device_attribute *soc_dev_attr;
>>>>> +	struct device *dev = &pdev->dev;
>>>>> +	struct soc_device *soc_dev;
>>>>> +	struct regmap *scb;
>>>>> +	u32 serial_id[4];
>>>>> +	int ret;
>>>>> +
>>>>> +	soc_dev_attr = devm_kzalloc(dev, sizeof(*soc_dev_attr), GFP_KERNEL);
>>>>> +	if (!soc_dev_attr)
>>>>> +		return -ENOMEM;
>>>>> +
>>>>> +	soc_dev_attr->family = "NXP LPC32xx";
>>>>> +
>>>>> +	ret = of_property_read_string(of_root, "model", &soc_dev_attr->machine);
>>>>> +	if (ret)
>>>>> +		return ret;
>>>>> +
>>>>> +	scb = syscon_regmap_lookup_by_compatible("nxp,lpc3220-scb");
>>>>
>>>> This is undocumented ABI.
>>>
>>> What is the expected level of documentation for syscon?
>>
>> git grep nxp,lpc3220-scb
>>
>> gives me 0 results.
>>
>> Documentation is supposed to be in this patchset. If it is not, you have
>> changelog part to explain dependencies and unusual things.
> 
> The documentation is under review, as a DT maintainer you are in To: list
> and should have it in the mailbox, for anyone's convenience the dependency
> is mentioned in the cover letter to this changeset also.


There is nothing about dependency and nothing about binding in the cover
letter, so no - this is not explained nowhere and must have been explained.

Best regards,
Krzysztof
Re: [PATCH 2/2] soc: nxp: Add a simple NXP LPC32xx socinfo driver
Posted by Vladimir Zapolskiy 1 month ago
On 1/3/26 14:43, Krzysztof Kozlowski wrote:
> On 02/01/2026 14:21, Vladimir Zapolskiy wrote:
>> On 1/2/26 14:54, Krzysztof Kozlowski wrote:
>>> On 02/01/2026 13:36, Vladimir Zapolskiy wrote:
>>>> On 1/2/26 11:58, Krzysztof Kozlowski wrote:
>>>>> On 02/01/2026 00:56, Vladimir Zapolskiy wrote:
>>>>>> Add NXP LPC32xx specific driver to get unique SoC ID from System Control
>>>>>> Block registers and export it to userspace.
>>>>>>
>>>>>> Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
>>>>>> ---
>>>>>>     drivers/soc/Kconfig           |   1 +
>>>>>>     drivers/soc/Makefile          |   1 +
>>>>>>     drivers/soc/nxp/Kconfig       |  16 +++++
>>>>>>     drivers/soc/nxp/Makefile      |   2 +
>>>>>>     drivers/soc/nxp/lpc32xx-soc.c | 114 ++++++++++++++++++++++++++++++++++
>>>>>>     5 files changed, 134 insertions(+)
>>>>>>     create mode 100644 drivers/soc/nxp/Kconfig
>>>>>>     create mode 100644 drivers/soc/nxp/Makefile
>>>>>>     create mode 100644 drivers/soc/nxp/lpc32xx-soc.c
>>>>>>
>>>>>> diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig
>>>>>> index a2d65adffb80..c21b0d2f58fc 100644
>>>>>> --- a/drivers/soc/Kconfig
>>>>>> +++ b/drivers/soc/Kconfig
>>>>>> @@ -18,6 +18,7 @@ source "drivers/soc/loongson/Kconfig"
>>>>>>     source "drivers/soc/mediatek/Kconfig"
>>>>>>     source "drivers/soc/microchip/Kconfig"
>>>>>>     source "drivers/soc/nuvoton/Kconfig"
>>>>>> +source "drivers/soc/nxp/Kconfig"
>>>>>>     source "drivers/soc/pxa/Kconfig"
>>>>>>     source "drivers/soc/qcom/Kconfig"
>>>>>>     source "drivers/soc/renesas/Kconfig"
>>>>>> diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile
>>>>>> index 47a3925ff84c..a04c21a8a5a4 100644
>>>>>> --- a/drivers/soc/Makefile
>>>>>> +++ b/drivers/soc/Makefile
>>>>>> @@ -24,6 +24,7 @@ obj-y				+= loongson/
>>>>>>     obj-y				+= mediatek/
>>>>>>     obj-y				+= microchip/
>>>>>>     obj-y				+= nuvoton/
>>>>>> +obj-y				+= nxp/
>>>>>>     obj-y				+= pxa/
>>>>>>     obj-y				+= qcom/
>>>>>>     obj-y				+= renesas/
>>>>>
>>>>> Missing maintainers entry.
>>>>>
>>>>>
>>>>>> +
>>>>>> +static int lpc32xx_soc_probe(struct platform_device *pdev)
>>>>>> +{
>>>>>> +	struct soc_device_attribute *soc_dev_attr;
>>>>>> +	struct device *dev = &pdev->dev;
>>>>>> +	struct soc_device *soc_dev;
>>>>>> +	struct regmap *scb;
>>>>>> +	u32 serial_id[4];
>>>>>> +	int ret;
>>>>>> +
>>>>>> +	soc_dev_attr = devm_kzalloc(dev, sizeof(*soc_dev_attr), GFP_KERNEL);
>>>>>> +	if (!soc_dev_attr)
>>>>>> +		return -ENOMEM;
>>>>>> +
>>>>>> +	soc_dev_attr->family = "NXP LPC32xx";
>>>>>> +
>>>>>> +	ret = of_property_read_string(of_root, "model", &soc_dev_attr->machine);
>>>>>> +	if (ret)
>>>>>> +		return ret;
>>>>>> +
>>>>>> +	scb = syscon_regmap_lookup_by_compatible("nxp,lpc3220-scb");
>>>>>
>>>>> This is undocumented ABI.
>>>>
>>>> What is the expected level of documentation for syscon?
>>>
>>> git grep nxp,lpc3220-scb
>>>
>>> gives me 0 results.
>>>
>>> Documentation is supposed to be in this patchset. If it is not, you have
>>> changelog part to explain dependencies and unusual things.
>>
>> The documentation is under review, as a DT maintainer you are in To: list
>> and should have it in the mailbox, for anyone's convenience the dependency
>> is mentioned in the cover letter to this changeset also.
> 
> There is nothing about dependency and nothing about binding in the cover
> letter, so no - this is not explained nowhere and must have been explained.
> 

If you do not find the asked information, then let me repeat my question, what
dependency or information does this changeset miss? What "undocumented ABI"
you'd expect to resolve?

Intentionally the driver works without a present "nxp,lpc3220-scb" compatible
device tree node, anyway, since it's mentioned in the driver, such a device
tree node is described over the link to another changeset.

-- 
Best wishes,
Vladimir
Re: [PATCH 2/2] soc: nxp: Add a simple NXP LPC32xx socinfo driver
Posted by Krzysztof Kozlowski 1 month ago
On 03/01/2026 23:14, Vladimir Zapolskiy wrote:
> On 1/3/26 14:43, Krzysztof Kozlowski wrote:
>> On 02/01/2026 14:21, Vladimir Zapolskiy wrote:
>>> On 1/2/26 14:54, Krzysztof Kozlowski wrote:
>>>> On 02/01/2026 13:36, Vladimir Zapolskiy wrote:
>>>>> On 1/2/26 11:58, Krzysztof Kozlowski wrote:
>>>>>> On 02/01/2026 00:56, Vladimir Zapolskiy wrote:
>>>>>>> Add NXP LPC32xx specific driver to get unique SoC ID from System Control
>>>>>>> Block registers and export it to userspace.
>>>>>>>
>>>>>>> Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
>>>>>>> ---
>>>>>>>     drivers/soc/Kconfig           |   1 +
>>>>>>>     drivers/soc/Makefile          |   1 +
>>>>>>>     drivers/soc/nxp/Kconfig       |  16 +++++
>>>>>>>     drivers/soc/nxp/Makefile      |   2 +
>>>>>>>     drivers/soc/nxp/lpc32xx-soc.c | 114 ++++++++++++++++++++++++++++++++++
>>>>>>>     5 files changed, 134 insertions(+)
>>>>>>>     create mode 100644 drivers/soc/nxp/Kconfig
>>>>>>>     create mode 100644 drivers/soc/nxp/Makefile
>>>>>>>     create mode 100644 drivers/soc/nxp/lpc32xx-soc.c
>>>>>>>
>>>>>>> diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig
>>>>>>> index a2d65adffb80..c21b0d2f58fc 100644
>>>>>>> --- a/drivers/soc/Kconfig
>>>>>>> +++ b/drivers/soc/Kconfig
>>>>>>> @@ -18,6 +18,7 @@ source "drivers/soc/loongson/Kconfig"
>>>>>>>     source "drivers/soc/mediatek/Kconfig"
>>>>>>>     source "drivers/soc/microchip/Kconfig"
>>>>>>>     source "drivers/soc/nuvoton/Kconfig"
>>>>>>> +source "drivers/soc/nxp/Kconfig"
>>>>>>>     source "drivers/soc/pxa/Kconfig"
>>>>>>>     source "drivers/soc/qcom/Kconfig"
>>>>>>>     source "drivers/soc/renesas/Kconfig"
>>>>>>> diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile
>>>>>>> index 47a3925ff84c..a04c21a8a5a4 100644
>>>>>>> --- a/drivers/soc/Makefile
>>>>>>> +++ b/drivers/soc/Makefile
>>>>>>> @@ -24,6 +24,7 @@ obj-y				+= loongson/
>>>>>>>     obj-y				+= mediatek/
>>>>>>>     obj-y				+= microchip/
>>>>>>>     obj-y				+= nuvoton/
>>>>>>> +obj-y				+= nxp/
>>>>>>>     obj-y				+= pxa/
>>>>>>>     obj-y				+= qcom/
>>>>>>>     obj-y				+= renesas/
>>>>>>
>>>>>> Missing maintainers entry.
>>>>>>
>>>>>>
>>>>>>> +
>>>>>>> +static int lpc32xx_soc_probe(struct platform_device *pdev)
>>>>>>> +{
>>>>>>> +	struct soc_device_attribute *soc_dev_attr;
>>>>>>> +	struct device *dev = &pdev->dev;
>>>>>>> +	struct soc_device *soc_dev;
>>>>>>> +	struct regmap *scb;
>>>>>>> +	u32 serial_id[4];
>>>>>>> +	int ret;
>>>>>>> +
>>>>>>> +	soc_dev_attr = devm_kzalloc(dev, sizeof(*soc_dev_attr), GFP_KERNEL);
>>>>>>> +	if (!soc_dev_attr)
>>>>>>> +		return -ENOMEM;
>>>>>>> +
>>>>>>> +	soc_dev_attr->family = "NXP LPC32xx";
>>>>>>> +
>>>>>>> +	ret = of_property_read_string(of_root, "model", &soc_dev_attr->machine);
>>>>>>> +	if (ret)
>>>>>>> +		return ret;
>>>>>>> +
>>>>>>> +	scb = syscon_regmap_lookup_by_compatible("nxp,lpc3220-scb");
>>>>>>
>>>>>> This is undocumented ABI.
>>>>>
>>>>> What is the expected level of documentation for syscon?
>>>>
>>>> git grep nxp,lpc3220-scb
>>>>
>>>> gives me 0 results.
>>>>
>>>> Documentation is supposed to be in this patchset. If it is not, you have
>>>> changelog part to explain dependencies and unusual things.
>>>
>>> The documentation is under review, as a DT maintainer you are in To: list
>>> and should have it in the mailbox, for anyone's convenience the dependency
>>> is mentioned in the cover letter to this changeset also.
>>
>> There is nothing about dependency and nothing about binding in the cover
>> letter, so no - this is not explained nowhere and must have been explained.
>>
> 
> If you do not find the asked information, then let me repeat my question, what
> dependency or information does this changeset miss? What "undocumented ABI"
> you'd expect to resolve?

I already explained that.

You added here new undocumented ABI. I said that.

Changelog of this patch or cover letter must say where is the ABI
documented, if it is not in this patchset. I basically said it as well.

There is nothing like this in cover letter. There is nothing about
dependency, either.


Best regards,
Krzysztof
Re: [PATCH 2/2] soc: nxp: Add a simple NXP LPC32xx socinfo driver
Posted by Arnd Bergmann 1 month, 1 week ago
On Fri, Jan 2, 2026, at 00:56, Vladimir Zapolskiy wrote:
> Add NXP LPC32xx specific driver to get unique SoC ID from System Control
> Block registers and export it to userspace.
>
> Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>

This looks fine to me overall

> +static int lpc32xx_soc_probe(struct platform_device *pdev)
> +{
> +	struct soc_device_attribute *soc_dev_attr;
> +	struct device *dev = &pdev->dev;
> +	struct soc_device *soc_dev;
> +	struct regmap *scb;
> +	u32 serial_id[4];
> +	int ret;
> +
> +	soc_dev_attr = devm_kzalloc(dev, sizeof(*soc_dev_attr), GFP_KERNEL);
> +	if (!soc_dev_attr)
> +		return -ENOMEM;
> +
> +	soc_dev_attr->family = "NXP LPC32xx";
> +
> +	ret = of_property_read_string(of_root, "model", &soc_dev_attr->machine);
> +	if (ret)
> +		return ret;
> +
> +	scb = syscon_regmap_lookup_by_compatible("nxp,lpc3220-scb");

It seems a bit odd to register a fake platform_device and then
get the registers from another device.

I think with the current iteration of syscon since 26769582bf35
("mfd: syscon: Remove the platform driver support"), you should be
able to just register the driver as a module_platform_driver
for the "nxp,lpc3220-scb" compatible value. Have you tried that?

If for some reason that doesn't work, I would drop the custom
platform_device here and just merge the probe function into
the module init.

       Arnd