From patchwork Wed Jul 15 03:25:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Nie X-Patchwork-Id: 51113 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 AC37C22A24 for ; Wed, 15 Jul 2015 03:26:24 +0000 (UTC) Received: by lagw2 with SMTP id w2sf7282665lag.3 for ; Tue, 14 Jul 2015 20:26:23 -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=INyZXlfA/AWe6b7Zldjjd1tt9kDpJ8HTvJaHhp6vO+g=; b=D/kTeyjZhhQrkq2Cnyhzf7ROdreHUfRQD3lBCpQAwaA+SODF38umRQZPW3aFPsKXKd uF5h73mSDPHz/btlFYbC7i32/Pi2FicRs3XhzT5cMuFTqikqltKp2S9Nh0RNjMLX1Q2p WkWXmz06HpktHTTdD2XPRML+MYsZiiH96O8Oo3lh2sShbAaDktp/YAWGWUVJJKj+mE6h sRpgA4UqobMcBZzmRM8KtrhIF72S0+NvFHzjIfVWoXmhXpWqKE9h5lkR0UxXHR6Hj5hX gYbqGlUOl7xUc9Uwyor/z3zyDIwRSUDrmvDoc2sKoYtsdw0X6XnZrb0a6xb6hSPTz+T6 DzSA== X-Gm-Message-State: ALoCoQmShGjRO3Se/5yCaoFU4UCGRuPfgrNHYoYxAb9kOmbmZ4WPQlMoqj5yPjMTKR0Ee8PFOt26 X-Received: by 10.180.35.162 with SMTP id i2mr11756182wij.6.1436930783643; Tue, 14 Jul 2015 20:26:23 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.228 with SMTP id bb4ls131877lab.88.gmail; Tue, 14 Jul 2015 20:26:23 -0700 (PDT) X-Received: by 10.112.91.131 with SMTP id ce3mr1804140lbb.61.1436930783483; Tue, 14 Jul 2015 20:26:23 -0700 (PDT) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com. [209.85.217.178]) by mx.google.com with ESMTPS id rk9si2735397lbb.152.2015.07.14.20.26.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Jul 2015 20:26:23 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by lblf12 with SMTP id f12so17030406lbl.2 for ; Tue, 14 Jul 2015 20:26:23 -0700 (PDT) X-Received: by 10.152.206.75 with SMTP id lm11mr1770802lac.41.1436930783368; Tue, 14 Jul 2015 20:26:23 -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 hn6csp2789865lbb; Tue, 14 Jul 2015 20:26:21 -0700 (PDT) X-Received: by 10.66.190.228 with SMTP id gt4mr3655217pac.72.1436930780307; Tue, 14 Jul 2015 20:26:20 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id il7si5043369pac.156.2015.07.14.20.26.19; Tue, 14 Jul 2015 20:26:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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 S1752110AbbGOD0S (ORCPT + 12 others); Tue, 14 Jul 2015 23:26:18 -0400 Received: from mail-pa0-f48.google.com ([209.85.220.48]:34215 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751365AbbGOD0S (ORCPT ); Tue, 14 Jul 2015 23:26:18 -0400 Received: by pacan13 with SMTP id an13so16068327pac.1 for ; Tue, 14 Jul 2015 20:26:18 -0700 (PDT) X-Received: by 10.68.65.34 with SMTP id u2mr3657474pbs.118.1436930777941; Tue, 14 Jul 2015 20:26:17 -0700 (PDT) Received: from localhost.localdomain ([107.6.117.178]) by smtp.gmail.com with ESMTPSA id x7sm2848924pbt.16.2015.07.14.20.26.11 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 14 Jul 2015 20:26:17 -0700 (PDT) From: Jun Nie To: sre@kernel.org, haojian.zhuang@linaro.org, dbaryshkov@gmail.com, dwmw2@infradead.org Cc: linux-pm@vger.kernel.org, shawn.guo@linaro.org, wan.zhijun@zte.com.cn, jason.liu@linaro.org, Jun Nie Subject: [PATCH v3] power/reset: zx: Register restart handler Date: Wed, 15 Jul 2015 11:25:58 +0800 Message-Id: <1436930758-19140-1-git-send-email-jun.nie@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@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.217.178 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 | 82 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+) create mode 100644 drivers/power/reset/zx-reboot.c diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig index 17d93a7..5a0189b 100644 --- a/drivers/power/reset/Kconfig +++ b/drivers/power/reset/Kconfig @@ -166,5 +166,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..cf4b973 --- /dev/null +++ b/drivers/power/reset/zx-reboot.c @@ -0,0 +1,82 @@ +/* + * 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 void __iomem *pcu_base; + +static int zx_restart_handler(struct notifier_block *this, + unsigned long mode, void *cmd) +{ + writel_relaxed(1, base + 0xb0); + writel_relaxed(1, pcu_base + 0x34); + + mdelay(50); + pr_emerg("Unable to restart system\n"); + + 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; + } + + np = of_find_compatible_node(NULL, NULL, "zte,zx296702-pcu"); + pcu_base = of_iomap(np, 0); + if (!pcu_base) { + iounmap(base); + WARN(1, "failed to map pcu_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);