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: 11721821 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 84F5614E3 for ; Tue, 18 Aug 2020 15:48:36 +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 5E36920897 for ; Tue, 18 Aug 2020 15:48:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="SFxnTBfN"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TckO8q8q" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5E36920897 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:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id: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=V1xgm0xz9EM16Bz/RkdTU4tR1Cg1GwOUmyjXSuPm3O0=; b=SFxnTBfNuMFu/HLB3+V7Oy7xbM N5S/OwdUAVY4xROVLmXIFpcqa3Nq0tBtTBf610pN30YIbITDLIvlGkjhwOx8UIdcNtWNeXrjniHvH eg1g9Oqbomc7ZckNcza1bTglFNh8NJ6bY0oh8FjonnY6NzLy6K2ar1NUutL4MtKQp1R8tkxVb4yQG W7zPRsQ89XoDdYSDizlHbQwoByCaG9LyJDBKx0CZQyAbAiMrsMMbsEgBXowZQegyBpZWPsreD6ioq l2E97jmkM/AOQqZabsGyV6eh7WaD5bI/pK36Q2gttjYdcl1yoXvuXWZ9EjbWZtJa7YdZcLluJtaZf 2lIYJczA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k83oz-0007Sh-Ek; Tue, 18 Aug 2020 15:46:45 +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 1k83ow-0007Ru-TK for linux-arm-kernel@lists.infradead.org; Tue, 18 Aug 2020 15:46:43 +0000 Received: by mail-io1-xd42.google.com with SMTP id z6so21626434iow.6 for ; 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=d9GJbyxRM4uGLj+gK2rupCsihSwT6g0ZV3A4jQ2znKGWEluaV7jauryZF2w8fSdJ/G CfpzacB9soILDmr3LigjkfaKxc/bsSMRT3OdY84ZlADd3gQcEofykbV9tiZ4i22GL9j1 K39yLm6fTdko2MhrN1pmmiuMkLiUtm/ALTedWZC8lEzBeIkaqvA6eJGepv6z7xKdHljj /38tP0LX06K3qSJZeeHaH/5eW9FsAlK5aZPrXyDY2aCEfRv0txveknppI3DLNPqIVKsm OWoFbXm/gMhPv7QmmItiM36fR4tE1vXRQUUTuf50ldw8igoA2scVz5Y5eVxEAB6xWKaR bF6A== X-Gm-Message-State: AOAM5338vpW61IECrwiHtDYbDCuCxAqEwbXRNcZxizLeseXWCYX/lavm PmzBP/XS+964t0EhR3gmiEM= 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200818_114642_959742_97DB2A88 X-CRM114-Status: GOOD ( 18.63 ) 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 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [aford173[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -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 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.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_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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, linux-pm@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 MIME-Version: 1.0 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 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; }; /**