From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E420303A0D for ; Fri, 21 Aug 2026 03:35:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787283325; cv=none; b=HcobvpWc8pNo4ADsE4nK1+tdmohpCyUVNfvthjTOT+gJWTi11n+b9DETSHHtmfjTKjkYsc2vPcZsEXe9RJjP05gbKfWfKM4fTA6/HRWcptD3BZSp0qu949Znlitx7vppy8nSBdzitYZ15fye/3p7wpi3tgLAFOLLRsajdjcHt18= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787283325; c=relaxed/simple; bh=Iu0QD2B8pAArylWQdRg2VzdYyhgQP61ZNCD3634x7aE=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=rIa8MoWRXkv6cDH+s1rRK3zKHj+W/mvj5zCkgVtErCUu3MXoRm7wIEeA9FYUw6jIew2QnuHc0mtdKgYT0hg7Tnv5fK4qK8T1JjBe9DLFb7j8HcUeEgTaj5Pysfpd/+Nl2icHIZ2Jq+v/7eaXmd3D+oRQXeIizsw8sEV5FwVO/Wc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=IU54qIoa; arc=none smtp.client-ip=209.85.215.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IU54qIoa" Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-ca766c1c9ccso409096a12.0 for ; Thu, 20 Aug 2026 20:35:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787283323; x=1787888123; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=SkdRK2bgrcEfsbwZEpewjn1QrHLiNYWzfQtC0NyTn0U=; b=IU54qIoanrRAfCjvYVmWVefiPcfe61jD6Oyot1QSB4gmLAPz0/kIrvdCGSpGJ8hgy4 r7ty1q1aFfC0t7Klmh8LvCtS0swx/QAmUkyTd/vt84QYftRbyayZQEn/ZgRqRQKAMXp5 mreaTYFf/ByKZ4dhiYuSn7taYggW1n02UiGyR9pOXYtNiXUqOJUkcz2pCtGGH+Du7EBh U/S1nesnhDZS1ayEZ4aDKBf3trNZ1n8gT/lZWHXCLerpMhWC1RAOZjIUSHCSaZyXfcHu 4w4Xb7RvW9dxQNoE2hArdQ2OafRtab7jxxZD7FUlDLiJSygr94lyI4ix0ASbAWptMTtN yM/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787283323; x=1787888123; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=SkdRK2bgrcEfsbwZEpewjn1QrHLiNYWzfQtC0NyTn0U=; b=TQXvmzlsYxQ1X1nDtVZdVcH58Je6JhHh0iW2Zua6+KXpG8eK2VyoFeYt2hiy7/8IqJ MLf8HrShJbkh6OyKaORW2SBFj3KF9+5geRCq9SDsYjIHcw16/E305+9eRxCCsnYTEo9q 5kSm635j9LR3CEgTdAM41Dw5SHPjadjvGRD93IzPEKWMHqCf9r42si/yU6StuTJog4vF ysWvpd4cVp8pbwUQ1AhLptcrjbTOms12MGoVBAvXTMTYEG0gOXmRYRtEZkVXlcCjDg3/ Mm/jURP2DZ15CvjnwKOBGSAKyK2BLqrGESQ56atNgoXafv/3CMtqVrn92KmSMsVXr7xN z2qA== X-Gm-Message-State: AOJu0YzoCwclvEgMAnpHKv/a41IUpHAWpgeJxWzXtVg1VeVpWZDRyOeG UtjT9CR6q6L4A2hpDHmADNG30JPXhTe8GzVOXi8HLjPv+DvjgWyeUuX9 X-Gm-Gg: AR+sD11VpYydFAVfoyQQxXpFQfb4b//tBZiv8mEoBbIgAr6oFdtrMeBkLxoW4i3QOSx xgqSt/Po5+aqYOBG3ePls+VUioU+b2tmHEqQEt4n5bKnrxD58zRcznawwZl6gnZlzU9o46tEcrH ZFsfUkwa8FrF+3HiZbAV1W9cAnLN63fdFNn8mUAs117CONobQ1WehXCEv5S27WsX+N971ZngRCA R0bIQ7YxPMHpKJsT8a9Oc866tRxTEmSrlbbNpHyu8OPZ1XTRwwLZ1WpkPAq2eHwITV9TCy7CvFq g1hj/VLz1MChJNTjVfOzVa44ndVE4I6S6zoboIbPgMgQfQN27SA7gc3wYIeixuajyztQGY4/9bF 9VA2ptPzYWylb5FClvvpzwpTRMvAK55oM9UBlD0epUDIViAXCWI8Gp8NKArjUgIQ1xXf3aglY+u sfdQRRZigQ5ms/k4+x9IqaJzbt/lAUjhuBY46lNuZd0C4IM1lMChRavzjkaBufoTA+xTW07uf8Y y9ZSviasNmyuElillacnAu/81vwsKM= X-Received: by 2002:a05:6a21:6001:b0:3cc:fb7d:a9ab with SMTP id adf61e73a8af0-3cd2fd8e99emr6862832637.2.1787283322918; Thu, 20 Aug 2026 20:35:22 -0700 (PDT) Received: from hcdev-d520mt2.. (60-250-196-139.hinet-ip.hinet.net. [60.250.196.139]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cc15891a04csm2204271a12.15.2026.08.20.20.35.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2026 20:35:22 -0700 (PDT) From: a0282524688@gmail.com To: lee@kernel.org Cc: linux-kernel@vger.kernel.org, Ming Yu Subject: [PATCH v7 00/10] mfd: nct6694: Refactor transport layer and add HIF (eSPI) support Date: Fri, 21 Aug 2026 11:34:55 +0800 Message-Id: <20260821033505.4017901-1-a0282524688@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Ming Yu The Nuvoton NCT6694 is a peripheral expander that provides GPIO, I2C, CAN-FD, Watchdog, HWMON, PWM, and RTC sub-devices. Currently, the driver only supports USB as the host transport interface. This series refactors the NCT6694 MFD core to support multiple transport backends and adds a new Host Interface (HIF) transport driver that communicates over eSPI using Super-I/O shared memory. The refactoring is split into small, self-contained steps: the USB transport is first isolated behind a dedicated data structure and file (nct6694-usb.c), the transport-agnostic device management is extracted into a new core module (nct6694-core.c), and the firmware command interface is then wrapped behind regmap so that sub-device drivers no longer reference any transport detail. The HIF (eSPI) driver is finally added cleanly on top of this abstraction, reusing the shared core. Patches 6 to 8 fix pre-existing bugs in the USB transport that were pointed out during the v6 review. They carry a Fixes tag and are placed before the regmap rework so that they can be picked up independently. Changes since version 6: - Transfer command payloads through a buffer owned by the transport instead of the caller's, which may be embedded in a sub-device structure and is therefore not safe to map for DMA. - Locate the interrupt IN endpoint with usb_find_int_in_endpoint() rather than reading endpoint[0] unchecked. - Submit the interrupt URB after the core has created the IRQ domain, and kill it before the core is removed. - HIF: zero the tail of the caller buffer on a short firmware response, request the interrupt before registering the core so that devres releases it last, skip unmapped hardware interrupts, return IRQ_HANDLED once the status has been cleared, reject an unconfigured shared memory base address, and program the SIRQ register with the hardware interrupt number instead of the Linux virq. Changes since version 5: - Replaced the custom read_msg/write_msg function-pointer indirection with a regmap-based transport abstraction. The firmware addressing (host control, module id and 16-bit offset) is packed into a single 32-bit regmap register, so sub-device drivers use the standard regmap bulk accessors while each transport implements its own regmap_bus. - Added nct6694_write_read_msg() for the few commands (e.g. the I2C "deliver") that send a request and read the reply back in a single transaction, and converted the I2C transfer path to use it. - Dropped the per-transport access_lock; regmap already serialises bus accesses on its own. - Reordered the series accordingly: rename the USB I/O functions and the driver file first, extract the transport-agnostic core, then introduce the regmap abstraction, and finally add the HIF driver. Changes since version 4: - Split the monolithic refactoring and HIF support patch into a series of smaller, logical commits to improve reviewability and adhere to the single logical change principle. - Decoupled USB-specific data into a dedicated 'nct6694_usb_data' structure referenced through a void *priv pointer in the core. - Renamed the existing driver to 'nct6694-usb.c' to strictly identify its transport boundary, alongside Kconfig/Makefile updates. - Extracted transport-agnostic device management (IRQ domain setup, IDA initialization, and MFD cell registration) into a standalone 'nct6694-core.c' module. - Added the 'nct6694-hif' eSPI transport driver on top of the new core abstraction. Changes since version 3: - Remove redundant module type macro definitions from sub-device drivers that are now provided by the shared header , fixing -Wmacro-redefined warnings. Changes since version 2: - Restore per-device IDA and mfd_add_hotplug_devices()/PLATFORM_DEVID_AUTO to avoid child device ID conflicts with multiple NCT6694 chips. - Validate irq_find_mapping() return value before dispatching IRQs. - Check superio_enter() return value in nct6694_irq_init(). Changes since version 1: - Reworked the Super-I/O access helpers. Ming Yu (10): mfd: nct6694: Move module type macros to shared header mfd: nct6694: Refactor USB-specific data into nct6694_usb_data mfd: nct6694: Rename USB transport functions with _usb_ prefix mfd: nct6694: Rename driver to nct6694-usb and update Kconfig mfd: nct6694: Extract core device management into a separate module mfd: nct6694: Transfer command payloads via a dedicated DMA buffer mfd: nct6694: Validate the interrupt IN endpoint mfd: nct6694: Submit the interrupt URB after the core is registered mfd: nct6694: Introduce regmap-based transport abstraction mfd: nct6694: Add Host Interface (HIF) eSPI transport driver MAINTAINERS | 2 +- drivers/gpio/gpio-nct6694.c | 7 - drivers/hwmon/nct6694-hwmon.c | 21 - drivers/i2c/busses/i2c-nct6694.c | 9 +- drivers/mfd/Kconfig | 48 ++- drivers/mfd/Makefile | 4 +- drivers/mfd/nct6694-core.c | 136 +++++++ drivers/mfd/nct6694-hif.c | 590 ++++++++++++++++++++++++++++ drivers/mfd/nct6694-usb.c | 388 ++++++++++++++++++ drivers/mfd/nct6694.c | 388 ------------------ drivers/net/can/usb/nct6694_canfd.c | 6 - drivers/rtc/rtc-nct6694.c | 7 - drivers/watchdog/nct6694_wdt.c | 7 - include/linux/mfd/nct6694.h | 104 ++++- 14 files changed, 1242 insertions(+), 475 deletions(-) create mode 100644 drivers/mfd/nct6694-core.c create mode 100644 drivers/mfd/nct6694-hif.c create mode 100644 drivers/mfd/nct6694-usb.c delete mode 100644 drivers/mfd/nct6694.c -- 2.34.1