From patchwork Wed Feb 21 15:11:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 204259 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1099104dyc; Wed, 21 Feb 2024 07:13:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU7/KuEsNZJLvBHotSG/vMH6Cj+acn5Ji381katqySINvPYLLuQ5bsl6mldhl4MWQlcA7U62aELybGvPFb3hgRHVtPHBA== X-Google-Smtp-Source: AGHT+IErgYA/TB32LSiyH5+UnAeoLm3+Gn/bsY3igCsGmeAEYnelkgMNBEiDSA21EzVGB+FOiCUf X-Received: by 2002:a17:903:2410:b0:1db:b302:604f with SMTP id e16-20020a170903241000b001dbb302604fmr17266599plo.41.1708528389490; Wed, 21 Feb 2024 07:13:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708528389; cv=pass; d=google.com; s=arc-20160816; b=rLXe/6+ZPf6pPSDUq1A31MeM8bcxpKxiK0txQUHa8e5X+YOhbR/9vKMfOBV7Xcr4K1 Fb8nelQDo+MY4kYQM49xO2J05SMDX0rnk+vcGJYU6MlIkzM1hFA+ecGhA05RonOCeIWG +COPCQ+B+Cz6kDzOBrZkuA47N+5NH/CXVqQPay/UdWVk3sE5qS5NV7L/vJyZ3UwIZR5Q gSawC1dnswtlSpFxUgDJ35Z7En50YQ7m9vOaYUEZOwHALN+x7f0qnLyiVMsB6horAHsk 1agPJDMvLF66pWijMztllBRxL2APuyVEQP9DAvrxmJFmczWdckqKnDqVSYMIBpAcCWIh KhiA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=eeb8+16ljSlEDFuGSbXwGh3NoqLN08Y0bLt4DyDQDqU=; fh=X50yPzwvQqJydZqYsdhEbtKyiJc+psh0A/Axa14kWGg=; b=wqpnIT5axio52aQ4N3gY4AN1PHPplvJqinhW08R/NOfc+Ux4pYHI1BCftvbkAzYnoj VScR05LUcsJYq91Pts6MX8fT5tCMHHALKCm9O7y8gHm1X5LLDt7UgGnFl8G1tFtlAoMX dhsCIarmFE2Jryz8SFXjS7+GJysUFLQPenAQ0lchMdiwZY0yRu3RHdfNWPQhoubKW5dh fQ986fl1N/RxI5gWFbHXnkuh6rIlhUgETZq/mVPBFwUJ3lCpvSPST+f9p4eA0LeCIwYj 3POmtAxdPfDro9aiIOcPxYhDn81Id2ekT+YKGcTWkXqxRbZe5QL/scVjw6Ofw117/Mwa tllg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=aR0TQKxh; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-74974-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74974-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id c17-20020a170902d49100b001dc0693e526si4492413plg.620.2024.02.21.07.13.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 07:13:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74974-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=aR0TQKxh; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-74974-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74974-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 8AD582850F9 for ; Wed, 21 Feb 2024 15:13:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E0BC5811FF; Wed, 21 Feb 2024 15:12:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="aR0TQKxh" Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0D7F27FBBF for ; Wed, 21 Feb 2024 15:12:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708528333; cv=none; b=oxSJe/Ou/vbnsE6T4bZRQVlYN7x1k4rpTL9XsJWJBnciWoJqG+X+2co5sefQlRqQ/67kZHPzqtQyBm9ZXUybmJnddqh/BlwScxVDTcd9cxrgg4EGPnsNDuiYCzW+CynRKGgLEAjQgzbef5wzhoqFMNmoJjUgBjoNV7y9VSZFtvc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708528333; c=relaxed/simple; bh=rM63ExwsBaOHEgSpHl10244P2WDwbbjheLQSfUe6erE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R7f4+eTmVPdAPwXJxGhAJ0r3d7Wj9sxiCBnEinAeFqvyGjqYxvJCy+v8nFi0btzIvSw8X6t9v1FZJe+JgXsrHF8zDQ7K5vD6YkgbZkEg/5kaPo4WU2a1yboub7ATZVHuUNvYSTIIZskGbyPcTW4wxNRzQA0NCTGdkEv6zummHLg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=aR0TQKxh; arc=none smtp.client-ip=209.85.221.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-33d509c5706so2108463f8f.2 for ; Wed, 21 Feb 2024 07:12:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1708528328; x=1709133128; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eeb8+16ljSlEDFuGSbXwGh3NoqLN08Y0bLt4DyDQDqU=; b=aR0TQKxhrjo775Ggr4P64dNue4qKA99NcsFEHeIxJAYWOYj7phgtVjpPPz2BSm+tE/ BnndTgkg7/le5M3ZxTzsVPje9+bL8mObswOiEImSei/rgrNEKI1CCab5f7J7njMqFrey 6W04cpXOS4GF8ahHgF/4FHivksvCHSZ7SIC+OYc+XCID/MfKp5F30b4xsfEBUw0I60Cb q0vlNHuuLCjBTCyPc1PB3vf4NNPq2lAKDgvKlFlYfl2pKZMVXamzuXD5gWrRaxeZGk+E 0d0lmTS+ZmRpa79MT+rl1sWUdXOcj9x1MCaQhnC/P+TGoVX/akrU9VpL4sI/YEMEa7G3 rAXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708528328; x=1709133128; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eeb8+16ljSlEDFuGSbXwGh3NoqLN08Y0bLt4DyDQDqU=; b=pjXRunmDT6mdZDzHOQjQKSR9YDrjAtVm+GT5bJtrmyX6ZwaJeg8pxSsx4fQ0Xm+OO+ lRNie46ztHm51+5Yar6wGvXxqBRh97Wl0vMI2MdkgN3Dq1C9trb8EIxEEkdkEkGhOmWf kYcejdCDHgAfi9Zs1SYwelb6Fh4AyhUKlJIYvv9/wtNb4maI44sL3BcNZPCR7a7tFhAV lJLYU9+Qmxe/Z9Gm1tBeL+k0f4pqO72GVNgw7CsJZH4XLd/KXNJ6AyuHCDTKPKJ8jthg v253ItYEr06DPP3DpCZKh0pSBnecD+apLw2bp6/BIOP6LZri31BBlm6y0JXKwx1jX4CS RBsA== X-Forwarded-Encrypted: i=1; AJvYcCW4811P5LoDZkG2Bra5vEu7sZ1vltr8Srq/C5fDbpKHwt8dZYThwCUJrfh+dUnV6rhAznzRCdm7dRWrYEptXNJwIkt5AKlx/UKMssg4 X-Gm-Message-State: AOJu0YymjmRycXUBO26UuQFHgAJsxVBQDFo1BvxmjrL37bL7e2Zxuxdy hloB4l6u0GmltxoEc6dZyP/23ZPXxbB2hhtjSLTOOQFJ/uZXlRw9C+ZANZeqfsQ= X-Received: by 2002:adf:ffc5:0:b0:33d:3f21:c38b with SMTP id x5-20020adfffc5000000b0033d3f21c38bmr6021597wrs.25.1708528328489; Wed, 21 Feb 2024 07:12:08 -0800 (PST) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:1b1a:d907:d735:9f9e]) by smtp.googlemail.com with ESMTPSA id bg22-20020a05600c3c9600b0040fc56712e8sm18725342wmb.17.2024.02.21.07.12.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 07:12:08 -0800 (PST) From: Jerome Brunet To: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Neil Armstrong , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Jerome Brunet , Kevin Hilman , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-pwm@vger.kernel.org, JunYi Zhao , Rob Herring Subject: [PATCH v5 1/5] dt-bindings: pwm: amlogic: fix s4 bindings Date: Wed, 21 Feb 2024 16:11:47 +0100 Message-ID: <20240221151154.26452-2-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240221151154.26452-1-jbrunet@baylibre.com> References: <20240221151154.26452-1-jbrunet@baylibre.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Bot: notify X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791521864256085692 X-GMAIL-MSGID: 1791521864256085692 s4 has been added to the compatible list while converting the Amlogic PWM binding documentation from txt to yaml. However, on the s4, the clock bindings have different meaning compared to the previous SoCs. On the previous SoCs the clock bindings used to describe which input the PWM channel multiplexer should pick among its possible parents. This is very much tied to the driver implementation, instead of describing the HW for what it is. When support for the Amlogic PWM was first added, how to deal with clocks through DT was not as clear as it nowadays. The Linux driver now ignores this DT setting, but still relies on the hard-coded list of clock sources. On the s4, the input multiplexer is gone. The clock bindings actually describe the clock as it exists, not a setting. The property has a different meaning, even if it is still 2 clocks and it would pass the check when support is actually added. Also the s4 cannot work if the clocks are not provided, so the property is no longer optional. Finally, for once it makes sense to see the input as being numbered somehow. No need to bother with clock-names on the s4 type of PWM. Fixes: 43a1c4ff3977 ("dt-bindings: pwm: Convert Amlogic Meson PWM binding") Reviewed-by: Rob Herring Signed-off-by: Jerome Brunet --- .../devicetree/bindings/pwm/pwm-amlogic.yaml | 67 ++++++++++++++++--- 1 file changed, 58 insertions(+), 9 deletions(-) diff --git a/Documentation/devicetree/bindings/pwm/pwm-amlogic.yaml b/Documentation/devicetree/bindings/pwm/pwm-amlogic.yaml index 527864a4d855..a1d382aacb82 100644 --- a/Documentation/devicetree/bindings/pwm/pwm-amlogic.yaml +++ b/Documentation/devicetree/bindings/pwm/pwm-amlogic.yaml @@ -9,9 +9,6 @@ title: Amlogic PWM maintainers: - Heiner Kallweit -allOf: - - $ref: pwm.yaml# - properties: compatible: oneOf: @@ -43,12 +40,8 @@ properties: maxItems: 2 clock-names: - oneOf: - - items: - - enum: [clkin0, clkin1] - - items: - - const: clkin0 - - const: clkin1 + minItems: 1 + maxItems: 2 "#pwm-cells": const: 3 @@ -57,6 +50,55 @@ required: - compatible - reg +allOf: + - $ref: pwm.yaml# + + - if: + properties: + compatible: + contains: + enum: + - amlogic,meson8-pwm + - amlogic,meson8b-pwm + - amlogic,meson-gxbb-pwm + - amlogic,meson-gxbb-ao-pwm + - amlogic,meson-axg-ee-pwm + - amlogic,meson-axg-ao-pwm + - amlogic,meson-g12a-ee-pwm + - amlogic,meson-g12a-ao-pwm-ab + - amlogic,meson-g12a-ao-pwm-cd + then: + # Historic bindings tied to the driver implementation + # The clocks provided here are meant to be matched with the input + # known (hard-coded) in the driver and used to select pwm clock + # source. Currently, the linux driver ignores this. + properties: + clock-names: + oneOf: + - items: + - enum: [clkin0, clkin1] + - items: + - const: clkin0 + - const: clkin1 + + # Newer IP block take a single input per channel, instead of 4 inputs + # for both channels + - if: + properties: + compatible: + contains: + enum: + - amlogic,meson-s4-pwm + then: + properties: + clocks: + items: + - description: input clock of PWM channel A + - description: input clock of PWM channel B + clock-names: false + required: + - clocks + additionalProperties: false examples: @@ -68,3 +110,10 @@ examples: clock-names = "clkin0", "clkin1"; #pwm-cells = <3>; }; + - | + pwm@1000 { + compatible = "amlogic,meson-s4-pwm"; + reg = <0x1000 0x10>; + clocks = <&pwm_src_a>, <&pwm_src_b>; + #pwm-cells = <3>; + }; From patchwork Wed Feb 21 15:11:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 204258 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1099033dyc; Wed, 21 Feb 2024 07:13:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW835emcAaTHVkuyvSywkUnxXrbMjkqPA8/L1Jvl9CevLSI9EG8ttAsKrAaUvTfXNXVZSNDTJWS8O1SmbX2vIT9shIdeg== X-Google-Smtp-Source: AGHT+IFXLk4XE2+IrPvUnIdCuEQJ2dpm3EVc8ejTzFFCeCLxbfhZR1BdDg+5J7dYBsfVlKF0/5eu X-Received: by 2002:a05:6214:c6e:b0:68f:2f35:d957 with SMTP id t14-20020a0562140c6e00b0068f2f35d957mr18011345qvj.16.1708528384081; Wed, 21 Feb 2024 07:13:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708528384; cv=pass; d=google.com; s=arc-20160816; b=nWevEkwPac6UO2j8So8bC2r06v8EGOsIYIsRRGaXUfcLt1oaQmNAJozqahAZCZOU7W bMM9z/gTdb76q2YoOgJn2ooc4P8dxzEcThfODocbB8tFVxlU3KT29GSXwyX3MgGWK9oB PvKXGPZJvIxIPuty6b/E2Lgazviuo0yW1OjaoW6osobH6YHVL4Xj53e2pccPzWhI4vdR pR6KYHNbQj1+7+XxE/qIdhGvKT1icUqUe8OJl2UXWXf7T0KSFB5b8XrKK4fK54IV6K08 rSCSC3KBX9seQxDF4KZsqhXVsx4igxWI2ya17SOXw1pPt/DcsIvGuB54MieQE6EqcC2W RcGQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=2dIMaRI4UL/ljzaiGORJNkCrZ9+yfYsQHx0oEU8j6rs=; fh=ThOulR+wNc58FauIqGkbNvt5HLfIG8b+qs1vY73SfVE=; b=XDDEPvfmapoewSd9vwPZDEmv7/qcLGl3lJE0smQEPf33jf5+giTJIEoSVUfqUiSD+m xUdE41n0DwIhrD5Z4fL7W+lus7bdHFhivOoeTENv0SEXkuyyoqfc1X+E99257SAncwUA ozToeMK22xRKJ8IYUZWGVMF6ocNe92CWdALPR3xiDAD0ug3P/JmzFgmBaE6JB3ic7W7q ZqOZScujXy6C/7j7QUlmn2m2jrfx64oCE16W1urzHJyqiaEr34YP8LNGOEeVzKOmKdlt GQvA9BvDvFshKK5McVWH+AotUBjcln4VNbVFV2H4mDpqGIHNmRvuESUbm+HI2PdcrD+E rR0w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=Aa2qlbtN; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-74973-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74973-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id jt4-20020a05621427e400b0068ce7bdfbebsi10575041qvb.594.2024.02.21.07.13.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 07:13:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74973-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=Aa2qlbtN; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-74973-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74973-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C97781C22769 for ; Wed, 21 Feb 2024 15:13:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8C728811EB; Wed, 21 Feb 2024 15:12:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="Aa2qlbtN" Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8E7580028 for ; Wed, 21 Feb 2024 15:12:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708528332; cv=none; b=DfduORCEJ7qCXga9nQGF8jututCBROpzSNu7sCKwa93t229hED6DSv1Nllz4Vgy6pKzWiSVqVE4GUCY9So+J8xOBFwtnntcv492Spzmbrk/khW1gY5qxk1VEKNd2I48NBgNra435l9BXe+GFkt5QgiAKN/ap++IDePpIfWqO7Lk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708528332; c=relaxed/simple; bh=H7u4y7uhZ2vjVcQPrDSO8zoTli1LbFPj5CyebiNWcN4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Vpmrszv3ZAz6D0He0hUOQhJQaw2BxLoqNokq2+PTO5qOdPQUv6l3SsGrEC2Xf3zSBieJge1yAPtOKZdF0v3SzS+3PUBaDn5qMRNTz8bNZC1opcB/4d2mGdh8eJF6999COtA4MEY9PBjcMvoC3lMc4LHfdb5J1k0h3Ji+dTho/xY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=Aa2qlbtN; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-4127706e48cso4533065e9.1 for ; Wed, 21 Feb 2024 07:12:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1708528329; x=1709133129; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2dIMaRI4UL/ljzaiGORJNkCrZ9+yfYsQHx0oEU8j6rs=; b=Aa2qlbtNIMn9LdUQwi+3lsDEnztdwLPFbQu7HtB2Z0SDzm1+oDzWJegjxZQzNZXoAx PEvmRmgNfHAXVg4E9Q6VYl1DPeb2Sqb184VlvcNVTMPOAG5JAaLVLWuTGPnC2mFJGEG5 AJ1nntou8MsRyIt27/0Z489RbMoy7Tdw6RC1tnhKP45NOo3d69fSTdAWGeNyunUd+RPK slnvAjO7peIJTx6i1keTxSiDA5FDrOm3JmRtd35WD+jBWgyC3bgYIrQ0nx5vKSywJjdt 4j80mxNtQfrV2wVX2v9UZmiD8MRYfcKJkxNfnA2RkPWx/GNgE/VBt1r3JulgKPBODUVi j4gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708528329; x=1709133129; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2dIMaRI4UL/ljzaiGORJNkCrZ9+yfYsQHx0oEU8j6rs=; b=C9D/6Jql1gdmgw5FQgtctZV9+LSWcWFNJdyp0Fz0MCWUOCQgcY//4N3gPHEOI+tDnU x0PLl5+OCz0okQwFo8f/LA4+9BWju5f2I3gLk8497GgglmZZF9LFPXi9PcrLBzURUEK6 k/p3FMd0my95lipKxPpYqAXI+Pm7YIBU3JoZiQN/x8AzkS4NAaNRHThxicnxXifWOcP9 MxV2V91ylIccan0cG9KInbQaf5GEyXlWBrFUEbVLC+TAIlYP8I2pAHzmTIhzl61w6WNo ir9ATaHcRCXlHv8nWv+fmCIxKbPHduHlN7NzOnZ0hx1144Ur+oBD9wdGrEITnXyqkKH5 ejww== X-Forwarded-Encrypted: i=1; AJvYcCVmlKT4E6d2ZS/XIQ91R3UIbK5QXRlXZ5tiaR3DTLx5KUetdi8UpTE/vnMcoXkSdhqmUwXGtPjtS8pB0qsNkfSKMrl6RoQtKX/mjAQP X-Gm-Message-State: AOJu0YzOlqwtty+4VUnXBYSU862UvSSJp8l813lzYMCPe19ZBDHzS9Tx iNwiC/yZlZgCopK6ERjLeHKvvolUvloNbOnZ9J9kNFNGYBx+5yTSt7axd/LXKCI= X-Received: by 2002:a05:600c:3515:b0:412:17dd:a227 with SMTP id h21-20020a05600c351500b0041217dda227mr13716851wmq.15.1708528329414; Wed, 21 Feb 2024 07:12:09 -0800 (PST) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:1b1a:d907:d735:9f9e]) by smtp.googlemail.com with ESMTPSA id bg22-20020a05600c3c9600b0040fc56712e8sm18725342wmb.17.2024.02.21.07.12.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 07:12:09 -0800 (PST) From: Jerome Brunet To: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Neil Armstrong , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Jerome Brunet , Kevin Hilman , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-pwm@vger.kernel.org, JunYi Zhao Subject: [PATCH v5 2/5] dt-bindings: pwm: amlogic: Add a new binding for meson8 pwm types Date: Wed, 21 Feb 2024 16:11:48 +0100 Message-ID: <20240221151154.26452-3-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240221151154.26452-1-jbrunet@baylibre.com> References: <20240221151154.26452-1-jbrunet@baylibre.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Bot: notify X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791521858908148446 X-GMAIL-MSGID: 1791521858908148446 The binding that is used up to now describe which input the PWM channel multiplexer should pick among its possible parents, which are hardcoded in the driver. This isn't a good binding in the sense that it should describe hardware but not usage. Add a new binding deprecating the old one that uses clocks in a better way and how clocks are usually used today: The list of clocks describe the inputs of the PWM block as they are realised in hardware. So deprecate the old bindings and introduce a compatible per SoC family to replace these. Signed-off-by: Jerome Brunet Reviewed-by: Rob Herring --- .../devicetree/bindings/pwm/pwm-amlogic.yaml | 50 +++++++++++++++++-- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/pwm/pwm-amlogic.yaml b/Documentation/devicetree/bindings/pwm/pwm-amlogic.yaml index a1d382aacb82..1d71d4f8f328 100644 --- a/Documentation/devicetree/bindings/pwm/pwm-amlogic.yaml +++ b/Documentation/devicetree/bindings/pwm/pwm-amlogic.yaml @@ -21,23 +21,36 @@ properties: - amlogic,meson-g12a-ee-pwm - amlogic,meson-g12a-ao-pwm-ab - amlogic,meson-g12a-ao-pwm-cd - - amlogic,meson-s4-pwm + deprecated: true - items: - const: amlogic,meson-gx-pwm - const: amlogic,meson-gxbb-pwm + deprecated: true - items: - const: amlogic,meson-gx-ao-pwm - const: amlogic,meson-gxbb-ao-pwm + deprecated: true - items: - const: amlogic,meson8-pwm - const: amlogic,meson8b-pwm + deprecated: true + - enum: + - amlogic,meson8-pwm-v2 + - amlogic,meson-s4-pwm + - items: + - enum: + - amlogic,meson8b-pwm-v2 + - amlogic,meson-gxbb-pwm-v2 + - amlogic,meson-axg-pwm-v2 + - amlogic,meson-g12-pwm-v2 + - const: amlogic,meson8-pwm-v2 reg: maxItems: 1 clocks: minItems: 1 - maxItems: 2 + maxItems: 4 clock-names: minItems: 1 @@ -68,11 +81,14 @@ allOf: - amlogic,meson-g12a-ao-pwm-ab - amlogic,meson-g12a-ao-pwm-cd then: - # Historic bindings tied to the driver implementation + # Obsolete historic bindings tied to the driver implementation # The clocks provided here are meant to be matched with the input # known (hard-coded) in the driver and used to select pwm clock # source. Currently, the linux driver ignores this. + # This is kept to maintain ABI backward compatibility. properties: + clocks: + maxItems: 2 clock-names: oneOf: - items: @@ -81,6 +97,27 @@ allOf: - const: clkin0 - const: clkin1 + # Newer binding where clock describe the actual clock inputs of the pwm + # block. These are necessary but some inputs may be grounded. + - if: + properties: + compatible: + contains: + enum: + - amlogic,meson8-pwm-v2 + then: + properties: + clocks: + minItems: 1 + items: + - description: input clock 0 of the pwm block + - description: input clock 1 of the pwm block + - description: input clock 2 of the pwm block + - description: input clock 3 of the pwm block + clock-names: false + required: + - clocks + # Newer IP block take a single input per channel, instead of 4 inputs # for both channels - if: @@ -110,6 +147,13 @@ examples: clock-names = "clkin0", "clkin1"; #pwm-cells = <3>; }; + - | + pwm@2000 { + compatible = "amlogic,meson8-pwm-v2"; + reg = <0x1000 0x10>; + clocks = <&xtal>, <0>, <&fdiv4>, <&fdiv5>; + #pwm-cells = <3>; + }; - | pwm@1000 { compatible = "amlogic,meson-s4-pwm"; From patchwork Wed Feb 21 15:11:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 204268 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1105522dyc; Wed, 21 Feb 2024 07:22:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX7UfaXRxRLvlMcOULQD9wPJy+94Et1ySGQ5qeG/NWnTfkQFJ1gtJ+5hV8OpscfnSaVKQwRJiZtxDIQ2uPArKbt3E0sqA== X-Google-Smtp-Source: AGHT+IFu/BM3YlRLK5k++OQAhTuF6JlXUv3dTBnGoL5b9RGydceq486g8kzn/BP3CBg17v8p/S5N X-Received: by 2002:a17:906:1982:b0:a3d:c9e9:c7e5 with SMTP id g2-20020a170906198200b00a3dc9e9c7e5mr11007889ejd.61.1708528963902; Wed, 21 Feb 2024 07:22:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708528963; cv=pass; d=google.com; s=arc-20160816; b=yjGSUkq3sT6XR3SWS1awAB6KmC6MCvbJ+dl3l+rdzhPzO/W8d01M6+eho4ilHRyRKz Ro0rHjOBZdbsum9jew3bXvR4BPGptLwU1iWqRq59emdmbnzQjQPeDIoUvmA3QemW8xc3 09aM0gVU0OHW39/8zEqjBBYcHML37henw46TzZ9yJmRl86rq8ZdKybDgaJe3J19LPH1H 5vKboFeNg7LhaMb4CqodwM09Gfh2ElCQWnunksaOKwLdUKv/OWPsRIaCB7fF+5jZRvqh /ach8MK2c6uajbO8LCZ5BeH6mtv25SiJ5FV6s19LAcaTLuL2sh9l/aze+hSO/hZbqVCt +Xhw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=phRSbqPQtjTITh3A7Rz+mg0BFNfzjESlEJDyy2/XwFI=; fh=ySbxMhWIePkpzGA4Qbb8UbDXs9M4WXRxU/JaMayycQk=; b=FSWD7j1DEdePlcgAvZeAeEoBAYyjrONPq1qyYv1WqLaFWszuttl0QDPhwCQxQ+fFU9 Oa83sRYhP3SX5UcX+h0QxOPK+PJVDyq63JlAxczcV7q3DPVL5pJm2YE1PrCzVvB1OsbO QQFOEZvk3U1ysp6HfnQE9ZNrXKMHuu5XdzPbnCxiAeeFuB+zbsMVy3BMYUYAYXQ1UgBd UpuVLvNo3YvE07ytiyW63hBrAt/20uX9lpkJyh71QNiyHYTuOP75+qR6hpl9kLdDlznD /WTDjzH7h8SS2IOPVWg+K+ijRuiN5iz9cK9eGcVPJtWawZjc75cw5ufk3IPXs1hWLhxC 6+dA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=yYxDp5ff; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-74975-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74975-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id b13-20020a170906194d00b00a3e654804ebsi3618915eje.692.2024.02.21.07.22.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 07:22:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74975-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=yYxDp5ff; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-74975-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74975-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 155761F25F16 for ; Wed, 21 Feb 2024 15:13:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8DD8681722; Wed, 21 Feb 2024 15:12:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="yYxDp5ff" Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 018EA80034 for ; Wed, 21 Feb 2024 15:12:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708528334; cv=none; b=YD2kFZOUH5vKojGY2Rw+szqkhdZdE3LYkWluKGbuWTBAUjSBgqK+mL3HIA9rYi4tZ3iXOsZBG1ZJ2yWuY8eT+wdEE8sq6NlI03xhfQ404izH/ReobWX/c49X+pkakAGHXNU44KS+2ZGzGK/U/cLxR8kjw1H94EhH7xrFaCq7KTY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708528334; c=relaxed/simple; bh=ruExk+3EVLbRjE0gQXVzGZ8dGRhGxHdE9Mjc5UHJiCU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pB+wH7cMzI9Zk6Ow5XlR91JWp1tY52zBKOs2k4BI+k5D8N9+uKJPJ2tLMXAn92XPC/EcvGdHLNpZRiYx0dsuPIzPTxgA26dS8PxoKH8Lku2jgFLyUz8ZQr20/iNecKfFx6hUuhjR5zp8Cp5ZpzfT6kAVUJCcSInBu5fVBIZ1w88= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=yYxDp5ff; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-4127706e48cso4533275e9.1 for ; Wed, 21 Feb 2024 07:12:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1708528330; x=1709133130; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=phRSbqPQtjTITh3A7Rz+mg0BFNfzjESlEJDyy2/XwFI=; b=yYxDp5ff4Hqy+ezd2nJg8Ja09q2SVxpsFpm3ZodcV1MCjrXQWiG/BlcmS+kXYinUd+ Lmf8yr3x32VnzuOPx+jRXwQ9d4GJ9AbgmTXDDz5E9AFBi9oFkPnS187i3mvR1zr25Fp+ hsDYetOHPEKQsVeNydjKnpfHG7QXdKHDl7WUrmKzUJxmXby1dORC/kkSfjexieoSw98T dD6oYOkG7xRgB+OnT4wMNgFLRmYqglw+8LxTj7fb+tOO1o2/oTAKeWxRnmSJ4DuZIreX xYdwV/2+JORlgXxg7Y6ES9oQc1T7s1Um2v2s57uIxgr6i/20xKNnwgPFqzMQ+74PJlsU kv1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708528330; x=1709133130; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=phRSbqPQtjTITh3A7Rz+mg0BFNfzjESlEJDyy2/XwFI=; b=oNeAVXtH5lR8/qN1P3dlXucNDl1L8H94+W8YyvBqGv426dR6TqV/j2AaPlFZChdWFx yAWfKO9HD0h2m2f1o4cs7C8BGUhT5nokUXcH0HOPdIxxFQaDoSsaTR6l0kK2eowKcOxJ xYvQQpGuZO2n5PiXsJXR3eOUbIE0uiDancWkuPk21QlpAq9DlN0LDEYYkj4nrRRUhGk/ H5hb+7jgX7VvXwP9KIyHPEX7gD3IO1zRMDRfAWqk7pMKNzTHi7EVXeqamgovgbkh0t/G om+se1I9BnFiPzOBfeKG9ElJ7wgSefgCSqxRCp4qkK7Tc9Z1vemaVFO5UMF7rfvLjKOJ jWTw== X-Forwarded-Encrypted: i=1; AJvYcCUhrborQEW3v9RHnT9tFIZ38XQFnTv20DUNiFWPwiDBTS8jjvb4PRpZVQwL1cNz/F/hdeW1eGIbHcJmrXgwCx90S87yl8wEgG7t++Wg X-Gm-Message-State: AOJu0YxwOtOi87J+521oQ8LXkG6UKPhYSxhSAz85QIVESBtV8sqn20K1 Qgp+qXWKLlDFp9+uLW9CZj1GP28J3Ka6kCJkLf/A5ZoXYg1jpj5Di1Y4wblBxxo= X-Received: by 2002:a05:600c:4747:b0:412:71af:8af5 with SMTP id w7-20020a05600c474700b0041271af8af5mr2971550wmo.16.1708528330296; Wed, 21 Feb 2024 07:12:10 -0800 (PST) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:1b1a:d907:d735:9f9e]) by smtp.googlemail.com with ESMTPSA id bg22-20020a05600c3c9600b0040fc56712e8sm18725342wmb.17.2024.02.21.07.12.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 07:12:09 -0800 (PST) From: Jerome Brunet To: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Neil Armstrong , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Jerome Brunet , Kevin Hilman , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-pwm@vger.kernel.org, JunYi Zhao Subject: [PATCH v5 3/5] pwm: meson: generalize 4 inputs clock on meson8 pwm type Date: Wed, 21 Feb 2024 16:11:49 +0100 Message-ID: <20240221151154.26452-4-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240221151154.26452-1-jbrunet@baylibre.com> References: <20240221151154.26452-1-jbrunet@baylibre.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Bot: notify X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791522466896082864 X-GMAIL-MSGID: 1791522466896082864 Meson8 pwm type always has 4 input clocks. Some inputs may be grounded, like in the AO domain of some SoCs. Drop the parent number parameter and make this is constant. This is also done to make the addition of generic meson8 compatible easier. Signed-off-by: Jerome Brunet --- drivers/pwm/pwm-meson.c | 53 +++++++++-------------------------------- 1 file changed, 11 insertions(+), 42 deletions(-) diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c index 40a5b64c26f5..a02fdbc61256 100644 --- a/drivers/pwm/pwm-meson.c +++ b/drivers/pwm/pwm-meson.c @@ -60,7 +60,7 @@ #define MISC_A_EN BIT(0) #define MESON_NUM_PWMS 2 -#define MESON_MAX_MUX_PARENTS 4 +#define MESON_NUM_MUX_PARENTS 4 static struct meson_pwm_channel_data { u8 reg_offset; @@ -97,8 +97,7 @@ struct meson_pwm_channel { }; struct meson_pwm_data { - const char * const *parent_names; - unsigned int num_parents; + const char *const parent_names[MESON_NUM_MUX_PARENTS]; }; struct meson_pwm { @@ -339,62 +338,32 @@ static const struct pwm_ops meson_pwm_ops = { .get_state = meson_pwm_get_state, }; -static const char * const pwm_meson8b_parent_names[] = { - "xtal", NULL, "fclk_div4", "fclk_div3" -}; - static const struct meson_pwm_data pwm_meson8b_data = { - .parent_names = pwm_meson8b_parent_names, - .num_parents = ARRAY_SIZE(pwm_meson8b_parent_names), + .parent_names = { "xtal", NULL, "fclk_div4", "fclk_div3" }, }; /* * Only the 2 first inputs of the GXBB AO PWMs are valid * The last 2 are grounded */ -static const char * const pwm_gxbb_ao_parent_names[] = { - "xtal", "clk81" -}; - static const struct meson_pwm_data pwm_gxbb_ao_data = { - .parent_names = pwm_gxbb_ao_parent_names, - .num_parents = ARRAY_SIZE(pwm_gxbb_ao_parent_names), -}; - -static const char * const pwm_axg_ee_parent_names[] = { - "xtal", "fclk_div5", "fclk_div4", "fclk_div3" + .parent_names = { "xtal", "clk81", NULL, NULL }, }; static const struct meson_pwm_data pwm_axg_ee_data = { - .parent_names = pwm_axg_ee_parent_names, - .num_parents = ARRAY_SIZE(pwm_axg_ee_parent_names), -}; - -static const char * const pwm_axg_ao_parent_names[] = { - "xtal", "axg_ao_clk81", "fclk_div4", "fclk_div5" + .parent_names = { "xtal", "fclk_div5", "fclk_div4", "fclk_div3" }, }; static const struct meson_pwm_data pwm_axg_ao_data = { - .parent_names = pwm_axg_ao_parent_names, - .num_parents = ARRAY_SIZE(pwm_axg_ao_parent_names), -}; - -static const char * const pwm_g12a_ao_ab_parent_names[] = { - "xtal", "g12a_ao_clk81", "fclk_div4", "fclk_div5" + .parent_names = { "xtal", "axg_ao_clk81", "fclk_div4", "fclk_div5" }, }; static const struct meson_pwm_data pwm_g12a_ao_ab_data = { - .parent_names = pwm_g12a_ao_ab_parent_names, - .num_parents = ARRAY_SIZE(pwm_g12a_ao_ab_parent_names), -}; - -static const char * const pwm_g12a_ao_cd_parent_names[] = { - "xtal", "g12a_ao_clk81", + .parent_names = { "xtal", "g12a_ao_clk81", "fclk_div4", "fclk_div5" }, }; static const struct meson_pwm_data pwm_g12a_ao_cd_data = { - .parent_names = pwm_g12a_ao_cd_parent_names, - .num_parents = ARRAY_SIZE(pwm_g12a_ao_cd_parent_names), + .parent_names = { "xtal", "g12a_ao_clk81", NULL, NULL }, }; static const struct of_device_id meson_pwm_matches[] = { @@ -437,13 +406,13 @@ MODULE_DEVICE_TABLE(of, meson_pwm_matches); static int meson_pwm_init_channels(struct pwm_chip *chip) { struct meson_pwm *meson = to_meson_pwm(chip); - struct clk_parent_data mux_parent_data[MESON_MAX_MUX_PARENTS] = {}; + struct clk_parent_data mux_parent_data[MESON_NUM_MUX_PARENTS] = {}; struct device *dev = pwmchip_parent(chip); unsigned int i; char name[255]; int err; - for (i = 0; i < meson->data->num_parents; i++) { + for (i = 0; i < MESON_NUM_MUX_PARENTS; i++) { mux_parent_data[i].index = -1; mux_parent_data[i].name = meson->data->parent_names[i]; } @@ -459,7 +428,7 @@ static int meson_pwm_init_channels(struct pwm_chip *chip) init.ops = &clk_mux_ops; init.flags = 0; init.parent_data = mux_parent_data; - init.num_parents = meson->data->num_parents; + init.num_parents = MESON_NUM_MUX_PARENTS; channel->mux.reg = meson->base + REG_MISC_AB; channel->mux.shift = From patchwork Wed Feb 21 15:11:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 204260 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1099486dyc; Wed, 21 Feb 2024 07:13:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUQazE/nsnFg5+CGSqZcGp4t/nfNoNCeTdm47R8Bf7hM0elxQRMcGxh44ywr8mWrCRPlQw5VAx0PZDQ+HB+MAL76k4ZrQ== X-Google-Smtp-Source: AGHT+IE0Q+lrSqJ8FkTZZJCeDLKmLoLNAoLaztdCSFZMayJsWk+FOmN0oFPSJH1XzwQ03LzmMFuk X-Received: by 2002:a05:622a:1b8d:b0:42e:2b6:8b52 with SMTP id bp13-20020a05622a1b8d00b0042e02b68b52mr12380919qtb.14.1708528426209; Wed, 21 Feb 2024 07:13:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708528426; cv=pass; d=google.com; s=arc-20160816; b=FZeyqOLbXrS/9YvZi8vZ/pvNdBO9QIqCV7AErjX2m9EL0GxeXzfiacEXYP4EzJpIVl DFNAURbRWbXEJ+LJtudeoGpVBpfFow2lHfw83O9orvVpTBB2gTIiU3wuT2dquvCKsHO7 VNEhsF3WuWrXjF5Gjkq6XcQRIlrSCBXrquxV16+F/j/NVKswfyzAArk0p6aPY0msIfTA xINs19waD3SToYSHWKhIl1KJnt7NP7XREn7XgdDtvg+uX8o29ahbmvyRUuxJqR57IWLr WfqJltD/o/9GhEqYtEzzGIaAGeNxz29ToiUr54QegRnKZTG6hCe9+cFqAJ9ZM10tduBf 67WQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=CDzlDzZQlyRp4tHPz70HDG/j2aqF8PDbUcJLYunNGlE=; fh=bJKI9Uc9cUZhiwFV0n5ZAoaVHri6U67pdrYIJbzBD3s=; b=TyxvzdJzJXei+3EEt/ZsFdmMAno08hXHLyzPCWKT0O/E9Dt6GD5Bru4hE2hIfDs6+U Fc2gBqxnc9aASYkgcNqAzpDI0R9OpB64yakB1Ozfjhi+W8MYNlvcDbfLC6xQn3xRrhcO fw9eCkB6DGmLfI7mwk/45cFKJ9Un8RHEJHHUP8SMbYogrvJzx4GLmE3GiT8R8LN6MZYj 8xd/eSuAQoqUaBSvA+k7nHopNKtAOv3sliAuGcUf8Gc88aRNU0MyhkpoJgHH2bbr/QIS XjGFELkllsj3NULXlQ/I248Oy6Yjn5m+vZ702NReMDR3VxMASSK3LIH7upx6AiksQs10 KjrQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=lOlMupNp; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-74977-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74977-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id f9-20020ac85d09000000b0042c41edcf47si11904801qtx.685.2024.02.21.07.13.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 07:13:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74977-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=lOlMupNp; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-74977-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74977-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id EC0EB1C23190 for ; Wed, 21 Feb 2024 15:13:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1F15081AAB; Wed, 21 Feb 2024 15:12:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="lOlMupNp" Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C4D978004C for ; Wed, 21 Feb 2024 15:12:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708528335; cv=none; b=Vj+cGH7ZUPw3dgIDpyodp+eKFU1BnWbtOfjzuA9Q9r3nPZl+3XjD1w+YAdyWvZLvEpYVLtlnGXKrtautk0cBvOTuZvsT0d9dUqsvH/or0kRtKljDwuCMHrjBjMqxCvkbmWpCBBaxrXrH+zOBVcpU3x20rLwLYeJ2IulrsdDN40s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708528335; c=relaxed/simple; bh=MdLPv7HkKaZwwZh1xD8A4aluOJVBj8VBH2qLxu3qrcM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IQOWzEB3hAC5ATYSVlix9RxB7HCFvS8GhZ479ECuBlPHpl7SZAhj24JqB7vLqk+oJllVG2cPUx90EH7TMl7NDJ0eKxhJPpUj2MHWEcAsb9t7NlC6yg6poa0b5L6YfbYYe3DMhm+Ej7iz7qEBolyli5raIF40HO4E2wSaGnGmxDo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=lOlMupNp; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-41275971886so5448855e9.3 for ; Wed, 21 Feb 2024 07:12:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1708528331; x=1709133131; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CDzlDzZQlyRp4tHPz70HDG/j2aqF8PDbUcJLYunNGlE=; b=lOlMupNpPEEBV1aMgYLpSCAOVrP+T9sekfvcpMz/FsTLddbeVskSLEVAB7kbpN33n8 LqP2OouNwG6pwemH5N18NaDevENBmn2CyQqwF0vWSo3uBTHlL9xC9yZQg07/lNJeQJg4 XwU4g/sgOR1nTZkGg4Q2kuXN929gFUN7q8yT8GIo+eJ3SyQNbFt37e1OHkK5aKECCAyf Fjiraf2ioKRncX1m4ERiyQNA5391SL/CzOZL970/+ZK7sFjMazx+F3JPDLBcDG/7bnU3 AeaMfR8k8cym3ufg7d4qC555rrcig9ACwNHCSq++EflUtLI1YFrMR6mmcL8e3jqUPo+P NgYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708528331; x=1709133131; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CDzlDzZQlyRp4tHPz70HDG/j2aqF8PDbUcJLYunNGlE=; b=L5obHWA+VVWYBBYQIeWdXjC8S7QE1CmoN6S2yIVvUn6veBJASMxcWtJt36Y79LuTfX UhLT3Kfhn3UuiYdoytZQm3TRZ4FlH4VKA2hJH/jH9YGjduwK9YD8JAXRe6USXOCD8vdg vWHKMndb/hSJNbbKFMfaqBqqu6v8C3tfeh1Ky7uYm4CUDyreH2dZn/qKTY3PV9RRG99/ lPsieIypUaTclam9jpjW1PrqPAYjlLtV/E1G4iJni9Qi9p14QEjbciRiSoiZlhQn1b/a Fs55pFVWB9wC27DELaz4452qrsyIRPehy/OEqN3b4e+Tu20PqSQ4cbMf4AP9Mx6GyYtJ NMrw== X-Forwarded-Encrypted: i=1; AJvYcCWxUP/WwmZK+/00Ci4kmQQi3Os/9GBSmSuyWlA5ppVoDA/2Vbss3LUUngZRKesb4sXFoUjJ/Wy1jHBC4ygD1jtpcfsW1W2B3VcGxHEj X-Gm-Message-State: AOJu0YwKUVcd7VJwUk5djN77PnsKoD+LUyoMd+f5TZ8RgRPQfezxqnzY /6pdbNc9SNRdHMJzLHt8C/ZCmL2G85xi2tsMntm3niXDNzSGkEr3Ip2Z8wh03qY= X-Received: by 2002:a05:600c:45d3:b0:410:2d72:63b3 with SMTP id s19-20020a05600c45d300b004102d7263b3mr13477876wmo.23.1708528331144; Wed, 21 Feb 2024 07:12:11 -0800 (PST) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:1b1a:d907:d735:9f9e]) by smtp.googlemail.com with ESMTPSA id bg22-20020a05600c3c9600b0040fc56712e8sm18725342wmb.17.2024.02.21.07.12.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 07:12:10 -0800 (PST) From: Jerome Brunet To: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Neil Armstrong , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Jerome Brunet , Kevin Hilman , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-pwm@vger.kernel.org, JunYi Zhao Subject: [PATCH v5 4/5] pwm: meson: don't carry internal clock elements around Date: Wed, 21 Feb 2024 16:11:50 +0100 Message-ID: <20240221151154.26452-5-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240221151154.26452-1-jbrunet@baylibre.com> References: <20240221151154.26452-1-jbrunet@baylibre.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Bot: notify X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791521903130189582 X-GMAIL-MSGID: 1791521903130189582 Pointers to the internal clock elements of the PWM are useless after probe. There is no need to carry this around in the device data. Rework the clock registration to let devres deal with it Signed-off-by: Jerome Brunet --- drivers/pwm/pwm-meson.c | 73 ++++++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 33 deletions(-) diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c index a02fdbc61256..fe61335d87d0 100644 --- a/drivers/pwm/pwm-meson.c +++ b/drivers/pwm/pwm-meson.c @@ -85,14 +85,17 @@ static struct meson_pwm_channel_data { } }; +struct meson8b_pwm_clocks { + struct clk_divider div; + struct clk_gate gate; + struct clk_mux mux; +}; + struct meson_pwm_channel { unsigned long rate; unsigned int hi; unsigned int lo; - struct clk_mux mux; - struct clk_divider div; - struct clk_gate gate; struct clk *clk; }; @@ -419,9 +422,14 @@ static int meson_pwm_init_channels(struct pwm_chip *chip) for (i = 0; i < chip->npwm; i++) { struct meson_pwm_channel *channel = &meson->channels[i]; - struct clk_parent_data div_parent = {}, gate_parent = {}; + struct clk_parent_data pdata = {}; + struct meson8b_pwm_clocks *clks; struct clk_init_data init = {}; + clks = devm_kzalloc(dev, sizeof(*clks), GFP_KERNEL); + if (!clks) + return -ENOMEM; + snprintf(name, sizeof(name), "%s#mux%u", dev_name(dev), i); init.name = name; @@ -430,16 +438,15 @@ static int meson_pwm_init_channels(struct pwm_chip *chip) init.parent_data = mux_parent_data; init.num_parents = MESON_NUM_MUX_PARENTS; - channel->mux.reg = meson->base + REG_MISC_AB; - channel->mux.shift = - meson_pwm_per_channel_data[i].clk_sel_shift; - channel->mux.mask = MISC_CLK_SEL_MASK; - channel->mux.flags = 0; - channel->mux.lock = &meson->lock; - channel->mux.table = NULL; - channel->mux.hw.init = &init; + clks->mux.reg = meson->base + REG_MISC_AB; + clks->mux.shift = meson_pwm_per_channel_data[i].clk_sel_shift; + clks->mux.mask = MISC_CLK_SEL_MASK; + clks->mux.flags = 0; + clks->mux.lock = &meson->lock; + clks->mux.table = NULL; + clks->mux.hw.init = &init; - err = devm_clk_hw_register(dev, &channel->mux.hw); + err = devm_clk_hw_register(dev, &clks->mux.hw); if (err) return dev_err_probe(dev, err, "failed to register %s\n", name); @@ -449,19 +456,19 @@ static int meson_pwm_init_channels(struct pwm_chip *chip) init.name = name; init.ops = &clk_divider_ops; init.flags = CLK_SET_RATE_PARENT; - div_parent.index = -1; - div_parent.hw = &channel->mux.hw; - init.parent_data = &div_parent; + pdata.index = -1; + pdata.hw = &clks->mux.hw; + init.parent_data = &pdata; init.num_parents = 1; - channel->div.reg = meson->base + REG_MISC_AB; - channel->div.shift = meson_pwm_per_channel_data[i].clk_div_shift; - channel->div.width = MISC_CLK_DIV_WIDTH; - channel->div.hw.init = &init; - channel->div.flags = 0; - channel->div.lock = &meson->lock; + clks->div.reg = meson->base + REG_MISC_AB; + clks->div.shift = meson_pwm_per_channel_data[i].clk_div_shift; + clks->div.width = MISC_CLK_DIV_WIDTH; + clks->div.hw.init = &init; + clks->div.flags = 0; + clks->div.lock = &meson->lock; - err = devm_clk_hw_register(dev, &channel->div.hw); + err = devm_clk_hw_register(dev, &clks->div.hw); if (err) return dev_err_probe(dev, err, "failed to register %s\n", name); @@ -471,22 +478,22 @@ static int meson_pwm_init_channels(struct pwm_chip *chip) init.name = name; init.ops = &clk_gate_ops; init.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED; - gate_parent.index = -1; - gate_parent.hw = &channel->div.hw; - init.parent_data = &gate_parent; + pdata.index = -1; + pdata.hw = &clks->div.hw; + init.parent_data = &pdata; init.num_parents = 1; - channel->gate.reg = meson->base + REG_MISC_AB; - channel->gate.bit_idx = meson_pwm_per_channel_data[i].clk_en_shift; - channel->gate.hw.init = &init; - channel->gate.flags = 0; - channel->gate.lock = &meson->lock; + clks->gate.reg = meson->base + REG_MISC_AB; + clks->gate.bit_idx = meson_pwm_per_channel_data[i].clk_en_shift; + clks->gate.hw.init = &init; + clks->gate.flags = 0; + clks->gate.lock = &meson->lock; - err = devm_clk_hw_register(dev, &channel->gate.hw); + err = devm_clk_hw_register(dev, &clks->gate.hw); if (err) return dev_err_probe(dev, err, "failed to register %s\n", name); - channel->clk = devm_clk_hw_get_clk(dev, &channel->gate.hw, NULL); + channel->clk = devm_clk_hw_get_clk(dev, &clks->gate.hw, NULL); if (IS_ERR(channel->clk)) return dev_err_probe(dev, PTR_ERR(channel->clk), "failed to register %s\n", name); From patchwork Wed Feb 21 15:11:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 204267 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1105451dyc; Wed, 21 Feb 2024 07:22:34 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWWzQbtwNtrhijlQpXH1gEWN/Okjj4bN4sPpNZbk9RPo3kr0zKSTqTzP1lq6ned4b+KGBQFwqV/9F1BIpV89fqWric32w== X-Google-Smtp-Source: AGHT+IH+A5kPoyP7b0LlABR0z3kQhFL3qe3bPfTtMlDKQs8N7lrHATcwmgE4rrXhaWb+Uo7kyHbR X-Received: by 2002:a05:6512:280b:b0:511:ab2a:4af1 with SMTP id cf11-20020a056512280b00b00511ab2a4af1mr20975728lfb.13.1708528954250; Wed, 21 Feb 2024 07:22:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708528954; cv=pass; d=google.com; s=arc-20160816; b=GV2nJAEBo7nhhMb2TNPOGiWqYVRGEjOjXpUG7dqKN84cRfKXHiAPi5FwG/praudzIF AyKNrqoML82gwNbCD9NjgZOXug7C3n0TANwyHo1tlhvMwqvqFTHgDPxRKt7TaoaJ3GT8 jZXgOUgxAlcHxxpQDJpRF85XmiKbtIX4xFViVtCgzxyyVLse/OoIamPiD8Fqbrg2mNan w78DCDnmtM20m+Ya7qlWqebte80Kvg811JonYh4SqWx3+eBOW/sY6m1IiETKgEvgM66v cP1b1EM1kGh4mywDPktiJT9Mo3dCKgPT4Q934q3wHAZXwzhE8Jb4UNMDitinMRi0+p/z Dkiw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=h74FeFDIe1tQA6L7395dqtw/ncyV+KOTJre2S3F/uNM=; fh=s8sPgH7QkKIIgqtcGks9cLrUc1i+fT8VA95JJCNWjdI=; b=xCWo0qxW6Azm3xDcsbrPMZySFiVdRHzxJDgUI/AsotdJtTFtUbsGtEvnl079MuxU4A eOIn94rIH9/qE+JeXhrN4dR3hcmGgl8Jw7b4L5RcTiVpdF5TlIBYZpF1IuAOcE1ytYvn PokCDTZft6SegOlxfybZP/a11fe0iMb+s1VGIfXdb7iuFpH+hY6f6Yta+Q9+xyw4EOa7 gORJLN3zOLJj4DccULCFxQr/wRYAJ62GvFBBAGkNFWHSZ+nbQ5NTEm81d/eM+moXylXn wSdOzaibMFUIPUb1y1G1eseF2xAOkWBm2QJIN8IyKsGITkAcObHL5w4ird59Q/Ayfq3I a0KQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=tKaSVONl; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-74978-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74978-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id d13-20020a170906040d00b00a3d42dafba0si4367255eja.1052.2024.02.21.07.22.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 07:22:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74978-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=tKaSVONl; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-74978-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74978-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 4FAAF1F263E6 for ; Wed, 21 Feb 2024 15:13:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A709081ABA; Wed, 21 Feb 2024 15:12:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="tKaSVONl" Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E7E680607 for ; Wed, 21 Feb 2024 15:12:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708528335; cv=none; b=ZSmiucLc/fTLwC/HBucoL/fmF6Slq8BQqf0OgSUf37ivDKx/ATogKSOkjWRkp6mOq7jPMqHD8/NWByhRVPOvp7fPFHpi7s24LVkwB9/BWjDOq79n9GR45O6sktqCJw3h6OTruNt8xqi0hR7UTU41m1mp3PBfsqBlGTTxEDYkXXI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708528335; c=relaxed/simple; bh=X3WasE9KQ70MN0Vh4+bqPFmp29TXlEdA2D5rh4MfY18=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CYGJs6oG+wQDBjQaoGKd+B4P8WOotGWBXDKvev+A+9igVrrzXAIFLrY+EAGhdP08Ycc9XyrpXV9fFIpbQwCDU2QAXbQfnuYxbR2Ce1lzpKclCSWqRIPFrL/7d/24vqr5uhhpLRdYsBpt62HduHXj0Xn1mQgH+Z6M3YjQiS1asAY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=tKaSVONl; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-41273f53c71so6615755e9.1 for ; Wed, 21 Feb 2024 07:12:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1708528332; x=1709133132; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=h74FeFDIe1tQA6L7395dqtw/ncyV+KOTJre2S3F/uNM=; b=tKaSVONlRDeqDMg/2j8gNpfxGRgVNQVENe7h+yFMpV9LvaVFxDj670ipTJzv9qqTR6 1k2EGFV9FDStfBCtpQLNqH4ixTdy+ZVynBcfjfiY3nQ9wgefcN8rl9HCyqmAMN+UxnkE dCc4OaeVg8HxveMvxO8pXiuEbq+UbSy0mxIcutb1jPAUqTXlkA+jYo0WNdrIdKryMrrV oiF3+eEWuDLJLo6XvFTAlRBnFg5jte/FDYsCJWOG5AeL9ABoy3zn/Zn9m0ROyzdpCvj2 +Imy6StO65B3UtN6JVWtiUPqPv8nLlRck3hOslnm4cXVLPr1jJxIFSg0kiDWa/749U0H fPeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708528332; x=1709133132; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=h74FeFDIe1tQA6L7395dqtw/ncyV+KOTJre2S3F/uNM=; b=rtywm/wGSQhr19lb4P/6EMrOgV1a3NAFXGDfJhCPbIZvRV7nqBAJnl/9tawiAXmuN1 Dv9zikTuvIfr6SmLtB0/RM/5izzQoVqobAKwq8T5UjWB45d6KPJoYPFM5sRQ7VJI6f2O /AH1wvMu/IdYrWzufMUGuF6O2k0g31fXq/P84ZgZcUtJoI8MswX3IRJBjJLAv59+RMRB rtVUFFsatau5fhq+qKQcC4HSiqjMWYSu6nOzfrz4SVPACf6XVC3YPHbGUY3Ap19d5/1J kGcFMv4biarHAHjPJh4wThA69rt2KQF8MdtrJ8+4DtYY/TzExWWekRX3XRyPOydoDil0 Z3hw== X-Forwarded-Encrypted: i=1; AJvYcCUFiepD4izGDf4gz09K2jgxSm52mikQ3E+tWhwIKbnnTpdJ+NnevN86Sb1CXME62bwQyKduwnsr7J6IzSu6U6bf8d9NkRZr6hLjcHtx X-Gm-Message-State: AOJu0YzPG2aM0mUfN9GxWwM4CrBugzFj79PRy4V4XKI6dpuEzLvWK5lN EdFJ87jbf2jHqQdtYQcDXXEuN4NeJjMX7AAyOkE1zIm0geJwaJfMCcRnN1ZSt7I= X-Received: by 2002:a05:600c:4f83:b0:411:ddc2:28b2 with SMTP id n3-20020a05600c4f8300b00411ddc228b2mr17153344wmq.27.1708528332062; Wed, 21 Feb 2024 07:12:12 -0800 (PST) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:1b1a:d907:d735:9f9e]) by smtp.googlemail.com with ESMTPSA id bg22-20020a05600c3c9600b0040fc56712e8sm18725342wmb.17.2024.02.21.07.12.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 07:12:11 -0800 (PST) From: Jerome Brunet To: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Neil Armstrong , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Jerome Brunet , Kevin Hilman , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-pwm@vger.kernel.org, JunYi Zhao Subject: [PATCH v5 5/5] pwm: meson: add generic compatible for meson8 to sm1 Date: Wed, 21 Feb 2024 16:11:51 +0100 Message-ID: <20240221151154.26452-6-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240221151154.26452-1-jbrunet@baylibre.com> References: <20240221151154.26452-1-jbrunet@baylibre.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Bot: notify X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791522456514295806 X-GMAIL-MSGID: 1791522456514295806 Introduce a new compatible support in the Amlogic PWM driver. The PWM HW is actually the same for all SoCs supported so far. A specific compatible is needed only because the clock sources of the PWMs are hard-coded in the driver. It is better to have the clock source described in DT but this changes the bindings so a new compatible must be introduced. When all supported platform have migrated to the new compatible, support for the legacy ones may be removed from the driver. The addition of this new compatible makes the old ones obsolete, as described in the DT documentation. Adding a callback to setup the clock will also make it easier to add support for the new PWM HW found in a1, s4, c3 and t7 SoC families. Signed-off-by: Jerome Brunet --- drivers/pwm/pwm-meson.c | 195 +++++++++++++++++++++++++--------------- 1 file changed, 121 insertions(+), 74 deletions(-) diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c index fe61335d87d0..90fc7b349723 100644 --- a/drivers/pwm/pwm-meson.c +++ b/drivers/pwm/pwm-meson.c @@ -101,6 +101,7 @@ struct meson_pwm_channel { struct meson_pwm_data { const char *const parent_names[MESON_NUM_MUX_PARENTS]; + int (*channels_init)(struct pwm_chip *chip); }; struct meson_pwm { @@ -341,86 +342,16 @@ static const struct pwm_ops meson_pwm_ops = { .get_state = meson_pwm_get_state, }; -static const struct meson_pwm_data pwm_meson8b_data = { - .parent_names = { "xtal", NULL, "fclk_div4", "fclk_div3" }, -}; - -/* - * Only the 2 first inputs of the GXBB AO PWMs are valid - * The last 2 are grounded - */ -static const struct meson_pwm_data pwm_gxbb_ao_data = { - .parent_names = { "xtal", "clk81", NULL, NULL }, -}; - -static const struct meson_pwm_data pwm_axg_ee_data = { - .parent_names = { "xtal", "fclk_div5", "fclk_div4", "fclk_div3" }, -}; - -static const struct meson_pwm_data pwm_axg_ao_data = { - .parent_names = { "xtal", "axg_ao_clk81", "fclk_div4", "fclk_div5" }, -}; - -static const struct meson_pwm_data pwm_g12a_ao_ab_data = { - .parent_names = { "xtal", "g12a_ao_clk81", "fclk_div4", "fclk_div5" }, -}; - -static const struct meson_pwm_data pwm_g12a_ao_cd_data = { - .parent_names = { "xtal", "g12a_ao_clk81", NULL, NULL }, -}; - -static const struct of_device_id meson_pwm_matches[] = { - { - .compatible = "amlogic,meson8b-pwm", - .data = &pwm_meson8b_data - }, - { - .compatible = "amlogic,meson-gxbb-pwm", - .data = &pwm_meson8b_data - }, - { - .compatible = "amlogic,meson-gxbb-ao-pwm", - .data = &pwm_gxbb_ao_data - }, - { - .compatible = "amlogic,meson-axg-ee-pwm", - .data = &pwm_axg_ee_data - }, - { - .compatible = "amlogic,meson-axg-ao-pwm", - .data = &pwm_axg_ao_data - }, - { - .compatible = "amlogic,meson-g12a-ee-pwm", - .data = &pwm_meson8b_data - }, - { - .compatible = "amlogic,meson-g12a-ao-pwm-ab", - .data = &pwm_g12a_ao_ab_data - }, - { - .compatible = "amlogic,meson-g12a-ao-pwm-cd", - .data = &pwm_g12a_ao_cd_data - }, - {}, -}; -MODULE_DEVICE_TABLE(of, meson_pwm_matches); - -static int meson_pwm_init_channels(struct pwm_chip *chip) +static int meson_pwm_init_clocks_meson8b(struct pwm_chip *chip, + struct clk_parent_data *mux_parent_data) { struct meson_pwm *meson = to_meson_pwm(chip); - struct clk_parent_data mux_parent_data[MESON_NUM_MUX_PARENTS] = {}; struct device *dev = pwmchip_parent(chip); unsigned int i; char name[255]; int err; - for (i = 0; i < MESON_NUM_MUX_PARENTS; i++) { - mux_parent_data[i].index = -1; - mux_parent_data[i].name = meson->data->parent_names[i]; - } - - for (i = 0; i < chip->npwm; i++) { + for (i = 0; i < MESON_NUM_PWMS; i++) { struct meson_pwm_channel *channel = &meson->channels[i]; struct clk_parent_data pdata = {}; struct meson8b_pwm_clocks *clks; @@ -502,6 +433,122 @@ static int meson_pwm_init_channels(struct pwm_chip *chip) return 0; } +static int meson_pwm_init_channels_meson8b_legacy(struct pwm_chip *chip) +{ + struct clk_parent_data mux_parent_data[MESON_NUM_MUX_PARENTS] = {}; + struct meson_pwm *meson = to_meson_pwm(chip); + int i; + + dev_warn_once(pwmchip_parent(chip), + "using obsolete compatible, please consider updating dt\n"); + + for (i = 0; i < MESON_NUM_MUX_PARENTS; i++) { + mux_parent_data[i].index = -1; + mux_parent_data[i].name = meson->data->parent_names[i]; + } + + return meson_pwm_init_clocks_meson8b(chip, mux_parent_data); +} + +static int meson_pwm_init_channels_meson8b_v2(struct pwm_chip *chip) +{ + struct clk_parent_data mux_parent_data[MESON_NUM_MUX_PARENTS] = {}; + int i; + + /* + * NOTE: Instead of relying on the hard coded names in the driver + * as the legacy version, this relies on DT to provide the list of + * clocks. + * For once, using input numbers actually makes more sense than names. + * Also DT requires clock-names to be explicitly ordered, so there is + * no point bothering with clock names in this case. + */ + for (i = 0; i < MESON_NUM_MUX_PARENTS; i++) + mux_parent_data[i].index = i; + + return meson_pwm_init_clocks_meson8b(chip, mux_parent_data); +} + +static const struct meson_pwm_data pwm_meson8b_data = { + .parent_names = { "xtal", NULL, "fclk_div4", "fclk_div3" }, + .channels_init = meson_pwm_init_channels_meson8b_legacy, +}; + +/* + * Only the 2 first inputs of the GXBB AO PWMs are valid + * The last 2 are grounded + */ +static const struct meson_pwm_data pwm_gxbb_ao_data = { + .parent_names = { "xtal", "clk81", NULL, NULL }, + .channels_init = meson_pwm_init_channels_meson8b_legacy, +}; + +static const struct meson_pwm_data pwm_axg_ee_data = { + .parent_names = { "xtal", "fclk_div5", "fclk_div4", "fclk_div3" }, + .channels_init = meson_pwm_init_channels_meson8b_legacy, +}; + +static const struct meson_pwm_data pwm_axg_ao_data = { + .parent_names = { "xtal", "axg_ao_clk81", "fclk_div4", "fclk_div5" }, + .channels_init = meson_pwm_init_channels_meson8b_legacy, +}; + +static const struct meson_pwm_data pwm_g12a_ao_ab_data = { + .parent_names = { "xtal", "g12a_ao_clk81", "fclk_div4", "fclk_div5" }, + .channels_init = meson_pwm_init_channels_meson8b_legacy, +}; + +static const struct meson_pwm_data pwm_g12a_ao_cd_data = { + .parent_names = { "xtal", "g12a_ao_clk81", NULL, NULL }, + .channels_init = meson_pwm_init_channels_meson8b_legacy, +}; + +static const struct meson_pwm_data pwm_meson8_v2_data = { + .channels_init = meson_pwm_init_channels_meson8b_v2, +}; + +static const struct of_device_id meson_pwm_matches[] = { + { + .compatible = "amlogic,meson8-pwm-v2", + .data = &pwm_meson8_v2_data + }, + /* The following compatibles are obsolete */ + { + .compatible = "amlogic,meson8b-pwm", + .data = &pwm_meson8b_data + }, + { + .compatible = "amlogic,meson-gxbb-pwm", + .data = &pwm_meson8b_data + }, + { + .compatible = "amlogic,meson-gxbb-ao-pwm", + .data = &pwm_gxbb_ao_data + }, + { + .compatible = "amlogic,meson-axg-ee-pwm", + .data = &pwm_axg_ee_data + }, + { + .compatible = "amlogic,meson-axg-ao-pwm", + .data = &pwm_axg_ao_data + }, + { + .compatible = "amlogic,meson-g12a-ee-pwm", + .data = &pwm_meson8b_data + }, + { + .compatible = "amlogic,meson-g12a-ao-pwm-ab", + .data = &pwm_g12a_ao_ab_data + }, + { + .compatible = "amlogic,meson-g12a-ao-pwm-cd", + .data = &pwm_g12a_ao_cd_data + }, + {}, +}; +MODULE_DEVICE_TABLE(of, meson_pwm_matches); + static int meson_pwm_probe(struct platform_device *pdev) { struct pwm_chip *chip; @@ -522,7 +569,7 @@ static int meson_pwm_probe(struct platform_device *pdev) meson->data = of_device_get_match_data(&pdev->dev); - err = meson_pwm_init_channels(chip); + err = meson->data->channels_init(chip); if (err < 0) return err;