From patchwork Wed Nov 4 19:24:51 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 3863 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mxe881.netcup.net (Postfix) with ESMTPS id E12C81C512F for ; Wed, 4 Nov 2026 21:16:41 +0100 (CET) Authentication-Results: mxe881; dkim=pass header.d=gmail.com; spf=pass (sender IP is 104.64.211.4) smtp.mailfrom=linux-sunxi+bounces-27206-noreply=patchwork.local@lists.linux.dev smtp.helo=sin.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 104.64.211.4 as permitted sender) client-ip=104.64.211.4; envelope-from=linux-sunxi+bounces-27206-noreply=patchwork.local@lists.linux.dev; helo=sin.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id 06867127D6B for ; Wed, 4 Nov 2026 19:37:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1793820305; b=z8ZTDotx8qFf8Z31aohcih9IbhbmuGnkTIcFmDM52ruD/saum3YQxQVB3YgJC8bJEAIk CxhjuEBa+lXyJt1skY8aA5fnNonSs7O90FsvtrNgu4db+jYouhXO8Cef7u7dij+DI2Tw+ wdjLDv2Z7QNWnQI1GahZhqQ2ILKNh7mUvPQmPWhLUZvCgR1aaAp2X4aIP1yRj/qT0+ppf pfSX79k3+iNND6Ot2eNQ10uBARUl9j446w6q/fs2dzgnYV/knHkc/sRt0Fq80nx2l8hLz 1dQdfDPkkJfAfApnuhC/VMxqUhHF6EEGkU9IGKWHpskpLps2ILBVS7eiByUWL+Gr4lw== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793820305; h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature: X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State: X-Gm-Gg:X-Received:Received:From:Date:Subject:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer; bh=M4cUR/bgVx/Ef4Tc/Iqux+0dgmZ5BenjLrR4X+eBZEU=; b=mvMCleoqcteiyQp1kgkAkJiZY3z7idYLZowLMxINASHcq/mvu1UQYVFLzDSM0B8O6kUJ AdX8fBk7zvwum0nOox4FBQu4K63DOcP0Qb0TkA/pjNiBbhnfZgYJa3JsyNTAB0xbGw0wG cJDPpixSn4hbMhMp7p6YBvM6XUtX/gsILdgqohM1CTHn6lZ+N4o3nSfOeyAqQ5NlcZ0Ej 4qsE/DgU2whPgBMBtn2mJkCTcgo8pZDnjUZWqoIfCCI15SeJYm6hnM+QKN3+UbjXhMML4 5/2CEtAne+rrSeJ1d1oYK7evAVEKB1XDFDJUUfk6FA3Yq+m9HN4/cRibqHZlV4BDADA== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=A4jboxSy; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C7553607F28D; Wed, 4 Nov 2026 19:25:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=A4jboxSy X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.174 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793820305; b=vGTYvQTnVbalK858oqadcREJJqdpksE6gfDvBm3tAP96A8OGDL5LvU9pgcWoATcU0SHo T59ks+/C1T4iSlV1I8L+kXXdvWU+fDzU08PS5y5Y777HechqYd015dQR5sm2ly6ugvSXh TdkG0HKe4fuZOlKyhD7UZ587/qAmNiXBb0IUyhnfL3j6geXeOU9L+bkYzibWeHlp+U885 Qq9StC8Y21zSCXQi6eKT0hwLPlslIveVPf1r0NDEK4Jhrrs7Dc5S6yBRLOolz96Nt2xWD Gaxg+fVb1DTSfWw+Iy6lxS9fkAyplpZaRIQRbyK56iqdjvpgAAiExvfMHAq10WkllaA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793820305; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:Date:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer; bh=M4cUR/bgVx/Ef4Tc/Iqux+0dgmZ5BenjLrR4X+eBZEU=; b=2rwvJai1ORQ4psnO0BRFZ6rguvb6735oo/aEpp/tzyCokSoaGccZyLfiVRXUvBdV83Q3 fAYhvEYMd3iceBlftYdEOXN88DKvXH7ohlhcWlJJmnJkTpY4Axzk4T4syZZYyuXS6VNq/ wBvhWFglbHiZgGeIxt0e7ohtRWHsJ5XpUaI7PWiAm8qtdHhKmfxidp6rRLgZBkFVM+IBH s9T8zRpyx6NVOJVXWx/6i11cW2ahkQIdY/fAWCxM9RYHReb02X+zUHZt5V6ZbvjLPMbVH jhKWMzUgRCYfywNuXKHdeqzDnUH4rTComliDPST47CBrt5jSyYGYvHsh1NRMY/1b0IQ== 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=A4jboxSy; arc=none smtp.remote-ip=209.85.167.174 Received: from mail-oi1-f174.google.com (mail-oi1-f174.google.com [209.85.167.174]) (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 5A7A0607F289 for ; Wed, 4 Nov 2026 19:25:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5A7A0607F289 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 Received: by mail-oi1-f174.google.com with SMTP id 5614622812f47-5058b105df7so428037b6e.1 for ; Wed, 04 Nov 2026 11:25:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1793820304; x=1794425104; darn=lists.linux.dev; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=M4cUR/bgVx/Ef4Tc/Iqux+0dgmZ5BenjLrR4X+eBZEU=; b=A4jboxSyRXqeJkr1C8Tch/CYtTYhFoyNqD7MTENlSR/xfaCaZwap5Y6Jlnm3BG1d4C GfvFZfMLwKAF/5kknTk/6uP7eDbiin0k8s5h7P679J3GiUK2SSobd898StnqUf3PZ2V9 jpMgtPZkD/vXwmbuFfoW5jKS1fx4OspxjjCwa2B+h9TXYxdsfMZM3Y9ZEnA9oMVW6dMr 2i7IOYb8WWLlK5MpGpahrMAE9j2tHTWrXkrSrfg1c9AmtKEvAAgopilmuPgkknoz4PPq YwhwohKwBE/ZCc6FbaVBscgMnbFDag/NJ4LOB41LBEVVly5CqlkvP+GB2qUGg3EgTyIs J0zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793820304; x=1794425104; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=M4cUR/bgVx/Ef4Tc/Iqux+0dgmZ5BenjLrR4X+eBZEU=; b=dSxszimLkXvXRsidmiF4ayb5FmwibWTI7Rzu0xrMg0TTFs8+6L9nmsCm4Fhb2B8cG1 YzkJnVw7tDAF6gwUicUdO3iB6CvdVywgJptMFPt4a3VL1v0FZ8Dj8dYzT3R+pxthCRUC Wx/SQD67ofEMGyZl+dg+/AvA9wnp4PJ8bEn5t5WWfnbnkjS8JKR/M3udaN8T7STScYRK wxzPCaDVskdnireeMgSWsonyjtxjndFcQzzbOSXdt3xXRKRyIz5vbIY2T77mDJkLR4ms l4jGtr16zWvWmUPxJOskfHiAyqKyt/TYN5Jg/cL6s6o64mCIZq/WEqXhPHUdd9nhhRQK JXbg== X-Forwarded-Encrypted: i=1; AKwUvBzeiZlWk1OcjWtv84hEykhBQa17qttB5gWJW9BjHqGZmwTQZV+dAp3pIDSHcK0jvph7PqKJHK93IBIWhQ==@lists.linux.dev X-Gm-Message-State: APuU4Z9+qpSnGk13b1R+yYx+WYbgc9vAnJJLJtpPxSgjXcUxK232qNYp dJYc13XJhNF/h5VLB3e8SrhVELraK5/s+pyghYNhXfwFvl8JtuL2GWum X-Gm-Gg: AYBFou1N4XmuYn2M1R78sUTU4dSkumT60VN8CZdo8oJdt90h/TulBnXXpEFAdZeWBc2 WBn4z/5ZcwydfoyrHQJ8rNJ9XPIF03g2qZ8RPY+0exRxMSReFyzj4A3dRH9J2AtlbZRWd8W6jr3 qowofpeouwn+mC1WI5GxHq2qfLYTofw6OuaCH2X3yzqJzfkRCc++TPSJG3DfR1semRudGdXWnCZ M1bBD9lL74f5kuulc5VKx+7IMf094Ei6bd7GHSTAU/4S0FcxyKNl8kVAhgEf5Xj6RIuIOn0bbxN eSKfBoVNg4J6nKQUIqDls+my4IWV6O1CuJbNgJforBoQCDus30gtOPw2Rqs9m4a9+vbWpZO2So9 H8XSAGqh7ZEErUKc0j24u76rPL0l/IZoLQzn3dVW8w/6TT3IOve+14o6I+Mgm1SZh9Syq3h9H1d 5KZlMSFCrxdoBD7JmJdP4guQDSxhxdklj5AxIA45Jn6MziqLdZKOSgydZ+QGeDS4noNxTXbGOeZ E2h0Ri+xGBWTM5Nkxx09fkrEb7ujmCtpfA6fBnEqlCOi8/gS8ToZIrAyqeov6sMaWOfA6funAU+ ExR3SZFcRTdw80/fTSOiQaFuBYKrcWwROT5EYcSxeoenFrZUoRFmBDuIQ1A4if60/knoDJCWG0l b8J7iiRoeRp8DDANep8QdYSqCvFmYbslrtek2EbJ8fvHA/ybfairMgWWqI4HOKQ8fOT3gCfB0tu waIdMiLqpauK59LWKMwrl8+zaMCULpY9ulB/KRAEbywbSmoV7M4jHLHs3o5yxgcvHHUNaGwJo1D /M= X-Received: by 2002:a05:6808:50a1:b0:539:596f:6623 with SMTP id 5614622812f47-5640de36536mr13164089b6e.64.1793820304255; Wed, 04 Nov 2026 11:25:04 -0800 (PST) Received: from [127.0.1.1] (174-29-1-49.hlrn.qwest.net. [174.29.1.49]) by smtp.gmail.com with ESMTPSA id 5614622812f47-567a9c7bbcesm2328723b6e.1.2026.11.04.11.25.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2026 11:25:03 -0800 (PST) From: James Hilliard Date: Wed, 04 Nov 2026 12:24:51 -0700 Subject: [PATCH v12 1/5] dt-bindings: pwm: allwinner: add h616 pwm compatible X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Message-Id: <20261104-h616-pwm-v8-v12-1-8ed39b0dba69@gmail.com> References: <20261104-h616-pwm-v8-v12-0-8ed39b0dba69@gmail.com> In-Reply-To: <20261104-h616-pwm-v8-v12-0-8ed39b0dba69@gmail.com> To: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Stephen Boyd , Brian Masney , Jerome Brunet , Richard Genoud , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Maxime Ripard Cc: Philipp Zabel , Michael Turquette , Paul Kocialkowski , Thomas Petazzoni , John Stultz , Joao Schim , bigunclemax@gmail.com, linux-pwm@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, James Hilliard , Conor Dooley X-Mailer: b4 0.15.2 X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [4.31 / 15.00]; RBL_SENDERSCORE(2.00)[104.64.211.4:from]; SUSPICIOUS_RECIPS(1.50)[]; DMARC_POLICY_SOFTFAIL(1.00)[gmail.com : SPF not aligned (relaxed), No valid DKIM,none]; MAILLIST(-0.18)[generic]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; HAS_LIST_UNSUB(-0.01)[]; TAGGED_FROM(0.00)[bounces-27206-noreply=patchwork.local]; FROM_HAS_DN(0.00)[]; RCVD_COUNT_FIVE(0.00)[6]; RCPT_COUNT_TWELVE(0.00)[27]; TAGGED_RCPT(0.00)[clk,dt]; FREEMAIL_CC(0.00)[pengutronix.de,baylibre.com,sys-base.io,bootlin.com,google.com,schimsalabim.eu,gmail.com,vger.kernel.org,lists.infradead.org,lists.linux.dev,microchip.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[sin.lore.kernel.org:helo,sin.lore.kernel.org:rdns,bootlin.com:email,microchip.com:email]; FORGED_SENDER_MAILLIST(0.00)[]; ASN(0.00)[asn:63949, ipnet:104.64.192.0/19, country:SG]; MID_RHS_MATCH_FROM(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[209.85.167.174:received,100.77.114.92:received,174.29.1.49:received]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[104.64.211.4:from]; FROM_NEQ_ENVFROM(0.00)[jameshilliard1@gmail.com,linux-sunxi@lists.linux.dev]; R_SPF_ALLOW(0.00)[+ip4:104.64.211.4]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc20261015:i=2]; FREEMAIL_TO(0.00)[kernel.org,redhat.com,baylibre.com,bootlin.com,gmail.com,sholland.org]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[] X-Rspamd-Queue-Id: E12C81C512F X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: INBOX From: Richard Genoud The Allwinner H616 PWM block differs from the A10 and H6 blocks, but it uses the same input clocks as H6, so extend the existing Allwinner PWM binding. The block has six channels that can generate PWM waveforms. Each channel also has a bypass that turns its output into a clock suitable for consumers such as the integrated X-Powers AC200 or AC300 Ethernet PHY. Require #clock-cells for H616 because the bypass clocks are part of its provider interface, while continuing to disallow the property for the older variants. Acked-by: Conor Dooley Signed-off-by: Richard Genoud Signed-off-by: James Hilliard --- .../bindings/pwm/allwinner,sun4i-a10-pwm.yaml | 33 +++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/pwm/allwinner,sun4i-a10-pwm.yaml b/Documentation/devicetree/bindings/pwm/allwinner,sun4i-a10-pwm.yaml index 1197858e431f..3b1819c8630c 100644 --- a/Documentation/devicetree/bindings/pwm/allwinner,sun4i-a10-pwm.yaml +++ b/Documentation/devicetree/bindings/pwm/allwinner,sun4i-a10-pwm.yaml @@ -14,6 +14,13 @@ properties: "#pwm-cells": const: 3 + "#clock-cells": + const: 1 + description: + The cell selects the PWM channel whose hardware bypass path is exported + as a clock. Its rate follows the selected shared pair source and divider; + the PWM period, duty-cycle and polarity logic is bypassed. + compatible: oneOf: - const: allwinner,sun4i-a10-pwm @@ -36,6 +43,7 @@ properties: - const: allwinner,sun50i-h5-pwm - const: allwinner,sun5i-a13-pwm - const: allwinner,sun50i-h6-pwm + - const: allwinner,sun50i-h616-pwm reg: maxItems: 1 @@ -62,7 +70,9 @@ allOf: properties: compatible: contains: - const: allwinner,sun50i-h6-pwm + enum: + - allwinner,sun50i-h6-pwm + - allwinner,sun50i-h616-pwm then: properties: @@ -83,6 +93,27 @@ allOf: clocks: maxItems: 1 + - if: + properties: + compatible: + contains: + const: allwinner,sun50i-h616-pwm + + then: + properties: + clocks: + minItems: 2 + + clock-names: + minItems: 2 + + required: + - "#clock-cells" + + else: + properties: + "#clock-cells": false + required: - compatible - reg From patchwork Wed Nov 4 19:24:52 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 3866 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mxe881.netcup.net (Postfix) with ESMTPS id 988FA1C513D for ; Wed, 4 Nov 2026 21:41:18 +0100 (CET) Authentication-Results: mxe881; dkim=pass header.d=gmail.com; spf=pass (sender IP is 172.105.105.114) smtp.mailfrom=linux-sunxi+bounces-27207-noreply=patchwork.local@lists.linux.dev smtp.helo=tor.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.105.105.114 as permitted sender) client-ip=172.105.105.114; envelope-from=linux-sunxi+bounces-27207-noreply=patchwork.local@lists.linux.dev; helo=tor.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 2422AA4766 for ; Wed, 4 Nov 2026 19:37:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1793820308; b=IVF3Vwt5mO1jIKiboZ9vjSP8IO4Z4kOfC1Gmw7KXmanBy/MKZstdJibnhPFgOf4N+x/j JXMWbOY3y2NGaJ1v+y67YNx9oAJNqQpCbrzQVcY4IcbLuU+izRKIONC53h1ok4I2309gS 9wpdftZnmTmqE9wvQVeCW7Vhht5WnS8YLeMqiJQ5aDysyvrypOAyw2GVBNRzWRZvu0lqm twdW/tqAn2f1G78H1g9mJz89/WzudRJumdly7TCep91adl0VpZAHimlS26y8GtDU/GpKU bILt0EPmGJdrxh6sVCixfFfNTE72WAEBeGPrmPN+EL8Jl4rfZMH7xVN75s1YVr2vJ4g== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793820308; h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature: X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State: X-Gm-Gg:X-Received:Received:From:Date:Subject:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer; bh=nF+17zLaGcRhA9AyB+z2XPaw9ZVbqKSa3gxOWxO0tDI=; b=w+v25u9YWKmzVRBuhWhhjX83d9cfWw8lyQURab0vfKZadnropR6Dq5GZruSVyn2oci/M vgtBaZycxxdDeLYYCWAFk5uqMToGijIxXHcoQFIFqPGVV23iVqKO7ORvCPvzzArl+CAA3 Iy08MpEvbQ3JpUIBL7hEyQdt07+1tv69ehBdoA7e3Xyu4aoEgCxZ5PlJ0/6GYmZ05iBei j+C926AOI310cfZGHixgUDvkqBKrE2OHPYRMHfps7tczKiHEbhRyQUgJIvkuRiU/v29GF DlGKyymvuQHqgbOCsvcliq7rbDORZP6NVgPtcefbOC2nflr5URXVVwchwT6+FfbUyWQ== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=id8xqzXV; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5901D607F298; Wed, 4 Nov 2026 19:25:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=id8xqzXV X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.47 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793820308; b=jit3OAVeqVdd7jtOGbGF31dJXBGt+fF/ZEkhcE30hyI5hAKx0O53FCX3gQuCGKi+Gjso gsFIOTNaA8bft7BX2UToFZ1izevkMgr63GtGsrJfGWH5KlXyG6a4a8y+PUGg84K/YFq/y Exo0d7T84Xoq01KYwcDv+EQNN1ereKyLBLyU3xYp6Kfssr8FhRjVyS8hPVchH3ECXqspg FAhzzGbsDfVOVEsiO/fwFzsxd0D4sjLhBrdOZtbaATLj5lHKYasSlBOIvwub6dE4AmqB9 PZsRnlgGuh6L6NsS8z+hWiZMx2+cgUju6iwdMmwzqy7HiWREnIqyq3Us3U+OwZybbhw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793820308; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:Date:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer; bh=nF+17zLaGcRhA9AyB+z2XPaw9ZVbqKSa3gxOWxO0tDI=; b=CyX1QVQs3oj75yx2uGRIR4kmXD3qrBD49/YHZPv+yw8ytTWRIuIunKt03nTBCyblRvNm JAthcRvpkHpIi55XmDuyRXAGupPo6x1kJPG8yvLkp1+vxSQRyh/ArrsvJ8+qxWyJf8UM0 zCbwUdG/oc59t1KmipYdwWTjcYUFB4V8tU6SThatYAldeurVfnA9PGa0OW/AY0K3yhtp5 p9ZgpiB75fZiNRmF01t8PmC/7g0XD3Ioo4pOl2ymFcUVrbLSLd62YzqxsJ76zEAfpcbl5 CYJ8xAaYt0FKgif3GD7LQG5dEPR6sHpUoJscQa+i8rAgzBD1d2OF/wfgRMipHLVzDog== 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=id8xqzXV; arc=none smtp.remote-ip=209.85.210.47 Received: from mail-ot1-f47.google.com (mail-ot1-f47.google.com [209.85.210.47]) (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 4A2BD607E935 for ; Wed, 4 Nov 2026 19:25:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4A2BD607E935 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 Received: by mail-ot1-f47.google.com with SMTP id 46e09a7af769-7f84a55e31aso702771a34.2 for ; Wed, 04 Nov 2026 11:25:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1793820306; x=1794425106; darn=lists.linux.dev; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=nF+17zLaGcRhA9AyB+z2XPaw9ZVbqKSa3gxOWxO0tDI=; b=id8xqzXVqz8c73h4r9WUHNwpTKAbEjXZQ3XCXpOGHCD+Mwj2QOWlhiGJ31vP4crI8w iEezYVxvB3axGxqVgNT/ezZTZOcHD6lTN7h1c+cHRJuTju44kzOfP07Ql1s0NS8Z14ao JwRuaki8A5HiC00rg825WZN2l27raLN/ott+UU/3IR3QBhfwsQ4KWXY1XAphCLUdtfkF LITqgE3up4I3Js7Z55IAfWMvyNtg9BOPxd2B6ShUivpAgJ1HMv2R8rLNMBSJjY0p6Exn O06spJpqGfs8wEgKgCgjbPskEjDOvjaGJ7WaoJjsykQKKsH6uB5XS7K4fhLxM5Vezgyg xgyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793820306; x=1794425106; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=nF+17zLaGcRhA9AyB+z2XPaw9ZVbqKSa3gxOWxO0tDI=; b=lzUFIWHRR/bLvKn3AFJQfb6u0aQut3IYXaJLz/grn2VdPtUek6ttcSuvBnIvlbh06C es6qKhKMfhH2fhKekyDHCPuT1l0hm2/JooEHgvXft/GeE9VeaFIxLmBR/BXyYp6xI4uN LcCH9RfUTrNdzJo4fGLLxuqWXY94+ISDB28rxZja7mG2Nri7ju7Pp0Il9xioZqgNXtnr 0dbe2HmFLNkkAvsO8Cdn997T5WO8H7pqBWH77pkrquIQ/XHXSMgzQ/WM/CU/Oz0Z/Qdy Bt/l0JaI0iQND3aNqozDQxxsOoggVXApUrDFPgPGZdoffBrXA7xZC5nl3iLt0biXNJwI jQGg== X-Forwarded-Encrypted: i=1; AKwUvBwaASoqTtJu8q4bmyqvr8ii8yYi6cJTgQh/bTaowID4pWr2nghfpe5zaK5FbOQoX0wXutgmHfT9avSdlA==@lists.linux.dev X-Gm-Message-State: APuU4Z9EooC8B2tGkmMz738IujPTUdadpXkDAYKrNSpcp2eklKql+js0 gXlqud0VS75BVa7vX/XE673nB1dUJJtVE0sSEIeH07jjCA9qz6rAWnYk X-Gm-Gg: AYBFou1NPPcb2uB34ZGkvO/rvxcJnw+A6KuWpgjcedvC3EPTdEkxmnE7GC+ddw2/Bos /abd6ATDzrL3JodBkW1Li25hKSns6ulUjpPtHagztqRQjZxtSgQUCs6nHCWoca8L3sB39NAx3WC LTnRYrmU4kGUvjsBsQV5MbvPtDUAfbthmWzWa9qwtg1SfksgghmudwZe2kmGEqJqqF5pFzOclZ1 +PJ3zdQwSc0GZvRpLbRdt3PRB5sq5qLtf/DzcArlgJcT/9p+9D3Wn9NZa6fR0l3lseGLxMKOAQW EM8HpN95UGpUNdpQpjn9BtscHU70dKdtDa3aTVehBdLPBAEbHeNeoiT0q/W4JFvx2CLf6ZrpTkS jkFCJKBgNDkPVND6rJH71AnVft8LdVaz4svnXPCPluqGnQiDFqcY3SRutRVJlTlFY3ZiQXVau8q qFwKwYWJazHKv5afekHiEt/nr75IOdVALD9TqxvlhpuwQT+usDET8bFB6hVniAdOdg+gFw2cXbR NsXpzLwclV4Rd7ZqTdL17n46oWtmO9QlxdUyex/XLphLhj/XM8fEq0BtaTFp8eFMUQnOPA2Z2SI GkqzkKFcubBEgS+yxIWFx6fpheOfirGeWWLqTLnWD3sRvPnmRB3tENd40WATAdUcywVmwAz6C6e HmFXUOumwMk2Q83pcACTJnMr/Kk4VAdIc6FYQIh686hRO9Np/gjuILtmLR8e5BdgDhDO8mAOWqe LOzs0mQMYx72JKDPFl59Wip9vKRNytRY0/6mZN+29B0hzCkSIQSTbN X-Received: by 2002:a05:6808:16a4:b0:4f4:9a44:73c0 with SMTP id 5614622812f47-5640d92cbb1mr10327644b6e.6.1793820305958; Wed, 04 Nov 2026 11:25:05 -0800 (PST) Received: from [127.0.1.1] (174-29-1-49.hlrn.qwest.net. [174.29.1.49]) by smtp.gmail.com with ESMTPSA id 5614622812f47-567a9c7bbcesm2328723b6e.1.2026.11.04.11.25.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2026 11:25:05 -0800 (PST) From: James Hilliard Date: Wed, 04 Nov 2026 12:24:52 -0700 Subject: [PATCH v12 2/5] pwm: sun8i: Add H616 PWM support X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Message-Id: <20261104-h616-pwm-v8-v12-2-8ed39b0dba69@gmail.com> References: <20261104-h616-pwm-v8-v12-0-8ed39b0dba69@gmail.com> In-Reply-To: <20261104-h616-pwm-v8-v12-0-8ed39b0dba69@gmail.com> To: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Stephen Boyd , Brian Masney , Jerome Brunet , Richard Genoud , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Maxime Ripard Cc: Philipp Zabel , Michael Turquette , Paul Kocialkowski , Thomas Petazzoni , John Stultz , Joao Schim , bigunclemax@gmail.com, linux-pwm@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, James Hilliard X-Mailer: b4 0.15.2 X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [4.31 / 15.00]; RBL_SENDERSCORE(2.00)[172.105.105.114:from]; SUSPICIOUS_RECIPS(1.50)[]; DMARC_POLICY_SOFTFAIL(1.00)[gmail.com : SPF not aligned (relaxed), No valid DKIM,none]; MAILLIST(-0.18)[generic]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; HAS_LIST_UNSUB(-0.01)[]; FROM_NEQ_ENVFROM(0.00)[jameshilliard1@gmail.com,linux-sunxi@lists.linux.dev]; FROM_HAS_DN(0.00)[]; RCVD_COUNT_FIVE(0.00)[6]; RCPT_COUNT_TWELVE(0.00)[26]; TAGGED_RCPT(0.00)[clk,dt]; FREEMAIL_CC(0.00)[pengutronix.de,baylibre.com,sys-base.io,bootlin.com,google.com,schimsalabim.eu,gmail.com,vger.kernel.org,lists.infradead.org,lists.linux.dev]; DBL_BLOCKED_OPENRESOLVER(0.00)[tor.lore.kernel.org:helo,tor.lore.kernel.org:rdns,bootlin.com:email]; FORGED_SENDER_MAILLIST(0.00)[]; ASN(0.00)[asn:63949, ipnet:172.105.96.0/20, country:SG]; MID_RHS_MATCH_FROM(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[174.29.1.49:received,100.77.114.92:received,209.85.210.47:received]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[172.105.105.114:from]; TAGGED_FROM(0.00)[bounces-27207-noreply=patchwork.local]; R_SPF_ALLOW(0.00)[+ip4:172.105.105.114]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc20261015:i=2]; FREEMAIL_TO(0.00)[kernel.org,redhat.com,baylibre.com,bootlin.com,gmail.com,sholland.org]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[] X-Rspamd-Queue-Id: 988FA1C513D X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: INBOX From: Richard Genoud Add waveform support for the six-channel Allwinner H616 PWM controller. Each pair of outputs shares a source mux, gate and power-of-two divider; each channel has its own prescaler and period/duty registers. Model the shared pair clocks in CCF and program the channel-local dividers directly. Protect the pair rate while a PWM is active. Also check the hardware enable bits before retuning or gating a pair, since firmware may have left an output running without a Linux consumer. Preserve such outputs until a consumer explicitly changes them; do not implement an unused-PWM sweep. Round period, duty and offset in the order required by the waveform API, including the hardware bypass path and the 65536-tick period boundary. Compare exact tick-to-rate ratios before converting to nanoseconds, so periods that round to the same nanosecond remain correctly ordered. Use half-cycle units to include the bypass output in that comparison. Check each candidate rate through the PWM consumer's clk_round_rate() handle so external rate holds are respected while the channel's own hold can be discounted. Retry if a rate notification invalidates the sampled rate and sibling constraints. Wait for pending period updates and quiesce the channel when changing its clock, prescaler, polarity or bypass mode. Live period updates additionally require PCLK to be faster than the PWM clock, as specified by the manual. Encode the channel register values during waveform conversion. Keep rate protection, safe quiescing and clock rollback in one preparation helper, leaving the write callback to apply the prepared values. If restoring the old rate fails, disable both PER and bypass and release the rate hold. Keep the software protection flag set until CCF has released that hold, so sibling rounding cannot mistake the release window for a free rate. Select candidates using one ordered comparison while retaining the bounded divider search. Pulse and coupled dead-zone modes cannot be represented by this API. Reject active unsupported modes, but clear dormant dead-zone configuration before programming an ordinary waveform. Enabled bypass outputs do not use the dead-zone generator and therefore do not prevent clearing dormant state. Allocate the fixed six-channel topology with the pwm_chip. Register the per-device clocks with managed helpers after deasserting reset. Acquire separate pair-clock consumer handles only while PWMs are requested, so internal clock references cannot prevent module removal. Use CCF's provider-owned handles for notifiers and rate readback, including readback of channels which have not been requested. Link: https://lore.kernel.org/all/sashiko-outbox-194932@kernel.org/ Signed-off-by: Richard Genoud Co-developed-by: James Hilliard Signed-off-by: James Hilliard --- drivers/pwm/Kconfig | 11 + drivers/pwm/Makefile | 1 + drivers/pwm/pwm-sun8i.c | 1171 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1183 insertions(+) diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index aacd800687e7..c7c964406da4 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig @@ -738,6 +738,17 @@ config PWM_SUN4I To compile this driver as a module, choose M here: the module will be called pwm-sun4i. +config PWM_SUN8I + tristate "Allwinner sun8i/sun50i PWM support" + depends on ARCH_SUNXI || COMPILE_TEST + depends on HAS_IOMEM && COMMON_CLK + help + PWM framework driver for Allwinner controllers whose channels share + paired source clocks. + + To compile this driver as a module, choose M here: the module + will be called pwm-sun8i. + config PWM_SUNPLUS tristate "Sunplus PWM support" depends on ARCH_SUNPLUS || COMPILE_TEST diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile index 7e2c34cc4f6a..b4fe23ffccd5 100644 --- a/drivers/pwm/Makefile +++ b/drivers/pwm/Makefile @@ -67,6 +67,7 @@ obj-$(CONFIG_PWM_STM32) += pwm-stm32.o obj-$(CONFIG_PWM_STM32_LP) += pwm-stm32-lp.o obj-$(CONFIG_PWM_STMPE) += pwm-stmpe.o obj-$(CONFIG_PWM_SUN4I) += pwm-sun4i.o +obj-$(CONFIG_PWM_SUN8I) += pwm-sun8i.o obj-$(CONFIG_PWM_SUNPLUS) += pwm-sunplus.o obj-$(CONFIG_PWM_TEGRA) += pwm-tegra.o obj-$(CONFIG_PWM_TH1520) += pwm_th1520.o diff --git a/drivers/pwm/pwm-sun8i.c b/drivers/pwm/pwm-sun8i.c new file mode 100644 index 000000000000..08d92d0da291 --- /dev/null +++ b/drivers/pwm/pwm-sun8i.c @@ -0,0 +1,1171 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Driver for Allwinner sun8i Pulse Width Modulation Controller + * + * (C) Copyright 2025 Richard Genoud, Bootlin + * (C) Copyright 2026 James Hilliard + * + * Based on drivers/pwm/pwm-sun4i.c with Copyright: + * + * Copyright (C) 2014 Alexandre Belloni + * + * Channels are paired (0/1, 2/3, 4/5). Each pair shares a clock source and + * first prescaler (div_m), while each channel has its own second prescaler + * (div_k) and bypass path. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define SUN8I_PWM_NPWM 6 +#define SUN8I_PWM_NPAIRS (SUN8I_PWM_NPWM / 2) + +/* PWMCC Pairs Clock Configuration Registers */ +#define SUN8I_PWM_PCCR(pair) (0x20 + ((pair) * 0x4)) +#define SUN8I_PWM_PCCR_SRC_SHIFT 7 +#define SUN8I_PWM_PCCR_SRC_MASK GENMASK(1, 0) +#define SUN8I_PWM_PCCR_GATE_BIT 4 +#define SUN8I_PWM_PCCR_GATE BIT(SUN8I_PWM_PCCR_GATE_BIT) +#define SUN8I_PWM_PCCR_BYPASS_BIT(chan) ((chan) % 2 + 5) +#define SUN8I_PWM_PCCR_DIV_M_SHIFT 0 +#define SUN8I_PWM_PCCR_DIV_M_WIDTH 4 + +/* PWM Enable Register */ +#define SUN8I_PWM_PER 0x40 +#define SUN8I_PWM_ENABLE(chan) BIT(chan) + +/* PWM Control Register */ +#define SUN8I_PWM_PCR(chan) (0x60 + (chan) * 0x20) +#define SUN8I_PWM_PCR_PRESCAL_K_MASK GENMASK(7, 0) +#define SUN8I_PWM_PCR_ACTIVE_STATE BIT(8) +#define SUN8I_PWM_PCR_MODE BIT(9) +#define SUN8I_PWM_PCR_PULSE_START BIT(10) +#define SUN8I_PWM_PCR_PERIOD_READY BIT(11) /* 0: ready, 1: busy */ +#define SUN8I_PWM_PCR_WAVEFORM_MASK (SUN8I_PWM_PCR_PRESCAL_K_MASK | \ + SUN8I_PWM_PCR_ACTIVE_STATE) + +/* PWM Period Register */ +#define SUN8I_PWM_PPR(chan) (0x64 + (chan) * 0x20) +#define SUN8I_PWM_PPR_PERIOD_MASK GENMASK(31, 16) +#define SUN8I_PWM_PPR_DUTY_MASK GENMASK(15, 0) +#define SUN8I_PWM_PPR_PERIOD_VALUE(reg) (FIELD_GET(SUN8I_PWM_PPR_PERIOD_MASK, reg) + 1) +#define SUN8I_PWM_PPR_DUTY_VALUE(reg) FIELD_GET(SUN8I_PWM_PPR_DUTY_MASK, reg) +#define SUN8I_PWM_PPR_PERIOD(prd) FIELD_PREP(SUN8I_PWM_PPR_PERIOD_MASK, (prd) - 1) +#define SUN8I_PWM_PPR_DUTY(dty) FIELD_PREP(SUN8I_PWM_PPR_DUTY_MASK, dty) +#define SUN8I_PWM_PPR_PERIOD_MAX (FIELD_MAX(SUN8I_PWM_PPR_PERIOD_MASK) + 1) + +/* PWM pair dead-zone control registers. */ +#define SUN8I_PWM_PDZCR(pair) (0x30 + ((pair) * 0x4)) +#define SUN8I_PWM_PDZCR_ENABLE BIT(0) + +#define SUN8I_PWM_PERIOD_READY_MARGIN_US 50 +#define SUN8I_PWM_PERIOD_READY_MIN_POLL_US 10 +#define SUN8I_PWM_PERIOD_READY_MAX_POLL_US 10000 +#define SUN8I_PWM_PERIOD_READY_POLL_COUNT 1024 + +#define SUN8I_PWM_PAIR_IDX(chan) ((chan) >> 1) + +/* + * Block diagram of the PWM clock controller: + * + * _____ ______ ________ + * OSC24M --->| | | | | | + * APB1 ----->| Mux |--->| Gate |--->| /div_m |-----> SUN8I_PWM_clock_src_xy + * |_____| |______| |________| + * ________ + * | | + * +->| /div_k |---> SUN8I_PWM_clock_x + * | |________| + * | ______ + * | | | + * +-->| Gate |----> SUN8I_PWM_bypass_clock_x + * | |______| + * SUN8I_PWM_clock_src_xy ---+ ________ + * | | | + * +->| /div_k |---> SUN8I_PWM_clock_y + * | |________| + * | ______ + * | | | + * +-->| Gate |----> SUN8I_PWM_bypass_clock_y + * |______| + * + * NB: when the bypass is set, all the PWM logic is bypassed. + * So, the duty cycle and polarity can't be modified (we just have a clock). + * The bypass in PWM mode is used to achieve a 1/2 relative duty cycle with the + * fastest clock. + * + */ + +/* /div_m is a power-of-two divider limited to /256. */ +static const struct clk_div_table sun8i_pwm_div_m_table[] = { + { .val = 0, .div = 1 }, + { .val = 1, .div = 2 }, + { .val = 2, .div = 4 }, + { .val = 3, .div = 8 }, + { .val = 4, .div = 16 }, + { .val = 5, .div = 32 }, + { .val = 6, .div = 64 }, + { .val = 7, .div = 128 }, + { .val = 8, .div = 256 }, + { /* sentinel */ } +}; + +struct sun8i_pwm_chip; + +struct sun8i_pwm_pair { + struct clk_mux mux; + struct clk_hw gate_hw; + struct clk_divider divider; + struct clk_hw *hw; + struct notifier_block rate_nb; + struct sun8i_pwm_chip *chip; + unsigned int index; + unsigned int rate_generation; +}; + +struct sun8i_pwm_channel { + /* Separate CCF consumer, held only from PWM request to free. */ + struct clk *pair_clk; + u64 pending_period_ns; + bool rate_exclusive; +}; + +struct sun8i_pwm_chip { + struct sun8i_pwm_pair pairs[SUN8I_PWM_NPAIRS]; + struct sun8i_pwm_channel channels[SUN8I_PWM_NPWM]; + struct clk *bus_clk; + void __iomem *base; + /* Protects shared registers and rate_exclusive. */ + spinlock_t lock; +}; + +struct sun8i_pwm_waveform { + u32 pcr; + u32 ppr; + u32 pair_rate; + bool enabled; + bool bypass_en; +}; + +static inline struct sun8i_pwm_chip *sun8i_pwm_from_chip(const struct pwm_chip *chip) +{ + return pwmchip_get_drvdata(chip); +} + +static unsigned long sun8i_pwm_get_pair_rate(struct sun8i_pwm_chip *sun8i_chip, + unsigned int idx) +{ + struct sun8i_pwm_pair *pair = &sun8i_chip->pairs[SUN8I_PWM_PAIR_IDX(idx)]; + + /* Readback also runs on channels without a PWM request. */ + return clk_get_rate(pair->hw->clk); +} + +static unsigned int +sun8i_pwm_get_rate_generation(struct sun8i_pwm_chip *sun8i_chip, unsigned int idx) +{ + guard(spinlock_irqsave)(&sun8i_chip->lock); + + return sun8i_chip->pairs[SUN8I_PWM_PAIR_IDX(idx)].rate_generation; +} + +static inline u32 sun8i_pwm_readl(struct sun8i_pwm_chip *sun8i_chip, + unsigned long offset) +{ + return readl(sun8i_chip->base + offset); +} + +static inline void sun8i_pwm_writel(struct sun8i_pwm_chip *sun8i_chip, + u32 val, unsigned long offset) +{ + writel(val, sun8i_chip->base + offset); +} + +static void sun8i_pwm_set_bypass_locked(struct sun8i_pwm_chip *sun8i_chip, + unsigned int idx, bool enable) +{ + unsigned long reg_offset; + u32 val; + + lockdep_assert_held(&sun8i_chip->lock); + + reg_offset = SUN8I_PWM_PCCR(SUN8I_PWM_PAIR_IDX(idx)); + val = sun8i_pwm_readl(sun8i_chip, reg_offset); + if (enable) + val |= BIT(SUN8I_PWM_PCCR_BYPASS_BIT(idx)); + else + val &= ~BIT(SUN8I_PWM_PCCR_BYPASS_BIT(idx)); + + sun8i_pwm_writel(sun8i_chip, val, reg_offset); +} + +static void sun8i_pwm_set_enabled_locked(struct sun8i_pwm_chip *sun8i_chip, + unsigned int idx, bool enable) +{ + u32 val; + + lockdep_assert_held(&sun8i_chip->lock); + + val = sun8i_pwm_readl(sun8i_chip, SUN8I_PWM_PER); + if (enable) + val |= SUN8I_PWM_ENABLE(idx); + else + val &= ~SUN8I_PWM_ENABLE(idx); + sun8i_pwm_writel(sun8i_chip, val, SUN8I_PWM_PER); +} + +static bool +sun8i_pwm_channel_is_enabled_locked(struct sun8i_pwm_chip *sun8i_chip, + unsigned int idx) +{ + unsigned int pair = SUN8I_PWM_PAIR_IDX(idx); + u32 pccr, per; + + lockdep_assert_held(&sun8i_chip->lock); + + pccr = sun8i_pwm_readl(sun8i_chip, SUN8I_PWM_PCCR(pair)); + per = sun8i_pwm_readl(sun8i_chip, SUN8I_PWM_PER); + + return (pccr & SUN8I_PWM_PCCR_GATE) && + (per & SUN8I_PWM_ENABLE(idx)); +} + +static u32 sun8i_pwm_pair_enable_mask(unsigned int pair) +{ + return GENMASK(pair * 2 + 1, pair * 2); +} + +static inline struct sun8i_pwm_pair * +sun8i_pwm_pair_from_gate_hw(struct clk_hw *hw) +{ + return container_of(hw, struct sun8i_pwm_pair, gate_hw); +} + +static int sun8i_pwm_pair_gate_enable(struct clk_hw *hw) +{ + struct sun8i_pwm_pair *pair = sun8i_pwm_pair_from_gate_hw(hw); + struct sun8i_pwm_chip *sun8i_chip = pair->chip; + u32 pccr; + + guard(spinlock_irqsave)(&sun8i_chip->lock); + pccr = sun8i_pwm_readl(sun8i_chip, SUN8I_PWM_PCCR(pair->index)); + pccr |= SUN8I_PWM_PCCR_GATE; + sun8i_pwm_writel(sun8i_chip, pccr, SUN8I_PWM_PCCR(pair->index)); + + return 0; +} + +static void sun8i_pwm_pair_gate_disable(struct clk_hw *hw) +{ + struct sun8i_pwm_pair *pair = sun8i_pwm_pair_from_gate_hw(hw); + struct sun8i_pwm_chip *sun8i_chip = pair->chip; + unsigned long reg = SUN8I_PWM_PCCR(pair->index); + u32 pccr, per; + + /* CCF counts do not include outputs awaiting firmware-state handoff. */ + guard(spinlock_irqsave)(&sun8i_chip->lock); + per = sun8i_pwm_readl(sun8i_chip, SUN8I_PWM_PER); + if (!(per & sun8i_pwm_pair_enable_mask(pair->index))) { + pccr = sun8i_pwm_readl(sun8i_chip, reg); + pccr &= ~SUN8I_PWM_PCCR_GATE; + sun8i_pwm_writel(sun8i_chip, pccr, reg); + } +} + +static int sun8i_pwm_pair_gate_is_enabled(struct clk_hw *hw) +{ + struct sun8i_pwm_pair *pair = sun8i_pwm_pair_from_gate_hw(hw); + struct sun8i_pwm_chip *sun8i_chip = pair->chip; + unsigned long reg = SUN8I_PWM_PCCR(pair->index); + + guard(spinlock_irqsave)(&sun8i_chip->lock); + + return !!(sun8i_pwm_readl(sun8i_chip, reg) & SUN8I_PWM_PCCR_GATE); +} + +static const struct clk_ops sun8i_pwm_pair_gate_ops = { + .enable = sun8i_pwm_pair_gate_enable, + .disable = sun8i_pwm_pair_gate_disable, + .is_enabled = sun8i_pwm_pair_gate_is_enabled, +}; + +static int sun8i_pwm_pair_rate_notifier(struct notifier_block *nb, + unsigned long event, void *data) +{ + struct sun8i_pwm_pair *pair = + container_of(nb, struct sun8i_pwm_pair, rate_nb); + struct sun8i_pwm_chip *sun8i_chip = pair->chip; + bool active; + + guard(spinlock_irqsave)(&sun8i_chip->lock); + /* Invalidate snapshots even when a rate change is subsequently aborted. */ + pair->rate_generation++; + if (event != PRE_RATE_CHANGE) + return NOTIFY_DONE; + + active = sun8i_pwm_readl(sun8i_chip, SUN8I_PWM_PER) & + sun8i_pwm_pair_enable_mask(pair->index); + + return active ? NOTIFY_BAD : NOTIFY_OK; +} + +static void sun8i_pwm_put_rate(struct sun8i_pwm_chip *sun8i_chip, + unsigned int idx) +{ + struct sun8i_pwm_channel *chan = &sun8i_chip->channels[idx]; + bool exclusive; + + scoped_guard(spinlock_irqsave, &sun8i_chip->lock) + exclusive = chan->rate_exclusive; + /* CCF takes the prepare mutex and may call back into this driver. */ + if (exclusive) + clk_rate_exclusive_put(chan->pair_clk); + /* A sibling must not see an unconstrained rate before CCF releases it. */ + scoped_guard(spinlock_irqsave, &sun8i_chip->lock) + chan->rate_exclusive = false; +} + +static int sun8i_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm) +{ + struct sun8i_pwm_chip *sun8i_chip = sun8i_pwm_from_chip(chip); + struct sun8i_pwm_channel *chan = &sun8i_chip->channels[pwm->hwpwm]; + unsigned int idx = pwm->hwpwm; + struct clk_hw *parent = sun8i_chip->pairs[SUN8I_PWM_PAIR_IDX(idx)].hw; + bool was_enabled; + int ret; + + scoped_guard(spinlock_irqsave, &sun8i_chip->lock) { + was_enabled = + sun8i_pwm_channel_is_enabled_locked(sun8i_chip, idx); + } + + chan->pair_clk = clk_hw_get_clk(parent, NULL); + if (IS_ERR(chan->pair_clk)) { + ret = PTR_ERR(chan->pair_clk); + goto err_clear_clock; + } + + if (was_enabled) { + ret = clk_rate_exclusive_get(chan->pair_clk); + if (ret) + goto err_put_clock; + scoped_guard(spinlock_irqsave, &sun8i_chip->lock) + chan->rate_exclusive = true; + } + + ret = clk_prepare_enable(chan->pair_clk); + if (ret) { + sun8i_pwm_put_rate(sun8i_chip, idx); + goto err_put_clock; + } + + return 0; + +err_put_clock: + clk_put(chan->pair_clk); +err_clear_clock: + chan->pair_clk = NULL; + + return ret; +} + +static void sun8i_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm) +{ + struct sun8i_pwm_chip *sun8i_chip = sun8i_pwm_from_chip(chip); + struct sun8i_pwm_channel *chan = &sun8i_chip->channels[pwm->hwpwm]; + + scoped_guard(spinlock_irqsave, &sun8i_chip->lock) { + sun8i_pwm_set_enabled_locked(sun8i_chip, pwm->hwpwm, false); + sun8i_pwm_set_bypass_locked(sun8i_chip, pwm->hwpwm, false); + } + + sun8i_pwm_put_rate(sun8i_chip, pwm->hwpwm); + clk_disable_unprepare(chan->pair_clk); + clk_put(chan->pair_clk); + chan->pair_clk = NULL; +} + +static int sun8i_pwm_read_waveform(struct pwm_chip *chip, + struct pwm_device *pwm, + void *_wfhw) +{ + struct sun8i_pwm_waveform *wfhw = _wfhw; + struct sun8i_pwm_chip *sun8i_chip = sun8i_pwm_from_chip(chip); + unsigned int pair = SUN8I_PWM_PAIR_IDX(pwm->hwpwm); + unsigned long pair_rate; + u32 pccr, pcr, pdzcr, per, ppr; + + pair_rate = sun8i_pwm_get_pair_rate(sun8i_chip, pwm->hwpwm); + if (pair_rate > U32_MAX) + return -ERANGE; + + scoped_guard(spinlock_irqsave, &sun8i_chip->lock) { + pccr = sun8i_pwm_readl(sun8i_chip, SUN8I_PWM_PCCR(pair)); + per = sun8i_pwm_readl(sun8i_chip, SUN8I_PWM_PER); + pcr = sun8i_pwm_readl(sun8i_chip, SUN8I_PWM_PCR(pwm->hwpwm)); + ppr = sun8i_pwm_readl(sun8i_chip, SUN8I_PWM_PPR(pwm->hwpwm)); + pdzcr = sun8i_pwm_readl(sun8i_chip, SUN8I_PWM_PDZCR(pair)); + } + + *wfhw = (struct sun8i_pwm_waveform) { + .enabled = !!(pccr & SUN8I_PWM_PCCR_GATE) && + !!(per & SUN8I_PWM_ENABLE(pwm->hwpwm)), + .bypass_en = !!(pccr & + BIT(SUN8I_PWM_PCCR_BYPASS_BIT(pwm->hwpwm))), + .pcr = pcr & SUN8I_PWM_PCR_WAVEFORM_MASK, + .ppr = ppr, + .pair_rate = pair_rate, + }; + + /* The waveform API cannot describe coupled dead-zone or pulse mode. */ + if (wfhw->enabled && !wfhw->bypass_en && + ((pdzcr & SUN8I_PWM_PDZCR_ENABLE) || (pcr & SUN8I_PWM_PCR_MODE))) + return -EOPNOTSUPP; + + return 0; +} + +static u64 sun8i_pwm_ticks_to_ns(u32 ticks, u16 div_k, u32 pair_rate) +{ + return DIV_ROUND_UP_ULL(NSEC_PER_SEC * (u64)ticks * div_k, + pair_rate); +} + +static u64 sun8i_pwm_period_ns(const struct sun8i_pwm_waveform *wfhw) +{ + if (wfhw->bypass_en) + return DIV_ROUND_UP_ULL(NSEC_PER_SEC, wfhw->pair_rate); + + return sun8i_pwm_ticks_to_ns(SUN8I_PWM_PPR_PERIOD_VALUE(wfhw->ppr), + FIELD_GET(SUN8I_PWM_PCR_PRESCAL_K_MASK, wfhw->pcr) + 1, + wfhw->pair_rate); +} + +static void +__sun8i_pwm_round_waveform_fromhw(const struct sun8i_pwm_waveform *wfhw, + struct pwm_waveform *wf) +{ + u32 pair_rate = wfhw->pair_rate; + u32 period_ticks = SUN8I_PWM_PPR_PERIOD_VALUE(wfhw->ppr); + u32 duty_ticks = SUN8I_PWM_PPR_DUTY_VALUE(wfhw->ppr); + u16 div_k = FIELD_GET(SUN8I_PWM_PCR_PRESCAL_K_MASK, wfhw->pcr) + 1; + + wf->duty_offset_ns = 0; + + if (!wfhw->enabled || !pair_rate) { + wf->period_length_ns = 0; + wf->duty_length_ns = 0; + return; + } + + wf->period_length_ns = sun8i_pwm_period_ns(wfhw); + if (wfhw->bypass_en) { + wf->duty_length_ns = + DIV_ROUND_UP_ULL(NSEC_PER_SEC, + 2ULL * pair_rate); + return; + } + + duty_ticks = min(duty_ticks, period_ticks); + if (!(wfhw->pcr & SUN8I_PWM_PCR_ACTIVE_STATE)) { + /* Constant outputs have no edge and therefore no offset. */ + if (duty_ticks && duty_ticks < period_ticks) + wf->duty_offset_ns = + sun8i_pwm_ticks_to_ns(duty_ticks, div_k, pair_rate); + duty_ticks = period_ticks - duty_ticks; + } + wf->duty_length_ns = sun8i_pwm_ticks_to_ns(duty_ticks, div_k, pair_rate); +} + +static int sun8i_pwm_round_waveform_fromhw(struct pwm_chip *chip, + struct pwm_device *pwm, + const void *_wfhw, + struct pwm_waveform *wf) +{ + const struct sun8i_pwm_waveform *wfhw = _wfhw; + + __sun8i_pwm_round_waveform_fromhw(wfhw, wf); + + dev_dbg(pwmchip_parent(chip), + "pwm#%u: pair-rate=%u, pcr=%#x, ppr=%#x, bypass=%u -> %llu/%llu [+%llu]\n", + pwm->hwpwm, wfhw->pair_rate, wfhw->pcr, wfhw->ppr, + wfhw->bypass_en, + wf->duty_length_ns, wf->period_length_ns, + wf->duty_offset_ns); + + return 0; +} + +static bool +sun8i_pwm_pair_rate_constrained(struct sun8i_pwm_chip *sun8i_chip, + unsigned int idx) +{ + unsigned int sibling = idx ^ 1; + + guard(spinlock_irqsave)(&sun8i_chip->lock); + return sun8i_chip->channels[sibling].rate_exclusive || + sun8i_pwm_channel_is_enabled_locked(sun8i_chip, sibling); +} + +static int sun8i_pwm_clear_idle_deadzone(struct sun8i_pwm_chip *sun8i_chip, + unsigned int idx) +{ + unsigned int pair = SUN8I_PWM_PAIR_IDX(idx); + u32 pdzcr, pccr, active; + + guard(spinlock_irqsave)(&sun8i_chip->lock); + pdzcr = sun8i_pwm_readl(sun8i_chip, SUN8I_PWM_PDZCR(pair)); + if (!(pdzcr & SUN8I_PWM_PDZCR_ENABLE)) + return 0; + + /* Bypass outputs ignore dead-zone configuration, even while enabled. */ + pccr = sun8i_pwm_readl(sun8i_chip, SUN8I_PWM_PCCR(pair)); + active = sun8i_pwm_readl(sun8i_chip, SUN8I_PWM_PER) & + sun8i_pwm_pair_enable_mask(pair); + for (unsigned int i = pair * 2; i < pair * 2 + 2; i++) + if (pccr & BIT(SUN8I_PWM_PCCR_BYPASS_BIT(i))) + active &= ~SUN8I_PWM_ENABLE(i); + /* Do not change an active firmware waveform on either paired output. */ + if (active) + return -EOPNOTSUPP; + + pdzcr &= ~SUN8I_PWM_PDZCR_ENABLE; + sun8i_pwm_writel(sun8i_chip, pdzcr, SUN8I_PWM_PDZCR(pair)); + + return 0; +} + +static u64 sun8i_pwm_max_period_ns(struct sun8i_pwm_chip *sun8i_chip, + unsigned int idx) +{ + unsigned long pair_rate; + u32 pcr; + u16 div_k; + + pair_rate = sun8i_pwm_get_pair_rate(sun8i_chip, idx); + if (!pair_rate || pair_rate > U32_MAX) + return 0; + + scoped_guard(spinlock_irqsave, &sun8i_chip->lock) { + pcr = sun8i_pwm_readl(sun8i_chip, SUN8I_PWM_PCR(idx)); + } + div_k = FIELD_GET(SUN8I_PWM_PCR_PRESCAL_K_MASK, pcr) + 1; + + return sun8i_pwm_ticks_to_ns(SUN8I_PWM_PPR_PERIOD_MAX, div_k, + pair_rate); +} + +static int sun8i_pwm_wait_period_ready(struct pwm_chip *chip, unsigned int idx) +{ + struct sun8i_pwm_chip *sun8i_chip = sun8i_pwm_from_chip(chip); + struct sun8i_pwm_channel *chan = &sun8i_chip->channels[idx]; + unsigned long poll_us; + u64 period_ns, timeout_us; + u32 val; + int ret; + + /* PPR contains the pending value, not necessarily the active period. */ + period_ns = chan->pending_period_ns; + if (!period_ns) + period_ns = sun8i_pwm_max_period_ns(sun8i_chip, idx); + timeout_us = DIV_ROUND_UP_ULL(period_ns, NSEC_PER_USEC) + + SUN8I_PWM_PERIOD_READY_MARGIN_US; + poll_us = clamp_t(u64, + DIV_ROUND_UP_ULL(timeout_us, + SUN8I_PWM_PERIOD_READY_POLL_COUNT), + SUN8I_PWM_PERIOD_READY_MIN_POLL_US, + SUN8I_PWM_PERIOD_READY_MAX_POLL_US); + + ret = readl_poll_timeout(sun8i_chip->base + SUN8I_PWM_PCR(idx), val, + !(val & SUN8I_PWM_PCR_PERIOD_READY), poll_us, + timeout_us); + if (!ret) + chan->pending_period_ns = 0; + else + dev_err_ratelimited(pwmchip_parent(chip), + "pwm#%u: update timeout after %llu us\n", + idx, timeout_us); + + return ret; +} + +/* + * Protect the rate and quiesce the output if a live update is unsafe. On + * failure restore the old clock before restarting an output we stopped. + * CCF operations must stay outside the register lock. + */ +static int sun8i_pwm_prepare_update(struct pwm_chip *chip, unsigned int idx, + const struct sun8i_pwm_waveform *wfhw, + struct sun8i_pwm_waveform *old) +{ + struct sun8i_pwm_chip *sun8i_chip = sun8i_pwm_from_chip(chip); + struct sun8i_pwm_channel *chan = &sun8i_chip->channels[idx]; + unsigned long rate, bus_rate; + bool had_exclusive, stop; + u32 pccr; + int ret, restore_ret; + + scoped_guard(spinlock_irqsave, &sun8i_chip->lock) + had_exclusive = chan->rate_exclusive; + + if (!had_exclusive) { + ret = clk_rate_exclusive_get(chan->pair_clk); + if (ret) + return ret; + scoped_guard(spinlock_irqsave, &sun8i_chip->lock) + chan->rate_exclusive = true; + } + + /* Sample the old rate only after excluding other rate changes. */ + rate = sun8i_pwm_get_pair_rate(sun8i_chip, idx); + if (!rate || rate > U32_MAX) { + ret = -ERANGE; + goto put_rate; + } + old->pair_rate = rate; + scoped_guard(spinlock_irqsave, &sun8i_chip->lock) { + old->enabled = sun8i_pwm_channel_is_enabled_locked(sun8i_chip, idx); + pccr = sun8i_pwm_readl(sun8i_chip, + SUN8I_PWM_PCCR(SUN8I_PWM_PAIR_IDX(idx))); + old->bypass_en = !!(pccr & BIT(SUN8I_PWM_PCCR_BYPASS_BIT(idx))); + old->pcr = sun8i_pwm_readl(sun8i_chip, SUN8I_PWM_PCR(idx)); + old->ppr = sun8i_pwm_readl(sun8i_chip, SUN8I_PWM_PPR(idx)); + } + + if (rate != wfhw->pair_rate && + sun8i_pwm_pair_rate_constrained(sun8i_chip, idx)) { + ret = -EBUSY; + goto put_rate; + } + + /* Live PPR updates require unchanged configuration and a faster PCLK. */ + bus_rate = clk_get_rate(sun8i_chip->bus_clk); + stop = old->enabled && + (old->bypass_en != wfhw->bypass_en || rate != wfhw->pair_rate || + (!wfhw->bypass_en && + (((old->pcr ^ wfhw->pcr) & + (SUN8I_PWM_PCR_WAVEFORM_MASK | SUN8I_PWM_PCR_MODE)) || + bus_rate <= DIV_ROUND_UP_ULL(wfhw->pair_rate, + FIELD_GET(SUN8I_PWM_PCR_PRESCAL_K_MASK, wfhw->pcr) + 1)))); + if (stop) { + scoped_guard(spinlock_irqsave, &sun8i_chip->lock) + sun8i_pwm_set_enabled_locked(sun8i_chip, idx, false); + } + + if (rate == wfhw->pair_rate) + return 0; + + ret = clk_set_rate(chan->pair_clk, wfhw->pair_rate); + if (!ret && sun8i_pwm_get_pair_rate(sun8i_chip, idx) == wfhw->pair_rate) + return 0; + if (!ret) + ret = -EINVAL; + + if (sun8i_pwm_get_pair_rate(sun8i_chip, idx) != rate) { + restore_ret = clk_set_rate(chan->pair_clk, rate); + if (restore_ret || sun8i_pwm_get_pair_rate(sun8i_chip, idx) != rate) { + dev_err(pwmchip_parent(chip), + "pwm#%u: failed to restore pair clock rate %lu\n", + idx, rate); + /* The old waveform cannot safely run at the remaining rate. */ + scoped_guard(spinlock_irqsave, &sun8i_chip->lock) { + sun8i_pwm_set_enabled_locked(sun8i_chip, idx, false); + sun8i_pwm_set_bypass_locked(sun8i_chip, idx, false); + } + sun8i_pwm_put_rate(sun8i_chip, idx); + return ret; + } + } + if (stop) { + scoped_guard(spinlock_irqsave, &sun8i_chip->lock) + sun8i_pwm_set_enabled_locked(sun8i_chip, idx, true); + } +put_rate: + if (!had_exclusive) + sun8i_pwm_put_rate(sun8i_chip, idx); + + return ret; +} + +static int sun8i_pwm_write_waveform(struct pwm_chip *chip, + struct pwm_device *pwm, const void *_wfhw) +{ + const struct sun8i_pwm_waveform *wfhw = _wfhw; + struct sun8i_pwm_chip *sun8i_chip = sun8i_pwm_from_chip(chip); + struct sun8i_pwm_channel *chan = &sun8i_chip->channels[pwm->hwpwm]; + struct sun8i_pwm_waveform old; + u64 old_ns = 0, new_ns; + u32 pcr; + int ret; + + if (!wfhw->enabled) { + scoped_guard(spinlock_irqsave, &sun8i_chip->lock) { + sun8i_pwm_set_enabled_locked(sun8i_chip, pwm->hwpwm, false); + sun8i_pwm_set_bypass_locked(sun8i_chip, pwm->hwpwm, false); + } + sun8i_pwm_put_rate(sun8i_chip, pwm->hwpwm); + return 0; + } + + if (!wfhw->bypass_en) { + ret = sun8i_pwm_clear_idle_deadzone(sun8i_chip, pwm->hwpwm); + if (ret) + return ret; + ret = sun8i_pwm_wait_period_ready(chip, pwm->hwpwm); + if (ret) + return ret; + } + + ret = sun8i_pwm_prepare_update(chip, pwm->hwpwm, wfhw, &old); + if (ret) + return ret; + + if (!wfhw->bypass_en) { + /* Apply only waveform fields; never replay status or W1S bits. */ + pcr = old.pcr & ~(SUN8I_PWM_PCR_WAVEFORM_MASK | + SUN8I_PWM_PCR_MODE | SUN8I_PWM_PCR_PULSE_START | + SUN8I_PWM_PCR_PERIOD_READY); + sun8i_pwm_writel(sun8i_chip, pcr | wfhw->pcr, + SUN8I_PWM_PCR(pwm->hwpwm)); + + if (old.enabled && !old.bypass_en) + old_ns = sun8i_pwm_period_ns(&old); + new_ns = sun8i_pwm_period_ns(wfhw); + chan->pending_period_ns = max(old_ns, new_ns); + sun8i_pwm_writel(sun8i_chip, wfhw->ppr, SUN8I_PWM_PPR(pwm->hwpwm)); + } + + scoped_guard(spinlock_irqsave, &sun8i_chip->lock) { + sun8i_pwm_set_bypass_locked(sun8i_chip, pwm->hwpwm, wfhw->bypass_en); + sun8i_pwm_set_enabled_locked(sun8i_chip, pwm->hwpwm, true); + } + + return 0; +} + +struct sun8i_pwm_rounding { + const struct pwm_waveform *requested; + struct sun8i_pwm_waveform best; + struct pwm_waveform best_wf; + u32 current_pair_rate; + bool have_best; +}; + +/* Half pair-clock ticks retain the bypass clock's half-period high time. */ +struct sun8i_pwm_ticks { + u32 period; + u32 duty; + u32 offset; +}; + +static struct sun8i_pwm_ticks +sun8i_pwm_waveform_ticks(const struct sun8i_pwm_waveform *wfhw) +{ + u32 period = SUN8I_PWM_PPR_PERIOD_VALUE(wfhw->ppr); + u32 duty = SUN8I_PWM_PPR_DUTY_VALUE(wfhw->ppr); + u32 unit = 2 * (FIELD_GET(SUN8I_PWM_PCR_PRESCAL_K_MASK, wfhw->pcr) + 1); + u32 offset = 0; + + if (wfhw->bypass_en) + return (struct sun8i_pwm_ticks) { .period = 2, .duty = 1 }; + + duty = min(duty, period); + if (!(wfhw->pcr & SUN8I_PWM_PCR_ACTIVE_STATE)) { + if (duty && duty < period) + offset = duty; + duty = period - duty; + } + + return (struct sun8i_pwm_ticks) { + .period = period * unit, + .duty = duty * unit, + .offset = offset * unit, + }; +} + +static int sun8i_pwm_cmp_ticks(u32 a, u32 a_rate, u32 b, u32 b_rate) +{ + /* Each product is at most 2 * 65536 * 256 * U32_MAX, below 2^57. */ + u64 lhs = (u64)a * b_rate; + u64 rhs = (u64)b * a_rate; + + return (lhs > rhs) - (lhs < rhs); +} + +static void +sun8i_pwm_choose_waveform(struct sun8i_pwm_rounding *rounding, + const struct sun8i_pwm_waveform *candidate) +{ + const struct pwm_waveform *requested = rounding->requested; + const struct pwm_waveform *best = &rounding->best_wf; + struct pwm_waveform wf; + bool better; + + __sun8i_pwm_round_waveform_fromhw(candidate, &wf); + /* A zero-duty, zero-offset cycle-mode candidate always exists. */ + if (wf.duty_length_ns > requested->duty_length_ns || + wf.duty_offset_ns > requested->duty_offset_ns) + return; + + if (!rounding->have_best) { + better = true; + } else { + struct sun8i_pwm_ticks a = sun8i_pwm_waveform_ticks(candidate); + struct sun8i_pwm_ticks b = sun8i_pwm_waveform_ticks(&rounding->best); + u32 a_rate = candidate->pair_rate, b_rate = rounding->best.pair_rate; + bool a_down = wf.period_length_ns <= requested->period_length_ns; + bool b_down = best->period_length_ns <= requested->period_length_ns; + int period = sun8i_pwm_cmp_ticks(a.period, a_rate, b.period, b_rate); + int duty = sun8i_pwm_cmp_ticks(a.duty, a_rate, b.duty, b_rate); + int offset = sun8i_pwm_cmp_ticks(a.offset, a_rate, b.offset, b_rate); + + /* Compare before rounding so duty cannot mask a better period. */ + if (a_down != b_down) + better = a_down; + else if (period) + better = a_down ? period > 0 : period < 0; + else if (duty) + better = duty > 0; + else if (offset) + better = offset > 0; + else + /* Prefer the current pair rate for exactly equal waveforms. */ + better = a_rate == rounding->current_pair_rate && + b_rate != rounding->current_pair_rate; + } + if (!better) + return; + + rounding->best = *candidate; + rounding->best_wf = wf; + rounding->have_best = true; +} + +static struct sun8i_pwm_waveform +sun8i_pwm_round_cycle(const struct pwm_waveform *requested, u32 pair_rate, + u16 div_k) +{ + struct sun8i_pwm_waveform candidate = { + .enabled = true, + .pair_rate = pair_rate, + .pcr = FIELD_PREP(SUN8I_PWM_PCR_PRESCAL_K_MASK, div_k - 1), + }; + u64 denominator = NSEC_PER_SEC * (u64)div_k; + u64 duty_ticks, period_ticks; + u32 inactive_ticks; + + /* Floor division rounds down, except for the minimum one-tick period. */ + period_ticks = mul_u64_u64_div_u64(requested->period_length_ns, + pair_rate, denominator); + period_ticks = clamp_t(u64, period_ticks, 1, SUN8I_PWM_PPR_PERIOD_MAX); + duty_ticks = mul_u64_u64_div_u64(requested->duty_length_ns, + pair_rate, denominator); + duty_ticks = min(duty_ticks, period_ticks); + + /* + * Zero active ticks encode either constant level. For a toggling + * waveform, active-low mode places the rising edge after the inactive + * part, which is the only non-zero offset supported by the hardware. + */ + if (!duty_ticks) { + candidate.pcr |= SUN8I_PWM_PCR_ACTIVE_STATE; + } else if (duty_ticks == period_ticks) { + duty_ticks = 0; + } else { + inactive_ticks = period_ticks - duty_ticks; + if (sun8i_pwm_ticks_to_ns(inactive_ticks, div_k, pair_rate) <= + requested->duty_offset_ns) + duty_ticks = inactive_ticks; + else + candidate.pcr |= SUN8I_PWM_PCR_ACTIVE_STATE; + } + + candidate.ppr = SUN8I_PWM_PPR_PERIOD(period_ticks) | + SUN8I_PWM_PPR_DUTY(duty_ticks); + + return candidate; +} + +static void +sun8i_pwm_consider_pair_rate(struct sun8i_pwm_rounding *rounding, u32 pair_rate) +{ + struct sun8i_pwm_waveform candidate; + + for (unsigned int div_k = 1; div_k <= 256; div_k++) { + candidate = sun8i_pwm_round_cycle(rounding->requested, pair_rate, div_k); + sun8i_pwm_choose_waveform(rounding, &candidate); + } + + candidate = (struct sun8i_pwm_waveform) { + .pair_rate = pair_rate, + .enabled = true, + .bypass_en = true, + }; + sun8i_pwm_choose_waveform(rounding, &candidate); +} + +static int sun8i_pwm_round_waveform_tohw(struct pwm_chip *chip, + struct pwm_device *pwm, + const struct pwm_waveform *wf, + void *_wfhw) +{ + struct sun8i_pwm_chip *sun8i_chip = sun8i_pwm_from_chip(chip); + struct sun8i_pwm_pair *pair = + &sun8i_chip->pairs[SUN8I_PWM_PAIR_IDX(pwm->hwpwm)]; + struct clk *pair_clk = sun8i_chip->channels[pwm->hwpwm].pair_clk; + struct sun8i_pwm_waveform *wfhw = _wfhw; + struct sun8i_pwm_rounding rounding = { + .requested = wf, + }; + unsigned long current_rate; + unsigned int generation; + + if (!wf->period_length_ns) { + *wfhw = (struct sun8i_pwm_waveform) { + .enabled = false, + }; + return 0; + } + +retry: + generation = sun8i_pwm_get_rate_generation(sun8i_chip, pwm->hwpwm); + rounding.have_best = false; + current_rate = sun8i_pwm_get_pair_rate(sun8i_chip, pwm->hwpwm); + if (!current_rate || current_rate > U32_MAX) + return -ERANGE; + rounding.current_pair_rate = current_rate; + + if (sun8i_pwm_pair_rate_constrained(sun8i_chip, pwm->hwpwm)) { + sun8i_pwm_consider_pair_rate(&rounding, current_rate); + } else { + for (unsigned int parent_idx = 0; + parent_idx < clk_hw_get_num_parents(pair->hw); + parent_idx++) { + struct clk_hw *parent; + unsigned long parent_rate; + + parent = clk_hw_get_parent_by_index(pair->hw, parent_idx); + if (!parent) + continue; + parent_rate = clk_hw_get_rate(parent); + if (!parent_rate) + continue; + + for (unsigned int i = 0; sun8i_pwm_div_m_table[i].div; + i++) { + u16 div_m = sun8i_pwm_div_m_table[i].div; + u64 pair_rate; + long rounded_rate; + + pair_rate = DIV_ROUND_UP_ULL(parent_rate, div_m); + if (!pair_rate || pair_rate > U32_MAX) + continue; + /* Include CCF reservations held by unprepared consumers. */ + rounded_rate = clk_round_rate(pair_clk, pair_rate); + if (rounded_rate <= 0 || rounded_rate > U32_MAX) + continue; + sun8i_pwm_consider_pair_rate(&rounding, rounded_rate); + } + } + } + + /* The constraint check and rate candidates must describe one rate epoch. */ + if (generation != sun8i_pwm_get_rate_generation(sun8i_chip, pwm->hwpwm)) { + cond_resched(); + goto retry; + } + + if (!rounding.have_best) + return -EINVAL; + *wfhw = rounding.best; + + dev_dbg(pwmchip_parent(chip), + "pwm#%u: %llu/%llu [+%llu] -> pair-rate=%u, pcr=%#x, ppr=%#x, bypass=%u\n", + pwm->hwpwm, wf->duty_length_ns, wf->period_length_ns, + wf->duty_offset_ns, wfhw->pair_rate, wfhw->pcr, wfhw->ppr, + wfhw->bypass_en); + + return rounding.best_wf.period_length_ns > wf->period_length_ns; +} + +static const struct pwm_ops sun8i_pwm_ops = { + .request = sun8i_pwm_request, + .free = sun8i_pwm_free, + .sizeof_wfhw = sizeof(struct sun8i_pwm_waveform), + .round_waveform_tohw = sun8i_pwm_round_waveform_tohw, + .round_waveform_fromhw = sun8i_pwm_round_waveform_fromhw, + .read_waveform = sun8i_pwm_read_waveform, + .write_waveform = sun8i_pwm_write_waveform, +}; + +/* Register the shared mux, gate and /div_m clock for each channel pair. */ +static int sun8i_pwm_register_pair_clocks(struct device *dev, + struct sun8i_pwm_chip *sun8i_chip) +{ + static const struct clk_parent_data parent_data[] = { + { .index = 0 }, + { .index = 1 }, + }; + + for (unsigned int i = 0; i < SUN8I_PWM_NPAIRS; i++) { + struct sun8i_pwm_pair *pair = &sun8i_chip->pairs[i]; + void __iomem *reg = sun8i_chip->base + SUN8I_PWM_PCCR(i); + const char *name; + int ret; + + name = devm_kasprintf(dev, GFP_KERNEL, + "%s#pwm-clk-src%u%u", dev_name(dev), + i * 2, i * 2 + 1); + if (!name) + return -ENOMEM; + + pair->mux.reg = reg; + pair->mux.shift = SUN8I_PWM_PCCR_SRC_SHIFT; + pair->mux.mask = SUN8I_PWM_PCCR_SRC_MASK; + pair->mux.flags = CLK_MUX_ROUND_CLOSEST; + pair->mux.lock = &sun8i_chip->lock; + + pair->chip = sun8i_chip; + pair->index = i; + + pair->divider.reg = reg; + pair->divider.shift = SUN8I_PWM_PCCR_DIV_M_SHIFT; + pair->divider.width = SUN8I_PWM_PCCR_DIV_M_WIDTH; + pair->divider.table = sun8i_pwm_div_m_table; + pair->divider.lock = &sun8i_chip->lock; + + pair->hw = devm_clk_hw_register_composite_pdata(dev, name, + parent_data, + ARRAY_SIZE(parent_data), + &pair->mux.hw, &clk_mux_ops, + &pair->divider.hw, &clk_divider_ops, + &pair->gate_hw, &sun8i_pwm_pair_gate_ops, 0); + if (IS_ERR(pair->hw)) + return dev_err_probe(dev, PTR_ERR(pair->hw), + "Failed to register pair %u clock\n", i); + + /* Borrow CCF's handle so registration cannot pin this module. */ + pair->rate_nb.notifier_call = sun8i_pwm_pair_rate_notifier; + ret = devm_clk_notifier_register(dev, pair->hw->clk, &pair->rate_nb); + if (ret) + return dev_err_probe(dev, ret, + "Failed to protect pair %u clock rate\n", i); + } + + return 0; +} + +/* + * A disabled pair gate makes any set PER bits ineffective. Clear those stale + * enables before a clock consumer can turn the shared gate on and expose an + * unrequested output. + */ +static void +sun8i_pwm_sanitize_disabled_pairs(struct sun8i_pwm_chip *sun8i_chip) +{ + u32 per; + + guard(spinlock_irqsave)(&sun8i_chip->lock); + per = sun8i_pwm_readl(sun8i_chip, SUN8I_PWM_PER); + for (unsigned int pair = 0; pair < SUN8I_PWM_NPAIRS; pair++) { + unsigned int first = pair * 2; + u32 pccr; + + pccr = sun8i_pwm_readl(sun8i_chip, SUN8I_PWM_PCCR(pair)); + if (pccr & SUN8I_PWM_PCCR_GATE) + continue; + + per &= ~sun8i_pwm_pair_enable_mask(pair); + pccr &= ~BIT(SUN8I_PWM_PCCR_BYPASS_BIT(first)); + pccr &= ~BIT(SUN8I_PWM_PCCR_BYPASS_BIT(first + 1)); + sun8i_pwm_writel(sun8i_chip, pccr, SUN8I_PWM_PCCR(pair)); + } + sun8i_pwm_writel(sun8i_chip, per, SUN8I_PWM_PER); +} + +static int sun8i_pwm_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct sun8i_pwm_chip *sun8i_chip; + struct reset_control *rst; + struct pwm_chip *chip; + int ret; + + chip = devm_pwmchip_alloc(dev, SUN8I_PWM_NPWM, sizeof(*sun8i_chip)); + if (IS_ERR(chip)) + return dev_err_probe(dev, PTR_ERR(chip), + "Failed to allocate pwmchip\n"); + + sun8i_chip = sun8i_pwm_from_chip(chip); + spin_lock_init(&sun8i_chip->lock); + sun8i_chip->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(sun8i_chip->base)) + return dev_err_probe(dev, PTR_ERR(sun8i_chip->base), + "Failed to get PWM base address\n"); + + sun8i_chip->bus_clk = devm_clk_get_enabled(dev, "bus"); + if (IS_ERR(sun8i_chip->bus_clk)) + return dev_err_probe(dev, PTR_ERR(sun8i_chip->bus_clk), + "Failed to get bus clock\n"); + + rst = devm_reset_control_get_shared_deasserted(dev, NULL); + if (IS_ERR(rst)) + return dev_err_probe(dev, PTR_ERR(rst), + "Failed to get reset control\n"); + + chip->ops = &sun8i_pwm_ops; + + sun8i_pwm_sanitize_disabled_pairs(sun8i_chip); + + ret = sun8i_pwm_register_pair_clocks(dev, sun8i_chip); + if (ret) + return ret; + + ret = devm_pwmchip_add(dev, chip); + if (ret < 0) + return dev_err_probe(dev, ret, "Failed to add PWM chip\n"); + + return 0; +} + +static const struct of_device_id sun8i_pwm_dt_ids[] = { + { + .compatible = "allwinner,sun50i-h616-pwm", + }, { + /* sentinel */ + } +}; +MODULE_DEVICE_TABLE(of, sun8i_pwm_dt_ids); + +static struct platform_driver sun8i_pwm_driver = { + .driver = { + .name = "sun8i-pwm", + .of_match_table = sun8i_pwm_dt_ids, + }, + .probe = sun8i_pwm_probe, +}; +module_platform_driver(sun8i_pwm_driver); + +MODULE_AUTHOR("Richard Genoud "); +MODULE_DESCRIPTION("Allwinner sun8i PWM driver"); +MODULE_LICENSE("GPL"); From patchwork Wed Nov 4 19:24:53 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 3867 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mxe881.netcup.net (Postfix) with ESMTPS id D10291C08F2 for ; Wed, 4 Nov 2026 21:49:19 +0100 (CET) Authentication-Results: mxe881; dkim=pass header.d=gmail.com; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-27208-noreply=patchwork.local@lists.linux.dev smtp.helo=sea.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.234.253.10 as permitted sender) client-ip=172.234.253.10; envelope-from=linux-sunxi+bounces-27208-noreply=patchwork.local@lists.linux.dev; helo=sea.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 6C98862B9A for ; Wed, 4 Nov 2026 19:38:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1793820309; b=FnjiC1KH9VEtwIpawJPW02stwcCT7aTg0tFzIJZqkfGNYJu18Sdh63b32GrWVWCb5znv Jft1+pKKLofP7hZXUQRi8YRATzDe/QF2Qc3UdZWSRE1VXBoKUXN3kg4/mLWenEnBGkIZS tlyZ6Eer3xkq9KW+N4YMDd5kYzTGg0TBLo8VdySOR/EwPk+ofG3Dn299yvT52Fp33po4n hAhBxr2wDI53EzqWwcq0O7hJqgFZis5XkKjDGhTXHb7b0cescVAy6jWUxXXpMLgyi0lX6 htebRbNyrM/YKu4U8jkwqekMZkRv70TRtNhDUP5IxzMIRYH7apL4ZxKoH/nO4zv/Wxg== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793820309; h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature: X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State: X-Gm-Gg:X-Received:Received:From:Date:Subject:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer; bh=W9WQdjXi6TY9dJIm31sodN+zbfnNOMbsy6mb4cShhQ4=; b=btuD/9HVq8bZRk93AJYt/xXTy/hyzHR9o/BWFsjS9Vr6rWxK9WgJyYPDwStO3B277+8e AhI8UeupduIVNIM5QrVyM9ZnqcvTaJSs+ytErcMk73UiAoxyRi00TYiJrTFgr+fC3d9OF YIJA9ufwlxNoKy2mqOhmao1OX63uyFSI5EEU+bmwuLI0+g1x0hbbcyvnxBwo54S9fu/rK 5akLahEHEVpfGbE2+lnqY6yhBkuB0YAGy8SRufxcgr/gISAncmRiQAHp9jbPxtYMKTiPC jiFCn54nWAqFy8P/2bWvVfTamUCKSFUDLHChYuxq+zJmyBSX2dr4qiADeJ0u/cLpb1w== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=RMlNPbVd; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 63639607F2A7; Wed, 4 Nov 2026 19:25:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=RMlNPbVd X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.173 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793820309; b=bY0FnFxyPCVcYjbzOHus49NMsyybd7lxIR0T+WWzdM5VuEC2uckp7m+zdvYpZ1tEMTPG 2rI1A8iSwW8CKo/adfwxjEp4YLb6mwlvOMQotAsG3eJ+xpUwKD1pbxsLCQ/B+n0g5nYUC K93e5kfenq0RYy8sMKyRTr+oO0mWA1mNfsCHbxEa8m3VSpFAtNz5ffcn29gOlga/2yYgB c5CQCx7AI1xkG3RVbMGOpKhVh+kA9t/My3u1kKzXZmne3hKQab0UqoLnZQspsjedHNMup E9rKX8akh8GDSEnHeIY992eJlvBbTNpOAvX8HyjVOnuN0thMyLEp/3rruQ+BNpNKm0g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793820309; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:Date:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer; bh=W9WQdjXi6TY9dJIm31sodN+zbfnNOMbsy6mb4cShhQ4=; b=uYZzgz6D3ZsFS7zBztS5dhaRymzQqNHljGO+g3CtsNI/Re08jG8LEPuD/cva5FqFQ0gg v1xIj9t/JetYmrgnaBZsbk2gFZJunBThaqQzFj0+lLkJ6JgnTgGHqMzKz2o1BouqmY7Ho mYkJdkKPYzb5KwSKuN+El6DIdYKbOgKXHk6tEsCgKA/LvYS7PRv9MzpuMadwh+7Z3HyU8 PA1JtV5RIwaQF5VeqE3olZJsLbgtqgNAT5j6DHPAJbtCV4gNK5QPu2IBP44oR6m6+mAyJ YDcPur4juoRaVr0wgdDQmfSm/cTFW4ymAFUAlOmzakWe8cJFWEAgRGl//kChLEHA4QQ== 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=RMlNPbVd; arc=none smtp.remote-ip=209.85.167.173 Received: from mail-oi1-f173.google.com (mail-oi1-f173.google.com [209.85.167.173]) (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 DBDCF607F2A0 for ; Wed, 4 Nov 2026 19:25:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DBDCF607F2A0 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 Received: by mail-oi1-f173.google.com with SMTP id 5614622812f47-4f55a53898cso590107b6e.3 for ; Wed, 04 Nov 2026 11:25:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1793820308; x=1794425108; darn=lists.linux.dev; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=W9WQdjXi6TY9dJIm31sodN+zbfnNOMbsy6mb4cShhQ4=; b=RMlNPbVdoTSVSPG3cWQ53GKtFqaNcLfssg19D7jmcKRZ7Elxzit/WCK0JqV5dPZgJa c5qGXzcqDuu5IRvD/n+aCKtlr/KZTNxORn3jK343TxUlRucSLMisRW2PrMzWBQGxJtV0 b3/VZWvocCLQMBkTTjee1PytzyZuwT3kt86rOZsiivSN/k87oBtXS/+ITGempehzJIY3 KL3b5BG8AA+Qa5yGwtBLtp+wGR6YEomzmSxW5j3ymG/ooaa+MET2+uIILo1KvNHbmLIH t4Wsjkx29LHcjFNuPM6NaUSUl3ztu4zfU3+ap+q7wwxxdM5mCQwILpn1dgxKCe4NJcza HQCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793820308; x=1794425108; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=W9WQdjXi6TY9dJIm31sodN+zbfnNOMbsy6mb4cShhQ4=; b=UegSfT/C984gZKJG76GRogG8lrPG8NQecKWJZrWgo8Lt9okKAU475qbg+GURE8+qha Jr5WoXTm5MN/OQOwhneRVEF36nTPxHEK9kGgubVpDsEhHc5/Q3TB9X/zg1WkWNN5QifW XYITbkyhx/Cwm/PqKnUNwXSL5HouVytYNiqLY21n6U8vAbqs59pRvfNIACZzVZBgFH9d l4XniK3twiCzvNdtApD4yuE+eqm0VeWhUIOMwuMcbjGJ7jMmAtgZrcxTG9FffyxszCPu SdDxW05mR2YvuB8gKdTHg2k1vPZ7Oe1z6QPzYzcPQen85SBsE7K1bs7MfQ17ZkdzOR/u uUJA== X-Forwarded-Encrypted: i=1; AKwUvBxHYArBJBi3Uru8XJJdX47JoXS1KxOqeKJsFb1p2HaI1bFcUeMclMrJBuYEU8pZJtjEPq7a0GS7nGTFVw==@lists.linux.dev X-Gm-Message-State: APuU4Z/HYGHePGAJXaPCl4t/ClASrL0gEUrDAUsWg+xtIADUy1/fbHT1 Gl3qDgQMunHUhi1pY/YCVyTIqMTvAqIjWSCF0mkAlcQJ7Fb0qdtXDqgT X-Gm-Gg: AYBFou2NlDcsKrtEslat1Dl8WfoKZfULo/CGyHtYvWhSUqLdmrntCpcwSSHJ9IwQR1h U0cluESZ5X2MUS88MB3Pa2N0GVPAMPWgfedVlNUfIITa3Q24WWeWvl+YLmqsRySQ5rriSY6Qi4v 0ZLxn5W+gSCRqJFOb2o1TVOF26Ax7XeUrgAvq7z9DimSzVbnkKgycZsVk3yuHzkcCKYoERhKgTL tWCzK99oFN/rR/M7se2oeQRjwUIdf8Rc3YecuThDLziuDcvw0j3gQFtIb0bBxkhI1NdGERLqd8F mgmjZaPKe66luQvBOFweZvez4KKevR6/aGDS/wHBQDUHX6ODeI5A7rDNrx3sflXq7pDb3TUqmnR KxIgLoW98AD0ktcbfrTdf1QU9G3OxLfYHxXs0ZpKE4zs8PDVsZEgLq9NDl7IDGi8GPsNIQTSbVw w4/pKMzzUJ8NTosRLKtyJA4sG2ONc2KMG0+/c1YASwCm5EwmQKIBYaBj2XhUOG8YsNgrw4c+9bh mVX1InXnPYYkWrtxLMIFGlwJqvXd+qW4EYyNgxZIgRmjDwqBxf1W3PLIAaa+TFLGrJjqxylKSmt aK9t2V6qE7mImLwwlSrY5oIIoNbpc4rtQheR6faywcMy4ZKHBVDSGyMD9c7dhFceccXFivxWHEj FdHE/PDoJnNaJGrf+lzLT+nVXNs72P40624twnxVvVrgT9Dqecig/RRQdG3xOJx/vGYUXC5V9lW M6sAw6c/ovMDVJE+jCBGpqM1OvmjK68w8+O3cxQaNCo19Re107PKF9 X-Received: by 2002:a05:6808:14ca:b0:4e8:18ee:eb4d with SMTP id 5614622812f47-5640dce42ddmr14479773b6e.20.1793820307724; Wed, 04 Nov 2026 11:25:07 -0800 (PST) Received: from [127.0.1.1] (174-29-1-49.hlrn.qwest.net. [174.29.1.49]) by smtp.gmail.com with ESMTPSA id 5614622812f47-567a9c7bbcesm2328723b6e.1.2026.11.04.11.25.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2026 11:25:07 -0800 (PST) From: James Hilliard Date: Wed, 04 Nov 2026 12:24:53 -0700 Subject: [PATCH v12 3/5] pwm: sun8i: export the bypass outputs as clocks X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Message-Id: <20261104-h616-pwm-v8-v12-3-8ed39b0dba69@gmail.com> References: <20261104-h616-pwm-v8-v12-0-8ed39b0dba69@gmail.com> In-Reply-To: <20261104-h616-pwm-v8-v12-0-8ed39b0dba69@gmail.com> To: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Stephen Boyd , Brian Masney , Jerome Brunet , Richard Genoud , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Maxime Ripard Cc: Philipp Zabel , Michael Turquette , Paul Kocialkowski , Thomas Petazzoni , John Stultz , Joao Schim , bigunclemax@gmail.com, linux-pwm@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, James Hilliard X-Mailer: b4 0.15.2 X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [-1.19 / 15.00]; BAYES_HAM(-5.50)[100.00%]; RBL_SENDERSCORE(2.00)[172.234.253.10:from]; SUSPICIOUS_RECIPS(1.50)[]; DMARC_POLICY_SOFTFAIL(1.00)[gmail.com : SPF not aligned (relaxed), No valid DKIM,none]; MAILLIST(-0.18)[generic]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; HAS_LIST_UNSUB(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[bootlin.com:email,sea.lore.kernel.org:helo,sea.lore.kernel.org:rdns]; FORGED_SENDER_MAILLIST(0.00)[]; RCVD_COUNT_FIVE(0.00)[6]; RCPT_COUNT_TWELVE(0.00)[26]; FROM_HAS_DN(0.00)[]; FREEMAIL_CC(0.00)[pengutronix.de,baylibre.com,sys-base.io,bootlin.com,google.com,schimsalabim.eu,gmail.com,vger.kernel.org,lists.infradead.org,lists.linux.dev]; TAGGED_RCPT(0.00)[clk,dt]; FROM_NEQ_ENVFROM(0.00)[jameshilliard1@gmail.com,linux-sunxi@lists.linux.dev]; ASN(0.00)[asn:63949, ipnet:172.234.224.0/19, country:SG]; MID_RHS_MATCH_FROM(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[209.85.167.173:received,100.77.114.92:received,174.29.1.49:received]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[172.234.253.10:from]; TAGGED_FROM(0.00)[bounces-27208-noreply=patchwork.local]; R_SPF_ALLOW(0.00)[+ip4:172.234.253.10]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc20261015:i=2]; FREEMAIL_TO(0.00)[kernel.org,redhat.com,baylibre.com,bootlin.com,gmail.com,sholland.org]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[] X-Rspamd-Queue-Id: D10291C08F2 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: INBOX From: Richard Genoud Expose each H616 PWM channel's hardware bypass as a CCF clock. Consumers such as the co-packaged AC200/AC300 PHY need a clock rather than PWM duty or polarity control. Keep the pair source protected for the complete prepared lifetime, and arbitrate ownership between PWM requests and clock prepare so both interfaces cannot drive the same output. drivers/clk/clk-pwm.c advertises a fixed frequency without reading back the rounded PWM rate. A 42 ns, 21 ns request does select 24 MHz bypass when it is available. However, with the pair constrained to 100 MHz by its sibling, the PWM rounding rules select a 40 ns, 20 ns waveform (25 MHz), while a pwm-clock configured for 24 MHz still reports 24 MHz. The direct provider instead reports the actual pair rate and makes its shared-rate protection visible to CCF. Consumers must still check the rate they receive. Use CLK_IGNORE_UNUSED to preserve unclaimed firmware bypass outputs, just as the PWM path preserves inherited waveforms. Normal consumer disable still turns the output off and releases its shared gate reference. Readback also runs on unrequested channels exposed through PWM debugfs. An exported-clock consumer can retune and enable a disabled output between the rate query and register snapshot. Retry when the pair's notification generation changes so the returned waveform uses a consistent rate and register state. The CCF rate read waits for changes already in progress; the locked generation check detects changes that start afterward. A temporary exclusive rate hold would instead clamp concurrent clock requests to the old rate, potentially returning success at the wrong frequency. Keep readback non-intrusive and leave sleeping CCF calls outside the register spinlock. PRE notifications invalidate snapshots even if a provider failure does not produce POST_RATE_CHANGE. Rate exclusivity protects frequency, whereas prepare/request arbitration owns an output. An unprepared clock's rate hold therefore constrains PWM rounding without reserving the channel. A consumer taking over an inherited output can prepare and enable it at its current rate, then disable and unprepare it before selecting a different rate. Link: https://lore.kernel.org/all/sashiko-outbox-194955@kernel.org/ Signed-off-by: Richard Genoud Co-developed-by: James Hilliard Signed-off-by: James Hilliard --- drivers/pwm/Kconfig | 3 +- drivers/pwm/pwm-sun8i.c | 206 ++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 202 insertions(+), 7 deletions(-) diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index c7c964406da4..48dfb8a8d1e9 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig @@ -744,7 +744,8 @@ config PWM_SUN8I depends on HAS_IOMEM && COMMON_CLK help PWM framework driver for Allwinner controllers whose channels share - paired source clocks. + paired source clocks. In addition to PWM operation, each channel's + hardware bypass path can be exported as a clock output. To compile this driver as a module, choose M here: the module will be called pwm-sun8i. diff --git a/drivers/pwm/pwm-sun8i.c b/drivers/pwm/pwm-sun8i.c index 08d92d0da291..fa81330162bc 100644 --- a/drivers/pwm/pwm-sun8i.c +++ b/drivers/pwm/pwm-sun8i.c @@ -114,6 +114,9 @@ * The bypass in PWM mode is used to achieve a 1/2 relative duty cycle with the * fastest clock. * + * SUN8I_PWM_clock_x/y serve for the PWM purpose. + * SUN8I_PWM_bypass_clock_x/y serve for the clock-provider purpose. + * */ /* /div_m is a power-of-two divider limited to /256. */ @@ -130,6 +133,12 @@ static const struct clk_div_table sun8i_pwm_div_m_table[] = { { /* sentinel */ } }; +enum sun8i_pwm_mode { + SUN8I_PWM_MODE_NONE, + SUN8I_PWM_MODE_PWM, + SUN8I_PWM_MODE_CLK, +}; + struct sun8i_pwm_chip; struct sun8i_pwm_pair { @@ -144,8 +153,12 @@ struct sun8i_pwm_pair { }; struct sun8i_pwm_channel { + struct clk_hw bypass_hw; + struct sun8i_pwm_chip *chip; + unsigned int index; /* Separate CCF consumer, held only from PWM request to free. */ struct clk *pair_clk; + enum sun8i_pwm_mode mode; u64 pending_period_ns; bool rate_exclusive; }; @@ -155,7 +168,7 @@ struct sun8i_pwm_chip { struct sun8i_pwm_channel channels[SUN8I_PWM_NPWM]; struct clk *bus_clk; void __iomem *base; - /* Protects shared registers and rate_exclusive. */ + /* Protects shared registers, channel ownership and rate_exclusive. */ spinlock_t lock; }; @@ -329,6 +342,101 @@ static int sun8i_pwm_pair_rate_notifier(struct notifier_block *nb, return active ? NOTIFY_BAD : NOTIFY_OK; } +static inline struct sun8i_pwm_channel * +sun8i_pwm_channel_from_hw(struct clk_hw *hw) +{ + return container_of(hw, struct sun8i_pwm_channel, bypass_hw); +} + +static int sun8i_pwm_bypass_prepare(struct clk_hw *hw) +{ + struct sun8i_pwm_channel *chan = sun8i_pwm_channel_from_hw(hw); + struct sun8i_pwm_chip *sun8i_chip = chan->chip; + + guard(spinlock_irqsave)(&sun8i_chip->lock); + if (chan->mode != SUN8I_PWM_MODE_NONE) + return -EBUSY; + + chan->mode = SUN8I_PWM_MODE_CLK; + return 0; +} + +static void sun8i_pwm_bypass_unprepare(struct clk_hw *hw) +{ + struct sun8i_pwm_channel *chan = sun8i_pwm_channel_from_hw(hw); + struct sun8i_pwm_chip *sun8i_chip = chan->chip; + + guard(spinlock_irqsave)(&sun8i_chip->lock); + if (chan->mode != SUN8I_PWM_MODE_CLK) + return; + + chan->mode = SUN8I_PWM_MODE_NONE; +} + +static int sun8i_pwm_bypass_enable(struct clk_hw *hw) +{ + struct sun8i_pwm_channel *chan = sun8i_pwm_channel_from_hw(hw); + struct sun8i_pwm_chip *sun8i_chip = chan->chip; + unsigned int pair = SUN8I_PWM_PAIR_IDX(chan->index); + u32 pccr, per; + + guard(spinlock_irqsave)(&sun8i_chip->lock); + if (chan->mode != SUN8I_PWM_MODE_CLK) + return -EBUSY; + + pccr = sun8i_pwm_readl(sun8i_chip, SUN8I_PWM_PCCR(pair)); + per = sun8i_pwm_readl(sun8i_chip, SUN8I_PWM_PER); + if (!(pccr & BIT(SUN8I_PWM_PCCR_BYPASS_BIT(chan->index))) || + !(per & SUN8I_PWM_ENABLE(chan->index))) { + sun8i_pwm_set_enabled_locked(sun8i_chip, chan->index, false); + sun8i_pwm_set_bypass_locked(sun8i_chip, chan->index, true); + sun8i_pwm_set_enabled_locked(sun8i_chip, chan->index, true); + } + + return 0; +} + +static void sun8i_pwm_bypass_disable(struct clk_hw *hw) +{ + struct sun8i_pwm_channel *chan = sun8i_pwm_channel_from_hw(hw); + struct sun8i_pwm_chip *sun8i_chip = chan->chip; + + guard(spinlock_irqsave)(&sun8i_chip->lock); + if (chan->mode != SUN8I_PWM_MODE_CLK) + return; + + sun8i_pwm_set_enabled_locked(sun8i_chip, chan->index, false); + sun8i_pwm_set_bypass_locked(sun8i_chip, chan->index, false); +} + +static int sun8i_pwm_bypass_is_enabled(struct clk_hw *hw) +{ + struct sun8i_pwm_channel *chan = sun8i_pwm_channel_from_hw(hw); + struct sun8i_pwm_chip *sun8i_chip = chan->chip; + unsigned int pair = SUN8I_PWM_PAIR_IDX(chan->index); + bool enabled; + u32 val; + + guard(spinlock_irqsave)(&sun8i_chip->lock); + + val = sun8i_pwm_readl(sun8i_chip, SUN8I_PWM_PCCR(pair)); + enabled = (val & SUN8I_PWM_PCCR_GATE) && + (val & BIT(SUN8I_PWM_PCCR_BYPASS_BIT(chan->index))); + + val = sun8i_pwm_readl(sun8i_chip, SUN8I_PWM_PER); + enabled = enabled && (val & SUN8I_PWM_ENABLE(chan->index)); + + return enabled; +} + +static const struct clk_ops sun8i_pwm_bypass_ops = { + .prepare = sun8i_pwm_bypass_prepare, + .unprepare = sun8i_pwm_bypass_unprepare, + .enable = sun8i_pwm_bypass_enable, + .disable = sun8i_pwm_bypass_disable, + .is_enabled = sun8i_pwm_bypass_is_enabled, +}; + static void sun8i_pwm_put_rate(struct sun8i_pwm_chip *sun8i_chip, unsigned int idx) { @@ -355,8 +463,12 @@ static int sun8i_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm) int ret; scoped_guard(spinlock_irqsave, &sun8i_chip->lock) { + if (chan->mode != SUN8I_PWM_MODE_NONE) + return -EBUSY; + was_enabled = sun8i_pwm_channel_is_enabled_locked(sun8i_chip, idx); + chan->mode = SUN8I_PWM_MODE_PWM; } chan->pair_clk = clk_hw_get_clk(parent, NULL); @@ -385,6 +497,8 @@ static int sun8i_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm) clk_put(chan->pair_clk); err_clear_clock: chan->pair_clk = NULL; + scoped_guard(spinlock_irqsave, &sun8i_chip->lock) + chan->mode = SUN8I_PWM_MODE_NONE; return ret; } @@ -395,6 +509,9 @@ static void sun8i_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm) struct sun8i_pwm_channel *chan = &sun8i_chip->channels[pwm->hwpwm]; scoped_guard(spinlock_irqsave, &sun8i_chip->lock) { + if (chan->mode != SUN8I_PWM_MODE_PWM) + return; + sun8i_pwm_set_enabled_locked(sun8i_chip, pwm->hwpwm, false); sun8i_pwm_set_bypass_locked(sun8i_chip, pwm->hwpwm, false); } @@ -403,6 +520,9 @@ static void sun8i_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm) clk_disable_unprepare(chan->pair_clk); clk_put(chan->pair_clk); chan->pair_clk = NULL; + + scoped_guard(spinlock_irqsave, &sun8i_chip->lock) + chan->mode = SUN8I_PWM_MODE_NONE; } static int sun8i_pwm_read_waveform(struct pwm_chip *chip, @@ -412,21 +532,39 @@ static int sun8i_pwm_read_waveform(struct pwm_chip *chip, struct sun8i_pwm_waveform *wfhw = _wfhw; struct sun8i_pwm_chip *sun8i_chip = sun8i_pwm_from_chip(chip); unsigned int pair = SUN8I_PWM_PAIR_IDX(pwm->hwpwm); + struct clk *pair_clk = sun8i_chip->pairs[pair].hw->clk; unsigned long pair_rate; u32 pccr, pcr, pdzcr, per, ppr; - pair_rate = sun8i_pwm_get_pair_rate(sun8i_chip, pwm->hwpwm); - if (pair_rate > U32_MAX) - return -ERANGE; + /* + * An unrequested channel can be retuned and enabled by a clock + * consumer. Retry if its rate changed between the CCF read and the + * register snapshot. A temporary exclusive hold would instead clamp + * concurrent bypass-clock rate requests to the old pair rate. + */ + for (;;) { + unsigned int generation; + + cond_resched(); + generation = sun8i_pwm_get_rate_generation(sun8i_chip, pwm->hwpwm); + /* This waits for any rate change already in progress to finish. */ + pair_rate = clk_get_rate(pair_clk); + + guard(spinlock_irqsave)(&sun8i_chip->lock); + if (generation != sun8i_chip->pairs[pair].rate_generation) + continue; - scoped_guard(spinlock_irqsave, &sun8i_chip->lock) { pccr = sun8i_pwm_readl(sun8i_chip, SUN8I_PWM_PCCR(pair)); per = sun8i_pwm_readl(sun8i_chip, SUN8I_PWM_PER); pcr = sun8i_pwm_readl(sun8i_chip, SUN8I_PWM_PCR(pwm->hwpwm)); ppr = sun8i_pwm_readl(sun8i_chip, SUN8I_PWM_PPR(pwm->hwpwm)); pdzcr = sun8i_pwm_readl(sun8i_chip, SUN8I_PWM_PDZCR(pair)); + break; } + if (pair_rate > U32_MAX) + return -ERANGE; + *wfhw = (struct sun8i_pwm_waveform) { .enabled = !!(pccr & SUN8I_PWM_PCCR_GATE) && !!(per & SUN8I_PWM_ENABLE(pwm->hwpwm)), @@ -523,7 +661,8 @@ sun8i_pwm_pair_rate_constrained(struct sun8i_pwm_chip *sun8i_chip, unsigned int sibling = idx ^ 1; guard(spinlock_irqsave)(&sun8i_chip->lock); - return sun8i_chip->channels[sibling].rate_exclusive || + return sun8i_chip->channels[sibling].mode == SUN8I_PWM_MODE_CLK || + sun8i_chip->channels[sibling].rate_exclusive || sun8i_pwm_channel_is_enabled_locked(sun8i_chip, sibling); } @@ -1075,6 +1214,42 @@ static int sun8i_pwm_register_pair_clocks(struct device *dev, return 0; } +/* Register the bypass clock for each channel. */ +static int sun8i_pwm_register_bypass_clocks(struct device *dev, + struct sun8i_pwm_chip *sun8i_chip) +{ + for (unsigned int i = 0; i < SUN8I_PWM_NPWM; i++) { + struct sun8i_pwm_channel *chan = &sun8i_chip->channels[i]; + struct clk_hw *parent = sun8i_chip->pairs[SUN8I_PWM_PAIR_IDX(i)].hw; + const char *name; + int ret; + + name = devm_kasprintf(dev, GFP_KERNEL, "%s#pwm-bypass%u", + dev_name(dev), i); + if (!name) + return -ENOMEM; + + chan->chip = sun8i_chip; + chan->index = i; + /* + * Protect the shared rate while prepared. Preserve unclaimed + * firmware outputs through CCF's unused-clock cleanup, as for + * PWM waveforms; only a consumer may turn them off. + */ + chan->bypass_hw.init = + CLK_HW_INIT_HW(name, parent, &sun8i_pwm_bypass_ops, + CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE | + CLK_IGNORE_UNUSED); + + ret = devm_clk_hw_register(dev, &chan->bypass_hw); + if (ret) + return dev_err_probe(dev, ret, + "Failed to register bypass clock %u\n", i); + } + + return 0; +} + /* * A disabled pair gate makes any set PER bits ineffective. Clear those stale * enables before a clock consumer can turn the shared gate on and expose an @@ -1103,6 +1278,17 @@ sun8i_pwm_sanitize_disabled_pairs(struct sun8i_pwm_chip *sun8i_chip) sun8i_pwm_writel(sun8i_chip, per, SUN8I_PWM_PER); } +static struct clk_hw *sun8i_pwm_get_clk_hw(struct of_phandle_args *clkspec, + void *data) +{ + struct sun8i_pwm_chip *sun8i_chip = data; + + if (clkspec->args_count != 1 || clkspec->args[0] >= SUN8I_PWM_NPWM) + return ERR_PTR(-EINVAL); + + return &sun8i_chip->channels[clkspec->args[0]].bypass_hw; +} + static int sun8i_pwm_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -1141,6 +1327,14 @@ static int sun8i_pwm_probe(struct platform_device *pdev) if (ret) return ret; + ret = sun8i_pwm_register_bypass_clocks(dev, sun8i_chip); + if (ret) + return ret; + + ret = devm_of_clk_add_hw_provider(dev, sun8i_pwm_get_clk_hw, sun8i_chip); + if (ret) + return dev_err_probe(dev, ret, "Failed to add HW clock provider\n"); + ret = devm_pwmchip_add(dev, chip); if (ret < 0) return dev_err_probe(dev, ret, "Failed to add PWM chip\n"); From patchwork Wed Nov 4 19:24:54 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 3865 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mxe881.netcup.net (Postfix) with ESMTPS id B91B81C5138 for ; Wed, 4 Nov 2026 21:34:22 +0100 (CET) Authentication-Results: mxe881; dkim=pass header.d=gmail.com; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-27209-noreply=patchwork.local@lists.linux.dev smtp.helo=sea.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.234.253.10 as permitted sender) client-ip=172.234.253.10; envelope-from=linux-sunxi+bounces-27209-noreply=patchwork.local@lists.linux.dev; helo=sea.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 0979C63C4B for ; Wed, 4 Nov 2026 19:38:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1793820310; b=0JYn1h0gKr0+iTQklKhVbY9l8DW5oscQum6wBFh83cvEz9LzZh9DrxLsLJsYy3ZkAkBd ifuFPyfUzNBmQC2Yg5aBG+dcMlZJHCJZH93hfWWwgGNOZK7vWr18Z+Xh+dOcT2+lwr7SI 7H+8R0fC5fIhyd1lzgbC7vfm2mbzs//PQEiRl0cRGguOz7NgCfYytVMCJSuGKkqCvpuea 4WkechWLSXBRoVA7DL6Zj5g+IAhqboYNQPfqfqXU4kb29PnFhiXiribwF/brIrdbKeztE LuLofg9DfUGaIiCvUCW7NhqQny5gpfI2rMK/5pKxfHg9GIojEnOEriDs4hE4T3Cn8hQ== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793820310; h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature: X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State: X-Gm-Gg:X-Received:Received:From:Date:Subject:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer; bh=eGQwnQ2neaJQ1jlowOf5tkGQBWxndnEwh30xNQGSIkQ=; b=0vOIoENRP5HckVGT2u3fSZvhHjiAqsPEZFsasTyQAHDvGKOaekGoSFRWmRDLaAN88m2R 755Hc/CDAao+s4S9MMJueX64eLmu2+vbz6J7BF4okiT0Dyi+E6rYLJ7qG6lhMd2DW9wCn QF/vlZY4Tqed7Be9kHFhBK95mqkfPGy9bAsxwNgERrNuif9Gi0+HOACRRLfnZAOtI0VsH Tw77xVIMHbwcij4YJQiW9G0lNaKOuzTat5rQ2r5gnly3sYuJ7L2tSQ9eAdFwCKH6zp3HC S/wgGvgj7w1gyzNVVvvrKlnhAA9d5Jt4GuG/QUVmnvRl6958C6mPo4rwg3fHD8ojbfw== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=yzFlKYJJ; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A9508607F2BC; Wed, 4 Nov 2026 19:25:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=yzFlKYJJ X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.161.46 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793820310; b=sWqYApiNX8Hs2dzvgUVqpcsXePsjwWAEPhaht2fbfBk3irRp1cx5eT9LTu1K1w8eNk9N AeYnScnnDiL7kYzZXGQUSHGhMnbEel14Wn4Q64Rju28gij+1FdfKuFZpjp5yhkErFKweW x5IjC03qGC1xRA15vmmJ4URNW3gzz60iRIEoPijT3NFGFwTo3rP8L31MpBuW4Ytah7RJJ mecHi3PibeKhQFNcw7JT7MDIVsPIPMAWN8yY0qIE5X4L7t0ezLeKMMsBnJqUA+TaYUxVk Fy1GppmJXkAEsLBMxSmATs0gQwt6j9ofGdOUdTXL2p18wyAf9rklocfIlYHZaQjeyLQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793820310; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:Date:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer; bh=eGQwnQ2neaJQ1jlowOf5tkGQBWxndnEwh30xNQGSIkQ=; b=Cp0m42p/jwxmTMqWBQik2mN1ZLr8PrJRYxwGhIi4Us2cyOJUFO9Uz39BPP7JbeLbMkbx 3SCkMivHwIkeGbjqUChflZJy3NesvTsw7Z/HzlX833uKO+e3pITCeaXxrcZbCGjs3xuhR y14ocQ9FAFfTPLuFUdg0C47Qb88qnEdWCCJ3IMUDBdDbE7fbFyTuhwG30BZLUwupJ9toK dREMWLKMMCUV5J3TNFstmurE+6socRUGnOSOZmvyVPqaA0rBgaHBkb3FzHUd/2jfp6y1o XoX++M1soWW1pGXH5ys0vw/p8AYWdtOFPlXa4RdA2mNKtsOshwfa3DOv6e5hiKfn5zg== 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=yzFlKYJJ; arc=none smtp.remote-ip=209.85.161.46 Received: from mail-oo1-f46.google.com (mail-oo1-f46.google.com [209.85.161.46]) (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 433A6607F2B3 for ; Wed, 4 Nov 2026 19:25:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 433A6607F2B3 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 Received: by mail-oo1-f46.google.com with SMTP id 006d021491bc7-70b875f6f13so1005636eaf.0 for ; Wed, 04 Nov 2026 11:25:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1793820309; x=1794425109; darn=lists.linux.dev; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=eGQwnQ2neaJQ1jlowOf5tkGQBWxndnEwh30xNQGSIkQ=; b=yzFlKYJJfTXVsWZznZ1cuh7GeO/22fTAVRujpFfgz0pCLH6cKeSWunGA3KS+JZfgzx zMmtvlKUqfkVzWCLAuDC6jay/E6B2SVtdS1LacsgCMKDSTF8/tDGAy8AbthHYtGKwoeK RNgXBw0xkLeT6RLci+yANIVHM43mW6W7K//iH5y1W/nwcFtUgDu8mI3TbUoxf4yvAmxZ MxM1O+mPqI3vw7heFPyonJ66uRocdVhBh6aVvu4bjryqB4RqVVX6lYfssAzN8OietHz8 UODzL21vVemKeELrCzZUmTSYDhTrqRZVSxDdkuwSq4R0olFLD/M1Qz/ejZmJKuT024xD OCrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793820309; x=1794425109; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=eGQwnQ2neaJQ1jlowOf5tkGQBWxndnEwh30xNQGSIkQ=; b=ImWD0x5NpmYXZByLFPuxX7FbP375r6Zk0L2xFU4+gp55XhlJUoje3VoLtR9MpKgX+Q 0yUixJPhYO0p63UYQwGzYlvr1Jf2G/LcObVQLy5fphf8tVSwWJWU9l/zRkYB3A+mNA47 miuzaZg4rqko9oy14Q67c0Bqy65XTmYhRxlSYtB3zvF9qxne5fdeQUOHPqieSFrLRxda 9Ll/Et2Dx2QdkuVlgVnSLqzKNxtTV9suXiKypB5KsLKwOszsDPkyCqpSdkle4O0suU2f 4g4eLVkUafFDpmHKbcc0SIibhJZjT3cxQS8Qssnc3xNdh7BrxcpzC9c/9S0lCFvScXs1 Xg0g== X-Forwarded-Encrypted: i=1; AKwUvBwYjWrbMobkJvgL+FbEQMOqZLFDt6kOoofdImZorrdM8AQb5avDYwDZ8XotgD01TjhSXoGfukSE3WSGNg==@lists.linux.dev X-Gm-Message-State: APuU4Z8441gyRu2mHnGYTkypfMhp//t7IkSaYBnn/jYECvvlIkScgxLl NF1ZFnj2sjbFW7hMzMoW6MgAtrPechV4BXV+0ZdZuq2P93eh2ptqa5kG X-Gm-Gg: AYBFou3DUy9UPhbAnVHc1ZZKTY/rjjDeLOnT577uT+Q6A2E88xuV3ccGC6zKAOGM5bb YStoDabZADy30zGscf0bUcegLj8yELuflJysluZzHX7G1rW4fYNvm+2DEl/eFBUs2O2Qda/e/sP H4YtlJslYu5jWAOi+F+YfIzzN/nhn8SdGg5CaITItsJkn3GPMUGHba0RGA6IKXtCN0A/LkSIVG2 m9Pg/+RU4sUJbLwyJNLdyG+sHFgaokzEOUWmXhweV5oQEnXkTxoZVVYtyMji0VVqBH684nBpTQd Hm/eoQDPJxGv+VqR3Pup+sdpvOL1BgnfR9LdwGOzP6YtzOYf+GD+kE5kjAFBh9ucHxsJE2LjJqG wIkbVZvTjgQqyVWEYAzfXzQ2ud+rm0PDrMl/R8FmT5VkhcYrcOGN3BS+L7FLSSpp4xLZL+QfgH4 bojjEq92LMasIOe4wut3sBKS/jF+jtbhAL077MdEa5byvsHHZ+gwDol4Sc4/cxFXuRjqAtaUC/7 uKNjscktPJ6rt1g5A3ALazK3x8jW2a+hAVrWYRCWLpN8m4r4Jx8F1gLYWNWKWlHvudVbUNRGnuV l/T44AKucz3gT/Zlz3p6hGaaJbCBsNTJGs8ML7cDuZmiVUw3CDAABj31NKPKqMgzGmDdXet1VPJ gQuE6D1g45iF8dSQJ1xz2WdRRdjpstDqroKxUD1fxyOmSFB7wlXjeqMPzpchgDdr4kABVolnyDB bbPX1KsrWSouAJRxuZkUdyVJ7xZmIkT6NRsLQPr740EGCbVQePcVHO X-Received: by 2002:a05:6808:2218:b0:52b:7641:33a6 with SMTP id 5614622812f47-5640deea502mr12233182b6e.14.1793820309111; Wed, 04 Nov 2026 11:25:09 -0800 (PST) Received: from [127.0.1.1] (174-29-1-49.hlrn.qwest.net. [174.29.1.49]) by smtp.gmail.com with ESMTPSA id 5614622812f47-567a9c7bbcesm2328723b6e.1.2026.11.04.11.25.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2026 11:25:08 -0800 (PST) From: James Hilliard Date: Wed, 04 Nov 2026 12:24:54 -0700 Subject: [PATCH v12 4/5] arm64: dts: allwinner: h616: add PWM controller X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Message-Id: <20261104-h616-pwm-v8-v12-4-8ed39b0dba69@gmail.com> References: <20261104-h616-pwm-v8-v12-0-8ed39b0dba69@gmail.com> In-Reply-To: <20261104-h616-pwm-v8-v12-0-8ed39b0dba69@gmail.com> To: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Stephen Boyd , Brian Masney , Jerome Brunet , Richard Genoud , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Maxime Ripard Cc: Philipp Zabel , Michael Turquette , Paul Kocialkowski , Thomas Petazzoni , John Stultz , Joao Schim , bigunclemax@gmail.com, linux-pwm@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, James Hilliard X-Mailer: b4 0.15.2 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: INBOX From: Richard Genoud The H616 has a PWM controller that can provide PWM signals, but also plain clocks. Add the PWM controller node and pins in the device tree. Signed-off-by: Richard Genoud Signed-off-by: James Hilliard --- arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi | 47 ++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi index c6b3a3f8359a..b6580f0c6e0f 100644 --- a/arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi +++ b/arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi @@ -293,6 +293,17 @@ watchdog: watchdog@30090a0 { clocks = <&osc24M>; }; + pwm: pwm@300a000 { + compatible = "allwinner,sun50i-h616-pwm"; + reg = <0x0300a000 0x400>; + clocks = <&osc24M>, <&ccu CLK_BUS_PWM>; + clock-names = "mod", "bus"; + resets = <&ccu RST_BUS_PWM>; + #pwm-cells = <3>; + #clock-cells = <1>; + status = "disabled"; + }; + pio: pinctrl@300b000 { compatible = "allwinner,sun50i-h616-pinctrl"; reg = <0x0300b000 0x400>; @@ -397,6 +408,42 @@ nand_rb1_pin: nand-rb1-pin { bias-pull-up; }; + /omit-if-no-ref/ + pwm0_pin: pwm0-pin { + pins = "PD28"; + function = "pwm0"; + }; + + /omit-if-no-ref/ + pwm1_pin: pwm1-pin { + pins = "PG19"; + function = "pwm1"; + }; + + /omit-if-no-ref/ + pwm2_pin: pwm2-pin { + pins = "PH2"; + function = "pwm2"; + }; + + /omit-if-no-ref/ + pwm3_pin: pwm3-pin { + pins = "PH0"; + function = "pwm3"; + }; + + /omit-if-no-ref/ + pwm4_pin: pwm4-pin { + pins = "PI14"; + function = "pwm4"; + }; + + /omit-if-no-ref/ + pwm5_pin: pwm5-pin { + pins = "PA12"; + function = "pwm5"; + }; + /omit-if-no-ref/ spi0_pins: spi0-pins { pins = "PC0", "PC2", "PC4"; From patchwork Wed Nov 4 19:24:55 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 3868 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mxe881.netcup.net (Postfix) with ESMTPS id 483921C52DF for ; Wed, 4 Nov 2026 23:34:03 +0100 (CET) Authentication-Results: mxe881; dkim=pass header.d=gmail.com; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-27210-noreply=patchwork.local@lists.linux.dev smtp.helo=sea.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.234.253.10 as permitted sender) client-ip=172.234.253.10; envelope-from=linux-sunxi+bounces-27210-noreply=patchwork.local@lists.linux.dev; helo=sea.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 4DE116515B for ; Wed, 4 Nov 2026 19:38:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1793820312; b=Ol6SpPxF6hfTE19INehOF6e4Fj6t7yuigIhrNf2Rqg6T+hmCvhIf/oIldCyQoH/HzAKq qlpMr9RBKL+U/E1FXOJ5Yrwn4YCr7yztJRSja/EyrtXjLvbnQTGQ6oGv7pQJIZ3s21Hv5 C/1bPHe41heZd0yXH2SaW6pcXB+nZ/+jeTvRA0jZq855ThT+sT2tHrm/LcslmG0Pf6aos DYtEBHoBF8/psplu30QTjE8l8qZW0R+O9MzBGhayrJ/GYmcPoY7knhirm7TVmKfFScSp8 V/UdD/n0tVbiS4acM4P7bgJfDw/t4u2t7Nvc0dTOHcqAAmyEPTZWJCCINdoJB9A0PsA== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793820312; h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature: X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State: X-Gm-Gg:X-Received:Received:From:Date:Subject:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer; bh=JUJOd9ewD2XzFuoXefvfL/kztf8QXUFxcaNj03ZJSj4=; b=G6/Y8xNMgLVs6QHWJgvAmc9aWDA7yhPDlsJkOwGbAutVBoRO8rmzuAmX6C/fh1wE41CI yAd/qUoj/58zmQ7V1YhPjr4eSP2gDPOoaQQU22C5+hLrdmCKaTUfmKfulcUbguU0F66LU /Uv9TE6l6ucL92TqaekhDQG/iFoZrL5VA+4+8SYx8BjdHpjSRwb4n6KVCJJVBW3e7z7iv tUxuc3vFM70hsF53+ffwGk429uaDPxayPGKbuV3ak6+HiPHxBLuRTmDpqtcRZn9UE/Ayx uv1FhFJI2CpAtvCZXBdpBF29Z4uO2oL08nxY810DJw6VzevGAL0e1l+F+gOrprKB0UA== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=e2wbH2kf; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E5BB36080790; Wed, 4 Nov 2026 19:25:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=e2wbH2kf X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.48 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793820311; b=E8UphWAcNL+HZLDaucW+Asw2/CSF97eSvgxhwAcQUnHZncJvSCHHxB0VTpDuHMfUCxBQ iW8axLPiDzO/iDLocriXUsobQq4goNWbpM1LzBpaYQx1/EpgsxcszzqHY/gX7yKDdvhUb ciLjzMNvW16Wnrmph4c1eX0LVlj8YgFu/K77+7qLQAfYnbWvrdZO0UJ2cKxaLG6dNFa9q LpjeNpAEyMWSLHIXJhiGsoFieXlDJ9lUOgiidfojDEC7t2Ez9FM9L+8lB+twCLtswmLEa Ykdz5SlmZfrLA0bw7vk7jhHWS6CLi8Hr1RG2bETxvPTq9FVqnt6PllWY2M0rdCp8XNQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793820311; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:Date:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer; bh=JUJOd9ewD2XzFuoXefvfL/kztf8QXUFxcaNj03ZJSj4=; b=uFlz7h2/nUO89g+yc+tGIkRIpdm+KJJJUII4rxmEHTxqhxDIlVCV7gv+uy/NQTOYWJDa PQiiS5U02q91ey1Kf0VC9qDTZyIE2UJWkI6BYoTMCuhX2eqXNBl7HNhDMe8gdUuvMZmHR 4QAQNpKFeyrwqAKvNCp50aS9lRlZOj+BsNogcyOgWxLNHfv6hLqF24bIpvO9ytOXeMfTM JDA5aGJVR87TYlJ+zN4yCw+X2QSWI7JAAh2TUmBWp0+rafrP2bW5OTIOIJ0aiHQRmr7lj tk//Uh/DL1NxdFk/S6OXVNKTeTHsA0fjD74h3cJucv1eUv+LzUt+Kn6+g6OKwxYqJTw== 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=e2wbH2kf; arc=none smtp.remote-ip=209.85.210.48 Received: from mail-ot1-f48.google.com (mail-ot1-f48.google.com [209.85.210.48]) (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 7D33A608078A for ; Wed, 4 Nov 2026 19:25:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7D33A608078A 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 Received: by mail-ot1-f48.google.com with SMTP id 46e09a7af769-8490a7d6696so647878a34.3 for ; Wed, 04 Nov 2026 11:25:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1793820310; x=1794425110; darn=lists.linux.dev; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=JUJOd9ewD2XzFuoXefvfL/kztf8QXUFxcaNj03ZJSj4=; b=e2wbH2kfjPFfaEESz5lcVqL0vzVebRt59F0vtDYeU5oKTaFmLffOZcH5Tp8CCcSl3s r1wYhw9Kx2v+Sthaf5C7kahAE5LRVFNCl6C7TteqdxHnQYYYgt39vIq4wbBu/Z6qrtdG /2Y4HlsRAeaqkA8IkuQHNMxtrmCL4xIyzoQvhdn5axdWXBokFrnQkZQjrf3yEhxK+xje Ng8ilXJsOSxEQktRr4Fp8lK/YEoSj7wk59gDmqDR7YbCZTUPlhbUECqyFWUgKe0RFuxo apsUv9M66yrjp1YMMuYhWsx6drAyISNARTlbQWZ+PrAgu+12soznJJtEyOq9P8hBbuAF Fs/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793820310; x=1794425110; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=JUJOd9ewD2XzFuoXefvfL/kztf8QXUFxcaNj03ZJSj4=; b=hQntNj70Sp00CIWU9yl68hrLPPQ+w+G+QHXRCTMuAO7RYbDDvcP0ndImXmvh/81yuc D5rDzE4AwwzaeW/GsY06e+buwGW2vl6gO+jzAyWikgvghV31ANWRzmNVp3AH249BKY/8 sCbcjqmaHutY4TThqvc2JV/uNDTfb7Fm1b21uCEiRWPPFmyaG8EAXjKghZZn/BlDwm/e 2FfelIOTSCj9nSpzbfUgvgFYZL03rOSeqSyeXa7g1OhazAKy/YnFDt3/3x3ZmI8QVDYZ GsUYU5er2HXyPr3kF+UK0zexGnDFPKXHtIL++JC6+JozHmM/jfwYruI98GRHvGKH4qBf JY1Q== X-Forwarded-Encrypted: i=1; AKwUvBxClafntf1Si80EBqo7GgrrrcNCpJDKtYulhVSIVI3PbssnDaJLg7++oYvIvgxTHbKd1j/tVovJcsGawQ==@lists.linux.dev X-Gm-Message-State: APuU4Z88/KKDen9VHYvmFqnQKAsFBpWxSR7vYjVpR9k0d4NVNLYvDDKP K8IFontR7xC2t8vgdWkZGDAGlgd6SeqXUUyJN8+lVFeagZtWXmQYpRlg X-Gm-Gg: AYBFou2+6wW4xMPQXVK6NjEilzXiAXsSXao3y/I6Pza7KJL8orapFZvPeRs6fEzHJJj Di9NN7EWMpYsC/W6lmrx1x9scT06gEIpgXKM4HvCnLo1EBFo5p3+VhzEbAAdmg29CNueHMZFdf9 EJ5ALBe7yufxv863WeRp4m7T3uv0/plhGOzhA5q40I1N8TV1a8JnISzqjyTFQyl2KPx4DYlDKCA 1e87eLXHoGTEB0M9NGsC1ZGAl5IiTw+59c0tK2C/iOFrBsIn4TZG+2rH0Pl8j7LMMCXRzlMkVpC 5KCgcSBLGOwymvPOvJYg10eAa7N/7vdGzHs7YxvMYoHPI3ujUuJKGae8YtkBcFLM3KIw2P0eltY klqMymOGHpRs7WzVFTqQz5hWHFGPyCpytPC8VGL4RUISjDUbQkenOvZe8ub/dn+pH/dMUYqzDWU yqbmliz44ur5wULOq4gWilmHF2zfQNresck4UCS/oXifYE/Nl8NrfUO+V/ofHLxFB7AXytz10DJ rNtDdIz2cncR54ZakN91Nc/8tg5maw+QoRVBaz0yp34FWnK2mwVzhxJwC3Ji2jy0E52al2oiVB2 lK6wpyXMwQO0TDuVsQXSpT4RC65B93StaMDgaiGXKOYujOEJmCQ2fWkVPifCYze24K8jckBcB5t mUruaYdc4gUVe1q2HKCvalwOYV7QWKppgCBhe4wthEe61k+Iau70RqbL65fsuxi7Xj0AvS/ywho 8T7XtbltQcAMnYGChmEsr+1NpTvu2JkBbj2F315peKzFsqaP2/1jBp X-Received: by 2002:a05:6808:198e:b0:4d6:9293:9b56 with SMTP id 5614622812f47-5640de2e892mr13003756b6e.62.1793820310505; Wed, 04 Nov 2026 11:25:10 -0800 (PST) Received: from [127.0.1.1] (174-29-1-49.hlrn.qwest.net. [174.29.1.49]) by smtp.gmail.com with ESMTPSA id 5614622812f47-567a9c7bbcesm2328723b6e.1.2026.11.04.11.25.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2026 11:25:10 -0800 (PST) From: James Hilliard Date: Wed, 04 Nov 2026 12:24:55 -0700 Subject: [PATCH v12 5/5] MAINTAINERS: Add entry on Allwinner sun8i/H616 PWM driver X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Message-Id: <20261104-h616-pwm-v8-v12-5-8ed39b0dba69@gmail.com> References: <20261104-h616-pwm-v8-v12-0-8ed39b0dba69@gmail.com> In-Reply-To: <20261104-h616-pwm-v8-v12-0-8ed39b0dba69@gmail.com> To: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Stephen Boyd , Brian Masney , Jerome Brunet , Richard Genoud , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Maxime Ripard Cc: Philipp Zabel , Michael Turquette , Paul Kocialkowski , Thomas Petazzoni , John Stultz , Joao Schim , bigunclemax@gmail.com, linux-pwm@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, James Hilliard X-Mailer: b4 0.15.2 X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [-1.19 / 15.00]; BAYES_HAM(-5.50)[100.00%]; RBL_SENDERSCORE(2.00)[172.234.253.10:from]; SUSPICIOUS_RECIPS(1.50)[]; DMARC_POLICY_SOFTFAIL(1.00)[gmail.com : SPF not aligned (relaxed), No valid DKIM,none]; MAILLIST(-0.18)[generic]; BAD_REP_POLICIES(0.10)[]; MIME_GOOD(-0.10)[text/plain]; HAS_LIST_UNSUB(-0.01)[]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc20261015:i=2]; FROM_HAS_DN(0.00)[]; TAGGED_RCPT(0.00)[clk,dt]; RCPT_COUNT_TWELVE(0.00)[26]; FREEMAIL_CC(0.00)[pengutronix.de,baylibre.com,sys-base.io,bootlin.com,google.com,schimsalabim.eu,gmail.com,vger.kernel.org,lists.infradead.org,lists.linux.dev]; DBL_BLOCKED_OPENRESOLVER(0.00)[sea.lore.kernel.org:helo,sea.lore.kernel.org:rdns,bootlin.com:email]; FORGED_SENDER_MAILLIST(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_NEQ_ENVFROM(0.00)[jameshilliard1@gmail.com,linux-sunxi@lists.linux.dev]; ASN(0.00)[asn:63949, ipnet:172.234.224.0/19, country:SG]; FREEMAIL_FROM(0.00)[gmail.com]; R_SPF_ALLOW(0.00)[+ip4:172.234.253.10]; TO_DN_SOME(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[100.77.114.92:received,174.29.1.49:received,209.85.210.48:received]; RCVD_COUNT_FIVE(0.00)[6]; FREEMAIL_TO(0.00)[kernel.org,redhat.com,baylibre.com,bootlin.com,gmail.com,sholland.org]; MIME_TRACE(0.00)[0:+]; TAGGED_FROM(0.00)[bounces-27210-noreply=patchwork.local]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[172.234.253.10:from] X-Rspamd-Queue-Id: 483921C52DF X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: INBOX From: Richard Genoud Add myself as maintainer of Allwinner SUN8I PWM driver. Signed-off-by: Richard Genoud Signed-off-by: James Hilliard --- MAINTAINERS | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 93abbb315065..b80ae0ac5eed 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -947,6 +947,11 @@ S: Maintained F: Documentation/devicetree/bindings/hwlock/allwinner,sun6i-a31-hwspinlock.yaml F: drivers/hwspinlock/sun6i_hwspinlock.c +ALLWINNER SUN8I PWM DRIVER +M: Richard Genoud +S: Maintained +F: drivers/pwm/pwm-sun8i.c + ALLWINNER THERMAL DRIVER M: Vasily Khoruzhick M: Yangtao Li