From patchwork Mon Aug 3 07:25:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 11697511 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 BA415722 for ; Mon, 3 Aug 2020 07:27:15 +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 92716206E2 for ; Mon, 3 Aug 2020 07:27:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="F9Rxnlvn"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="PKRTGJsV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 92716206E2 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=microchip.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=hxvDnWyQdrQ+ioX0AI9imFPxvoKGILZ1tX8tKadNTC0=; b=F9RxnlvnIG/lks1VwUpzq9j1Q 2Yzt2uf7htgvY1Hn1TWzYU/0/caz+V340HwF6R33YtK64vCK7vwltwzXuGRV5uZgMyTytMRMtJXVS LA7ghYzsH1/w9H1nG1rVVo1X8dtBjsHsRijDzVwdNe0i/VTmLEuDo42qfmIFRUTQNv4PEwPZbllzN E+uqvzDOze4SqN7skABPXXxVIMMyHi1IF6G4Ai0i/9YGUDJEQoTBh2NSz9l3yRsNCGdbTKDwGtwVZ PWC6b6WiXmX1BEPPDa2oHXoPocm5kVtzIoC28TSog9COs416jzrHX7cRcBGEpVLrh6iIeYbpW/azG d9pMdYQbA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k2Uqj-0000j4-GD; Mon, 03 Aug 2020 07:25:33 +0000 Received: from esa3.microchip.iphmx.com ([68.232.153.233]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k2Uqf-0000hN-Fg for linux-arm-kernel@lists.infradead.org; Mon, 03 Aug 2020 07:25:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1596439529; x=1627975529; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=FiWLYOAdV1lwBOPSXO+yNFoXeb/CDTvo5oQEMUUm8Cc=; b=PKRTGJsV7Mvx1DjV1FO53DSkwoeVpLWanzQc1C1ggBcOZy2hGQuGzG9S lCNZg84OStoElDuiTVtgkpQGumq/ME+c6JjTh9iF4zOaBXgyKsgprws2k V3Q5UVR7T6gs/a+xsVEH+iA/fBM2mxaGY3O8QDr50S1yzxZMJiTrtLsnm Eccw7kKOho2p4g4OecwCtxPDeYkltyHmhxst8EPsl7ttCTdyDX011eByQ v/Fk8OgCD4VJN+8MuAD/D+kop9bZ0u936kAsY3ppH/neV2RY8FPDHn7Lt 6LoG8gawEGjynSIlxuQT3P+1DZBoD2kXZR+qFaC/P6czvL2W9CVkJvotb A==; IronPort-SDR: I8Aohz9CRjnZcar6IRgE7m/mykp72h0JJrg/bg02GR6/sy0Y1wMbcMqUX5MhpqmPEAv4B0ahzz QxMzYf74ye811wOhU35N0p/+EnsKhlhoGIsdpdhAquerN1q5UivemhHY9ovwyBa/sRUMG/8bF2 t2WOdZvbyGaml6MmGBJvC5pveUjCIs17r1hs9dEr2zHF+/JKAyesh3/XsDzV8H4LDvVoqetA/t mvWbgmH3nw0X9BdhArsUJrCt+V3zeC7NUZjeYYxG+FBEQT9dwG8HfeBCK2ycdKzWc1zrohsbTq VQY= X-IronPort-AV: E=Sophos;i="5.75,429,1589266800"; d="scan'208";a="86388015" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 03 Aug 2020 00:25:26 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Mon, 3 Aug 2020 00:25:24 -0700 Received: from m18063-ThinkPad-T460p.microchip.com (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Mon, 3 Aug 2020 00:25:24 -0700 From: Claudiu Beznea To: , , Subject: [PATCH 1/3] ARM: at91: pm: add support for ulp0 fast mode Date: Mon, 3 Aug 2020 10:25:15 +0300 Message-ID: <1596439517-12993-2-git-send-email-claudiu.beznea@microchip.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1596439517-12993-1-git-send-email-claudiu.beznea@microchip.com> References: <1596439517-12993-1-git-send-email-claudiu.beznea@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200803_032529_677308_E7066735 X-CRM114-Status: GOOD ( 14.65 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [68.232.153.233 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [68.232.153.233 listed in wl.mailspike.net] -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 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders 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: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Claudiu Beznea Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org ULP0 fast improves suspend/resume time with few milliseconds the drawback being the power consumption. The mean values measured for suspend/resume time are as follows (measured on SAMA5D2 Xplained board), ULP0 compared with ULP0 fast: - ulp0 fast: suspend time: 169 ms, resume time: 216 ms - ulp0 : suspend time: 197 ms, resume time: 258 ms Current consumption while suspended (measured on SAMA5D2 Xplained board): - ulp0 fast: 730uA - ulp0 : 270uA Signed-off-by: Claudiu Beznea --- arch/arm/mach-at91/pm.c | 9 +++++---- arch/arm/mach-at91/pm.h | 5 +++-- arch/arm/mach-at91/pm_suspend.S | 41 +++++++++++++++++++++++++++++++++++++---- 3 files changed, 45 insertions(+), 10 deletions(-) diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index 074bde64064e..04fdcbd57100 100644 --- a/arch/arm/mach-at91/pm.c +++ b/arch/arm/mach-at91/pm.c @@ -51,10 +51,11 @@ static struct at91_soc_pm soc_pm = { }; static const match_table_t pm_modes __initconst = { - { AT91_PM_STANDBY, "standby" }, - { AT91_PM_ULP0, "ulp0" }, - { AT91_PM_ULP1, "ulp1" }, - { AT91_PM_BACKUP, "backup" }, + { AT91_PM_STANDBY, "standby" }, + { AT91_PM_ULP0, "ulp0" }, + { AT91_PM_ULP0_FAST, "ulp0-fast" }, + { AT91_PM_ULP1, "ulp1" }, + { AT91_PM_BACKUP, "backup" }, { -1, NULL }, }; diff --git a/arch/arm/mach-at91/pm.h b/arch/arm/mach-at91/pm.h index 218e8d1a30fb..bfb260be371e 100644 --- a/arch/arm/mach-at91/pm.h +++ b/arch/arm/mach-at91/pm.h @@ -19,8 +19,9 @@ #define AT91_PM_STANDBY 0x00 #define AT91_PM_ULP0 0x01 -#define AT91_PM_ULP1 0x02 -#define AT91_PM_BACKUP 0x03 +#define AT91_PM_ULP0_FAST 0x02 +#define AT91_PM_ULP1 0x03 +#define AT91_PM_BACKUP 0x04 #ifndef __ASSEMBLY__ struct at91_pm_data { diff --git a/arch/arm/mach-at91/pm_suspend.S b/arch/arm/mach-at91/pm_suspend.S index be9764e8d3fa..0184de05c1be 100644 --- a/arch/arm/mach-at91/pm_suspend.S +++ b/arch/arm/mach-at91/pm_suspend.S @@ -164,7 +164,22 @@ ENDPROC(at91_backup_mode) .macro at91_pm_ulp0_mode ldr pmc, .pmc_base + ldr tmp2, .pm_mode + ldr tmp3, .mckr_offset + + /* Check if ULP0 fast variant has been requested. */ + cmp tmp2, #AT91_PM_ULP0_FAST + bne 0f + + /* Set highest prescaler for power saving */ + ldr tmp1, [pmc, tmp3] + bic tmp1, tmp1, #AT91_PMC_PRES + orr tmp1, tmp1, #AT91_PMC_PRES_64 + str tmp1, [pmc, tmp3] + wait_mckrdy + b 1f +0: /* Turn off the crystal oscillator */ ldr tmp1, [pmc, #AT91_CKGR_MOR] bic tmp1, tmp1, #AT91_PMC_MOSCEN @@ -192,7 +207,18 @@ ENDPROC(at91_backup_mode) /* Wait for interrupt */ 1: at91_cpu_idle - /* Restore RC oscillator state */ + /* Check if ULP0 fast variant has been requested. */ + cmp tmp2, #AT91_PM_ULP0_FAST + bne 5f + + /* Set lowest prescaler for fast resume. */ + ldr tmp1, [pmc, tmp3] + bic tmp1, tmp1, #AT91_PMC_PRES + str tmp1, [pmc, tmp3] + wait_mckrdy + b 6f + +5: /* Restore RC oscillator state */ ldr tmp1, .saved_osc_status tst tmp1, #AT91_PMC_MOSCRCS beq 4f @@ -216,6 +242,7 @@ ENDPROC(at91_backup_mode) str tmp1, [pmc, #AT91_CKGR_MOR] wait_moscrdy +6: .endm /** @@ -473,23 +500,29 @@ ENDPROC(at91_backup_mode) ENTRY(at91_ulp_mode) ldr pmc, .pmc_base ldr tmp2, .mckr_offset + ldr tmp3, .pm_mode /* Save Master clock setting */ ldr tmp1, [pmc, tmp2] str tmp1, .saved_mckr /* - * Set the Master clock source to slow clock + * Set master clock source to: + * - MAINCK if using ULP0 fast variant + * - slow clock, otherwise */ bic tmp1, tmp1, #AT91_PMC_CSS + cmp tmp3, #AT91_PM_ULP0_FAST + bne save_mck + orr tmp1, tmp1, #AT91_PMC_CSS_MAIN +save_mck: str tmp1, [pmc, tmp2] wait_mckrdy at91_plla_disable - ldr r0, .pm_mode - cmp r0, #AT91_PM_ULP1 + cmp tmp3, #AT91_PM_ULP1 beq ulp1_mode at91_pm_ulp0_mode From patchwork Mon Aug 3 07:25:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 11697513 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 599B4722 for ; Mon, 3 Aug 2020 07:27:19 +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 25B5E206E2 for ; Mon, 3 Aug 2020 07:27:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="CpbxKsGO"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="ganv1XIP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 25B5E206E2 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=microchip.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=s13Blm/NxF7LIjSw/NoZkisbk6zoYpBFnEzhW8KwcRg=; b=CpbxKsGOAginBsRp6lz6bPijj ZO7BaAgyZuHjsEwNvEwYVUjjSjvJXkQQVFVejoUx9SFAU6gFHsB+maopfkdS2vwZjr+T65PVdb26U cRNnQ5davIF48icO4ZwMXdU14VOfUXl6oQ6V2i0G9brNUxehcB5RGDkYB12dBrW6cdsnr8rKBSWAl JMAPRaMvB4GpcRTSWzbZ8xSYdZhvOIwtY+I4V5CLLTOg+CsZJCbp0iMj94ULc2BrATnHzPyQA26a8 USYYiFmE9eo9ymS7JAR1dgPtWzuUZJCbeiNQBjQuEEralG8B26TSncwSUGavnacjNGqH9LeLa8OSr sO7xKYALg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k2Uql-0000jk-Rz; Mon, 03 Aug 2020 07:25:35 +0000 Received: from esa6.microchip.iphmx.com ([216.71.154.253]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k2Uqg-0000gx-1b for linux-arm-kernel@lists.infradead.org; Mon, 03 Aug 2020 07:25:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1596439529; x=1627975529; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=nxv/i0poXFykdLHREa4T6R3yBNxPXfCtmRSibFbJH4g=; b=ganv1XIPmHY/6JLvr1qf7DK7nGyex7aa+I3LYXK0UlLBcPm2Pi8eI1t5 CLoru6h8xbgYrmR3fYDy09n1FVVkujw+rehynW7q+qlZ4NmWrJu4ixUS+ NV0TDaVr5rVAJFeE6s+9yJ+1H9jCpbZ9KJ5zWKAzfo60KsrSgAEBt+G5m /I9B+e3tS5kKh0y7t906VHWaYgGtjcJrOpf9xj4ctBBa2M/UOOKQuFoKM ciR+PdyZ4yrvxtMvBMryEPtZLCadp5pd9/AbNPwNVDSplWA7cB0dJf+Wg ztv5IKo4lOCcHizdNLRpx/kADuoLinNKqPAq/ooP7brZfL68eknMvCTHs Q==; IronPort-SDR: oRhJcP2e8RoQFonOz67gWe8V5n/9FSDMVCPjPywu+2xO+kerSwqcszs4fcmXnXvpp/W0VuJZ3v nPsyQuAHWZdy2WdhgLf7K4MGCadSRKBZaR4NdlQKRpkSllo8gHuLM8NTtIaHFpxTLvy59w6I4m eH+KAnwy/r/p21d2uk33HVdSy7fyn062XZyDS/lR2D/lPvHCPPRQUZm/cDZU5GTuWh9U6SKZ7d IiA+QPaVginM4Z4G40b/9AKtuzcy2YY0+SDbGCALucaHDwJRSimkjDGREM3y5WQWk/OpYZ/btA GC0= X-IronPort-AV: E=Sophos;i="5.75,429,1589266800"; d="scan'208";a="21509737" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 03 Aug 2020 00:25:29 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Mon, 3 Aug 2020 00:25:29 -0700 Received: from m18063-ThinkPad-T460p.microchip.com (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Mon, 3 Aug 2020 00:25:26 -0700 From: Claudiu Beznea To: , , Subject: [PATCH 2/3] ARM: at91: pm: add per soc validation of pm modes Date: Mon, 3 Aug 2020 10:25:16 +0300 Message-ID: <1596439517-12993-3-git-send-email-claudiu.beznea@microchip.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1596439517-12993-1-git-send-email-claudiu.beznea@microchip.com> References: <1596439517-12993-1-git-send-email-claudiu.beznea@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200803_032530_356967_FDE4EED3 X-CRM114-Status: GOOD ( 18.58 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.154.253 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [216.71.154.253 listed in wl.mailspike.net] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -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 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -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: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Claudiu Beznea Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Not all SoCs supports all the PM mode. User may end up settings, e.g. backup mode, on a non SAMA5D2 device, but the mode to not be valid. If backup mode is used on a devices not supporting it there will be no way of resuming other than rebooting. Signed-off-by: Claudiu Beznea --- arch/arm/mach-at91/at91rm9200.c | 10 +++++- arch/arm/mach-at91/at91sam9.c | 9 +++++- arch/arm/mach-at91/generic.h | 20 ++++++------ arch/arm/mach-at91/pm.c | 69 +++++++++++++++++++++++++++++++++++++---- arch/arm/mach-at91/sam9x60.c | 11 ++++++- arch/arm/mach-at91/sama5.c | 21 +++++++++++-- 6 files changed, 119 insertions(+), 21 deletions(-) diff --git a/arch/arm/mach-at91/at91rm9200.c b/arch/arm/mach-at91/at91rm9200.c index 4f8186211619..7318d8e16797 100644 --- a/arch/arm/mach-at91/at91rm9200.c +++ b/arch/arm/mach-at91/at91rm9200.c @@ -13,12 +13,20 @@ #include #include "generic.h" +#include "pm.h" + +/* AT91RM9200 valid PM modes. */ +static const int at91rm9200_pm_modes[] = { + AT91_PM_STANDBY, + AT91_PM_ULP0, +}; static void __init at91rm9200_dt_device_init(void) { of_platform_default_populate(NULL, NULL, NULL); - at91rm9200_pm_init(); + at91rm9200_pm_init(at91rm9200_pm_modes, + ARRAY_SIZE(at91rm9200_pm_modes)); } static const char *const at91rm9200_dt_board_compat[] __initconst = { diff --git a/arch/arm/mach-at91/at91sam9.c b/arch/arm/mach-at91/at91sam9.c index 7e572189a5eb..683f2c35a116 100644 --- a/arch/arm/mach-at91/at91sam9.c +++ b/arch/arm/mach-at91/at91sam9.c @@ -13,12 +13,19 @@ #include #include "generic.h" +#include "pm.h" + +/* AT91SAM9 valid PM modes. */ +static const int at91sam9_pm_modes[] = { + AT91_PM_STANDBY, + AT91_PM_ULP0, +}; static void __init at91sam9_init(void) { of_platform_default_populate(NULL, NULL, NULL); - at91sam9_pm_init(); + at91sam9_pm_init(at91sam9_pm_modes, ARRAY_SIZE(at91sam9_pm_modes)); } static const char *const at91_dt_board_compat[] __initconst = { diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h index 0a4cdcb4985b..610a12e5a71c 100644 --- a/arch/arm/mach-at91/generic.h +++ b/arch/arm/mach-at91/generic.h @@ -9,17 +9,17 @@ #define _AT91_GENERIC_H #ifdef CONFIG_PM -extern void __init at91rm9200_pm_init(void); -extern void __init at91sam9_pm_init(void); -extern void __init sam9x60_pm_init(void); -extern void __init sama5_pm_init(void); -extern void __init sama5d2_pm_init(void); +extern void __init at91rm9200_pm_init(const int *modes, int len); +extern void __init at91sam9_pm_init(const int *modes, int len); +extern void __init sam9x60_pm_init(const int *modes, int len); +extern void __init sama5_pm_init(const int *modes, int len); +extern void __init sama5d2_pm_init(const int *modes, int len); #else -static inline void __init at91rm9200_pm_init(void) { } -static inline void __init at91sam9_pm_init(void) { } -static inline void __init sam9x60_pm_init(void) { } -static inline void __init sama5_pm_init(void) { } -static inline void __init sama5d2_pm_init(void) { } +static inline void __init at91rm9200_pm_init(const int *modes, int len) { } +static inline void __init at91sam9_pm_init(const int *modes, int len) { } +static inline void __init sam9x60_pm_init(const int *modes, int len) { } +static inline void __init sama5_pm_init(const int *modes, int len) { } +static inline void __init sama5d2_pm_init(const int *modes, int len) { } #endif #endif /* _AT91_GENERIC_H */ diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index 04fdcbd57100..caf87efc7eeb 100644 --- a/arch/arm/mach-at91/pm.c +++ b/arch/arm/mach-at91/pm.c @@ -785,6 +785,59 @@ static const struct of_device_id atmel_pmc_ids[] __initconst = { { /* sentinel */ }, }; +static void __init at91_pm_modes_validate(const int *modes, int len) +{ + u8 i, located = 0; + int mode; + +#define STANDBY BIT(0) +#define SUSPEND BIT(1) + + for (i = 0; i < len; i++) { + if ((located & STANDBY) && (located & SUSPEND)) + break; + + if (modes[i] == soc_pm.data.standby_mode && + !(located & STANDBY)) { + located |= STANDBY; + continue; + } + + if (modes[i] == soc_pm.data.suspend_mode && + !(located & SUSPEND)) { + located |= SUSPEND; + continue; + } + } + + if (!(located & STANDBY)) { + if (soc_pm.data.suspend_mode == AT91_PM_STANDBY) + mode = AT91_PM_ULP0; + else + mode = AT91_PM_STANDBY; + + pr_warn("AT91: PM: %s mode not supported! Using %s.\n", + pm_modes[soc_pm.data.standby_mode].pattern, + pm_modes[mode].pattern); + soc_pm.data.standby_mode = mode; + } + + if (!(located & SUSPEND)) { + if (soc_pm.data.standby_mode == AT91_PM_ULP0) + mode = AT91_PM_STANDBY; + else + mode = AT91_PM_ULP0; + + pr_warn("AT91: PM: %s mode not supported! Using %s.\n", + pm_modes[soc_pm.data.suspend_mode].pattern, + pm_modes[mode].pattern); + soc_pm.data.suspend_mode = mode; + } + +#undef STANDBY +#undef SUSPEND +} + static void __init at91_pm_init(void (*pm_idle)(void)) { struct device_node *pmc_np; @@ -821,11 +874,12 @@ static void __init at91_pm_init(void (*pm_idle)(void)) } } -void __init at91rm9200_pm_init(void) +void __init at91rm9200_pm_init(const int *modes, int len) { if (!IS_ENABLED(CONFIG_SOC_AT91RM9200)) return; + at91_pm_modes_validate(modes, len); at91_dt_ramc(); /* @@ -836,11 +890,12 @@ void __init at91rm9200_pm_init(void) at91_pm_init(at91rm9200_idle); } -void __init sam9x60_pm_init(void) +void __init sam9x60_pm_init(const int *modes, int len) { if (!IS_ENABLED(CONFIG_SOC_SAM9X60)) return; + at91_pm_modes_validate(modes, len); at91_pm_modes_init(); at91_dt_ramc(); at91_pm_init(at91sam9x60_idle); @@ -849,31 +904,33 @@ void __init sam9x60_pm_init(void) soc_pm.config_pmc_ws = at91_sam9x60_config_pmc_ws; } -void __init at91sam9_pm_init(void) +void __init at91sam9_pm_init(const int *modes, int len) { if (!IS_ENABLED(CONFIG_SOC_AT91SAM9)) return; + at91_pm_modes_validate(modes, len); at91_dt_ramc(); at91_pm_init(at91sam9_idle); } -void __init sama5_pm_init(void) +void __init sama5_pm_init(const int *modes, int len) { if (!IS_ENABLED(CONFIG_SOC_SAMA5)) return; + at91_pm_modes_validate(modes, len); at91_dt_ramc(); at91_pm_init(NULL); } -void __init sama5d2_pm_init(void) +void __init sama5d2_pm_init(const int *modes, int len) { if (!IS_ENABLED(CONFIG_SOC_SAMA5D2)) return; + sama5_pm_init(modes, len); at91_pm_modes_init(); - sama5_pm_init(); soc_pm.ws_ids = sama5d2_ws_ids; soc_pm.config_shdwc_ws = at91_sama5d2_config_shdwc_ws; diff --git a/arch/arm/mach-at91/sam9x60.c b/arch/arm/mach-at91/sam9x60.c index d8c739d25458..d7c869c7b542 100644 --- a/arch/arm/mach-at91/sam9x60.c +++ b/arch/arm/mach-at91/sam9x60.c @@ -14,12 +14,21 @@ #include #include "generic.h" +#include "pm.h" + +/* SAM9X60 valid PM modes. */ +static const int sam9x60_pm_modes[] = { + AT91_PM_STANDBY, + AT91_PM_ULP0, + AT91_PM_ULP0_FAST, + AT91_PM_ULP1, +}; static void __init sam9x60_init(void) { of_platform_default_populate(NULL, NULL, NULL); - sam9x60_pm_init(); + sam9x60_pm_init(sam9x60_pm_modes, ARRAY_SIZE(sam9x60_pm_modes)); } static const char *const sam9x60_dt_board_compat[] __initconst = { diff --git a/arch/arm/mach-at91/sama5.c b/arch/arm/mach-at91/sama5.c index 89dab7cf01e8..7eb124612a10 100644 --- a/arch/arm/mach-at91/sama5.c +++ b/arch/arm/mach-at91/sama5.c @@ -14,11 +14,19 @@ #include #include "generic.h" +#include "pm.h" + +/* SAMA5 valid PM modes. */ +static const int sama5_pm_modes[] = { + AT91_PM_STANDBY, + AT91_PM_ULP0, + AT91_PM_ULP0_FAST, +}; static void __init sama5_dt_device_init(void) { of_platform_default_populate(NULL, NULL, NULL); - sama5_pm_init(); + sama5_pm_init(sama5_pm_modes, ARRAY_SIZE(sama5_pm_modes)); } static const char *const sama5_dt_board_compat[] __initconst = { @@ -44,10 +52,19 @@ DT_MACHINE_START(sama5_alt_dt, "Atmel SAMA5") .l2c_aux_mask = ~0UL, MACHINE_END +/* sama5d2 PM modes. */ +static const int sama5d2_pm_modes[] = { + AT91_PM_STANDBY, + AT91_PM_ULP0, + AT91_PM_ULP0_FAST, + AT91_PM_ULP1, + AT91_PM_BACKUP, +}; + static void __init sama5d2_init(void) { of_platform_default_populate(NULL, NULL, NULL); - sama5d2_pm_init(); + sama5d2_pm_init(sama5d2_pm_modes, ARRAY_SIZE(sama5d2_pm_modes)); } static const char *const sama5d2_compat[] __initconst = { From patchwork Mon Aug 3 07:25:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 11697509 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 753FA722 for ; Mon, 3 Aug 2020 07:27:11 +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 4E5E3206E9 for ; Mon, 3 Aug 2020 07:27:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="lcbWMA8r"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="T9ODTq3b" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4E5E3206E9 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=microchip.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=cjryF21G/NbocQd+3bY1EGHHx4NLJfIMrv47Gasrn8A=; b=lcbWMA8rGLyjPcBdKbx9zgsGD csqQ+RLmlk0BAvcu2HrDE75TnVwmHFwiqZIQTyuZQBt3uJ09Bxe/HSr3mWyBFv0gB+1VLS0cTnnTj dMYoW1Hw/YYNw72E8l+gUJsvLlWurLudK7+uV/ZsdG0ZFDcPEwS+0ZJ9RreXbac1b3ELblncrAgHm fU9w0AZ+77EPdll7ls0/vH7TY8uoXLyCqr3CE4k5M/QaTm6TsfOcZq3EZNl67R1lDZVuO8UYRxtjA 191xhUUtfsk41q3yBS2rITu/7FRs4lWk4hQCtHTVyHH6Wu4cb3/jR9iCdL/bm3pYTF4IM8PLTwz9n 7KU8dYwqQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k2Uqp-0000mC-M5; Mon, 03 Aug 2020 07:25:40 +0000 Received: from esa1.microchip.iphmx.com ([68.232.147.91]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k2Uql-0000j7-1Q for linux-arm-kernel@lists.infradead.org; Mon, 03 Aug 2020 07:25:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1596439534; x=1627975534; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=FR4Uar89M801Ogjt06aJ8ElOzC2Rm5sCdn/Dj7DNFlI=; b=T9ODTq3b0uwdjSoZ7Lfx/g0o1M/058Mss8cQb3kPYf1jH0Ea5LpXgR5e m9+xprXPsEdBcoCSJ6vn3SY+uIOI0FQR3kdzufNUTbD15NNyUS6EpifYs jdqMYF+5DC/kY63/N7xZpncMW0Mkpm5URYirvtNI7RbUn5KC8hDWqU8yD 2fAAgyBlDNe5IAk7zJVkIGeTwFPkDSCI3/91cl8ckRUtV++ipH0o/JJ4i VBFXhuw7wajvwTmdlaQ5rhfjUSBCehn46QGrd8fo4VDEq6GTQgZwGTwPI DrLR2/xCX8YvZw88b5iZq/g6ykJFFZvJl6+JzOFysKZN4mEQhqw+eZ2NS g==; IronPort-SDR: GosEPmJBhxETLcwKwNGZ//r3creh5djcPbrjWXnu8vtM9ty8iWuuS2OVhhAIS9wUr+aOUaBEoE mOq56HyuvWPq7KlwAqc7WOizyJHsu+XznJ0DSvE7GJuzPVTUsuzFf+pVZGAqXuug7+ybfdFxIh XUk4I1EOodMRMJfDU7hlzGMkb0dd8OOcsXlY4fWx3zm45ouiRptiCf/CVVhsvD9/GSyyZIfPVm MdzhF5vEvlqQj+rAOjQZE3/RueIUfYWLda6wVmn6rX5DFR3v6YusuNJKqbni7i05dK94qTvO67 B90= X-IronPort-AV: E=Sophos;i="5.75,429,1589266800"; d="scan'208";a="90194271" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 03 Aug 2020 00:25:32 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Mon, 3 Aug 2020 00:25:31 -0700 Received: from m18063-ThinkPad-T460p.microchip.com (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Mon, 3 Aug 2020 00:25:29 -0700 From: Claudiu Beznea To: , , Subject: [PATCH 3/3] ARM: at91: pm: put node after its usage Date: Mon, 3 Aug 2020 10:25:17 +0300 Message-ID: <1596439517-12993-4-git-send-email-claudiu.beznea@microchip.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1596439517-12993-1-git-send-email-claudiu.beznea@microchip.com> References: <1596439517-12993-1-git-send-email-claudiu.beznea@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200803_032535_237552_E6B824AB X-CRM114-Status: GOOD ( 10.66 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [68.232.147.91 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [68.232.147.91 listed in wl.mailspike.net] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -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 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders 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: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Claudiu Beznea Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org of_find_matching_node_and_match() returns a node pointer with refcount incremented. Use of_node_put() after the node has been used. Fixes: 13f16017d3e3f ("ARM: at91: pm: Tie the USB clock mask to the pmc") Signed-off-by: Claudiu Beznea --- arch/arm/mach-at91/pm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index caf87efc7eeb..3d2ee8273b4c 100644 --- a/arch/arm/mach-at91/pm.c +++ b/arch/arm/mach-at91/pm.c @@ -849,6 +849,7 @@ static void __init at91_pm_init(void (*pm_idle)(void)) pmc_np = of_find_matching_node_and_match(NULL, atmel_pmc_ids, &of_id); soc_pm.data.pmc = of_iomap(pmc_np, 0); + of_node_put(pmc_np); if (!soc_pm.data.pmc) { pr_err("AT91: PM not supported, PMC not found\n"); return;