1e77063
[openwrt/staging/blogic.git] /
1 From e5810fa0c1bed16fdfb408862a2e17e962ec5cf6 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
3 Date: Tue, 28 Oct 2014 14:40:38 +0100
4 Subject: [PATCH 158/158] MIPS: BCM47XX: Initialize bcma bus later (with mm
5 available)
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
10 Initializaion with memory allocator available will be much simpler, this
11 will allow cleanup in the bcma code.
12
13 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
14 Acked-by: Hauke Mehrtens <hauke@hauke-m.de>
15 Cc: linux-mips@linux-mips.org
16 Patchwork: https://patchwork.linux-mips.org/patch/8234/
17 Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
18 ---
19 arch/mips/bcm47xx/bcm47xx_private.h | 3 +++
20 arch/mips/bcm47xx/irq.c | 8 ++++++++
21 arch/mips/bcm47xx/setup.c | 33 +++++++++++++++++++++++++++------
22 3 files changed, 38 insertions(+), 6 deletions(-)
23
24 --- a/arch/mips/bcm47xx/bcm47xx_private.h
25 +++ b/arch/mips/bcm47xx/bcm47xx_private.h
26 @@ -15,6 +15,9 @@ int __init bcm47xx_buttons_register(void
27 /* leds.c */
28 void __init bcm47xx_leds_register(void);
29
30 +/* setup.c */
31 +void __init bcm47xx_bus_setup(void);
32 +
33 /* workarounds.c */
34 void __init bcm47xx_workarounds(void);
35
36 --- a/arch/mips/bcm47xx/irq.c
37 +++ b/arch/mips/bcm47xx/irq.c
38 @@ -22,6 +22,8 @@
39 * 675 Mass Ave, Cambridge, MA 02139, USA.
40 */
41
42 +#include "bcm47xx_private.h"
43 +
44 #include <linux/types.h>
45 #include <linux/interrupt.h>
46 #include <linux/irq.h>
47 @@ -65,6 +67,12 @@ DEFINE_HWx_IRQDISPATCH(7)
48
49 void __init arch_init_irq(void)
50 {
51 + /*
52 + * This is the first arch callback after mm_init (we can use kmalloc),
53 + * so let's finish bus initialization now.
54 + */
55 + bcm47xx_bus_setup();
56 +
57 #ifdef CONFIG_BCM47XX_BCMA
58 if (bcm47xx_bus_type == BCM47XX_BUS_TYPE_BCMA) {
59 bcma_write32(bcm47xx_bus.bcma.bus.drv_mips.core,
60 --- a/arch/mips/bcm47xx/setup.c
61 +++ b/arch/mips/bcm47xx/setup.c
62 @@ -156,15 +156,14 @@ static void __init bcm47xx_register_bcma
63 err = bcma_host_soc_register(&bcm47xx_bus.bcma);
64 if (err)
65 panic("Failed to register BCMA bus (err %d)", err);
66 -
67 - err = bcma_host_soc_init(&bcm47xx_bus.bcma);
68 - if (err)
69 - panic("Failed to initialize BCMA bus (err %d)", err);
70 -
71 - bcm47xx_fill_bcma_boardinfo(&bcm47xx_bus.bcma.bus.boardinfo, NULL);
72 }
73 #endif
74
75 +/*
76 + * Memory setup is done in the early part of MIPS's arch_mem_init. It's supposed
77 + * to detect memory and record it with add_memory_region.
78 + * Any extra initializaion performed here must not use kmalloc or bootmem.
79 + */
80 void __init plat_mem_setup(void)
81 {
82 struct cpuinfo_mips *c = &current_cpu_data;
83 @@ -193,6 +192,28 @@ void __init plat_mem_setup(void)
84 _machine_restart = bcm47xx_machine_restart;
85 _machine_halt = bcm47xx_machine_halt;
86 pm_power_off = bcm47xx_machine_halt;
87 +}
88 +
89 +/*
90 + * This finishes bus initialization doing things that were not possible without
91 + * kmalloc. Make sure to call it late enough (after mm_init).
92 + */
93 +void __init bcm47xx_bus_setup(void)
94 +{
95 +#ifdef CONFIG_BCM47XX_BCMA
96 + if (bcm47xx_bus_type == BCM47XX_BUS_TYPE_BCMA) {
97 + int err;
98 +
99 + err = bcma_host_soc_init(&bcm47xx_bus.bcma);
100 + if (err)
101 + panic("Failed to initialize BCMA bus (err %d)", err);
102 +
103 + bcm47xx_fill_bcma_boardinfo(&bcm47xx_bus.bcma.bus.boardinfo,
104 + NULL);
105 + }
106 +#endif
107 +
108 + /* With bus initialized we can access NVRAM and detect the board */
109 bcm47xx_board_detect();
110 mips_set_machine_name(bcm47xx_board_get_name());
111 }