aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ssb/sprom.c
diff options
context:
space:
mode:
authorHauke Mehrtens <hauke@hauke-m.de>2011-05-10 17:31:30 -0400
committerRalf Baechle <ralf@linux-mips.org>2011-05-19 04:55:47 -0400
commitb3ae52b6b0335eba547221aad2cb3c50902e3d2d (patch)
treeb7901a68a97fc73e6e711828f93ec8dbcca5722d /drivers/ssb/sprom.c
parentb7f720d68c0042cc8ce496e31a61df79a77f1b48 (diff)
SSB: Change fallback sprom to callback mechanism.
Some embedded devices like the Netgear WNDR3300 have two SSB based cards without an own sprom on the pci bus. We have to provide two different fallback sproms for these and this was not possible with the old solution. In the bcm47xx architecture the sprom data is stored in the nvram in the main flash storage. The architecture code will be able to fill the sprom with the stored data based on the bus where the device was found. The bcm63xx code should do the same thing as before, just using the new API. Acked-by: Michael Buesch <mb@bu3sch.de> Cc: netdev@vger.kernel.org Cc: linux-wireless@vger.kernel.org Cc: Florian Fainelli <florian@openwrt.org> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/2362/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'drivers/ssb/sprom.c')
-rw-r--r--drivers/ssb/sprom.c43
1 files changed, 25 insertions, 18 deletions
diff --git a/drivers/ssb/sprom.c b/drivers/ssb/sprom.c
index 5f34d7a3e3a5..45ff0e3a3828 100644
--- a/drivers/ssb/sprom.c
+++ b/drivers/ssb/sprom.c
@@ -17,7 +17,7 @@
17#include <linux/slab.h> 17#include <linux/slab.h>
18 18
19 19
20static const struct ssb_sprom *fallback_sprom; 20static int(*get_fallback_sprom)(struct ssb_bus *dev, struct ssb_sprom *out);
21 21
22 22
23static int sprom2hex(const u16 *sprom, char *buf, size_t buf_len, 23static int sprom2hex(const u16 *sprom, char *buf, size_t buf_len,
@@ -145,36 +145,43 @@ out:
145} 145}
146 146
147/** 147/**
148 * ssb_arch_set_fallback_sprom - Set a fallback SPROM for use if no SPROM is found. 148 * ssb_arch_register_fallback_sprom - Registers a method providing a
149 * fallback SPROM if no SPROM is found.
149 * 150 *
150 * @sprom: The SPROM data structure to register. 151 * @sprom_callback: The callback function.
151 * 152 *
152 * With this function the architecture implementation may register a fallback 153 * With this function the architecture implementation may register a
153 * SPROM data structure. The fallback is only used for PCI based SSB devices, 154 * callback handler which fills the SPROM data structure. The fallback is
154 * where no valid SPROM can be found in the shadow registers. 155 * only used for PCI based SSB devices, where no valid SPROM can be found
156 * in the shadow registers.
155 * 157 *
156 * This function is useful for weird architectures that have a half-assed SSB device 158 * This function is useful for weird architectures that have a half-assed
157 * hardwired to their PCI bus. 159 * SSB device hardwired to their PCI bus.
158 * 160 *
159 * Note that it does only work with PCI attached SSB devices. PCMCIA devices currently 161 * Note that it does only work with PCI attached SSB devices. PCMCIA
160 * don't use this fallback. 162 * devices currently don't use this fallback.
161 * Architectures must provide the SPROM for native SSB devices anyway, 163 * Architectures must provide the SPROM for native SSB devices anyway, so
162 * so the fallback also isn't used for native devices. 164 * the fallback also isn't used for native devices.
163 * 165 *
164 * This function is available for architecture code, only. So it is not exported. 166 * This function is available for architecture code, only. So it is not
167 * exported.
165 */ 168 */
166int ssb_arch_set_fallback_sprom(const struct ssb_sprom *sprom) 169int ssb_arch_register_fallback_sprom(int (*sprom_callback)(struct ssb_bus *bus,
170 struct ssb_sprom *out))
167{ 171{
168 if (fallback_sprom) 172 if (get_fallback_sprom)
169 return -EEXIST; 173 return -EEXIST;
170 fallback_sprom = sprom; 174 get_fallback_sprom = sprom_callback;
171 175
172 return 0; 176 return 0;
173} 177}
174 178
175const struct ssb_sprom *ssb_get_fallback_sprom(void) 179int ssb_fill_sprom_with_fallback(struct ssb_bus *bus, struct ssb_sprom *out)
176{ 180{
177 return fallback_sprom; 181 if (!get_fallback_sprom)
182 return -ENOENT;
183
184 return get_fallback_sprom(bus, out);
178} 185}
179 186
180/* http://bcm-v4.sipsolutions.net/802.11/IsSpromAvailable */ 187/* http://bcm-v4.sipsolutions.net/802.11/IsSpromAvailable */