From patchwork Wed Mar 18 09:52:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 6037661 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 79A279F314 for ; Wed, 18 Mar 2015 10:01:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8A545204FC for ; Wed, 18 Mar 2015 10:01:02 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 98ED62037C for ; Wed, 18 Mar 2015 10:01:01 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YYAjW-0005F6-Pr; Wed, 18 Mar 2015 09:57:50 +0000 Received: from mail-wi0-x22c.google.com ([2a00:1450:400c:c05::22c]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YYAg4-00027z-OD for linux-arm-kernel@lists.infradead.org; Wed, 18 Mar 2015 09:54:18 +0000 Received: by wibg7 with SMTP id g7so60882379wib.1 for ; Wed, 18 Mar 2015 02:53:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=c13eJdgwHcFGI/kgrcEr7cFnbrtGcFprkLq2rotOZiQ=; b=zPCdCIKof72YQy6OxXQi8Ki4DqlBencEGhmaD+KPMaOJSiVyGjNkVyLHMKiy3tmV+t 4+g7Sc6wIk2UD5LloNbrOUN7bStQ515WOUNx93hBhBcgjIXUr5dMArn0Py9Rd1hu+kSD fI4KAuD4tC5ReTKKc1FXFmh/DumcHKGZhLWjXr74omKRz+c/5IlHM7aWqh1ai+SfdZvm aCinhiC6AdZuAbva4tYhaLJFvq6IC5pzDGpjhlK5SBFZRxV3vkURWk+JOMXkkgorLIwV YESSfPQIUZIo9PnD3RFe1vltQ3X0VHBSf6sBzmLPyRyPhCVJyoRv27JnYbDbqHFAY3cR rJGg== X-Received: by 10.180.198.37 with SMTP id iz5mr4969830wic.95.1426672433043; Wed, 18 Mar 2015 02:53:53 -0700 (PDT) Received: from cizrna.lan ([109.72.12.84]) by mx.google.com with ESMTPSA id nb4sm23715761wjc.20.2015.03.18.02.53.50 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Mar 2015 02:53:51 -0700 (PDT) From: Tomeu Vizoso To: linux-tegra@vger.kernel.org Subject: [PATCH v6 10/12] soc/tegra: pmc: move to using a restart handler Date: Wed, 18 Mar 2015 10:52:25 +0100 Message-Id: <1426672363-30667-11-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1426672363-30667-1-git-send-email-tomeu.vizoso@collabora.com> References: <1426672363-30667-1-git-send-email-tomeu.vizoso@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150318_025416_980632_F7639665 X-CRM114-Status: GOOD ( 15.66 ) X-Spam-Score: -0.5 (/) Cc: Alexandre Courbot , Paul Walmsley , Russell King , Tomeu Vizoso , Stephen Warren , Peter De Schrijver , linux-kernel@vger.kernel.org, Mikko Perttunen , Thierry Reding , David Riley , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: David Riley The pmc driver was previously exporting tegra_pmc_restart, which was assigned to machine_desc.init_machine, taking precedence over the restart handlers registered through register_restart_handler(). Signed-off-by: David Riley [tomeu.vizoso@collabora.com: Rebased] Signed-off-by: Tomeu Vizoso Acked-by: Stephen Warren Reviewed-by: Alexandre Courbot --- arch/arm/mach-tegra/tegra.c | 1 - drivers/soc/tegra/pmc.c | 31 +++++++++++++++++++++---------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/arch/arm/mach-tegra/tegra.c b/arch/arm/mach-tegra/tegra.c index 914341b..4805ef6 100644 --- a/arch/arm/mach-tegra/tegra.c +++ b/arch/arm/mach-tegra/tegra.c @@ -164,6 +164,5 @@ DT_MACHINE_START(TEGRA_DT, "NVIDIA Tegra SoC (Flattened Device Tree)") .init_irq = tegra_dt_init_irq, .init_machine = tegra_dt_init, .init_late = tegra_dt_init_late, - .restart = tegra_pmc_restart, .dt_compat = tegra_dt_board_compat, MACHINE_END diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c index c956395..0285b74 100644 --- a/drivers/soc/tegra/pmc.c +++ b/drivers/soc/tegra/pmc.c @@ -377,26 +377,23 @@ int tegra_pmc_cpu_remove_clamping(int cpuid) } #endif /* CONFIG_SMP */ -/** - * tegra_pmc_restart() - reboot the system - * @mode: which mode to reboot in - * @cmd: reboot command - */ -void tegra_pmc_restart(enum reboot_mode mode, const char *cmd) +static int tegra_pmc_restart_notify(struct notifier_block *this, + unsigned long mode, void *cmd) { u32 value; + const char *cmd_str = (const char *) cmd; value = tegra_pmc_readl(PMC_SCRATCH0); value &= ~PMC_SCRATCH0_MODE_MASK; - if (cmd) { - if (strcmp(cmd, "recovery") == 0) + if (cmd_str) { + if (strcmp(cmd_str, "recovery") == 0) value |= PMC_SCRATCH0_MODE_RECOVERY; - if (strcmp(cmd, "bootloader") == 0) + if (strcmp(cmd_str, "bootloader") == 0) value |= PMC_SCRATCH0_MODE_BOOTLOADER; - if (strcmp(cmd, "forced-recovery") == 0) + if (strcmp(cmd_str, "forced-recovery") == 0) value |= PMC_SCRATCH0_MODE_RCM; } @@ -405,8 +402,15 @@ void tegra_pmc_restart(enum reboot_mode mode, const char *cmd) value = tegra_pmc_readl(0); value |= 0x10; tegra_pmc_writel(value, 0); + + return NOTIFY_DONE; } +static struct notifier_block tegra_pmc_restart_handler = { + .notifier_call = tegra_pmc_restart_notify, + .priority = 128, +}; + static int powergate_show(struct seq_file *s, void *data) { unsigned int i; @@ -837,6 +841,13 @@ static int tegra_pmc_probe(struct platform_device *pdev) return err; } + err = register_restart_handler(&tegra_pmc_restart_handler); + if (err) { + dev_err(&pdev->dev, "unable to register restart handler, %d\n", + err); + return err; + } + return 0; }