7fdbaa3853cf43587e69190e9367edc082163db8
[librecmc/librecmc.git] / target / linux / bcm53xx / patches-3.14 / 131-ARM-BCM5301X-add-restart-support.patch
1 From 28b11a8b1258214b3b5d58bb6e3bbcb0fc9fd4fe Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
3 Date: Thu, 31 Jul 2014 07:28:05 +0200
4 Subject: [PATCH] ARM: BCM5301X: add restart support
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
10 ---
11  arch/arm/mach-bcm/bcm_5301x.c | 31 +++++++++++++++++++++++++++++++
12  1 file changed, 31 insertions(+)
13
14 diff --git a/arch/arm/mach-bcm/bcm_5301x.c b/arch/arm/mach-bcm/bcm_5301x.c
15 index edff697..e349897 100644
16 --- a/arch/arm/mach-bcm/bcm_5301x.c
17 +++ b/arch/arm/mach-bcm/bcm_5301x.c
18 @@ -12,9 +12,26 @@
19  #include <asm/siginfo.h>
20  #include <asm/signal.h>
21  
22 +#include <linux/bcma/bcma.h>
23  
24  static bool first_fault = true;
25  
26 +static struct bcma_bus *bcm5301x_get_bcma_bus(void)
27 +{
28 +       struct device_node *np;
29 +       struct platform_device *pdev;
30 +
31 +       np = of_find_compatible_node(NULL, NULL, "brcm,bus-aix");
32 +       if (!np)
33 +               return NULL;
34 +
35 +       pdev = of_find_device_by_node(np);
36 +       if (!pdev)
37 +               return NULL;
38 +
39 +       return platform_get_drvdata(pdev);
40 +}
41 +
42  static int bcm5301x_abort_handler(unsigned long addr, unsigned int fsr,
43                                  struct pt_regs *regs)
44  {
45 @@ -49,6 +66,19 @@ static void __init bcm5301x_dt_init(void)
46         of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
47  }
48  
49 +static void bcm5301x_restart(enum reboot_mode mode, const char *cmd)
50 +{
51 +       struct bcma_bus *bus = bcm5301x_get_bcma_bus();
52 +
53 +       if (bus)
54 +               bcma_chipco_watchdog_timer_set(&bus->drv_cc, 1);
55 +       else
56 +               pr_warn("Unable to access bcma bus\n");
57 +
58 +       while (1)
59 +               ;
60 +}
61 +
62  static const char __initconst *bcm5301x_dt_compat[] = {
63         "brcm,bcm4708",
64         NULL,
65 @@ -57,5 +87,6 @@ static const char __initconst *bcm5301x_dt_compat[] = {
66  DT_MACHINE_START(BCM5301X, "BCM5301X")
67         .init_early     = bcm5301x_init_early,
68         .init_machine   = bcm5301x_dt_init,
69 +       .restart        = bcm5301x_restart,
70         .dt_compat      = bcm5301x_dt_compat,
71  MACHINE_END
72 -- 
73 1.8.4.5
74