From: Brian Norris <computersforpeace@gmail.com>
To: Arnd Bergmann <arnd@arndb.de>, Olof Johansson <olof@lixom.net>
Cc: Matt Porter <mporter@linaro.org>,
Christian Daudt <bcm@fixthebug.org>,
Russell King <linux@arm.linux.org.uk>,
linux-arm-kernel@lists.infradead.org,
Linux Kernel <linux-kernel@vger.kernel.org>,
devicetree@vger.kernel.org, Gregory Fong <gregory.0xf0@gmail.com>,
Brian Norris <computersforpeace@gmail.com>,
Florian Fainelli <f.fainelli@gmail.com>,
Marc Carino <marc.ceeeee@gmail.com>,
Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>,
David Woodhouse <dwmw2@infradead.org>
Subject: [PATCH v8 02/11] power: reset: Add reboot driver for brcmstb
Date: Mon, 21 Jul 2014 14:07:57 -0700 [thread overview]
Message-ID: <1405976886-27807-3-git-send-email-computersforpeace@gmail.com> (raw)
In-Reply-To: <1405976886-27807-1-git-send-email-computersforpeace@gmail.com>
From: Marc Carino <marc.ceeeee@gmail.com>
Add support for reboot functionality on boards with ARM-based
Broadcom STB chipsets.
Signed-off-by: Marc Carino <marc.ceeeee@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: David Woodhouse <dwmw2@infradead.org>
---
arch/arm/mach-bcm/Kconfig | 1 +
drivers/power/reset/Kconfig | 10 +++
drivers/power/reset/Makefile | 1 +
drivers/power/reset/brcmstb-reboot.c | 120 +++++++++++++++++++++++++++++++++++
4 files changed, 132 insertions(+)
create mode 100644 drivers/power/reset/brcmstb-reboot.c
diff --git a/arch/arm/mach-bcm/Kconfig b/arch/arm/mach-bcm/Kconfig
index 0073633e7699..9782e8d80647 100644
--- a/arch/arm/mach-bcm/Kconfig
+++ b/arch/arm/mach-bcm/Kconfig
@@ -94,6 +94,7 @@ config ARCH_BRCMSTB
select MIGHT_HAVE_PCI
select HAVE_SMP
select HAVE_ARM_ARCH_TIMER
+ select POWER_RESET_BRCMSTB
help
Say Y if you intend to run the kernel on a Broadcom ARM-based STB
chipset.
diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
index bdcf5173e377..fcb9825debe5 100644
--- a/drivers/power/reset/Kconfig
+++ b/drivers/power/reset/Kconfig
@@ -20,6 +20,16 @@ config POWER_RESET_AXXIA
Say Y if you have an Axxia family SoC.
+config POWER_RESET_BRCMSTB
+ bool "Broadcom STB reset driver"
+ depends on POWER_RESET && ARCH_BRCMSTB
+ help
+ This driver provides restart support for ARM-based Broadcom STB
+ boards.
+
+ Say Y here if you have an ARM-based Broadcom STB board and you wish
+ to have restart support.
+
config POWER_RESET_GPIO
bool "GPIO power-off driver"
depends on OF_GPIO && POWER_RESET
diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile
index dde2e8bbac53..7379818ca69d 100644
--- a/drivers/power/reset/Makefile
+++ b/drivers/power/reset/Makefile
@@ -1,5 +1,6 @@
obj-$(CONFIG_POWER_RESET_AS3722) += as3722-poweroff.o
obj-$(CONFIG_POWER_RESET_AXXIA) += axxia-reset.o
+obj-$(CONFIG_POWER_RESET_BRCMSTB) += brcmstb-reboot.o
obj-$(CONFIG_POWER_RESET_GPIO) += gpio-poweroff.o
obj-$(CONFIG_POWER_RESET_MSM) += msm-poweroff.o
obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o
diff --git a/drivers/power/reset/brcmstb-reboot.c b/drivers/power/reset/brcmstb-reboot.c
new file mode 100644
index 000000000000..3f236924742a
--- /dev/null
+++ b/drivers/power/reset/brcmstb-reboot.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2013 Broadcom Corporation
+ *
+ * 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 version 2.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/device.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/io.h>
+#include <linux/jiffies.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
+#include <linux/of_platform.h>
+#include <linux/platform_device.h>
+#include <linux/printk.h>
+#include <linux/reboot.h>
+#include <linux/regmap.h>
+#include <linux/smp.h>
+#include <linux/mfd/syscon.h>
+
+#include <asm/system_misc.h>
+
+#define RESET_SOURCE_ENABLE_REG 1
+#define SW_MASTER_RESET_REG 2
+
+static struct regmap *regmap;
+static u32 rst_src_en;
+static u32 sw_mstr_rst;
+
+static void brcmstb_reboot(enum reboot_mode mode, const char *cmd)
+{
+ int rc;
+ u32 tmp;
+
+ rc = regmap_write(regmap, rst_src_en, 1);
+ if (rc) {
+ pr_err("failed to write rst_src_en (%d)\n", rc);
+ return;
+ }
+
+ rc = regmap_read(regmap, rst_src_en, &tmp);
+ if (rc) {
+ pr_err("failed to read rst_src_en (%d)\n", rc);
+ return;
+ }
+
+ rc = regmap_write(regmap, sw_mstr_rst, 1);
+ if (rc) {
+ pr_err("failed to write sw_mstr_rst (%d)\n", rc);
+ return;
+ }
+
+ rc = regmap_read(regmap, sw_mstr_rst, &tmp);
+ if (rc) {
+ pr_err("failed to read sw_mstr_rst (%d)\n", rc);
+ return;
+ }
+
+ while (1)
+ ;
+}
+
+static int brcmstb_reboot_probe(struct platform_device *pdev)
+{
+ int rc;
+ struct device_node *np = pdev->dev.of_node;
+
+ regmap = syscon_regmap_lookup_by_phandle(np, "syscon");
+ if (IS_ERR(regmap)) {
+ pr_err("failed to get syscon phandle\n");
+ return -EINVAL;
+ }
+
+ rc = of_property_read_u32_index(np, "syscon", RESET_SOURCE_ENABLE_REG,
+ &rst_src_en);
+ if (rc) {
+ pr_err("can't get rst_src_en offset (%d)\n", rc);
+ return -EINVAL;
+ }
+
+ rc = of_property_read_u32_index(np, "syscon", SW_MASTER_RESET_REG,
+ &sw_mstr_rst);
+ if (rc) {
+ pr_err("can't get sw_mstr_rst offset (%d)\n", rc);
+ return -EINVAL;
+ }
+
+ arm_pm_restart = brcmstb_reboot;
+
+ return 0;
+}
+
+static const struct of_device_id of_match[] = {
+ { .compatible = "brcm,brcmstb-reboot", },
+ {},
+};
+
+static struct platform_driver brcmstb_reboot_driver = {
+ .probe = brcmstb_reboot_probe,
+ .driver = {
+ .name = "brcmstb-reboot",
+ .owner = THIS_MODULE,
+ .of_match_table = of_match,
+ },
+};
+
+static int __init brcmstb_reboot_init(void)
+{
+ return platform_driver_probe(&brcmstb_reboot_driver,
+ brcmstb_reboot_probe);
+}
+subsys_initcall(brcmstb_reboot_init);
--
1.9.1
next prev parent reply other threads:[~2014-07-21 21:07 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-21 21:07 [PATCH v8 00/11] ARM: brcmstb: Add Broadcom STB SoC support Brian Norris
2014-07-21 21:07 ` [PATCH v8 01/11] ARM: brcmstb: add infrastructure for ARM-based Broadcom STB SoCs Brian Norris
2014-07-30 9:26 ` Russell King - ARM Linux
[not found] ` <20140730092635.GI30282-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2014-07-31 2:36 ` Brian Norris
[not found] ` <1405976886-27807-2-git-send-email-computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-07-30 17:09 ` Rob Herring
[not found] ` <CAL_Jsq+Nbk7m9KXhG+Chdpvurp75RrvhFR2oE_LGxV444GSe9Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-07-31 2:23 ` Brian Norris
2014-07-31 8:43 ` Russell King - ARM Linux
[not found] ` <20140731084315.GJ30282-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2014-07-31 22:06 ` Brian Norris
2014-08-02 9:27 ` Russell King - ARM Linux
2014-08-13 23:47 ` Brian Norris
2014-08-19 0:02 ` Brian Norris
2014-08-01 14:33 ` Rob Herring
[not found] ` <CAL_Jsq+47YtqWwOkxYDzaEOG-+oouvpXvmGaX+Wh3wQ+BNAx_w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-08-01 19:29 ` Florian Fainelli
[not found] ` <CAGVrzcaEV81BW+a--QgQSHiLb6UQDFsP3cqQxGwV206MRx4gXw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-08-01 19:46 ` Matt Porter
2014-08-02 8:21 ` Russell King - ARM Linux
2014-08-02 8:19 ` Russell King - ARM Linux
2014-08-04 17:39 ` Brian Norris
2014-07-21 21:07 ` Brian Norris [this message]
[not found] ` <1405976886-27807-3-git-send-email-computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-07-22 7:28 ` [PATCH v8 02/11] power: reset: Add reboot driver for brcmstb Arnd Bergmann
2014-07-22 20:02 ` Brian Norris
2014-07-22 21:02 ` Arnd Bergmann
2014-07-22 22:51 ` Brian Norris
2014-07-21 21:07 ` [PATCH v8 03/11] ARM: brcmstb: add debug UART for earlyprintk support Brian Norris
2014-08-02 8:30 ` Russell King - ARM Linux
2014-08-04 16:56 ` Brian Norris
2014-08-13 22:11 ` Brian Norris
[not found] ` <CAN8TOE8w5bUT5byHiJrYr8AzaZ+EADzE+aoH6f2x2tFc1+1eQw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-08-13 22:16 ` Olof Johansson
2014-09-02 22:22 ` Florian Fainelli
2014-09-02 22:44 ` Brian Norris
2014-07-21 21:07 ` [PATCH v8 04/11] ARM: do CPU-specific init for Broadcom Brahma15 cores Brian Norris
[not found] ` <1405976886-27807-1-git-send-email-computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-07-21 21:08 ` [PATCH v8 05/11] ARM: Enable erratum 798181 for Broadcom Brahma-B15 Brian Norris
2014-07-22 7:35 ` [PATCH v8 00/11] ARM: brcmstb: Add Broadcom STB SoC support Arnd Bergmann
2014-07-22 20:44 ` Brian Norris
2014-07-22 20:57 ` Arnd Bergmann
2014-07-22 21:33 ` Matt Porter
2014-07-22 22:24 ` Arnd Bergmann
2014-07-22 22:30 ` Brian Norris
2014-07-21 21:08 ` [PATCH v8 06/11] ARM: brcmstb: add CPU binding for Broadcom Brahma15 Brian Norris
2014-07-21 21:08 ` [PATCH v8 07/11] ARM: brcmstb: add misc. DT bindings for brcmstb Brian Norris
2014-07-21 21:08 ` [PATCH v8 08/11] ARM: brcmstb: gic: add compatible string for Broadcom Brahma15 Brian Norris
2014-07-21 21:08 ` [PATCH v8 09/11] ARM: brcmstb: dts: add a reference DTS for Broadcom 7445 Brian Norris
2014-07-21 21:08 ` [PATCH v8 10/11] ARM: brcmstb: select GISB arbiter and interrupt drivers Brian Norris
2014-07-21 21:08 ` [PATCH v8 11/11] MAINTAINERS: add entry for Broadcom ARM STB architecture Brian Norris
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1405976886-27807-3-git-send-email-computersforpeace@gmail.com \
--to=computersforpeace@gmail.com \
--cc=arnd@arndb.de \
--cc=bcm@fixthebug.org \
--cc=dbaryshkov@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=dwmw2@infradead.org \
--cc=f.fainelli@gmail.com \
--cc=gregory.0xf0@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=marc.ceeeee@gmail.com \
--cc=mporter@linaro.org \
--cc=olof@lixom.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).