* [PATCH] pinctrl: imx: Use of_device_id match table for per-SoC data
@ 2026-10-19 11:09 joy.zou
2026-10-19 19:30 ` Frank Li
0 siblings, 1 reply; 2+ messages in thread
From: joy.zou @ 2026-10-19 11:09 UTC (permalink / raw)
To: Peng Fan, Dong Aisheng, Fabio Estevam, Frank Li, Jacky Bai, Ye Li,
Pengutronix Kernel Team, NXP S32 Linux Team, Linus Walleij,
Sascha Hauer
Cc: linux-gpio, imx, linux-arm-kernel, linux-kernel, Joy Zou, Joy Zou
From: Peng Fan <peng.fan@nxp.com>
Replace the hardcoded of_machine_is_compatible() if-else chain and the
static string allowlist with a proper of_device_id match table carrying
per-SoC data via the .data field.
This eliminates the static local variable anti-pattern for daisy_off
(lazy-initialized, shared across instances) and adopts the idiomatic
kernel of_machine_get_match_data() APIs.
A new pinctrl_scmi_imx_data struct captures the daisy register offset
for future extensibility when new SoCs may not use register-offset based
daisy configuration.
No functional changes.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Joy Zou <joy.zou@nxp.com>
---
Replace the hardcoded of_machine_is_compatible() if-else chain and the
static string allowlist with an of_device_id match table that carries the
per-SoC daisy register offset in its .data field.
This drops the lazily-initialized "static uint32_t daisy_off" local and
lets probe do the compatible match and per-SoC data lookup in one step
via of_machine_get_match_data().
No functional change intended.
Signed-off-by: Joy Zou <joy.zou@oss.nxp.com>
---
drivers/pinctrl/freescale/pinctrl-imx-scmi.c | 55 +++++++++++++++++-----------
1 file changed, 34 insertions(+), 21 deletions(-)
diff --git a/drivers/pinctrl/freescale/pinctrl-imx-scmi.c b/drivers/pinctrl/freescale/pinctrl-imx-scmi.c
index b259a526ccc1..c287c3ef73a1 100644
--- a/drivers/pinctrl/freescale/pinctrl-imx-scmi.c
+++ b/drivers/pinctrl/freescale/pinctrl-imx-scmi.c
@@ -28,12 +28,17 @@
#define DRV_NAME "scmi-pinctrl-imx"
+struct pinctrl_scmi_imx_data {
+ uint32_t daisy_off;
+};
+
struct scmi_pinctrl_imx {
struct device *dev;
struct scmi_protocol_handle *ph;
struct pinctrl_dev *pctldev;
struct pinctrl_desc pctl_desc;
const struct scmi_pinctrl_proto_ops *ops;
+ const struct pinctrl_scmi_imx_data *data;
};
/* SCMI pin control types, aligned with SCMI firmware */
@@ -59,6 +64,7 @@ static int pinctrl_scmi_imx_dt_node_to_map(struct pinctrl_dev *pctldev,
struct pinctrl_map **map,
unsigned int *num_maps)
{
+ struct scmi_pinctrl_imx *pmx = pinctrl_dev_get_drvdata(pctldev);
struct pinctrl_map *new_map;
const __be32 *list;
unsigned long *configs = NULL;
@@ -67,21 +73,15 @@ static int pinctrl_scmi_imx_dt_node_to_map(struct pinctrl_dev *pctldev,
int mux_reg, conf_reg, input_reg, mux_val, conf_val, input_val;
int i, j;
uint32_t ncfg;
- static uint32_t daisy_off;
-
- if (!daisy_off) {
- if (of_machine_is_compatible("fsl,imx95")) {
- daisy_off = IMX95_DAISY_OFF;
- } else if (of_machine_is_compatible("fsl,imx94")) {
- daisy_off = IMX94_DAISY_OFF;
- } else if (of_machine_is_compatible("fsl,imx952")) {
- daisy_off = IMX952_DAISY_OFF;
- } else {
- dev_err(pctldev->dev, "platform not support scmi pinctrl\n");
- return -EINVAL;
- }
+ uint32_t daisy_off;
+
+ if (!pmx->data) {
+ dev_err(pctldev->dev, "platform does not support scmi pinctrl\n");
+ return -EINVAL;
}
+ daisy_off = pmx->data->daisy_off;
+
list = of_get_property(np, "fsl,pins", &size);
if (!list) {
dev_err(pctldev->dev, "no fsl,pins property in node %pOF\n", np);
@@ -299,11 +299,23 @@ scmi_pinctrl_imx_get_pins(struct scmi_pinctrl_imx *pmx, struct pinctrl_desc *des
return 0;
}
-static const char * const scmi_pinctrl_imx_allowlist[] = {
- "fsl,imx94",
- "fsl,imx95",
- "fsl,imx952",
- NULL
+static const struct pinctrl_scmi_imx_data imx94_pin_data = {
+ .daisy_off = IMX94_DAISY_OFF,
+};
+
+static const struct pinctrl_scmi_imx_data imx95_pin_data = {
+ .daisy_off = IMX95_DAISY_OFF,
+};
+
+static const struct pinctrl_scmi_imx_data imx952_pin_data = {
+ .daisy_off = IMX952_DAISY_OFF,
+};
+
+static const struct of_device_id scmi_pinctrl_imx_data[] = {
+ { .compatible = "fsl,imx94", .data = &imx94_pin_data, },
+ { .compatible = "fsl,imx95", .data = &imx95_pin_data, },
+ { .compatible = "fsl,imx952", .data = &imx952_pin_data, },
+ { }
};
static int scmi_pinctrl_imx_probe(struct scmi_device *sdev)
@@ -318,9 +330,6 @@ static int scmi_pinctrl_imx_probe(struct scmi_device *sdev)
if (!handle)
return -EINVAL;
- if (!of_machine_compatible_match(scmi_pinctrl_imx_allowlist))
- return -ENODEV;
-
pinctrl_ops = handle->devm_protocol_get(sdev, SCMI_PROTOCOL_PINCTRL, &ph);
if (IS_ERR(pinctrl_ops))
return PTR_ERR(pinctrl_ops);
@@ -329,6 +338,10 @@ static int scmi_pinctrl_imx_probe(struct scmi_device *sdev)
if (!pmx)
return -ENOMEM;
+ pmx->data = of_machine_get_match_data(scmi_pinctrl_imx_data);
+ if (!pmx->data)
+ return -ENODEV;
+
pmx->ph = ph;
pmx->ops = pinctrl_ops;
---
base-commit: 2efb7a11f1aa4d2dc285fe2680cca22cb9f72f64
change-id: 20261019-b4-imx937-frdm-scmi-pinctrl-7bce28f895f7
Best regards,
--
Joy Zou <joy.zou@oss.nxp.com>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] pinctrl: imx: Use of_device_id match table for per-SoC data
2026-10-19 11:09 [PATCH] pinctrl: imx: Use of_device_id match table for per-SoC data joy.zou
@ 2026-10-19 19:30 ` Frank Li
0 siblings, 0 replies; 2+ messages in thread
From: Frank Li @ 2026-10-19 19:30 UTC (permalink / raw)
To: joy.zou
Cc: Peng Fan, Dong Aisheng, Fabio Estevam, Frank Li, Jacky Bai, Ye Li,
Pengutronix Kernel Team, NXP S32 Linux Team, Linus Walleij,
Sascha Hauer, linux-gpio, imx, linux-arm-kernel, linux-kernel,
Joy Zou
On Mon, Oct 19, 2026 at 07:09:35PM +0800, joy.zou@oss.nxp.com wrote:
> From: Peng Fan <peng.fan@nxp.com>
>
> Replace the hardcoded of_machine_is_compatible() if-else chain and the
> static string allowlist with a proper of_device_id match table carrying
> per-SoC data via the .data field.
>
> This eliminates the static local variable anti-pattern for daisy_off
> (lazy-initialized, shared across instances) and adopts the idiomatic
> kernel of_machine_get_match_data() APIs.
>
> A new pinctrl_scmi_imx_data struct captures the daisy register offset
> for future extensibility when new SoCs may not use register-offset based
> daisy configuration.
>
> No functional changes.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> Signed-off-by: Joy Zou <joy.zou@nxp.com>
> ---
Reviewed-by: Frank Li <Frank.Li@nxp.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-19 19:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-19 11:09 [PATCH] pinctrl: imx: Use of_device_id match table for per-SoC data joy.zou
2026-10-19 19:30 ` Frank Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox