lantiq: add v3.10 patches
[openwrt.git] / target / linux / lantiq / patches-3.10 / 0011-MIPS-lantiq-add-reset-controller-api-support.patch
1 From ab066a50a4aa00a862f467579960e8d12693df18 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Tue, 3 Sep 2013 13:18:12 +0200
4 Subject: [PATCH 11/34] MIPS: lantiq: add reset-controller api support
5
6 Add a reset-controller binding for the reset registers found on the lantiq
7 SoC.
8
9 Signed-off-by: John Crispin <blogic@openwrt.org>
10 ---
11  arch/mips/lantiq/xway/reset.c |   61 +++++++++++++++++++++++++++++++++++++++++
12  1 file changed, 61 insertions(+)
13
14 diff --git a/arch/mips/lantiq/xway/reset.c b/arch/mips/lantiq/xway/reset.c
15 index 1fa0f17..a1e06b7 100644
16 --- a/arch/mips/lantiq/xway/reset.c
17 +++ b/arch/mips/lantiq/xway/reset.c
18 @@ -14,6 +14,7 @@
19  #include <linux/delay.h>
20  #include <linux/of_address.h>
21  #include <linux/of_platform.h>
22 +#include <linux/reset-controller.h>
23  
24  #include <asm/reboot.h>
25  
26 @@ -113,6 +114,66 @@ void ltq_reset_once(unsigned int module, ulong u)
27         ltq_rcu_w32(ltq_rcu_r32(RCU_RST_REQ) & ~module, RCU_RST_REQ);
28  }
29  
30 +static int ltq_assert_device(struct reset_controller_dev *rcdev,
31 +                               unsigned long id)
32 +{
33 +       u32 val;
34 +
35 +       if (id < 8)
36 +               return -1;
37 +
38 +       val = ltq_rcu_r32(RCU_RST_REQ);
39 +       val |= BIT(id);
40 +       ltq_rcu_w32(val, RCU_RST_REQ);
41 +
42 +       return 0;
43 +}
44 +
45 +static int ltq_deassert_device(struct reset_controller_dev *rcdev,
46 +                                 unsigned long id)
47 +{
48 +       u32 val;
49 +
50 +       if (id < 8)
51 +               return -1;
52 +
53 +       val = ltq_rcu_r32(RCU_RST_REQ);
54 +       val &= ~BIT(id);
55 +       ltq_rcu_w32(val, RCU_RST_REQ);
56 +
57 +       return 0;
58 +}
59 +
60 +static int ltq_reset_device(struct reset_controller_dev *rcdev,
61 +                              unsigned long id)
62 +{
63 +       ltq_assert_device(rcdev, id);
64 +       return ltq_deassert_device(rcdev, id);
65 +}
66 +
67 +static struct reset_control_ops reset_ops = {
68 +       .reset = ltq_reset_device,
69 +       .assert = ltq_assert_device,
70 +       .deassert = ltq_deassert_device,
71 +};
72 +
73 +static struct reset_controller_dev reset_dev = {
74 +       .ops                    = &reset_ops,
75 +       .owner                  = THIS_MODULE,
76 +       .nr_resets              = 32,
77 +       .of_reset_n_cells       = 1,
78 +};
79 +
80 +void ltq_rst_init(void)
81 +{
82 +       reset_dev.of_node = of_find_compatible_node(NULL, NULL,
83 +                                               "lantiq,xway-reset");
84 +       if (!reset_dev.of_node)
85 +               pr_err("Failed to find reset controller node");
86 +       else
87 +               reset_controller_register(&reset_dev);
88 +}
89 +
90  static void ltq_machine_restart(char *command)
91  {
92         local_irq_disable();
93 -- 
94 1.7.10.4
95