From patchwork Tue Nov 3 08:40:26 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 3825 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mxe881.netcup.net (Postfix) with ESMTPS id C139D1C60AC for ; Tue, 3 Nov 2026 09:43:58 +0100 (CET) Authentication-Results: mxe881; dkim=pass header.d=gmail.com; spf=pass (sender IP is 172.232.135.74) smtp.mailfrom=linux-sunxi+bounces-27092-noreply=patchwork.local@lists.linux.dev smtp.helo=sto.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.232.135.74 as permitted sender) client-ip=172.232.135.74; envelope-from=linux-sunxi+bounces-27092-noreply=patchwork.local@lists.linux.dev; helo=sto.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id C86916061B3 for ; Tue, 3 Nov 2026 08:41:35 +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=1793695237; b=oUNn77IwWT9+en3RhYDC5L/BUY+LugUTcgedioZ6n3pXD184xF4xNOOxOnzbaKV9r2gm ijGcwJ+daatv5ufNHsTiawo+esInuvopJkXMsLlIa0nHcFKFDCaCbyLd28lX64kxwpdJ3 PLWeF5Y6hNtErMyzrJB0K2Cs5+LdG5Uc3FojFDTGS20RTPmiQDSGa5UjBEL0Jf4bWXmGt zlI5HM8QXHDJY5L76Lj/YT5IWaRX+Df7JHPmV+ZmCKTaHGrZFJuIhC7qrSSAEgFkrRR9V 1Dnmh54aD8ZumwtcMFwZtv5E+/WNOx8dDvTGV6JPFbiACY2u+zn/R8CiQZbntmZeUoQ== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793695237; 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=TnuIyZVE01jryvKtMKC+z02i0aTe2BXAjjFv8p61aI71UXEz1RrjwGIIJun/0xNNClql +B6Bm8Ttv7jkM9MndqEHyqen93TYMHzFwaYs5/h6SmLXvB1Joywkh3CcNsZ1IN0FNAt+K ZKj5XQAaOjIHZm/aaygMWfI24V+69mUxQqxAEDJb6c1pr3b9CuW7nZce6iHNUZKoLvENH TPl0f0P6liL9YRDG/7a3t8GnHsysNJnHCxn+NbUuQK534706ME+uIO6Rn3zszQF2aL+X/ g3HJx4t+sWolNsdRqUPHfkJRxvd0Fp6SzvUi4pfFpwOLUrZZD7JfWa40FG9YozRt0zA== 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=RUa2K7MR; 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 029A0606B6C3; Tue, 3 Nov 2026 08:40:37 +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=RUa2K7MR X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.161.42 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793695236; b=4YpzgM/wLsx99JfrCg8OJcsmSWTn5+NMnwqj3mQDRNac27z0+gsApDSV6MIvb17jLZF6 tytMwqH7cKS7hSXaaHkWzqIeM5XO7THnmjn9PCyew1vbUEEF5ZDD7LkBt0tY9q8dQzrX+ tSKzJJD7M1IBe6IgB+a3IPtypLW1wqjw3SOHq7xlo6P427EXcsVmxiGVEpIxVPVkyUDp/ iBI9PummUaL3JF5qup7mIVBm6dqybZWJjFoz8G/VFa5NdDdgfIB4GOAHG07CvKGf4PX1F 4eGp4TafY/s/l6YlR9x+vJeLFSktfttRiFzDiRZOEbGGc+9gT3GwKFwPs7YXyAItrBw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793695236; 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=Fcs7r8Qnzddzp2B0tebeDg+5DUNi0v+DCqvjAJukrENDySN/BvkUWNl5Zi7wWK962zOu ylY4k9RBOt4ggSsiAgTzs3i85Glkyz7jfyHR/v0egdttVOUZpZmY4nZMrESp3SBH0ujSG FOFgf073hFJIrXNtPYcKBcjQiHRuJp0N3T47/QEZ9357/3ApRdUOzXwL1N5YlZ2PZWMca iED8cs0NufDYsKcwDw1Yjrd3wI7tvaNMYkeiLyYrxQcUf2hSsWDJTOQtiVmT3I9bG76pE DQQbt55sjl8uwSL5xQtgrr18OLet6FY20lChIlpC9p7SG/AdlRlvPO2zdACfhVVgvrQ== 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=RUa2K7MR; arc=none smtp.remote-ip=209.85.161.42 Received: from mail-oo1-f42.google.com (mail-oo1-f42.google.com [209.85.161.42]) (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 8B5D9606A954 for ; Tue, 3 Nov 2026 08:40:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8B5D9606A954 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-f42.google.com with SMTP id 006d021491bc7-706113e92f9so2172730eaf.2 for ; Tue, 03 Nov 2026 00:40:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1793695235; x=1794300035; 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=RUa2K7MRllhQIHhweE3R2akTBhUTtROoG3vwH658NLFfkr/fc8P4D8u0tvrrP1gX8h I6xMHZTQc9ndxr3JMHv2GfNVUIRkaB58UWjQHIY8AKtxop907eIEblGOc+zev0LnKTb8 KNdoyUC6RvHa4kJnMRYO/nmSxtrl/DB8NDrUci/wAQK/7tF+qJvZlXSFa0fhdzKjdnyv Dt7y/IrgkoYekpUXgAkhroVBxaS6m2EmoVO37DSlVrIyvBHW3YqN3I1JwHAu+JK9DA3Q d4y5aDc0S3IlnqbmrwpBz8M4ic04gmaRhfyi2gKsPkdyA9MzwWsVEAaxWWMjqMUKMUTu OcHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793695235; x=1794300035; 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=eWoyQ5ZGmQd7DKvKG9poVE13RBpJyPu59ZzOS6YZ/336xYuw8fZ0lPBQjS2bcuq3v8 XtULLF5Z1hAecwQ1GkJTbjZl3hGhM+ALGDJe3eNZcFhkrFzB6FYAJRWCLlzLwPIVxxxp j7HBTNfBgdZoUFLM0vdItMXOsgzd+kF7qwMtGNYqmvC3Yp/qrx6GaGQHtrf7EYjTbfMv C89cbxzf6sJKUb2/fidowS8/VamJ6FtYCojaN6E5UNG7yyC0Jw05DL+sRqsP7iJjGlHT zZ8B1RDxsYMFeq1E7PbnWF5LTuPy56UBJZ9dWhv61TIik7BLU5zLu6VlN1fS9+UUbxZx I4OA== X-Forwarded-Encrypted: i=1; AKwUvBzrLn0EW6yMPv5iV2ECUUIs2B5JSoDr74Q4AO6H2U/l8qkgyPvqrlEonErNdkSYne5058pWCzZlRDv65Q==@lists.linux.dev X-Gm-Message-State: APuU4Z/xfjjFoLRyTCMfSpHIwFnQ4thV6lUITD1/INv+BMmYLIrcxPnL G0w2/Rje24UWnZQ8xqSmB89hYfk8pwgffLeZOuD9sxng94yrxvl3Vf1W X-Gm-Gg: AYBFou1Dy3oo653bFpKtti+6fXHaGCa2Qbk1/zk1fVwu4tmUF9oOHeYLUOJ6fKERYgR QUEjN0vZVwfB8WXN9F9eiTbgqPxvc8zz6EQ5PKehb7DgV1BtOT2JZ9Wufy5KaocbgoHCE8l94uA gWKA4tlYnKwFNOzgzH61241EXoVpVo1VoRb5OkTSW2FYv4iPAu6YwhZwJsNZhPQ6brWdAPGbyER LtBo19Mu8I0AkgWaDMVCROrb5V1zoMYeXwddBYS7EB+67BETlOUUSbd/2njwnFvFtMrKOhHycEf fcrFAJnibhSVxiav1U/0HdBO/LQHdBrokuMzNAuYhzjyU/X3l9Sn/aK6so47cxPI7snuEAIKMt+ 1T0Af5bx1wF5NB30p9SLB8fyRsbT0wNalkPQWXHaV7bBPyTnD9atEQkZKDNogReAAbMQmz934oE seyzAktMKo0oMJBwPnJHldW3m2j16F8O4W4Ba58VKm7MDMsJPFGgsdVXrmMrXUiaTgYQ+I2fjIi RHtvGvHj6/SdNwPLQ9SkHUAjsiGKuWAhzDizrh9Y0djCTnkKz1ApeQlqs2tMPMWN+LMNhYqGy7R Cy5erTfqIwmX8nscCtaVMFbY+ZSzeNgJkI6diG20nUkO60S7Yj9KEsiL7ZgAj2tYNLufA7bRDEe wxvR6Hv0m5lYb927ZN5i9wAORrYnKJXP2Yly8EKBMzoxjbutf9f60lvinbE7Y9d2YZW0MjT1Sp9 As3MXUhf7WvZaiV11ug4sMIiWk2apLlcW/Pc83P/DELy3QbX9qnRQ= X-Received: by 2002:a05:6820:a50f:10b0:6ff:3c41:8153 with SMTP id 006d021491bc7-714f299c8cfmr4772331eaf.54.1793695235466; Tue, 03 Nov 2026 00:40:35 -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 006d021491bc7-714f3081097sm10520397eaf.13.2026.11.03.00.40.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2026 00:40:34 -0800 (PST) From: James Hilliard Date: Tue, 03 Nov 2026 01:40:26 -0700 Subject: [PATCH v11 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: <20261103-h616-pwm-v8-v11-1-07abb59575c3@gmail.com> References: <20261103-h616-pwm-v8-v11-0-07abb59575c3@gmail.com> In-Reply-To: <20261103-h616-pwm-v8-v11-0-07abb59575c3@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-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 Tue Nov 3 08:40:27 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 3830 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 3BE381C2D66 for ; Tue, 3 Nov 2026 10:12:06 +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-27093-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-27093-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 7BCB429485 for ; Tue, 3 Nov 2026 08:41:46 +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=1793695239; b=OYVsz9nCzJINOW5GJooNyaQpbBxQ1lm393IJBT5KUGhT2DT/TJMzDS41JOySjzDeeBjr c7xQO1pWQraX45eraE2Q4GhS/n14wMF5UU9BRuq83QAuQxFBiMmTlbUORdIA+emeR4Qc7 wIZLCRMTECaiAh14MB2tT/2O736Nts85HjijA8Eljx0pDaPWg6ztct8lyod9hwoLgh4VT HqugLZkdwmI6nhGpCfZIlqA9HwTXh/tl0kVzMyJQWcaUpkYZEz8/wxfUND3XSNcEufTyp YyJdaA8SYvtw8vbUrTjjIJSjVBG4ezj8e02gb4jS3d+/u07pkgWRRjYxvO3WsVFTy9Q== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793695239; 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=wVUrGHWUazMkQfkNxvRuSlykd4L0BZwuc90KbAxywBg=; b=z5C+Nd/2cwhguVzcFsl3t+kPnQSnG5wsMVjA+vt3k65gcJA/vwi5MhRzi+EznZVN7ehF tz0PZNy6Ba2XegKNkkWST/LcfaqB4sWOH5B9uXe7eOmz37iQ48/v6Yaw/wSOuU1Fvzi1N ZnP+zZ/pOP8bEPcGFK4b6N/LJhfcbNu+9HMWm/A/wmVetpcaKE5BmAjIIz4JNRniUhlCc majJDZIlncn/RXusFKIvtqSlUOt1uQRC2VNw0VCXh++msyvV/Q5ToUC7hdycxcFWBQsLh AOMH1Qj85PaeyI4prUkDlPU8rKaa6euYgM/eV9vR5yYdSbm3i9d63IspJOwbxr0U9sQ== 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=eiAPY0wX; 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 83525606B6F2; Tue, 3 Nov 2026 08:40:39 +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=eiAPY0wX X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.161.47 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793695239; b=MuyqyCgAln7TzS1cMHNAm6ITXtf7Lt3Q0zOl65m/Mxo+0F3caEO5DpHt/3Yq4gbWyg+q lBQbMcnOgf2gVFcaJbQ/0sDHTDSdvxvT+aaQ1G3ashMwQHF+bCEYtUNzXJr9xDEsUBtzk WbZna9c9guwgA++/XSyxOv6w7aBE1bZCy5HXIbqYzD78XOPYtgiJU9O3Skh19UV8l+M0s HFW9cROd84wbXLdoDMfkwiPpXQokvAXdAyfgY+RdBgeG0LBwCCe0CSdK1PXzT0OCd3K1V mFNZ2OhVI4W12IIU3Bfjc9uI4jjWppHnVzB7+pO1YFbBXz3u+R7CQCx7Y6w2M+bGbsg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793695239; 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=wVUrGHWUazMkQfkNxvRuSlykd4L0BZwuc90KbAxywBg=; b=giVUwu7zuEQCiPwN5SpcI1cNLU2mKGUrqD7k4xcF0T3KuM+BT8F7ls0e7QdjnomxP4qH rHzUgAFSt/ytVdFeYFanmo/TUO6ZRa4UZWylfSn5dXGrwnxDjfSxw7jcKKxDYCt2hGFkl CbCKUE/LZVqOELSs5MZV2dnvUN90/UOnxSg4ynnVN+S4HgvE37bzBHQVxuSL6FlBeuMIR 0pdi3qUVLALk/IHbr/GEVBvQEuceyTuSrTBjN6zvPabTL9q8wKTkAkpl9ZNtXFgI20Erg MQjyhQ/OdsJpYkAyvvKWwpzS2SZuek3/7C48qxrhlOTDKg1SnRdLgvTuQyIl9lst5/g== 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=eiAPY0wX; arc=none smtp.remote-ip=209.85.161.47 Received: from mail-oo1-f47.google.com (mail-oo1-f47.google.com [209.85.161.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 6E90A606B6DB for ; Tue, 3 Nov 2026 08:40:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6E90A606B6DB 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-f47.google.com with SMTP id 006d021491bc7-6df5e315bd1so3432002eaf.2 for ; Tue, 03 Nov 2026 00:40:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1793695237; x=1794300037; 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=wVUrGHWUazMkQfkNxvRuSlykd4L0BZwuc90KbAxywBg=; b=eiAPY0wXMKfkW7NA9T5JCbQxJHyMxJC+Gi8sdPAtdcAFdzZP+fXPip27XiNluQulLv pQXY51s0RUNq/K0Rq9MTdiVOhQdC6cncQgBiUHskaWcfhDScft44bo0bfg7HvF8XOAB9 hAvGFYaZQFcCOeEDIJhwLYlU/fc+wzATfzvZTBj+X0iAEWGjlqkNwy9tDuQdk2IO8GTZ wi0rJnJVwE5tnDc2JRUbMhOEkZIZzK/E0xyGjN8klSWT3A72e83mBN7e3jNY9g6QZ6b3 /Y1TEZSn8kgd8Zvs8t86CQKF3Z0AsyebZrMwljGgSGV1J2keqiXRs2RaJYgo0S9mRUDX dJjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793695237; x=1794300037; 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=wVUrGHWUazMkQfkNxvRuSlykd4L0BZwuc90KbAxywBg=; b=ocEaxZZGe/kRneTRffx+T64uxnCIdsdvGxnA+nSZsp72JhxcBP1/RZgmak3stJcjDz VhMKLNZctFX6NGrMcV7T2Kz65oDAG4DeDPZvWkdsTHTQK5Sgaz6pVbxOvSPqFyLw18eX Koc3c1Kp02N+wabPKU//j3SxN14GyACyZnD1wGzdBZOm+6wY5t4dpLhefPX+w+h0ht8O w0Dj89EJ/PcZwr837a7QbvKK+XJHp2pUY7jRLpMl6ADEvvjdt17/+PRcmf6cxPLNx7cR S8sTK9TjoLbGYK0GfDBFucttJ7bKi/IY6h1ZRtSuEGzd1VUAERfO1eAouNm37VxQ3/0i 0DQA== X-Forwarded-Encrypted: i=1; AKwUvByk89220XuZ2w80BL1QFTTBGY2pJtYsV0xA6SD6PY3S4C+uVJUU1qJdaZjiaFBW1TU8+0WjZ8g7Ve0o6w==@lists.linux.dev X-Gm-Message-State: APuU4Z/ZeT9Ha6xz6SH8dw3ARql9OMywZiTTEb++qnEff9CHj4sL3jGj 0dA4tztOinlbjt7lhDE+9273pwpE0lJXrssJ4maSHC7SVRoBJwH+E7/B X-Gm-Gg: AYBFou2LoPYIljIugwWf8QjypWuTCL2JZJ1eKZBWVQDB8+CKYleDP7BX0louYgsT7sh YBUm16wuK24JTjzphu/OyWZA9T5n6vlA5QC5ScZKi7W3VyCUkEyO5f2UzK+XqeuoNg8c1X5uggz u1Q6Im7kimQFYRF+cQAEhfQmBBE/NA3NKoyYNpxtpFYNwUrVA/NcG0sa8uBn+2/u+WC+xOeqIiZ QzUmksYSK8xCpjqYC1BiFuUS+1HX4yFK2GXrvymGoYNJ/owQMlqHYnakaEO3ka7fa6EjVfNNDRK D2gE6r8YwNQXnJF01bwov7tLkbHUTpozp2pxa1eHx/GvmmYooJP3QKAE11R8wq+wtUldOJWzMMp HYXGg8b5vVBGscyAOC0gkMJ8HEu8AzEReR59OOtagbi8bNwrqTq/W0v+8n5RBqdSZD4wk6s5COe BbX5+FP/2bBTwSreyFN8hV4a6KUgkbWvU600JsEclksgLkkvRoMx2BA2kNunzT4LQiL5U+QaUwn pOIZevl0Suk6ObdT3gIIrxnXMy59T5IrLpm6nYWP8t2SyyCqRstDpskH2dEZUHh1ZRsJV7zLH2K O1Y/7OZytRlURuVEA3E3jw3cEwSxHw/eBsdLegj/tHSD3HR3HceenAdCUvUeP6zawdHlCcNdZuB i+aMgf5nq3afEXEepzMRCj25o3+xKePwhDNQLzP188MDVJlRZJZzgC9aSmrvR6PI3W917aWQNHe R62pnH4dQN5J51sbRj01seHiLafGzCStZMJ5/1VDRhbHT1+PwQYbrl X-Received: by 2002:a05:6820:80a:b0:70b:f166:ee63 with SMTP id 006d021491bc7-714f23fb95bmr6655421eaf.25.1793695237218; Tue, 03 Nov 2026 00:40:37 -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 006d021491bc7-714f3081097sm10520397eaf.13.2026.11.03.00.40.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2026 00:40:36 -0800 (PST) From: James Hilliard Date: Tue, 03 Nov 2026 01:40:27 -0700 Subject: [PATCH v11 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: <20261103-h616-pwm-v8-v11-2-07abb59575c3@gmail.com> References: <20261103-h616-pwm-v8-v11-0-07abb59575c3@gmail.com> In-Reply-To: <20261103-h616-pwm-v8-v11-0-07abb59575c3@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 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. 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. 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. 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. 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 | 1129 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1141 insertions(+) diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index 729776086879..d87d166e7836 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig @@ -748,6 +748,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 5630a521a7cf..9c922b1fd0b4 100644 --- a/drivers/pwm/Makefile +++ b/drivers/pwm/Makefile @@ -68,6 +68,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..bcc2c5744378 --- /dev/null +++ b/drivers/pwm/pwm-sun8i.c @@ -0,0 +1,1129 @@ +// 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 + +#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; +}; + +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 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; + + if (event != PRE_RATE_CHANGE) + return NOTIFY_DONE; + + guard(spinlock_irqsave)(&sun8i_chip->lock); + 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; + chan->rate_exclusive = false; + } + /* CCF takes the prepare mutex and may call back into this driver. */ + if (exclusive) + clk_rate_exclusive_put(chan->pair_clk); +} + +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, per; + + guard(spinlock_irqsave)(&sun8i_chip->lock); + pdzcr = sun8i_pwm_readl(sun8i_chip, SUN8I_PWM_PDZCR(pair)); + if (!(pdzcr & SUN8I_PWM_PDZCR_ENABLE)) + return 0; + + per = sun8i_pwm_readl(sun8i_chip, SUN8I_PWM_PER); + if (per & sun8i_pwm_pair_enable_mask(pair)) + 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); + goto put_rate; + } + } + 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 sun8i_pwm_waveform *wfhw = _wfhw; + struct sun8i_pwm_rounding rounding = { + .requested = wf, + }; + unsigned long current_rate; + + if (!wf->period_length_ns) { + *wfhw = (struct sun8i_pwm_waveform) { + .enabled = false, + }; + return 0; + } + + 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; + + pair_rate = DIV_ROUND_UP_ULL(parent_rate, div_m); + if (!pair_rate || pair_rate > U32_MAX) + continue; + sun8i_pwm_consider_pair_rate(&rounding, pair_rate); + } + } + } + + 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 Tue Nov 3 08:40:28 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 3826 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mxe881.netcup.net (Postfix) with ESMTPS id 9C4951C421A for ; Tue, 3 Nov 2026 09:44:35 +0100 (CET) Authentication-Results: mxe881; dkim=pass header.d=gmail.com; spf=pass (sender IP is 172.232.135.74) smtp.mailfrom=linux-sunxi+bounces-27094-noreply=patchwork.local@lists.linux.dev smtp.helo=sto.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.232.135.74 as permitted sender) client-ip=172.232.135.74; envelope-from=linux-sunxi+bounces-27094-noreply=patchwork.local@lists.linux.dev; helo=sto.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id 5EFCF60649C for ; Tue, 3 Nov 2026 08:41:50 +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=1793695240; b=LYTzhTjUvvHsk5BEuA3HJ8uxePxc44jQ9gYz2oh4NWb2auqKPa0ZShdfwMigFUvQQCMA BuxuRxoO2J0dY7KTPUXJPsMS7eGJtEFCmwCu6puk41+COE4MSuceae6Ej6WUnndP6y4Ic ObOMy0gol2K2qkwkmwD9usY0KuZrlQqLZM3lRZEyvSGm2MiJ6sCCF7gYV5dtwqbq6w7/g muV0dsZv31t3l+KaJZ/38XrvVprHyCbOsPDqAixJuMicvn3/fTCcVASF3Br9QYF4/WveM sW+Ik+Fb+kVzr2Fproh8d7ius+HuDyedCU2s8iRunglWnjmyrg/a7Xfn6D9VeY8nJfA== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793695240; 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=WEFo+IxVAs/pTlWHu2sW56+ha4/QPfN3XGM3j/8cBZM=; b=37WnWYOr5Xl9IQb9heHiym8/D93Z1hSwZHe4/6c3awmDPWJVxgPnDt8yW2ZXZm2aRAad lZeg0SoHdx9euULGAa1h1epBXPjK0pOrk1TPy1cx0a+oyOxTquWM0lrKTVAL5GuvbtXIG lcLKGsL0+5mLtA3gmuy0g4PfcnmjTecXxA7bikcYRFhyeB97mbAnlPgU5N9cviSgkY9ak Ms0ACgYspythBq0lQxt4bsE3MAf3lCoR32tnzF+Z6xbKSq3ECPNVP+VeublmcRh/SrDce oAUBob2NUfiAqyCgSzWrZQxpoRDxZHGcji1J5ncmzmgzQHwHxcrkAyNVlxQgRXQ0uLQ== 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=xkqfCSfs; 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 A2BC5606D802; Tue, 3 Nov 2026 08:40:40 +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=xkqfCSfs X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.161.44 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793695240; b=E/9j9/G2H4FhO7YIidmpFnNDHKADhvJDo8DzHLEY8oXAtOU8/aL6Gaj2su0YH6EHa3Wa oM8eypb4zA7t/hnFdD5K08lKeVBt7Wlpx9DHgW8B2wSQlBBUF27FjubwWUCebU31CAKWr 0aPknRXbXAET46kv7B9rwVnv7UARkCNFgsjmCr1+u6k3w74W0+F+tnaP9gtxXoIrVMr1d ubOHLZ2BdYyuHa5F3Rwf/vB5/HrjM5mwOXd1tx2tZOxkd+1MPGFKooeezYZZBafvMcfLv 4zWPkd8aVJsetFsWtqER8Hb0wTdHE03ktLF09hdV15HwMvJV7OYzFoEUCVpOStGh/og== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793695240; 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=WEFo+IxVAs/pTlWHu2sW56+ha4/QPfN3XGM3j/8cBZM=; b=ZZjCeDkcovfzcIJu6GSdTOP4e2Aff2ui9kqXRIqbWOtIgQBinrt9hQjiiKUdcxJTanHm K4jjasGqtYbafGZFvW2kAUmQeFZmuT74JMNhvyTIbaUNx5UZ9bmfmSNgvvtV+x+g3vzpF gk2oQrasC1Tu82UjUahX9PcJHiAlg9rCIdGNdehEFXXr3y0smlZAUXrv8fEpADNVs+Gt7 qkq01yjkXpqhq26foYWlHfXKnuDUoY2LniQPj9cS5VS9iVx8SlnTCA3D5KD5Cgr1gzhUM WK5e8I+Z87ZB8Zwi7sHquWk/CqIb9d7gtdRpyLA+lM0nILn/J6rnhgLFCtSKtbi6Iig== 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=xkqfCSfs; arc=none smtp.remote-ip=209.85.161.44 Received: from mail-oo1-f44.google.com (mail-oo1-f44.google.com [209.85.161.44]) (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 1F4CE606A97E for ; Tue, 3 Nov 2026 08:40:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1F4CE606A97E 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-f44.google.com with SMTP id 006d021491bc7-703be215729so1726015eaf.1 for ; Tue, 03 Nov 2026 00:40:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1793695239; x=1794300039; 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=WEFo+IxVAs/pTlWHu2sW56+ha4/QPfN3XGM3j/8cBZM=; b=xkqfCSfs8s0zVQLA1C3eEpSglovr25YEJkpB7ZrKb9+CyorTA5w3QkJuin8PQ6S+aZ rw1q5KzH510ac0NwioNdEgQzykkz2D5l7kJ+Vb6+QOvktpfOMJlLHMJEyawO+Wuu/WUD m8SuGHe5NAiMCZTeY4a222fXzdRIK3gjpWt1HOJ9h02RYvHwBWTpQHRPLZr2x0+9loJL 22Lx1Jbg2ShpXJLROOJdIWrR9uI18duAmnGiMxeXc7D0CD9W+wvKnyskh5YKH3IMxa3e JxA5G39WgSeAYFCkB3O9/eiE4k7qjstPlFtPmTIxK1SGb/h23WGZMM5GgH2ac0rqtSPj to7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793695239; x=1794300039; 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=WEFo+IxVAs/pTlWHu2sW56+ha4/QPfN3XGM3j/8cBZM=; b=Kq9xhXLkOpp9VKw2agskO7RslEV5DtSGW+g2noNbkDR9T/iYcrb/ngboVAfOqSF7uy M5cLsC/XCMiERMUl2NEOYzySXIVcogJ1zxqAanSQQ8bZIaAIj/5sFlHAqZXnvnyJrBHk qzkrPer5ulFERTL7kQLMGvtSqgfaiGn5Ro3QNjOXaGqWwESkuMKEVaFdCLXfUahPnGZO Fa4Wy0oevbQONgn10x07GnTIDWCwtCkC76vyKhM4MDbuyf0HG8bnrGezp2IFROSaWY1f uKZOlRa1PXzMcZOREbfS0Ib/RV/xSd5RopV7CXhCIn/poc+JsZt482pdZR1VpHcS7qLD LNGg== X-Forwarded-Encrypted: i=1; AKwUvBy6z1bv34jrSXRxAmh8aMD4/dEIAwik+xBeXkRKtEsrByMvI9viRWc9go3q3bXsHiXPKBG9MeUn6ewMmA==@lists.linux.dev X-Gm-Message-State: APuU4Z8OziueZyobePiMOw5KK1diOZ/XU/ffLVOeAL+t7RjY+YkrAM4y 83HLiv8w3cfcVTmmPUhbPAqmsYnaXL3hIp4R49oGV8GHqOs2+ImSsIMk X-Gm-Gg: AYBFou3JkRz/072okRKzoa5I7ePBBSSmJNEBTB6+ascVh97XZ6ZbOoGzukIMedChU8E rxWuofwp+y79txECxhYkR4xnKDhaec37Lvnrw8Tq8NR/jXFSYuvEqdksVogBSJhG54I/a1wWUqD IstVpGv5a6TJETSjl+wpEs/w/Zz89HTaSUxvr+fYfSrl8evLjJ3IKKwadgJf9wSQA60KfHVY4xX Y03JxCGlikVwhw74fkWYX0UmaUsaEzSkwtWC6nRsfe2mUKtdpMIIwUyQs6DAi7O/KhabSoZAo0D 0L4OJi1RlU20q0NlWAGuOVfwH5YtPldW9u1hx1Sa2sb5+6FKUjl5Q9kyp3atKX+R4kQ7QYOjI1Q +7XssZWFEUMybeszi1yBtz2iyOV9cxdUxnnr2qPsgIB7l5O4zZjGsyozNn/cpB98+lf3ckaUa5R Ulnrr30JhVoZhBvgs8MwrJxKf+7oAywuYx2YSWqCkNp+4/1MqOs1CU9r/w6lUMdh3jBfVrcpnGH INUd5NhpL9dTEWOaZmooVBDeCd3rUKBhmjzOAyePx+S2foG/AqbPvzlPoZqySj7eawmCg0mC5Bz ydl6Jhuqvr/OrefNL3V9fIaibToDmXovT13M8lhBsuidftDwnw8Zj/sFdFCbaV9NmHksZr5omFn CaexYnOEO/mQZuV/SZ19UaPA56rUi0q9jtz/5i92pOppS3cMJRdqKNy7r5dQHv5w3LrjW2WM/NQ sVMmrFwUz/3kLBKSMeT4T1pBJ+ezED3wFD548QL+JTT6LQC+5d20U= X-Received: by 2002:a05:6820:151b:b0:6e0:3cef:6883 with SMTP id 006d021491bc7-714f2a9d542mr6176467eaf.77.1793695238968; Tue, 03 Nov 2026 00:40:38 -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 006d021491bc7-714f3081097sm10520397eaf.13.2026.11.03.00.40.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2026 00:40:38 -0800 (PST) From: James Hilliard Date: Tue, 03 Nov 2026 01:40:28 -0700 Subject: [PATCH v11 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: <20261103-h616-pwm-v8-v11-3-07abb59575c3@gmail.com> References: <20261103-h616-pwm-v8-v11-0-07abb59575c3@gmail.com> In-Reply-To: <20261103-h616-pwm-v8-v11-0-07abb59575c3@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.232.135.74: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)[]; TAGGED_RCPT(0.00)[clk,dt]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc20261015:i=2]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; 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)[bootlin.com:email,sto.lore.kernel.org:helo,sto.lore.kernel.org:rdns]; FORGED_SENDER_MAILLIST(0.00)[]; FROM_HAS_DN(0.00)[]; TAGGED_FROM(0.00)[bounces-27094-noreply=patchwork.local]; ASN(0.00)[asn:63949, ipnet:172.232.128.0/19, country:SG]; FREEMAIL_FROM(0.00)[gmail.com]; R_SPF_ALLOW(0.00)[+ip4:172.232.135.74]; TO_DN_SOME(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[209.85.161.44:received,100.77.114.92: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:+]; FROM_NEQ_ENVFROM(0.00)[jameshilliard1@gmail.com,linux-sunxi@lists.linux.dev]; RECEIVED_SPAMHAUS_PBL(0.00)[174.29.1.49:received]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[172.232.135.74:from] X-Rspamd-Queue-Id: 9C4951C421A 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. Protect the pair rate temporarily while reading a waveform, including unrequested channels exposed through PWM debugfs. Otherwise an exported clock consumer can retune and enable a previously disabled output between the rate query and register snapshot, combining the old rate with the new configuration. Use the provider-owned handle for this hold so a rate-setting consumer cannot drop it, and release it after the locked register snapshot. Keep the sleeping CCF calls outside the register spinlock. Signed-off-by: Richard Genoud Co-developed-by: James Hilliard Signed-off-by: James Hilliard --- drivers/pwm/Kconfig | 3 +- drivers/pwm/pwm-sun8i.c | 198 ++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 195 insertions(+), 6 deletions(-) diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index d87d166e7836..d3c35a11859f 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig @@ -754,7 +754,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 bcc2c5744378..56854e6218c9 100644 --- a/drivers/pwm/pwm-sun8i.c +++ b/drivers/pwm/pwm-sun8i.c @@ -113,6 +113,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. */ @@ -129,6 +132,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 { @@ -142,8 +151,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; }; @@ -153,7 +166,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; }; @@ -317,6 +330,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) { @@ -342,8 +450,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); @@ -372,6 +484,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; } @@ -382,6 +496,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); } @@ -390,6 +507,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, @@ -399,12 +519,20 @@ 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; + int ret; - 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. Keep its rate stable until the register snapshot is taken. + * Use the provider handle, separate from the PWM rate-setting handles. + */ + ret = clk_rate_exclusive_get(pair_clk); + if (ret) + return ret; + pair_rate = clk_get_rate(pair_clk); scoped_guard(spinlock_irqsave, &sun8i_chip->lock) { pccr = sun8i_pwm_readl(sun8i_chip, SUN8I_PWM_PCCR(pair)); @@ -413,6 +541,10 @@ static int sun8i_pwm_read_waveform(struct pwm_chip *chip, ppr = sun8i_pwm_readl(sun8i_chip, SUN8I_PWM_PPR(pwm->hwpwm)); pdzcr = sun8i_pwm_readl(sun8i_chip, SUN8I_PWM_PDZCR(pair)); } + clk_rate_exclusive_put(pair_clk); + + if (pair_rate > U32_MAX) + return -ERANGE; *wfhw = (struct sun8i_pwm_waveform) { .enabled = !!(pccr & SUN8I_PWM_PCCR_GATE) && @@ -510,7 +642,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); } @@ -1033,6 +1166,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 @@ -1061,6 +1230,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; @@ -1099,6 +1279,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 Tue Nov 3 08:40:29 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 3828 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mxe881.netcup.net (Postfix) with ESMTPS id AB9FF1C2D67 for ; Tue, 3 Nov 2026 09:44:58 +0100 (CET) Authentication-Results: mxe881; dkim=pass header.d=gmail.com; spf=pass (sender IP is 172.232.135.74) smtp.mailfrom=linux-sunxi+bounces-27095-noreply=patchwork.local@lists.linux.dev smtp.helo=sto.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.232.135.74 as permitted sender) client-ip=172.232.135.74; envelope-from=linux-sunxi+bounces-27095-noreply=patchwork.local@lists.linux.dev; helo=sto.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id E9B036089A3 for ; Tue, 3 Nov 2026 08:41:59 +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=1793695242; b=kx48i150Ic9k50DfZlhXzUxpiOvgSCoYY50PWDnHihZyMS+Pmba6bjKV3vqdZQccIQSD 8v+x8Gj43BH3KrNE9iLYeUlM8hqwp3EKrDwO1fk0tbCO9EFftR+8fBqEiQ4G6qSzgm8hg 6YoDkpgPhZPgRP36kGFC6o2T0C1cxS8sGKxO3jKWS2YpiDCuJEtZZ1OopLUv1e4IyC1Rt fKbcjusnJjcbyF1uYJOJTNwc7RqNNoeqbHsV6hGEXOwqh8R+IQV13Nsgbg6tt3CfAI5hg OTbrbL5sIa4HUkwCGb1KKz8UT+AfHWb0WYopeZbBX/BFLPs4RFIeecjAbsdpRKqngGw== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793695242; 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=bDh7g9zms6FDnCU67c/5Cz6dMG1h6R0xdoBcO4JJGRn8ZJ/qF//+pZIrnjVg7qX5DNfQ OaCVTBOGRfQi3VY7TW76Rv5DNm/tt5wQLJ5RIpjT8lB+xJ92pqz0XuqU/JiDU66NfF+wU PAk7g2o9BbGs5w145DuaBZn8dyurVquoNqvt+eVRmBb3W3yD0HphHXNqjfz5Hyha9fYWT ACu17vn/ju9iPm5BJQbHKxgDOnTFisi59139ydEChuw+gQ2z0vkgSM8C4ToyPs6nv/hQE YjTjjtyNMgg3xMtocTOs7e+xj/qZf/A63Z9lwNl10m5qJRhX6jr3pwi0/GmjOVvJRtg== 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=gbS9hVe2; 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 87CC7606C6BD; Tue, 3 Nov 2026 08:40:42 +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=gbS9hVe2 X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.161.54 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793695242; b=WoMpVlUgpuyDiylvaTlF5OJ9nBM3spqmU1CF/bV/PZyMPr0dA7Q4k4jghktHXEUsee11 KEd3JLrcLzs3S1fMm48ghlFRBNA8GUxgT9WJoFcMgZgGj8yZF9zcJSHHyOcxKpYRa/HHF t1a/K8FmV0GYSsGO7gb9qbQOwpl1/XZE2Vfyczn6/iv7Ua5HMVzjNzp0UzMdCNTUKjuUd mWDc3fZ0UPqpOR/ZoAVUT5u5Tbi5bn4GmN5eptIG5gLCGTPX6uAH/mKiwPubR6gJtfSjj D85JVllsoOdzeyyqflA5We1lgFQfMPrsSDQKBP/Swi16jInoT0M6DLbUn2aY6k2s7Ew== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793695242; 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=mBluyGjaqd88KHCDoyb+1Er1pZRXOboCI8uxzcphsfwfMXqnXHgzAMhT4y+d1DewIRuD cAomGf4xjiZHzBqkElErzaG27Cyf9AchUI/KfDEAdJP5jwb0/1ld6E8WWLkal6JhN76bf ArNCxPsDWMGqVA4Lc4SZn+9wUFfoC5dA2EQtXSCNqofTUpiUSjpCxzOlbjAI/HXs5d64u EkYk/AHA8BqC6o+QYuZRPzBbXvWUIVssxucq9P5lfq2OioMMVijuAoV7sjWb4h/rJPIF+ 2EOQLETqDBml5m579eLgYPSivuaSzlAuOCS8+DjdCd8rvpHqCVvDInfUhfjn3+XVtWA== 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=gbS9hVe2; arc=none smtp.remote-ip=209.85.161.54 Received: from mail-oo1-f54.google.com (mail-oo1-f54.google.com [209.85.161.54]) (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 9508D606D80F for ; Tue, 3 Nov 2026 08:40:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9508D606D80F 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-f54.google.com with SMTP id 006d021491bc7-6de1ca1b05aso2877474eaf.0 for ; Tue, 03 Nov 2026 00:40:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1793695240; x=1794300040; 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=gbS9hVe2VVgAfnAxPponCk4HfQrcqJwSAd97Q9vcGT8jYgF6r4riWcl/k4u2sLt1N+ 8LchkVapq5kt3KWvhcjMU5qEzdCvz0PkKjt2qSogUwDz2Eb02DJpUVzuMbYGOw9loiUz IWvkC5Ri4ejmwZl2bVbbM0c4Zxr53OAWIdIEBN/yBwNfXxunvkvMgP9e79pjZIqE99yl QcQ2qFq9n5mbjjDgT7Kydnvgqzxefuea+zw1hRqTYGcld5tLNNUdfgpudRWaDplUsEfA TIHhFj7z1TMYa6nxc+xOAcPZdam/HfmQpX3O3osirFQw9fDg+5QNO8XvRs/0fxbXQEQe vPng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793695240; x=1794300040; 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=fmPx7mdAnnG21WHITX//8UsZXHnXupoflg34Scke3pVg02dcCt06R3zRSx9cD2LBSP yllIp6OHyHQp7qZpmRxxpT/Yuy8VMGCr4tEruVcnNqq22jmAF9YeYygrtibQRDz91WR3 1LuXhROKcD1CfDMCk3S1OcXF7DCeLd+Xud9XSKyJUHx7XysTO2PadkzQy9LfoZ52i5nL sdV3KvOLtHvTPapuzCCGVUw+D8vymB/LOAtv6jlqcKNIXj65X2rg0xBDKm0fQ1dkt7KQ iozGj9/KeLY/pOCmEkXn22y7Vr+WV/HCv91zoAYNPy5uBs3FGC+NFDieqHB0IZe19Y/w w0dw== X-Forwarded-Encrypted: i=1; AKwUvBwBhudpB0J9E92R90ygt3NCGyfqcniM1Xp1MfkTr2KpZ6c0HyyCsxl4pbCLAz+0f2dxE6gId6cM9+e4qA==@lists.linux.dev X-Gm-Message-State: APuU4Z9ocXfqF9hOp4uF5jWxWHcMJuDNobReGodFvB7wL/VE3A4AQtLe yPtG2qc4kC/OTpGUrsgS9HmKIJStp5Nud8PnYnChsYAUG4kOgbWKRsD3 X-Gm-Gg: AYBFou1H2xIxvJqRKJ0EHlfK5PgPgvvLJslkLk5OkEnu9N6gB53+k68a4RsjqVAxfK3 aO2G9tMWaMYWxpFEb/n8Lau4CQV0nGD3btLg/KLNYSDswzs9Fur4elQHkI//KetQWjPIXWASl/f cj/hitLQbLP6mC2qdEMPT6jckCJHxUV4CG1ONoqo94CsdoQgwUmpxvw/bieuSj+Ouv5eERbGLtG QetsK195azO7a5lVMsvY9YFhcXBqPBo+EpRiV7tAKcSNsGp7x/tCBJP4MLWIb1QvLzf01n0P2ke B/aJyxrOcNVp3BI1lYjGI9yyhylRd7+Q4kHApRbsp+wY7A3/NvAxJoyOpdCbWZGeMrKKRkYjy0A ZegoC3l2+pU2kXyNStdbIiCwEHbiDi39A2biD/1b/QUsNkDXAHmLkp32Opv5KsBvZMZCSEYdbED 03lWGlN7X+d40bkxFYLAmldv0s8qkP2LuqLjYdNC+7R0ulub4zdOYzpjgOzVePSuV+J+k+x/kfI KUsCWa3G65lkzRCyizlRfVWHRSDOtuDgCEiyQag/w56RqsGtHvFu75vbG9wiuOBckuTkjKgcnO8 /GBRSZGNe98V6fl9zTzynyUYUFLKV013PocbLSnqKkhp5UzQ6f3WmC5/MsxLqNH+gJvcIPo4jtI sDuJmqOczR1bBBTl/36mjVnELI+ZTdB/1MKGOhPMYF/nLjco95HcPfmUZZku3w8Fwe4kw+PaWjU VlZtYM998ASq6WMJvkVB6UJE+/HzDHCZ+HRd+focE4P1yGeCuBCyReep6qhA76yB0eHiipg1Db X-Received: by 2002:a05:6820:221a:b0:702:778c:ec5c with SMTP id 006d021491bc7-714f29d36c6mr6837555eaf.53.1793695240569; Tue, 03 Nov 2026 00:40:40 -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 006d021491bc7-714f3081097sm10520397eaf.13.2026.11.03.00.40.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2026 00:40:40 -0800 (PST) From: James Hilliard Date: Tue, 03 Nov 2026 01:40:29 -0700 Subject: [PATCH v11 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: <20261103-h616-pwm-v8-v11-4-07abb59575c3@gmail.com> References: <20261103-h616-pwm-v8-v11-0-07abb59575c3@gmail.com> In-Reply-To: <20261103-h616-pwm-v8-v11-0-07abb59575c3@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 Tue Nov 3 08:40:30 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 3827 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mxe881.netcup.net (Postfix) with ESMTPS id 4BF2F1C421A for ; Tue, 3 Nov 2026 09:45:05 +0100 (CET) Authentication-Results: mxe881; dkim=pass header.d=gmail.com; spf=pass (sender IP is 172.232.135.74) smtp.mailfrom=linux-sunxi+bounces-27096-noreply=patchwork.local@lists.linux.dev smtp.helo=sto.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.232.135.74 as permitted sender) client-ip=172.232.135.74; envelope-from=linux-sunxi+bounces-27096-noreply=patchwork.local@lists.linux.dev; helo=sto.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id 90D53608AF0 for ; Tue, 3 Nov 2026 08:42:02 +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=1793695243; b=u9xk7BLgnHnjQK34F5qjL3DBRu1IJasuxmDDH1TVYbcoYt7k3tRwnMDIbwbKJrp+zwXv LR3yOzMHjJcTbkiDSLMhDZGhjLNOobwDZAY/VdhQXto5CEP4GFOOLSy5gEOQWrSa7Yqo3 7EmFerc/kFkz1hgRV+DlQhn+PgK3mWq2EHh9tjg+/BCF432kDSu7ACN7uoNsYxzvZH8H0 Bd4jtn8Kp60+eg62tYt3lfmpf6rkGnRauPNUltzc+stNg3fsA0usXPqRYeTaJkzYiwwUG volCAmO51W4cnDL3gPrT9rWhkH6MgNTiOB/8OS2R1/yXlyAGU03mWpjaQoh5qP6O05Q== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793695243; 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=EICMzlo7XYVR+Ds7QxMTcqWjg/oqwdZFpFEJj599RI8oGrN4RRsESRtJYWd3PLY3t0uW hl3s22fE8zuVEwtn4nmCC3+Ika6kODjzzSHFa2K9QI3AY2+ZW/dtd6lyF0+AvbnvvbHm5 VkdqKTeP1CPLRpr3kcI5LycHCYP+DP2YBnqBKljSg1GiMpwEimER0N17j9pzDL6muaUbK 05TFlRllzApmRLSdcJyWl0OjknBYwTe/tomqxCKaOAGS8floyK6SfM/im/rXUMOmqgZXr l9rPTdySqpDJELRXK8/682C9UVOnsKiMcxVP2alxSgTh3+RpciSS+XIRxY4pXQJMUKA== 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=Uvee5Hwk; 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 A3B27606A94E; Tue, 3 Nov 2026 08:40:43 +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=Uvee5Hwk X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.161.52 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793695243; b=LpJaFc+wzOYV5udOdE5I2smX/WIJn0mgNl7x9zIK4Tcyt3U5loaZZDAaWf6fDweFWLNO S7fV3LSXVkmXRLuxy0HppHKHe63NXgDXzw1DC4CIiqQ6PMoXVKaiVIO7EEg8u/ho0iLd6 RhkVqSKbAja7TwxDGMf8VIrhb6DxyqjR1fe1YINOfqKdcu41gFWfKeVau0kKP3q4c8vdq TGc9kaXVpPkOH/qmQ+m2TRn0hEKPNRExYFM5XZ+uJ+JfyTvS9/Mj559/nSsHGW6bEZk5M qITFgrHemm0uZY9GtFjNtbg5+IADMhEaO5xq9KKQpWgWLezCpjdJBFfFgOTyfq4ll/w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793695243; 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=GvWIg37wJc2frP63zU8gmJk04u217R03WPT7BHdzAODEOEoCsFM65DhbewPiowAkdiWD L9AtPmF2fvHyDPE2V/AhY/cGCdaFRmS/etfQs2Tjvqu9BptsHcdXfpFgEQW1PIbn6pD4a D3VxUqCTIGezZZn9mgcPA3vCPWeD2ngk920dKp7sZ37Z3yPAnzTE5YCg/eHIHp10em0d1 Afl4A8D+Gf2iplcTgffioEYz0QmClXL6tasoNIChnaah1Zm+qWeGrXwtH9WA32yqBmRh0 548LcLXngGpRE0jZYzl0H7qH/qpz/1RdF2Nk2qOT/yieY3O1Lj0oznkYFc2PYsDK6Ug== 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=Uvee5Hwk; arc=none smtp.remote-ip=209.85.161.52 Received: from mail-oo1-f52.google.com (mail-oo1-f52.google.com [209.85.161.52]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C6FE606D82A for ; Tue, 3 Nov 2026 08:40:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3C6FE606D82A 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-f52.google.com with SMTP id 006d021491bc7-6fe4372c5f3so2638846eaf.3 for ; Tue, 03 Nov 2026 00:40:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1793695242; x=1794300042; 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=Uvee5Hwkp8p6ltael57UpeWC5SdWRcUEQuu6daT9zDIHZwsLTR4CmQtxawmL/nUA+a IvsFRI1EHSrcNJ5XQuJx3EQTFeYsZSvG25J2mVIqqIOWtMRRSIiz4OpATGAmr9T+TvPu gIYwVCqC8yQKY/srI+CAneS9UWqgCT/6IZIAPPR1ngp3vu2rbYqn2/GAJ0N9Q8jeyBtJ bAKs5PvnsOfoRnt5Ulh+R1ZsKMn1A3o5wnq4pybIdqGeKFPusAa0VU4mfnx2lIkTpnuS xCmBpiE+rkA1n11vUhw7xYqk/N64UNrXPT48gn7HM20g1r/UbE3GKsLhJJevesyGkbmy gmZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793695242; x=1794300042; 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=MHFZeWmG8pQHPvwlXtXIFk1ZMujS281R9B1JTqiQtRwZMQxnMAtaW45t1aOa+mK6y3 wjkflOKyaXSWSwRfSZ0N5IyZ+OGSipvISN/ldTt1v39yAnjdo6K49/OJP13oGSKHZ1t5 O/J57q4Rc6gmcgkdhew3lPRUL5M4GCUsJgassSLeUSc6JTSXD78dx84kqtmocRmS3HOf zW4aO0izRJ+QUJIWIJ+TEHiwy1tZu2FPkwY13XM3nJ4FeDBLcArVR0n7bc3r1FC1rSzf xDgz+iYLXe/kc5GT2PrVmDDdi8JqkaidbI8FMvXV9IlY46YuU4bABpuwrvI1gMPCvMZ2 B8Zg== X-Forwarded-Encrypted: i=1; AKwUvBwZ/ewfdTiz566WOtLsrpyg824bC/iCZBG6Ru0c6ly+RKDAqr2lygMuEMFGbAryrlrvKcxCqRYYMIJ2EQ==@lists.linux.dev X-Gm-Message-State: APuU4Z8MwEgkj1qLzHoEeHu49Cf9sU2kBLAAK/qqr1XfFg2AfQf1CXbC FHiqUmzI9VcaTJRnAKGoDSyvBkOFrfCANlPUSGNu/clArY1IFAEZohCr X-Gm-Gg: AYBFou3OH2bBZZKwJzugWr4rrU/yjVb5BZUTGSkUp1vIgsT7nREXQr9kfhumtA8BrW3 aDInx0PSZKC7w1qMt2naBb75me9sU9nuxcr97HVZDCqmfMqCa91mkz22IrVbQU3spx/PI0CAnAo 3GakE6G7pJV/dgE0kVJsP/M+3Z+CDuQFPPrvlsdvgKDX0yXUEdb3k3lnrsNiyMrGTyvMuQjkalb 6D4HtyNEsYC6xHtOZXXOMdkb0+vsnQX7WvyX29XxHP60WpNyie27ku95+B1RcEaufFLK9dV6xKc oNspeHC6LZOu9SVbNa2FSTBujv+JAnz/JJnlHYO31Hm8a2xl9QTdqr1gUq8gvcd4B43IhAieE2n w16Rg0i2uWV1ZtxjZoqzGR3yOiwcyA209kr92CSaJbBV89q8hiU0Wpadwp8Vmb73X55iDfnSWF3 K1m3WFRAbt9uBpFHkV+UJPXz/Kkhl7uJdWgFTK9Jxlw88XLNV4F4feMo+tJLQyTio2uSNb2JC4Y 8d3xQYL3aLd7UIMAsOYL15CXYzRBXOo8jn1aF2MtNvkGFJhHj+96IRri8DThumE5OGXcB1U/2pg QCME/JPQ7dpmnjprpA213jwGZCvwbScr6raB5IdzkS55+In6dRZA0Fd5BGHBHG/LaGZqIX9W1gV OUkebpkfTj0G2mW0FoL0Gn06jyPJ3WdvcQoqeTCTCeChz39JNtlRHGeyXdMH+f8MIzZrjapVfJr 3Wag+yFjCUSeaCXnIizTy4JAR8fjVKFc+L9O1Z+8iRPYgf0w7clDQ= X-Received: by 2002:a05:6820:240b:b0:710:8db7:5f57 with SMTP id 006d021491bc7-714f2ab5e9amr5840218eaf.78.1793695242282; Tue, 03 Nov 2026 00:40:42 -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 006d021491bc7-714f3081097sm10520397eaf.13.2026.11.03.00.40.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2026 00:40:41 -0800 (PST) From: James Hilliard Date: Tue, 03 Nov 2026 01:40:30 -0700 Subject: [PATCH v11 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: <20261103-h616-pwm-v8-v11-5-07abb59575c3@gmail.com> References: <20261103-h616-pwm-v8-v11-0-07abb59575c3@gmail.com> In-Reply-To: <20261103-h616-pwm-v8-v11-0-07abb59575c3@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.232.135.74: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)[]; TAGGED_RCPT(0.00)[clk,dt]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc20261015:i=2]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; 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)[bootlin.com:email,sto.lore.kernel.org:helo,sto.lore.kernel.org:rdns]; FORGED_SENDER_MAILLIST(0.00)[]; FROM_HAS_DN(0.00)[]; TAGGED_FROM(0.00)[bounces-27096-noreply=patchwork.local]; ASN(0.00)[asn:63949, ipnet:172.232.128.0/19, country:SG]; FREEMAIL_FROM(0.00)[gmail.com]; R_SPF_ALLOW(0.00)[+ip4:172.232.135.74]; TO_DN_SOME(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[209.85.161.52:received,100.77.114.92: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:+]; FROM_NEQ_ENVFROM(0.00)[jameshilliard1@gmail.com,linux-sunxi@lists.linux.dev]; RECEIVED_SPAMHAUS_PBL(0.00)[174.29.1.49:received]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[172.232.135.74:from] X-Rspamd-Queue-Id: 4BF2F1C421A 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