source: branches/contrib/debian/package-build/linux-patch-bcm47xx/patches-3.16/030-04-MIPS-BCM47XX-Move-SPROM-fallback-code-into-sprom.c.patch @ 716

Last change on this file since 716 was 716, checked in by ehem, 4 years ago

Adjust BCM47xx patches

Get rid of fuzz during application, this should make application more
reliable and potentially provide better warnings in future.

File size: 6.6 KB
  • arch/mips/bcm47xx/bcm47xx_private.h

    From a59da8fb3b2a1f2df5f871464e43cd5b6ca6ceb1 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
    Date: Tue, 28 Oct 2014 12:52:02 +0100
    Subject: [PATCH 157/158] MIPS: BCM47XX: Move SPROM fallback code into sprom.c
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    This is some general cleanup as well as preparing sprom.c to become a
    standalone driver. We will need this for bcm53xx ARM arch support.
    
    Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
    Acked-by: Hauke Mehrtens <hauke@hauke-m.de>
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/8232/
    Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
    ---
     arch/mips/bcm47xx/bcm47xx_private.h |  3 ++
     arch/mips/bcm47xx/setup.c           | 58 ++-----------------------------
     arch/mips/bcm47xx/sprom.c           | 68 +++++++++++++++++++++++++++++++++++++
     3 files changed, 73 insertions(+), 56 deletions(-)
    
    diff --git a/arch/mips/bcm47xx/bcm47xx_private.h b/arch/mips/bcm47xx/bcm47xx_private.h
    index f1cc9d0..12a112d 100644
    a b  
    33
    44#include <linux/kernel.h>
    55
     6/* sprom.c */
     7void bcm47xx_sprom_register_fallbacks(void);
     8
    69/* buttons.c */
    710int __init bcm47xx_buttons_register(void);
    811
  • arch/mips/bcm47xx/setup.c

    diff --git a/arch/mips/bcm47xx/setup.c b/arch/mips/bcm47xx/setup.c
    index c00585d..444c65a 100644
    a b static void bcm47xx_machine_halt(void) 
    9393}
    9494
    9595#ifdef CONFIG_BCM47XX_SSB
    96 static int bcm47xx_get_sprom_ssb(struct ssb_bus *bus, struct ssb_sprom *out)
    97 {
    98         char prefix[10];
    99 
    100         if (bus->bustype == SSB_BUSTYPE_PCI) {
    101                 memset(out, 0, sizeof(struct ssb_sprom));
    102                 snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
    103                          bus->host_pci->bus->number + 1,
    104                          PCI_SLOT(bus->host_pci->devfn));
    105                 bcm47xx_fill_sprom(out, prefix, false);
    106                 return 0;
    107         } else {
    108                 printk(KERN_WARNING "bcm47xx: unable to fill SPROM for given bustype.\n");
    109                 return -EINVAL;
    110         }
    111 }
    112 
    11396static int bcm47xx_get_invariants(struct ssb_bus *bus,
    11497                                  struct ssb_init_invariants *iv)
    11598{
    static void __init bcm47xx_register_ssb(void) 
    135118        char buf[100];
    136119        struct ssb_mipscore *mcore;
    137120
    138         err = ssb_arch_register_fallback_sprom(&bcm47xx_get_sprom_ssb);
    139         if (err)
    140                 printk(KERN_WARNING "bcm47xx: someone else already registered"
    141                         " a ssb SPROM callback handler (err %d)\n", err);
    142 
    143121        err = ssb_bus_ssbbus_register(&(bcm47xx_bus.ssb), SSB_ENUM_BASE,
    144122                                      bcm47xx_get_invariants);
    145123        if (err)
    static void __init bcm47xx_register_ssb(void) 
    162140#endif
    163141
    164142#ifdef CONFIG_BCM47XX_BCMA
    165 static int bcm47xx_get_sprom_bcma(struct bcma_bus *bus, struct ssb_sprom *out)
    166 {
    167         char prefix[10];
    168         struct bcma_device *core;
    169 
    170         switch (bus->hosttype) {
    171         case BCMA_HOSTTYPE_PCI:
    172                 memset(out, 0, sizeof(struct ssb_sprom));
    173                 snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
    174                          bus->host_pci->bus->number + 1,
    175                          PCI_SLOT(bus->host_pci->devfn));
    176                 bcm47xx_fill_sprom(out, prefix, false);
    177                 return 0;
    178         case BCMA_HOSTTYPE_SOC:
    179                 memset(out, 0, sizeof(struct ssb_sprom));
    180                 core = bcma_find_core(bus, BCMA_CORE_80211);
    181                 if (core) {
    182                         snprintf(prefix, sizeof(prefix), "sb/%u/",
    183                                  core->core_index);
    184                         bcm47xx_fill_sprom(out, prefix, true);
    185                 } else {
    186                         bcm47xx_fill_sprom(out, NULL, false);
    187                 }
    188                 return 0;
    189         default:
    190                 pr_warn("bcm47xx: unable to fill SPROM for given bustype.\n");
    191                 return -EINVAL;
    192         }
    193 }
    194 
    195143static void __init bcm47xx_register_bcma(void)
    196144{
    197145        int err;
    198146
    199         err = bcma_arch_register_fallback_sprom(&bcm47xx_get_sprom_bcma);
    200         if (err)
    201                 pr_warn("bcm47xx: someone else already registered a bcma SPROM callback handler (err %d)\n", err);
    202 
    203147        err = bcma_host_soc_register(&bcm47xx_bus.bcma);
    204148        if (err)
    205149                panic("Failed to register BCMA bus (err %d)", err);
    void __init plat_mem_setup(void) 
    220164                printk(KERN_INFO "bcm47xx: using bcma bus\n");
    221165#ifdef CONFIG_BCM47XX_BCMA
    222166                bcm47xx_bus_type = BCM47XX_BUS_TYPE_BCMA;
     167                bcm47xx_sprom_register_fallbacks();
    223168                bcm47xx_register_bcma();
    224169                bcm47xx_set_system_type(bcm47xx_bus.bcma.bus.chipinfo.id);
    225170#endif
    void __init plat_mem_setup(void) 
    227172                printk(KERN_INFO "bcm47xx: using ssb bus\n");
    228173#ifdef CONFIG_BCM47XX_SSB
    229174                bcm47xx_bus_type = BCM47XX_BUS_TYPE_SSB;
     175                bcm47xx_sprom_register_fallbacks();
    230176                bcm47xx_register_ssb();
    231177                bcm47xx_set_system_type(bcm47xx_bus.ssb.chip_id);
    232178#endif
  • arch/mips/bcm47xx/sprom.c

    diff --git a/arch/mips/bcm47xx/sprom.c b/arch/mips/bcm47xx/sprom.c
    index 41226b6..e772e77 100644
    a b void bcm47xx_fill_bcma_boardinfo(struct bcma_boardinfo *boardinfo, 
    753753        nvram_read_u16(prefix, NULL, "boardtype", &boardinfo->type, 0, true);
    754754}
    755755#endif
     756
     757#if defined(CONFIG_BCM47XX_SSB)
     758static int bcm47xx_get_sprom_ssb(struct ssb_bus *bus, struct ssb_sprom *out)
     759{
     760        char prefix[10];
     761
     762        if (bus->bustype == SSB_BUSTYPE_PCI) {
     763                memset(out, 0, sizeof(struct ssb_sprom));
     764                snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
     765                         bus->host_pci->bus->number + 1,
     766                         PCI_SLOT(bus->host_pci->devfn));
     767                bcm47xx_fill_sprom(out, prefix, false);
     768                return 0;
     769        } else {
     770                pr_warn("bcm47xx: unable to fill SPROM for given bustype.\n");
     771                return -EINVAL;
     772        }
     773}
     774#endif
     775
     776#if defined(CONFIG_BCM47XX_BCMA)
     777static int bcm47xx_get_sprom_bcma(struct bcma_bus *bus, struct ssb_sprom *out)
     778{
     779        char prefix[10];
     780        struct bcma_device *core;
     781
     782        switch (bus->hosttype) {
     783        case BCMA_HOSTTYPE_PCI:
     784                memset(out, 0, sizeof(struct ssb_sprom));
     785                snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
     786                         bus->host_pci->bus->number + 1,
     787                         PCI_SLOT(bus->host_pci->devfn));
     788                bcm47xx_fill_sprom(out, prefix, false);
     789                return 0;
     790        case BCMA_HOSTTYPE_SOC:
     791                memset(out, 0, sizeof(struct ssb_sprom));
     792                core = bcma_find_core(bus, BCMA_CORE_80211);
     793                if (core) {
     794                        snprintf(prefix, sizeof(prefix), "sb/%u/",
     795                                 core->core_index);
     796                        bcm47xx_fill_sprom(out, prefix, true);
     797                } else {
     798                        bcm47xx_fill_sprom(out, NULL, false);
     799                }
     800                return 0;
     801        default:
     802                pr_warn("bcm47xx: unable to fill SPROM for given bustype.\n");
     803                return -EINVAL;
     804        }
     805}
     806#endif
     807
     808/*
     809 * On bcm47xx we need to register SPROM fallback handler very early, so we can't
     810 * use anything like platform device / driver for this.
     811 */
     812void bcm47xx_sprom_register_fallbacks(void)
     813{
     814#if defined(CONFIG_BCM47XX_SSB)
     815        if (ssb_arch_register_fallback_sprom(&bcm47xx_get_sprom_ssb))
     816                pr_warn("Failed to registered ssb SPROM handler\n");
     817#endif
     818
     819#if defined(CONFIG_BCM47XX_BCMA)
     820        if (bcma_arch_register_fallback_sprom(&bcm47xx_get_sprom_bcma))
     821                pr_warn("Failed to registered bcma SPROM handler\n");
     822#endif
     823}
Note: See TracBrowser for help on using the repository browser.