[PATCH 1/2] pinctrl: imx: Support building SCU pinctrl driver as module

Anson Huang anson.huang at nxp.com
Mon Sep 7 04:34:24 EDT 2020



> Subject: RE: [PATCH 1/2] pinctrl: imx: Support building SCU pinctrl driver as
> module
> 
> > From: Anson Huang <Anson.Huang at nxp.com>
> > Sent: Thursday, July 16, 2020 11:07 PM
> > Subject: [PATCH 1/2] pinctrl: imx: Support building SCU pinctrl driver
> > as module
> >
> > To support building i.MX SCU pinctrl driver as module, below things
> > need to be
> > changed:
> >
> >     - Export SCU related functions
> 
> This line seems not comply with the patch anymore
> 

OK.

> > and use "IS_ENABLED" instead of
> >       "ifdef" to support SCU pinctrl driver user and itself to be
> >       built as module;
> >     - Use function callbacks for SCU related functions in pinctrl-imx.c
> >       in order to support the scenario of PINCTRL_IMX is built in
> >       while PINCTRL_IMX_SCU is built as module;
> >     - All drivers using SCU pinctrl driver need to initialize the
> >       SCU related function callback;
> >     - Change PINCTR_IMX_SCU to tristate;
> >     - Add module author, description and license.
> >
> > With above changes, i.MX SCU pinctrl driver can be built as module.
> >
> > Signed-off-by: Anson Huang <Anson.Huang at nxp.com>
> > ---
> >  drivers/pinctrl/freescale/Kconfig           |  2 +-
> >  drivers/pinctrl/freescale/pinctrl-imx.c     |  8 ++--
> >  drivers/pinctrl/freescale/pinctrl-imx.h     | 57 ++++++++++++-----------------
> >  drivers/pinctrl/freescale/pinctrl-imx8dxl.c |  3 ++
> > drivers/pinctrl/freescale/pinctrl-imx8qm.c  |  3 ++
> > drivers/pinctrl/freescale/pinctrl-imx8qxp.c |  3 ++
> >  drivers/pinctrl/freescale/pinctrl-scu.c     |  5 +++
> >  7 files changed, 42 insertions(+), 39 deletions(-)
> >
> > diff --git a/drivers/pinctrl/freescale/Kconfig
> > b/drivers/pinctrl/freescale/Kconfig
> > index 08fcf5c..570355c 100644
> > --- a/drivers/pinctrl/freescale/Kconfig
> > +++ b/drivers/pinctrl/freescale/Kconfig
> > @@ -7,7 +7,7 @@ config PINCTRL_IMX
> >  	select REGMAP
> >
> >  config PINCTRL_IMX_SCU
> > -	bool
> > +	tristate "IMX SCU pinctrl driver"
> 
> IMX SCU pinctrl core driver
> 

Will change it in V2.

> >  	depends on IMX_SCU
> >  	select PINCTRL_IMX
> >
> > diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c
> > b/drivers/pinctrl/freescale/pinctrl-imx.c
> > index 507e4af..b80c450 100644
> > --- a/drivers/pinctrl/freescale/pinctrl-imx.c
> > +++ b/drivers/pinctrl/freescale/pinctrl-imx.c
> > @@ -373,7 +373,7 @@ static int imx_pinconf_get(struct pinctrl_dev
> *pctldev,
> >  	const struct imx_pinctrl_soc_info *info = ipctl->info;
> >
> >  	if (info->flags & IMX_USE_SCU)
> > -		return imx_pinconf_get_scu(pctldev, pin_id, config);
> > +		return info->imx_pinconf_get(pctldev, pin_id, config);
> >  	else
> >  		return imx_pinconf_get_mmio(pctldev, pin_id, config);  } @@
> -423,7
> > +423,7 @@ static int imx_pinconf_set(struct pinctrl_dev *pctldev,
> >  	const struct imx_pinctrl_soc_info *info = ipctl->info;
> >
> >  	if (info->flags & IMX_USE_SCU)
> > -		return imx_pinconf_set_scu(pctldev, pin_id,
> > +		return info->imx_pinconf_set(pctldev, pin_id,
> >  					   configs, num_configs);
> >  	else
> >  		return imx_pinconf_set_mmio(pctldev, pin_id, @@ -440,7 +440,7
> @@
> > static void imx_pinconf_dbg_show(struct pinctrl_dev *pctldev,
> >  	int ret;
> >
> >  	if (info->flags & IMX_USE_SCU) {
> > -		ret = imx_pinconf_get_scu(pctldev, pin_id, &config);
> > +		ret = info->imx_pinconf_get(pctldev, pin_id, &config);
> >  		if (ret) {
> >  			dev_err(ipctl->dev, "failed to get %s pinconf\n",
> >  				pin_get_name(pctldev, pin_id));
> > @@ -629,7 +629,7 @@ static int imx_pinctrl_parse_groups(struct
> > device_node *np,
> >  	for (i = 0; i < grp->num_pins; i++) {
> >  		pin = &((struct imx_pin *)(grp->data))[i];
> >  		if (info->flags & IMX_USE_SCU)
> > -			imx_pinctrl_parse_pin_scu(ipctl, &grp->pins[i],
> > +			info->imx_pinctrl_parse_pin(ipctl, &grp->pins[i],
> >  						  pin, &list);
> >  		else
> >  			imx_pinctrl_parse_pin_mmio(ipctl, &grp->pins[i], diff --git
> > a/drivers/pinctrl/freescale/pinctrl-imx.h
> > b/drivers/pinctrl/freescale/pinctrl-imx.h
> > index 333d32b..bdb86c2 100644
> > --- a/drivers/pinctrl/freescale/pinctrl-imx.h
> > +++ b/drivers/pinctrl/freescale/pinctrl-imx.h
> > @@ -75,6 +75,21 @@ struct imx_cfg_params_decode {
> >  	bool invert;
> >  };
> >
> > +/**
> > + * @dev: a pointer back to containing device
> > + * @base: the offset to the controller in virtual memory  */ struct
> > +imx_pinctrl {
> > +	struct device *dev;
> > +	struct pinctrl_dev *pctl;
> > +	void __iomem *base;
> > +	void __iomem *input_sel_base;
> > +	const struct imx_pinctrl_soc_info *info;
> > +	struct imx_pin_reg *pin_regs;
> > +	unsigned int group_index;
> > +	struct mutex mutex;
> > +};
> 
> Any reason to move this part of code?


It is because below function callback added in imx_pinctrl_soc_info structure need to use imx_pinctrl, otherwise,
build will fail.

+       void (*imx_pinctrl_parse_pin)(struct imx_pinctrl *ipctl,


Anson


More information about the linux-arm-kernel mailing list