From patchwork Tue Aug 18 15:46:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Ford X-Patchwork-Id: 11721803 X-Patchwork-Delegate: daniel.lezcano@linaro.org 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 DB72214E3 for ; Tue, 18 Aug 2020 15:47:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C1D472245C for ; Tue, 18 Aug 2020 15:47:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TckO8q8q" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728109AbgHRPrF (ORCPT ); Tue, 18 Aug 2020 11:47:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726752AbgHRPqk (ORCPT ); Tue, 18 Aug 2020 11:46:40 -0400 Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84E62C061389; Tue, 18 Aug 2020 08:46:40 -0700 (PDT) Received: by mail-io1-xd42.google.com with SMTP id b17so21600439ion.7; Tue, 18 Aug 2020 08:46:40 -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; bh=IhRK4si9xEoUVOddxAouxLbNZadm1eVe8xYF5LfxIzI=; b=TckO8q8q9GYYWdaLzHlnObn7mHR35pCqimMAEwUhMPsF+NV+xV4ejpqnKoPqKMSypT I9rU/5J41DIaPz4HTAMJjpDixzfSvnBXc04VLIQhM5qpnZEEvRzp3RbFCNvXzr6Ww3jk ahUxT8/0Exv19xESS+wdDLpFGPiTevIx24ZYNCZZCehuWCYI92TXVxlp3tiPQPiJO0Ru K4BG00OH2+9JsWS8PobPx7L9NqAZMq4ctc5u838x96I/PKQ9E37iHirGcO+qfdK6AlOQ YPwmNkDHaTSREYdWJ95Yo5rR8cXARlsCgoxlrmJr9bre6vrIiCzBUD5lN9d7hNOfWlDi 7uvA== 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; bh=IhRK4si9xEoUVOddxAouxLbNZadm1eVe8xYF5LfxIzI=; b=eMSRZ6WTcunhlr/jxoYEu2EGz6SMOS/IC0mZoxjvv4Augj6qMg+ygkfLYZZdybLQ6Y rCF6OsGocT98+bA/8mb5s8+YZ1k0CbfATSM+s3KchQ3BOvUIpIetHzd2Rko/mxzk/VE8 PipHeMb0PHRfqcAInOBClI28PX9DkQmh1uotjjIPnohF3bEJJpGsAw5Ws3BZ2P6YiZwy tucv6d3MikiyqCntJhUuNpha963vfflWEv0cMBG+xDnmVxXE+hNN+qe0/n9D3jFnr1n2 qbyX8/ufcQ5vy6FY2NK9IC7kaqZiR4At2aDV2rpFDlyruFWQcmC1VzML4YTRjdTS8f1r bp7A== X-Gm-Message-State: AOAM531PkBwaaVVy0xpsI5O4/0NuqmwOhvDufM8DCn00BW+RpN7VfiDz pWWU3G50/GLPWKOST8JhAs34Lb0K8SmPDg== X-Google-Smtp-Source: ABdhPJwhvjO8PItUV55yph5joJ/ppt3vZmd0TDwQG+VHhkUUct6SsNcqDfEBWZNCP2Uo8fBayzx6+Q== X-Received: by 2002:a05:6638:8b:: with SMTP id v11mr19816588jao.122.1597765599365; Tue, 18 Aug 2020 08:46:39 -0700 (PDT) Received: from aford-OptiPlex-7050.logicpd.com ([174.46.170.158]) by smtp.gmail.com with ESMTPSA id z1sm3113625ilh.13.2020.08.18.08.46.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Aug 2020 08:46:38 -0700 (PDT) From: Adam Ford To: linux-omap@vger.kernel.org Cc: aford@beaconembedded.com, Adam Ford , Tony Lindgren , Russell King , Eduardo Valentin , Keerthy , Zhang Rui , Daniel Lezcano , Amit Kucheria , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH 1/2] thermal: ti-soc-thermal: Enable addition power management Date: Tue, 18 Aug 2020 10:46:32 -0500 Message-Id: <20200818154633.5421-1-aford173@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.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 diff --git a/drivers/thermal/ti-soc-thermal/ti-bandgap.c b/drivers/thermal/ti-soc-thermal/ti-bandgap.c index ab19ceff6e2a..923ef3abb867 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); @@ -1153,6 +1166,38 @@ static int ti_bandgap_suspend(struct device *dev) 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); 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 Tue Aug 18 15:46:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Ford X-Patchwork-Id: 11721871 X-Patchwork-Delegate: daniel.lezcano@linaro.org 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 8C1A513B1 for ; Tue, 18 Aug 2020 15:57:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6DBFF22B4B for ; Tue, 18 Aug 2020 15:57:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LTsd1Ljs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728382AbgHRP5y (ORCPT ); Tue, 18 Aug 2020 11:57:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728093AbgHRPqm (ORCPT ); Tue, 18 Aug 2020 11:46:42 -0400 Received: from mail-io1-xd41.google.com (mail-io1-xd41.google.com [IPv6:2607:f8b0:4864:20::d41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8E57C061342; Tue, 18 Aug 2020 08:46:41 -0700 (PDT) Received: by mail-io1-xd41.google.com with SMTP id b17so21600548ion.7; Tue, 18 Aug 2020 08:46:41 -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; bh=gpcsNzkAMDE+NE5CExnC5iIWbWS0MQMV+dfpRNB/riw=; b=LTsd1LjsrCLzPuwc2S7Ages4odkwdUd/orSwwvAaVGSMmkNy2rzr6rxpbZXywiYzmd wRhaoEjAEbvHfBa9PM0FMk/jjghuWw8VOWdA7p3ImauoyymzPLC+AbT+nUvLfO13KGxf PrQFpYM7gDrvoUCoecNEeao9rXU7cprR2MdWerdiNT1MjzICwuybSGauPjzDqjEUxEfm fINxhoIOsH7bNRwheI23g2Ifvgqg3ZINRrlALCC02M2mTfA/G8VB9UzxUbT1WlahPx53 V7Qr1SVW8+uw5akLVM9YgUQxoZfx8PrCcI3SJRxtMVo1yjw42u76YFi/o29VHLLvlkNh DrGg== 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; bh=gpcsNzkAMDE+NE5CExnC5iIWbWS0MQMV+dfpRNB/riw=; b=kN7hw++4kMxQZoHXUIHK09RIj+WlUtst0O1+CsHn4fx8ikXyYDL9sqSZH/CZhaQiwi eL7TWu3kFGasxRU4DqJs4jCu4VQQmZoJecgciU1Oh6eQ8f/+1wf726LGqf0afu8Bg6Tl nM2Lfh+BDHrRyJNukwQp+SmiyUvmUMtlPx/TB4kJjiZheq+9QZwFrE1KhqZmmT18CL5L NynOyNIj3NP5ZIQXwserOPiYUxq8OtsPU9aGQZ7Fqix14GESAbNYH8cONLYd1sdnt8hv DZhTWIKWiNn6DXXiC19vogrX+++EPZ/iS9ZqZeHZwgbaJZ1ss1wxecuKJgbvC4Eei0H9 tMhA== X-Gm-Message-State: AOAM532wnXMWb8ZN9+H1xAbsFIn9v4JYe43PZNr7KDLa/NVen0CbnTYY /yjGlmPYKhM88SQC+oXK307tPLq2Hwqp8A== X-Google-Smtp-Source: ABdhPJwx8qWomQtlosTWe8r6s7ROViav8P/asi0DxBNbpGIMpnE0w4BCLWsczjGwYLtI7jbNca/y5g== X-Received: by 2002:a02:7786:: with SMTP id g128mr19118716jac.45.1597765600813; Tue, 18 Aug 2020 08:46:40 -0700 (PDT) Received: from aford-OptiPlex-7050.logicpd.com ([174.46.170.158]) by smtp.gmail.com with ESMTPSA id z1sm3113625ilh.13.2020.08.18.08.46.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Aug 2020 08:46:40 -0700 (PDT) From: Adam Ford To: linux-omap@vger.kernel.org Cc: aford@beaconembedded.com, Adam Ford , Tony Lindgren , Russell King , Eduardo Valentin , Keerthy , Zhang Rui , Daniel Lezcano , Amit Kucheria , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH 2/2] ARM: omap2plus_defconfig: Enable OMAP3_THERMAL Date: Tue, 18 Aug 2020 10:46:33 -0500 Message-Id: <20200818154633.5421-2-aford173@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200818154633.5421-1-aford173@gmail.com> References: <20200818154633.5421-1-aford173@gmail.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org With the additional power management options enabled, this patch enables OMAP3_THERMAL by default. Signed-off-by: Adam Ford 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