layerscape: add 64b/32b target for ls1043ardb device
[openwrt/staging/wigyori.git] / target / linux / layerscape / patches-4.4 / 8037-ls1043a-Add-support-for-reset.patch
1 From 5d7f8473e3472c16703bf5692d0b13f47d08c70a Mon Sep 17 00:00:00 2001
2 From: Shaohui Xie <Shaohui.Xie@freescale.com>
3 Date: Fri, 22 Jan 2016 12:01:28 +0800
4 Subject: [PATCH 37/70] ls1043a: Add support for reset
5
6 The reset in ls1043a is similar to ls2085a, but accessed in big endian,
7 so we modify the existing driver to handle endianness, if driver probes
8 property 'big-endian' in DTS, driver works in big endian mode,
9 otherwise, driver works in little endian by default.
10
11 Signed-off-by: Shaohui Xie <Shaohui.Xie@freescale.com>
12 ---
13 drivers/power/reset/ls-reboot.c | 18 +++++++++++++++---
14 1 file changed, 15 insertions(+), 3 deletions(-)
15
16 --- a/drivers/power/reset/ls-reboot.c
17 +++ b/drivers/power/reset/ls-reboot.c
18 @@ -28,6 +28,7 @@
19 struct ls_reboot_priv {
20 struct device *dev;
21 u32 *rstcr;
22 + bool is_big_endian;
23 };
24
25 static struct ls_reboot_priv *ls_reboot_priv;
26 @@ -39,9 +40,15 @@ static void ls_reboot(enum reboot_mode r
27 unsigned long timeout;
28
29 if (ls_reboot_priv) {
30 - val = readl(priv->rstcr);
31 - val |= 0x02;
32 - writel(val, priv->rstcr);
33 + if (priv->is_big_endian) {
34 + val = ioread32be(priv->rstcr);
35 + val |= 0x02;
36 + iowrite32be(val, priv->rstcr);
37 + } else {
38 + val = readl(priv->rstcr);
39 + val |= 0x02;
40 + writel(val, priv->rstcr);
41 + }
42 }
43
44 timeout = jiffies + HZ;
45 @@ -66,6 +73,11 @@ static int ls_reboot_probe(struct platfo
46 return -ENODEV;
47 }
48
49 + if (of_get_property(pdev->dev.of_node, "big-endian", NULL))
50 + ls_reboot_priv->is_big_endian = true;
51 + else
52 + ls_reboot_priv->is_big_endian = false;
53 +
54 ls_reboot_priv->dev = &pdev->dev;
55
56 arm_pm_restart = ls_reboot;