Re: [V1 2/2] drivers soc: add support for ST stm32mp13xx family
From: Krzysztof Kozlowski
Date: Mon May 19 2025 - 14:34:37 EST
On 19/05/2025 15:08, Rodolfo Giometti wrote:
> This patch adds SoC support for the ST stm32mp13xx family. It also
Please do not use "This commit/patch/change", but imperative mood. See
longer explanation here:
https://elixir.bootlin.com/linux/v5.17.1/source/Documentation/process/submitting-patches.rst#L95
> adds the special attribute "secure" which returns the CPU's secure
> mode status.
>
> Signed-off-by: Rodolfo Giometti <giometti@xxxxxxxxxxxx>
You Cc-ed linux-kernel, so I assume this is patch for mainline kernel.
Please use scripts/get_maintainers.pl to get a list of necessary people
and lists to CC (and consider --no-git-fallback argument, so you will
not CC people just because they made one commit years ago). It might
happen, that command when run on an older kernel, gives you outdated
entries. Therefore please be sure you base your patches on recent Linux
kernel.
Tools like b4 or scripts/get_maintainer.pl provide you proper list of
people, so fix your workflow. Tools might also fail if you work on some
ancient tree (don't, instead use mainline) or work on fork of kernel
(don't, instead use mainline). Just use b4 and everything should be
fine, although remember about `b4 prep --auto-to-cc` if you added new
patches to the patchset.
...
> +
> + switch (val) {
> + case 0b0000010111:
> + str = "open";
> + break;
> + case 0b0000111111:
> + str = "closed";
> + break;
> + case 0b0101111111:
> + str = "closed boundary-scan-disabled]";
> + break;
> + case 0b1111111111:
> + str = "closed JTAG-disabled";
> + break;
> + default:
> + str = "unknown";
> + }
> +
> + return sprintf(buf, "%s\n", str);
> +}
> +static DEVICE_ATTR_RO(secure);
Where is ABI documented?
> +
> +static struct attribute *stm32mp13_soc_attrs[] = {
> + &dev_attr_secure.attr,
> + NULL
> +};
> +ATTRIBUTE_GROUPS(stm32mp13_soc);
> +
> +static int __init stm32mp13_soc_get_idc(u32 *idc)
> +{
> + struct device_node *np;
> + void __iomem *regs;
> + static const struct of_device_id devids[] = {
> + { .compatible = "st,stm32mp157-syscfg" },
No, don't add compatibles for other devices into the driver functions.
Use standard methods for binding, like every driver does.
> + { },
> + };
> +
> + np = of_find_matching_node(NULL, devids);
> + if (!np)
> + return -ENODEV;
> +
> + regs = of_iomap(np, 0);
> + of_node_put(np);
> +
> + if (!regs) {
> + pr_warn("Could not map BSEC iomem range");
> + return -ENXIO;
> + }
> +
> + *idc = readl(regs + SYSCFG_IDC);
> +
> + iounmap(regs);
> +
> + return 0;
> +}
> +
> +static int __init stm32mp13_soc_device_init(void)
> +{
> + u32 part_number, rev, chipid[3];
> + struct soc_device_attribute *soc_dev_attr;
> + struct soc_device *soc_dev;
> + struct device_node *root;
> + const char *soc_id;
> + int ret;
> +
> + soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
> + if (!soc_dev_attr)
> + return -ENOMEM;
> + soc_dev_attr->family = "STM STM32MP13xx";
> +
> + root = of_find_node_by_path("/");
> + ret = of_property_read_string(root, "model", &soc_dev_attr->machine);
> + if (ret)
> + of_property_read_string_index(root, "compatible", 0,
> + &soc_dev_attr->machine);
> + of_node_put(root);
> + if (ret)
> + goto free_soc;
> +
> + /* Get chip info */
> + ret = stm32mp13_soc_get_rpn_uid(&part_number, chipid);
> + if (ret) {
> + pr_err("failed to get chip part number: %d\n", ret);
> + goto free_soc;
> + }
> + switch (part_number) {
> + case STM32MP131A:
> + soc_id = "131a";
> + break;
> + case STM32MP131C:
> + soc_id = "131c";
> + break;
> + case STM32MP131D:
> + soc_id = "131d";
> + break;
> + case STM32MP131F:
> + soc_id = "131f";
> + break;
> + case STM32MP133A:
> + soc_id = "133a";
> + break;
> + case STM32MP133C:
> + soc_id = "133c";
> + break;
> + case STM32MP133D:
> + soc_id = "133d";
> + break;
> + case STM32MP133F:
> + soc_id = "133f";
> + break;
> + case STM32MP135A:
> + soc_id = "135a";
> + break;
> + case STM32MP135C:
> + soc_id = "135c";
> + break;
> + case STM32MP135D:
> + soc_id = "135d";
> + break;
> + case STM32MP135F:
> + soc_id = "135f";
> + break;
> + default:
> + soc_id = "unknown";
> + }
> + soc_dev_attr->soc_id = soc_id;
> +
> + ret = stm32mp13_soc_get_idc(&rev);
> + if (ret)
> + goto free_soc;
> + soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%X", rev >> 16);
> + if (!soc_dev_attr->revision) {
> + ret = -ENOMEM;
> + goto free_soc;
> + }
> +
> + soc_dev_attr->serial_number = kasprintf(GFP_KERNEL, "%08X%08X%08X",
> + chipid[0], chipid[1], chipid[2]);
> + if (!soc_dev_attr->serial_number) {
> + ret = -ENOMEM;
> + goto free_rev;
> + }
> +
> + /* Add custom attributes group */
> + soc_dev_attr->custom_attr_group = stm32mp13_soc_groups[0];
> +
> + /* Register the SOC device */
> + soc_dev = soc_device_register(soc_dev_attr);
> + if (IS_ERR(soc_dev)) {
> + ret = PTR_ERR(soc_dev);
> + goto free_serial_number;
> + }
> +
> + pr_info("SoC Machine: %s\n", soc_dev_attr->machine);
> + pr_info("SoC family: %s\n", soc_dev_attr->family);
> + pr_info("SoC ID: %s, Revision: %s\n",
> + soc_dev_attr->soc_id, soc_dev_attr->revision);
So this will print and spam every dmesg for every user of the kernel.
No, this has to be regular platform driver and only one print (see
kernel coding style about drivers being silent).
Best regards,
Krzysztof