From patchwork Thu Apr 20 12:35:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 85894 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp306812vqo; Thu, 20 Apr 2023 05:48:05 -0700 (PDT) X-Google-Smtp-Source: AKy350Y5W3CYEl0M1HrJRPYr9wv/BzztLASRbTHlIt8mg2aL84iUvtMzqt+3sClcaLsy7JM3+WjX X-Received: by 2002:a17:903:2285:b0:1a6:3737:750d with SMTP id b5-20020a170903228500b001a63737750dmr1541280plh.17.1681994885079; Thu, 20 Apr 2023 05:48:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681994885; cv=none; d=google.com; s=arc-20160816; b=LxpRiuRPDcEWoUsuVdyg5bPjTYBHeQqboLcoQMEt8BsTfotPNjwJuEph2kDDEOd0L7 nKRs4CvC2LQu/muclu1Re0EExbvFxDGhWNgNn1+aK2ZZ4IKXWULfAPxXriB0B6QHto6Q LQXv2O9RuwFTzu01qqsVSiJjrdDgX6naGXbLiRWfa75kHtswwR/NXMU6fTK982xgPHGq VxTsKztUnX4V14GBQXmqrFNbFgOcQgmbvmHa6pALBbiB9fVT+QKZXXCdVnF00MmNEzbG mSIOK7SEK031h5QsD82VRU0YdtxS+MuFQtk3p6G43wBji8Vv1b5ubtBlGZ7be55ofBdn S5iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:to:from:date; bh=3wd5FAKMHJkTahKY9JJtXlNmZfB6CgtiI8PYPgNN8KI=; b=ylNgqgtAuw7D0sAjQAnfrHRmSXXE2b7TOCZSwIvLoNbeol8ZvZIdGHuXqL28zTwevu Th+turm6RVD2bZvimEdXWOHs7UnxBnXtk+oeRt04tOkSGlS4YP9zJKlyCAgyi537KwJr QeAR0hnF57EhL8ti4rqtVAOCPHo3+mTCPqPQ6dIwxETR8sezXJwekpO0NyU55UTKAgxX jv4GmFOS+opVxnPyTp6oYTBBuZU+jBEDHDq+j9bz36R6WmJEtAKXzjz5KSrmAjiBBZLi VPhd5wOx9FM2pwZAsGm1kJSzhQu/0EwaWPBV+eZCbW90NvHEKzZMCM4Xt+zQilxU/cG8 xHEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y8-20020a655a08000000b0051b5fef546fsi1599151pgs.600.2023.04.20.05.47.50; Thu, 20 Apr 2023 05:48:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231311AbjDTMgM (ORCPT + 99 others); Thu, 20 Apr 2023 08:36:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231715AbjDTMgD (ORCPT ); Thu, 20 Apr 2023 08:36:03 -0400 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71B356EB9; Thu, 20 Apr 2023 05:35:58 -0700 (PDT) Received: from local by fudo.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1ppTW0-0005Vz-2e; Thu, 20 Apr 2023 14:35:56 +0200 Date: Thu, 20 Apr 2023 13:35:51 +0100 From: Daniel Golle To: devicetree@vger.kernel.org, linux-pwm@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Rob Herring , Krzysztof Kozlowski , Thierry Reding , Uwe =?iso-8859-1?q?Kleine-K=F6ni?= =?iso-8859-1?q?g?= , Matthias Brugger , AngeloGioacchino Del Regno , John Crispin Subject: [PATCH v2 1/2] dt-bindings: pwm: mediatek: Add mediatek,mt7981 compatible Message-ID: <2662c29ec80458852bb8c9041656bca46e2662dd.1681992038.git.daniel@makrotopia.org> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763699468463971271?= X-GMAIL-MSGID: =?utf-8?q?1763699468463971271?= Add compatible string for the PWM unit found of the MediaTek MT7981 SoC. This is in preparation to adding support in the pwm-mediatek.c driver. Signed-off-by: Daniel Golle Reviewed-by: AngeloGioacchino Del Regno Acked-by: Krzysztof Kozlowski --- No changes since v1. Documentation/devicetree/bindings/pwm/mediatek,mt2712-pwm.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/pwm/mediatek,mt2712-pwm.yaml b/Documentation/devicetree/bindings/pwm/mediatek,mt2712-pwm.yaml index 8e176ba7a525f..0fbe8a6469eb2 100644 --- a/Documentation/devicetree/bindings/pwm/mediatek,mt2712-pwm.yaml +++ b/Documentation/devicetree/bindings/pwm/mediatek,mt2712-pwm.yaml @@ -22,6 +22,7 @@ properties: - mediatek,mt7623-pwm - mediatek,mt7628-pwm - mediatek,mt7629-pwm + - mediatek,mt7981-pwm - mediatek,mt7986-pwm - mediatek,mt8183-pwm - mediatek,mt8365-pwm From patchwork Thu Apr 20 12:36:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 85892 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp301124vqo; Thu, 20 Apr 2023 05:38:07 -0700 (PDT) X-Google-Smtp-Source: AKy350bk2uskccLXfPnWCZPrBMbJ0kSHc8JJhHRPA0UTU87mVVM82b3fKExVsKqAgQWSqRxBQ/E9 X-Received: by 2002:a05:6a20:840b:b0:ee:c9a0:c738 with SMTP id c11-20020a056a20840b00b000eec9a0c738mr2352114pzd.24.1681994287578; Thu, 20 Apr 2023 05:38:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681994287; cv=none; d=google.com; s=arc-20160816; b=y1wBlHPnfT+C5BxKInguc41s8Chb1PcFGSJ4NQ1hdnEWtARC0CG1CN8d9p+WNPuCnG wpbjdwik08WrNSpKiPqtyhV/enioveOWqOHFiRKarY5Rz83WzwDtcOOyJl6Fkr9fSzs2 zRo+ShllA++ln8tL8z7B9uo/qaRka3jPWSPQwbZpfxp3/Eyx2mwrI6YaQcFyMzCBcVEm UKKVHznjqhIZvwq9FndyIA42KYohecMe0hCpQI25CDp48UJpjlGU6IGr1tI7VJch3hSc zILJfkYjY6lAWKAfKA11Ks4bU2OtQFqsfO7iYmllA9PmHHyhlZG3GjnD1QYng3ACZDSq pyug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:to:from:date; bh=eLpSYAegpxY7NjaX/YgkK/7RMMj/JIX8fCYP8Mrk+Dk=; b=rp4lcqzknfVtb6FjmRs/fS9FKSTH4yFU8K0QllkgdALUaxUnBwFY4QpzjQWrtSSrJ7 pNdBswPzIYZ7g6U7xN2ZUWTq8dzP4jrcNsjRe5WbRGg6H/nexJxGtlhw3dajxm/GTaHh e0R1XlHAvfk0eMVwGXARmSD8PZoqgZgBf3ARyHZYqacAyLqM39KhRwXsKksTRugE5kr8 u2XxRFOjNg12SUw0pGIC3u6iKRr7gqRieilGp7Hg/rAH9sBduzgsCUfB2AWgFB5qvqr4 88hWI1T7jU/YEDoQCcgYp3eDIyO7MuFrhMkqOctCXkjowo1C6ImKI05JoY43FnNuXxGY nNug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l190-20020a6388c7000000b0051b5e96024asi1572226pgd.591.2023.04.20.05.37.46; Thu, 20 Apr 2023 05:38:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229704AbjDTMgr (ORCPT + 99 others); Thu, 20 Apr 2023 08:36:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231394AbjDTMgp (ORCPT ); Thu, 20 Apr 2023 08:36:45 -0400 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42AC92D43; Thu, 20 Apr 2023 05:36:31 -0700 (PDT) Received: from local by fudo.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1ppTWX-0005XF-2E; Thu, 20 Apr 2023 14:36:29 +0200 Date: Thu, 20 Apr 2023 13:36:23 +0100 From: Daniel Golle To: linux-pwm@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Thierry Reding , Uwe =?iso-8859-1?q?Kleine-K=F6ni?= =?iso-8859-1?q?g?= , Matthias Brugger , AngeloGioacchino Del Regno , John Crispin Subject: [PATCH v2 2/2] pwm: mediatek: Add support for MT7981 Message-ID: <7c6e31c844642c199f223f4229a04a37b57a34f3.1681992038.git.daniel@makrotopia.org> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763698842027670849?= X-GMAIL-MSGID: =?utf-8?q?1763698842027670849?= The PWM unit on MT7981 uses different register offsets than previous MediaTek PWM units. Add support for these new offsets and add support for PWM on MT7981 which has 3 PWM channels, one of them is typically used for a temperature controlled fan. Signed-off-by: Daniel Golle Reviewed-by: AngeloGioacchino Del Regno --- Changes since v1: * use pointer to reg_offset instead of u8 reg_ver and if-else drivers/pwm/pwm-mediatek.c | 39 ++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/drivers/pwm/pwm-mediatek.c b/drivers/pwm/pwm-mediatek.c index 5b5eeaff35da6..7a51d210a8778 100644 --- a/drivers/pwm/pwm-mediatek.c +++ b/drivers/pwm/pwm-mediatek.c @@ -38,6 +38,7 @@ struct pwm_mediatek_of_data { unsigned int num_pwms; bool pwm45_fixup; bool has_ck_26m_sel; + const unsigned int *reg_offset; }; /** @@ -59,10 +60,14 @@ struct pwm_mediatek_chip { const struct pwm_mediatek_of_data *soc; }; -static const unsigned int pwm_mediatek_reg_offset[] = { +static const unsigned int mtk_pwm_reg_offset_v1[] = { 0x0010, 0x0050, 0x0090, 0x00d0, 0x0110, 0x0150, 0x0190, 0x0220 }; +static const unsigned int mtk_pwm_reg_offset_v2[] = { + 0x0080, 0x00c0, 0x0100, 0x0140, 0x0180, 0x01c0, 0x0200, 0x0240 +}; + static inline struct pwm_mediatek_chip * to_pwm_mediatek_chip(struct pwm_chip *chip) { @@ -111,7 +116,7 @@ static inline void pwm_mediatek_writel(struct pwm_mediatek_chip *chip, unsigned int num, unsigned int offset, u32 value) { - writel(value, chip->regs + pwm_mediatek_reg_offset[num] + offset); + writel(value, chip->regs + chip->soc->reg_offset[num] + offset); } static int pwm_mediatek_config(struct pwm_chip *chip, struct pwm_device *pwm, @@ -285,60 +290,77 @@ static const struct pwm_mediatek_of_data mt2712_pwm_data = { .num_pwms = 8, .pwm45_fixup = false, .has_ck_26m_sel = false, + .reg_offset = mtk_pwm_reg_offset_v1, }; static const struct pwm_mediatek_of_data mt6795_pwm_data = { .num_pwms = 7, .pwm45_fixup = false, .has_ck_26m_sel = false, + .reg_offset = mtk_pwm_reg_offset_v1, }; static const struct pwm_mediatek_of_data mt7622_pwm_data = { .num_pwms = 6, .pwm45_fixup = false, .has_ck_26m_sel = true, + .reg_offset = mtk_pwm_reg_offset_v1, }; static const struct pwm_mediatek_of_data mt7623_pwm_data = { .num_pwms = 5, .pwm45_fixup = true, .has_ck_26m_sel = false, + .reg_offset = mtk_pwm_reg_offset_v1, }; static const struct pwm_mediatek_of_data mt7628_pwm_data = { .num_pwms = 4, .pwm45_fixup = true, .has_ck_26m_sel = false, + .reg_offset = mtk_pwm_reg_offset_v1, }; static const struct pwm_mediatek_of_data mt7629_pwm_data = { .num_pwms = 1, .pwm45_fixup = false, .has_ck_26m_sel = false, + .reg_offset = mtk_pwm_reg_offset_v1, }; -static const struct pwm_mediatek_of_data mt8183_pwm_data = { - .num_pwms = 4, +static const struct pwm_mediatek_of_data mt7981_pwm_data = { + .num_pwms = 3, .pwm45_fixup = false, .has_ck_26m_sel = true, + .reg_offset = mtk_pwm_reg_offset_v2, }; -static const struct pwm_mediatek_of_data mt8365_pwm_data = { - .num_pwms = 3, +static const struct pwm_mediatek_of_data mt7986_pwm_data = { + .num_pwms = 2, .pwm45_fixup = false, .has_ck_26m_sel = true, + .reg_offset = mtk_pwm_reg_offset_v1, }; -static const struct pwm_mediatek_of_data mt7986_pwm_data = { - .num_pwms = 2, +static const struct pwm_mediatek_of_data mt8183_pwm_data = { + .num_pwms = 4, + .pwm45_fixup = false, + .has_ck_26m_sel = true, + .reg_offset = mtk_pwm_reg_offset_v1, +}; + +static const struct pwm_mediatek_of_data mt8365_pwm_data = { + .num_pwms = 3, .pwm45_fixup = false, .has_ck_26m_sel = true, + .reg_offset = mtk_pwm_reg_offset_v1, }; static const struct pwm_mediatek_of_data mt8516_pwm_data = { .num_pwms = 5, .pwm45_fixup = false, .has_ck_26m_sel = true, + .reg_offset = mtk_pwm_reg_offset_v1, }; static const struct of_device_id pwm_mediatek_of_match[] = { @@ -348,6 +370,7 @@ static const struct of_device_id pwm_mediatek_of_match[] = { { .compatible = "mediatek,mt7623-pwm", .data = &mt7623_pwm_data }, { .compatible = "mediatek,mt7628-pwm", .data = &mt7628_pwm_data }, { .compatible = "mediatek,mt7629-pwm", .data = &mt7629_pwm_data }, + { .compatible = "mediatek,mt7981-pwm", .data = &mt7981_pwm_data }, { .compatible = "mediatek,mt7986-pwm", .data = &mt7986_pwm_data }, { .compatible = "mediatek,mt8183-pwm", .data = &mt8183_pwm_data }, { .compatible = "mediatek,mt8365-pwm", .data = &mt8365_pwm_data },