From patchwork Thu Sep 29 10:26:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?WGlubGVpIExlZSAo5p2O5piV56OKKQ==?= X-Patchwork-Id: 12993910 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 DD9D5C433F5 for ; Thu, 29 Sep 2022 10:28:49 +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: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:In-Reply-To:References: List-Owner; bh=BPslsm6iRMOxM/lp4rDfiEClQV1EXpwYQSlu0dUt5AA=; b=0Wu9W/Io2LCbKK BVG/2H++YEKumC3C/yAHXwlw7uqFYMIdubgsoEhDcmYMerlNbKsl5gJ+il59dYic+islMnpq5QVm2 Qko6L+xTdgVZtECUenJq0xHT77Xq99n8pEp9DZmKckCcc1ylYRpoy8FHiGDtl2HI9CQk2dqtc2MjA TVKUxjVkOgdbN6cA8e3UbA2g+dhAfepEaZJwGdQT/Iyi5J6QO/C5olhIb2Yw/HHUOaBIn5OBg2/yV zfZdMUrE2MzI2XuAwVAClv6inT6+oMMs7YK5BhhAKurLudtJuwM9ornV/CT491Lh77xJHq0fHii91 meJRYdL9ljZW0VdOCwTA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1odqlY-002Ptk-A1; Thu, 29 Sep 2022 10:27:40 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1odqlU-002Pra-A0; Thu, 29 Sep 2022 10:27:37 +0000 X-UUID: 2fc55fe00d4943c5a98b53ab834acbbe-20220929 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=wsUKJLhSYIayaF4qEX2zqgtQ6cU740L96TzpS6CtFpA=; b=GtzGu5MbFpFbH3TAwB+8CKet9xU29PZFBByKkseWDJ57UVIwY8tmZEvVx8xF9LSmcVQTtqLRNnArBdvfNoFS/KjwAZs0FJ4wSbIRRvbhdD0mkkzCUTiqMjefy3MWjhUQRl4geZkNkZEY0swrE1pn2uArtVyd2QrfOwFMgCvk03s=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.11,REQID:08a2a2e0-e16f-413f-a69b-58e85a47db85,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:95 X-CID-INFO: VERSION:1.1.11,REQID:08a2a2e0-e16f-413f-a69b-58e85a47db85,IP:0,URL :0,TC:0,Content:0,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTION :quarantine,TS:95 X-CID-META: VersionHash:39a5ff1,CLOUDID:8d1b7fa3-dc04-435c-b19b-71e131a5fc35,B ulkID:2209291827172ARFGNY5,BulkQuantity:1,Recheck:0,SF:38|28|17|19|48,TC:n il,Content:0,EDM:-3,IP:nil,URL:0,File:nil,Bulk:40,QS:nil,BEC:nil,COL:0 X-UUID: 2fc55fe00d4943c5a98b53ab834acbbe-20220929 Received: from mtkmbs13n1.mediatek.inc [(172.21.101.193)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 577905476; Thu, 29 Sep 2022 03:27:27 -0700 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by mtkmbs13n1.mediatek.inc (172.21.101.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Thu, 29 Sep 2022 18:26:51 +0800 Received: from mszsdaap41.gcn.mediatek.inc (10.16.6.141) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Thu, 29 Sep 2022 18:26:50 +0800 From: To: , , , CC: , , , , , xinlei lee Subject: [PATCH v3] pwm: mtk-disp: Fix the parameters calculated by the enabled flag of disp_pwm Date: Thu, 29 Sep 2022 18:26:49 +0800 Message-ID: <1664447209-19417-1-git-send-email-xinlei.lee@mediatek.com> X-Mailer: git-send-email 2.6.4 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220929_032736_372285_A76F4C22 X-CRM114-Status: GOOD ( 12.79 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: xinlei lee In the original mtk_disp_pwm_get_state() function, the result of reading con0 & BIT(0) is enabled as disp_pwm. In order to conform to the register table, we should use the disp_pwm base address as the enabled judgment. Fixes: 3f2b16734914 ("pwm: mtk-disp: Implement atomic API .get_state()") Signed-off-by: xinlei lee --- Base on the branch of Linux-next/master. change since v2: 1. Modify the code for readability. change since v1: 1. Modify the way to set disp_pwm enbale. --- --- drivers/pwm/pwm-mtk-disp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/pwm/pwm-mtk-disp.c b/drivers/pwm/pwm-mtk-disp.c index c605013e4114..3fbb4bae93a4 100644 --- a/drivers/pwm/pwm-mtk-disp.c +++ b/drivers/pwm/pwm-mtk-disp.c @@ -178,7 +178,7 @@ static void mtk_disp_pwm_get_state(struct pwm_chip *chip, { struct mtk_disp_pwm *mdp = to_mtk_disp_pwm(chip); u64 rate, period, high_width; - u32 clk_div, con0, con1; + u32 clk_div, pwm_en, con0, con1; int err; err = clk_prepare_enable(mdp->clk_main); @@ -197,7 +197,8 @@ static void mtk_disp_pwm_get_state(struct pwm_chip *chip, rate = clk_get_rate(mdp->clk_main); con0 = readl(mdp->base + mdp->data->con0); con1 = readl(mdp->base + mdp->data->con1); - state->enabled = !!(con0 & BIT(0)); + pwm_en = readl(mdp->base + DISP_PWM_EN); + state->enabled = !!(pwm_en & mdp->data->enable_mask); clk_div = FIELD_GET(PWM_CLKDIV_MASK, con0); period = FIELD_GET(PWM_PERIOD_MASK, con1); /*