Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4543584rwl; Mon, 3 Apr 2023 06:32:29 -0700 (PDT) X-Google-Smtp-Source: AKy350YRF4Eu0ME2sv/bYvDQiuy36oMa5BFOoAwrvedcW/365JBwdZ9r3J9CXMqEA4zJH7FlRJAU X-Received: by 2002:a17:906:da81:b0:947:895a:bd82 with SMTP id xh1-20020a170906da8100b00947895abd82mr15278031ejb.56.1680528749417; Mon, 03 Apr 2023 06:32:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680528749; cv=none; d=google.com; s=arc-20160816; b=nWuxrBeXiVakCJAxJop+K531RcMvdRykVLX6CQjxo7g4Q7bAC9Cl8b/9TzdqLYyJVy 8KPA7afMS4xt9gU+diTPLbnHedK6ekjDUNJeBRxVaZdp9cMfSKS4K+mV11rpspARfc0f Ra+zz4jYAKAnDb8p0jabZusf0+qHBNRb7xsk1xTduD6SMHIiL2d8FZWJJTV9dyLDpGhl ccVRkFQ5LWRmxKeKed3UzxjGboWCkoRce6PC+gudwMOJtBTbYhCnJJLoqd/Hxg9rB6Bv 6XEE9LyYsEgH3yJhHPdGZp/2iVC9U/ZgqfOrsgWPngCWf7Jz4UMYJhXVhYPJ1XcdefHe 1w4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CU2rECyEMJthSMbBkPmB4ARhBI3HTIqLuygygc/BZ9A=; b=QIhEQU9QTF2AeX19NYMB9GkTdGOlYTrrxDrVcD/eu1sLDDM86emoAZJffrB7xtKmAM C65T2kiq7uF0HHadj8lbXAhYdEfW6tbYoOaU7aCYwW7vNuILNCQXw1zfooFyFfCLfyF1 EQYuL2HrbtinnRkeGbf48UPu/UypkyawAXdp6TKShg0m4qjvng5XyNFfMZGB4P5DYLmT Rf5cCQ/kYYCRWzeXlsJQx1O+/6IPIeEzZSW/icimaOKWJvZWELOPe/Rb9lPO8vOrjzZA Ys7fjq8dns62O1KbcZ+FPyo7NVZiKw1cT0FCHSwLKshIlE9lCqlciB9QcXx6HfYsA3YV dTBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=gjxT+m2A; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nb1-20020a1709071c8100b00947c19f9f2bsi1185320ejc.354.2023.04.03.06.32.02; Mon, 03 Apr 2023 06:32:29 -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; dkim=pass header.i=@collabora.com header.s=mail header.b=gjxT+m2A; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232627AbjDCNbI (ORCPT + 99 others); Mon, 3 Apr 2023 09:31:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232415AbjDCNbE (ORCPT ); Mon, 3 Apr 2023 09:31:04 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 909364C0A; Mon, 3 Apr 2023 06:31:03 -0700 (PDT) Received: from IcarusMOD.eternityproject.eu (2-237-20-237.ip236.fastwebnet.it [2.237.20.237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madras.collabora.co.uk (Postfix) with ESMTPSA id 872C766003B1; Mon, 3 Apr 2023 14:31:01 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680528662; bh=++loIoPqiqnGGTd1ang00wuiYVquczoRpePLER4RqUU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gjxT+m2Ah+kCTuvUOY9tjJuw9qCUKk2oRh+J1/+uKe6XFO5z/queg1h3gngEPzyOY wxqfUN2/A39W6wzBb5SWgvsaLoeRPKMxWJ7nDKvOK1oFqb+E4nV53dRkMZkwzfoNid dFFpNnfY66PAQL5yyXSHyZ5H0lE0+TDSJf3/jKj9hWRyxdsvWWyGmInb4aBnupRUKB ZzQ8NPMOsx4exJNAZvtU4Btl6/OXW/S3DzSwbwaSMyKFjZSKvcbw2jdqe9wh4sriz2 eoM0krYhN2xgvyCbuFe0nnWSYMksXC0RQr9jPjbIHv6EV4nfiODYpBSBWDKGhF1/7u 5t3xEiguxRNPA== From: AngeloGioacchino Del Regno To: thierry.reding@gmail.com Cc: u.kleine-koenig@pengutronix.de, matthias.bgg@gmail.com, weiqing.kong@mediatek.com, jitao.shi@mediatek.com, linux-pwm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@collabora.com, wenst@chromium.org, AngeloGioacchino Del Regno , =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= Subject: [PATCH RESEND 1/2] pwm: mtk-disp: Disable shadow registers before setting backlight values Date: Mon, 3 Apr 2023 15:30:53 +0200 Message-Id: <20230403133054.319070-2-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230403133054.319070-1-angelogioacchino.delregno@collabora.com> References: <20230403133054.319070-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 If shadow registers usage is not desired, disable that before performing any write to CON0/1 registers in the .apply() callback, otherwise we may lose clkdiv or period/width updates. Fixes: cd4b45ac449a ("pwm: Add MediaTek MT2701 display PWM driver support") Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: NĂ­colas F. R. A. Prado Tested-by: NĂ­colas F. R. A. Prado --- drivers/pwm/pwm-mtk-disp.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/pwm/pwm-mtk-disp.c b/drivers/pwm/pwm-mtk-disp.c index 692a06121b28..82b430d881a2 100644 --- a/drivers/pwm/pwm-mtk-disp.c +++ b/drivers/pwm/pwm-mtk-disp.c @@ -138,6 +138,19 @@ static int mtk_disp_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, high_width = mul_u64_u64_div_u64(state->duty_cycle, rate, div); value = period | (high_width << PWM_HIGH_WIDTH_SHIFT); + if (mdp->data->bls_debug && !mdp->data->has_commit) { + /* + * For MT2701, disable double buffer before writing register + * and select manual mode and use PWM_PERIOD/PWM_HIGH_WIDTH. + */ + mtk_disp_pwm_update_bits(mdp, mdp->data->bls_debug, + mdp->data->bls_debug_mask, + mdp->data->bls_debug_mask); + mtk_disp_pwm_update_bits(mdp, mdp->data->con0, + mdp->data->con0_sel, + mdp->data->con0_sel); + } + mtk_disp_pwm_update_bits(mdp, mdp->data->con0, PWM_CLKDIV_MASK, clk_div << PWM_CLKDIV_SHIFT); @@ -152,17 +165,6 @@ static int mtk_disp_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, mtk_disp_pwm_update_bits(mdp, mdp->data->commit, mdp->data->commit_mask, 0x0); - } else { - /* - * For MT2701, disable double buffer before writing register - * and select manual mode and use PWM_PERIOD/PWM_HIGH_WIDTH. - */ - mtk_disp_pwm_update_bits(mdp, mdp->data->bls_debug, - mdp->data->bls_debug_mask, - mdp->data->bls_debug_mask); - mtk_disp_pwm_update_bits(mdp, mdp->data->con0, - mdp->data->con0_sel, - mdp->data->con0_sel); } mtk_disp_pwm_update_bits(mdp, DISP_PWM_EN, mdp->data->enable_mask, -- 2.39.0