From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.52 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795416655; b=PmYZyOnTQQ58U8L8riPNjqgMgNox/YR2vTPpaPneIxP0aA4vJ7dZRQc6duhGOz8mV3Sc V5orvsUl6AHmxv5LdqEvq9mXqTVEBSpJ3XpaaRvCgTJQSrJK2b2TXLazWLJgsz8obyG3Z B+M9t3vpFDRWwvUiR1NeRuALwwcgN6m1pWTIWMBKG3w52Z8XT+CS7mg8s48E6uyh0iwD6 fnhRwv02I9KJSqn+i/mjNzYcQPZ7eNIlbmpUI7qllU8Z2wiOtEoIkJxfwEWpZzPqfsZsq 5brw0pL8HMCbpLDluwbYWtL4Mt+IrFJVE2roRz1BYt77U26y9mTjno9raB43QjEKtAw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795416655; 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=RsghqF/m5W3+Sk6FDMeWBFDKibQsse7a2Bj9+KgEx1c=; b=h+6HBC/qmgFNdvxyv3Am0jwrOQWwl2FHpljcKFwXAGeb+O8o60EnbRe/ry48aH76Q3+n HGhkkvPiP6xC5j3QYL7oT+c64DmNRX4ojmleALym7KVEBzbN5xWdjRiBjTaDz3JgGJydS vz+Hd4mQG9L2KvMz78tPm11heoqNdPe9P7Dzsaky/d8Ofu9nExoycsrXaWArtK0mjOxDM DB6t1skNjQCtf8LCAP9/5SDjNRlAWWxEhPz2wjiNkVdqhpcBoZrVzwdl2tzb8JwM2OPyZ 8lETdEO0jqK+k9dBGOqJWZC6eJX59lu1c7RMauNRQp/QEZg4ruT+fpcSwYN4sIxKdJA== 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=OEE72Kfd; arc=none smtp.remote-ip=209.85.216.52 Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) (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 E2AB5606A330 for ; Mon, 23 Nov 2026 06:50:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E2AB5606A330 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=OEE72Kfd Received: by mail-pj1-f52.google.com with SMTP id 98e67ed59e1d1-3b413997581so2461306a91.2 for ; Sun, 22 Nov 2026 22:50:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795416654; x=1796021454; 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=RsghqF/m5W3+Sk6FDMeWBFDKibQsse7a2Bj9+KgEx1c=; b=OEE72Kfd+Obfg8FU0f9Bf+u8OMdyF8baJf2O5azWAUnPrPx7XI3CPaz1RAVW2h/vza 6Kd+aRUE3Sa3hJVDYGhr+tLFcd9Z9jC37/g6rrluW3PSOPQvMkYAmmEdAsHdS73c9DFK eZj9eElKxaMZh8zBzNgD7zKAcwDb2hjLqWVvir52pqyhk9oWpPmuVD5vZ1gryD7Ow8Ve 1at8ctTxVFINOIwitHXCv58Py0mcgn/Sjh0eJv2ly8NQmpI8jWa3146YYA9s4Z3JGI1X TeGDdvV0Sue9L20dz0aEW5w7wtFbekF3wJnkaCKEX8XDrAkzQVHw2SMhODtnCHW4npzb QOCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795416654; x=1796021454; 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=RsghqF/m5W3+Sk6FDMeWBFDKibQsse7a2Bj9+KgEx1c=; b=uovxiPTSzKVybI7CCd1whiLnTlnyhhwBoEjr3XS6h81zkr21C9xp3KvGjjmb32oWB0 tR3iPTAE9Nusg7Y8UN8tIGpLWNPv/arOZasbfX23WTOMT+JS73EjaHyaAkxxVU8L/FvF m6wTo6GKzJq7ZitRMN5V6bRkYrre863jWhmdf6+RLspCK2I3QiyvdB6VqXQmpWDSoamK Gft7ke2QXVmvkamO9+8Z6b7yT55HPNjd28PqqqTOdUuw+NvPaCp6cufluR4f09jDuj8+ rT+WpA/S4j64DXPGE2axhZ1wCf5ijQVsAhj7FxrVkkb8dmbS1w/yNTbXTrbtI0bVLvY5 nH7w== X-Forwarded-Encrypted: i=1; AL+hErHleNWnWxTlV0JF/UTAy66jAnSMzIuVsbWhuhx7OIgctHLsVYdh8ifMnY/n6AHqoW9PD3ZZpildBgc8Bck=@vger.kernel.org X-Gm-Message-State: APuU4Z9gAT3kWWZGEXT4PSgC5GeIdd4lluIk9iKxJLp8QExqK7ScJWwY SeZPW3ShcKaC9/zzQOw386Qi+W1n0zJSVMQPmqpN/BQbQA7JkbYrfmRh X-Gm-Gg: AZFdTZdQHa4TRx3+nZ8ccwWOBmcIxUDAY4DG7UhDoK83XviwT7CPZMSg5YK92YFQYe6 tg7yVPNVg1pc+2ugzh8b74XAKZr/aMU1sWejRxZfDogKM61WEoW1kt+zfzp6/k+dYooF2DQGXC1 /jdofOBkXAsonQYt/TScGLVvHa0vwnw/sbT4jZoycSg0sfB72F/3u1QOLp30F2W6pV4e2w9uxoz V2kHHmE89NbLSam5nqFy5utc7FNk/OzUR+EG8tfdhFnWOIm0yyzPSCPQPJTdqK2yHVaOCesGYbO xUXdKnXpwzfHSnGBE4eDvdIhUqKxmozIT53AbNTpUaatiLmzaax4Q2+kVIDIzIRZcQEYc8RC0Sx TJF2F/FknmIRvesAWMml2Fy5oxI/8YjuQbtfZ31i6K7k8RKcE1u0kWBuTr3RjdOQe5QpTRaKuzr btBsuQUPumJ7YyWTe3Bc2YGuAKLGkgbx/Q+Hke1sPfGH2n4yKIcpt+b0gCWhYlQJ9pnI1CeUBIx LoriLbqdt648iKMbgVXTZ+M+zQFCdqf+2PtC95BhnKXkwiVI4q8zBhJpwLBPmhqjk6PaX3U6eP8 MMD4E89triLikR2fMvb0bHy8GxVDiwIDXjGKau7/wQzJtUpROeQoPTgvWcUSuBSNgf3W9DOw38v kq6brf4acT2p8Jbk= X-Received: by 2002:a17:90b:55d0:b0:3b0:92be:ea4a with SMTP id 98e67ed59e1d1-3b41c9830demr9484321a91.45.1795416654083; Sun, 22 Nov 2026 22:50:54 -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-3b48b41928esm5224811a91.9.2026.11.22.22.50.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Nov 2026 22:50:53 -0800 (PST) From: Chi-Wen Weng To: ukleinek@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-pwm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, cwweng@nuvoton.com, cwweng.linux@gmail.com Subject: [PATCH v7 0/2] pwm: Add Nuvoton MA35D1 PWM controller support Date: Mon, 23 Nov 2026 14:50:04 +0800 Message-Id: <20261123065006.28768-1-cwweng.linux@gmail.com> X-Mailer: git-send-email 2.25.1 X-Mailing-List: linux-kernel@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 From: Chi-Wen Weng This series adds the device tree binding and PWM framework driver for the Nuvoton MA35D1 EPWM controller. The MA35D1 EPWM controller provides 6 PWM channels. The hardware supports up, down and up-down counter types, auto-reload and one-shot modes, and independent and complementary output modes. The initial driver supports independent output mode only and configures a channel for up-counting and auto-reload operation when an explicit .apply() request is made. The waveform generator drives the output high at the zero point and low at the compare-up point. In up-counting mode, the counter counts from 0 to PERIOD inclusive. With the selected waveform actions, CMPDAT = 0 generates a 0% duty cycle and CMPDAT > PERIOD generates a 100% duty cycle. The driver keeps PERIOD one count below the 16-bit field maximum so that CMPDAT can be programmed greater than PERIOD for the full-duty case. PERIOD and CMPDAT use the hardware period-loading buffers. Since the two registers are written separately, if a period boundary occurs between the writes, one transitional cycle can use the new PERIOD value with the previous CMPDAT value. The following period then uses both new values. The driver selects period loading mode by clearing IMMLDENn, WINLDENn and CTRLDn. When a PWM is disabled, POENn and CNTENn are cleared. Clearing POENn disables the output driver and puts the output pin into high impedance. The driver does not modify the PWM controller during probe. This preserves PWM outputs that may have been configured and enabled by firmware, such as a display backlight. The counter and waveform configuration is changed only for the channel passed to .apply(). Since the independent/complementary mode selection is shared by each pair of channels, the driver refuses to change an active complementary pair to independent mode when the paired channel is active. Changes in v7: - Rename register macros to match the EPWM register names in the reference manual. - Rename bitfield macros to use the corresponding register name as a prefix. - Rename CNTTYPE and related CTL1 field macros to match the reference manual naming. - Keep short register update calls on a single line. - No functional changes. Changes in v6: - Document that clearing POENn disables the output driver and puts the output pin into high impedance. - Document that a period boundary between the PERIOD and CMPDAT writes can result in one transitional cycle using the new period with the previous duty cycle. - No functional changes. Changes in v5: - Remove the probe-time controller initialization to preserve PWM outputs configured by firmware. - Configure the counter and waveform settings only for the channel passed to .apply(). - Keep the disable path limited to clearing POENn and CNTENn. - Check for an active paired channel before changing a complementary pair to independent mode. - Return -EBUSY when changing the shared output mode would disturb an active paired channel. - Document that the initial driver supports independent output mode only. - Remove the unnecessary include. - Simplify the WGCTL action field handling and remove the associated static inline mask helpers. - Rename the PWM field and period limits to clarify their different semantics. - Configure period loading mode explicitly in .apply(). - Preserve the pair-shared clock prescaler and account for it in period and duty-cycle calculations. - Limit the period to 0xffff counter cycles while reserving CMPDAT = 0xffff for the full-duty case. Changes in v4: - Add a Limitations section to describe the hardware capabilities and driver limitations. - Add a link to the MA35D1 reference manual. - Replace register address macros containing the base pointer with register offset macros. - Add readl/writel/rmw helper functions. - Rename TOTAL_CHANNELS to NUM_CHANNELS. - Use unsigned long for the cached clock rate. - Use devm_clk_rate_exclusive_get(). - Configure polarity before enabling the counter and output. - Add controller initialization for up-counting, auto-reload and independent output mode. - Configure the waveform generator for zero-point-high and compare-up-low output. - Fix the period conversion because the hardware period is PERIOD + 1 cycles. - Limit the maximum PERIOD value to 0xfffe so that CMPDAT = 0xffff can be used to generate 100% duty cycle. - Use CNTEN and POEN bits to report the enabled state in .get_state(). - Disable the PWM by clearing POENn and CNTENn. - Fix error message capitalization and trailing newlines. - Fix coding style issues reported by review/checkpatch-style tools. Changes in v3: - Update nuvoton,ma35d1-pwm.yaml: - Add maintainers entry. - Increase "#pwm-cells" to 3. - Update the MA35D1 PWM driver: - Organize include headers and macro definitions. - Rename REG_PWM_XXXX macros to MA35D1_REG_PWM_XXXX. - Add register address macros. v2 resend: - Remove incorrect Reviewed-by tags. Changes in v2: - Update nuvoton,ma35d1-pwm.yaml: - Fix maxItems of reg to 1. - Remove unused label. - Update the MA35D1 PWM driver: - Remove MODULE_ALIAS(). - Add chip->atomic = true. Chi-Wen Weng (2): dt-bindings: pwm: Add Nuvoton MA35D1 PWM controller pwm: Add Nuvoton MA35D1 PWM controller support .../bindings/pwm/nuvoton,ma35d1-pwm.yaml | 45 +++ drivers/pwm/Kconfig | 10 + drivers/pwm/Makefile | 1 + drivers/pwm/pwm-ma35d1.c | 382 ++++++++++++++++++ 4 files changed, 438 insertions(+) create mode 100644 Documentation/devicetree/bindings/pwm/nuvoton,ma35d1-pwm.yaml create mode 100644 drivers/pwm/pwm-ma35d1.c -- 2.25.1