tools: install a fake empty ldconfig script to prevent the system ldconfig from messi...
[openwrt.git] / target / linux / ramips / patches-3.10 / 0009-MIPS-ralink-add-support-for-reset-controller-API.patch
1 From 4e694014a11a407e309f62c7daade545ba71dcf1 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Sun, 28 Jul 2013 13:54:22 +0200
4 Subject: [PATCH 09/25] MIPS: ralink: add support for reset-controller API
5
6 Add a helper for reseting different devices on the SoC.
7
8 Signed-off-by: John Crispin <blogic@openwrt.org>
9 ---
10  arch/mips/Kconfig         |    1 +
11  arch/mips/ralink/common.h |    2 ++
12  arch/mips/ralink/of.c     |    3 +++
13  arch/mips/ralink/reset.c  |   62 +++++++++++++++++++++++++++++++++++++++++++++
14  4 files changed, 68 insertions(+)
15
16 --- a/arch/mips/Kconfig
17 +++ b/arch/mips/Kconfig
18 @@ -374,6 +374,7 @@ config MACH_VR41XX
19         select CSRC_R4K
20         select SYS_HAS_CPU_VR41XX
21         select ARCH_REQUIRE_GPIOLIB
22 +       select ARCH_HAS_RESET_CONTROLLER
23  
24  config NXP_STB220
25         bool "NXP STB220 board"
26 --- a/arch/mips/ralink/common.h
27 +++ b/arch/mips/ralink/common.h
28 @@ -46,6 +46,8 @@ extern void ralink_of_remap(void);
29  extern void ralink_clk_init(void);
30  extern void ralink_clk_add(const char *dev, unsigned long rate);
31  
32 +extern void ralink_rst_init(void);
33 +
34  extern void prom_soc_init(struct ralink_soc_info *soc_info);
35  
36  __iomem void *plat_of_remap_node(const char *node);
37 --- a/arch/mips/ralink/of.c
38 +++ b/arch/mips/ralink/of.c
39 @@ -110,6 +110,9 @@ static int __init plat_of_setup(void)
40         if (of_platform_populate(NULL, of_ids, NULL, NULL))
41                 panic("failed to populate DT\n");
42  
43 +       /* make sure ithat the reset controller is setup early */
44 +       ralink_rst_init();
45 +
46         return 0;
47  }
48  
49 --- a/arch/mips/ralink/reset.c
50 +++ b/arch/mips/ralink/reset.c
51 @@ -10,6 +10,8 @@
52  
53  #include <linux/pm.h>
54  #include <linux/io.h>
55 +#include <linux/of.h>
56 +#include <linux/reset-controller.h>
57  
58  #include <asm/reboot.h>
59  
60 @@ -19,6 +21,66 @@
61  #define SYSC_REG_RESET_CTRL     0x034
62  #define RSTCTL_RESET_SYSTEM     BIT(0)
63  
64 +static int ralink_assert_device(struct reset_controller_dev *rcdev,
65 +                               unsigned long id)
66 +{
67 +       u32 val;
68 +
69 +       if (id < 8)
70 +               return -1;
71 +
72 +       val = rt_sysc_r32(SYSC_REG_RESET_CTRL);
73 +       val |= BIT(id);
74 +       rt_sysc_w32(val, SYSC_REG_RESET_CTRL);
75 +
76 +       return 0;
77 +}
78 +
79 +static int ralink_deassert_device(struct reset_controller_dev *rcdev,
80 +                                 unsigned long id)
81 +{
82 +       u32 val;
83 +
84 +       if (id < 8)
85 +               return -1;
86 +
87 +       val = rt_sysc_r32(SYSC_REG_RESET_CTRL);
88 +       val &= ~BIT(id);
89 +       rt_sysc_w32(val, SYSC_REG_RESET_CTRL);
90 +
91 +       return 0;
92 +}
93 +
94 +static int ralink_reset_device(struct reset_controller_dev *rcdev,
95 +                              unsigned long id)
96 +{
97 +       ralink_assert_device(rcdev, id);
98 +       return ralink_deassert_device(rcdev, id);
99 +}
100 +
101 +static struct reset_control_ops reset_ops = {
102 +       .reset = ralink_reset_device,
103 +       .assert = ralink_assert_device,
104 +       .deassert = ralink_deassert_device,
105 +};
106 +
107 +static struct reset_controller_dev reset_dev = {
108 +       .ops                    = &reset_ops,
109 +       .owner                  = THIS_MODULE,
110 +       .nr_resets              = 32,
111 +       .of_reset_n_cells       = 1,
112 +};
113 +
114 +void ralink_rst_init(void)
115 +{
116 +       reset_dev.of_node = of_find_compatible_node(NULL, NULL,
117 +                                               "ralink,rt2880-reset");
118 +       if (!reset_dev.of_node)
119 +               pr_err("Failed to find reset controller node");
120 +       else
121 +               reset_controller_register(&reset_dev);
122 +}
123 +
124  static void ralink_restart(char *command)
125  {
126         local_irq_disable();