From patchwork Fri Sep 11 16:12:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Kemnade X-Patchwork-Id: 11770891 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 4FE5C13B1 for ; Fri, 11 Sep 2020 16:15:04 +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 1BED220731 for ; Fri, 11 Sep 2020 16:15:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="B1CgwWLU"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kemnade.info header.i=@kemnade.info header.b="V4Nb7efr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1BED220731 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kemnade.info 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=3kTs1gjYbEfhmWk20Ls9mZDPd+StAiPSO+mjnLWuQSs=; b=B1CgwWLU3vDetLC/3cbrvsx942 cohzm3CSsy1wsybdKvjxnibCxfOV6LL3IuZK060AwqXqG2v9tPs8ppoZTTmdTtGdoxFMqdcQc/F6g DpBZbPEJzth1U/speGKG3zFG2S1t/WXLB7f/Km/0csKyCtAb6kzBOPGiftLAD6L1Ku9LbfFyXMiVR MTJfBTIUufl0VJKWW/cyTTQIyzUtPsGE+Oc75l7jxOCWFg1uygKTQhgF/T1xEGCXpaGUhAmsG369K qo7RYeF4M2tv3gFDXjqNXAg50HglK3JU0NKooNsIXIQXJcDVL7FwK1P95IT0jnVUjZx+sPgwFJ4/x vzYuFmZA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGlgB-00045c-PL; Fri, 11 Sep 2020 16:13:39 +0000 Received: from mail.andi.de1.cc ([2a01:238:4321:8900:456f:ecd6:43e:202c]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGlg9-00044m-Jg for linux-arm-kernel@lists.infradead.org; Fri, 11 Sep 2020 16:13:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kemnade.info; s=20180802; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=mieaiSS+0BhtRy+uP0NJAzxIjFSZGneK1DCisX/Obgo=; b=V4Nb7efrp4tZ78hd7CxB4LTZtN ZA1wbO1uxaQZmTjZuaY4lfGJCUGq8E6fiAsLMfsKEA2W9Dyf9clJ/9FXwJLzAt5uUff0PZgrf4n2s w6Lor6ueydCj6SaT+tdNtGo5jUUSjzr88djKbyGHMn7HYwZN5WrzeahAqliHvXghraM8=; Received: from p200300ccff0ce9001a3da2fffebfd33a.dip0.t-ipconnect.de ([2003:cc:ff0c:e900:1a3d:a2ff:febf:d33a] helo=aktux) by mail.andi.de1.cc with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1kGlg1-00023Y-Pa; Fri, 11 Sep 2020 18:13:30 +0200 Received: from andi by aktux with local (Exim 4.92) (envelope-from ) id 1kGlg1-0006dL-3I; Fri, 11 Sep 2020 18:13:29 +0200 From: Andreas Kemnade To: khilman@kernel.org, tony@atomide.com, linux@armlinux.org.uk, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, letux-kernel@openphoenux.org Subject: [PATCH v2] omap3: enable off mode automatically Date: Fri, 11 Sep 2020 18:12:09 +0200 Message-Id: <20200911161209.25149-1-andreas@kemnade.info> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Spam-Score: -1.0 (-) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200911_121337_864983_AC479236 X-CRM114-Status: GOOD ( 18.54 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record 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: Andreas Kemnade Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Enabling off mode was only reachable deeply hidden in the debugfs. As powersaving is an important feature, move the option out of its shady place. The debugfs file can still be used to override the default. Use the presence of a device compatible to ti,twl4030-idle or ti,twl4030-idle-osc-off as an indicator that the board is wired correctly for off mode. Signed-off-by: Andreas Kemnade --- An earlier version of this patch was here: https://patchwork.kernel.org/patch/10794121/ A config option was used instead of the suggested devicetree check. Changes in v2: - fix compile without CONFIG_ARCH_OMAP3 The variable enable_off_mode is now always a real one and not a preprocessor constant to avoid trouble with unusual configurations. arch/arm/mach-omap2/pm-debug.c | 2 -- arch/arm/mach-omap2/pm.c | 2 ++ arch/arm/mach-omap2/pm.h | 4 ---- arch/arm/mach-omap2/pm34xx.c | 25 ++++++++++++++++++++++++- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/arch/arm/mach-omap2/pm-debug.c b/arch/arm/mach-omap2/pm-debug.c index fceb1e525d26..919d35d5b325 100644 --- a/arch/arm/mach-omap2/pm-debug.c +++ b/arch/arm/mach-omap2/pm-debug.c @@ -34,8 +34,6 @@ #include "prm2xxx_3xxx.h" #include "pm.h" -u32 enable_off_mode; - #ifdef CONFIG_DEBUG_FS #include #include diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c index 01ec1ba4878b..da829a90fe8c 100644 --- a/arch/arm/mach-omap2/pm.c +++ b/arch/arm/mach-omap2/pm.c @@ -28,6 +28,8 @@ #include "clockdomain.h" #include "pm.h" +u32 enable_off_mode; + #ifdef CONFIG_SUSPEND /* * omap_pm_suspend: points to a function that does the SoC-specific diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h index 2a883a0c1fcd..80e84ae66aee 100644 --- a/arch/arm/mach-omap2/pm.h +++ b/arch/arm/mach-omap2/pm.h @@ -49,11 +49,7 @@ static inline int omap4_opp_init(void) extern int omap3_pm_get_suspend_state(struct powerdomain *pwrdm); extern int omap3_pm_set_suspend_state(struct powerdomain *pwrdm, int state); -#ifdef CONFIG_PM_DEBUG extern u32 enable_off_mode; -#else -#define enable_off_mode 0 -#endif #if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS) extern void pm_dbg_update_time(struct powerdomain *pwrdm, int prev); diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c index f5dfddf492e2..925b8efbf46c 100644 --- a/arch/arm/mach-omap2/pm34xx.c +++ b/arch/arm/mach-omap2/pm34xx.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -410,7 +411,12 @@ static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused) if (!pwrst) return -ENOMEM; pwrst->pwrdm = pwrdm; - pwrst->next_state = PWRDM_POWER_RET; + + if (enable_off_mode) + pwrst->next_state = PWRDM_POWER_OFF; + else + pwrst->next_state = PWRDM_POWER_RET; + list_add(&pwrst->node, &pwrst_list); if (pwrdm_has_hdwr_sar(pwrdm)) @@ -444,6 +450,21 @@ static void __init pm_errata_configure(void) } } +static void __init omap3_pm_check_pmic(void) +{ + struct device_node *np; + + np = of_find_compatible_node(NULL, NULL, "ti,twl4030-power-idle"); + if (!np) + np = of_find_compatible_node(NULL, NULL, "ti,twl4030-power-idle-osc-off"); + + if (np) { + of_node_put(np); + enable_off_mode = 1; + } else + enable_off_mode = 0; +} + int __init omap3_pm_init(void) { struct power_state *pwrst, *tmp; @@ -477,6 +498,8 @@ int __init omap3_pm_init(void) goto err2; } + omap3_pm_check_pmic(); + ret = pwrdm_for_each(pwrdms_setup, NULL); if (ret) { pr_err("Failed to setup powerdomains\n");