From patchwork Thu Aug 30 11:50:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 10581599 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 199EE920 for ; Thu, 30 Aug 2018 11:53:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 05CCE2B2C7 for ; Thu, 30 Aug 2018 11:53:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA9BB2B37D; Thu, 30 Aug 2018 11:53:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 785A52B2C7 for ; Thu, 30 Aug 2018 11:53:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=0kyTTSgruXSjPAGVXupBjoYu2VCQJDo4vcCGt/pN/v8=; b=nqEiG1XXOTpXdl f3Zndpr+XbWcsTwLDNopmCt+OdS+oMyEdvfE/7RDmt/oxoSXfP0TzMytEzFnzPkxKMcdnSFEcKA9m LWE2XwDLyhO/rKH0K2+fT5VV3v1b2PAlZcCVLjirz2VxUbkfztZig238Y+dKxcM7tTV46pRTHbPEd qM/X247lcYNu8EVdPMl11uNRUgeAPb7t3sAHBJewkEccgHUzS1Ofn4aEM0ZuEbVlveN554A7Rpl7o nEZ0/qikO3cLcCwIW4KzCqqaBtLU+uX+SuEq6QuRjAbh/U+wJ2YNIwSwjVp///hDVanBmKG6YZk/0 G0++Wq67ZdhKNrc9PfrA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fvLVV-0004EJ-Sz; Thu, 30 Aug 2018 11:53:01 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fvLTQ-0003RI-La for linux-arm-kernel@bombadil.infradead.org; Thu, 30 Aug 2018 11:50:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=uQ6CViW2fwy3GnTw3JBs73aa04LdnE2Eqd1ILMVhnFU=; b=Q2oJYYTxXf8Ze9pCMcaLbJidb WGolDpBnVB3agT0WkfMIaTR+LhzgUhmQFywkrnDBq3C1L8SPTm70w1xUL5QFYH9AYW5oL6GtFtaIk ESUdNDbn6PprE1hzDN08vfBb7HfPzDbLuiPhiCywjJEQ9ZbBaP/dBCkJMa/GVJxux1XTnwVNox1Mb DfhoqbQscQCT+CY8TG509xoB/vKj7LgQPDqrwe+UzKb1V+5k8qafTjVtCRAko7qWLoCxnAzsovZtD tZ/2bIngrZvtfjWHuxLbo6mMp7j0LZ4BpruLmLVug2PUE6Zrw/gWD2eLr2sZR+/bHYOpQ0oC9Ao4a QNq48eLhA==; Received: from esa3.microchip.iphmx.com ([68.232.153.233]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fvLTN-0008Qq-LX for linux-arm-kernel@lists.infradead.org; Thu, 30 Aug 2018 11:50:50 +0000 X-IronPort-AV: E=Sophos;i="5.53,306,1531810800"; d="scan'208";a="19080216" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 30 Aug 2018 04:50:33 -0700 Received: from m18063-ThinkPad-T460p.mchp-main.com (10.10.76.4) by chn-sv-exch05.mchp-main.com (10.10.76.106) with Microsoft SMTP Server id 14.3.352.0; Thu, 30 Aug 2018 04:50:32 -0700 From: Claudiu Beznea To: , , , Subject: [PATCH 2/6] power: reset: at91-poweroff: use only one poweroff function Date: Thu, 30 Aug 2018 14:50:07 +0300 Message-ID: <1535629811-13403-3-git-send-email-claudiu.beznea@microchip.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535629811-13403-1-git-send-email-claudiu.beznea@microchip.com> References: <1535629811-13403-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-20180830_075049_879475_9CA2C81B X-CRM114-Status: GOOD ( 11.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Claudiu Beznea , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Use only one poweroff function for sama5d2 and adapt it to work for both scenarios (having LPDDR or not). Signed-off-by: Claudiu Beznea --- drivers/power/reset/at91-sama5d2_shdwc.c | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/drivers/power/reset/at91-sama5d2_shdwc.c b/drivers/power/reset/at91-sama5d2_shdwc.c index dd6297bd7b6a..94ad79d0d82e 100644 --- a/drivers/power/reset/at91-sama5d2_shdwc.c +++ b/drivers/power/reset/at91-sama5d2_shdwc.c @@ -110,18 +110,6 @@ static void __init at91_wakeup_status(struct platform_device *pdev) static void at91_poweroff(void) { - /* Switch the master clock source to slow clock. */ - writel(readl(at91_shdwc->pmc_base + AT91_PMC_MCKR) & ~AT91_PMC_CSS, - at91_shdwc->pmc_base + AT91_PMC_MCKR); - while (!(readl(at91_shdwc->pmc_base + AT91_PMC_SR) & AT91_PMC_MCKRDY)) - ; - - writel(AT91_SHDW_KEY | AT91_SHDW_SHDW, - at91_shdwc->at91_shdwc_base + AT91_SHDW_CR); -} - -static void at91_lpddr_poweroff(void) -{ asm volatile( /* Align to cache lines */ ".balign 32\n\t" @@ -130,16 +118,18 @@ static void at91_lpddr_poweroff(void) " ldr r6, [%2, #" __stringify(AT91_SHDW_CR) "]\n\t" /* Power down SDRAM0 */ + " tst %0, #0\n\t" + " beq 1f\n\t" " str %1, [%0, #" __stringify(AT91_DDRSDRC_LPR) "]\n\t" /* Switch the master clock source to slow clock. */ - " ldr r6, [%4, #" __stringify(AT91_PMC_MCKR) "]\n\t" + "1: ldr r6, [%4, #" __stringify(AT91_PMC_MCKR) "]\n\t" " bic r6, r6, #" __stringify(AT91_PMC_CSS) "\n\t" " str r6, [%4, #" __stringify(AT91_PMC_MCKR) "]\n\t" /* Wait for clock switch. */ - "1: ldr r6, [%4, #" __stringify(AT91_PMC_SR) "]\n\t" + "2: ldr r6, [%4, #" __stringify(AT91_PMC_SR) "]\n\t" " tst r6, #" __stringify(AT91_PMC_MCKRDY) "\n\t" - " beq 1b\n\t" + " beq 2b\n\t" /* Shutdown CPU */ " str %3, [%2, #" __stringify(AT91_SHDW_CR) "]\n\t" @@ -326,10 +316,8 @@ static int __init at91_shdwc_probe(struct platform_device *pdev) pm_power_off = at91_poweroff; ddr_type = readl(mpddrc_base + AT91_DDRSDRC_MDR) & AT91_DDRSDRC_MD; - if ((ddr_type == AT91_DDRSDRC_MD_LPDDR2) || - (ddr_type == AT91_DDRSDRC_MD_LPDDR3)) { - pm_power_off = at91_lpddr_poweroff; - } else { + if (ddr_type != AT91_DDRSDRC_MD_LPDDR2 && + ddr_type != AT91_DDRSDRC_MD_LPDDR3) { iounmap(mpddrc_base); mpddrc_base = NULL; } @@ -348,8 +336,7 @@ static int __exit at91_shdwc_remove(struct platform_device *pdev) { struct shdwc *shdw = platform_get_drvdata(pdev); - if (pm_power_off == at91_poweroff || - pm_power_off == at91_lpddr_poweroff) + if (pm_power_off == at91_poweroff) pm_power_off = NULL; /* Reset values to disable wake-up features */