From patchwork Fri Sep 11 12:31:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Ford X-Patchwork-Id: 11770405 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C8BE5618 for ; Fri, 11 Sep 2020 12:33:53 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8D9C0221F1 for ; Fri, 11 Sep 2020 12:33:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="g9OToiH0"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MpdvMpPq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8D9C0221F1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=u0s0JlY/12qW3149Gr6GC8TKEjo7we79uMCvofbV4xM=; b=g9OToiH0hnqKXs2510MwYCoiK7 6PwedfcwIzaNVzxREej0PEnyWW3V7zPG5Z7P/WPpDegIdE8VechzOotwdnE7OC4PfhB1qGy3lAyWA /m1CtB+RlxI6HPljTPh0AdBWsJYtHQfZtmIumhwKMlo0+ASS6+N+RSbGtjXJ2OK5Eh/peEY4Q8kH7 tUV+D0qsY8Kv7dbrA4XTCfzxw/L4aLckAZ2yO6D9k3DvXTVTtbR2LrwPyoxCjc2C2P2i2n0b5ICFp id/M7chgt7U8wcVWpV4yGrcl6WrWyxgpH4wFUrbv/VsJJl36z/ORm8V7hpkplymmq50yjhTA04Gl1 k3PTCXlw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGiDu-0002LU-7r; Fri, 11 Sep 2020 12:32:14 +0000 Received: from mail-il1-x141.google.com ([2607:f8b0:4864:20::141]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGiDr-0002Kb-86 for linux-arm-kernel@lists.infradead.org; Fri, 11 Sep 2020 12:32:12 +0000 Received: by mail-il1-x141.google.com with SMTP id q6so8763998ild.12 for ; Fri, 11 Sep 2020 05:32:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ugTNUn8mm2Ku6DfVm6vxHRWJ3JTBU9LWayGqG53mxMw=; b=MpdvMpPqMKWBctHOkuDpfxbTZK3NqQSwG0yCiF+ibrvu2DHy4mZCcuQx8xzubGiltk fXkGxi9AehKRLwp0zIARnb4WngxM54WeeCagnuDxR29D12RJa1RwACdiwe9q5YMfIJYN ZcUEatOXvTiO9nfXsyZEkNS2co1OVbLzgigfJdoFzuimQ1Fn9s8sKghAhXBZQAx/OENo ziWEcXeoXQ1OdBgW99Ypps/x+fb6rEHBfc6A6iBRcPKTcTtOrep0VtJ0hv/Kg6weibPT Wds0+wkvGyF/NhDJYTE+ScXFZX1lSo4xa05qmXHg/0sC/uX7kHss/xGwC1pxVFNmeCA2 QpGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ugTNUn8mm2Ku6DfVm6vxHRWJ3JTBU9LWayGqG53mxMw=; b=TGWE/bTMheYj725vJbLzReHV1/qW9NIRdAl1fa4Dw4moDZRRo1WWcY8qogclnksNs5 Ho7uFQALbov3xgO19xx1nZBYyApTGVxVE3RFcRweePewSMfTIj33OhI6Gdd+iVefNRcz WDn7URZWVBK26ziCQzKgRkCPhNb8osO7t1FG7hjm3dzX3gXVIjOvAS8kv5RkpmSQVJLx dCejcgL5lCfgM7jD1eW51WJGGownmMNFQzFJNlrmyxW8zuyLJfZAvcvqbo+OnmSbR8lS asIMbPMxqFlWYcrVDrvhSq/CFV4VVkGbvi4C49tRbnUCW01N9cXKEE3OKhzTdS9pQVP6 fy4w== X-Gm-Message-State: AOAM531axCTWYve4XJbdYODxdPyZNxAuxJwDC+fuASt5jWRRq6DkfO1w yZ39PUZBnzwyyvEIPubLE0U= X-Google-Smtp-Source: ABdhPJxl2ZwcqutABattNSET4QKwUd7/IzX1WiTFxtg4ligGakYCwNb+FcHWlik94jksPpHtKPkWvw== X-Received: by 2002:a92:9646:: with SMTP id g67mr1536585ilh.116.1599827529114; Fri, 11 Sep 2020 05:32:09 -0700 (PDT) Received: from aford-IdeaCentre-A730.lan (mn-10k-dhcp7-1791.dsl.hickorytech.net. [68.232.239.6]) by smtp.gmail.com with ESMTPSA id m18sm1144277iln.80.2020.09.11.05.32.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 05:32:08 -0700 (PDT) From: Adam Ford To: linux-pm@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH 1/2] thermal: ti-soc-thermal: Enable addition power management Date: Fri, 11 Sep 2020 07:31:56 -0500 Message-Id: <20200911123157.759379-1-aford173@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200911_083211_308247_6490D26C X-CRM114-Status: GOOD ( 20.51 ) X-Spam-Score: 0.1 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:141 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [aford173[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [aford173[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amit Kucheria , linux-kernel@vger.kernel.org, kernel test robot , Tony Lindgren , Keerthy , Daniel Lezcano , Russell King , aford@beaconembedded.com, Eduardo Valentin , Andreas Kemnade , Zhang Rui , Adam Ford , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The bandgap sensor can be idled when the processor is too, but it isn't currently being done, so the power consumption of OMAP3 boards can elevated if the bangap sensor is enabled. This patch attempts to use some additional power management to idle the clock to the bandgap when not needed. Signed-off-by: Adam Ford Reported-by: kernel test robot Tested-by: Andreas Kemnade # GTA04 --- V3: bandgap_omap_cpu_notifier is only defined when CONFIG_PM_SLEEP is enabled, so make all references to it also depend on CONFIG_PM_SLEEP as well V2: Fix issue where variable stating the suspend mode isn't being properly set and cleared. diff --git a/drivers/thermal/ti-soc-thermal/ti-bandgap.c b/drivers/thermal/ti-soc-thermal/ti-bandgap.c index ab19ceff6e2a..5e596168ba73 100644 --- a/drivers/thermal/ti-soc-thermal/ti-bandgap.c +++ b/drivers/thermal/ti-soc-thermal/ti-bandgap.c @@ -25,10 +25,20 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include "ti-bandgap.h" static int ti_bandgap_force_single_read(struct ti_bandgap *bgp, int id); +#ifdef CONFIG_PM_SLEEP +static int bandgap_omap_cpu_notifier(struct notifier_block *nb, + unsigned long cmd, void *v); +#endif /*** Helper functions to access registers and their bitfields ***/ @@ -1008,6 +1018,11 @@ int ti_bandgap_probe(struct platform_device *pdev) } } +#ifdef CONFIG_PM_SLEEP + bgp->nb.notifier_call = bandgap_omap_cpu_notifier; + cpu_pm_register_notifier(&bgp->nb); +#endif + return 0; remove_last_cooling: @@ -1041,7 +1056,9 @@ int ti_bandgap_remove(struct platform_device *pdev) struct ti_bandgap *bgp = platform_get_drvdata(pdev); int i; - /* First thing is to remove sensor interfaces */ + cpu_pm_unregister_notifier(&bgp->nb); + + /* Remove sensor interfaces */ for (i = 0; i < bgp->conf->sensor_count; i++) { if (bgp->conf->sensors[i].unregister_cooling) bgp->conf->sensors[i].unregister_cooling(bgp, i); @@ -1150,9 +1167,43 @@ static int ti_bandgap_suspend(struct device *dev) if (TI_BANDGAP_HAS(bgp, CLK_CTRL)) clk_disable_unprepare(bgp->fclock); + bgp->is_suspended = true; + return err; } +static int bandgap_omap_cpu_notifier(struct notifier_block *nb, + unsigned long cmd, void *v) +{ + struct ti_bandgap *bgp; + + bgp = container_of(nb, struct ti_bandgap, nb); + + spin_lock(&bgp->lock); + switch (cmd) { + case CPU_CLUSTER_PM_ENTER: + if (bgp->is_suspended) + break; + ti_bandgap_save_ctxt(bgp); + ti_bandgap_power(bgp, false); + if (TI_BANDGAP_HAS(bgp, CLK_CTRL)) + clk_disable(bgp->fclock); + break; + case CPU_CLUSTER_PM_ENTER_FAILED: + case CPU_CLUSTER_PM_EXIT: + if (bgp->is_suspended) + break; + if (TI_BANDGAP_HAS(bgp, CLK_CTRL)) + clk_enable(bgp->fclock); + ti_bandgap_power(bgp, true); + ti_bandgap_restore_ctxt(bgp); + break; + } + spin_unlock(&bgp->lock); + + return NOTIFY_OK; +} + static int ti_bandgap_resume(struct device *dev) { struct ti_bandgap *bgp = dev_get_drvdata(dev); @@ -1161,6 +1212,7 @@ static int ti_bandgap_resume(struct device *dev) clk_prepare_enable(bgp->fclock); ti_bandgap_power(bgp, true); + bgp->is_suspended = false; return ti_bandgap_restore_ctxt(bgp); } diff --git a/drivers/thermal/ti-soc-thermal/ti-bandgap.h b/drivers/thermal/ti-soc-thermal/ti-bandgap.h index fce4657e9486..ed0ea4b17b25 100644 --- a/drivers/thermal/ti-soc-thermal/ti-bandgap.h +++ b/drivers/thermal/ti-soc-thermal/ti-bandgap.h @@ -12,6 +12,10 @@ #include #include #include +#include +#include +#include +#include struct gpio_desc; @@ -203,6 +207,8 @@ struct ti_bandgap { int irq; struct gpio_desc *tshut_gpiod; u32 clk_rate; + struct notifier_block nb; + unsigned int is_suspended:1; }; /** From patchwork Fri Sep 11 12:31:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Ford X-Patchwork-Id: 11770395 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 12174618 for ; Fri, 11 Sep 2020 12:33:44 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D54A1221F1 for ; Fri, 11 Sep 2020 12:33:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Sm31EMcT"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lc6n1Kaa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D54A1221F1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=O6a3EmgH5xKNEN5SDxHmYzbpXT75noq82CUTDFSWDbg=; b=Sm31EMcTiFyDhjx1fZQZIAU2l s1FEvXyVxVsLt+/W2YWMT7T36Y5X8tXFiVXabMObA4h37+hkxVj4r0hZoq7vG9kHKWsoYUhYVkeqA FmheAqKJk0QI6HtTkPQRZ/jZeJBnZVXKB6KzdK68EuQCRrgUzMUnwqwSlok0SiqOGyxt0CK6KnyiW ndYskNUXvqR5YyYRdTuguT6vVi2mCc2tmYGKWTvxWHxZgQKLfjRkcOBZdhVN1IqizIO8d5OAie/4j xqzupkoPzS7tFAOvxqSGFq1OYHUPf/SHaltULpgsA9JXCfnj0ZpXgUYDtupk1bZdBDjrhR3OUGaTs 42UQ91yXA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGiDx-0002M3-Mt; Fri, 11 Sep 2020 12:32:17 +0000 Received: from mail-io1-xd42.google.com ([2607:f8b0:4864:20::d42]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGiDs-0002Ky-QX for linux-arm-kernel@lists.infradead.org; Fri, 11 Sep 2020 12:32:13 +0000 Received: by mail-io1-xd42.google.com with SMTP id b6so10786880iof.6 for ; Fri, 11 Sep 2020 05:32:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0Sb49eUm0XrlnNsnZsPLqQ9U00n3jcPCCGAV2VtAgHI=; b=lc6n1Kaa/wF17ufcjPO/ngCuQ9lEKwpFewkLAgOal4k3oEFKEtZXMsHExvbErNgW4Y /1yhBN0xNaa+MvorWG4lj5SgsR6MdfF97Xtp1GEdGm9fV4Awomp/ru6KijDP0c4hG/Wo 1LLBcfx1S56swAtpr2fddq3hE/WBos01siWq1ERI6zlYru2wPoqsvsuG55A7aqM5kxWG 3GnBfYI+/97INTUmjaNNR03oi7Abq+XsngKHVdNdDWJEBj0tBn2BjHxQ8Zr/mvsAW9Sa Bk9J6QJro6g5qnkb7vr8feWI4WjANL81MGy1wd9ibe/CjgF4nOzi4Me+SuBVq9DABK82 exbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0Sb49eUm0XrlnNsnZsPLqQ9U00n3jcPCCGAV2VtAgHI=; b=WB0S1ShZEIRZ9ZWMZJrxUm8bQhKJk2zqEzhOQK+TxYqoSBiby+xiWJDXpdkgqZtt6S w9C8tghUNqdushSIAy7JuUZZioC541Rb0vqIy1g7OMe//OV243+Gf4HYgTwGYqQwm81i q1R4fRe8DDuu/SzQBgcNuTLaZpxlHW75rVdHTUzgOovCAbalxWpgRTvLafJ3IdV3uUIe da+CldQlS5Qp9jVIXslOPnnZp8/2lq+phZM+HKIjqbNdMS3wx8NoLE7OVl/Lf24sAK/s lnQXs0NZZQLdyTTr0ZAcQKLieCCcNnKisF2sBGwyGKLdV39qLArdBABB/MusrxM1OB2U HBnw== X-Gm-Message-State: AOAM532cyyTvVDBnQz+BUtFM/1anRqbPlLHJ8Ifw7MwuI+NBbTv8riEi 7Ocyuec13RT9ddwYwbuHVY8= X-Google-Smtp-Source: ABdhPJzHNqR+nZ6mQlao/3kciscoqAvYhSU0szgSBUbX1aqkqbfkR1HY4Kh8e/C90MsLYuX+4vS2Jg== X-Received: by 2002:a6b:9305:: with SMTP id v5mr1503265iod.201.1599827530934; Fri, 11 Sep 2020 05:32:10 -0700 (PDT) Received: from aford-IdeaCentre-A730.lan (mn-10k-dhcp7-1791.dsl.hickorytech.net. [68.232.239.6]) by smtp.gmail.com with ESMTPSA id m18sm1144277iln.80.2020.09.11.05.32.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 05:32:10 -0700 (PDT) From: Adam Ford To: linux-pm@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH 2/2] ARM: omap2plus_defconfig: Enable OMAP3_THERMAL Date: Fri, 11 Sep 2020 07:31:57 -0500 Message-Id: <20200911123157.759379-2-aford173@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200911123157.759379-1-aford173@gmail.com> References: <20200911123157.759379-1-aford173@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200911_083212_884909_6731C38A X-CRM114-Status: GOOD ( 10.28 ) X-Spam-Score: 0.1 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:d42 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [aford173[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [aford173[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amit Kucheria , linux-kernel@vger.kernel.org, Tony Lindgren , Keerthy , Daniel Lezcano , aford@beaconembedded.com, Russell King , Eduardo Valentin , Zhang Rui , Adam Ford , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org With the additional power management options enabled, this patch enables OMAP3_THERMAL by default. Signed-off-by: Adam Ford --- V3: No change V2: No change diff --git a/arch/arm/configs/omap2plus_defconfig b/arch/arm/configs/omap2plus_defconfig index fe383f5a92fb..efcc46305a47 100644 --- a/arch/arm/configs/omap2plus_defconfig +++ b/arch/arm/configs/omap2plus_defconfig @@ -303,6 +303,7 @@ CONFIG_THERMAL_GOV_FAIR_SHARE=y CONFIG_THERMAL_GOV_USER_SPACE=y CONFIG_CPU_THERMAL=y CONFIG_TI_THERMAL=y +CONFIG_OMAP3_THERMAL=y CONFIG_OMAP4_THERMAL=y CONFIG_OMAP5_THERMAL=y CONFIG_DRA752_THERMAL=y