From patchwork Sun May 15 06:41:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Moon X-Patchwork-Id: 12850004 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 6C45CC433F5 for ; Sun, 15 May 2022 06:44:13 +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=eydQK0a4Zl2Qo3RVPkvspr+6NHJvhMvPgGDx68RhxBk=; b=qMB+nkEZf8nrBp rP49WGplxDNtyLI9f/yanQ7wRwNVqZQ9DuMdIW06Di2sZ1yZclrBVCWY8dG1jkXJ/tTfCvN6OJD+6 tqZT7P5EYaDmRtJ5S1gw/C67qFx8hRrl/OtP3b4NfPaJTigBvM5rjjBj3s0WcDyyqX+x3x6CHEpsg Y30/k8mQH+AYN1sE4NISoMwCBipXaB3r9/WvDzOW9bEIeRJhp2hoxiWqpnd7fASnkSRDui3jgl6sh IIs2BlE7e5br1ezsdD8lEwtSOsIEu1npNU/vetcYY+SJRb1DyRTnlbeCy5VTsK4LFvqZdD8/Y+Zfn fUi87PUeLznmWpU8hHwg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nq7yD-003KDa-3Q; Sun, 15 May 2022 06:43:13 +0000 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nq7xl-003JzM-GQ for linux-arm-kernel@lists.infradead.org; Sun, 15 May 2022 06:42:47 +0000 Received: by mail-pg1-x531.google.com with SMTP id 191so119717pgf.4 for ; Sat, 14 May 2022 23:42:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=D4Q6w6yEvGwJK0TRipYAGtfiK43Dmnd3tJ7ygkkWia4=; b=IOLCGdIAmm3LunK3vBZkd/zL03BzIKvSMk+Utas+4Rbjc1kgqSnZVisi+yBAvrPSDX y/Rykv02QICz7x6MMGfUNDMjOAi4QyP4CLjK2VAtFwUkiLT3BX177/DXaBBSNwn+3pqJ /0ff8f8msGQ6Vt+K0aLeKn6GW8pHmSYYnpdjnAb62dJmQvKUMfH2MLQ535Rd7tTii5XG 3BaPorgEEpb36Ei2LBex0KVE+uwJOOByOUuGpxiizr+744YJpAdXdIbAHw92oxLozHGE PhIFmkCTc9jLTwxecZUGpxlplo/YS2t1cDMhwxol4xU22WvCo5uuGreWf8bAEF0GIvfv gW2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=D4Q6w6yEvGwJK0TRipYAGtfiK43Dmnd3tJ7ygkkWia4=; b=rN/vhfnNprv1uThpMU9heSba46AbMrD0/SpsxVX/gD2c7OdxakKof2a4ncPCIj1nUx cuV5tLPsjoYaqkOVfjWDr3VUzH8Ajci44qVWJWxnssjoV+oK1Xo+BJ6mX8aqamKUKD9j qJNYmYzoE/ZT8SKetUYiM8FC88E+QCisG6F+4BP4m8PvRP7JPIdBZkU2b0g6VzZCGDzo yk5OlTxOYj4ghlMW1T1NfZztOYFwKAQC6Umj6CkFg50/YA9MLlLiWZCvjFSSmV656V/S yV0TTlsLMG11C0WF+rlMyZH8DAwrHUuJx8i3c98DM7aMvxQ0Y/X7AXqa/ICjkRCQrUBS c1YQ== X-Gm-Message-State: AOAM531R8Mg/N4YN72zK2oXWGQvZpLQynTE6wTE6EDzyjIe9bbRI48II meSTuZ8KwEaXV4hahB5pULM= X-Google-Smtp-Source: ABdhPJzaWlQJYvbQ+EagfN3qdp16Rk+tbk02UoNETO2+CAcbdrv7RLtNe2Z7jSDRK6RLvZbVgRfX3A== X-Received: by 2002:a62:1ad4:0:b0:510:c635:e516 with SMTP id a203-20020a621ad4000000b00510c635e516mr12359143pfa.42.1652596964160; Sat, 14 May 2022 23:42:44 -0700 (PDT) Received: from alarm.. ([103.51.72.28]) by smtp.gmail.com with ESMTPSA id g24-20020a170902d5d800b0015e8d4eb2e3sm4568687plh.301.2022.05.14.23.42.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 May 2022 23:42:43 -0700 (PDT) From: Anand Moon To: Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski , "Rafael J. Wysocki" , Daniel Lezcano , Amit Kucheria , Zhang Rui , Alim Akhtar , linux-pm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Anand Moon Subject: [PATCHv2 6/6] thermal: exynos: Add runtime power management for tmu Date: Sun, 15 May 2022 06:41:23 +0000 Message-Id: <20220515064126.1424-7-linux.amoon@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220515064126.1424-1-linux.amoon@gmail.com> References: <20220515064126.1424-1-linux.amoon@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220514_234245_598235_F3774055 X-CRM114-Status: GOOD ( 17.59 ) 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 Add runtime power management for exynos thermal driver. Cc: Bartlomiej Zolnierkiewicz Signed-off-by: Anand Moon --- v1: new patch in this series. --- drivers/thermal/samsung/exynos_tmu.c | 29 ++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index f8a527f19383..be9b98caf2ba 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -20,6 +20,7 @@ #include #include #include +#include #include @@ -1106,6 +1107,15 @@ static int exynos_tmu_probe(struct platform_device *pdev) goto err_thermal; } + pm_runtime_set_active(&pdev->dev); + pm_runtime_set_autosuspend_delay(&pdev->dev, 1000); + pm_runtime_use_autosuspend(&pdev->dev); + pm_runtime_enable(&pdev->dev); + + ret = pm_runtime_resume_and_get(&pdev->dev); + if (ret < 0) + goto disable_runtime_pm; + ret = devm_request_irq(&pdev->dev, data->irq, exynos_tmu_irq, IRQF_TRIGGER_RISING | IRQF_SHARED, dev_name(&pdev->dev), data); if (ret) { @@ -1113,11 +1123,16 @@ static int exynos_tmu_probe(struct platform_device *pdev) goto err_thermal; } + pm_runtime_put(&pdev->dev); + exynos_tmu_control(pdev, true); return 0; err_thermal: thermal_zone_of_sensor_unregister(&pdev->dev, data->tzd); +disable_runtime_pm: + pm_runtime_put_noidle(&pdev->dev); + pm_runtime_disable(&pdev->dev); err_clk_sec: clk_disable_unprepare(data->clk_sec); err_sclk: @@ -1143,6 +1158,9 @@ static int exynos_tmu_remove(struct platform_device *pdev) clk_disable_unprepare(data->clk); clk_disable_unprepare(data->clk_sec); + pm_runtime_put_noidle(&pdev->dev); + pm_runtime_disable(&pdev->dev); + if (!IS_ERR(data->regulator)) regulator_disable(data->regulator); @@ -1151,18 +1169,25 @@ static int exynos_tmu_remove(struct platform_device *pdev) static int __maybe_unused exynos_tmu_suspend(struct device *dev) { - exynos_tmu_control(to_platform_device(dev), false); + struct platform_device *pdev = to_platform_device(dev); - return 0; + exynos_tmu_control(pdev, false); + + return pm_runtime_force_suspend(&pdev->dev); } static int __maybe_unused exynos_tmu_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); + int ret; exynos_tmu_initialize(pdev); exynos_tmu_control(pdev, true); + ret = pm_runtime_force_resume(&pdev->dev); + if (ret) + return ret; + return 0; }