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: 451332 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 62F6614008F for ; Wed, 18 Mar 2015 20:55:03 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="verification failed; unprotected key" header.d=gmail.com header.i=@gmail.com header.b=zPCdCIKo; dkim-adsp=none (unprotected policy); dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933016AbbCRJyA (ORCPT ); Wed, 18 Mar 2015 05:54:00 -0400 Received: from mail-we0-f171.google.com ([74.125.82.171]:35935 "EHLO mail-we0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932742AbbCRJxy (ORCPT ); Wed, 18 Mar 2015 05:53:54 -0400 Received: by wetk59 with SMTP id k59so27718395wet.3; 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 Cc: David Riley , Tomeu Vizoso , Russell King , Stephen Warren , Thierry Reding , Alexandre Courbot , Peter De Schrijver , Paul Walmsley , Mikko Perttunen , linux-arm-kernel@lists.infradead.org, linux-kernel@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> Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org 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; }