From patchwork Thu Feb 12 08:51:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 5818371 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B465ABF440 for ; Thu, 12 Feb 2015 08:58:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DBE7520103 for ; Thu, 12 Feb 2015 08:58:01 +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 E83A0200F4 for ; Thu, 12 Feb 2015 08:58:00 +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 1YLpXz-00042b-Vc; Thu, 12 Feb 2015 08:54:55 +0000 Received: from mail-wi0-x22d.google.com ([2a00:1450:400c:c05::22d]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YLpWF-0002hy-OB for linux-arm-kernel@lists.infradead.org; Thu, 12 Feb 2015 08:53:08 +0000 Received: by mail-wi0-f173.google.com with SMTP id bs8so2458357wib.0 for ; Thu, 12 Feb 2015 00:52:45 -0800 (PST) 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=njjWD/cH1+78EWYDEBKHqUzoaalcln+dSVfQKMc3sio=; b=CPxHH+yszVP9dcF+0oMtMtuufytqY6WeCw8TGwHR/qIZMatY5xOd2iNA1LbhLsbhbW s3Lql0dKAE2moTTCIirXx2fu9Qy+0an0YpVEX/gdJyJj9QK5H3btFiWJCylxfNA0TqEW 6eFAGh6XtjPCy7plLQs1cVQEBQVCPbPKgTykTloe5Q6iQ2mzOMxdhUjryRURcv4dZR9E CV2s1OGVxxBoWUJYOI3snN0CoX26rJaCe5WJFxChoyAdvxfukLg91l16BlDeZ+QySNJ2 f69kipI7cZRDLluX3MGi7edcHtb9D8h+nKtrCHEsnUXEf3ZvML5Tz/cdy12kC5GJinrG iAEw== X-Received: by 10.180.9.71 with SMTP id x7mr2404033wia.0.1423731165666; Thu, 12 Feb 2015 00:52:45 -0800 (PST) Received: from cizrna.lan (37-48-47-45.tmcz.cz. [37.48.47.45]) by mx.google.com with ESMTPSA id w16sm1571919wia.15.2015.02.12.00.52.42 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Feb 2015 00:52:44 -0800 (PST) From: Tomeu Vizoso To: linux-tegra@vger.kernel.org Subject: [PATCH v5 10/11] soc/tegra: pmc: move to using a restart handler Date: Thu, 12 Feb 2015 09:51:04 +0100 Message-Id: <1423731078-26681-11-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1423731078-26681-1-git-send-email-tomeu.vizoso@collabora.com> References: <1423731078-26681-1-git-send-email-tomeu.vizoso@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150212_005307_964488_9E8DE87D X-CRM114-Status: GOOD ( 15.10 ) X-Spam-Score: -0.5 (/) Cc: Alexandre Courbot , Paul Walmsley , David Riley , Tomeu Vizoso , Stephen Warren , Andrew Bresticker , Simon Glass , linux-kernel@vger.kernel.org, Mikko Perttunen , Thierry Reding , Russell King , Dylan Reid , Peter De Schrijver , Javier Martinez Canillas , 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 --- 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; }