From: Anson Huang <anson.huang@nxp.com>
To: Aisheng Dong <aisheng.dong@nxp.com>,
"festevam@gmail.com" <festevam@gmail.com>,
"shawnguo@kernel.org" <shawnguo@kernel.org>,
"stefan@agner.ch" <stefan@agner.ch>,
"kernel@pengutronix.de" <kernel@pengutronix.de>,
"linus.walleij@linaro.org" <linus.walleij@linaro.org>,
"s.hauer@pengutronix.de" <s.hauer@pengutronix.de>,
"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Cc: dl-linux-imx <linux-imx@nxp.com>
Subject: RE: [PATCH V5 1/9] pinctrl: imx: Support building SCU pinctrl driver as module
Date: Wed, 17 Jun 2020 03:19:19 +0000 [thread overview]
Message-ID: <DB3PR0402MB391687D9A9CFAAAEB3E4F236F59A0@DB3PR0402MB3916.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <AM6PR04MB49661AA8A25B73D04FFF6769809A0@AM6PR04MB4966.eurprd04.prod.outlook.com>
> Subject: RE: [PATCH V5 1/9] pinctrl: imx: Support building SCU pinctrl driver as
> module
>
> > From: Anson Huang <anson.huang@nxp.com>
> > Sent: Tuesday, June 16, 2020 6:44 PM
> >
> > > Subject: RE: [PATCH V5 1/9] pinctrl: imx: Support building SCU
> > > pinctrl driver as module
> > >
> > > > From: Anson Huang <Anson.Huang@nxp.com>
> > > > Sent: Thursday, June 11, 2020 7:35 PM
> > > >
> > > > To support building i.MX SCU pinctrl driver as module, below
> > > > things need to be
> > > > changed:
> > > >
> > > > - Export SCU related functions 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@nxp.com>
> > > > ---
> > > > Changes since V4:
> > > > - add module author and description.
> > > > ---
> > > > drivers/pinctrl/freescale/Kconfig | 2 +-
> > > > drivers/pinctrl/freescale/pinctrl-imx.c | 18 ++++-----
> > > > 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 | 9 +++++
> > > > 7 files changed, 51 insertions(+), 44 deletions(-)
> > > >
> > > > diff --git a/drivers/pinctrl/freescale/Kconfig
> > > > b/drivers/pinctrl/freescale/Kconfig
> > > > index 4ca44dd..a3a30f1d 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"
> > > > depends on IMX_SCU
> > > > select PINCTRL_IMX
> > > >
> > > > diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c
> > > > b/drivers/pinctrl/freescale/pinctrl-imx.c
> > > > index cb7e0f0..c1faae1 100644
> > > > --- a/drivers/pinctrl/freescale/pinctrl-imx.c
> > > > +++ b/drivers/pinctrl/freescale/pinctrl-imx.c
> > > > @@ -372,8 +372,8 @@ static int imx_pinconf_get(struct pinctrl_dev
> > > *pctldev,
> > > > struct imx_pinctrl *ipctl = pinctrl_dev_get_drvdata(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);
> > > > + if ((info->flags & IMX_USE_SCU) && info->imx_pinconf_get)
> > > > + return info->imx_pinconf_get(pctldev, pin_id, config);
> > >
> > > Pointer check here seems not be necessary
> >
> > I think it is NOT harmful and it is just in case the drivers using scu
> > pinctrl do NOT initialize these functions callback and lead to NULL pointer
> dump.
> >
>
> It is a bit harmful to the code readability as we already use flag IMX_USE_SCU
> to distinguish the difference. Not need double check the pointer again because
> platforms driver must have defined it.
I am fine, it is just because checking the function callback before calling it is better.
I can remove it if you insist to NOT check it. If there is other comment, will remove
them together in next version.
>
> > >
> > > > 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;
> > > > +};
> > > > +
> > > > struct imx_pinctrl_soc_info {
> > > > const struct pinctrl_pin_desc *pins;
> > > > unsigned int npins;
> > > > @@ -98,21 +113,13 @@ struct imx_pinctrl_soc_info {
> > > > struct pinctrl_gpio_range *range,
> > > > unsigned offset,
> > > > bool input);
> > > > -};
> > > > -
> > > > -/**
> > > > - * @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;
> > > > + int (*imx_pinconf_get)(struct pinctrl_dev *pctldev, unsigned int
> pin_id,
> > > > + unsigned long *config);
> > > > + int (*imx_pinconf_set)(struct pinctrl_dev *pctldev, unsigned int
> pin_id,
> > > > + unsigned long *configs, unsigned int num_configs);
> > > > + void (*imx_pinctrl_parse_pin)(struct imx_pinctrl *ipctl,
> > > > + unsigned int *pin_id, struct imx_pin *pin,
> > > > + const __be32 **list_p);
> > >
> > > Compared with V4, this new implementation seems a bit complicated.
> > > I guess we don't have to support PINCTRL_IMX=y && PINCTRL_IMX_SCU=m
> > > case.
> > > Will that make the support a bit easier?
> >
> > I am NOT sure if such scenario meets requirement, the fact is other
> > non-i.MX SoC also selects the PINCTRL_IMX which will make
> > PINCTRL_IMX=y, so in that case, even all i.MX PINCTRL drivers are set
> > to module, it will still have PINCTRL_IMX=y and PINCTRL_IMX_SCU=m,
> > then build will fail. And I believe the auto build test may also cover
> > such case and build error will be reported, that is why this change is
> > needed and with this change, function is NOT impacted,
> >
>
> Is it possible to add some constrainst to make sure PINCTRL_IMX_SCU value is
> the same as PINCTRL_IMX? Or combine them into one?
> If we can do that, it may ease the implementation a lot and make the code still
> clean.
Combine PINCTRL_IMX_SCU and PINCTRL_IMX is NOT making sense, since for non-SCU
platforms, PINCTRL_IMX_SCU is NOT necessary, to make PINCTRL_IMX_SCU same value
as PINCTRL_IMX, unless make "select PINCTRL_IMX_SCU" in PINCTRL_IMX, but that is
also NOT making sense, because, PINCTRL_IMX does NOT depends on PINCTRL_IMX_SCU
at all.
The change is NOT that big IMO, and no better idea in my mind, have tried that in previous versions
of patch series.
Anson
next prev parent reply other threads:[~2020-06-17 3:19 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-11 11:34 [PATCH V5 0/9] Support i.MX8 SoCs pinctrl drivers built as module Anson Huang
2020-06-11 11:34 ` [PATCH V5 1/9] pinctrl: imx: Support building SCU pinctrl driver " Anson Huang
2020-06-16 9:19 ` Aisheng Dong
2020-06-16 10:44 ` Anson Huang
2020-06-17 2:59 ` Aisheng Dong
2020-06-17 3:19 ` Anson Huang [this message]
2020-06-17 10:29 ` Aisheng Dong
2020-06-17 13:43 ` Anson Huang
2020-06-11 11:34 ` [PATCH V5 2/9] pinctrl: imx: Support building i.MX " Anson Huang
2020-06-11 11:34 ` [PATCH V5 3/9] pinctrl: imx8mm: Support building " Anson Huang
2020-06-11 11:34 ` [PATCH V5 4/9] pinctrl: imx8mn: " Anson Huang
2020-06-11 11:34 ` [PATCH V5 5/9] pinctrl: imx8mq: " Anson Huang
2020-06-11 11:34 ` [PATCH V5 6/9] pinctrl: imx8mp: " Anson Huang
2020-06-11 11:34 ` [PATCH V5 7/9] pinctrl: imx8qxp: " Anson Huang
2020-06-11 11:34 ` [PATCH V5 8/9] pinctrl: imx8qm: " Anson Huang
2020-06-11 11:34 ` [PATCH V5 9/9] pinctrl: imx8dxl: " Anson Huang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DB3PR0402MB391687D9A9CFAAAEB3E4F236F59A0@DB3PR0402MB3916.eurprd04.prod.outlook.com \
--to=anson.huang@nxp.com \
--cc=aisheng.dong@nxp.com \
--cc=festevam@gmail.com \
--cc=kernel@pengutronix.de \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=stefan@agner.ch \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).