From patchwork Mon Jun 29 03:06:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Nie X-Patchwork-Id: 50405 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 213D8218ED for ; Mon, 29 Jun 2015 03:06:58 +0000 (UTC) Received: by lagx9 with SMTP id x9sf14911263lag.2 for ; Sun, 28 Jun 2015 20:06:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=2q52XUui7608rfAItEDN5FihOj23Drq9enk19rExc7c=; b=jy275vd/zLlaARwOzbn3LIDMZwWDCUIIILIbVAKkBS5Nh25lpKuir0vBTHK5H+922M J4R5/Fxs84Ph+AlEzs1bh2QPs0Vb1G67vOB9EIpPB+GxLKCk7tllhbXYMkANPWBZTBNT oChmlaj9OOrPyQZa7ukYPSw4GW/PAsl+Mqzv8Xo5kP4Ot5xK8Qkvo351o/H29gXMcpSJ AkUAupUNE/2qqJP4kJrSSA9gLJJY8oYBl1edsamj/tV8m/UCRvE0+hu4Ms+YpvzztEJN XdkPNSWyBM6TCcZQCCgKe7AzFLMnPAPOqyBWEpPPwzQwMMbsoIgSekwG1RRgBcpkiGJi xJPw== X-Gm-Message-State: ALoCoQlS3raD8ayT53QK0bGVAhygX9A54ILo/5iYtcwq+/Uu2ufqu8c6xfVM8PzxfOzxZrcLycUB X-Received: by 10.180.105.226 with SMTP id gp2mr7235437wib.1.1435547216903; Sun, 28 Jun 2015 20:06:56 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.207.38 with SMTP id lt6ls62040lac.50.gmail; Sun, 28 Jun 2015 20:06:56 -0700 (PDT) X-Received: by 10.152.23.4 with SMTP id i4mr12038401laf.51.1435547216729; Sun, 28 Jun 2015 20:06:56 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id e14si33901017lbo.160.2015.06.28.20.06.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Jun 2015 20:06:56 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by lagh6 with SMTP id h6so37663503lag.2 for ; Sun, 28 Jun 2015 20:06:56 -0700 (PDT) X-Received: by 10.152.1.40 with SMTP id 8mr12330394laj.56.1435547216113; Sun, 28 Jun 2015 20:06:56 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp1409431lbb; Sun, 28 Jun 2015 20:06:54 -0700 (PDT) X-Received: by 10.70.65.10 with SMTP id t10mr27259126pds.151.1435547214273; Sun, 28 Jun 2015 20:06:54 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id za10si49028020pac.69.2015.06.28.20.06.52; Sun, 28 Jun 2015 20:06:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752503AbbF2DGw (ORCPT + 2 others); Sun, 28 Jun 2015 23:06:52 -0400 Received: from mail-pd0-f169.google.com ([209.85.192.169]:33485 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753064AbbF2DGv (ORCPT ); Sun, 28 Jun 2015 23:06:51 -0400 Received: by pdjn11 with SMTP id n11so108426646pdj.0 for ; Sun, 28 Jun 2015 20:06:51 -0700 (PDT) X-Received: by 10.68.186.35 with SMTP id fh3mr27408951pbc.62.1435547210829; Sun, 28 Jun 2015 20:06:50 -0700 (PDT) Received: from localhost.localdomain ([107.6.117.179]) by mx.google.com with ESMTPSA id ox6sm40425023pdb.25.2015.06.28.20.06.44 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 28 Jun 2015 20:06:49 -0700 (PDT) From: Jun Nie To: haojian.zhuang@linaro.org, linus.walleij@linaro.org, linux-gpio@vger.kernel.org Cc: tony@atomide.com, shawn.guo@linaro.org, wan.zhijun@zte.com.cn, jason.liu@linaro.org, Jun Nie Subject: [PATCH] power/reset: zx: Register restart handler Date: Mon, 29 Jun 2015 11:06:31 +0800 Message-Id: <1435547191-18405-1-git-send-email-jun.nie@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-gpio-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-gpio@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: jun.nie@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Register with kernel restart handler instead of setting arm_pm_restart directly. Signed-off-by: Jun Nie --- drivers/power/reset/Kconfig | 7 ++++ drivers/power/reset/Makefile | 1 + drivers/power/reset/zx-reboot.c | 79 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 drivers/power/reset/zx-reboot.c diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig index aad9c33..4ed90f3 100644 --- a/drivers/power/reset/Kconfig +++ b/drivers/power/reset/Kconfig @@ -165,5 +165,12 @@ config POWER_RESET_RMOBILE help Reboot support for Renesas R-Mobile and SH-Mobile SoCs. +config POWER_RESET_ZX + tristate "ZTE SoCs reset driver" + depends on ARCH_ZX || COMPILE_TEST + depends on HAS_IOMEM + help + Reboot support for ZTE SoCs. + endif diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile index dbe06c3..096fa67 100644 --- a/drivers/power/reset/Makefile +++ b/drivers/power/reset/Makefile @@ -19,3 +19,4 @@ obj-$(CONFIG_POWER_RESET_KEYSTONE) += keystone-reset.o obj-$(CONFIG_POWER_RESET_SYSCON) += syscon-reboot.o obj-$(CONFIG_POWER_RESET_SYSCON_POWEROFF) += syscon-poweroff.o obj-$(CONFIG_POWER_RESET_RMOBILE) += rmobile-reset.o +obj-$(CONFIG_POWER_RESET_ZX) += zx-reboot.o diff --git a/drivers/power/reset/zx-reboot.c b/drivers/power/reset/zx-reboot.c new file mode 100644 index 0000000..fbfee0b --- /dev/null +++ b/drivers/power/reset/zx-reboot.c @@ -0,0 +1,79 @@ +/* + * ZTE zx296702 SoC reset code + * + * Copyright (c) 2015 Linaro Ltd. + * + * Author: Jun Nie + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include + +static void __iomem *base; + +static int zx_restart_handler(struct notifier_block *this, + unsigned long mode, void *cmd) +{ + struct device_node *np; + void __iomem *pcu_base; + + np = of_find_compatible_node(NULL, NULL, "zte,zx296702-pcu"); + pcu_base = of_iomap(np, 0); + + writel_relaxed(1, base + 0xb0); + writel_relaxed(1, pcu_base + 0x34); + + while (1) + cpu_do_idle(); + + return NOTIFY_DONE; +} + +static struct notifier_block zx_restart_nb = { + .notifier_call = zx_restart_handler, + .priority = 128, +}; + +static int zx_reboot_probe(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + int err; + + base = of_iomap(np, 0); + if (!base) { + WARN(1, "failed to map base address"); + return -ENODEV; + } + + err = register_restart_handler(&zx_restart_nb); + if (err) + dev_err(&pdev->dev, "Register restart handler failed(err=%d)\n", + err); + + return err; +} + +static const struct of_device_id zx_reboot_of_match[] = { + { .compatible = "zte,sysctrl" }, + {} +}; + +static struct platform_driver zx_reboot_driver = { + .probe = zx_reboot_probe, + .driver = { + .name = "zx-reboot", + .of_match_table = zx_reboot_of_match, + }, +}; +module_platform_driver(zx_reboot_driver);