From patchwork Tue Dec 23 16:15:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 423740 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id C3B171400B7 for ; Wed, 24 Dec 2014 03:20:34 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932348AbaLWQUS (ORCPT ); Tue, 23 Dec 2014 11:20:18 -0500 Received: from mail-lb0-f175.google.com ([209.85.217.175]:54692 "EHLO mail-lb0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932215AbaLWQUR (ORCPT ); Tue, 23 Dec 2014 11:20:17 -0500 Received: by mail-lb0-f175.google.com with SMTP id u10so5510303lbd.6; Tue, 23 Dec 2014 08:20:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=08OPnDSuzc8AJemI9XcTgpsm4YPGZvKjuIw+418EOHk=; b=U2whVF9fCPDgc/26azBJObMLNNTZw0Oxh/tbHMQvKxDwXbCJF7AmF/G+/IsVfT6WR3 CKo72Sgo3DWKRvcpUEh3C6Lk/fT1t8xtDjf78n5+bDoZ//reWUkrCg3L4f0HgFgUOJGw 9mSyQ9oD/myfOfOPaShwN57XpoCsIzfKuifljVgK35NSYpdpUBNI/zBY+6kLC0sRappx H61MgD0EK025PemIlJmIC78hXO7lNXsdYUTXT41Z//4yzQONSB4/rNHxNABdZee4JPeZ iGv9UZ01fCF2Od2kUkk0e9GIMF5V3SBS8H8kBP2lvSjWsVMMh+4yapCjA++90xGDs5ae lO5Q== X-Received: by 10.112.235.67 with SMTP id uk3mr28960514lbc.48.1419351615020; Tue, 23 Dec 2014 08:20:15 -0800 (PST) Received: from localhost.localdomain ([91.77.120.206]) by mx.google.com with ESMTPSA id n6sm5976699laj.16.2014.12.23.08.20.12 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 23 Dec 2014 08:20:14 -0800 (PST) From: Dmitry Osipenko To: digetx@gmail.com, Stephen Warren , Thierry Reding , Alexandre Courbot Cc: , linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] soc: tegra: pmc: Use syscore PM ops Date: Tue, 23 Dec 2014 19:15:37 +0300 Message-Id: <1419351358-6201-1-git-send-email-digetx@gmail.com> X-Mailer: git-send-email 2.2.0 Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org Commit 7232398abc6a ("ARM: tegra: Convert PMC to a driver") changed tegra_resume() location storing from late to early and as result broke suspend on Tegra20. PMC scratch register 41 is used by tegra LP1 resume code for retrieving stored physical memory address of common resume function and in the same time used by Tegra20 cpuidle driver for storing cpu1 "resettable" status, it implies strict order of scratch register use. Fix it by making PMC driver use syscore PM ops to ensure that tegra_resume() location is stored after cpuidle driver suspend and before resume respectively. Signed-off-by: Dmitry Osipenko Fixes: 7232398abc6a (ARM: tegra: Convert PMC to a driver) Cc: # v3.17+ --- drivers/soc/tegra/pmc.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c index a2c0ceb..4ebd94a 100644 --- a/drivers/soc/tegra/pmc.c +++ b/drivers/soc/tegra/pmc.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -703,6 +704,23 @@ static void tegra_pmc_init(struct tegra_pmc *pmc) tegra_pmc_writel(value, PMC_CNTRL); } +static int tegra_pmc_suspend(void) +{ + tegra_pmc_writel(virt_to_phys(tegra_resume), PMC_SCRATCH41); + + return 0; +} + +static void tegra_pmc_resume(void) +{ + tegra_pmc_writel(0x0, PMC_SCRATCH41); +} + +static struct syscore_ops tegra_pmc_syscore_ops = { + .suspend = tegra_pmc_suspend, + .resume = tegra_pmc_resume, +}; + static int tegra_pmc_probe(struct platform_device *pdev) { void __iomem *base = pmc->base; @@ -736,27 +754,11 @@ static int tegra_pmc_probe(struct platform_device *pdev) return err; } - return 0; -} - -#ifdef CONFIG_PM_SLEEP -static int tegra_pmc_suspend(struct device *dev) -{ - tegra_pmc_writel(virt_to_phys(tegra_resume), PMC_SCRATCH41); + register_syscore_ops(&tegra_pmc_syscore_ops); return 0; } -static int tegra_pmc_resume(struct device *dev) -{ - tegra_pmc_writel(0x0, PMC_SCRATCH41); - - return 0; -} -#endif - -static SIMPLE_DEV_PM_OPS(tegra_pmc_pm_ops, tegra_pmc_suspend, tegra_pmc_resume); - static const char * const tegra20_powergates[] = { [TEGRA_POWERGATE_CPU] = "cpu", [TEGRA_POWERGATE_3D] = "3d", @@ -894,7 +896,6 @@ static struct platform_driver tegra_pmc_driver = { .name = "tegra-pmc", .suppress_bind_attrs = true, .of_match_table = tegra_pmc_match, - .pm = &tegra_pmc_pm_ops, }, .probe = tegra_pmc_probe, };