1 From a59da8fb3b2a1f2df5f871464e43cd5b6ca6ceb1 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 12:52:02 +0100
4 Subject: [PATCH 157/158] MIPS: BCM47XX: Move SPROM fallback code into sprom.c
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 This is some general cleanup as well as preparing sprom.c to become a
10 standalone driver. We will need this for bcm53xx ARM arch support.
12 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
13 Acked-by: Hauke Mehrtens <hauke@hauke-m.de>
14 Cc: linux-mips@linux-mips.org
15 Patchwork: https://patchwork.linux-mips.org/patch/8232/
16 Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
18 arch/mips/bcm47xx/bcm47xx_private.h | 3 ++
19 arch/mips/bcm47xx/setup.c | 58 ++-----------------------------
20 arch/mips/bcm47xx/sprom.c | 68 +++++++++++++++++++++++++++++++++++++
21 3 files changed, 73 insertions(+), 56 deletions(-)
23 diff --git a/arch/mips/bcm47xx/bcm47xx_private.h b/arch/mips/bcm47xx/bcm47xx_private.h
24 index f1cc9d0..12a112d 100644
25 --- a/arch/mips/bcm47xx/bcm47xx_private.h
26 +++ b/arch/mips/bcm47xx/bcm47xx_private.h
29 void __init bcm47xx_prom_highmem_init(void);
32 +void bcm47xx_sprom_register_fallbacks(void);
35 int __init bcm47xx_buttons_register(void);
37 diff --git a/arch/mips/bcm47xx/setup.c b/arch/mips/bcm47xx/setup.c
38 index c00585d..444c65a 100644
39 --- a/arch/mips/bcm47xx/setup.c
40 +++ b/arch/mips/bcm47xx/setup.c
41 @@ -102,23 +102,6 @@ static void bcm47xx_machine_halt(void)
44 #ifdef CONFIG_BCM47XX_SSB
45 -static int bcm47xx_get_sprom_ssb(struct ssb_bus *bus, struct ssb_sprom *out)
49 - if (bus->bustype == SSB_BUSTYPE_PCI) {
50 - memset(out, 0, sizeof(struct ssb_sprom));
51 - snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
52 - bus->host_pci->bus->number + 1,
53 - PCI_SLOT(bus->host_pci->devfn));
54 - bcm47xx_fill_sprom(out, prefix, false);
57 - printk(KERN_WARNING "bcm47xx: unable to fill SPROM for given bustype.\n");
62 static int bcm47xx_get_invariants(struct ssb_bus *bus,
63 struct ssb_init_invariants *iv)
65 @@ -144,11 +127,6 @@ static void __init bcm47xx_register_ssb(void)
67 struct ssb_mipscore *mcore;
69 - err = ssb_arch_register_fallback_sprom(&bcm47xx_get_sprom_ssb);
71 - printk(KERN_WARNING "bcm47xx: someone else already registered"
72 - " a ssb SPROM callback handler (err %d)\n", err);
74 err = ssb_bus_ssbbus_register(&(bcm47xx_bus.ssb), SSB_ENUM_BASE,
75 bcm47xx_get_invariants);
77 @@ -171,44 +149,10 @@ static void __init bcm47xx_register_ssb(void)
80 #ifdef CONFIG_BCM47XX_BCMA
81 -static int bcm47xx_get_sprom_bcma(struct bcma_bus *bus, struct ssb_sprom *out)
84 - struct bcma_device *core;
86 - switch (bus->hosttype) {
87 - case BCMA_HOSTTYPE_PCI:
88 - memset(out, 0, sizeof(struct ssb_sprom));
89 - snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
90 - bus->host_pci->bus->number + 1,
91 - PCI_SLOT(bus->host_pci->devfn));
92 - bcm47xx_fill_sprom(out, prefix, false);
94 - case BCMA_HOSTTYPE_SOC:
95 - memset(out, 0, sizeof(struct ssb_sprom));
96 - core = bcma_find_core(bus, BCMA_CORE_80211);
98 - snprintf(prefix, sizeof(prefix), "sb/%u/",
100 - bcm47xx_fill_sprom(out, prefix, true);
102 - bcm47xx_fill_sprom(out, NULL, false);
106 - pr_warn("bcm47xx: unable to fill SPROM for given bustype.\n");
111 static void __init bcm47xx_register_bcma(void)
115 - err = bcma_arch_register_fallback_sprom(&bcm47xx_get_sprom_bcma);
117 - pr_warn("bcm47xx: someone else already registered a bcma SPROM callback handler (err %d)\n", err);
119 err = bcma_host_soc_register(&bcm47xx_bus.bcma);
121 panic("Failed to register BCMA bus (err %d)", err);
122 @@ -229,6 +173,7 @@ void __init plat_mem_setup(void)
123 printk(KERN_INFO "bcm47xx: using bcma bus\n");
124 #ifdef CONFIG_BCM47XX_BCMA
125 bcm47xx_bus_type = BCM47XX_BUS_TYPE_BCMA;
126 + bcm47xx_sprom_register_fallbacks();
127 bcm47xx_register_bcma();
128 bcm47xx_set_system_type(bcm47xx_bus.bcma.bus.chipinfo.id);
129 #ifdef CONFIG_HIGHMEM
130 @@ -239,6 +184,7 @@ void __init plat_mem_setup(void)
131 printk(KERN_INFO "bcm47xx: using ssb bus\n");
132 #ifdef CONFIG_BCM47XX_SSB
133 bcm47xx_bus_type = BCM47XX_BUS_TYPE_SSB;
134 + bcm47xx_sprom_register_fallbacks();
135 bcm47xx_register_ssb();
136 bcm47xx_set_system_type(bcm47xx_bus.ssb.chip_id);
138 diff --git a/arch/mips/bcm47xx/sprom.c b/arch/mips/bcm47xx/sprom.c
139 index 41226b6..e772e77 100644
140 --- a/arch/mips/bcm47xx/sprom.c
141 +++ b/arch/mips/bcm47xx/sprom.c
142 @@ -801,3 +801,71 @@ void bcm47xx_fill_bcma_boardinfo(struct bcma_boardinfo *boardinfo,
143 nvram_read_u16(prefix, NULL, "boardtype", &boardinfo->type, 0, true);
147 +#if defined(CONFIG_BCM47XX_SSB)
148 +static int bcm47xx_get_sprom_ssb(struct ssb_bus *bus, struct ssb_sprom *out)
152 + if (bus->bustype == SSB_BUSTYPE_PCI) {
153 + memset(out, 0, sizeof(struct ssb_sprom));
154 + snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
155 + bus->host_pci->bus->number + 1,
156 + PCI_SLOT(bus->host_pci->devfn));
157 + bcm47xx_fill_sprom(out, prefix, false);
160 + pr_warn("bcm47xx: unable to fill SPROM for given bustype.\n");
166 +#if defined(CONFIG_BCM47XX_BCMA)
167 +static int bcm47xx_get_sprom_bcma(struct bcma_bus *bus, struct ssb_sprom *out)
170 + struct bcma_device *core;
172 + switch (bus->hosttype) {
173 + case BCMA_HOSTTYPE_PCI:
174 + memset(out, 0, sizeof(struct ssb_sprom));
175 + snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
176 + bus->host_pci->bus->number + 1,
177 + PCI_SLOT(bus->host_pci->devfn));
178 + bcm47xx_fill_sprom(out, prefix, false);
180 + case BCMA_HOSTTYPE_SOC:
181 + memset(out, 0, sizeof(struct ssb_sprom));
182 + core = bcma_find_core(bus, BCMA_CORE_80211);
184 + snprintf(prefix, sizeof(prefix), "sb/%u/",
186 + bcm47xx_fill_sprom(out, prefix, true);
188 + bcm47xx_fill_sprom(out, NULL, false);
192 + pr_warn("bcm47xx: unable to fill SPROM for given bustype.\n");
199 + * On bcm47xx we need to register SPROM fallback handler very early, so we can't
200 + * use anything like platform device / driver for this.
202 +void bcm47xx_sprom_register_fallbacks(void)
204 +#if defined(CONFIG_BCM47XX_SSB)
205 + if (ssb_arch_register_fallback_sprom(&bcm47xx_get_sprom_ssb))
206 + pr_warn("Failed to registered ssb SPROM handler\n");
209 +#if defined(CONFIG_BCM47XX_BCMA)
210 + if (bcma_arch_register_fallback_sprom(&bcm47xx_get_sprom_bcma))
211 + pr_warn("Failed to registered bcma SPROM handler\n");