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 --- a/arch/mips/bcm47xx/bcm47xx_private.h
24 +++ b/arch/mips/bcm47xx/bcm47xx_private.h
27 void __init bcm47xx_prom_highmem_init(void);
30 +void bcm47xx_sprom_register_fallbacks(void);
33 int __init bcm47xx_buttons_register(void);
35 --- a/arch/mips/bcm47xx/setup.c
36 +++ b/arch/mips/bcm47xx/setup.c
37 @@ -102,23 +102,6 @@ static void bcm47xx_machine_halt(void)
40 #ifdef CONFIG_BCM47XX_SSB
41 -static int bcm47xx_get_sprom_ssb(struct ssb_bus *bus, struct ssb_sprom *out)
45 - if (bus->bustype == SSB_BUSTYPE_PCI) {
46 - memset(out, 0, sizeof(struct ssb_sprom));
47 - snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
48 - bus->host_pci->bus->number + 1,
49 - PCI_SLOT(bus->host_pci->devfn));
50 - bcm47xx_fill_sprom(out, prefix, false);
53 - printk(KERN_WARNING "bcm47xx: unable to fill SPROM for given bustype.\n");
58 static int bcm47xx_get_invariants(struct ssb_bus *bus,
59 struct ssb_init_invariants *iv)
61 @@ -144,11 +127,6 @@ static void __init bcm47xx_register_ssb(
63 struct ssb_mipscore *mcore;
65 - err = ssb_arch_register_fallback_sprom(&bcm47xx_get_sprom_ssb);
67 - printk(KERN_WARNING "bcm47xx: someone else already registered"
68 - " a ssb SPROM callback handler (err %d)\n", err);
70 err = ssb_bus_ssbbus_register(&(bcm47xx_bus.ssb), SSB_ENUM_BASE,
71 bcm47xx_get_invariants);
73 @@ -171,44 +149,10 @@ static void __init bcm47xx_register_ssb(
76 #ifdef CONFIG_BCM47XX_BCMA
77 -static int bcm47xx_get_sprom_bcma(struct bcma_bus *bus, struct ssb_sprom *out)
80 - struct bcma_device *core;
82 - switch (bus->hosttype) {
83 - case BCMA_HOSTTYPE_PCI:
84 - memset(out, 0, sizeof(struct ssb_sprom));
85 - snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
86 - bus->host_pci->bus->number + 1,
87 - PCI_SLOT(bus->host_pci->devfn));
88 - bcm47xx_fill_sprom(out, prefix, false);
90 - case BCMA_HOSTTYPE_SOC:
91 - memset(out, 0, sizeof(struct ssb_sprom));
92 - core = bcma_find_core(bus, BCMA_CORE_80211);
94 - snprintf(prefix, sizeof(prefix), "sb/%u/",
96 - bcm47xx_fill_sprom(out, prefix, true);
98 - bcm47xx_fill_sprom(out, NULL, false);
102 - pr_warn("bcm47xx: unable to fill SPROM for given bustype.\n");
107 static void __init bcm47xx_register_bcma(void)
111 - err = bcma_arch_register_fallback_sprom(&bcm47xx_get_sprom_bcma);
113 - pr_warn("bcm47xx: someone else already registered a bcma SPROM callback handler (err %d)\n", err);
115 err = bcma_host_soc_register(&bcm47xx_bus.bcma);
117 panic("Failed to register BCMA bus (err %d)", err);
118 @@ -229,6 +173,7 @@ void __init plat_mem_setup(void)
119 printk(KERN_INFO "bcm47xx: using bcma bus\n");
120 #ifdef CONFIG_BCM47XX_BCMA
121 bcm47xx_bus_type = BCM47XX_BUS_TYPE_BCMA;
122 + bcm47xx_sprom_register_fallbacks();
123 bcm47xx_register_bcma();
124 bcm47xx_set_system_type(bcm47xx_bus.bcma.bus.chipinfo.id);
125 #ifdef CONFIG_HIGHMEM
126 @@ -239,6 +184,7 @@ void __init plat_mem_setup(void)
127 printk(KERN_INFO "bcm47xx: using ssb bus\n");
128 #ifdef CONFIG_BCM47XX_SSB
129 bcm47xx_bus_type = BCM47XX_BUS_TYPE_SSB;
130 + bcm47xx_sprom_register_fallbacks();
131 bcm47xx_register_ssb();
132 bcm47xx_set_system_type(bcm47xx_bus.ssb.chip_id);
134 --- a/arch/mips/bcm47xx/sprom.c
135 +++ b/arch/mips/bcm47xx/sprom.c
136 @@ -801,3 +801,71 @@ void bcm47xx_fill_bcma_boardinfo(struct
137 nvram_read_u16(prefix, NULL, "boardtype", &boardinfo->type, 0, true);
141 +#if defined(CONFIG_BCM47XX_SSB)
142 +static int bcm47xx_get_sprom_ssb(struct ssb_bus *bus, struct ssb_sprom *out)
146 + if (bus->bustype == SSB_BUSTYPE_PCI) {
147 + memset(out, 0, sizeof(struct ssb_sprom));
148 + snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
149 + bus->host_pci->bus->number + 1,
150 + PCI_SLOT(bus->host_pci->devfn));
151 + bcm47xx_fill_sprom(out, prefix, false);
154 + pr_warn("bcm47xx: unable to fill SPROM for given bustype.\n");
160 +#if defined(CONFIG_BCM47XX_BCMA)
161 +static int bcm47xx_get_sprom_bcma(struct bcma_bus *bus, struct ssb_sprom *out)
164 + struct bcma_device *core;
166 + switch (bus->hosttype) {
167 + case BCMA_HOSTTYPE_PCI:
168 + memset(out, 0, sizeof(struct ssb_sprom));
169 + snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
170 + bus->host_pci->bus->number + 1,
171 + PCI_SLOT(bus->host_pci->devfn));
172 + bcm47xx_fill_sprom(out, prefix, false);
174 + case BCMA_HOSTTYPE_SOC:
175 + memset(out, 0, sizeof(struct ssb_sprom));
176 + core = bcma_find_core(bus, BCMA_CORE_80211);
178 + snprintf(prefix, sizeof(prefix), "sb/%u/",
180 + bcm47xx_fill_sprom(out, prefix, true);
182 + bcm47xx_fill_sprom(out, NULL, false);
186 + pr_warn("bcm47xx: unable to fill SPROM for given bustype.\n");
193 + * On bcm47xx we need to register SPROM fallback handler very early, so we can't
194 + * use anything like platform device / driver for this.
196 +void bcm47xx_sprom_register_fallbacks(void)
198 +#if defined(CONFIG_BCM47XX_SSB)
199 + if (ssb_arch_register_fallback_sprom(&bcm47xx_get_sprom_ssb))
200 + pr_warn("Failed to registered ssb SPROM handler\n");
203 +#if defined(CONFIG_BCM47XX_BCMA)
204 + if (bcma_arch_register_fallback_sprom(&bcm47xx_get_sprom_bcma))
205 + pr_warn("Failed to registered bcma SPROM handler\n");