From patchwork Mon May 29 16:46:02 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: 100365 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1657114vqr; Mon, 29 May 2023 10:07:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5cNbQqj/QbNeFHxHdifeARtWsvHiTQmJZm6evSElH5bB+BUElcZOmNIe/rZC3w4xX1nXIt X-Received: by 2002:a05:6a20:430c:b0:10c:4c76:e909 with SMTP id h12-20020a056a20430c00b0010c4c76e909mr11034762pzk.8.1685380042012; Mon, 29 May 2023 10:07:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685380041; cv=none; d=google.com; s=arc-20160816; b=uyn+z9R4JOoJPZUjebzpd1I1HDCaZ6fV4iqqbp8edE8AmiN6YQpF+P/90iqByjrMeO 7HlGMxpdam4S5n6XM62q6K+L6jpgCg3oIChHlunljOQBbr9wpgoGquAXLAt3d2BmRLXl QZ6gAB0bLyh2LzLz0/RLHFrC0pCwGlzcpuZjNuu/cyfGgb4vskDHYQy7zQGsFQ0ttHdJ IkfLw26s7ogIQ1uK5OuO3MnL9luwWR+E/fGFwLDcwmjdHCPtgF992o+LRQCZTYrEnp/f AOR/CLLchBujMqWmPPfFhli2O0ESm/8R5+4lVUK4+YYCxnbF3Q/G3gKWH7WP8nS8vwcw o07A== 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=GZ1Pw000YHwunl4UOYUIH6XIIpBvLCqm0y/k6ZseuYk=; b=w/0d2wrBrKKul8rYpBP58Ga3qxFCxeZd+g6pjh/nHFO2L4vjEMn9R7d/QTo3VwUsky fzA1eggQp3mfdhgoPO8ydPzhc3B35r6WwK1qX7hNx2aCowhdoUgwwD7PGrSTBGj02KMd C5rcmld9GqBiM6QWtR9vje/imm4NaNltGzYIcKM/vsGl1U+pWPU1h7Azy+P63MGbyTmK yB5u+LJ2qMI7jxzgPSqBkXYLUkvyoy0+5LXWm5HxfKzxxoFiW107Maf3AW/pVf9xgC62 5x3GwZBp1a3peU/+bI6tc9KcEdcCnjbo25xJawu5AZyGwmCu6cpIOdnTEr0rrN1ulAYJ h9mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20221208.gappssmtp.com header.s=20221208 header.b=deTEIU+p; 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 t4-20020a639544000000b005208c4fa34csi9128693pgn.773.2023.05.29.10.07.09; Mon, 29 May 2023 10:07:21 -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=deTEIU+p; 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 S229582AbjE2QqW (ORCPT + 99 others); Mon, 29 May 2023 12:46:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229580AbjE2QqR (ORCPT ); Mon, 29 May 2023 12:46:17 -0400 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A620CD for ; Mon, 29 May 2023 09:46:14 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-96fbc74fbf1so649481066b.1 for ; Mon, 29 May 2023 09:46:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1685378773; x=1687970773; 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=GZ1Pw000YHwunl4UOYUIH6XIIpBvLCqm0y/k6ZseuYk=; b=deTEIU+pyD3V5mnx/rrEaGu+++V8NuthSZVyNy3qg7qAW7v1bdiAuHp1Ykv4wUMdak sEITqWIa0GT/2rqYOvugqqALSSRd0RVUjiefeGQVIw0wLoa8e+hwbyx+2w1oNF//W7Un BXuQN9qcPNRjHieND/XpY8yaVCXqjH/bMXGpEm8E/v6SQuK2JCOB0KFrRcLdU/v7pTEj EI/mw2e4EWrFO1ixiI2qRQFfaNcig/KQNRdwTN6CbqtiM5EDCUzq8/hCPOICPWOAq9tw 8Q6Ityc22xe4ekw1DhjSIKE7tu0Jvyv+2v80prncLc1QuPfo6T8PloejnKRJqziKOLJj KE8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685378773; x=1687970773; 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=GZ1Pw000YHwunl4UOYUIH6XIIpBvLCqm0y/k6ZseuYk=; b=TX0f2jAoxldgRm6+ROGu+4vOA/sbuCJonJZRDmDK82fphoPsFLO+L8AHlKo16IuVSV LoMVUGurNJ6XOqe/a3PpwFHpqZctGmp6IIEtIyqdYTliG1aBSDeXG9MOgiJKZWL36RUm LXM/3QESqTEq1XdU2KInz5S62gnqVi3T7df4iq0VDP8vdQzWjYzSuukSVVKDLBtfKQME 0VqI/Vlcis7M6DuvWqATrCn+qcnxFjvGFusNa1q0ToenfH8zAazcAi2Yox7xUAxwhEjx 4gasDxG9jo3TUzxq/+jZmhK3AL+Il9laHY8romdRmPbzliqylecr0/jPB4mKdpoqBNb8 BpwA== X-Gm-Message-State: AC+VfDzLFM5G2FfJzxiXbDJDoHfm5mTJHeq3dSDzkiqbI5Fqml+to1wE sFKDdzh6yTA8osZ0ylTL+EzDhw== X-Received: by 2002:a17:907:6093:b0:965:6075:d100 with SMTP id ht19-20020a170907609300b009656075d100mr14795453ejc.39.1685378772810; Mon, 29 May 2023 09:46:12 -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 f4-20020aa7d844000000b0050d89daaa70sm3248578eds.2.2023.05.29.09.46.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 May 2023 09:46:12 -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 v3 2/5] thermal/drivers/mediatek/lvts_thermal: Add suspend and resume Date: Mon, 29 May 2023 18:46:02 +0200 Message-ID: <20230529164605.3552619-3-bero@baylibre.com> X-Mailer: git-send-email 2.41.0.rc2 In-Reply-To: <20230529164605.3552619-1-bero@baylibre.com> References: <20230529164605.3552619-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?1767249062670043671?= X-GMAIL-MSGID: =?utf-8?q?1767249062670043671?= 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,