Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@nxp.com>
To: Linus Walleij <linusw@kernel.org>
Cc: "Peter Rosin" <peda@axentia.se>, "Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Rafał Miłecki" <rafal@milecki.pl>,
	"Sascha Hauer" <s.hauer@pengutronix.de>,
	"Pengutronix Kernel Team" <kernel@pengutronix.de>,
	"Fabio Estevam" <festevam@gmail.com>,
	linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,
	devicetree@vger.kernel.org, imx@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	"Haibo Chen" <haibo.chen@nxp.com>
Subject: Re: [PATCH v2 4/6] pinctrl: add generic board-level pinctrl driver using mux framework
Date: Thu, 5 Mar 2026 12:37:53 -0500	[thread overview]
Message-ID: <aam_cZhlCSxu5WHS@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <CAD++jLm=6pTh7N5UAXFaaYWCs5DhfQdb+8TnM5XLcYC886=kLw@mail.gmail.com>

On Mon, Mar 02, 2026 at 11:11:00AM +0100, Linus Walleij wrote:
> On Fri, Feb 27, 2026 at 4:23 PM Frank Li <Frank.li@nxp.com> wrote:
> > On Fri, Feb 27, 2026 at 10:20:14AM +0100, Linus Walleij wrote:
> > > On Thu, Feb 26, 2026 at 12:55 AM Frank Li <Frank.Li@nxp.com> wrote:
>
> > > > +static void mux_pinmux_release_mux(struct pinctrl_dev *pctldev,
> > > > +                                  unsigned int func_selector,
> > > > +                                  unsigned int group_selector)
> > > > +{
> > > > +       struct mux_pinctrl *mpctl = pinctrl_dev_get_drvdata(pctldev);
> > > > +       const struct function_desc *function;
> > > > +       struct mux_pin_function *func;
> > > > +
> > > > +       guard(mutex)(&mpctl->lock);
> > > > +
> > > > +       function = pinmux_generic_get_function(pctldev, func_selector);
> > > > +       func = function->data;
> > > > +
> > > > +       mux_state_deselect(func->mux_state);
> > > > +
> > > > +       mpctl->cur_select = -1;
> > > > +}
> > >
> > > As mentioned I have my doubts about this, explain why this hardware
> > > is so different that this is needed.
> >
> > As board mux (uart and flexcan) exist, for example, only one of UART and
> > FlexCAN work.
> >
> > when modprobe uart.ko,  mux_state_select called.
> >
> > So flexcan driver can't get such mux as expected.
> >
> > when remmod uart.ko, we need release mux_state, so flexcan driver can
> > get such resource.
> >
> > Genernally, DT may only enouble one of UART or flexcan.
> >
> > but insmod uart.ko
> >     rmmod uart.ko
> >
> >     insmod uart.ko (here also need release previous's state at prevous rmmod).
>
> Can't you just enter the state "init"? This can be used
> explicitly on the uart .remove() path using pinctrl_pm_select_init_state().
>
> Sure the device core does not do it automatically but this is a
> special case.
>
> If you want a generic solution without having to change any drivers,
> Add pinctrl_unbind_pins() to drivers/base/pinctrl.c and call on the
> generic .remove path for all drivers to put the device into "init"
> state during rmmod.
>
> This gives us better control of the actual hardware states I think?

init state is before probe if exist, which not fit this case because:
- on board mux need be enabled before probe, some device need communicate
with periphal at probe, such as SD card. SD data/cmd line must be ready
to scan SD, similar case for all mtd devices.

if add new state "release",  when the pinctrl may switch between default,
sleep, ... , "release" have to switch between switch state, such as default
 -> sleep have to change to default->release->sleep.

mux device also have idle state, which map to pinctrl's "init" or "sleep"
state.

The key difference should be
- pinctrl can uncondtional switch state.
- mux frame have to use pair mux_control_(de)select() to switch state.

So, I think just need a hook in pinctrl system to call mux_control_deselect()
when switch state and release resource.

Frank

>
> Yours,
> Linus Walleij


  reply	other threads:[~2026-03-05 17:38 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-25 23:55 [PATCH v2 0/6] pinctrl: Add generic pinctrl for board-level mux chips Frank Li
2026-02-25 23:55 ` [PATCH v2 1/6] mux: add devm_mux_control_get_from_np() to get mux from child node Frank Li
2026-02-25 23:55 ` [PATCH v2 2/6] dt-bindings: pinctrl: Add generic pinctrl for board-level mux chips Frank Li
2026-02-27  9:02   ` Linus Walleij
2026-03-06  0:57   ` Rob Herring (Arm)
2026-02-25 23:55 ` [PATCH v2 3/6] pinctrl: add optional .release_mux() callback Frank Li
2026-02-27  9:07   ` Linus Walleij
2026-02-27 15:32     ` Frank Li
2026-03-02 10:12       ` Linus Walleij
2026-02-25 23:55 ` [PATCH v2 4/6] pinctrl: add generic board-level pinctrl driver using mux framework Frank Li
2026-02-27  9:09   ` Daniel Baluta
2026-02-27  9:20   ` Linus Walleij
2026-02-27 15:22     ` Frank Li
2026-03-02 10:11       ` Linus Walleij
2026-03-05 17:37         ` Frank Li [this message]
2026-03-08 23:49           ` Linus Walleij
2026-02-25 23:55 ` [PATCH v2 5/6] arm64: dts: imx8mp-evk: add board-level mux for CAN2 and MICFIL Frank Li
2026-02-25 23:55 ` [PATCH v2 6/6] arm64: dts: imx8mp-evk: add flexcan2 overlay file Frank Li

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=aam_cZhlCSxu5WHS@lizhi-Precision-Tower-5810 \
    --to=frank.li@nxp.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=festevam@gmail.com \
    --cc=haibo.chen@nxp.com \
    --cc=imx@lists.linux.dev \
    --cc=kernel@pengutronix.de \
    --cc=krzk+dt@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peda@axentia.se \
    --cc=rafal@milecki.pl \
    --cc=robh@kernel.org \
    --cc=s.hauer@pengutronix.de \
    /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