Root/target/linux/brcm47xx/patches-3.2/199-MIPS-BCM47XX-provide-sprom-to-bcma-bus.patch

1From 112b2e12edda60f495b57e8a1d85eb95e2662845 Mon Sep 17 00:00:00 2001
2From: Hauke Mehrtens <hauke@hauke-m.de>
3Date: Thu, 16 Feb 2012 23:44:26 +0100
4Subject: [PATCH 199/202] MIPS: BCM47XX: provide sprom to bcma bus
5
6On SoCs the sprom is often stored in nvram in the flashchip. This patch
7registers a sprom fallback callback handler in bcma and provides the
8sprom needed for this device.
9
10Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
11---
12 arch/mips/bcm47xx/setup.c | 39 +++++++++++++++++++++++++++++++++++----
13 1 files changed, 35 insertions(+), 4 deletions(-)
14
15--- a/arch/mips/bcm47xx/setup.c
16+++ b/arch/mips/bcm47xx/setup.c
17@@ -3,7 +3,7 @@
18  * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
19  * Copyright (C) 2006 Michael Buesch <m@bues.ch>
20  * Copyright (C) 2010 Waldemar Brodkorb <wbx@openadk.org>
21- * Copyright (C) 2010-2011 Hauke Mehrtens <hauke@hauke-m.de>
22+ * Copyright (C) 2010-2012 Hauke Mehrtens <hauke@hauke-m.de>
23  *
24  * This program is free software; you can redistribute it and/or modify it
25  * under the terms of the GNU General Public License as published by the
26@@ -91,7 +91,7 @@ static void bcm47xx_machine_halt(void)
27 }
28 
29 #ifdef CONFIG_BCM47XX_SSB
30-static int bcm47xx_get_sprom(struct ssb_bus *bus, struct ssb_sprom *out)
31+static int bcm47xx_get_sprom_ssb(struct ssb_bus *bus, struct ssb_sprom *out)
32 {
33     char prefix[10];
34 
35@@ -108,7 +108,7 @@ static int bcm47xx_get_sprom(struct ssb_
36 }
37 
38 static int bcm47xx_get_invariants(struct ssb_bus *bus,
39- struct ssb_init_invariants *iv)
40+ struct ssb_init_invariants *iv)
41 {
42     char buf[20];
43 
44@@ -163,7 +163,7 @@ static void __init bcm47xx_register_ssb(
45     char buf[100];
46     struct ssb_mipscore *mcore;
47 
48- err = ssb_arch_register_fallback_sprom(&bcm47xx_get_sprom);
49+ err = ssb_arch_register_fallback_sprom(&bcm47xx_get_sprom_ssb);
50     if (err)
51         printk(KERN_WARNING "bcm47xx: someone else already registered"
52             " a ssb SPROM callback handler (err %d)\n", err);
53@@ -197,10 +197,41 @@ static void __init bcm47xx_register_ssb(
54 #endif
55 
56 #ifdef CONFIG_BCM47XX_BCMA
57+static int bcm47xx_get_sprom_bcma(struct bcma_bus *bus, struct ssb_sprom *out)
58+{
59+ char prefix[10];
60+ struct bcma_device *core;
61+
62+ if (bus->hosttype == BCMA_HOSTTYPE_PCI) {
63+ snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
64+ bus->host_pci->bus->number + 1,
65+ PCI_SLOT(bus->host_pci->devfn));
66+ bcm47xx_fill_sprom(out, prefix);
67+ return 0;
68+ } else if (bus->hosttype == BCMA_HOSTTYPE_SOC) {
69+ bcm47xx_fill_sprom_ethernet(out, NULL);
70+ core = bcma_find_core(bus, BCMA_CORE_80211);
71+ if (core) {
72+ snprintf(prefix, sizeof(prefix), "sb/%u/",
73+ core->core_index);
74+ bcm47xx_fill_sprom(out, prefix);
75+ }
76+ return 0;
77+ } else {
78+ printk(KERN_WARNING "bcm47xx: unable to fill SPROM for given bustype.\n");
79+ return -EINVAL;
80+ }
81+}
82+
83 static void __init bcm47xx_register_bcma(void)
84 {
85     int err;
86 
87+ err = bcma_arch_register_fallback_sprom(&bcm47xx_get_sprom_bcma);
88+ if (err)
89+ printk(KERN_WARNING "bcm47xx: someone else already registered"
90+ " a bcma SPROM callback handler (err %d)\n", err);
91+
92     err = bcma_host_soc_register(&bcm47xx_bus.bcma);
93     if (err)
94         panic("Failed to initialize BCMA bus (err %d)\n", err);
95

Archive Download this file



interactive