diff options
author | Hauke Mehrtens <hauke@hauke-m.de> | 2012-02-27 18:56:14 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2012-03-05 15:20:51 -0500 |
commit | f384b3dddc727b1cbd77e493c24d7fefa883396a (patch) | |
tree | e04cbe3485d2490d1965e8cd7f9d485f3550e6b9 | |
parent | 019eee2e34e2d1db715dc4fe5be2079800636fa8 (diff) |
MIPS: BCM47XX: provide sprom to bcma bus
On SoCs the sprom is often stored in nvram in the flashchip. This patch
registers a sprom fallback callback handler in bcma and provides the
sprom needed for this device.
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | arch/mips/bcm47xx/setup.c | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/arch/mips/bcm47xx/setup.c b/arch/mips/bcm47xx/setup.c index 6b0dacde98d4..19780aa91708 100644 --- a/arch/mips/bcm47xx/setup.c +++ b/arch/mips/bcm47xx/setup.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org> | 3 | * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org> |
4 | * Copyright (C) 2006 Michael Buesch <m@bues.ch> | 4 | * Copyright (C) 2006 Michael Buesch <m@bues.ch> |
5 | * Copyright (C) 2010 Waldemar Brodkorb <wbx@openadk.org> | 5 | * Copyright (C) 2010 Waldemar Brodkorb <wbx@openadk.org> |
6 | * Copyright (C) 2010-2011 Hauke Mehrtens <hauke@hauke-m.de> | 6 | * Copyright (C) 2010-2012 Hauke Mehrtens <hauke@hauke-m.de> |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or modify it | 8 | * This program is free software; you can redistribute it and/or modify it |
9 | * under the terms of the GNU General Public License as published by the | 9 | * under the terms of the GNU General Public License as published by the |
@@ -85,7 +85,7 @@ static void bcm47xx_machine_halt(void) | |||
85 | } | 85 | } |
86 | 86 | ||
87 | #ifdef CONFIG_BCM47XX_SSB | 87 | #ifdef CONFIG_BCM47XX_SSB |
88 | static int bcm47xx_get_sprom(struct ssb_bus *bus, struct ssb_sprom *out) | 88 | static int bcm47xx_get_sprom_ssb(struct ssb_bus *bus, struct ssb_sprom *out) |
89 | { | 89 | { |
90 | char prefix[10]; | 90 | char prefix[10]; |
91 | 91 | ||
@@ -102,7 +102,7 @@ static int bcm47xx_get_sprom(struct ssb_bus *bus, struct ssb_sprom *out) | |||
102 | } | 102 | } |
103 | 103 | ||
104 | static int bcm47xx_get_invariants(struct ssb_bus *bus, | 104 | static int bcm47xx_get_invariants(struct ssb_bus *bus, |
105 | struct ssb_init_invariants *iv) | 105 | struct ssb_init_invariants *iv) |
106 | { | 106 | { |
107 | char buf[20]; | 107 | char buf[20]; |
108 | 108 | ||
@@ -132,7 +132,7 @@ static void __init bcm47xx_register_ssb(void) | |||
132 | char buf[100]; | 132 | char buf[100]; |
133 | struct ssb_mipscore *mcore; | 133 | struct ssb_mipscore *mcore; |
134 | 134 | ||
135 | err = ssb_arch_register_fallback_sprom(&bcm47xx_get_sprom); | 135 | err = ssb_arch_register_fallback_sprom(&bcm47xx_get_sprom_ssb); |
136 | if (err) | 136 | if (err) |
137 | printk(KERN_WARNING "bcm47xx: someone else already registered" | 137 | printk(KERN_WARNING "bcm47xx: someone else already registered" |
138 | " a ssb SPROM callback handler (err %d)\n", err); | 138 | " a ssb SPROM callback handler (err %d)\n", err); |
@@ -159,10 +159,41 @@ static void __init bcm47xx_register_ssb(void) | |||
159 | #endif | 159 | #endif |
160 | 160 | ||
161 | #ifdef CONFIG_BCM47XX_BCMA | 161 | #ifdef CONFIG_BCM47XX_BCMA |
162 | static int bcm47xx_get_sprom_bcma(struct bcma_bus *bus, struct ssb_sprom *out) | ||
163 | { | ||
164 | char prefix[10]; | ||
165 | struct bcma_device *core; | ||
166 | |||
167 | switch (bus->hosttype) { | ||
168 | case BCMA_HOSTTYPE_PCI: | ||
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); | ||
173 | return 0; | ||
174 | case BCMA_HOSTTYPE_SOC: | ||
175 | bcm47xx_fill_sprom_ethernet(out, NULL); | ||
176 | core = bcma_find_core(bus, BCMA_CORE_80211); | ||
177 | if (core) { | ||
178 | snprintf(prefix, sizeof(prefix), "sb/%u/", | ||
179 | core->core_index); | ||
180 | bcm47xx_fill_sprom(out, prefix); | ||
181 | } | ||
182 | return 0; | ||
183 | default: | ||
184 | pr_warn("bcm47xx: unable to fill SPROM for given bustype.\n"); | ||
185 | return -EINVAL; | ||
186 | } | ||
187 | } | ||
188 | |||
162 | static void __init bcm47xx_register_bcma(void) | 189 | static void __init bcm47xx_register_bcma(void) |
163 | { | 190 | { |
164 | int err; | 191 | int err; |
165 | 192 | ||
193 | err = bcma_arch_register_fallback_sprom(&bcm47xx_get_sprom_bcma); | ||
194 | if (err) | ||
195 | pr_warn("bcm47xx: someone else already registered a bcma SPROM callback handler (err %d)\n", err); | ||
196 | |||
166 | err = bcma_host_soc_register(&bcm47xx_bus.bcma); | 197 | err = bcma_host_soc_register(&bcm47xx_bus.bcma); |
167 | if (err) | 198 | if (err) |
168 | panic("Failed to initialize BCMA bus (err %d)", err); | 199 | panic("Failed to initialize BCMA bus (err %d)", err); |