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

Last change on this file since 671 was 671, checked in by ehem, 5 years ago

Initial experimental set of patches against Debian's 3.16 kernel for
Broadcom 47xx devices. These are mostly untested and are likely to fail
spectacularly. Progress appears to be being made towards building a
kernel that may work on actual hardware.

File size: 6.7 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  
    66/* prom.c */
    77void __init bcm47xx_prom_highmem_init(void);
    88
     9/* sprom.c */
     10void bcm47xx_sprom_register_fallbacks(void);
     11
    912/* buttons.c */
    1013int __init bcm47xx_buttons_register(void);
    1114
  • 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) 
    102102}
    103103
    104104#ifdef CONFIG_BCM47XX_SSB
    105 static int bcm47xx_get_sprom_ssb(struct ssb_bus *bus, struct ssb_sprom *out)
    106 {
    107         char prefix[10];
    108 
    109         if (bus->bustype == SSB_BUSTYPE_PCI) {
    110                 memset(out, 0, sizeof(struct ssb_sprom));
    111                 snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
    112                          bus->host_pci->bus->number + 1,
    113                          PCI_SLOT(bus->host_pci->devfn));
    114                 bcm47xx_fill_sprom(out, prefix, false);
    115                 return 0;
    116         } else {
    117                 printk(KERN_WARNING "bcm47xx: unable to fill SPROM for given bustype.\n");
    118                 return -EINVAL;
    119         }
    120 }
    121 
    122105static int bcm47xx_get_invariants(struct ssb_bus *bus,
    123106                                  struct ssb_init_invariants *iv)
    124107{
    static void __init bcm47xx_register_ssb(void) 
    144127        char buf[100];
    145128        struct ssb_mipscore *mcore;
    146129
    147         err = ssb_arch_register_fallback_sprom(&bcm47xx_get_sprom_ssb);
    148         if (err)
    149                 printk(KERN_WARNING "bcm47xx: someone else already registered"
    150                         " a ssb SPROM callback handler (err %d)\n", err);
    151 
    152130        err = ssb_bus_ssbbus_register(&(bcm47xx_bus.ssb), SSB_ENUM_BASE,
    153131                                      bcm47xx_get_invariants);
    154132        if (err)
    static void __init bcm47xx_register_ssb(void) 
    171149#endif
    172150
    173151#ifdef CONFIG_BCM47XX_BCMA
    174 static int bcm47xx_get_sprom_bcma(struct bcma_bus *bus, struct ssb_sprom *out)
    175 {
    176         char prefix[10];
    177         struct bcma_device *core;
    178 
    179         switch (bus->hosttype) {
    180         case BCMA_HOSTTYPE_PCI:
    181                 memset(out, 0, sizeof(struct ssb_sprom));
    182                 snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
    183                          bus->host_pci->bus->number + 1,
    184                          PCI_SLOT(bus->host_pci->devfn));
    185                 bcm47xx_fill_sprom(out, prefix, false);
    186                 return 0;
    187         case BCMA_HOSTTYPE_SOC:
    188                 memset(out, 0, sizeof(struct ssb_sprom));
    189                 core = bcma_find_core(bus, BCMA_CORE_80211);
    190                 if (core) {
    191                         snprintf(prefix, sizeof(prefix), "sb/%u/",
    192                                  core->core_index);
    193                         bcm47xx_fill_sprom(out, prefix, true);
    194                 } else {
    195                         bcm47xx_fill_sprom(out, NULL, false);
    196                 }
    197                 return 0;
    198         default:
    199                 pr_warn("bcm47xx: unable to fill SPROM for given bustype.\n");
    200                 return -EINVAL;
    201         }
    202 }
    203 
    204152static void __init bcm47xx_register_bcma(void)
    205153{
    206154        int err;
    207155
    208         err = bcma_arch_register_fallback_sprom(&bcm47xx_get_sprom_bcma);
    209         if (err)
    210                 pr_warn("bcm47xx: someone else already registered a bcma SPROM callback handler (err %d)\n", err);
    211 
    212156        err = bcma_host_soc_register(&bcm47xx_bus.bcma);
    213157        if (err)
    214158                panic("Failed to register BCMA bus (err %d)", err);
    void __init plat_mem_setup(void) 
    229173                printk(KERN_INFO "bcm47xx: using bcma bus\n");
    230174#ifdef CONFIG_BCM47XX_BCMA
    231175                bcm47xx_bus_type = BCM47XX_BUS_TYPE_BCMA;
     176                bcm47xx_sprom_register_fallbacks();
    232177                bcm47xx_register_bcma();
    233178                bcm47xx_set_system_type(bcm47xx_bus.bcma.bus.chipinfo.id);
    234179#ifdef CONFIG_HIGHMEM
    void __init plat_mem_setup(void) 
    239184                printk(KERN_INFO "bcm47xx: using ssb bus\n");
    240185#ifdef CONFIG_BCM47XX_SSB
    241186                bcm47xx_bus_type = BCM47XX_BUS_TYPE_SSB;
     187                bcm47xx_sprom_register_fallbacks();
    242188                bcm47xx_register_ssb();
    243189                bcm47xx_set_system_type(bcm47xx_bus.ssb.chip_id);
    244190#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, 
    801801        nvram_read_u16(prefix, NULL, "boardtype", &boardinfo->type, 0, true);
    802802}
    803803#endif
     804
     805#if defined(CONFIG_BCM47XX_SSB)
     806static int bcm47xx_get_sprom_ssb(struct ssb_bus *bus, struct ssb_sprom *out)
     807{
     808        char prefix[10];
     809
     810        if (bus->bustype == SSB_BUSTYPE_PCI) {
     811                memset(out, 0, sizeof(struct ssb_sprom));
     812                snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
     813                         bus->host_pci->bus->number + 1,
     814                         PCI_SLOT(bus->host_pci->devfn));
     815                bcm47xx_fill_sprom(out, prefix, false);
     816                return 0;
     817        } else {
     818                pr_warn("bcm47xx: unable to fill SPROM for given bustype.\n");
     819                return -EINVAL;
     820        }
     821}
     822#endif
     823
     824#if defined(CONFIG_BCM47XX_BCMA)
     825static int bcm47xx_get_sprom_bcma(struct bcma_bus *bus, struct ssb_sprom *out)
     826{
     827        char prefix[10];
     828        struct bcma_device *core;
     829
     830        switch (bus->hosttype) {
     831        case BCMA_HOSTTYPE_PCI:
     832                memset(out, 0, sizeof(struct ssb_sprom));
     833                snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
     834                         bus->host_pci->bus->number + 1,
     835                         PCI_SLOT(bus->host_pci->devfn));
     836                bcm47xx_fill_sprom(out, prefix, false);
     837                return 0;
     838        case BCMA_HOSTTYPE_SOC:
     839                memset(out, 0, sizeof(struct ssb_sprom));
     840                core = bcma_find_core(bus, BCMA_CORE_80211);
     841                if (core) {
     842                        snprintf(prefix, sizeof(prefix), "sb/%u/",
     843                                 core->core_index);
     844                        bcm47xx_fill_sprom(out, prefix, true);
     845                } else {
     846                        bcm47xx_fill_sprom(out, NULL, false);
     847                }
     848                return 0;
     849        default:
     850                pr_warn("bcm47xx: unable to fill SPROM for given bustype.\n");
     851                return -EINVAL;
     852        }
     853}
     854#endif
     855
     856/*
     857 * On bcm47xx we need to register SPROM fallback handler very early, so we can't
     858 * use anything like platform device / driver for this.
     859 */
     860void bcm47xx_sprom_register_fallbacks(void)
     861{
     862#if defined(CONFIG_BCM47XX_SSB)
     863        if (ssb_arch_register_fallback_sprom(&bcm47xx_get_sprom_ssb))
     864                pr_warn("Failed to registered ssb SPROM handler\n");
     865#endif
     866
     867#if defined(CONFIG_BCM47XX_BCMA)
     868        if (bcma_arch_register_fallback_sprom(&bcm47xx_get_sprom_bcma))
     869                pr_warn("Failed to registered bcma SPROM handler\n");
     870#endif
     871}
Note: See TracBrowser for help on using the repository browser.