From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.169 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796009045; b=l7ZUKe7TNu77BhODtK3kXSIl3L4uK1259LNSxKrp6FM0aTN8PepotaKMQewIWY+pSX2M +WJx+2yT9zF2ro3JXbxJ/n71NquCppFnEHWvxK/BpVxk72OQ73a/iJLUOdABGPORtFmTB Kk31bBtTK8YqMZ+YWB98glWMpaBgJGRAfS97HTeuByBe/C98Qh82ey2Xll7hpHDC57otS NMvKrnnLtdKAnaIfz3RZCwYRv4Usu5HX2NUoolBddLgLUPCGlsREPFuyb36f174kusiU0 7Ohn+erkOWR8NpoR8rO1ZEWywVrXZcS74xxAGznHJ6dP+cyrXDkKMfLaE2xf6MtvJlw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796009045; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-Id:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=6KuAacuQ3TofdjXUjO0odKsMeoKMHrjeoapAwfXqd0E=; b=qtBwsZCwxUGH5ikUzwN5f1eHeFR1dp7oAaR9DGJOU/MiXP+/8ia9UlD974yYdTzBNyas FmQDVZD6P0AfcYqjuEhSDo44pv54rfIYMBcl8ZnpOUnHULwmyFEeUqSGYf4SyaandrpvE 2W94p1tXYPKbClLNGEaKZs/Kcgs8KYO7OhaIQkTxPwPJeSWXXUAlyxTJJ5MGyrd1g/7bd KMBdmRXlAKEF6H1yGsGrynw8tp9U8ln8DtS34P+bKjiA98AcfMI+oPz9Zgc5SQDC/oWsv Bwc9E36qr2o6Ejx404ktwedLjaqIDkQeYHh/0Bpy1VlCrlHZ6uBDOGN1BdlifG4OVJA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=jPhxjq7p; arc=none smtp.remote-ip=209.85.210.169 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2021606A32A for ; Mon, 30 Nov 2026 03:24:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A2021606A32A 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.a=rsa-sha256 header.s=20260707 header.b=jPhxjq7p Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-8a06e79e152so4732030b3a.0 for ; Sun, 29 Nov 2026 19:24:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796009044; x=1796613844; 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=6KuAacuQ3TofdjXUjO0odKsMeoKMHrjeoapAwfXqd0E=; b=jPhxjq7pOinJWl57YwX8s+JhRCGx13ySC7IcMHOT2Wx/O/4R8QLyH4TYp+vPUuq6Mg fFVUCJV9dyKabGHqk4TSyol+X1/vGWPMGNvfdQ8jaiaHAqqTwF31CNstVa0vh/z7ufg+ 0qUCBl/YGsm4tm+q3LoxXrUnpRgeuzXZrq5oeAgR1d+YpcRWKe9IMdKKarza6MeNfo5B DKJNRUQ0sDVuaYwCDyzbBLajywEKdVdTjXok610tS8b5LLXVlrRi3yvIGzOyxGyMrBUR qyx6ZJRZ9PEdptVSpSZ+gN/t0lo87t7GQylJwCxNJEhlb3B5i8rx0iUOoIZoxTQ/oW6E Rt2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796009044; x=1796613844; 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=6KuAacuQ3TofdjXUjO0odKsMeoKMHrjeoapAwfXqd0E=; b=ocPI5/eME0M8vXOy9/WJtM/5KrcuGARs1jVbGDG6/0l7HS3VIfs8yCLw+A0qpfObdK bRePWMfqamC1L5+I7EaUyELtnDe5FP7u1jSeq6mCQ7CNPgdsKTfJnAj3TuzLWcRL4EfN b7zSwukrM7iHT1ApNQIIr2oYsvVGJdleA81Pzw6IAgzZQRVeNHu57GDwKuyAQr1ARXGf oQkhZCQL4IuuBKuC2NWLyLl0vuqnq4fw7g8xnQRWzvQDHgqJ3QFhxuYhSpN+ZTJO/v3C x4jWLvkc0Rjs1l/pli207YxMk8IGmazLPv+MO7/GbzPZeUZRmPUPQQSR4Z15RwxE29R5 MaWw== X-Forwarded-Encrypted: i=1; AL+hErH9FzCLUcGh+w71yHz+JrJX/LC8JqhOeXwB+57fq6xDmp4nnlEh/HCihOKqwRtsnZXwtY/MK6DAlm4=@vger.kernel.org X-Gm-Message-State: APuU4Z8D9UxTKlEEiRJT796Zh54iDKNOxc2Kml5r9xmL8pFWR09qMN+K g7GYjec0f9D/FzHb5XZQmSSMAuVFig9yD4VuY+3fXK8ep/tUcMdf9av4 X-Gm-Gg: AZFdTZfcZu/aHPckS1P8Q7VJhHBvguFyjWzNaMjerukLJOEdoOqczW7Os9LPfAz2qhG Y3pidJs7tNjj3W+NwRHEAw6DBjzwK9Qq7wPMpvh0JyUXKVMXKYZ8hzQUJdNGBbD9FdjCD0hW6RM jj4eSOcgzfCULWjIlgjj1KGnUodSqntOyYCseCScG5BdThilgXYzVYM67t+Ox7yTgtwMvbhxwqc ODGF33IAQXyzdvyBJurabIGK37PYJIoUCqACKaKTNzCwV0jdLKTUPdbglcHtRc4MjZbsjut1Vb9 mqgvGlzhRJPyUklwSw/js/UKfJ/Zkh2Xp1xQOfzWosB9XOC+EmDCvWxHA2f9R/dUAIWgnLetAJD ZAJtc2Jfxvo/9iCPf/L0bOwDUxDy4THk+8NOq3URR16flW9seRkCwv6A5Ef5+BAs/TAQCAKjw/e Pyyj+um0/8AyulJqTZKfBy28WbvdAenqh/3ex9VAq1US2YC/RB+daYPeXpW5DkA7a+pCR6tw3w5 /IHdJoaAfC9nEtxFJMPz35YEP4kRrFYzO0u+pA8ml+YoMUpv2i9+7ocwe8yEdz6iyvn3ahwMiYh N4YTWDuOq4y562cfVyeBQwopG2W3Zvmb/Y/5T03Yu/o7LG8H70A4nYnstVSZpvPNhHfjcLajEct UHD1gLCMkRp8nQBxl3osANEZYrTLDJBXx X-Received: by 2002:a17:90b:17cd:b0:3ac:9599:a689 with SMTP id 98e67ed59e1d1-3b41c9d3111mr27576241a91.34.1796009043920; Sun, 29 Nov 2026 19:24:03 -0800 (PST) Received: from localhost.localdomain (60-250-196-139.hinet-ip.hinet.net. [60.250.196.139]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b409330ae8sm53207150a91.7.2026.11.29.19.24.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 19:24:03 -0800 (PST) From: Zi-Yu Chen To: Andi Shyti , linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Jacky Huang , Shan-Chun Hung , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Philipp Zabel , Andrew Jeffery , Zi-Yu Chen Subject: [PATCH RESEND v12 0/3] i2c: ma35d1: Add support for MA35D1 I2C controller Date: Mon, 30 Nov 2026 11:23:43 +0800 Message-Id: <20261130032346.1720769-1-zychennvt@gmail.com> X-Mailer: git-send-email 2.34.1 X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Resending the v12 series for review. No changes since the previous submission. The Sashiko AI findings were addressed in the previous discussion. This series adds support for the I2C controller found in the Nuvoton MA35D1 SoC. The driver supports controller and optional target mode and runtime power management. The implementation has been tested on the Nuvoton MA35D1 SOM board. Signed-off-by: Zi-Yu Chen --- Changes in v12: - Synchronize IRQs while initializing transfer state and issuing START. - Clear wake-up control if enabling IRQ wake fails. v11: https://lore.kernel.org/r/20261001075101.489660-1-zychennvt@gmail.com/ Changes in v11: According to Andi's comments: - Prefix the remaining timeout macros with `MA35_`. - Handle errors returned by `i2c_slave_event()` by sending NACK when the target driver rejects a request. - Use `dev_err_probe()` consistently in probe error paths. v10: https://lore.kernel.org/r/20260921083753.1109826-1-zychennvt@gmail.com/ Changes in v10: - Handle enable_irq_wake() return value in suspend. - Correct clock divider mask and maximum limit to 10-bit. v9: https://lore.kernel.org/r/20260807060400.2047517-1-zychennvt@gmail.com/ Changes in v9: - Centralize SI handling in the interrupt handler. - Fix target mode comments. - Initialize the target transmit byte. - Add reset_control_deassert() during probe. v8: https://lore.kernel.org/r/20260804084806.1846570-1-zychennvt@gmail.com/ Changes in v8: - Remove rpm_put avoid duplicate processing. - Add synchronize_irq wait for interrupt to finish before i2c->target = NULL. - Add ma35d1_i2c_restore_idle() to handle bus errors or spurious interrupts. - Change return types of TRX helper functions to irqreturn_t, returning IRQ_NONE for unhandled status codes. v7: https://lore.kernel.org/r/20260727081859.1737223-1-zychennvt@gmail.com/ Changes in v7: - Disable IRQ before clearing i2c->msg. - Support CONFIG_PM=n, and simplify runtime PM setup accordingly. - Remove redundant register access in runtime suspend/resume callbacks. - Defer clearing i2c->target until after pm_runtime_put_sync() in ma35d1_unreg_target(). - Enable interrupts alongside I2C enable in ma35d1_i2c_reset(). v6: https://lore.kernel.org/r/20260720030616.1067660-1-zychennvt@gmail.com/ Changes in v6: - Patch 2 (driver): - Removed dynamic IRQ toggling helpers for simpler interrupt management. Based on Sashiko AI Feedback: - Added zero-length read quirk. - Set i2c->msg to NULL on timeout to avoid use-after-free. - Cleared hardware registers on target unregistration to release the bus. - Protected suspend-path register writes with a spinlock. - Validated clock-frequency to prevent division-by-zero. - Removed incorrect I2C_M_IGNORE_NAK handling. - Corrected a comment typo in the receive data path. - Patch 3 (dts): - use a generic functional name audio-codec@1a v5: https://lore.kernel.org/r/20260630012106.3616821-1-zychennvt@gmail.com/ Changes in v5: - Patch 2 (driver): - Add spinlock protection for MA35_CTL0 register access. - Add NULL pointer check for i2c->msg in the ISR. - Use devres-managed cleanup (devm_add_action_or_reset) for runtime PM. - Use pm_runtime_force_suspend/resume() for Controller mode system sleep. - Control I2CEN bit enabling/disabling via runtime PM. - Refactor arbitration lost handling in state machines. - Remove unsupported I2C_FUNC_PROTOCOL_MANGLING flag. - Clean up readl_poll_timeout() parameters, retry loop, and unused macros. v4: https://lore.kernel.org/r/20260610030208.2020275-1-zychennvt@gmail.com/ Changes in v4: - Patch 1 (dt-bindings): - Update example interrupt number. - Patch 2 (driver): - Remove redundant spinlocks and fix 'irq' type to signed. - Fix target address recovery in ma35d1_i2c_reset(). - Refactor IRQ handler for multi-msg reads and NACK/IGNORE_NAK. - Fix timeout UAF via explicit IRQ disabling during recovery. - Drop IRQF_SHARED and fix PM paths in probe/unregistration. - Limit suspend/resume wakeup logic to target mode only. - Patch 3 (dts): - Add missing i2c0 node to dtsi. - Switch SoM configuration from i2c1 to i2c2 with updated pinctrl. - Add nau8822 audio codec node under i2c2 on the SoM board. - Drop redundant i2c0 alias and clean up dtsi property ordering. v3: https://lore.kernel.org/r/20260512073953.564323-1-zychennvt@gmail.com/ Changes in v3: - Fix minor DTS formatting issues (whitespace, missing newline) v2: https://lore.kernel.org/r/20260316063726.41048-1-zychennvt@gmail.com Changes in v2: - Overall: - Rebase on linux-i2c/i2c-next - Switched terminology from "master/slave" to "controller/target". - Patch 1 (dt-bindings): - Simplified description and fixed 'reg' size in example. - Patch 2 (driver): - Modernized using devm_*, generic device properties, and FIELD_PREP/GENMASK. - Optimized power management by moving clock control to runtime PM. - Simplified code by removing redundant .remove(), .owner, and inlines. - Added dev_err_probe() and default bus frequency handling. - Patch 3 (dts): - Moved i2c aliases to board dts and reordered nodes alphabetically. v1: https://lore.kernel.org/r/20260302020822.13936-1-zychennvt@gmail.com Zi-Yu Chen (3): dt-bindings: i2c: nuvoton,ma35d1-i2c: Add MA35D1 I2C controller i2c: ma35d1: Add Nuvoton MA35D1 I2C driver support arm64: dts: nuvoton: Add I2C nodes for MA35D1 SoC .../bindings/i2c/nuvoton,ma35d1-i2c.yaml | 63 ++ .../boot/dts/nuvoton/ma35d1-som-256m.dts | 20 + arch/arm64/boot/dts/nuvoton/ma35d1.dtsi | 72 ++ drivers/i2c/busses/Kconfig | 13 + drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-ma35d1.c | 800 ++++++++++++++++++ 6 files changed, 969 insertions(+) create mode 100644 Documentation/devicetree/bindings/i2c/nuvoton,ma35d1-i2c.yaml create mode 100644 drivers/i2c/busses/i2c-ma35d1.c -- 2.34.1