From patchwork Sat May 7 08:43:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 12841903 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 E0CEEC433F5 for ; Sat, 7 May 2022 08:44:06 +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=KQN7JSnc3YcjKfEMF61n+I6+GdNsxdgSnpQ/OCX0QsQ=; b=PmQ18YGE3ba8xS 0rrzFyvrc0Hzq/JHfYeP4Pa235ljSDJchapFj05RyMTuZVwKGyVK9IwJ7/cypFGwRPbmhdZdiItDW QmOU9f4d0wXRCFCdCbyyT7gZnYc5ot9NBXJnRpoX7bL8qa+Y3Vk8/nznt0/+kYaiDQHYx/B72VTFY iY4X2YRAv3NazWM2oU1wWK+cF+JyM+prc+ekS2gGDwKIhH/MLBvGtuabV0XawOSJaYGZxUJyYT5M1 dBjO/TvBM91S/7qQzFEChDZvy2tG8F3cX2AUgKWcpOvsyFzr4Z83eFsHxAPUzJmTHyffYTLeWMGDR j/Tm+O9n66y5WnFI5AIg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nnG2j-006WlS-Vt; Sat, 07 May 2022 08:44:02 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nnG2b-006Wib-0K for linux-mediatek@lists.infradead.org; Sat, 07 May 2022 08:43:54 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nnG2W-0003ZA-VT; Sat, 07 May 2022 10:43:49 +0200 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1nnG2W-000rna-UN; Sat, 07 May 2022 10:43:47 +0200 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1nnG2U-00885o-Rb; Sat, 07 May 2022 10:43:46 +0200 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Thierry Reding , Lee Jones , Matthias Brugger Cc: linux-pwm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH] pwm: mediatek: Implement .apply() callback Date: Sat, 7 May 2022 10:43:37 +0200 Message-Id: <20220507084337.167890-1-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1612; h=from:subject; bh=1KW6ty6GQ2hPJLt+FmKcTNmj+Zi8+DqoBiVLGQsCtaQ=; b=owEBbQGS/pANAwAKAcH8FHityuwJAcsmYgBidjE1BE8QaAG8kut8vuwP3pNWJ+MbI0NoKyRVRwrT LZ5Sk6WJATMEAAEKAB0WIQR+cioWkBis/z50pAvB/BR4rcrsCQUCYnYxNQAKCRDB/BR4rcrsCYnLB/ 0XT4bvhgerT8ZpBENu+CGRC0wyQ+GST9QmS1RA5dA1PSPitenhwiNFwL1Rem7vYeIvWjGlHcyZGHPo DGqv9AWug1qGxkwfMxeqvS7xIQSw4GLpchoUPsTyXybkc1cR95A88G0gq6dRRhOBOljAY5sfrRuE0I 2C2BVUUziHMnlSXvk1EsvJydBAstYrb8s2Bh6OOxvDAXaqVCW1CuVCtss5ICgRaz2Vzlt2n+qo/8TS Aoj0U69s/WVdkNCyWb4vVqRBc6nh4unYb8cDzecKToI2/jCZvC4m9yAB6u20XmIFMI9rHq3t8+Zjak xTjBBVwblUZzAx6cY7FUhH5i7rUB/l X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-mediatek@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220507_014353_049925_5A58F399 X-CRM114-Status: GOOD ( 14.08 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org To eventually get rid of all legacy drivers convert this driver to the modern world implementing .apply(). This just pushed a variant of pwm_apply_legacy() into the driver that was slightly simplified because the driver doesn't provide a .set_polarity() callback. Signed-off-by: Uwe Kleine-König Reviewed-by: AngeloGioacchino Del Regno --- drivers/pwm/pwm-mediatek.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) base-commit: 2bf8ee0faa988b5cec3503ebf2f970a0e84d24ee diff --git a/drivers/pwm/pwm-mediatek.c b/drivers/pwm/pwm-mediatek.c index 568b13a48717..e264bb74fdde 100644 --- a/drivers/pwm/pwm-mediatek.c +++ b/drivers/pwm/pwm-mediatek.c @@ -198,10 +198,33 @@ static void pwm_mediatek_disable(struct pwm_chip *chip, struct pwm_device *pwm) pwm_mediatek_clk_disable(chip, pwm); } +static int pwm_mediatek_apply(struct pwm_chip *chip, struct pwm_device *pwm, + const struct pwm_state *state) +{ + int err; + + if (state->polarity != PWM_POLARITY_NORMAL) + return -EINVAL; + + if (!state->enabled) { + if (pwm->state.enabled) + pwm_mediatek_disable(chip, pwm); + + return 0; + } + + err = pwm_mediatek_config(pwm->chip, pwm, state->duty_cycle, state->period); + if (err) + return err; + + if (!pwm->state.enabled) + err = pwm_mediatek_enable(chip, pwm); + + return err; +} + static const struct pwm_ops pwm_mediatek_ops = { - .config = pwm_mediatek_config, - .enable = pwm_mediatek_enable, - .disable = pwm_mediatek_disable, + .apply = pwm_mediatek_apply, .owner = THIS_MODULE, };