aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power/reset
diff options
context:
space:
mode:
authorMarc Carino <marc.ceeeee@gmail.com>2014-07-22 19:48:03 -0400
committerSebastian Reichel <sre@kernel.org>2014-07-23 07:49:23 -0400
commit030494e75064cb4fcbeb609d845ae0c9ceade2b9 (patch)
tree021338b1d18dd2b528f8a100db4111e3aa2176e2 /drivers/power/reset
parentc128d39737fbf23d978eb05a9c7915507a69c1df (diff)
power: reset: Add reboot driver for brcmstb
Add support for reboot functionality on boards with ARM-based Broadcom STB chipsets. Make it built-in by default for ARCH_BRCMSTB, but allow it to be configurable under COMPILE_TEST. Signed-off-by: Marc Carino <marc.ceeeee@gmail.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
Diffstat (limited to 'drivers/power/reset')
-rw-r--r--drivers/power/reset/Kconfig11
-rw-r--r--drivers/power/reset/Makefile1
-rw-r--r--drivers/power/reset/brcmstb-reboot.c120
3 files changed, 132 insertions, 0 deletions
diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
index bdcf5173e377..f2ac54df496f 100644
--- a/drivers/power/reset/Kconfig
+++ b/drivers/power/reset/Kconfig
@@ -20,6 +20,17 @@ config POWER_RESET_AXXIA
20 20
21 Say Y if you have an Axxia family SoC. 21 Say Y if you have an Axxia family SoC.
22 22
23config POWER_RESET_BRCMSTB
24 bool "Broadcom STB reset driver" if COMPILE_TEST
25 depends on POWER_RESET && ARM
26 default ARCH_BRCMSTB
27 help
28 This driver provides restart support for ARM-based Broadcom STB
29 boards.
30
31 Say Y here if you have an ARM-based Broadcom STB board and you wish
32 to have restart support.
33
23config POWER_RESET_GPIO 34config POWER_RESET_GPIO
24 bool "GPIO power-off driver" 35 bool "GPIO power-off driver"
25 depends on OF_GPIO && POWER_RESET 36 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 @@
1obj-$(CONFIG_POWER_RESET_AS3722) += as3722-poweroff.o 1obj-$(CONFIG_POWER_RESET_AS3722) += as3722-poweroff.o
2obj-$(CONFIG_POWER_RESET_AXXIA) += axxia-reset.o 2obj-$(CONFIG_POWER_RESET_AXXIA) += axxia-reset.o
3obj-$(CONFIG_POWER_RESET_BRCMSTB) += brcmstb-reboot.o
3obj-$(CONFIG_POWER_RESET_GPIO) += gpio-poweroff.o 4obj-$(CONFIG_POWER_RESET_GPIO) += gpio-poweroff.o
4obj-$(CONFIG_POWER_RESET_MSM) += msm-poweroff.o 5obj-$(CONFIG_POWER_RESET_MSM) += msm-poweroff.o
5obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o 6obj-$(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 @@
1/*
2 * Copyright (C) 2013 Broadcom Corporation
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation version 2.
7 *
8 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9 * kind, whether express or implied; without even the implied warranty
10 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14#include <linux/device.h>
15#include <linux/errno.h>
16#include <linux/init.h>
17#include <linux/io.h>
18#include <linux/jiffies.h>
19#include <linux/of_address.h>
20#include <linux/of_irq.h>
21#include <linux/of_platform.h>
22#include <linux/platform_device.h>
23#include <linux/printk.h>
24#include <linux/reboot.h>
25#include <linux/regmap.h>
26#include <linux/smp.h>
27#include <linux/mfd/syscon.h>
28
29#include <asm/system_misc.h>
30
31#define RESET_SOURCE_ENABLE_REG 1
32#define SW_MASTER_RESET_REG 2
33
34static struct regmap *regmap;
35static u32 rst_src_en;
36static u32 sw_mstr_rst;
37
38static void brcmstb_reboot(enum reboot_mode mode, const char *cmd)
39{
40 int rc;
41 u32 tmp;
42
43 rc = regmap_write(regmap, rst_src_en, 1);
44 if (rc) {
45 pr_err("failed to write rst_src_en (%d)\n", rc);
46 return;
47 }
48
49 rc = regmap_read(regmap, rst_src_en, &tmp);
50 if (rc) {
51 pr_err("failed to read rst_src_en (%d)\n", rc);
52 return;
53 }
54
55 rc = regmap_write(regmap, sw_mstr_rst, 1);
56 if (rc) {
57 pr_err("failed to write sw_mstr_rst (%d)\n", rc);
58 return;
59 }
60
61 rc = regmap_read(regmap, sw_mstr_rst, &tmp);
62 if (rc) {
63 pr_err("failed to read sw_mstr_rst (%d)\n", rc);
64 return;
65 }
66
67 while (1)
68 ;
69}
70
71static int brcmstb_reboot_probe(struct platform_device *pdev)
72{
73 int rc;
74 struct device_node *np = pdev->dev.of_node;
75
76 regmap = syscon_regmap_lookup_by_phandle(np, "syscon");
77 if (IS_ERR(regmap)) {
78 pr_err("failed to get syscon phandle\n");
79 return -EINVAL;
80 }
81
82 rc = of_property_read_u32_index(np, "syscon", RESET_SOURCE_ENABLE_REG,
83 &rst_src_en);
84 if (rc) {
85 pr_err("can't get rst_src_en offset (%d)\n", rc);
86 return -EINVAL;
87 }
88
89 rc = of_property_read_u32_index(np, "syscon", SW_MASTER_RESET_REG,
90 &sw_mstr_rst);
91 if (rc) {
92 pr_err("can't get sw_mstr_rst offset (%d)\n", rc);
93 return -EINVAL;
94 }
95
96 arm_pm_restart = brcmstb_reboot;
97
98 return 0;
99}
100
101static const struct of_device_id of_match[] = {
102 { .compatible = "brcm,brcmstb-reboot", },
103 {},
104};
105
106static struct platform_driver brcmstb_reboot_driver = {
107 .probe = brcmstb_reboot_probe,
108 .driver = {
109 .name = "brcmstb-reboot",
110 .owner = THIS_MODULE,
111 .of_match_table = of_match,
112 },
113};
114
115static int __init brcmstb_reboot_init(void)
116{
117 return platform_driver_probe(&brcmstb_reboot_driver,
118 brcmstb_reboot_probe);
119}
120subsys_initcall(brcmstb_reboot_init);