From patchwork Tue Apr 25 13:30:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balsam CHIHI X-Patchwork-Id: 87404 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3407710vqo; Tue, 25 Apr 2023 06:32:33 -0700 (PDT) X-Google-Smtp-Source: AKy350YzlJikt1xRkx0igVmpIx7faHWNJOcMet22m1PmkXOFGzzWCtpg3XyljKg97ahJlCPqYowo X-Received: by 2002:a17:902:f68c:b0:1a9:736a:5251 with SMTP id l12-20020a170902f68c00b001a9736a5251mr9615099plg.16.1682429553653; Tue, 25 Apr 2023 06:32:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682429553; cv=none; d=google.com; s=arc-20160816; b=oOsP9vwJpbmZOjznuW7dt7rNmGGF1M87PdFKnXYw/WnzsPBwQ+J/7H66TCj4EG0V9K 3SV4ayvpXcTYt88wcpAeNKtqF87vghuv9HkHETpMCrzS6W0waxqs69TnTig5GvSbf3g8 RWfdXOTEXxCvAoT/E35bxVwO2C8ZAOHqBli4nubFMFzfV4u8olEyqgSE+XcKhXDjVKry 3anF106Gmis5MsgBYInDMzjpKL4w6lWNbMJnkNWvQeRQCEWiG1rqDvSDCVcdDH3STjCR 3rDvwNPnb8Zkm3YNElsxsvA/KD69zAJM4T22R3tqFbQw0KlaQxxvQWn7ss1pNtE/mtnW Kn/g== 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=xDyX15c4y3riamcjrdLMF5pPD4/84jZH8J69KsbOpF0=; b=sMmhck5OvBtxVc2bhKoNreYkqcJLGb/cEhGIa8xPs0d5tFsgpBiFug8sxvrhmdYDjD EGLVoYkug+LUBrPqV+fpzLMc3AA0nY7UVvNwLTe3LwW3FNVbXloe/2AkX8kmnns0ltFp wxpb2lrvfFyh48p4sZHtVKPljlwnW8FVSoDUvFFKGW9FNKWmo7me42N4u/+d76l8xhAj 3R4HGP8rmgLkBKq5Z/JOIrtpcTze5W8F+/vTN5WzBmGzwIfR0JSEW2tyBM0o017LmC0E qn9I2JBP2RFhME+M+x7yAxGsbXBsPrCw2PTK9Y2fuglHu/5AY1u5pbmITkyfkvZfxSBd YZFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20221208.gappssmtp.com header.s=20221208 header.b=1OUmbyzN; 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 d12-20020a170903230c00b001a6dfb35f63si14815446plh.385.2023.04.25.06.32.21; Tue, 25 Apr 2023 06:32:33 -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=1OUmbyzN; 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 S234139AbjDYNbI (ORCPT + 99 others); Tue, 25 Apr 2023 09:31:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234024AbjDYNbB (ORCPT ); Tue, 25 Apr 2023 09:31:01 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5133CCC20 for ; Tue, 25 Apr 2023 06:30:58 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3f086770a50so38618825e9.2 for ; Tue, 25 Apr 2023 06:30:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1682429457; x=1685021457; 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=xDyX15c4y3riamcjrdLMF5pPD4/84jZH8J69KsbOpF0=; b=1OUmbyzN0xF/mDJ1gUGkqSjXYr2z+M5aimUYWd9TNVfidYxTNxjh2AtzJkq94h84se F1r6So8ybYynTOFUbiBR+B7R7r3yVfjalof12uKPCrxFGRoR8TBkkRBoBsSEfzttgbxE DeYWaiRnA/NUUATsH8ng8QjPP1ibPa5zg0at9vGqz9DPLlo1RCJJohmyRS1Dt81VNJmq 8e5Qt5oMrzwUpORj3g22uN406FLzpVuyzKaFQZ2spHQHh98Uulw/s1bJHlLbsbkDW5Zb Rg7WPZmU+sWOeDXSS/APn4biXVeKfFF5ZDyGuqLXWeXx6Ee1Nh0GC58fFKtLsZlIn83r s8Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682429457; x=1685021457; 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=xDyX15c4y3riamcjrdLMF5pPD4/84jZH8J69KsbOpF0=; b=OlMtF6Yhj3JA40WUk0DE1bG02H2myk9/zKRmmOXNHUBW1b4VsztvNm0D66zB3oIubN tUyvm12A2EXL7epmhDaMUk1QPoBWU1E/p/zwRB6WrM0AdTqibkZrcVvKXkeKf8A+y9Af oJjaxd/8stHm9r4GNLeLngnM0BsxtJo/AFpNfbVNRmCWv3ttU64CtHxi5aMropJat2UY qCWb7A/qxDY66Jm2lhPOZ5nRQpkcQRuxSiJh3yoFxDVsQQSwFAw1yHdiqaooi+PFp9Ae b8kpvQ2VQKZBMt3nEDHPRpmGrcEOr9CjPYq7sV5lMneIetUxQZUvCW3wMbPzmRVpEdWl Gyjg== X-Gm-Message-State: AAQBX9dWsJBbcsy5oLVb08VpLPQWbvOSRgOzBZ7SCGkrho5gNqEQumQT rBfM+OHHfZH0pUTnyXnAS2nseg== X-Received: by 2002:a5d:4f8e:0:b0:2fb:2567:bc1 with SMTP id d14-20020a5d4f8e000000b002fb25670bc1mr12267998wru.8.1682429456731; Tue, 25 Apr 2023 06:30:56 -0700 (PDT) Received: from localhost.localdomain (laubervilliers-657-1-248-155.w90-24.abo.wanadoo.fr. [90.24.137.155]) by smtp.gmail.com with ESMTPSA id t10-20020a05600c198a00b003f16932fe7dsm18575434wmq.38.2023.04.25.06.30.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Apr 2023 06:30:56 -0700 (PDT) From: bchihi@baylibre.com 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 v2 1/5] thermal/drivers/mediatek/lvts_thermal: Add suspend and resume Date: Tue, 25 Apr 2023 15:30:48 +0200 Message-Id: <20230425133052.199767-2-bchihi@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230425133052.199767-1-bchihi@baylibre.com> References: <20230425133052.199767-1-bchihi@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?1764155251154282534?= X-GMAIL-MSGID: =?utf-8?q?1764155251154282534?= From: Balsam CHIHI Add suspend and resume support to LVTS driver. Signed-off-by: Balsam CHIHI --- 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,