source: trunk/package/broadcom-wl/patches/007-add-bcma-support.patch @ 27751

Last change on this file since 27751 was 27751, checked in by jow, 5 years ago

[package] broadcom-wl: make it work on the RT-N16 and other device using the BCMA bus

  • refresh and reorder patches
  • introduce a unified BCMA/SSB glue driver to accomodate for both bus types on brcm47xx
  • extend wlunbind init script to detach device from bcma-pci-bridge as well
File size: 5.0 KB
  • driver/wl_linux.c

    a b typedef void wlc_hw_info_t; 
    8585#include <bcmjtag.h> 
    8686#endif  /* BCMJTAG */ 
    8787 
    88  
    89 #ifdef CONFIG_SSB 
    90 #include <linux/ssb/ssb.h> 
    91 #endif 
     88#if defined(CONFIG_SSB) || defined(CONFIG_BCMA) 
     89#include <wl_glue.h> 
     90#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */ 
    9291 
    9392/* Linux wireless extension support */ 
    9493#ifdef CONFIG_WIRELESS_EXT 
    static struct pci_driver wl_pci_driver = 
    997996#endif  /* CONFIG_PCI */ 
    998997#endif   
    999998 
     999#ifdef BCMJTAG 
     1000static bcmjtag_driver_t wl_jtag_driver = { 
     1001                wl_jtag_probe, 
     1002                wl_jtag_detach, 
     1003                wl_jtag_poll, 
     1004                }; 
     1005#endif  /* BCMJTAG */ 
    10001006 
    1001 static int wl_ssb_probe(struct ssb_device *dev, const struct ssb_device_id *id) 
     1007#if defined(CONFIG_SSB) || defined(CONFIG_BCMA) 
     1008static void * glue_attach_cb(u16 vendor, u16 device, 
     1009                                ulong mmio, void *dev, u32 irq) 
    10021010{ 
    1003         wl_info_t *wl; 
    1004         void *mmio; 
    1005  
    1006         if (dev->bus->bustype != SSB_BUSTYPE_SSB) { 
    1007                 printk("Attaching to SSB behind PCI is not supported. Please remove the b43 ssb bridge\n"); 
    1008                 return -EINVAL; 
    1009         } 
    1010  
    1011         mmio = (void *) 0x18000000 + dev->core_index * 0x1000; 
    1012         wl = wl_attach(id->vendor, id->coreid, (ulong) mmio, SI_BUS, dev, dev->irq); 
    1013         if (!wl) { 
    1014                 printk("wl_attach failed\n"); 
    1015                 return -ENODEV; 
    1016         } 
    1017  
    1018         ssb_set_drvdata(dev, wl); 
    1019  
    1020         return 0; 
     1011        return wl_attach(vendor, device, mmio, SI_BUS, dev, irq); 
    10211012} 
    10221013 
    1023 static void wl_ssb_remove(struct ssb_device *dev) 
     1014static void glue_remove_cb(void *wldev) 
    10241015{ 
    1025         wl_info_t *wl = (wl_info_t *) ssb_get_drvdata(dev); 
     1016        wl_info_t *wl = (wl_info_t *)wldev; 
    10261017 
    10271018        WL_LOCK(wl); 
    10281019        WL_APSTA_UPDN(("wl%d (%s): wl_remove() -> wl_down()\n", wl->pub->unit, wl->dev->name)); 
    10291020        wl_down(wl); 
    10301021        WL_UNLOCK(wl); 
    10311022        wl_free(wl); 
    1032         ssb_set_drvdata(dev, NULL); 
    10331023} 
    1034  
    1035 static const struct ssb_device_id wl_ssb_tbl[] = { 
    1036         SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_80211, SSB_ANY_REV), 
    1037         SSB_DEVTABLE_END 
    1038 }; 
    1039  
    1040 #ifdef CONFIG_SSB 
    1041 static struct ssb_driver wl_ssb_driver = { 
    1042         .name   = KBUILD_MODNAME, 
    1043         .id_table = wl_ssb_tbl, 
    1044         .probe = wl_ssb_probe, 
    1045         .remove = wl_ssb_remove, 
    1046 }; 
    1047 #endif 
    1048  
    1049 #ifdef BCMJTAG 
    1050 static bcmjtag_driver_t wl_jtag_driver = { 
    1051                 wl_jtag_probe, 
    1052                 wl_jtag_detach, 
    1053                 wl_jtag_poll, 
    1054                 }; 
    1055 #endif  /* BCMJTAG */ 
     1024#endif/* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */ 
    10561025 
    10571026 
    10581027/**  
    wl_module_init(void) 
    10671036{ 
    10681037        int error = -ENODEV; 
    10691038 
    1070 #ifdef CONFIG_SSB 
    1071         error = ssb_driver_register(&wl_ssb_driver); 
     1039#if defined(CONFIG_SSB) || defined(CONFIG_BCMA) 
     1040        wl_glue_set_attach_callback(&glue_attach_cb); 
     1041        wl_glue_set_remove_callback(&glue_remove_cb); 
     1042        error = wl_glue_register(); 
    10721043        if (error) 
    10731044                return error; 
    1074 #endif  /* CONFIG_SSB */ 
     1045#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */ 
    10751046 
    10761047#ifdef CONFIG_PCI 
    10771048        error = pci_register_driver(&wl_pci_driver); 
    wl_module_init(void) 
    10821053        return 0; 
    10831054 
    10841055error_pci: 
    1085         ssb_driver_unregister(&wl_ssb_driver); 
     1056#if defined(CONFIG_SSB) || defined(CONFIG_BCMA) 
     1057        wl_glue_unregister(); 
     1058#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */ 
    10861059        return error; 
    10871060} 
    10881061 
    wl_module_exit(void) 
    10991072#ifdef CONFIG_PCI 
    11001073        pci_unregister_driver(&wl_pci_driver); 
    11011074#endif  /* CONFIG_PCI */ 
    1102 #ifdef CONFIG_SSB 
    1103         ssb_driver_unregister(&wl_ssb_driver); 
    1104 #endif  /* CONFIG_SSB */ 
     1075#if defined(CONFIG_SSB) || defined(CONFIG_BCMA) 
     1076        wl_glue_unregister(); 
     1077#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */ 
    11051078} 
    11061079 
    11071080module_init(wl_module_init); 
  • driver/linux_osl.c

    a b  
    2525#include <asm/paccess.h> 
    2626#endif /* mips */ 
    2727#include <pcicfg.h> 
    28 #ifdef CONFIG_SSB 
    29 #include <linux/ssb/ssb.h> 
    30 #endif 
     28#if defined(CONFIG_SSB) || defined(CONFIG_BCMA) 
     29#include <wl_glue.h> 
     30#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */ 
    3131 
    3232#define PCI_CFG_RETRY           10 
    3333 
    osl_dma_consistent_align(void) 
    370370static struct device * 
    371371osl_get_dmadev(osl_t *osh) 
    372372{ 
    373 #ifdef CONFIG_SSB 
     373#if defined(CONFIG_SSB) || defined(CONFIG_BCMA) 
    374374        if (osh->bustype == SI_BUS) { 
    375                 /* This can be SiliconBackplane emulated as pci with Broadcom or 
    376                  * ssb device. Less harmful is to check for pci_bus_type and if 
    377                  * no match then assume we got ssb */ 
     375                /* This can be SiliconBackplane emulated as pci with Broadcom, 
     376                 * ssb or bcma device. Less harmful is to check for pci_bus_type and if 
     377                 * no match then assume we got either ssb or bcma */ 
    378378                if (((struct pci_dev *)osh->pdev)->dev.bus != &pci_bus_type) 
    379                         return ((struct ssb_device *)osh->pdev)->dma_dev; 
     379                { 
     380                        return wl_glue_get_dmadev(osh->pdev); 
     381                } 
    380382        } 
    381 #endif 
     383#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */ 
    382384        return &((struct pci_dev *)osh->pdev)->dev; 
    383385} 
    384386 
  • driver/Makefile

    a b  
    11BUILD_TYPE=wl_apsta 
    22include $(src)/$(BUILD_TYPE)/buildflags.mk 
    33 
    4 EXTRA_CFLAGS += -I$(src)/include -I$(src) -DBCMDRIVER $(WLFLAGS) 
     4EXTRA_CFLAGS += -I$(src)/include -I$(src) -I$(realpath $(src)/../glue) -DBCMDRIVER $(WLFLAGS) 
    55 
    66wl-objs := $(BUILD_TYPE)/wl_prebuilt.o wl_iw.o wl_linux.o linux_osl.o siutils.o aiutils.o hndpmu.o bcmutils.o sbutils.o nicpci.o hnddma.o bcmsrom.o nvram_stub.o 
    77 
Note: See TracBrowser for help on using the repository browser.