.../bindings/pinctrl/pinctrl-multiplexer.yaml | 57 +++++++ .../devicetree/bindings/pinctrl/pinctrl.yaml | 2 +- arch/arm64/boot/dts/freescale/Makefile | 4 + .../boot/dts/freescale/imx8mp-evk-flexcan2.dtso | 15 ++ arch/arm64/boot/dts/freescale/imx8mp-evk.dts | 23 ++- drivers/mux/core.c | 42 +++-- drivers/pinctrl/Kconfig | 9 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinconf.h | 18 ++ drivers/pinctrl/pinctrl-generic-mux.c | 185 +++++++++++++++++++++ drivers/pinctrl/pinctrl-generic.c | 95 ++++++----- drivers/pinctrl/pinmux.c | 5 + include/linux/mux/consumer.h | 8 +- include/linux/pinctrl/pinmux.h | 5 + 14 files changed, 410 insertions(+), 59 deletions(-)
Add a generic pinctrl binding for board-level pinmux chips that are
controlled through the multiplexer subsystem.
On some boards, especially development boards, external mux chips are used
to switch SoC signals between different peripherals (e.g. MMC and UART).
The mux select lines are often driven by a GPIO expander over I2C,
as illustrated below:
┌──────┐ ┌─────┐
│ SOC │ │ │ ┌───────┐
│ │ │ │───►│ MMC │
│ │ │ MUX │ └───────┘
│ ├─────►│ │ ┌───────┐
│ │ │ │───►│ UART │
│ │ └─────┘ └───────┘
│ │ ▲
│ │ ┌────┴──────────────┐
│ I2C ├───►│ GPIO Expander │
└──────┘ └───────────────────┘
Traditionally, gpio-hog is used to configure the onboard mux at boot.
However, the GPIO expander may probe later than consumer devices such as
MMC. As a result, the MUX might not be configured when the peripheral
driver probes, leading to initialization failures or data transfer errors.
Introduce a generic pinctrl binding that models the board-level MUX as a
pin control provider and builds proper device links between the MUX, its
GPIO controller, and peripheral devices. This ensures correct probe
ordering and reliable mux configuration.
The implementation leverages the standard multiplexer subsystem, which
provides broad support for onboard mux controllers and avoids the need for
per-driver custom MUX handling
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
Changes in v6:
- rebase to v7.1-rc2
- remove devm_mux_control_get() change because it is not used yet.
- fixes a AI review bugs about cur_select.
- fixes missed EXPORT_SYMBOL_GPL(pinctrl_generic_to_map)
- Link to v5: https://lore.kernel.org/r/20260327-pinctrl-mux-v5-0-d4aec9d62c62@nxp.com
Changes in v5:
- add npins to pinctrl_generic_to_map()
- remove pins = kmalloc() in pinctrl_generic_to_map().
- Link to v4: https://lore.kernel.org/r/20260325-pinctrl-mux-v4-0-043c2c82e623@nxp.com
Changes in v4:
- use Conor Dooley suggest to extract funciton pinctrl_generic_pins_to_map()
- Link to v3: https://lore.kernel.org/r/20260311-pinctrl-mux-v3-0-236b1c17bf9b@nxp.com
Changes in v3:
- collect rob's review tag for binding
- extend and use pinctrl_generic_pins_function_dt_node_to_map()
- add judgement about
commit 2243a87d90b42eb38bc281957df3e57c712b5e56
"pinctrl: avoid duplicated calling enable_pinmux_setting for a pin"
which call pinmux_disable_setting() before pinmux_enable_setting() when
switch state. It is actually what wanted. Previous remove .disable() to
avoid hardware glitch when switch state.
New .release_mux() call intent just release software resource, like lock,
don't touch hardware register. No glitch involve. Comments already added
Linus Walleij:
I hope this answer all of your questions. If I missed, let me know
- Link to v2: https://lore.kernel.org/r/20260225-pinctrl-mux-v2-0-1436a25fa454@nxp.com
Changes in v2:
- Add release_mux callback,
test insmod/rmmod, mux_state_(de)select() called.
- Link to v1: https://lore.kernel.org/r/20260219-pinctrl-mux-v1-0-678d21637788@nxp.com
---
Frank Li (7):
mux: add devm_mux_state_get_from_np() to get mux from child node
dt-bindings: pinctrl: Add generic pinctrl for board-level mux chips
pinctrl: extract pinctrl_generic_to_map() from pinctrl_generic_pins_function_dt_node_to_map()
pinctrl: add optional .release_mux() callback
pinctrl: add generic board-level pinctrl driver using mux framework
arm64: dts: imx8mp-evk: add board-level mux for CAN2 and MICFIL
arm64: dts: imx8mp-evk: add flexcan2 overlay file
.../bindings/pinctrl/pinctrl-multiplexer.yaml | 57 +++++++
.../devicetree/bindings/pinctrl/pinctrl.yaml | 2 +-
arch/arm64/boot/dts/freescale/Makefile | 4 +
.../boot/dts/freescale/imx8mp-evk-flexcan2.dtso | 15 ++
arch/arm64/boot/dts/freescale/imx8mp-evk.dts | 23 ++-
drivers/mux/core.c | 42 +++--
drivers/pinctrl/Kconfig | 9 +
drivers/pinctrl/Makefile | 1 +
drivers/pinctrl/pinconf.h | 18 ++
drivers/pinctrl/pinctrl-generic-mux.c | 185 +++++++++++++++++++++
drivers/pinctrl/pinctrl-generic.c | 95 ++++++-----
drivers/pinctrl/pinmux.c | 5 +
include/linux/mux/consumer.h | 8 +-
include/linux/pinctrl/pinmux.h | 5 +
14 files changed, 410 insertions(+), 59 deletions(-)
---
base-commit: 254f49634ee16a731174d2ae34bc50bd5f45e731
change-id: 20260213-pinctrl-mux-df9c5b661540
Best regards,
--
Frank Li <Frank.Li@nxp.com>
Hi Frank! On Tue, May 5, 2026 at 1:55 AM Frank Li <Frank.Li@nxp.com> wrote: > Add a generic pinctrl binding for board-level pinmux chips that are > controlled through the multiplexer subsystem. > > On some boards, especially development boards, external mux chips are used > to switch SoC signals between different peripherals (e.g. MMC and UART). > The mux select lines are often driven by a GPIO expander over I2C, > as illustrated below: > > ┌──────┐ ┌─────┐ > │ SOC │ │ │ ┌───────┐ > │ │ │ │───►│ MMC │ > │ │ │ MUX │ └───────┘ > │ ├─────►│ │ ┌───────┐ > │ │ │ │───►│ UART │ > │ │ └─────┘ └───────┘ > │ │ ▲ > │ │ ┌────┴──────────────┐ > │ I2C ├───►│ GPIO Expander │ > └──────┘ └───────────────────┘ > > Traditionally, gpio-hog is used to configure the onboard mux at boot. > However, the GPIO expander may probe later than consumer devices such as > MMC. As a result, the MUX might not be configured when the peripheral > driver probes, leading to initialization failures or data transfer errors. > > Introduce a generic pinctrl binding that models the board-level MUX as a > pin control provider and builds proper device links between the MUX, its > GPIO controller, and peripheral devices. This ensures correct probe > ordering and reliable mux configuration. > > The implementation leverages the standard multiplexer subsystem, which > provides broad support for onboard mux controllers and avoids the need for > per-driver custom MUX handling > > Signed-off-by: Frank Li <Frank.Li@nxp.com> I put the pinctrl patches on an immutable branch for testing again, if nothing explodes I will try to merge it for linux-next ASAP! Yours, Linus Walleij
On Tue, May 05, 2026 at 02:50:17PM +0200, Linus Walleij wrote: > Hi Frank! > > On Tue, May 5, 2026 at 1:55 AM Frank Li <Frank.Li@nxp.com> wrote: > > > Add a generic pinctrl binding for board-level pinmux chips that are > > controlled through the multiplexer subsystem. > > > > On some boards, especially development boards, external mux chips are used > > to switch SoC signals between different peripherals (e.g. MMC and UART). > > The mux select lines are often driven by a GPIO expander over I2C, > > as illustrated below: > > > > ┌──────┐ ┌─────┐ > > │ SOC │ │ │ ┌───────┐ > > │ │ │ │───►│ MMC │ > > │ │ │ MUX │ └───────┘ > > │ ├─────►│ │ ┌───────┐ > > │ │ │ │───►│ UART │ > > │ │ └─────┘ └───────┘ > > │ │ ▲ > > │ │ ┌────┴──────────────┐ > > │ I2C ├───►│ GPIO Expander │ > > └──────┘ └───────────────────┘ > > > > Traditionally, gpio-hog is used to configure the onboard mux at boot. > > However, the GPIO expander may probe later than consumer devices such as > > MMC. As a result, the MUX might not be configured when the peripheral > > driver probes, leading to initialization failures or data transfer errors. > > > > Introduce a generic pinctrl binding that models the board-level MUX as a > > pin control provider and builds proper device links between the MUX, its > > GPIO controller, and peripheral devices. This ensures correct probe > > ordering and reliable mux configuration. > > > > The implementation leverages the standard multiplexer subsystem, which > > provides broad support for onboard mux controllers and avoids the need for > > per-driver custom MUX handling > > > > Signed-off-by: Frank Li <Frank.Li@nxp.com> > > I put the pinctrl patches on an immutable branch for testing again, > if nothing explodes I will try to merge it for linux-next ASAP! I fixed a build warning by missing doc 'np', https://lore.kernel.org/imx/20260507152117.240612-1-Frank.Li@nxp.com/ Anything need me to do futher? Frank > > Yours, > Linus Walleij
On Mon, May 11, 2026 at 9:38 PM Frank Li <Frank.li@nxp.com> wrote: > I fixed a build warning by missing doc 'np', > https://lore.kernel.org/imx/20260507152117.240612-1-Frank.Li@nxp.com/ > > Anything need me to do futher? Sorry was busy! Applied this fixup on top of the branch and merged it into my devel branch for v7.2! Yours, Linus Walleij
On Mon, May 11, 2026 at 10:34:35PM +0200, Linus Walleij wrote: > On Mon, May 11, 2026 at 9:38 PM Frank Li <Frank.li@nxp.com> wrote: > > > I fixed a build warning by missing doc 'np', > > https://lore.kernel.org/imx/20260507152117.240612-1-Frank.Li@nxp.com/ > > > > Anything need me to do futher? > > Sorry was busy! > > Applied this fixup on top of the branch and merged it into my > devel branch for v7.2! Sorry, I missed picked up fix patch during rebase. https://lore.kernel.org/imx/20260512144806.22447-1-Frank.Li@nxp.com/T/#u Frank > > Yours, > Linus Walleij
On Tue, May 12, 2026 at 5:21 PM Frank Li <Frank.li@nxp.com> wrote: > On Mon, May 11, 2026 at 10:34:35PM +0200, Linus Walleij wrote: > > On Mon, May 11, 2026 at 9:38 PM Frank Li <Frank.li@nxp.com> wrote: > > > > > I fixed a build warning by missing doc 'np', > > > https://lore.kernel.org/imx/20260507152117.240612-1-Frank.Li@nxp.com/ > > > > > > Anything need me to do futher? > > > > Sorry was busy! > > > > Applied this fixup on top of the branch and merged it into my > > devel branch for v7.2! > > Sorry, I missed picked up fix patch during rebase. > > https://lore.kernel.org/imx/20260512144806.22447-1-Frank.Li@nxp.com/T/#u Ooops I should have seen it. Applied it now! Yours, Linus Walleij
© 2016 - 2026 Red Hat, Inc.