[PATCH v4 3/3] pinctrl: imx: support SCMI pinctrl protocol for i.MX95

Peng Fan peng.fan at nxp.com
Mon May 13 02:09:04 PDT 2024


> Subject: Re: [PATCH v4 3/3] pinctrl: imx: support SCMI pinctrl protocol for
> i.MX95
> 
> Sun, May 05, 2024 at 11:47:19AM +0800, Peng Fan (OSS) kirjoitti:
> > From: Peng Fan <peng.fan at nxp.com>
> >
> > The generic pinctrl-scmi.c driver could not be used for i.MX95 because
> > i.MX95 SCMI firmware not supports functions, groups or generic 'Pin
> > Configuration Type and Enumerations' listed in SCMI Specification.
> >
> > i.MX95 System Control Management Interface(SCMI) firmware only
> > supports below pin configuration types which are OEM specific types:
> >     192: PIN MUX
> >     193: PIN CONF
> >     194: DAISY ID
> >     195: DAISY VAL
> >
> > To support Linux generic pinctrl properties(pinmux, bias-pull-[up,
> > down], and etc), need extract the value from the property and map them
> > to the format that i.MX95 SCMI pinctrl protocol understands, so add
> > this driver.
> 

Thanks for refining this.

> ...
> 
> > +struct imx_pin_group {
> > +	struct pingroup data;
> > +};
> 
> I don't see the necessity of having this wrapper structure. Can't you simply
> use struct pingroup directly?

Yeah. Let me drop the wrapper in v6.

> 
> ...
> 
> > +static int scmi_pinctrl_imx_probe(struct scmi_device *sdev) {
> > +	int ret;
> > +	struct device *dev = &sdev->dev;
> > +	struct scmi_pinctrl_imx *pmx;
> > +	const struct scmi_handle *handle;
> > +	struct scmi_protocol_handle *ph;
> > +	struct device_node *np __free(device_node) =
> of_find_node_by_path("/");
> > +	const struct scmi_pinctrl_proto_ops *pinctrl_ops;
> 
> > +	if (!sdev->handle)
> > +		return -EINVAL;
> 
> When this conditional can be true?

Just follow what other SCMI drivers do.
scmi_set_handle will get handles, per the code, there
might be NULL.

> 
> > +	if (!of_match_node(scmi_pinctrl_imx_allowlist, np))
> > +		return -ENODEV;
> 
> > +	handle = sdev->handle;
> 
> It's even better to assign first and then check if the above check is needed at
> all.

Yeah. Update in v6.

> 
> > +	pinctrl_ops = handle->devm_protocol_get(sdev,
> SCMI_PROTOCOL_PINCTRL, &ph);
> > +	if (IS_ERR(pinctrl_ops))
> > +		return PTR_ERR(pinctrl_ops);
> > +
> > +	pmx = devm_kzalloc(dev, sizeof(*pmx), GFP_KERNEL);
> > +	if (!pmx)
> > +		return -ENOMEM;
> > +
> > +	pmx->ph = ph;
> > +	pmx->ops = pinctrl_ops;
> > +
> > +	pmx->dev = dev;
> > +	pmx->pctl_desc.name = DRV_NAME;
> > +	pmx->pctl_desc.owner = THIS_MODULE;
> > +	pmx->pctl_desc.pctlops = &pinctrl_scmi_imx_pinctrl_ops;
> > +	pmx->pctl_desc.pmxops = &pinctrl_scmi_imx_pinmux_ops;
> > +	pmx->pctl_desc.confops = &pinctrl_scmi_imx_pinconf_ops;
> > +
> > +	ret = scmi_pinctrl_imx_get_pins(pmx, &pmx->pctl_desc);
> > +	if (ret)
> > +		return ret;
> > +
> > +	ret = scmi_pinctrl_imx_probe_dt(sdev, pmx);
> > +	if (ret)
> > +		return ret;
> > +
> > +	ret = devm_pinctrl_register_and_init(dev, &pmx->pctl_desc, pmx,
> > +					     &pmx->pctldev);
> > +	if (ret)
> > +		return dev_err_probe(dev, ret, "Failed to register pinctrl\n");
> > +
> > +	return pinctrl_enable(pmx->pctldev); }

Thanks,
Peng.
> 
> --
> With Best Regards,
> Andy Shevchenko
> 




More information about the linux-arm-kernel mailing list