From patchwork Tue May 30 19:51:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Bernhard_Rosenkr=C3=A4nzer?= X-Patchwork-Id: 101088 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2424049vqr; Tue, 30 May 2023 12:55:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6cYe/3QhyGvTZx9AEdm4A8t5bPgfVsW3g0BlxeKALu65gXScsYKO5GVqRmNbq36Sf/OYxh X-Received: by 2002:a05:6a20:160b:b0:104:35ec:c25c with SMTP id l11-20020a056a20160b00b0010435ecc25cmr4332833pzj.41.1685476555512; Tue, 30 May 2023 12:55:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685476555; cv=none; d=google.com; s=arc-20160816; b=JBYkolwtPUd1jrUo355iwanLtHanwB1D5aVVsRHYgLZKJqajF+gCsjU0KRJggA7JJu Zp7PqZxfhpvRwFmnfuybTM8BYEfypY3gLXjXcxtzycn5U4WAGqva9TyxHU/pju9tGbwG zKGrowwPTevfD+tPADLDWuPoKfRMbiqBCSfqsUGhWHTwoGHcK92+lLwNlA+jCft57XoC gM/X4rUXA9CKGng1xWQiGsOCbS6FHwIitGAFCrFyTI9xSJeGiap9bun8skczOkAzjE0S 2eFjpwt+HfXZL20PmN7bC2qU7gfhXLtZX76IW/nLoP6qFFAOPNpMLBaoOaaP77Uivrwj rBXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Z41wTT110P1GAe0L+S4OKXh20Gfqxsl4liUxJPQgofw=; b=ze9FMqo+wEtGYeMMKseXVmg3v8EB3up81/2woHjq6dTh5eoKi4NlKBpM3fLjGHniSC N7rUzE88OI44rQCOT6GrN3L2LZhnkuCZtzRNFRsbBJmywI4PMe0P4FrukJhxEZIJVFXq PGZqheZxmK7ZQWmfdVEK08HnyUk9P5EF4KpCGRnR/8l3Y7GEi8O9LZzAReHJR3JKMDkH MGBjIptgih2wmpa6uwGeXBhhKbCRUdHVzB+q3wRK2HaBVlx//hP8ahNrtUO8KeqezCDx j90JmjpROaOhfPv77DiQAXswxXDM0aihOERJLGTaFtxu4JYjyZkTBiUIDPDTUku5hWHS 7DxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20221208.gappssmtp.com header.s=20221208 header.b=tEmQmpa4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o11-20020a637e4b000000b0053051c56825si7220900pgn.777.2023.05.30.12.55.43; Tue, 30 May 2023 12:55:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20221208.gappssmtp.com header.s=20221208 header.b=tEmQmpa4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233472AbjE3Tvw (ORCPT + 99 others); Tue, 30 May 2023 15:51:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233417AbjE3Tvl (ORCPT ); Tue, 30 May 2023 15:51:41 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6029107 for ; Tue, 30 May 2023 12:51:38 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-3f6e1393f13so35676435e9.0 for ; Tue, 30 May 2023 12:51:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1685476297; x=1688068297; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Z41wTT110P1GAe0L+S4OKXh20Gfqxsl4liUxJPQgofw=; b=tEmQmpa44HZ/kv6vTlX8wyeO/afOACS5eUcBQq2VJB/P9Q3YypdEbY6cnBK/8GN8bX 6TsjtwoSjliRb37xd9swXOthPTRt9HZjkIJlh1VXVkepdyiVC/hXUaN+Ax1Dsis4Vq7V n1a3Ci1olvT0RHTiDJm+AN67H+F/igCZP2S/93Y/BNs8fB3gf+aMy+64mZ29DqDqgEKb bTPewOBAxf4FvdW6S6/7Vs4npnOP1Jrla9Ok/PybMioQuJweLF/Lpr2vOVo3mKidb+gk Awkwi/vYduXHg0boGmaAzO2yMYJNQ3bvkPhA0OUU8HmGJXnqprqRCbIP5j2aQBQeHqHr fWlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685476297; x=1688068297; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Z41wTT110P1GAe0L+S4OKXh20Gfqxsl4liUxJPQgofw=; b=htF6BQlM6K2G9bvhI3bqtBfzElHAf3aVU8uk3FVIZ7e18oW2n9bC7cVPGReUc344WH xNXlfPzBSQWzqFGvlgLYJ79I+4kcJqMos2qiCSi8kH9u7H4j3zox/8ADsd+/NW6dNQnD nAAqD0/+fjV38vVH6kteEMwwsDoVpSpEvQpSr1Pcm8XgdVVbumClyUZWS+WsLRyzHfBq /DhX6J3eRW1DPPzZYGMWF1Rd6nk71tWWE/YDweufvhwA59Ja2ar5LIkv90KiKGNjRmPH ta5FYyvAiVMZno0Q9dTM7D0ZcYv12zez7kbpschGt+8muCmj0OGuS0SyknHcbUpdEXRK 3+OQ== X-Gm-Message-State: AC+VfDxW8djeqsNm6ooAS4YB5riH0FSYIi+1JzuvYmg0Qhg0EaSapFkH mPPh7r/C68CEByNQaTYvxRaeTg== X-Received: by 2002:a5d:4050:0:b0:309:49e6:9047 with SMTP id w16-20020a5d4050000000b0030949e69047mr2494496wrp.16.1685476297465; Tue, 30 May 2023 12:51:37 -0700 (PDT) Received: from ph18.baylibre (laubervilliers-658-1-213-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.gmail.com with ESMTPSA id n11-20020adfe34b000000b003078cd719ffsm4271545wrj.95.2023.05.30.12.51.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 May 2023 12:51:37 -0700 (PDT) From: =?utf-8?q?Bernhard_Rosenkr=C3=A4nzer?= To: daniel.lezcano@linaro.org, angelogioacchino.delregno@collabora.com, rafael@kernel.org, amitk@kernel.org, rui.zhang@intel.com, matthias.bgg@gmail.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, rdunlap@infradead.org, ye.xingchen@zte.com.cn, p.zabel@pengutronix.de Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, wenst@chromium.org, james.lo@mediatek.com, rex-bc.chen@mediatek.com, nfraprado@collabora.com, abailon@baylibre.com, amergnat@baylibre.com, khilman@baylibre.com Subject: [PATCH v4 2/5] thermal/drivers/mediatek/lvts_thermal: Add suspend and resume Date: Tue, 30 May 2023 21:51:29 +0200 Message-ID: <20230530195132.2286163-3-bero@baylibre.com> X-Mailer: git-send-email 2.41.0.rc2 In-Reply-To: <20230530195132.2286163-1-bero@baylibre.com> References: <20230530195132.2286163-1-bero@baylibre.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767350264451714553?= X-GMAIL-MSGID: =?utf-8?q?1767350264451714553?= From: Balsam CHIHI Add suspend and resume support to LVTS driver. Signed-off-by: Balsam CHIHI Signed-off-by: Bernhard Rosenkränzer Reviewed-by: Matthias Brugger --- drivers/thermal/mediatek/lvts_thermal.c | 34 +++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c index d0a3f95b7884b..5ea8a9d569ea6 100644 --- a/drivers/thermal/mediatek/lvts_thermal.c +++ b/drivers/thermal/mediatek/lvts_thermal.c @@ -1169,6 +1169,38 @@ static int lvts_remove(struct platform_device *pdev) return 0; } +static int lvts_suspend(struct platform_device *pdev, pm_message_t state) +{ + struct lvts_domain *lvts_td; + int i; + + lvts_td = platform_get_drvdata(pdev); + + for (i = 0; i < lvts_td->num_lvts_ctrl; i++) + lvts_ctrl_set_enable(&lvts_td->lvts_ctrl[i], false); + + clk_disable_unprepare(lvts_td->clk); + + return 0; +} + +static int lvts_resume(struct platform_device *pdev) +{ + struct lvts_domain *lvts_td; + int i, ret; + + lvts_td = platform_get_drvdata(pdev); + + ret = clk_prepare_enable(lvts_td->clk); + if (ret) + return ret; + + for (i = 0; i < lvts_td->num_lvts_ctrl; i++) + lvts_ctrl_set_enable(&lvts_td->lvts_ctrl[i], true); + + return 0; +} + static const struct lvts_ctrl_data mt8195_lvts_mcu_data_ctrl[] = { { .cal_offset = { 0x04, 0x07 }, @@ -1268,6 +1300,8 @@ MODULE_DEVICE_TABLE(of, lvts_of_match); static struct platform_driver lvts_driver = { .probe = lvts_probe, .remove = lvts_remove, + .suspend = lvts_suspend, + .resume = lvts_resume, .driver = { .name = "mtk-lvts-thermal", .of_match_table = lvts_of_match,