From: Lee Jones <lee@kernel.org>
To: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: Guenter Roeck <linux@roeck-us.net>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>, Peter Rosin <peda@axentia.se>,
Linus Walleij <linusw@kernel.org>,
kernel@pengutronix.de, linux-kernel@vger.kernel.org,
devicetree@vger.kernel.org, linux-hwmon@vger.kernel.org,
linux-gpio@vger.kernel.org, David Jander <david@protonic.nl>
Subject: Re: [PATCH v12 2/6] mfd: add NXP MC33978/MC34978 core driver
Date: Thu, 4 Jun 2026 14:51:48 +0100 [thread overview]
Message-ID: <20260604135148.GB4151951@google.com> (raw)
In-Reply-To: <20260515160537.115808-3-o.rempel@pengutronix.de>
On Fri, 15 May 2026, Oleksij Rempel wrote:
> Add core Multi-Function Device (MFD) driver for the NXP MC33978 and
> MC34978 Multiple Switch Detection Interfaces (MSDI).
>
> The MC33978/MC34978 devices provide 22 switch detection inputs, analog
> multiplexing (AMUX), and comprehensive hardware fault detection.
>
> This core driver handles:
> - SPI communications via a custom regmap bus to support the device's
> pipelined two-frame MISO response requirement.
> - Power sequencing for the VDDQ (logic) and VBATP (battery) regulators.
> - Interrupt demultiplexing, utilizing an irq_domain to provide 22 virtual
> IRQs for switch state changes and 1 virtual IRQ for hardware faults.
> - Inline status harvesting from the SPI MSB to detect and trigger events
> without requiring dedicated status register polling.
>
> Child devices (pinctrl, hwmon, mux) are instantiated by the core driver
> from match data.
>
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---
> changes v12:
> - Split monolithic MFD driver into two modules per maintainer feedback:
> * drivers/mfd/mc33978.c: Thin wrapper for SPI binding, power sequencing,
> and child device registration
> * drivers/platform/misc/mc33978-core.c: Complex core functionality
> including custom regmap bus, IRQ domain, and event handling
> - Add mc33978_core_init() API exported by core module for MFD initialization
> - Introduce CONFIG_MC33978_CORE in drivers/platform/misc/Kconfig
> - Update CONFIG_MFD_MC33978 to select CONFIG_MC33978_CORE
> - Add MODULE_SOFTDEP("pre: mc33978-core") to ensure correct module load order
> - Rename struct mc33978_mfd_priv to context-specific names:
> * mc33978_ddata in MFD driver
> * mc33978_core_data in core module
> - Rename local variables from 'mc' to 'ddata'/'cdata' for clarity
> - Replace MC33978_DRV_NAME macro with string literal "mc33978"
> - Convert kerneldoc (/** */) on static functions to regular comments (/* */)
> - Adopt 100-character line limit throughout
> - Fix misleading cacheline alignment comment ("must be at end" -> "prevent
> DMA corruption from adjacent fields")
> - Document IRQ locking strategy explicitly (irq_lock mutex for regmap/SPI,
> irq_state_lock raw spinlock for atomic state access)
> - Reformat header file comments from inline style to preceding style for
> improved readability
> - Enhance interrupt behavior documentation with detailed datasheet references
> explaining INT_flg clear timing and FAULT_STAT latching behavior
> - add .suppress_bind_attrs = true
> changes v11:
> - Introduce synthetic wakeup bit to prevent hardware bit overloading and
> avoid phantom transient faults.
> - Add smp_mb__before_atomic() to ensure memory visibility before
> updating harvested_flags.
> - Update event processing to mask synthetic bits before evaluating
> hardware fault conditions.
> - Introduce fault_lock spinlock to protect fault state members.
> - Replace manual memory barriers and READ_ONCE/WRITE_ONCE with
> spinlock-protected access.
> - Introduce irq_state_lock raw spinlock to protect IRQ state fields.
> - Replace irq_lock mutex with raw spinlock in IRQ callbacks and event
> handling paths.
> - Include MC33978_REG_ENTER_LPM in volatile and precious ranges.
> - Mark MC33978_REG_ENTER_LPM as readable to avoid regcache sync writes.
> changes v10:
> - Refactor IRQ setup into a common helper to unify the .map and .alloc
> code paths.
> - Enable hierarchical IRQ support to allow integration with the
> pinctrl/GPIO child domain.
> - Simplify event handling by removing redundant boolean return values
> from internal handlers.
> - Fix IRQ cleanup by disposing of all active mappings before removing
> the IRQ domain.
> - Standardize IRQ constants using MC33978_NUM_IRQS for consistent domain
> sizing and bounds checks.
> changes v9:
> - Fix null irq_domain dereference from debugfs race by initializing IRQ domain
> early before regmap initialization.
> - Refactor mc33978_handle_fault_condition() to improve readability by keeping
> variable declarations at the top and adding inline comments.
> - Fix spurious transient fault events caused by redundant STAT_FAULT flags
> during event loop.
> - Fix spurious interrupt loops by explicitly returning -ENODATA in
> mc33978_rx_decode() for registers without status bits.
> - Validate hwirq bounds in mc33978_irq_domain_alloc() to prevent corruption
> of irq_rise/irq_fall bitmasks by malformed device tree inputs.
> - set DOMAIN_BUS_NEXUS
> - Protect work on teardown
> - remove IRQF_SHARED
> changes v8:
> - Fix TOCTOU race condition in SPI event harvesting loop by grabbing
> harvested_flags before hardware reads.
> - Fix broken hierarchical IRQ allocation by replacing
> irq_domain_set_hwirq_and_chip() with irq_domain_set_info() and passing
> the handle_simple_irq flow handler.
> - Fix out-of-bounds stack read and endianness bug in for_each_set_bit() by
> typing fired_pins as unsigned long instead of casting u32.
> - Prevent DMA cacheline corruption by explicitly aligning rx_frame with
> ____cacheline_aligned to separate it from tx_frame.
> - Prevent spurious IRQs by verifying irq_find_mapping() returns non-zero
> before calling handle_nested_irq().
> - Prevent missed transient hardware faults by explicitly evaluating
> hw_flags in mc33978_handle_fault_condition().
> - Fix missing memory barrier in mc33978_harvest_status() with
> smp_mb__after_atomic() to ensure harvested_flags visibility.
> - Fix devres use-after-free teardown race by using INIT_WORK and a custom
> cancel action after the IRQ domain is destroyed, instead of
> devm_work_autocancel.
> - Prevent spurious pin interrupts on boot by priming cached_pin_state via
> a regmap_read() during probe before enabling IRQs.
> - Implement .irq_set_wake callback to support system wake from
> hardware faults and switch state changes.
> changes v7:
> - Fix event handling race condition with smp_mb()
> - Replace INIT_WORK() with devm_work_autocancel()
> changes v6:
> - Remove the hardcoded bypass in irq_set_type to allow child drivers to
> configure the FAULT line for edge-triggering.
> - Implement software edge-detection for FAULT interrupt.
> - Add MC33978_FAULT_ALARM_MASK to the shared header for child devices
> - Use READ_ONCE() and WRITE_ONCE() for lockless shared state variables
> (cached_pin_mask, irq_rise, irq_fall, bus_fault_active,
> cached_fault_active) accessed across the SPI harvesting context and
> the event worker.
> - Add an if (hwirq < MC33978_NUM_PINS) guard in irq_mask() and
> irq_unmask() to prevent the FAULT hwirq (22) from altering the
> physical pin mask registers.
> - Lowercase the error strings in dev_err_probe()
> - Add inline comments explaining the irq_map fallback behavior
> changes v5:
> - no changes
> changes v4:
> - Removed .of_compatible strings from the mfd_cell arrays
> changes v3:
> - Select IRQ_DOMAIN_HIERARCHY in Kconfig
> - Add .alloc and .free callbacks to irq_domain_ops to support hierarchical
> IRQ domains
> - Set IRQ_DOMAIN_FLAG_HIERARCHY flag on the core MFD irq_domain
> - replace manual lock/unlock with guard()
> changes v2:
> - Rewrite the driver header comment
> - Explicitly reject IRQ_TYPE_LEVEL_HIGH and IRQ_TYPE_LEVEL_LOW in
> mc33978_irq_set_type() to correctly reflect the hardware's edge-only
> interrupt capabilities.
> - Pass the hardware fault IRQ to the hwmon child driver via mfd_cell
> resources, rather than requiring the child to parse the parent's irq_domain.
> - Ensure the Kconfig strictly depends on OF and SPI
> ---
> drivers/mfd/Kconfig | 15 +
> drivers/mfd/Makefile | 2 +
> drivers/mfd/mc33978.c | 187 +++++
> include/linux/mfd/mc33978.h | 160 ++++
This is one patch.
> drivers/platform/Kconfig | 2 +
> drivers/platform/Makefile | 1 +
> drivers/platform/misc/Kconfig | 10 +
> drivers/platform/misc/Makefile | 6 +
> drivers/platform/misc/mc33978-core.c | 1106 ++++++++++++++++++++++++++
This should be in another.
> 9 files changed, 1489 insertions(+)
> create mode 100644 drivers/mfd/mc33978.c
> create mode 100644 drivers/platform/misc/Kconfig
> create mode 100644 drivers/platform/misc/Makefile
> create mode 100644 drivers/platform/misc/mc33978-core.c
> create mode 100644 include/linux/mfd/mc33978.h
--
Lee Jones
next prev parent reply other threads:[~2026-06-04 13:51 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-15 16:05 [PATCH v12 0/6] mfd: Add support for NXP MC33978/MC34978 MSDI Oleksij Rempel
2026-05-15 16:05 ` [PATCH v12 1/6] dt-bindings: pinctrl: add " Oleksij Rempel
2026-05-15 16:05 ` [PATCH v12 2/6] mfd: add NXP MC33978/MC34978 core driver Oleksij Rempel
2026-05-15 16:48 ` sashiko-bot
2026-06-04 13:51 ` Lee Jones [this message]
2026-05-15 16:05 ` [PATCH v12 3/6] pinctrl: core: Make pin group callbacks optional for pin-only drivers Oleksij Rempel
2026-05-15 17:43 ` sashiko-bot
2026-05-16 8:06 ` Krzysztof Kozlowski
2026-05-23 9:37 ` Linus Walleij
2026-05-15 16:05 ` [PATCH v12 4/6] pinctrl: add NXP MC33978/MC34978 pinctrl driver Oleksij Rempel
2026-05-15 18:07 ` sashiko-bot
2026-05-15 16:05 ` [PATCH v12 5/6] hwmon: add NXP MC33978/MC34978 driver Oleksij Rempel
2026-05-15 18:38 ` sashiko-bot
2026-05-16 8:06 ` Krzysztof Kozlowski
2026-05-15 16:05 ` [PATCH v12 6/6] mux: add NXP MC33978/MC34978 AMUX driver Oleksij Rempel
2026-05-15 19:07 ` sashiko-bot
2026-05-16 7:56 ` Krzysztof Kozlowski
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=20260604135148.GB4151951@google.com \
--to=lee@kernel.org \
--cc=conor+dt@kernel.org \
--cc=david@protonic.nl \
--cc=devicetree@vger.kernel.org \
--cc=kernel@pengutronix.de \
--cc=krzk+dt@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=o.rempel@pengutronix.de \
--cc=peda@axentia.se \
--cc=robh@kernel.org \
/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