aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/layerscape/patches-4.4/8037-ls1043a-Add-support-for-reset.patch
blob: bd2d90e9bc1efce32d94bf6801ce8973551f711c (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
From 5d7f8473e3472c16703bf5692d0b13f47d08c70a Mon Sep 17 00:00:00 2001
From: Shaohui Xie <Shaohui.Xie@freescale.com>
Date: Fri, 22 Jan 2016 12:01:28 +0800
Subject: [PATCH 37/70] ls1043a: Add support for reset

The reset in ls1043a is similar to ls2085a, but accessed in big endian,
so we modify the existing driver to handle endianness, if driver probes
property 'big-endian' in DTS, driver works in big endian mode,
otherwise, driver works in little endian by default.

Signed-off-by: Shaohui Xie <Shaohui.Xie@freescale.com>
---
 drivers/power/reset/ls-reboot.c |   18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

--- a/drivers/power/reset/ls-reboot.c
+++ b/drivers/power/reset/ls-reboot.c
@@ -28,6 +28,7 @@
 struct	ls_reboot_priv {
 	struct device *dev;
 	u32 *rstcr;
+	bool is_big_endian;
 };
 
 static struct ls_reboot_priv	*ls_reboot_priv;
@@ -39,9 +40,15 @@ static void ls_reboot(enum reboot_mode r
 	unsigned long timeout;
 
 	if (ls_reboot_priv) {
-		val = readl(priv->rstcr);
-		val |= 0x02;
-		writel(val, priv->rstcr);
+		if (priv->is_big_endian) {
+			val = ioread32be(priv->rstcr);
+			val |= 0x02;
+			iowrite32be(val, priv->rstcr);
+		} else {
+			val = readl(priv->rstcr);
+			val |= 0x02;
+			writel(val, priv->rstcr);
+		}
 	}
 
 	timeout = jiffies + HZ;
@@ -66,6 +73,11 @@ static int ls_reboot_probe(struct platfo
 		return -ENODEV;
 	}
 
+	if (of_get_property(pdev->dev.of_node, "big-endian", NULL))
+		ls_reboot_priv->is_big_endian = true;
+	else
+		ls_reboot_priv->is_big_endian = false;
+
 	ls_reboot_priv->dev = &pdev->dev;
 
 	arm_pm_restart = ls_reboot;