From patchwork Wed Jan 27 00:37:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 60550 Delivered-To: patches@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp2289470lbb; Tue, 26 Jan 2016 16:38:08 -0800 (PST) X-Received: by 10.66.255.70 with SMTP id ao6mr38112594pad.64.1453855086659; Tue, 26 Jan 2016 16:38:06 -0800 (PST) Return-Path: Received: from mail-pf0-x235.google.com (mail-pf0-x235.google.com. [2607:f8b0:400e:c00::235]) by mx.google.com with ESMTPS id o4si5309317pfi.36.2016.01.26.16.38.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Jan 2016 16:38:06 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c00::235 as permitted sender) client-ip=2607:f8b0:400e:c00::235; Authentication-Results: mx.google.com; spf=pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c00::235 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dkim=pass header.i=@linaro.org Received: by mail-pf0-x235.google.com with SMTP id n128so107461314pfn.3 for ; Tue, 26 Jan 2016 16:38:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=ICG5aNNpghTO7uXj4FvqK63LsNOiQrt/YiqCf1A0ojI=; b=OlxGZpkxS6jOdV3ByqF16Op2eT3Rz67hIG3tOhefoKsvVNhCV35VcrvUhcSVpaCm88 NR7fF7n/U900XVqdSG0NUJkdgdsXjNqekgcjld8X6oMGooNq1EhXqR1L5T/soXSPyFY4 RnDk62QYxp5QA4AmCvdJJ/nGFjwAeCuAgOfT0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=ICG5aNNpghTO7uXj4FvqK63LsNOiQrt/YiqCf1A0ojI=; b=d/eOodGULACWIMKPYu/YrbzixwXPYii0Y2OTY7kX5KuBPFWedYsuFOnJxHJ3yhUsle oPxU449+fItBJzy9BBwnELq1FMbMas0oq5i+Dh1vvPrGlUjQfNjR1z4+Yk6A88mleIND +5Sq7/HlEmZ9tw5Xds4XfxxwQ+xTaUl+MtxFRw4bW0iw6NNh5domS6i6sYsSsZjMT822 FtQ7y+saT5mH8fyeSIWWJCGbZD25AK5jUvpO0NBsnlMey/Gp5vKQHTH1JkgeE/ro2gZg ot5y0RetgiGUCar8hB9jNZsNTp8BF/9VAUS94K5t7UZm5WXU3ofx0hFmLAIupBIjZpmd Mocw== X-Gm-Message-State: AG10YORTv/26Q6lGHDiA8R28EIgJ8AvBwY4jmU2tLGYag9Gh4ZfPdhCoW0uaslAv40U3qxV/aU8= X-Received: by 10.98.42.83 with SMTP id q80mr37724293pfq.19.1453855086309; Tue, 26 Jan 2016 16:38:06 -0800 (PST) Return-Path: Received: from localhost.localdomain (c-76-115-103-22.hsd1.or.comcast.net. [76.115.103.22]) by smtp.gmail.com with ESMTPSA id c86sm4321091pfd.75.2016.01.26.16.38.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 26 Jan 2016 16:38:05 -0800 (PST) From: John Stultz To: lkml Cc: John Stultz , Andy Yan , Rob Herring , Arnd Bergmann , Thierry Reding , =?UTF-8?q?Heiko=20St=C3=BCbner?= , Caesar Wang , Kees Cook , Guodong Xu , Haojian Zhuang , Vishal Bhoj , Bjorn Andersson , devicetree@vger.kernel.org, Android Kernel Team Subject: [RFC][PATCH 2/3] power: reset: Add sram-reboot-mode driver Date: Tue, 26 Jan 2016 16:37:59 -0800 Message-Id: <1453855080-17760-3-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1453855080-17760-1-git-send-email-john.stultz@linaro.org> References: <1453855080-17760-1-git-send-email-john.stultz@linaro.org> MIME-Version: 1.0 Add sram-reboot-mode driver, which enables reboot modes to be specified from sram subnodes. Cc: Andy Yan Cc: Rob Herring Cc: Arnd Bergmann Cc: Thierry Reding Cc: Heiko Stübner Cc: Caesar Wang Cc: Kees Cook Cc: Guodong Xu Cc: Haojian Zhuang Cc: Vishal Bhoj Cc: Bjorn Andersson Cc: devicetree@vger.kernel.org Cc: Android Kernel Team Signed-off-by: John Stultz --- drivers/power/reset/Kconfig | 9 +++++ drivers/power/reset/Makefile | 1 + drivers/power/reset/sram-reboot-mode.c | 66 ++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 drivers/power/reset/sram-reboot-mode.c -- 1.9.1 diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig index 76a6251..b033922 100644 --- a/drivers/power/reset/Kconfig +++ b/drivers/power/reset/Kconfig @@ -182,5 +182,14 @@ config SYSCON_REBOOT_MODE register, then the bootloader can read it to take different action according to the mode. +config SRAM_REBOOT_MODE + bool "Generic SRAM reboot mode driver" + select REBOOT_MODE + help + Say y here will enable reboot mode driver. This will + get reboot mode arguments and store it in an SRAM + address, then the bootloader can read it to take different + action according to the mode. + endif diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile index afd05e9..4780f20 100644 --- a/drivers/power/reset/Makefile +++ b/drivers/power/reset/Makefile @@ -21,4 +21,5 @@ obj-$(CONFIG_POWER_RESET_SYSCON_POWEROFF) += syscon-poweroff.o obj-$(CONFIG_POWER_RESET_RMOBILE) += rmobile-reset.o obj-$(CONFIG_REBOOT_MODE) += reboot-mode.o obj-$(CONFIG_SYSCON_REBOOT_MODE) += syscon-reboot-mode.o +obj-$(CONFIG_SRAM_REBOOT_MODE) += sram-reboot-mode.o diff --git a/drivers/power/reset/sram-reboot-mode.c b/drivers/power/reset/sram-reboot-mode.c new file mode 100644 index 0000000..065c3a8 --- /dev/null +++ b/drivers/power/reset/sram-reboot-mode.c @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2016, Linaro Limited + * Based on syscon-reboot-mode.c + * Copyright (c) 2016, Fuzhou Rockchip Electronics Co., Ltd + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "reboot-mode.h" + +static void __iomem *reboot_reason_val_addr; + +static int sram_reboot_mode_write(int magic) +{ + writel(magic, reboot_reason_val_addr); + return 0; +} + +static int sram_reboot_mode_probe(struct platform_device *pdev) +{ + struct resource *res; + int ret; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return PTR_ERR(res); + + reboot_reason_val_addr = devm_ioremap(&pdev->dev, res->start, resource_size(res)); + if (IS_ERR(reboot_reason_val_addr)) + return PTR_ERR(reboot_reason_val_addr); + + ret = reboot_mode_register(&pdev->dev, sram_reboot_mode_write); + if (ret) + dev_err(&pdev->dev, "can't register reboot mode\n"); + + return ret; +} + +static const struct of_device_id sram_reboot_mode_of_match[] = { + { .compatible = "sram-reboot-mode" }, + {} +}; + +static struct platform_driver sram_reboot_mode_driver = { + .probe = sram_reboot_mode_probe, + .driver = { + .name = "sram-reboot-mode", + .of_match_table = sram_reboot_mode_of_match, + }, +}; +module_platform_driver(sram_reboot_mode_driver); + +MODULE_AUTHOR("John Stultz "); +MODULE_DESCRIPTION("SRAM reboot mode driver"); +MODULE_LICENSE("GPL v2");