From patchwork Wed Aug 19 12:59:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Ford X-Patchwork-Id: 11724051 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 214AA14E3 for ; Wed, 19 Aug 2020 13:01:22 +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 EECC2206FA for ; Wed, 19 Aug 2020 13:01:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="fbEkW921"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="H9uu9JET" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EECC2206FA 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=bHXlYiYf/WnAZD3o2oQjmKb0a9jE1Gy5QQ37SzyTQBA=; b=fbEkW921rD24t8XNpQScOB7hni IuS0We6z9aarcqr+mL3uRW5//HIza4c2WD4MHQu5d2o9J9szZTBPSDqBaUjs+8mOZeu7r3aEUqyIy QUDixQXnD2hFNsQOfCzcSqc4P5V6nBnt5SXVAs/QSnXz+ZOsHqDDG+MMV6WOT7JVKPEg51JooJ5Uw 3CIX46iNvfpc0lPObcTsnv8qouUAGynwCIyiwB9Gq/AT8t8NIIYKfO+JvF/5L/QXawplmnpKIvNB1 h27DJGtNQT9A97Efjk2OTTuQobt8E/ES8qXIQeAImNec/KHEGZkQQUh32RnzKmGdZbw9OXDKotDtz VqET87/Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k8Ngo-0001FQ-Of; Wed, 19 Aug 2020 12:59:38 +0000 Received: from mail-io1-xd43.google.com ([2607:f8b0:4864:20::d43]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k8Ngl-0001DL-Rl for linux-arm-kernel@lists.infradead.org; Wed, 19 Aug 2020 12:59:36 +0000 Received: by mail-io1-xd43.google.com with SMTP id s1so11460995iot.10 for ; Wed, 19 Aug 2020 05:59:35 -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=6oVAmZyNrEFZ/qRL/Go1FpkwND3iynaGyrQg/YaoVXg=; b=H9uu9JET+dLKWqo7t/dWEJEOctZhL8wpGr2sXlW4Vb0wn6trZDEN53GJhvvjgJhZIP 659ezdEWF8Z4SwbFa/Asb8VX8m00ejalsigAVz8iJKnKyCI+Y14A0l9BpPcAIV61HTCV uSfB7Cuztw8qjG9OfjCWkBcFv/MC/IwjzPQ7rRo//S533Jp0nMNsR7oulST+XzR+YwnC kmSr1NWBD1FlYBqRwOimkgE9IAGSV+V5ZHP0kBvKwX1FPYgqHSh2pN5JijoMlxiTGLex Fb+pWCudQGBLu2FCBxMHqDJ5M8C1HHIJQcVn0ocp9XUmG7NfOTi/5BXj5i9AOFw+Bd4a 43ww== 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=6oVAmZyNrEFZ/qRL/Go1FpkwND3iynaGyrQg/YaoVXg=; b=PuXlA5JS7BITdZ/yN8NC4t4swXda9wJtx9s3YBnpuZUuoKRH3xDyZjJiQrXGtE9A1u dCtXa6vU917SrcZyUY2u9ROeNfLwmwm6FoW/j+Jy9yBnQa/iSyRlMWNCbzAhcyCBZs9q f2akVDYxdwGS0WwzigbhpYLC82KAFhcl1cK4ysAHMdVTtv4ssRldWoD0iTW/bJBCfUxr e5FjwOUv49Loxow93hzuAO/ObkaoIpB3aS1AYpS8DOoi+coFhc81oaO1KBqQvE0QUKml pC5r64L1LZd3OO9+zLRhFIjnnh4/wZDKntnDMvZ5pzO4PUKQxU8ce3eUJywLpjMBY7to +CTQ== X-Gm-Message-State: AOAM533e75xFOtGQdSPfgE2TzeeFgZ8p+xk2R8OJdbD28/kHwJs8+AzX 9l78mEuCuVsrYpd/oy0xayg= X-Google-Smtp-Source: ABdhPJy7SeHYcvfIBOyXe6sU4+ijHjrvIgF6d7n/mmqAgapcaRBQ/s4uRdGv3Qa2xUjeFQ0kgX8+iA== X-Received: by 2002:a02:3843:: with SMTP id v3mr24082031jae.23.1597841973657; Wed, 19 Aug 2020 05:59:33 -0700 (PDT) Received: from aford-IdeaCentre-A730.lan ([2601:448:8400:9e8:b588:1a5f:55c3:870e]) by smtp.gmail.com with ESMTPSA id i5sm4138388ilc.69.2020.08.19.05.59.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2020 05:59:32 -0700 (PDT) From: Adam Ford To: linux-pm@vger.kernel.org Subject: [PATCH V2 1/2] thermal: ti-soc-thermal: Enable addition power management Date: Wed, 19 Aug 2020 07:59:23 -0500 Message-Id: <20200819125925.2119434-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-20200819_085936_091056_F69ED3A1 X-CRM114-Status: GOOD ( 20.15 ) 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:d43 listed in] [list.dnswl.org] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [aford173[at]gmail.com] 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.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 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 -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from 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 , hns@goldelico.com, Daniel Lezcano , aford@beaconembedded.com, Russell King , Eduardo Valentin , Keerthy , Zhang Rui , linux-omap@vger.kernel.org, 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 --- 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..9404631bea4d 100644 --- a/drivers/thermal/ti-soc-thermal/ti-bandgap.c +++ b/drivers/thermal/ti-soc-thermal/ti-bandgap.c @@ -25,10 +25,18 @@ #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); +static int bandgap_omap_cpu_notifier(struct notifier_block *nb, + unsigned long cmd, void *v); /*** Helper functions to access registers and their bitfields ***/ @@ -1008,6 +1016,9 @@ int ti_bandgap_probe(struct platform_device *pdev) } } + bgp->nb.notifier_call = bandgap_omap_cpu_notifier; + cpu_pm_register_notifier(&bgp->nb); + return 0; remove_last_cooling: @@ -1041,7 +1052,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 +1163,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 +1208,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 Wed Aug 19 12:59:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Ford X-Patchwork-Id: 11724035 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 EB851913 for ; Wed, 19 Aug 2020 13:00:03 +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 C354A206FA for ; Wed, 19 Aug 2020 13:00:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="XmFk3eq6"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FBl+WwvR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C354A206FA 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=sDm+88jLnXpb+jXPDGrP8cHynT4g3UNvs5R7Uk4GeOQ=; b=XmFk3eq6muaCXMtQFZo0WB8jr Qs1f/tMyIxnwIgi/5+Ok3OHlCJkb6iZXNJuD0J9aw1QYoVfBn8g4P5qNfFCVBqM2gn506+vRsu5gw pwsj26lZk6GVWjM4bFhzjITSHdOnT0UocS5vikIBtNwXEpyAz+4ThA/xa+gOVVoUdaDrUfXR4nKMp BuKy/PL+CsxW+W4t5bglq90FnxczBvjnBK/WzR93sQsjbstDjqjbqbwaB14FqzTi5IRhRk1Urp4N1 UN8PF+YIG5kGmp1wXgxlKvYz5DOEToOgdEWdy7T2PZVm6NLG6RTRyMJu9wAAbNT+sM/sj9+oSjx/i kWdbkLJ1g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k8Ngw-0001Hi-3v; Wed, 19 Aug 2020 12:59:46 +0000 Received: from mail-io1-xd43.google.com ([2607:f8b0:4864:20::d43]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k8Ngm-0001Dj-Ll for linux-arm-kernel@lists.infradead.org; Wed, 19 Aug 2020 12:59:37 +0000 Received: by mail-io1-xd43.google.com with SMTP id v6so24467564iow.11 for ; Wed, 19 Aug 2020 05:59:36 -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=NtzkSuCwuVd+0UO9n6oA+BAW4tVVE+zEGyv58T8TdB4=; b=FBl+WwvRGqGnorKLY+KDejdhfQgPSnP1ekvH33MA/ME8GETj8p+yLDx5UHYD8st7Wc 05o982Lz0UMjp/ZrZ5UCXLB4/HbZTywC0H1YmS5I58nLxcCoSbQky5c6U/SwreWXxTEq PpMZX21CdKlOkg5dWPlRVxJ5G1uSNxLbpj5XygJWCjlwzielL07egsxNXKX3yHWTcWz6 D+KN4Fljr5dhFNeMyT+uE1zK1b6nGucRCnbLbULlgIfgyKmdxobG8yJr8r5RAGu2LciP Ufu6kR8RkCsOvon1Hzo9ge+vLW0vwRZRdbSx9cJIbZF+DtTAN9Ujp08IZqX/Kg6QP/h8 K7fA== 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=NtzkSuCwuVd+0UO9n6oA+BAW4tVVE+zEGyv58T8TdB4=; b=Jlx6L+Be+e7hDKDKbVKWKwiK74KByI8AYqhd4u0C1rt8Cz6zJ+zaNdnyPqRuUz2NFx 4moDw4Fjz46wyvu9qtHuv6QETDhkBG9rTP0cHZnlQTXSSLd0MHv54UvtJ7Rfz9JBykd1 J5sPwNpuRkmM7HdQBaBTLoqwRWnxOKF2nYTnv4dMl72opL4cUpCebo73GF3Y7W+Yrb8k TbtZ7gtP4vjFb3WhAh2sL5VOVd0/PZNZwJSM3WvyvrdW01Q4zhAvpYAfngzH5U7oODgt JeiAbLkkmAwWo7A4ML4n8B9E4GBosvgGqO59lHhBHESGWLoEp1q3XOscunlBbys7QpQ/ svoQ== X-Gm-Message-State: AOAM533iisbLKf6Fjxc46vecjgjYpSL/UZxRG1YUVEjvpG+V4u+w9kMN zSr1Nelj0qcIDQlgE3nLhDY= X-Google-Smtp-Source: ABdhPJxoK4y5weKNZKYd6Bo31UrzQruDNpkUn3kcI2PMlwC+ga3JeKSQlr3x0203g5IVWZcE1EWoJA== X-Received: by 2002:a05:6638:1393:: with SMTP id w19mr23503106jad.113.1597841975108; Wed, 19 Aug 2020 05:59:35 -0700 (PDT) Received: from aford-IdeaCentre-A730.lan ([2601:448:8400:9e8:b588:1a5f:55c3:870e]) by smtp.gmail.com with ESMTPSA id i5sm4138388ilc.69.2020.08.19.05.59.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2020 05:59:34 -0700 (PDT) From: Adam Ford To: linux-pm@vger.kernel.org Subject: [PATCH V2 2/2] ARM: omap2plus_defconfig: Enable OMAP3_THERMAL Date: Wed, 19 Aug 2020 07:59:24 -0500 Message-Id: <20200819125925.2119434-2-aford173@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200819125925.2119434-1-aford173@gmail.com> References: <20200819125925.2119434-1-aford173@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200819_085936_737997_AC431EDA X-CRM114-Status: GOOD ( 10.59 ) 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:d43 listed in] [list.dnswl.org] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [aford173[at]gmail.com] 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.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 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 -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from 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 , hns@goldelico.com, Daniel Lezcano , aford@beaconembedded.com, Russell King , Eduardo Valentin , Keerthy , Zhang Rui , linux-omap@vger.kernel.org, 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 --- 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