From patchwork Tue Aug 29 09:18:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mateusz Majewski X-Patchwork-Id: 719694 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA6E4C83F14 for ; Tue, 29 Aug 2023 09:25:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234705AbjH2JYb (ORCPT ); Tue, 29 Aug 2023 05:24:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234809AbjH2JY0 (ORCPT ); Tue, 29 Aug 2023 05:24:26 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24C031BF for ; Tue, 29 Aug 2023 02:24:20 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230829092413euoutp02c00b68f81c2649d44f31bdf91c3318e9~-0FYhdjci0626506265euoutp021 for ; Tue, 29 Aug 2023 09:24:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230829092413euoutp02c00b68f81c2649d44f31bdf91c3318e9~-0FYhdjci0626506265euoutp021 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1693301053; bh=R1npbRRHIVc5z6cr0/4uwlBlhUhKgoCzpA6deobymMU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KOFpkEUL0x/7wZ6c3789rGGdbcGSzNtU6wTf93x1lVVHYX+lXu5vu6N38rfo6LfI2 sArTPqMPk63e8pYYMcz4yu347pTa5vgo6F9UYAOmT5TUarMLbnwLxee5BvfDym+Dgx WjDFEY0w21t1a7pE+ZV4hbES3gOyR3mWWJCFSUxk= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230829092412eucas1p1531cee3670a5d7e7fe38d7d7151f2a71~-0FYHCpq31623216232eucas1p1l; Tue, 29 Aug 2023 09:24:12 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id D4.7F.37758.C39BDE46; Tue, 29 Aug 2023 10:24:12 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230829092412eucas1p2b79a6f90b9077a3a5486845b7e68bbc6~-0FXq7Jdh2939629396eucas1p24; Tue, 29 Aug 2023 09:24:12 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230829092412eusmtrp14cd3da253366871f711c7e1809b20078~-0FXqKtVd3248032480eusmtrp1v; Tue, 29 Aug 2023 09:24:12 +0000 (GMT) X-AuditID: cbfec7f5-815ff7000002937e-43-64edb93cbb05 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id ED.D9.10549.C39BDE46; Tue, 29 Aug 2023 10:24:12 +0100 (BST) Received: from AMDC4515.eu.corp.samsungelectronics.net (unknown [106.120.51.28]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230829092411eusmtip28a316e30a2b60f07dd72a3c2872f77ed~-0FWvvzIj0629806298eusmtip2i; Tue, 29 Aug 2023 09:24:11 +0000 (GMT) From: Mateusz Majewski To: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Cc: Mateusz Majewski , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Alim Akhtar , Bartlomiej Zolnierkiewicz , "Rafael J. Wysocki" , Daniel Lezcano , Amit Kucheria , Zhang Rui , Liam Girdwood , Mark Brown , Marek Szyprowski Subject: [PATCH 04/11] thermal: exynos: remove fine-grained clk management Date: Tue, 29 Aug 2023 11:18:42 +0200 Message-ID: <20230829091853.626011-5-m.majewski2@samsung.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230829091853.626011-1-m.majewski2@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrHKsWRmVeSWpSXmKPExsWy7djP87o2O9+mGOxu17V4MG8bm8Xh+RUW Ux8+YbP4vuU6k8WaveeYLOZ9lrWYf+Qcq0Xfi4fMFt+udDBZbHp8jdXi8q45bBafe48wWsw4 v4/JYuKxycwWa4/cZbeY+2Uqs0Xr3iPsFk8e9rE5CHnsnHWX3WPxnpdMHptWdbJ53Lm2h81j 85J6j74tqxg9Pm+SC2CP4rJJSc3JLEst0rdL4Mq4su4uU8EthYrnN5axNjD+kupi5OSQEDCR mPX5P2sXIxeHkMAKRomLH7exQzhfGCXOdW5mgnA+M0rcu7aVBablfsNuNojEcqCWtZcYIZxW JomWBx+ZQarYBAwkHrxZBjZLRGAxo8TWnbPAZjELzGWRaFj5E2yWsICXxNQLWxlBbBYBVYmW re/AbF4BW4nzx2ezQ+yTl3h+6w6YzSlgJzH9fDsTRI2gxMmZT8DmMAPVNG+dzQxRP51T4sxK NgjbRWL1iXaouLDEq+NboGbKSJye3AP1T77EjM3vgWwOILtC4u5BLwjTWuLjGWYQk1lAU2L9 Ln2IYkeJO82PWSEq+CRuvBWE2M8nMWnbdGaIMK9ER5sQRLWqxPE9k6DWS0s8abnNBGF7SNx+ c519AqPiLCSfzELyySyEvQsYmVcxiqeWFuempxYb56WW6xUn5haX5qXrJefnbmIEJrnT/45/ 3cG44tVHvUOMTByMhxglOJiVRHgvOb5KEeJNSaysSi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C85vkoR4k1JrKxKLcqPLyrNSS0+xGgK dPdEZinR5HxgWsgriTc0MzA1NDGzNDC1NDNWEuf1LOhIFBJITyxJzU5NLUgtgulj4uCUamAy z4xzPZB5XYxFzPxXv/30QB6lpqqlMmsW5exz/JT/mmn1mt+zfz06vztmhde0uew3ivKPGRc1 8tUnaoVs/cI84e3TQMF5NSt3nA25pniRd7772wZFoTb/TRtrsg5opbd/jjA7+oyD2eLtxSXq Fq4zOy4yOHrb34qqLiiYduP1RdO3X1iW1tnzXOd7VC0258zHBU9ZJMqWWh95nDdDw/f75oW2 7lvezVoryxNuz57ywHmVTGLytw35s+bdC/wgeY6x/wXzV95PXFzT9zfxvSpW5zHe6nvIa8fE v/r3LjDM1lyeE8HMUqYp+luK0+BB7/OeKRPEonxazf5UpjzIcdx83MFeJcVe5Kdd+FR2h7lK LMUZiYZazEXFiQDCK5BvUwMAAA== X-CMS-MailID: 20230829092412eucas1p2b79a6f90b9077a3a5486845b7e68bbc6 X-Msg-Generator: CA X-RootMTR: 20230829092412eucas1p2b79a6f90b9077a3a5486845b7e68bbc6 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230829092412eucas1p2b79a6f90b9077a3a5486845b7e68bbc6 References: <20230829091853.626011-1-m.majewski2@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org This clock only controls the register operations. The gain in power efficiency is therefore quite dubious, while there is price of added complexity that is important to get right (as a register operation might outright hang the CPU if the clock is not enabled). Signed-off-by: Mateusz Majewski --- drivers/thermal/samsung/exynos_tmu.c | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 35b0a55017ad..2c5501704911 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -275,7 +275,6 @@ static int exynos_tmu_initialize(struct platform_device *pdev) } mutex_lock(&data->lock); - clk_enable(data->clk); if (!IS_ERR(data->clk_sec)) clk_enable(data->clk_sec); @@ -305,7 +304,6 @@ static int exynos_tmu_initialize(struct platform_device *pdev) data->tmu_clear_irqs(data); } err: - clk_disable(data->clk); mutex_unlock(&data->lock); if (!IS_ERR(data->clk_sec)) clk_disable(data->clk_sec); @@ -336,10 +334,8 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on) struct exynos_tmu_data *data = platform_get_drvdata(pdev); mutex_lock(&data->lock); - clk_enable(data->clk); data->tmu_control(pdev, on); data->enabled = on; - clk_disable(data->clk); mutex_unlock(&data->lock); } @@ -654,7 +650,6 @@ static int exynos_get_temp(struct thermal_zone_device *tz, int *temp) return -EAGAIN; mutex_lock(&data->lock); - clk_enable(data->clk); value = data->tmu_read(data); if (value < 0) @@ -662,7 +657,6 @@ static int exynos_get_temp(struct thermal_zone_device *tz, int *temp) else *temp = code_to_temp(data, value) * MCELSIUS; - clk_disable(data->clk); mutex_unlock(&data->lock); return ret; @@ -729,9 +723,7 @@ static int exynos_tmu_set_emulation(struct thermal_zone_device *tz, int temp) goto out; mutex_lock(&data->lock); - clk_enable(data->clk); data->tmu_set_emulation(data, temp); - clk_disable(data->clk); mutex_unlock(&data->lock); return 0; out: @@ -769,12 +761,10 @@ static irqreturn_t exynos_tmu_threaded_irq(int irq, void *id) thermal_zone_device_update(data->tzd, THERMAL_EVENT_UNSPECIFIED); mutex_lock(&data->lock); - clk_enable(data->clk); /* TODO: take action based on particular interrupt */ data->tmu_clear_irqs(data); - clk_disable(data->clk); mutex_unlock(&data->lock); return IRQ_HANDLED; @@ -1012,7 +1002,7 @@ static int exynos_tmu_probe(struct platform_device *pdev) if (ret) goto err_sensor; - data->clk = devm_clk_get(&pdev->dev, "tmu_apbif"); + data->clk = devm_clk_get_enabled(&pdev->dev, "tmu_apbif"); if (IS_ERR(data->clk)) { dev_err(&pdev->dev, "Failed to get clock\n"); ret = PTR_ERR(data->clk); @@ -1034,12 +1024,6 @@ static int exynos_tmu_probe(struct platform_device *pdev) } } - ret = clk_prepare(data->clk); - if (ret) { - dev_err(&pdev->dev, "Failed to get clock\n"); - goto err_clk_sec; - } - switch (data->soc) { case SOC_ARCH_EXYNOS5433: case SOC_ARCH_EXYNOS7: @@ -1047,12 +1031,12 @@ static int exynos_tmu_probe(struct platform_device *pdev) if (IS_ERR(data->sclk)) { dev_err(&pdev->dev, "Failed to get sclk\n"); ret = PTR_ERR(data->sclk); - goto err_clk; + goto err_clk_sec; } else { ret = clk_prepare_enable(data->sclk); if (ret) { dev_err(&pdev->dev, "Failed to enable sclk\n"); - goto err_clk; + goto err_clk_sec; } } break; @@ -1094,8 +1078,6 @@ static int exynos_tmu_probe(struct platform_device *pdev) err_sclk: clk_disable_unprepare(data->sclk); -err_clk: - clk_unprepare(data->clk); err_clk_sec: if (!IS_ERR(data->clk_sec)) clk_unprepare(data->clk_sec); @@ -1113,7 +1095,6 @@ static int exynos_tmu_remove(struct platform_device *pdev) exynos_tmu_control(pdev, false); clk_disable_unprepare(data->sclk); - clk_unprepare(data->clk); if (!IS_ERR(data->clk_sec)) clk_unprepare(data->clk_sec);