aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/layerscape/patches-4.4/8036-ls2085a-Add-support-for-reset.patch
blob: 62420191b73bceaa167f0ffab4a33cd1936e7250 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
From 4b9227ba510562a51e87487905895aea97e17e77 Mon Sep 17 00:00:00 2001
From: pankaj chauhan <pankaj.chauhan@freescale.com>
Date: Tue, 3 Feb 2015 13:08:52 +0530
Subject: [PATCH 36/70] ls2085a: Add support for reset

Add support for layerscape reset driver.
Reset is implemented by raising RESET_REQ_B.

Signed-off-by: pankaj chauhan <pankaj.chauhan@freescale.com>
Signed-off-by: Stuart Yoder <stuart.yoder@freescale.com>
(cherry picked from commit f248be3aea58ca32b7d77413d742996249b293e9)
---
 drivers/power/reset/Kconfig     |    7 ++-
 drivers/power/reset/Makefile    |    1 +
 drivers/power/reset/ls-reboot.c |   93 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 100 insertions(+), 1 deletion(-)
 create mode 100644 drivers/power/reset/ls-reboot.c

--- a/drivers/power/reset/Kconfig
+++ b/drivers/power/reset/Kconfig
@@ -173,5 +173,10 @@ config POWER_RESET_ZX
 	help
 	  Reboot support for ZTE SoCs.
 
-endif
+config POWER_RESET_LAYERSCAPE
+	bool "Freescale LayerScape reset driver"
+	depends on ARCH_FSL_LS2085A
+	help
+	  Reboot support for the Freescale LayerScape SoCs.
 
+endif
--- a/drivers/power/reset/Makefile
+++ b/drivers/power/reset/Makefile
@@ -20,3 +20,4 @@ obj-$(CONFIG_POWER_RESET_SYSCON) += sysc
 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
+obj-$(CONFIG_POWER_RESET_LAYERSCAPE) += ls-reboot.o
--- /dev/null
+++ b/drivers/power/reset/ls-reboot.c
@@ -0,0 +1,93 @@
+/*
+ * Freescale LayerScape reboot driver
+ *
+ * Copyright (c) 2015, Freescale Semiconductor.
+ * Author: Pankaj Chauhan <pankaj.chauhan@freescale.com>
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <linux/io.h>
+#include <linux/of_device.h>
+#include <linux/of_address.h>
+#include <linux/platform_device.h>
+#include <linux/stat.h>
+#include <linux/slab.h>
+#include <asm/system_misc.h>
+
+struct	ls_reboot_priv {
+	struct device *dev;
+	u32 *rstcr;
+};
+
+static struct ls_reboot_priv	*ls_reboot_priv;
+
+static void ls_reboot(enum reboot_mode reboot_mode, const char *cmd)
+{
+	struct ls_reboot_priv	*priv = ls_reboot_priv;
+	u32 val;
+	unsigned long timeout;
+
+	if (ls_reboot_priv) {
+		val = readl(priv->rstcr);
+		val |= 0x02;
+		writel(val, priv->rstcr);
+	}
+
+	timeout = jiffies + HZ;
+	while (time_before(jiffies, timeout))
+		cpu_relax();
+
+}
+
+static int ls_reboot_probe(struct platform_device *pdev)
+{
+	ls_reboot_priv = devm_kzalloc(&pdev->dev,
+				sizeof(*ls_reboot_priv), GFP_KERNEL);
+	if (!ls_reboot_priv) {
+		dev_err(&pdev->dev, "out of memory for context\n");
+		return -ENODEV;
+	}
+
+	ls_reboot_priv->rstcr = of_iomap(pdev->dev.of_node, 0);
+	if (!ls_reboot_priv->rstcr) {
+		devm_kfree(&pdev->dev, ls_reboot_priv);
+		dev_err(&pdev->dev, "can not map resource\n");
+		return -ENODEV;
+	}
+
+	ls_reboot_priv->dev = &pdev->dev;
+
+	arm_pm_restart = ls_reboot;
+
+	return 0;
+}
+
+static struct of_device_id ls_reboot_of_match[] = {
+	{ .compatible = "fsl,ls-reset" },
+	{}
+};
+
+static struct platform_driver ls_reboot_driver = {
+	.probe = ls_reboot_probe,
+	.driver = {
+		.name = "ls-reset",
+		.of_match_table = ls_reboot_of_match,
+	},
+};
+
+static int __init ls_reboot_init(void)
+{
+	return platform_driver_register(&ls_reboot_driver);
+}
+device_initcall(ls_reboot_init);