From patchwork Wed Feb 14 09:32:24 2024 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: 13556195 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 6193BC48BC4 for ; Wed, 14 Feb 2024 09:39:38 +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:References:In-Reply-To: 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: List-Owner; bh=1sP3VR7SEHgsDVLpSnUZJ194sMUAZt+mCjX16icj+q8=; b=F+cEUWlz7mJvQs plxWj8THka+sSnJNsGDcFY2xm6KYXnJ2RA+pf2bGPCarjNbUv5h/SnvKmCEXaYBVadpCVB3TsdMcX Z9c1Kt1sUTCutVYRRvzzIyFnd9qtPTX/L2GT7tRaZUTibEQ/qnMRxffp+uvg4W4K7rlXoAGmVItqG KvLmkZmRxoPPCElUDK/tvyPk2fdraDCnUS9ysgiX43MkVtY8TyDprwUfmPN0QoudyFB9bXrxhYHck nj/yUz/CJKVdUdKuz5xgsCBbqla84PVrv3S/xw7b0Xxq6LffiIY+45xMCwAdA6oilXgmYa77PE2Xo u4Fc2DpWk+4XS9tFArIg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBjc-0000000CNct-1aeC; Wed, 14 Feb 2024 09:39:20 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfU-0000000CKqj-06JE for linux-arm-kernel@bombadil.infradead.org; Wed, 14 Feb 2024 09:35:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Sender:Reply-To:Content-ID:Content-Description; bh=IclYCuABXw6OxctvCL/bCAJvMqHGqIFyYsSEdYqkkUM=; b=q06CGaa3aY3ffVX4PA84gE8dk8 JrOi4NeQNERVTe7GMx126tvf1SxNXjejrS6EttnqPFBpyGhMxq3msH0v2FlDS0NNulHAlqBvH+cis 3P/N2/YCOkBSeVCF6hVnpgTEyMkpq4JeBb+hUkgNzJo4MGusfCnPuJTQW9hT7RQ1XGPxM0Vy6UnFO B75ddWaNcweYrWwd3AfVlvxECXCCLpGVC3pxXRrywhep2qWQhhGY3J8dyiAeb3zGh4XIVeu4HgeVg xGU7ERaQ4kthGWP9F6wZnes+btlZJg8ujz/4hew76jFGlUE67grvD/VIbT7n5oK0Q4/Q/tMS916Qu ebQn98AA==; Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfE-0000000GAXJ-2Pjo for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:35:00 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBf2-0005Ss-Pr; Wed, 14 Feb 2024 10:34:36 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBey-000fEk-Pb; Wed, 14 Feb 2024 10:34:32 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBey-004Y6F-2J; Wed, 14 Feb 2024 10:34:32 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Krzysztof Kozlowski , linux-pwm@vger.kernel.org Cc: Alim Akhtar , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH v6 097/164] pwm: samsung: Change prototype of helpers to prepare further changes Date: Wed, 14 Feb 2024 10:32:24 +0100 Message-ID: <33ea7d7fbf3be4a542ae8aafa213470c5831487e.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5324; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=nipCLLMDWvTbNQBD2/LQ6KGkbMAdcFJTiu0fWjzZ3NQ=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIi6JSgJnfb/o/v1UGfK1a40dVFvZSJlDgqKg Xk6KeC51PSJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIugAKCRCPgPtYfRL+ TuvLB/4s6CYTlewRyBSFA8yqp2ewf3X+euU/JvyxQzepa8SVKlsrV4tnHeD+xFnp+RqgpAFO5JU e6LfiEBaE6UV0labcIneyRzPIjgbuMRflcg3lHFjscxkp8PxEdubdCq5O9AKwjVmzaDN0C8Q0IL KEITIuzA+A0qRlQL0GpLK9AFixeLfdELnSB89xosG1buGODiys5KZin48/E1FfYeIf+zOB8ST/6 qDxMp+WFilHpw2dDNO3wNip+D9kZNgjlcrssD/gJ6OIJCLrvZtov0n10aFN3rvxK62ucJo1XpHy CGuidjlALj1MtuKxTuNb5rqEi1HmUxIR0tZyroklEVeN7FhR 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_093449_117134_A611BDC8 X-CRM114-Status: GOOD ( 18.90 ) 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 This prepares the driver for further changes that will make it harder to determine the pwm_chip from a given samsung_pwm_chip. To just not have to do that, rework pwm_samsung_calc_tin() and pwm_samsung_parse_dt take a pwm_chip. Also use the pwm_chip as driver data instead of the samsung_pwm_chip. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-samsung.c | 41 ++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/drivers/pwm/pwm-samsung.c b/drivers/pwm/pwm-samsung.c index 0f9a2a5e3ebc..ecd612adf19d 100644 --- a/drivers/pwm/pwm-samsung.c +++ b/drivers/pwm/pwm-samsung.c @@ -181,9 +181,10 @@ static unsigned long pwm_samsung_get_tin_rate(struct samsung_pwm_chip *our_chip, return rate / (reg + 1); } -static unsigned long pwm_samsung_calc_tin(struct samsung_pwm_chip *our_chip, +static unsigned long pwm_samsung_calc_tin(struct pwm_chip *chip, unsigned int chan, unsigned long freq) { + struct samsung_pwm_chip *our_chip = to_samsung_pwm_chip(chip); struct samsung_pwm_variant *variant = &our_chip->variant; unsigned long rate; struct clk *clk; @@ -197,12 +198,12 @@ static unsigned long pwm_samsung_calc_tin(struct samsung_pwm_chip *our_chip, return rate; } - dev_warn(our_chip->chip.dev, + dev_warn(chip->dev, "tclk of PWM %d is inoperational, using tdiv\n", chan); } rate = pwm_samsung_get_tin_rate(our_chip, chan); - dev_dbg(our_chip->chip.dev, "tin parent at %lu\n", rate); + dev_dbg(chip->dev, "tin parent at %lu\n", rate); /* * Compare minimum PWM frequency that can be achieved with possible @@ -329,7 +330,7 @@ static int __pwm_samsung_config(struct pwm_chip *chip, struct pwm_device *pwm, dev_dbg(chip->dev, "duty_ns=%d, period_ns=%d (%u)\n", duty_ns, period_ns, period); - tin_rate = pwm_samsung_calc_tin(our_chip, pwm->hwpwm, period); + tin_rate = pwm_samsung_calc_tin(chip, pwm->hwpwm, period); dev_dbg(chip->dev, "tin_rate=%lu\n", tin_rate); @@ -506,9 +507,10 @@ static const struct of_device_id samsung_pwm_matches[] = { }; MODULE_DEVICE_TABLE(of, samsung_pwm_matches); -static int pwm_samsung_parse_dt(struct samsung_pwm_chip *our_chip) +static int pwm_samsung_parse_dt(struct pwm_chip *chip) { - struct device_node *np = our_chip->chip.dev->of_node; + struct samsung_pwm_chip *our_chip = to_samsung_pwm_chip(chip); + struct device_node *np = chip->dev->of_node; const struct of_device_id *match; struct property *prop; const __be32 *cur; @@ -522,7 +524,7 @@ static int pwm_samsung_parse_dt(struct samsung_pwm_chip *our_chip) of_property_for_each_u32(np, "samsung,pwm-outputs", prop, cur, val) { if (val >= SAMSUNG_PWM_NUM) { - dev_err(our_chip->chip.dev, + dev_err(chip->dev, "%s: invalid channel index in samsung,pwm-outputs property\n", __func__); continue; @@ -533,7 +535,7 @@ static int pwm_samsung_parse_dt(struct samsung_pwm_chip *our_chip) return 0; } #else -static int pwm_samsung_parse_dt(struct samsung_pwm_chip *our_chip) +static int pwm_samsung_parse_dt(struct pwm_chip *chip) { return -ENODEV; } @@ -543,6 +545,7 @@ static int pwm_samsung_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct samsung_pwm_chip *our_chip; + struct pwm_chip *chip; unsigned int chan; int ret; @@ -550,13 +553,14 @@ static int pwm_samsung_probe(struct platform_device *pdev) if (our_chip == NULL) return -ENOMEM; - our_chip->chip.dev = &pdev->dev; - our_chip->chip.ops = &pwm_samsung_ops; - our_chip->chip.npwm = SAMSUNG_PWM_NUM; + chip = &our_chip->chip; + chip->dev = &pdev->dev; + chip->ops = &pwm_samsung_ops; + chip->npwm = SAMSUNG_PWM_NUM; our_chip->inverter_mask = BIT(SAMSUNG_PWM_NUM) - 1; if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node) { - ret = pwm_samsung_parse_dt(our_chip); + ret = pwm_samsung_parse_dt(chip); if (ret) return ret; } else { @@ -593,9 +597,9 @@ static int pwm_samsung_probe(struct platform_device *pdev) our_chip->tclk0 = devm_clk_get(&pdev->dev, "pwm-tclk0"); our_chip->tclk1 = devm_clk_get(&pdev->dev, "pwm-tclk1"); - platform_set_drvdata(pdev, our_chip); + platform_set_drvdata(pdev, chip); - ret = pwmchip_add(&our_chip->chip); + ret = pwmchip_add(chip); if (ret < 0) { dev_err(dev, "failed to register PWM chip\n"); clk_disable_unprepare(our_chip->base_clk); @@ -612,17 +616,18 @@ static int pwm_samsung_probe(struct platform_device *pdev) static void pwm_samsung_remove(struct platform_device *pdev) { - struct samsung_pwm_chip *our_chip = platform_get_drvdata(pdev); + struct pwm_chip *chip = platform_get_drvdata(pdev); + struct samsung_pwm_chip *our_chip = to_samsung_pwm_chip(chip); - pwmchip_remove(&our_chip->chip); + pwmchip_remove(chip); clk_disable_unprepare(our_chip->base_clk); } static int pwm_samsung_resume(struct device *dev) { - struct samsung_pwm_chip *our_chip = dev_get_drvdata(dev); - struct pwm_chip *chip = &our_chip->chip; + struct pwm_chip *chip = dev_get_drvdata(dev); + struct samsung_pwm_chip *our_chip = to_samsung_pwm_chip(chip); unsigned int i; for (i = 0; i < SAMSUNG_PWM_NUM; i++) {