From patchwork Sun May 15 06:41:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Moon X-Patchwork-Id: 572895 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 3D541C433FE for ; Sun, 15 May 2022 06:42:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235822AbiEOGmK (ORCPT ); Sun, 15 May 2022 02:42:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229836AbiEOGmI (ORCPT ); Sun, 15 May 2022 02:42:08 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B529421833; Sat, 14 May 2022 23:42:07 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id o13-20020a17090a9f8d00b001df3fc52ea7so531095pjp.3; Sat, 14 May 2022 23:42:07 -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=yUsWY8yO7JINjNZjm2YNwG/QCXLT5+H4ss9vbx5Zd0w=; b=W4TO+xCxh/8tDfBX3UQBWoDFjUykmIMldo50JqnI8/SRLznz0WeUDf2jrPuAak/fEc t0QcGx0qKWPl3sPVp8I3sfh3FrZ1GS6nVFhJcbopsv6a70Pvr4eVBWY3JVGv518rCGY1 Tu04TkWzKudEwoLfCxRM/sq7beVEHT6QHN/1SFx05fsnvWefiAX9XNbxgG3M1MkU56c3 3I4A0NkgAAVOQ5csvjbjjggxw0ZHIQVEFk9DzLazqqT5A0kKrfuw4y/2u+bZtK5TXt+J YslAF7jV2r2s8pEwWPcqDokf3RkqthbSb/G7APGMRHe/Oq82/1anL3BDCM3y9MvXIzNz +EAw== 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=yUsWY8yO7JINjNZjm2YNwG/QCXLT5+H4ss9vbx5Zd0w=; b=o2lyIYKy96wwoJDl5NF+TZ5zleIMGC4Cxxmnga1/yCUCwx69SmfONvH2D285NAYec0 iEA2aZj+2yk4U2oIgwZ4DRIYm0dNw+REA7nfDZhqMtSuTzVRb9uCBz/wqM5XRyVk1VLf YB8SH/wY6qfyHnPBO+rhWXVq+/rtSZA3iMJnz5BEK2gWKGQN4H8qQvk5VUQX+g/eaozH x1U63FX3nTi+kDyz/GM1IUbMShkg5WpJNfZLKtoqL0SeUVxjuD+Bf2CAbOik4c95FCof W2TiSJwuZv1ac38u421jntCvIMBTOuyHaSeukhRrSc84FqUrG3yetr4aFcWj82XJTU/A Th1A== X-Gm-Message-State: AOAM53363tGswPFApSosYlumnDgWCPXLtdq15h+EH89ltzoG3uzs133u UDma0g7PiSfbfbuNBwe7uZU= X-Google-Smtp-Source: ABdhPJz33p0ux51f2WvaEY+nQUYH4tVmxqP3fLiRfjM7Jqpa5ngaRasABu7YzWql7RGfMLkmAYYzKw== X-Received: by 2002:a17:90b:350d:b0:1dc:6680:6f1d with SMTP id ls13-20020a17090b350d00b001dc66806f1dmr24421442pjb.27.1652596927259; Sat, 14 May 2022 23:42:07 -0700 (PDT) Received: from alarm.. ([103.51.72.28]) by smtp.gmail.com with ESMTPSA id g24-20020a170902d5d800b0015e8d4eb2e3sm4568687plh.301.2022.05.14.23.42.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 May 2022 23:42:06 -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 1/6] thermal: exynos: Enable core tmu hardware clk flag on exynos platform Date: Sun, 15 May 2022 06:41:18 +0000 Message-Id: <20220515064126.1424-2-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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Use clk_prepare_enable api to enable tmu internal hardware clock flag on, use clk_disable_unprepare to disable the clock. Cc: Bartlomiej Zolnierkiewicz Signed-off-by: Anand Moon --- v1: split te changes and improve the commit message. --- drivers/thermal/samsung/exynos_tmu.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index f4ab4c5b4b62..75b3afadb5be 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -1054,14 +1054,14 @@ static int exynos_tmu_probe(struct platform_device *pdev) goto err_sensor; } } else { - ret = clk_prepare(data->clk_sec); + ret = clk_prepare_enable(data->clk_sec); if (ret) { dev_err(&pdev->dev, "Failed to get clock\n"); goto err_sensor; } } - ret = clk_prepare(data->clk); + ret = clk_prepare_enable(data->clk); if (ret) { dev_err(&pdev->dev, "Failed to get clock\n"); goto err_clk_sec; @@ -1122,10 +1122,10 @@ static int exynos_tmu_probe(struct platform_device *pdev) err_sclk: clk_disable_unprepare(data->sclk); err_clk: - clk_unprepare(data->clk); + clk_disable_unprepare(data->clk); err_clk_sec: if (!IS_ERR(data->clk_sec)) - clk_unprepare(data->clk_sec); + clk_disable_unprepare(data->clk_sec); err_sensor: if (!IS_ERR(data->regulator)) regulator_disable(data->regulator); @@ -1142,9 +1142,9 @@ static int exynos_tmu_remove(struct platform_device *pdev) exynos_tmu_control(pdev, false); clk_disable_unprepare(data->sclk); - clk_unprepare(data->clk); + clk_disable_unprepare(data->clk); if (!IS_ERR(data->clk_sec)) - clk_unprepare(data->clk_sec); + clk_disable_unprepare(data->clk_sec); if (!IS_ERR(data->regulator)) regulator_disable(data->regulator); From patchwork Sun May 15 06:41:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Moon X-Patchwork-Id: 574135 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 2BB5AC433F5 for ; Sun, 15 May 2022 06:42:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235841AbiEOGmS (ORCPT ); Sun, 15 May 2022 02:42:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235842AbiEOGmP (ORCPT ); Sun, 15 May 2022 02:42:15 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E04BF21E2E; Sat, 14 May 2022 23:42:14 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id ev18so940815pjb.4; Sat, 14 May 2022 23:42:14 -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=RNX8IttIs7gPKZ/ZnlljxMvfqRG5qWD1gnAXVMMqp+0=; b=XEBWuyekW9Udsy/Vmpi4TY/XNvR6qWx5rXCSqsQu38ntjFvrZ7UBEto6MpPBdQJnzp H/QYIJJVqffc+impBIGZY/MgvA6BcxfpypE61Mv5qsOkhdyooPNwgtunUKmau/HX6NHB jlmk2eGVS+8L5jSUCeHPBenPyLuAWSCf5azOXgnp06e7zouH7VdOzz2MHJyrJbnkAEHs pKZtPck8GEuNzxbYjkerb3Y4Ob2PUYY3uBLf4/WDR5fHiVARgxItMmdrluI7oX0g8+Wy QGGGu4wbaA83ceJnAikUtq37nFoDIa9sRNceKxsp2XAzM5oTC9mCnlyesgVnHxR9FBKC AOvw== 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=RNX8IttIs7gPKZ/ZnlljxMvfqRG5qWD1gnAXVMMqp+0=; b=6U83q/tKBX4o5dqx9DtXcet6VeKNcd4cbJ+McZ2bc20OhgvbLh+klUGC9HERBV0xAs fIlhdASrNTZn/WqeFUe5iOTk1r18BuoMWtAaIhPK5Oy49jEF06dvYJPbtGVD6jkylAde P19fDs+lXcsuTx6HwyKSzZT9Dri98LS3EexGIHbk0f7qzBzwTvvoLxemqto272Bm9j22 k6cS+VPDSK/PdJ6zMohvneNYvPDms+z8Ye9d7CPurwTtxWk9hnat4XvOdnPGhRzmQQEr r4fWiqb1nMJFacUo/bkv1AMrr/6cWQlHJhy6G79ieHCTQmgHZ9t6H7wVYlJfTQK4nVGc E9EQ== X-Gm-Message-State: AOAM533PqLzu6b54oFkdDPuBvGUo+LBtNNcPwfUZSdTXf1buyGmdF4yE zhRZkFxTW/gKXoEj9sJSe0k= X-Google-Smtp-Source: ABdhPJyT8+/XLu+q/7btdUnRMr1o9G/m+//8acAzxbS43SlpLD4HVZDMbTlxRTchAJLWw+4FK5O7pQ== X-Received: by 2002:a17:90a:f2ce:b0:1d9:a18f:87f3 with SMTP id gt14-20020a17090af2ce00b001d9a18f87f3mr24550386pjb.213.1652596934488; Sat, 14 May 2022 23:42:14 -0700 (PDT) Received: from alarm.. ([103.51.72.28]) by smtp.gmail.com with ESMTPSA id g24-20020a170902d5d800b0015e8d4eb2e3sm4568687plh.301.2022.05.14.23.42.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 May 2022 23:42:14 -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 2/6] thermal: exynos: Reorder the gpu clock initialization for exynos5420 SoC Date: Sun, 15 May 2022 06:41:19 +0000 Message-Id: <20220515064126.1424-3-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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Reorder the tmu_gpu clock initialization for exynos5422 SoC. Cc: Bartlomiej Zolnierkiewicz Signed-off-by: Anand Moon --- v1: split the changes and improve the commit messages --- drivers/thermal/samsung/exynos_tmu.c | 43 ++++++++++++++-------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 75b3afadb5be..1ef90dc52c08 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -1044,42 +1044,41 @@ static int exynos_tmu_probe(struct platform_device *pdev) dev_err(&pdev->dev, "Failed to get clock\n"); ret = PTR_ERR(data->clk); goto err_sensor; - } - - data->clk_sec = devm_clk_get(&pdev->dev, "tmu_triminfo_apbif"); - if (IS_ERR(data->clk_sec)) { - if (data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO) { - dev_err(&pdev->dev, "Failed to get triminfo clock\n"); - ret = PTR_ERR(data->clk_sec); - goto err_sensor; - } } else { - ret = clk_prepare_enable(data->clk_sec); + ret = clk_prepare_enable(data->clk); if (ret) { dev_err(&pdev->dev, "Failed to get clock\n"); goto err_sensor; } } - ret = clk_prepare_enable(data->clk); - if (ret) { - dev_err(&pdev->dev, "Failed to get clock\n"); - goto err_clk_sec; - } - switch (data->soc) { + case SOC_ARCH_EXYNOS5420_TRIMINFO: + data->clk_sec = devm_clk_get(&pdev->dev, "tmu_triminfo_apbif"); + if (IS_ERR(data->clk_sec)) { + dev_err(&pdev->dev, "Failed to get triminfo clock\n"); + ret = PTR_ERR(data->clk_sec); + goto err_clk_apbif; + } else { + ret = clk_prepare_enable(data->clk_sec); + if (ret) { + dev_err(&pdev->dev, "Failed to get clock\n"); + goto err_clk_apbif; + } + } + break; case SOC_ARCH_EXYNOS5433: case SOC_ARCH_EXYNOS7: data->sclk = devm_clk_get(&pdev->dev, "tmu_sclk"); 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; @@ -1119,13 +1118,13 @@ static int exynos_tmu_probe(struct platform_device *pdev) err_thermal: thermal_zone_of_sensor_unregister(&pdev->dev, data->tzd); -err_sclk: - clk_disable_unprepare(data->sclk); -err_clk: - clk_disable_unprepare(data->clk); err_clk_sec: if (!IS_ERR(data->clk_sec)) clk_disable_unprepare(data->clk_sec); +err_sclk: + clk_disable_unprepare(data->sclk); +err_clk_apbif: + clk_disable_unprepare(data->clk); err_sensor: if (!IS_ERR(data->regulator)) regulator_disable(data->regulator); From patchwork Sun May 15 06:41:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Moon X-Patchwork-Id: 572894 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 63EF6C433F5 for ; Sun, 15 May 2022 06:42:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229606AbiEOGm2 (ORCPT ); Sun, 15 May 2022 02:42:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235865AbiEOGmY (ORCPT ); Sun, 15 May 2022 02:42:24 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12AAF21E1C; Sat, 14 May 2022 23:42:22 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id l20-20020a17090a409400b001dd2a9d555bso11470591pjg.0; Sat, 14 May 2022 23:42:22 -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=5SvJ/++bycunC3OKTAB9+JnJnOimY+H66XGtoS2w60s=; b=jrwaBKFl5d35QZ+3Gee2JrXoy7jVYCOzlLjUKMZ00zqNMc4yv3WfXcp3A1Irk2aD4y NHYe7fdu1w2rvINacTdaZsuNalurMXEFmu4dajXvHlIF6fEcGSuSAAmI821cUxO7UjLm T6xQdGAjpDNecUPguBmvEsOWjR1ScYtxo3v9VVkxtPaTlR+ZZ53VXeWYZQfx/fFNIilS az/p6n/0+RaYr0W8QnQe3gwjPHsOEx+GTyAjfDIEUoMbDqWNZW5aPLZENyceBVgKT/VO e8GRHJRCpNaEmFe89deWgZRv2GlMK56yVyuKiATL3+K/sJNTjosJiHhakkCww3cKbfZh 2EEw== 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=5SvJ/++bycunC3OKTAB9+JnJnOimY+H66XGtoS2w60s=; b=1/CVOIgl9axhSrIcOyuBRgNOdQTdFJ3sw8igd5FKKTnGoiekyo1gphKF5aG3I5qQec QQYo0eWS9/o7RG6Xr2RRVNRJCTufN9W8/XNfqGxauo6c6Zhele5UXz7+if/Pu+t5Nt1C efPrK98CSWHBpuopYuyFW2TBsqheMQteqkO4gMgJnzkvy9GjatVrJ9CG/PSWUJQZ+gTh dEHC5nGP1/y3Cu7W21q9k0LlU3LruztaRveDnyS/lU0EbblqG1wX+2Pg8oIAjZHUtDfK TKDgi2vtvHnp+VNV6L5Av32iV/syAHWIAMiC+nqRCfCwoIpuZxatXjkHnUxnoVRJgDWX 4fqg== X-Gm-Message-State: AOAM532JBzc9Mv2QeJJ0DpI+mwp4kJFpM+3WfAKEBGH+kVBnzKajfroI S7SL/94v/Zr31p6/rhU4fy4= X-Google-Smtp-Source: ABdhPJzWcVVfdugYBkVY7O80ZUsr97cxYMYWRp1vfSYA4vb0IAvOv+WNAehaqvlWeMBCDABHd9zg/A== X-Received: by 2002:a17:90a:ba11:b0:1df:2d09:1308 with SMTP id s17-20020a17090aba1100b001df2d091308mr3500270pjr.184.1652596941625; Sat, 14 May 2022 23:42:21 -0700 (PDT) Received: from alarm.. ([103.51.72.28]) by smtp.gmail.com with ESMTPSA id g24-20020a170902d5d800b0015e8d4eb2e3sm4568687plh.301.2022.05.14.23.42.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 May 2022 23:42:21 -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 3/6] thermal: exynos: Check before clk_disable_unprepare() not needed Date: Sun, 15 May 2022 06:41:20 +0000 Message-Id: <20220515064126.1424-4-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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org All code in clk_disable_unprepare() already checks the clk ptr using IS_ERR_OR_NULL so there is no need to check it again before calling it. A lot of other drivers already rely on this behaviour, so it's safe to do so here. Cc: Bartlomiej Zolnierkiewicz Signed-off-by: Anand Moon --- v1: improve the commit message --- drivers/thermal/samsung/exynos_tmu.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 1ef90dc52c08..58ff1b577c47 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -289,8 +289,7 @@ 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); + clk_enable(data->clk_sec); status = readb(data->base + EXYNOS_TMU_REG_STATUS); if (!status) { @@ -323,8 +322,7 @@ static int exynos_tmu_initialize(struct platform_device *pdev) err: clk_disable(data->clk); mutex_unlock(&data->lock); - if (!IS_ERR(data->clk_sec)) - clk_disable(data->clk_sec); + clk_disable(data->clk_sec); out: return ret; } @@ -1119,8 +1117,7 @@ static int exynos_tmu_probe(struct platform_device *pdev) err_thermal: thermal_zone_of_sensor_unregister(&pdev->dev, data->tzd); err_clk_sec: - if (!IS_ERR(data->clk_sec)) - clk_disable_unprepare(data->clk_sec); + clk_disable_unprepare(data->clk_sec); err_sclk: clk_disable_unprepare(data->sclk); err_clk_apbif: @@ -1142,8 +1139,7 @@ static int exynos_tmu_remove(struct platform_device *pdev) clk_disable_unprepare(data->sclk); clk_disable_unprepare(data->clk); - if (!IS_ERR(data->clk_sec)) - clk_disable_unprepare(data->clk_sec); + clk_disable_unprepare(data->clk_sec); if (!IS_ERR(data->regulator)) regulator_disable(data->regulator); From patchwork Sun May 15 06:41:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Moon X-Patchwork-Id: 574134 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 7010DC4332F for ; Sun, 15 May 2022 06:42:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235861AbiEOGmd (ORCPT ); Sun, 15 May 2022 02:42:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235879AbiEOGmb (ORCPT ); Sun, 15 May 2022 02:42:31 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A27A222B2; Sat, 14 May 2022 23:42:29 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id bo5so11311944pfb.4; Sat, 14 May 2022 23:42:29 -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=R70u7aKcalBy/OfNQ27Efmy9t/Kzj8CNy0QFYWzkyIg=; b=PaEiC5KNfp1oJ/1byQ6sKlb0XBZfuoy6H+ca9hxE+ZFIADImwXIyvZxMv1kib9xMx0 KTqjrr7jmOjS9m39Cd1LLBR2qBa4esr4sSl3jOkjCEGWxe1/zsfsJPsNwKzejKr/fRue +dKW+uzQoiD47Leg5jEwcVSqDZQbWUzqnG5QQVmHUJk4vtTyid2Bz5pJV2dD9vpSpMyT Bl38jdSs/16kPbWX2g/9C4G8tbyaHx8ZgmztmyadkG50zTUQztkaSHK9DHjsE1h7G8Ua D4Ztmk3bZj2MuU9koAvETVgAdEu7ynJjF1VCMfHr75L2G3maOutPGjHsDdmjaCqB3Ha0 DWow== 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=R70u7aKcalBy/OfNQ27Efmy9t/Kzj8CNy0QFYWzkyIg=; b=xP9lRzHSAdvvIGH5+86duQzSgpDasZ/HpvmH1TuuUkzIqhmEziJGmC09vCAQs/XJfK INAwwqV8Lde3ex3Ld+iqRuVI234G6zzs9fxBuKg2pA3eFduTELSi0DuQd9QJWK7lkZLi +oOWDC9P6sy/eaPIoHD4rmd+JkdldXNUc4q8rF0vENuVdhXpHplJGoXwMXKEuvWUuCvh 0FzVAwdxQMBmcq456bRoB8UimGulAEbqgBDW+kPlD1uWVarHMWi4kMSLeloy2bIZuNx2 20DVpRA58Qpqy7LXFD0HsF7bJLLxkT8tpMBoAaDMI4jbf4FJjLsE6Jou8kI1TbRxSPUg FJDQ== X-Gm-Message-State: AOAM5333ob2O6kLI0iLcmJ3lVkl8X3MltLG6uh0sfSMnWleW2uPDmPlX T/V1ao+peSQmZQVEr3q9xDQ= X-Google-Smtp-Source: ABdhPJw1IgUFDGp0uoKhqpfGvW0FjfkaLTJupB0PEcRiLm+MbVXGkcGdILpLntVDoY7cYo5x/NFAZg== X-Received: by 2002:a63:5f07:0:b0:3db:8691:f66e with SMTP id t7-20020a635f07000000b003db8691f66emr10455711pgb.567.1652596948704; Sat, 14 May 2022 23:42:28 -0700 (PDT) Received: from alarm.. ([103.51.72.28]) by smtp.gmail.com with ESMTPSA id g24-20020a170902d5d800b0015e8d4eb2e3sm4568687plh.301.2022.05.14.23.42.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 May 2022 23:42:28 -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 4/6] thermal: exynos: fixed the efuse min/max value for exynos5422 Date: Sun, 15 May 2022 06:41:21 +0000 Message-Id: <20220515064126.1424-5-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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org As per Exynos5422 user manaul e-Fuse range min~max range is 16~76. if e-Fuse value is out of this range, then thermal sensor may not sense thermal data properly. Cc: Bartlomiej Zolnierkiewicz Signed-off-by: Anand Moon --- v1: Fix the commit message --- drivers/thermal/samsung/exynos_tmu.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 58ff1b577c47..0faec0f16db6 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -926,12 +926,14 @@ static int exynos_map_dt_data(struct platform_device *pdev) data->gain = 8; data->reference_voltage = 16; data->efuse_value = 55; - if (data->soc != SOC_ARCH_EXYNOS5420 && - data->soc != SOC_ARCH_EXYNOS5420_TRIMINFO) + if (data->soc == SOC_ARCH_EXYNOS5420 && + data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO) { + data->min_efuse_value = 16; + data->max_efuse_value = 76; + } else { data->min_efuse_value = 40; - else - data->min_efuse_value = 0; - data->max_efuse_value = 100; + data->max_efuse_value = 100; + } break; case SOC_ARCH_EXYNOS5433: data->tmu_set_trip_temp = exynos5433_tmu_set_trip_temp; From patchwork Sun May 15 06:41:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Moon X-Patchwork-Id: 572893 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 374E4C433FE for ; Sun, 15 May 2022 06:42:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235871AbiEOGmk (ORCPT ); Sun, 15 May 2022 02:42:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235880AbiEOGmh (ORCPT ); Sun, 15 May 2022 02:42:37 -0400 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 043592CE0C; Sat, 14 May 2022 23:42:37 -0700 (PDT) Received: by mail-pg1-x52e.google.com with SMTP id 202so11267094pgc.9; Sat, 14 May 2022 23:42:36 -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=jHoiiJnHaNxKGmdGlLTGyX4TUtGSyjY88OutPdITYRg=; b=TXw+i+bQKAdvXrV/lWICdHZCsWSVMpk+d2HPACKk2B6zaN09RH3YvbXXGnyLPeUnAh UwecqpTwVTVeFg0LcSwMIM9hMwYT9mY+90XbciLa/O8d1gHIltBYIXQ4fqzPtP+Tgg/R rwtbAAb6E+Cs+M7ZyGKRz2EYNpE5uwu/vNxoWoFOgm6V2a2AC9Pv3fIIik1tCJt/SLhb 75J58Ohml89s8iHDQ2nkCCjfYhsKiHMei+VN0JZi2dL/U89NeG+9yeT21k3yAiQHQMqd eKouDFbwHvEes25IR2t0xgSUQ77zeAFygXUWxVNvwKuyOnYmxP28jbFBdsFjofxn4tiL xW5A== 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=jHoiiJnHaNxKGmdGlLTGyX4TUtGSyjY88OutPdITYRg=; b=rQOWCbfRjCsj2DHZGTclzN3aGJA9zT/cLSO+Mwnyndi97BP06ZgeqYqyaMzXfySnvz C5x4gdn26NMrG4LJDr1HCJbFKiRaxwowXiSWqYtF0Eari7qFY0QM6RpzZ4rB51c7cL4H vvTyg9TuBlfYXmm0cwAPrZ4qg5oysazbEsyDWrUT28ncS4LbA7aLteAgvvSraxFE2ide +yXXpcww6Aq5Vp2QddlGOqLEqL5J4LcMxzek83Kne3IPWoc1mwUEDYDxxsJ7a0FwRCQW vRo7K12KZbr1p2S8KlRwxDwY1qehI5DSOqdRMe7Y51qPrydpberUN08BeF75RgnGGHw8 0F7A== X-Gm-Message-State: AOAM533igRMhD8gWk8iPvq5s+A71t0six+2DHOSrT2lUYKaLfX/duWpr eXzMmbI1LpiPJigabmdZKoKzpR7r2uNcp8dJ X-Google-Smtp-Source: ABdhPJyVg2kGbF7B3nhQRG6rI1vby0IkE4VgLt98KUxzOmJrd5yLL/6h83HAjfdjuWTewrm7Tsj0vQ== X-Received: by 2002:a05:6a00:98c:b0:50d:f856:53d8 with SMTP id u12-20020a056a00098c00b0050df85653d8mr12020989pfg.49.1652596956582; Sat, 14 May 2022 23:42:36 -0700 (PDT) Received: from alarm.. ([103.51.72.28]) by smtp.gmail.com with ESMTPSA id g24-20020a170902d5d800b0015e8d4eb2e3sm4568687plh.301.2022.05.14.23.42.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 May 2022 23:42:36 -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 5/6] thermal: exynos: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() Date: Sun, 15 May 2022 06:41:22 +0000 Message-Id: <20220515064126.1424-6-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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Use the newlly introduced pm_sleep_ptr() macro, and mark the functions __maybe_unused. These functions can then be moved outside the CONFIG_PM_SUSPEND block, and the compiler can then process them and detect build failures independently of the config. If unused, they will simply be discarded by the compiler. Cc: Bartlomiej Zolnierkiewicz Signed-off-by: Anand Moon --- v1: new patch in this series. --- drivers/thermal/samsung/exynos_tmu.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 0faec0f16db6..f8a527f19383 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -1149,15 +1149,14 @@ static int exynos_tmu_remove(struct platform_device *pdev) return 0; } -#ifdef CONFIG_PM_SLEEP -static int exynos_tmu_suspend(struct device *dev) +static int __maybe_unused exynos_tmu_suspend(struct device *dev) { exynos_tmu_control(to_platform_device(dev), false); return 0; } -static int exynos_tmu_resume(struct device *dev) +static int __maybe_unused exynos_tmu_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); @@ -1169,15 +1168,11 @@ static int exynos_tmu_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(exynos_tmu_pm, exynos_tmu_suspend, exynos_tmu_resume); -#define EXYNOS_TMU_PM (&exynos_tmu_pm) -#else -#define EXYNOS_TMU_PM NULL -#endif static struct platform_driver exynos_tmu_driver = { .driver = { .name = "exynos-tmu", - .pm = EXYNOS_TMU_PM, + .pm = pm_sleep_ptr(&exynos_tmu_pm), .of_match_table = exynos_tmu_match, }, .probe = exynos_tmu_probe, 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: 574133 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 1A5D3C4332F for ; Sun, 15 May 2022 06:42:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235893AbiEOGms (ORCPT ); Sun, 15 May 2022 02:42:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235889AbiEOGmq (ORCPT ); Sun, 15 May 2022 02:42:46 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6F1E2DA93; Sat, 14 May 2022 23:42:44 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id y41so11286373pfw.12; 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=I/FCBW0FE+Y+f0smgt8SoGbvoVK2tnHR7KuHWuaMRa7C2RXGUkrHGn9jHF4Q4jbBeO C34ZFwZOiyOoy0sVDzKrYWl6ReNXGxC8dJ9/dkqHyOSSz/aLtIgBAoWrA5ZG8j5suH/Q Y9lYzQdHsEuNOwPU5IVPps0rIF8b2sFvbeqwqw6UEyrSKO0EGXTljsfK6KSLSAyUVJ6l vLCblO6aUX3oq9X5Xe2ETRxFzFccHHqHcQm3UYyICfiCD92e9CDGi6ILwv1wOuOzsYX/ uLnowzHy/9yIUxIhqp3MyxlV8h8KMvsXQcutJdnlP1hdt4544bvlXzTCPsOlw8mqq3IZ dFzA== X-Gm-Message-State: AOAM532Hr9HK0RZSlk7QERx5K3WMbtjD1/sf9qxKqkIBD/VFlsYYpp/Y 5o+zrOmRyNhqKH4RxfAPlNg= 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.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; }