brcm47xx: when detecting a ssb pci device without an own sprom write the sprom data...
[oweals/openwrt.git] / target / linux / brcm47xx / patches-2.6.38 / 033-bcm47xx-register-fallback-callback.patch
1 --- a/arch/mips/bcm47xx/nvram.c
2 +++ b/arch/mips/bcm47xx/nvram.c
3 @@ -23,7 +23,7 @@
4  static char nvram_buf[NVRAM_SPACE];
5  
6  /* Probe for NVRAM header */
7 -static void __init early_nvram_init(void)
8 +static void early_nvram_init(void)
9  {
10         struct ssb_mipscore *mcore = &ssb_bcm47xx.mipscore;
11         struct nvram_header *header;
12 --- a/arch/mips/bcm47xx/setup.c
13 +++ b/arch/mips/bcm47xx/setup.c
14 @@ -156,6 +156,22 @@ static void bcm47xx_fill_sprom(struct ss
15         }
16  }
17  
18 +int bcm47xx_get_sprom(struct ssb_bus *bus, struct ssb_sprom *out)
19 +{
20 +       char prefix[10];
21 +
22 +       if (bus->bustype == SSB_BUSTYPE_PCI) {
23 +               snprintf(prefix, sizeof(prefix), "pci/%x/%x/",
24 +                        bus->host_pci->bus->number + 1,
25 +                        PCI_SLOT(bus->host_pci->devfn));
26 +               bcm47xx_fill_sprom(out, prefix);
27 +               return 0;
28 +       } else {
29 +               printk(KERN_WARNING "bcm47xx: unable to fill SPROM for given bustype.\n");
30 +               return -EINVAL;
31 +       }
32 +}
33 +
34  static int bcm47xx_get_invariants(struct ssb_bus *bus,
35                                    struct ssb_init_invariants *iv)
36  {
37 @@ -212,6 +228,11 @@ void __init plat_mem_setup(void)
38         char buf[100];
39         struct ssb_mipscore *mcore;
40  
41 +       err = ssb_arch_register_fallback_sprom(&bcm47xx_get_sprom);
42 +       if (err)
43 +               printk(KERN_WARNING "bcm47xx: someone else already registered"
44 +                       " a ssb SPROM callback handler (err %d)\n", err);
45 +
46         err = ssb_bus_ssbbus_register(&ssb_bcm47xx, SSB_ENUM_BASE,
47                                       bcm47xx_get_invariants);
48         if (err)