From patchwork Mon Oct 24 20:52:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 10404 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp707032wru; Mon, 24 Oct 2022 16:43:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7UAxbqc9wys/uQCu62fiOz+PcAiV4iE0PRFNx1Iy6se+jrl6O8KD3Ueo3qT2yX6z1ps5hm X-Received: by 2002:a17:902:f54f:b0:186:a987:c733 with SMTP id h15-20020a170902f54f00b00186a987c733mr7610305plf.170.1666655006596; Mon, 24 Oct 2022 16:43:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666655006; cv=none; d=google.com; s=arc-20160816; b=vPuGolf3D63mr3qJajaKs7d305A0MEpY1UU0+rI/jqKvoU1jD7RikSGqzzJmuoZMqX IG2FbStKMHgANcC855gc8NAk/RAIhuVZvOjovhN+ZNvAWlWtlXABnPNjXj1v6T1tRl1C NiHm+VT0o2o29cqMuGXnF85njGXpE17k4zlswpxUsRF6Cxd6a4G+k3rEnv3haPOLZ0ez S0qek9rTdX6BGW4yJvdfXFplHH2q9SO17U2OVrTwpY4ZRxSb6B5DJoW+tavq3HPh60Jt cpoF/Fxgq/gOAIp7FSjk97qodndR0xbBC5vO/d5XqgvA5cGYj5NGRcUpu7Uer8+G0ChV m66Q== 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=avcN02YNvaxpZRdy8N6BP2+uTVrnwX31SrzsZGCAp0c=; b=GQcB8HFttUEhuRzYaSCXaXjxeQcjWJf6/kvvos3HlkyO6S4ZB0BfqcvQQMyDIE91/c dS19gAJWy5xtSpQH1cL0d9XBaLb9zUce4maoIb2X+cUCp3mWRB+9D1X6pCBv4Ss6wOdd Wlr2+kQ+TSd4/D2W4XMgRBdb2WPK9OQWM7GVGb01mrPz4xpV3pYtMvS3Q3tt9HKyHvOt gkK/7jlsZESWCBUJuJKmoDdArvF1mGRV2Eftx8XZy+UnPmzNUU7jcViES2vbZXKXizoq qstT9HZRUM+W7WBffDqCLhenqdJcvTw3E2TShxeWC20hUSkVES+rsKCm4cRPi6YHM+MX ZUHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=Bmyh2YOh; 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=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y10-20020a170902d64a00b0017f5ea2e8easi893226plh.357.2022.10.24.16.43.14; Mon, 24 Oct 2022 16:43:26 -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=@crapouillou.net header.s=mail header.b=Bmyh2YOh; 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=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231384AbiJXXdE (ORCPT + 99 others); Mon, 24 Oct 2022 19:33:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230405AbiJXXcZ (ORCPT ); Mon, 24 Oct 2022 19:32:25 -0400 Received: from aposti.net (aposti.net [89.234.176.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE040107A8C; Mon, 24 Oct 2022 14:53:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1666644740; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=avcN02YNvaxpZRdy8N6BP2+uTVrnwX31SrzsZGCAp0c=; b=Bmyh2YOhAjfg1GSy4ncnAj+0uagLOdl4JNbxAeyUKnYnHQsPI4htDWCoHQuYlBqCsqa7qz a1TvbaO2+3VP3gUDS4UmlqXfBkR5Tze5O7MPfwSi++v+pk0pHtro5AQCZftppjugDkmdxZ IqWyRrP0D7KxE5peHD5QjkDZvR7LGAI= From: Paul Cercueil To: Thierry Reding , =?utf-8?q?Uwe_Kleine-K=C3=B6n?= =?utf-8?q?ig?= Cc: od@opendingux.net, linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, Paul Cercueil , stable@vger.kernel.org Subject: [PATCH 1/5] pwm: jz4740: Fix pin level of disabled TCU2 channels, part 1 Date: Mon, 24 Oct 2022 21:52:09 +0100 Message-Id: <20221024205213.327001-2-paul@crapouillou.net> In-Reply-To: <20221024205213.327001-1-paul@crapouillou.net> References: <20221024205213.327001-1-paul@crapouillou.net> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS 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?1747614439856556216?= X-GMAIL-MSGID: =?utf-8?q?1747614439856556216?= The "duty > cycle" trick to force the pin level of a disabled TCU2 channel would only work when the channel had been enabled previously. Address this issue by enabling the PWM mode in jz4740_pwm_disable (I know, right) so that the "duty > cycle" trick works before disabling the PWM channel right after. This issue went unnoticed, as the PWM pins on the majority of the boards tested would default to the inactive level once the corresponding TCU clock was enabled, so the first call to jz4740_pwm_disable() would not actually change the pin levels. On the GCW Zero however, the PWM pin for the backlight (PWM1, which is a TCU2 channel) goes active as soon as the timer1 clock is enabled. Since the jz4740_pwm_disable() function did not work on channels not previously enabled, the backlight would shine at full brightness from the moment the backlight driver would probe, until the backlight driver tried to *enable* the PWM output. With this fix, the PWM pins will be forced inactive as soon as jz4740_pwm_apply() is called (and might be reconfigured to active if dictated by the pwm_state). This means that there is still a tiny time frame between the .request() and .apply() callbacks where the PWM pin might be active. Sadly, there is no way to fix this issue: it is impossible to write a PWM channel's registers if the corresponding clock is not enabled, and enabling the clock is what causes the PWM pin to go active. There is a workaround, though, which complements this fix: simply starting the backlight driver (or any PWM client driver) with a "init" pinctrl state that sets the pin as an inactive GPIO. Once the driver is probed and the pinctrl state switches to "default", the regular PWM pin configuration can be used as it will be properly driven. Fixes: c2693514a0a1 ("pwm: jz4740: Obtain regmap from parent node") Signed-off-by: Paul Cercueil Cc: stable@vger.kernel.org --- drivers/pwm/pwm-jz4740.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/pwm/pwm-jz4740.c b/drivers/pwm/pwm-jz4740.c index a5fdf97c0d2e..228eb104bf1e 100644 --- a/drivers/pwm/pwm-jz4740.c +++ b/drivers/pwm/pwm-jz4740.c @@ -102,11 +102,14 @@ static void jz4740_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) struct jz4740_pwm_chip *jz = to_jz4740(chip); /* - * Set duty > period. This trick allows the TCU channels in TCU2 mode to - * properly return to their init level. + * Set duty > period, then enable PWM mode and start the counter. + * This trick allows to force the inactive pin level for the TCU2 + * channels. */ regmap_write(jz->map, TCU_REG_TDHRc(pwm->hwpwm), 0xffff); regmap_write(jz->map, TCU_REG_TDFRc(pwm->hwpwm), 0x0); + regmap_set_bits(jz->map, TCU_REG_TCSRc(pwm->hwpwm), TCU_TCSR_PWM_EN); + regmap_write(jz->map, TCU_REG_TESR, BIT(pwm->hwpwm)); /* * Disable PWM output. From patchwork Mon Oct 24 20:52:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 10401 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp706884wru; Mon, 24 Oct 2022 16:42:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM60rXJirG5CHi9B3KagwL9EA7imUgSugy/AHF6M6vjoRth23XALYKB0B14jGXNa8Vwa5IJ7 X-Received: by 2002:a05:6a00:2446:b0:528:5f22:5b6f with SMTP id d6-20020a056a00244600b005285f225b6fmr36467848pfj.73.1666654977452; Mon, 24 Oct 2022 16:42:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666654977; cv=none; d=google.com; s=arc-20160816; b=bgJFsVH3oZNygstAEdPGsCQCc0dunDXhrMhf7HKyOOSDWj4Asi3JhAO3KgXtALqUM3 P3kQNv/wA28h31v/dvivwkWXfLdxr3ZYHv28gHvWLqyOZw75dODgAg5ptywnqEQer3w/ NojCE/9j18BADtc4HMHGf+T2llyap/BPMZ4TWgXlwjcqTS5fM7utXGMy0dSTMfLeTRIH drfLdzxRLVD4E3q/2QXmnHUxgLjEIrfJsdTW0THYlXgtR9whsD4g7GBwNLRS99NCNFbO 0Dmijehb+ZNTMPv2XDtYCdQKsWDmWEwJ0KXmv4dyK94eg+bnhafRJ8kODPvVaD57/7rO w8og== 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=fhJrUP+Njp6HsgAA/ZXoqJpzcRmNXj5pVHzoSisYMV4=; b=pOSMQytA7EevIeIHb6NTsLzNFv5CMSzf5kq0RtewMp/aRaftrMPCCBB/8VqbWBFBL1 esocudeL3eWYwyeuEPVTatobLiGnhtLbSUn405PJKvSF+gcZDxkl/lPPvNP59YlujtfQ rq1zGM5kl7UCXrZEE6Lux1TDJ9qfjLaJxiGjyqoDBNAQKNZQam1Xxl1FHHdtazK7Te9e 2bEpSROOjvTZy+tprNVgb06lbESdG2xQ9MoSQo9H59+qV9vlJExTzATYnxh80cPEbrV/ 9yXeGrM4HiB02dDFGh/h/H9dfDcnLten0r/0NLGxbRcNy3W4WB6dsArf1t9Fwf9fBsdC x39Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=X3ViSXvr; 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=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q3-20020a63cc43000000b0043c1481a835si943889pgi.267.2022.10.24.16.42.45; Mon, 24 Oct 2022 16:42:57 -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=@crapouillou.net header.s=mail header.b=X3ViSXvr; 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=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230158AbiJXXbp (ORCPT + 99 others); Mon, 24 Oct 2022 19:31:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231289AbiJXXbT (ORCPT ); Mon, 24 Oct 2022 19:31:19 -0400 Received: from aposti.net (aposti.net [89.234.176.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1916FE93F; Mon, 24 Oct 2022 14:52:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1666644741; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fhJrUP+Njp6HsgAA/ZXoqJpzcRmNXj5pVHzoSisYMV4=; b=X3ViSXvrs2DTVmBs1bS+Stp7Zsayi6JvxxstatJ+bXCQrKzYPB71+k+m1NyhYpgUfMubvJ 1dhLa4d241qWW23ro7HP2VPDT6HVtKb9MrcefjBfaOWEPUqVCF2iMd9coarbeAtB+h+dD8 8LWesp3qkUci38YVquaZ1QjiD5SP8lU= From: Paul Cercueil To: Thierry Reding , =?utf-8?q?Uwe_Kleine-K=C3=B6n?= =?utf-8?q?ig?= Cc: od@opendingux.net, linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, Paul Cercueil , stable@vger.kernel.org Subject: [PATCH 2/5] pwm: jz4740: Fix pin level of disabled TCU2 channels, part 2 Date: Mon, 24 Oct 2022 21:52:10 +0100 Message-Id: <20221024205213.327001-3-paul@crapouillou.net> In-Reply-To: <20221024205213.327001-1-paul@crapouillou.net> References: <20221024205213.327001-1-paul@crapouillou.net> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS 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?1747614409409498536?= X-GMAIL-MSGID: =?utf-8?q?1747614409409498536?= After commit a020f22a4ff5 ("pwm: jz4740: Make PWM start with the active part"), the trick to set duty > period to properly shut down TCU2 channels did not work anymore, because of the polarity inversion. Address this issue by restoring the proper polarity before disabling the channels. Fixes: a020f22a4ff5 ("pwm: jz4740: Make PWM start with the active part") Signed-off-by: Paul Cercueil Cc: stable@vger.kernel.org --- drivers/pwm/pwm-jz4740.c | 62 ++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 22 deletions(-) diff --git a/drivers/pwm/pwm-jz4740.c b/drivers/pwm/pwm-jz4740.c index 228eb104bf1e..65462a0052af 100644 --- a/drivers/pwm/pwm-jz4740.c +++ b/drivers/pwm/pwm-jz4740.c @@ -97,6 +97,19 @@ static int jz4740_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) return 0; } +static void jz4740_pwm_set_polarity(struct jz4740_pwm_chip *jz, + unsigned int hwpwm, + enum pwm_polarity polarity) +{ + unsigned int value = 0; + + if (polarity == PWM_POLARITY_INVERSED) + value = TCU_TCSR_PWM_INITL_HIGH; + + regmap_update_bits(jz->map, TCU_REG_TCSRc(hwpwm), + TCU_TCSR_PWM_INITL_HIGH, value); +} + static void jz4740_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) { struct jz4740_pwm_chip *jz = to_jz4740(chip); @@ -130,6 +143,7 @@ static int jz4740_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, unsigned long long tmp = 0xffffull * NSEC_PER_SEC; struct clk *clk = pwm_get_chip_data(pwm); unsigned long period, duty; + enum pwm_polarity polarity; long rate; int err; @@ -169,6 +183,9 @@ static int jz4740_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, if (duty >= period) duty = period - 1; + /* Restore regular polarity before disabling the channel. */ + jz4740_pwm_set_polarity(jz4740, pwm->hwpwm, state->polarity); + jz4740_pwm_disable(chip, pwm); err = clk_set_rate(clk, rate); @@ -190,29 +207,30 @@ static int jz4740_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, regmap_update_bits(jz4740->map, TCU_REG_TCSRc(pwm->hwpwm), TCU_TCSR_PWM_SD, TCU_TCSR_PWM_SD); - /* - * Set polarity. - * - * The PWM starts in inactive state until the internal timer reaches the - * duty value, then becomes active until the timer reaches the period - * value. In theory, we should then use (period - duty) as the real duty - * value, as a high duty value would otherwise result in the PWM pin - * being inactive most of the time. - * - * Here, we don't do that, and instead invert the polarity of the PWM - * when it is active. This trick makes the PWM start with its active - * state instead of its inactive state. - */ - if ((state->polarity == PWM_POLARITY_NORMAL) ^ state->enabled) - regmap_update_bits(jz4740->map, TCU_REG_TCSRc(pwm->hwpwm), - TCU_TCSR_PWM_INITL_HIGH, 0); - else - regmap_update_bits(jz4740->map, TCU_REG_TCSRc(pwm->hwpwm), - TCU_TCSR_PWM_INITL_HIGH, - TCU_TCSR_PWM_INITL_HIGH); - - if (state->enabled) + if (state->enabled) { + /* + * Set polarity. + * + * The PWM starts in inactive state until the internal timer + * reaches the duty value, then becomes active until the timer + * reaches the period value. In theory, we should then use + * (period - duty) as the real duty value, as a high duty value + * would otherwise result in the PWM pin being inactive most of + * the time. + * + * Here, we don't do that, and instead invert the polarity of + * the PWM when it is active. This trick makes the PWM start + * with its active state instead of its inactive state. + */ + if (state->polarity == PWM_POLARITY_NORMAL) + polarity = PWM_POLARITY_INVERSED; + else + polarity = PWM_POLARITY_NORMAL; + + jz4740_pwm_set_polarity(jz4740, pwm->hwpwm, polarity); + jz4740_pwm_enable(chip, pwm); + } return 0; } From patchwork Mon Oct 24 20:52:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 10403 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp706964wru; Mon, 24 Oct 2022 16:43:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7j6wxXvRec1lZS1R2gCjtOazX36S8Tif9CkW75LlFS2EA8dkb6UsaphnTiVPL0cqSoKEXR X-Received: by 2002:a17:902:a506:b0:186:8272:bb50 with SMTP id s6-20020a170902a50600b001868272bb50mr17936438plq.45.1666654991366; Mon, 24 Oct 2022 16:43:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666654991; cv=none; d=google.com; s=arc-20160816; b=iGlz6d1PsNgSN0wWsM3PTENDIcGUTZvz+efvjvRK0GzjVvdagjDMzHu257JUBnTSH/ R/LQ4gqEeEMmCWsqHSY0VmNyUkZdszkI5xKyDuB3flRJU1+ETZoH9k0oU08cvo8ISMY7 YTW0uRNU5t4sacxpFcLEwp3gJbsqm83hjlCXEQUoAlNjRfS4mqZiTIme6ktmQjSXLEaM 87Oo3wZcaAU+7KuPWbbpupTyXhvhT2f4qRWgTB8UraOEIM22uhuzn7gbN/YjgdJbeYaC CeHnta8QC/uL9KeZ+jLRkN+jwNwvb/xuRqVr5D5OKUl0P55ybeSI78E7KtkB3qs7nK5u CEXA== 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=xak1hhi2ZXgbcAJgD44C+AwcAkXWEuIXNRLIGjZ6/V8=; b=t8BS8b2y0/H0JfCKmx28Nmu7eXZKV7mavpdWrFwsx0mOWkQKJlQjY9O3e5B9qqkU3g ps+Y1akhd4pMqCFkBx3iwc7ah3X/RPnMJ0SlQqckYFmjeLkxNw2CeZDb+/MjZgBnsyYt +cdMgieWe6bt+CsbQ4f+6Spdo9WK19hnJ724q1GnV8UJLFbdxsl2ZHnuADv05oPCD9iN fxelwQgO10HZgxdVaIUGDcRKglTfeQdvQ0FSnPdpvDwTqOhM5WFBQJJEgMOZVJ5dIpjc PZin1wQMBOIm6eTutd83NKsZPXLdO6N30J1RF2McwiSYSPlSYzhFeOpgs/qh2PVjCFjh 7jEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=BT7X4ojF; 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=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a18-20020a170902ecd200b00178b7f3b89esi1296076plh.352.2022.10.24.16.42.59; Mon, 24 Oct 2022 16:43:11 -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=@crapouillou.net header.s=mail header.b=BT7X4ojF; 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=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231341AbiJXXbv (ORCPT + 99 others); Mon, 24 Oct 2022 19:31:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230308AbiJXXbc (ORCPT ); Mon, 24 Oct 2022 19:31:32 -0400 Received: from aposti.net (aposti.net [89.234.176.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8CC68E7AE; Mon, 24 Oct 2022 14:52:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1666644742; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xak1hhi2ZXgbcAJgD44C+AwcAkXWEuIXNRLIGjZ6/V8=; b=BT7X4ojFfsnA/z0K4xQ9xt0xKjIe+Y3K9UTqeUi22nPxgECWzdT8xZj6o3SR86Aj5EFyQp mA3k4mYgDmL/0+hpBIM1GI1AEz0Bt2Trq6p/O5Z9ArFc1cHm13OatrZtQKO7Vo7rwBTckm PGfl/xO9c5iQmmHRmm54wy2LFaSfIdw= From: Paul Cercueil To: Thierry Reding , =?utf-8?q?Uwe_Kleine-K=C3=B6n?= =?utf-8?q?ig?= Cc: od@opendingux.net, linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, Paul Cercueil Subject: [PATCH 3/5] pwm: jz4740: Force dependency on Device Tree Date: Mon, 24 Oct 2022 21:52:11 +0100 Message-Id: <20221024205213.327001-4-paul@crapouillou.net> In-Reply-To: <20221024205213.327001-1-paul@crapouillou.net> References: <20221024205213.327001-1-paul@crapouillou.net> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS 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?1747614423940631836?= X-GMAIL-MSGID: =?utf-8?q?1747614423940631836?= Ingenic SoCs all require CONFIG_OF, so there is no case where we want to use this driver without CONFIG_OF. Signed-off-by: Paul Cercueil Acked-by: Uwe Kleine-König --- drivers/pwm/Kconfig | 2 +- drivers/pwm/pwm-jz4740.c | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index 60d13a949bc5..1fe420a45f91 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig @@ -283,7 +283,7 @@ config PWM_IQS620A config PWM_JZ4740 tristate "Ingenic JZ47xx PWM support" depends on MIPS || COMPILE_TEST - depends on COMMON_CLK + depends on COMMON_CLK && OF select MFD_SYSCON help Generic PWM framework driver for Ingenic JZ47xx based diff --git a/drivers/pwm/pwm-jz4740.c b/drivers/pwm/pwm-jz4740.c index 65462a0052af..c0afc0c316a8 100644 --- a/drivers/pwm/pwm-jz4740.c +++ b/drivers/pwm/pwm-jz4740.c @@ -269,19 +269,18 @@ static int jz4740_pwm_probe(struct platform_device *pdev) return devm_pwmchip_add(dev, &jz4740->chip); } -static const struct soc_info __maybe_unused jz4740_soc_info = { +static const struct soc_info jz4740_soc_info = { .num_pwms = 8, }; -static const struct soc_info __maybe_unused jz4725b_soc_info = { +static const struct soc_info jz4725b_soc_info = { .num_pwms = 6, }; -static const struct soc_info __maybe_unused x1000_soc_info = { +static const struct soc_info x1000_soc_info = { .num_pwms = 5, }; -#ifdef CONFIG_OF static const struct of_device_id jz4740_pwm_dt_ids[] = { { .compatible = "ingenic,jz4740-pwm", .data = &jz4740_soc_info }, { .compatible = "ingenic,jz4725b-pwm", .data = &jz4725b_soc_info }, @@ -289,12 +288,11 @@ static const struct of_device_id jz4740_pwm_dt_ids[] = { {}, }; MODULE_DEVICE_TABLE(of, jz4740_pwm_dt_ids); -#endif static struct platform_driver jz4740_pwm_driver = { .driver = { .name = "jz4740-pwm", - .of_match_table = of_match_ptr(jz4740_pwm_dt_ids), + .of_match_table = jz4740_pwm_dt_ids, }, .probe = jz4740_pwm_probe, }; From patchwork Mon Oct 24 20:52:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 10399 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp706864wru; Mon, 24 Oct 2022 16:42:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7LLINNQbrdWmQI0yYegytjeKcFe1V1/HpYO0pR/bfA2Zyqxs3+tailpPlW10S4Da77KDBj X-Received: by 2002:a63:2d8:0:b0:46e:9da4:df67 with SMTP id 207-20020a6302d8000000b0046e9da4df67mr20836098pgc.176.1666654972881; Mon, 24 Oct 2022 16:42:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666654972; cv=none; d=google.com; s=arc-20160816; b=xKqrYDIF4iFdGjcBLfBHWgjUafSG0QW153g69q3svkCYgU2X2ssl7CrBIGBOPn2ChD fgnrBy31noUN70ylUq8QAaf+Rpy5YOAqbcP+/nHCJ5uI0J30XtWsdyFnd1/8+TgusWda pKiIvJB0TjjRWzwVdhASM5hWCEWHb/bk8gTkTTjXheDyto2ibLtpdq5MsvH59VPZLp68 4zl67TUAzWhyWX3bU/k5DcxabG8a1gNPV2pXXuesF24CSZu2wTBtK4V5DjBCfhPopWez 233WgPUQRVIUqyHKC2UK1DncrS3h/2A53H4YV7t70XZf+PceWgtbo7KOICuJCbO0ODla Ntjw== 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=Vr7lNDSbGtSjiNdf7yERkT0vvFH6fFGxF2sxGNjzC/g=; b=b/M1ZAmL2zy9OqQCxGp20beUAkbM3DoaJeRQSHTXj0dEqNMhwfRomt0d+JngS4ZiZ2 UAXjPv3xw6jeH9HQlHSDVUh7UO+L7x4DwHLDnQwb5GvsKtIRjTkap2g7m5DKqQZIrvJG tHjlAb7AYSTGEPLkv4i5U7lVHX0VeVyDRVWEts//Q7136CHcoapdIwuMRaXOrFRdqSS+ mb9bgZregIwFwW33Tuxm36e/EpLpaciv2C5GEA0kHb/+BAdbBZEfAIYzSH49ql/aK/mF 2fsGgC9hJfPrxL1vdhHF1QkFPkHk/L784uxFdGBDeK4rAb3xcQUohkKvekVwei9HLoF4 IOcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=B2abmIY2; 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=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 203-20020a6305d4000000b004525a153e80si928022pgf.445.2022.10.24.16.42.39; Mon, 24 Oct 2022 16:42:52 -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=@crapouillou.net header.s=mail header.b=B2abmIY2; 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=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229968AbiJXXbW (ORCPT + 99 others); Mon, 24 Oct 2022 19:31:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230341AbiJXXaz (ORCPT ); Mon, 24 Oct 2022 19:30:55 -0400 Received: from aposti.net (aposti.net [89.234.176.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC676147D03; Mon, 24 Oct 2022 14:51:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1666644742; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Vr7lNDSbGtSjiNdf7yERkT0vvFH6fFGxF2sxGNjzC/g=; b=B2abmIY22GUeSjPRTWzhdM/9vbX7QdDB9z6ewKCRCOvLaLS1P/CDnidjVpsxGAFWB9KLs7 JPgBNcc5ZPDngtVnNwFl8YpWba+3xfg8Dz3jVqpmCK2cv1bSPBhPG8z3kixHrN2vdJ4vc9 jZ+a11nSsRwYNTUVc3yMBQxX/K2NLcQ= From: Paul Cercueil To: Thierry Reding , =?utf-8?q?Uwe_Kleine-K=C3=B6n?= =?utf-8?q?ig?= Cc: od@opendingux.net, linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, Paul Cercueil Subject: [PATCH 4/5] pwm: jz4740: Depend on MACH_INGENIC instead of MIPS Date: Mon, 24 Oct 2022 21:52:12 +0100 Message-Id: <20221024205213.327001-5-paul@crapouillou.net> In-Reply-To: <20221024205213.327001-1-paul@crapouillou.net> References: <20221024205213.327001-1-paul@crapouillou.net> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS 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?1747614404847981194?= X-GMAIL-MSGID: =?utf-8?q?1747614404847981194?= The MACH_INGENIC Kconfig option will be selected when building a kernel targeting Ingenic SoCs, but also when compiling a generic MIPS kernel that happens to support Ingenic SoCs. Therefore, if MACH_INGENIC is not set, we know that we're not even trying to build a generic kernel that supports these SoCs, and we can hide the options to compile the SoC-specific drivers. Signed-off-by: Paul Cercueil Reviewed-by: Philippe Mathieu-Daudé Acked-by: Uwe Kleine-König --- drivers/pwm/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index 1fe420a45f91..cb623d0702f6 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig @@ -282,7 +282,7 @@ config PWM_IQS620A config PWM_JZ4740 tristate "Ingenic JZ47xx PWM support" - depends on MIPS || COMPILE_TEST + depends on MACH_INGENIC || COMPILE_TEST depends on COMMON_CLK && OF select MFD_SYSCON help From patchwork Mon Oct 24 20:52:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 10402 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp706949wru; Mon, 24 Oct 2022 16:43:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4mJJGFSJPA8mq96Q9FebT+V2uNfQCcMR8OITuDB6sb1SQjvWkAb1Nq56voZiERewMV+/pq X-Received: by 2002:aa7:9212:0:b0:562:b5f6:f7d7 with SMTP id 18-20020aa79212000000b00562b5f6f7d7mr36872160pfo.70.1666654988218; Mon, 24 Oct 2022 16:43:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666654988; cv=none; d=google.com; s=arc-20160816; b=ST67tPQ3sLMyFBuQ0Q6t60J9q+qy0nZB2MMOnKeQpP7ldmqjr8n3a27TA/YpdF1qo2 4D1c4iic7ZFKgWPcFToKnPMqh8nD9VkH+nc/oCMERzlCLfWdUjNJ+fgoYJidyaZA1smC oGlckvco5196BOY1pMm5m9Tg6T8aGwj8cdbK9dqj3eVmUrjA2/SipG3TL99dCaWUXel/ vt3/7s8bruuga9wXK+M2NhdIBddqwEc5RsyYFvg6y4tJ5kgei7OI+ZhqU78ZAV9JF0OK vnR/bpLb/w7sNeVQdYolo1EzEmq1KoiygTb0XG+HQ7SJRaWn2fmXqcByRWRXd9+3h9C3 jI5Q== 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=HPp+33aYNoQqAGKipSoPytGt3HFjbS0IYlzYnBXZnaU=; b=gepoVww7uZW+oOcW4AOh8GvM1WLCEhnZ9a+YdO5x81N/XBm4/tdSKfclXhM2JoLyv7 JZmETl5yBKxvzG4A9UBZoWuP/YPk76vHUgc7SWiS6XZ/pxEif7sO+kaUWpwKa1JGueGF Xe0q7CfBVxYsjv7n/HXr73ooRasQ45ezUyt2Dh0xy5huTEj0DW938EHS1thVf8iw/wpv q3NANjg9gz2iajep+ELQLrM6qNeNZhxpSjbg+rikeI4i960JtBilZyV+RW1WSnWOzuEo ULY9tdJsc0nSsBtHMvurIMRXuDYL+5rgOxwB7WrbmGXoKLyHkE7/1okkKXRZ3P117qS8 OFIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=jmCmEXMj; 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=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u11-20020a65670b000000b00460b9d08d7bsi948077pgf.868.2022.10.24.16.42.55; Mon, 24 Oct 2022 16:43:08 -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=@crapouillou.net header.s=mail header.b=jmCmEXMj; 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=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231345AbiJXXcN (ORCPT + 99 others); Mon, 24 Oct 2022 19:32:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231297AbiJXXbq (ORCPT ); Mon, 24 Oct 2022 19:31:46 -0400 Received: from aposti.net (aposti.net [89.234.176.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 017771D4DFA; Mon, 24 Oct 2022 14:52:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1666644743; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HPp+33aYNoQqAGKipSoPytGt3HFjbS0IYlzYnBXZnaU=; b=jmCmEXMjhFZ7z+eIBo9HtNqhmipvRftvCUfSkfxFDQLiBRNfB9VrBmbvT96g75zhyIZIce shnY8wpFnn7y/GovUG363mZ+WURakSFyv420pdTbBDBiPOx0yoe+99bQVAb/OULG5PUbgE R7g4gCSz49qRygDCKTsSTHba6xJ1CCw= From: Paul Cercueil To: Thierry Reding , =?utf-8?q?Uwe_Kleine-K=C3=B6n?= =?utf-8?q?ig?= Cc: od@opendingux.net, linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, Paul Cercueil Subject: [PATCH 5/5] pwm: jz4740: Use regmap_{set,clear}_bits Date: Mon, 24 Oct 2022 21:52:13 +0100 Message-Id: <20221024205213.327001-6-paul@crapouillou.net> In-Reply-To: <20221024205213.327001-1-paul@crapouillou.net> References: <20221024205213.327001-1-paul@crapouillou.net> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS 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?1747614420568793956?= X-GMAIL-MSGID: =?utf-8?q?1747614420568793956?= Simplify a bit the code by using regmap_set_bits() and regmap_clear_bits() instead of regmap_update_bits() when possible. Signed-off-by: Paul Cercueil Reviewed-by: Philippe Mathieu-Daudé Acked-by: Uwe Kleine-König --- drivers/pwm/pwm-jz4740.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/pwm/pwm-jz4740.c b/drivers/pwm/pwm-jz4740.c index c0afc0c316a8..22fcdca66081 100644 --- a/drivers/pwm/pwm-jz4740.c +++ b/drivers/pwm/pwm-jz4740.c @@ -88,8 +88,7 @@ static int jz4740_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) struct jz4740_pwm_chip *jz = to_jz4740(chip); /* Enable PWM output */ - regmap_update_bits(jz->map, TCU_REG_TCSRc(pwm->hwpwm), - TCU_TCSR_PWM_EN, TCU_TCSR_PWM_EN); + regmap_set_bits(jz->map, TCU_REG_TCSRc(pwm->hwpwm), TCU_TCSR_PWM_EN); /* Start counter */ regmap_write(jz->map, TCU_REG_TESR, BIT(pwm->hwpwm)); @@ -129,8 +128,7 @@ static void jz4740_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) * In TCU2 mode (channel 1/2 on JZ4750+), this must be done before the * counter is stopped, while in TCU1 mode the order does not matter. */ - regmap_update_bits(jz->map, TCU_REG_TCSRc(pwm->hwpwm), - TCU_TCSR_PWM_EN, 0); + regmap_clear_bits(jz->map, TCU_REG_TCSRc(pwm->hwpwm), TCU_TCSR_PWM_EN); /* Stop counter */ regmap_write(jz->map, TCU_REG_TECR, BIT(pwm->hwpwm)); @@ -204,8 +202,8 @@ static int jz4740_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, regmap_write(jz4740->map, TCU_REG_TDFRc(pwm->hwpwm), period); /* Set abrupt shutdown */ - regmap_update_bits(jz4740->map, TCU_REG_TCSRc(pwm->hwpwm), - TCU_TCSR_PWM_SD, TCU_TCSR_PWM_SD); + regmap_set_bits(jz4740->map, TCU_REG_TCSRc(pwm->hwpwm), + TCU_TCSR_PWM_SD); if (state->enabled) { /*