From patchwork Sat Sep 27 00:57:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 4988561 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 90F109F32B for ; Sat, 27 Sep 2014 00:59:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9021520222 for ; Sat, 27 Sep 2014 00:59:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B166A201F5 for ; Sat, 27 Sep 2014 00:59:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752926AbaI0A7B (ORCPT ); Fri, 26 Sep 2014 20:59:01 -0400 Received: from mail-pd0-f178.google.com ([209.85.192.178]:53517 "EHLO mail-pd0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752203AbaI0A5x (ORCPT ); Fri, 26 Sep 2014 20:57:53 -0400 Received: by mail-pd0-f178.google.com with SMTP id ft15so13755184pdb.37 for ; Fri, 26 Sep 2014 17:57: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=UCKJNwGe73z10G3iq94T4Y7vUoNMo5Cw+OB7ixRQpGA=; b=M81YKBqYrs0BcsT5rMytyk/OelylmzRdO3a15Wcy5P0T5HJwklrsuadwpYUF+KWyG3 NZfUt7VskIpZa8VM6qwOS6N1kY2VP3QhPz/5zrnwG9kZutSJfsxqNuIzE++9PfYXPFBu OgbrtJoeVmmm7+zJV+5fcVBd1EbJkNcGB6WAK//aFa+CF5HRGhi2aL2xopr0kGMFESBM DKnWQkmxT73Dt0TlnbhfHzRX2kE7xo9Wra/BkYPY6XOWJZomNd5fXAV1cwfYawZTAAW1 02cfHjX9MrZbwfsXJnJAf0BKfpUgcMMEilqfiqXsYfHsnkRVRBIG7UxUrZR1KgLAwVrC O79g== X-Received: by 10.70.3.194 with SMTP id e2mr330824pde.161.1411779473014; Fri, 26 Sep 2014 17:57:53 -0700 (PDT) Received: from localhost (108-223-40-66.lightspeed.sntcca.sbcglobal.net. [108.223.40.66]) by mx.google.com with ESMTPSA id c3sm6037032pdk.3.2014.09.26.17.57.52 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 26 Sep 2014 17:57:52 -0700 (PDT) From: Guenter Roeck To: Sebastian Reichel Cc: linux-pm@vger.kernel.org, Dmitry Eremin-Solenikov , David Woodhouse , Santosh Shilimkar , linux-kernel@vger.kernel.org, Guenter Roeck , Ivan Khoronzhuk Subject: [PATCH 08/10] power/reset: keystone: Register with kernel restart handler Date: Fri, 26 Sep 2014 17:57:16 -0700 Message-Id: <1411779438-23127-9-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1411779438-23127-1-git-send-email-linux@roeck-us.net> References: <1411779438-23127-1-git-send-email-linux@roeck-us.net> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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 Register with kernel restart handler instead of setting arm_pm_restart directly. Move notifier registration to the end of the probe function to avoid having to implement error handling. Cc: Ivan Khoronzhuk Cc: Santosh Shilimkar Signed-off-by: Guenter Roeck Acked-by: Santosh Shilimkar --- drivers/power/reset/keystone-reset.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/power/reset/keystone-reset.c b/drivers/power/reset/keystone-reset.c index 408a18f..9d46586 100644 --- a/drivers/power/reset/keystone-reset.c +++ b/drivers/power/reset/keystone-reset.c @@ -12,9 +12,9 @@ #include #include +#include #include #include -#include #include #include @@ -52,7 +52,8 @@ static inline int rsctrl_enable_rspll_write(void) RSCTRL_KEY_MASK, RSCTRL_KEY); } -static void rsctrl_restart(enum reboot_mode mode, const char *cmd) +static int rsctrl_restart_handler(struct notifier_block *this, + unsigned long mode, void *cmd) { /* enable write access to RSTCTRL */ rsctrl_enable_rspll_write(); @@ -60,8 +61,15 @@ static void rsctrl_restart(enum reboot_mode mode, const char *cmd) /* reset the SOC */ regmap_update_bits(pllctrl_regs, rspll_offset + RSCTRL_RG, RSCTRL_RESET_MASK, 0); + + return NOTIFY_DONE; } +static struct notifier_block rsctrl_restart_nb = { + .notifier_call = rsctrl_restart_handler, + .priority = 128, +}; + static struct of_device_id rsctrl_of_match[] = { {.compatible = "ti,keystone-reset", }, {}, @@ -114,8 +122,6 @@ static int rsctrl_probe(struct platform_device *pdev) if (ret) return ret; - arm_pm_restart = rsctrl_restart; - /* disable a reset isolation for all module clocks */ ret = regmap_write(pllctrl_regs, rspll_offset + RSISO_RG, 0); if (ret) @@ -147,6 +153,10 @@ static int rsctrl_probe(struct platform_device *pdev) return ret; } + ret = register_restart_handler(&rsctrl_restart_nb); + if (ret) + dev_err(dev, "cannot register restart handler (err=%d)\n", ret); + return 0; }