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: 13565658 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D913EC48BF6 for ; Wed, 21 Feb 2024 15:12:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+RDdV0zivT5u0KflKYxVF3ROz1QRupoUOPXWHOGQ8Qo=; b=3uEbDk+cbBNyHW RyFRMtnxkqKOP051m/nXfir69pElsm4puS0Oh2ktLxm0dx5lP9cNBdBIiigZFkL4cQeRIg9otUO9F 4De4cL5oAHAZ5ooIL3/4p941YBxhcDrvKfjzQjYWq43csZPUvIQPi+oa0EACR47nwlnCAAWkUJm5c yPQGOXqbx/WwjHuGsr+0Fyfug2NqF1INBz/COSiD6iawts7Jn2AnQXO+P1X2+6n1UMXD0vtrx4RlF 0L0hdL/1dFlgUrk6exeL9Fj10rn4PqnwoUmTPuW8wrIZwErvT66miq52MckBw7yh7lYHKzIoxp4sC JvybDh0ovR2NjdJe44Bw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcoGb-00000001QRO-493F; Wed, 21 Feb 2024 15:12:13 +0000 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcoGY-00000001QPG-0pBX for linux-amlogic@lists.infradead.org; Wed, 21 Feb 2024 15:12:11 +0000 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-33d509c5706so2108462f8f.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=lists.infradead.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=LtTTB8H85cpryUMK3Uo0yZK/XD+FuuKxPm+Zwh2fShaemoXm/ZI6Uh0e5xlpwUtVHk XXMKD48nu9/l8gf9li0RMxA+Ud9+mbkUToSKibfeZrdJ92mJmYyTwN8f+ptyU506VsaU aAGEfThVnw98c+2P1bqS+XUF4Cw3xMLB01My41cxoaXXNwkmpsAI5t4swY2ZTuKN2Q91 f1bwdLKzGy78DP3cgDE0jOMPHswIQoXNbZ27OaOBQ/AZwMbLxpmtLIzF3rNIYoTG7TJJ KsR7NDjP9ebFdC+Ncj+TpMo3WWUyCqtXEyeVjwNKB+/43Ulmbioy5CWoYZ/z5iPuxzHe p+Ew== 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=Vu+oBraGe//cK8jW5KQzLFJRntoq5Mf1oW5esAapnkfmoLQtsi1Ws9snRdwCEd/0IS NyYwTucR2FirpR6KWuLaoOYTf+oo0IWlwVNNTJExmjdElU9vDTjOIVj/38Pjzmd+Tuwl q+3py2MnxJsjkZFfhdzFnY3/bQ2KyRMZyNWiZ+8s/VTOePy1kgZC59uAy2/eaMbYMgqn pWFJXyOw5w9YG2rkBVlTWE7dTMW2uaa4tG5y7rxiIy5yVOyrAccvJ+O5FtOF3rksa75e 9vX8d4qHNfMZVG8IlcIVh6KWhUE3tZ6HM62D39ZCMyWpGNPeseADDl8pNcl3Tq7MTy8H q8/w== X-Forwarded-Encrypted: i=1; AJvYcCWXF5fVQVwntYc9Ip3VDvP53hWtKfkLDNAUH92uk8gmhsQDWGkYaFM5VPTpqRjCa/oIsxMYmeBEoV4aV3qa4vxgKJxMyfVOy1cbpBn5nmaxp4s= X-Gm-Message-State: AOJu0YyC6xQ1pq6ssq40vUMOWjg80bs0nnO/EC+hOYhVLAlLuaE0L0Yf Zv3tNbF1C62ToOyfHgb7igiUkqPJpr+GdSrLJrxHXQBxELyaukpVXowIMRk7N9c= X-Google-Smtp-Source: AGHT+IGm2sH+dRd6PnvO83tJQa9VL0HTxHwYnaY9gzdZI6rvajQdxVWVttPfM8ui1jJcxYYhGdzRnQ== 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> MIME-Version: 1.0 X-Patchwork-Bot: notify X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240221_071210_259366_114CC85B X-CRM114-Status: GOOD ( 18.39 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org 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: 13565657 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EAC40C5478A for ; Wed, 21 Feb 2024 15:12:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hEVG1U0z7poMf5zRgofrnkY+oL4lelIaLTCpnEx5Xgg=; b=U8MCia1iOvoDRN BXOmMl1lfh1lmxmkAYgJhRhullYb7ch1iboUkXj9Hhfll6XmUKzp9szp3QzzgvFR+hphO+zGtOpGM fo1pnuKR6Dam6pjAdpD6s6nZ89eRl3EM9sQ8+RW5vf1E+o28TSquR32sFftlxc8ettQHfxLfqiFRb I0jMTu/0noZBPYYqBSmcEcT3FSqxjJ01zZYCXvxMEa24SYR7j1NtYL3ygE265c5I+pepM0w1Mn2Y6 4xE3mX3K9OPMYUZwZrNE31hJtyuJa80Lx+UkSfRfxJDCjs/2tBPu05MTaPYER/rkgdJFNcYh/IpEg ixzD38wa3dUGU3FtggdA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcoGd-00000001QRi-3VOP; Wed, 21 Feb 2024 15:12:15 +0000 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcoGZ-00000001QPJ-0b0z for linux-amlogic@lists.infradead.org; Wed, 21 Feb 2024 15:12:13 +0000 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-41272d42207so9088805e9.2 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=lists.infradead.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=ZWkO6iGvd3rC+hSlfWat+h2AJWmDS6GIws2pIh1ESmlCnd1ZE7c20/ZPgCWJvymz02 oFOiYDcC/fV2V269fH28NMUzdWzyuPX83hVXRLT5NC/KY/uYnCt8RFX6Wd8RkKZ5UL7r lmy3LVAvnSaAciaCT2A1EYx9QyCgtNg1hABA7fgwipya1FTGTXIVXOHyFaLfb8okp8dh 03rEEoINLzCRtTxXUPg12KvTY4wt3y2TDBw/c2ipW5C5zkwborQ8X6Ne/iF/2OlPiUVm 0mvtRhTJlwRAn6LMVyxSwn8Wg9Y+HjZM0mvhbZluRpvESzr3Q4fUr7zuY0fUW+4K9TiX G8NQ== 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=KtXS3nAe4P5rlnrXFEXQBrrzz0TEvyrrRVuIfdQTcjIXEi2Hl9KiEq465RPMBptit9 i+bLljo5OboQhicjycwi9RlqBbrcHWOdr5ThP5ea0Fc7zyKflSJbVBYujcZ6FQRsw79d W9++CAi/PtweAbU9P0H9rdG0UidSVSi2A24ZdxwqR3wIiOZKfd+sLRWtKpohLGiyr9EI /x00/l3PnPlKWuky341tk04FUdri51NvyX6tS9p19vDte7Hdd7BX58bmyeAB/ulLWBTv /tfonG4PyKAN3RzhC6wo01aHfKucLW0cVKoALakNsCZdsGx7R4Tc9kEghYCp6B13RHWc opqg== X-Forwarded-Encrypted: i=1; AJvYcCXfBGANHBJeWngtxam9cQUsfGv2Sa7OCcF7HcD/Nm483/DyQdWreS3DdUwF7sbFJaialDlehUMUcImpl6pguZ6JmxNl9H6BHJP4U0dulbjiyQs= X-Gm-Message-State: AOJu0YxoXWotd40sZa/xMSnykIIKUwh+Li5nfBCSZ0x/t4bA+dXI8xY0 MBOip8gLOqMyxVI5xROjBNwGw+i755IBCyjFc87zoIfayCB1L5Tos9i2QrT2FdY= X-Google-Smtp-Source: AGHT+IGnB/yDjeQ1zYwsD0gS9+46rlsbMLhYcTvmjGYKfgU3FPt5e+DC9MUyGg4jOgcKx3D6U0nZZA== 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> MIME-Version: 1.0 X-Patchwork-Bot: notify X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240221_071211_207623_7E8B43A8 X-CRM114-Status: GOOD ( 15.36 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org 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: 13565656 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 925E5C48BC3 for ; Wed, 21 Feb 2024 15:12:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wTsu6kKrKa7fx1Vj+86CZY+GcKk1uUFjLw2hxHEIVBo=; b=p6lbtVwSbmXrpx 6tYqh0P6k/p+sPhIBXjCkWBwm0PTAS66YybhAu/pdBdhi1dkUUWBRtXIBuLwoMHC5GAgBTGMi4Vxy 0suir4Y7/yDjEEeaC8iYnhblqI1qQrM/ENnabcvM+4xB2Ucpxc7P9ptf6ooSDy/F2a414Yf5drU4a irLeSEcoy+qDTF73Ea3fGBxTqtPSZdsFtKqnO+alvC1b4KZvH421aaTxxN91jisXjuXQyAmvdCkye eRNYUsdjEhJzS40ZoFZzbvCD2DYJzF25D84gmBO/kOaQ/FtVaia2a7f09sQtE8mw4fwVWTS+vVARK CsjCLQ0LM/CwFhmQez/A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcoGe-00000001QRm-0sjX; Wed, 21 Feb 2024 15:12:16 +0000 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcoGa-00000001QQ0-0k5Z for linux-amlogic@lists.infradead.org; Wed, 21 Feb 2024 15:12:13 +0000 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-41272d42207so9088995e9.2 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=lists.infradead.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=ehg7OiQUB39OZzoukgYV2IRJZiVhyGohObqcpbuVfpPVgLh7EFpaFHvZfu0YrWn2CZ NhHEJ/9FMDlr7Ensdr7qGnPcqkSWtUwAYlMRdK7lHnRO764Sq4S5XrNj350GRKmyosKa 13DJz3Aaz3EtMpQP7p/RqhpiBov4i5wsDj36AvKkp3xPTI9n6GZ2OE66ER0eu5y+s34/ RMrntgwajHATbMXQXmFbzyZZirZ8rWbQj3KPAl4xO5HBDru9yW0Vzf54cRlgrQwvwIuk Kfj5ZkVJYAQ4PDLABU/uMTDkm74fTzJJtT0WBksPuKhD++heeA/hEtTM8FI4tDe/yuy7 j9vg== 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=msCEDYc43N8w6jQwNEzDOTbI8nZxZGEbdHFPG5jLj6HyWNC3q19KnwxQgTJr0rPm8V UPvLllPxP7t1kj/G+DGjXK7YvLaSEIflBKl/U1USut+plMiuzd1dyq93KCP7fo/+hFPa YwQx1vV6Z1W4D252TPd6PoWyp64LxaF2m4VmfWwVkpJfx2iOz3oTf38JMYdZCKe1hZe5 tGWmnyZaGzBjYymtmcp5oQKp6iLnZLx34mwbz9PlEyziA5YarnglWOhAEawk8LAUsrSU HMqtMUcep52MEKZdmxmZXNAcHOmnGEiY2ZHPqYQPeuYeGq6ao2quY14IiFjIftMM5COH ce5w== X-Forwarded-Encrypted: i=1; AJvYcCU5eqJ5jTDU9Bu8w6CxVQh7mH8I0frXMtsDE0xkt42JDvydwm2s9DrK8Hfc+jbI6ddowlBgyRh+R0kpaNRgYT8oDAP+goesQ4aecr3SFSktBWU= X-Gm-Message-State: AOJu0Yxx6UqJsP24dBDJ2OFJzGc8rNDY5kUEIj+NxcTfRbecpwBUY6xL 4y/TnKXGA392rkWKCeuyL/TprxwdJOHeW243bGJzc7EHLpSqwnFLG3CNLDIEMys= X-Google-Smtp-Source: AGHT+IEeRU4MfkeafbqILY5kXFWxrlUsTufKp1YAOEcBHiEhDE6BI4BT3nlSA0stwDgg/5oJv/ywgw== 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> MIME-Version: 1.0 X-Patchwork-Bot: notify X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240221_071212_270411_E328586D X-CRM114-Status: GOOD ( 15.06 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org 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: 13565659 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2CFEBC5478B for ; Wed, 21 Feb 2024 15:12:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mX//zPR8a3W+U0O9lEHo6yqATp4i8UtU9cvd5Q+U7x8=; b=XAVQmVsC+YNKxR FIewEv4wVNWQuWJeCdyFVsOLQF8c913aoPchw8J+dcoheQJ+0lFSq/ydcUes015GAG1kaGETBBRw3 SczvKoT1TSM0kdJvyV6saxl8ng6FcCIlgZCXnUGzukfwiHpGJ1GUgwRTPOYoI6/4E34cg+RRL6s++ a9vK3Lo6YKmT6qdsw+/LCeW5nK2KH2wOp7jLJkKjGdyzAnI01ItpaI8uHrbLOJq3YNKEyJW/wIpFr /qYcwrWnUxuRYrIMEeOAa0HpKi9wbkzvXqEWfNMOaZujao8JfbanufnV+RRc7UrYpC99QTRUvreBT 0D+LDoFwWbH5GwOzsvgg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcoGe-00000001QSS-2cet; Wed, 21 Feb 2024 15:12:16 +0000 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcoGa-00000001QQF-3mhd for linux-amlogic@lists.infradead.org; Wed, 21 Feb 2024 15:12:14 +0000 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4127190ad83so11074295e9.0 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=lists.infradead.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=PfYwXGLuIYDtd67JxUgglrszSk0mqF/wnPnKOz7UsHQj6T190BOzBebq8JysJLbbBX XwioyVKt+XxfdLl1xf+WFeuNctRwGXJoBfqp++xT2EQA3FHMFptQayKIHKfU3N+fG+BV CP3wJfG2Lq6ISePYt3m8Epvs5FzwlXYVtlLhq9GIfnNmTFgvlo56freQCgf5gW2uak5M 3JIYAsABEl7kR9jBWxi+IfbPIdUp5/FtG6VOaEpF6O2lU0ZOBI6DZbqV9I2gH9voJ95x cCB/r4iCZy/jWiTdLp/wj/Z7H8JzG2qBB0mF8+gZ2wmJPl26hw1vVHAlaEL/OIfgCC4j DgiA== 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=icA3PCwNDyENdLERA590JmKKzliDdMUDNGMVZgENtvA6d+RjqZuaCBAooF1SNS3iVM 9kzxiic17rNR9FoRViF+og4B8/KuseuzzIsGutuWS0zu6/7QMTZzrR7rcpPassUnuoCQ HMMg1BDk3+qSA3szi63hurVvIhrvemBmLnzfgF9LgWC9IkzV01efz/36Prnr4zISBQ2t OK56QKPhtiqToNGv9V7Dz3xDZ/yUzQDpMg3HlpEEIqxYINNuuBiGjxbFSGL8SuAbQN3Y S0LZmiW+tDi2v3Tw41vu1e9QtlGzJxkWyg7Y+vOCx7uwzejpOZ0rl3PQ2Gfrru2a5i9m mlTg== X-Forwarded-Encrypted: i=1; AJvYcCXlkOvcvYimkcbrFA1khjBeyieEjC4u/T/EVG1ClOAif1cIECPCdTZvat/pzmTtO0QIzTgQcivRyFC/rSU67VZpTc6vMMpIiesIOON4mq1LwMw= X-Gm-Message-State: AOJu0YwuHhoKUhRXTKf2WVmTu78sH23EJ4S7c0vlwuSJ1jtcEXZPwfiu 2pVo2s92RWSlqiocldNPGlztX+87a2bb1+G8B2nfq8dDrHwIChDNktOhqG6fyYU= X-Google-Smtp-Source: AGHT+IFVjoug76sKUiM3bxfin/b2jHTnn52j44PDi+C4u8iMcyLosuU5W9Kxm6Kr7b2Go6+sQkLLSQ== 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> MIME-Version: 1.0 X-Patchwork-Bot: notify X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240221_071212_964666_A3EA258F X-CRM114-Status: GOOD ( 13.36 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org 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: 13565660 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0B609C48BEB for ; Wed, 21 Feb 2024 15:12:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=i7TiWSmPe4q3WzB0C9VN8MCl6nMKRyVfu5O2XY+RrJc=; b=svP/VbdTKEDOhU 5WbRbl0OBmmMVaN/KzWLQcKU99R6eww7pnLVFgSx5bqpu9dQlgdwHQm/YxotAhh4dC1VEGy2QknwC gGwRNwiSWc8gwP97NMxrqDp2a4rOMQKWT9shWCwcu00Ez1AAlXsDQppEJxoWgpGnpOAjByadKDtj7 JWcvNJltGurDjMTsF+dcUeHHYFqwv3bVm7PReUtkiGZSdUOuXZaHWFNoi6JkeDKClOIO6Lc568r5R PFpRfhUELYR5qKsY156h9JMtt1fJMJhYXb3iv6qC41CvDzwm6IBm1oJIUmI8R4wkGj70jEuuyCeXe 6dgqWyZVJh4IJYZms8nQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcoGf-00000001QSo-1Bgd; Wed, 21 Feb 2024 15:12:17 +0000 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcoGb-00000001QQi-1AlY for linux-amlogic@lists.infradead.org; Wed, 21 Feb 2024 15:12:14 +0000 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-41275f1b45aso5202085e9.3 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=lists.infradead.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=xmUQvDWtnage5+AVdv7wJ1MCpET9vieZNbEDiuSRceHkuI2OpHbcpo6D6i2myCN+lF cs8AGyB4vWJ+isPE5AnPp3Lo0iDGDh+qFeOW0O9vNDYRujxsCrTXWVw4yQNFHfU745qd KIwzUMHnomvkJ96RwA4TnXgIEJhGrIcQz3tEmxtSplc2qPnfpfhuK29K2oHRT7uYwHth yqOP/B47acse5h1rtTFolQbQzr+IJPqgTkU8tXR/Q9DIxneiTKnC6EC2uOofxJral5ia ITkax6KlwNQd3jUVyAMUZG+tl99lN8P+IGKIqY/okHeaiv5PFsfEkoeNRjfJJwntBr+b f8Ug== 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=owX7R4Fs6czBNOZATl7YIZBntkW6U6HEm0w1hp+NU+d1y5M3AZw9Zi4Hksm8u10duP QSnNuhrUcWEh3ZDI37Nng3jLI+kicYfqOPFyL42gF+gV3+h3zeVzTZ8V/icGPXKjnyAk JTUHIPvK9DUBFzGvRlvSi4hwmoM1KxSsdoF8bgeLs570Kl6/P2tlNJkqz7teAlcQrOHs 4bgeL9FFQx8/tjpx2vNQA++yfZIuasLTs9OR74SDoF46IL4bWWBe/vijr+dEvBYp2Tkc +32dunWXSq+0nvGx5ZTy4kYmqSXJ48T+sEHRLvbAQwtuQ9bKAgISuWq2GjKd4lkRCASn HP/g== X-Forwarded-Encrypted: i=1; AJvYcCUQ3XacTt+4iNQanzEUGrfQKtUh8w927V7sC0cTJkOQDsxrGckNgmt+wDt7F6ZadTdDpzt4NjMajIz+HkCjdKN433XU6pExvUTbLmxdTo8HE0M= X-Gm-Message-State: AOJu0Yxw1rUsQoyTYDvk67luUcxPrQb/7qgxPy5yGRgT5TN2jJNwiR46 xf5Bw31MwHgV4AKGXXPeFRhc3bwARgs7fSB9Fk49KBJgd1nLKNOnIsYUENH2lgY= X-Google-Smtp-Source: AGHT+IH0BIGfDcyECWrL+G0YcnBelN2VYVCfDRoTAKneFYafATVPl+LVdCn8hr7FrY+5box9ZQGFEg== 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> MIME-Version: 1.0 X-Patchwork-Bot: notify X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240221_071213_371726_F034DE6C X-CRM114-Status: GOOD ( 25.73 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org 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;