5bedd913687061428eb535f3846f36551646aa2a
[openwrt.git] / target / linux / lantiq / patches-3.7 / 0002-MIPS-lantiq-fix-bootselect-bits-on-XRX200-SoC.patch
1 From 15753b6586710d788f36cfd5fbb98d0805b390ab Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Fri, 9 Nov 2012 13:31:51 +0100
4 Subject: [PATCH 2/6] MIPS: lantiq: fix bootselect bits on XRX200 SoC
5
6 The XRX200 SoC family has a different register layout for reading the boot
7 selection bits.
8
9 Signed-off-by: John Crispin <blogic@openwrt.org>
10 Patchwork: http://patchwork.linux-mips.org/patch/4519
11 ---
12  arch/mips/lantiq/xway/reset.c |   22 +++++++++++++++-------
13  1 file changed, 15 insertions(+), 7 deletions(-)
14
15 --- a/arch/mips/lantiq/xway/reset.c
16 +++ b/arch/mips/lantiq/xway/reset.c
17 @@ -34,11 +34,12 @@
18  /* reset cause */
19  #define RCU_STAT_SHIFT         26
20  /* boot selection */
21 -#define RCU_BOOT_SEL_SHIFT     26
22 -#define RCU_BOOT_SEL_MASK      0x7
23 +#define RCU_BOOT_SEL(x)                ((x >> 18) & 0x7)
24 +#define RCU_BOOT_SEL_XRX200(x) (((x >> 17) & 0xf) | ((x >> 8) & 0x10))
25  
26  /* remapped base addr of the reset control unit */
27  static void __iomem *ltq_rcu_membase;
28 +static struct device_node *ltq_rcu_np;
29  
30  /* This function is used by the watchdog driver */
31  int ltq_reset_cause(void)
32 @@ -52,7 +53,11 @@ EXPORT_SYMBOL_GPL(ltq_reset_cause);
33  unsigned char ltq_boot_select(void)
34  {
35         u32 val = ltq_rcu_r32(RCU_RST_STAT);
36 -       return (val >> RCU_BOOT_SEL_SHIFT) & RCU_BOOT_SEL_MASK;
37 +
38 +       if (of_device_is_compatible(ltq_rcu_np, "lantiq,rcu-xrx200"))
39 +               return RCU_BOOT_SEL_XRX200(val);
40 +
41 +       return RCU_BOOT_SEL(val);
42  }
43  
44  /* reset a io domain for u micro seconds */
45 @@ -85,14 +90,17 @@ static void ltq_machine_power_off(void)
46  static int __init mips_reboot_setup(void)
47  {
48         struct resource res;
49 -       struct device_node *np =
50 -               of_find_compatible_node(NULL, NULL, "lantiq,rcu-xway");
51 +
52 +       ltq_rcu_np = of_find_compatible_node(NULL, NULL, "lantiq,rcu-xway");
53 +       if (!ltq_rcu_np)
54 +               ltq_rcu_np = of_find_compatible_node(NULL, NULL,
55 +                                                       "lantiq,rcu-xrx200");
56  
57         /* check if all the reset register range is available */
58 -       if (!np)
59 +       if (!ltq_rcu_np)
60                 panic("Failed to load reset resources from devicetree");
61  
62 -       if (of_address_to_resource(np, 0, &res))
63 +       if (of_address_to_resource(ltq_rcu_np, 0, &res))
64                 panic("Failed to get rcu memory range");
65  
66         if (request_mem_region(res.start, resource_size(&res), res.name) < 0)