495a0bff26828f5367deb3160c0979e7440470a2
[openwrt.git] / target / linux / brcm47xx / patches-2.6.39 / 033-bcm47xx-register-fallback-callback.patch
1 --- a/arch/mips/bcm47xx/nvram.c
2 +++ b/arch/mips/bcm47xx/nvram.c
3 @@ -3,6 +3,7 @@
4   *
5   * Copyright (C) 2005 Broadcom Corporation
6   * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
7 + * Copyright (C) 2010-2011 Hauke Mehrtens <hauke@hauke-m.de>
8   *
9   * This program is free software; you can redistribute  it and/or modify it
10   * under  the terms of  the GNU General  Public License as published by the
11 @@ -23,7 +24,7 @@
12  static char nvram_buf[NVRAM_SPACE];
13  
14  /* Probe for NVRAM header */
15 -static void __init early_nvram_init(void)
16 +static void early_nvram_init(void)
17  {
18         struct ssb_mipscore *mcore = &ssb_bcm47xx.mipscore;
19         struct nvram_header *header;
20 --- a/arch/mips/bcm47xx/setup.c
21 +++ b/arch/mips/bcm47xx/setup.c
22 @@ -3,6 +3,7 @@
23   *  Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
24   *  Copyright (C) 2006 Michael Buesch <mb@bu3sch.de>
25   *  Copyright (C) 2010 Waldemar Brodkorb <wbx@openadk.org>
26 + *  Copyright (C) 2010-2011 Hauke Mehrtens <hauke@hauke-m.de>
27   *
28   *  This program is free software; you can redistribute  it and/or modify it
29   *  under  the terms of  the GNU General  Public License as published by the
30 @@ -156,6 +157,22 @@ static void bcm47xx_fill_sprom(struct ss
31         }
32  }
33  
34 +int bcm47xx_get_sprom(struct ssb_bus *bus, struct ssb_sprom *out)
35 +{
36 +       char prefix[10];
37 +
38 +       if (bus->bustype == SSB_BUSTYPE_PCI) {
39 +               snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
40 +                        bus->host_pci->bus->number + 1,
41 +                        PCI_SLOT(bus->host_pci->devfn));
42 +               bcm47xx_fill_sprom(out, prefix);
43 +               return 0;
44 +       } else {
45 +               printk(KERN_WARNING "bcm47xx: unable to fill SPROM for given bustype.\n");
46 +               return -EINVAL;
47 +       }
48 +}
49 +
50  static int bcm47xx_get_invariants(struct ssb_bus *bus,
51                                    struct ssb_init_invariants *iv)
52  {
53 @@ -212,6 +229,11 @@ void __init plat_mem_setup(void)
54         char buf[100];
55         struct ssb_mipscore *mcore;
56  
57 +       err = ssb_arch_register_fallback_sprom(&bcm47xx_get_sprom);
58 +       if (err)
59 +               printk(KERN_WARNING "bcm47xx: someone else already registered"
60 +                       " a ssb SPROM callback handler (err %d)\n", err);
61 +
62         err = ssb_bus_ssbbus_register(&ssb_bcm47xx, SSB_ENUM_BASE,
63                                       bcm47xx_get_invariants);
64         if (err)