From df14a3269c98f6d1c2f6fd848588d0fe409ff688 Mon Sep 17 00:00:00 2001 From: jow Date: Sun, 24 Jul 2011 14:10:39 +0000 Subject: [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 git-svn-id: svn://svn.openwrt.org/openwrt/trunk@27751 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../patches/005-fix-mem-leak-on-unload.patch | 31 ++++ .../patches/006-fix-mem-leak-on-unload.patch | 31 ---- .../broadcom-wl/patches/006-generic-dma-api.patch | 4 +- .../broadcom-wl/patches/007-add-bcma-support.patch | 184 +++++++++++++++++++++ .../broadcom-wl/patches/910-fallback-sprom.patch | 2 +- 5 files changed, 218 insertions(+), 34 deletions(-) create mode 100644 package/broadcom-wl/patches/005-fix-mem-leak-on-unload.patch delete mode 100644 package/broadcom-wl/patches/006-fix-mem-leak-on-unload.patch create mode 100644 package/broadcom-wl/patches/007-add-bcma-support.patch (limited to 'package/broadcom-wl/patches') diff --git a/package/broadcom-wl/patches/005-fix-mem-leak-on-unload.patch b/package/broadcom-wl/patches/005-fix-mem-leak-on-unload.patch new file mode 100644 index 000000000..41c246ff8 --- /dev/null +++ b/package/broadcom-wl/patches/005-fix-mem-leak-on-unload.patch @@ -0,0 +1,31 @@ +From: George Kashperko + +Release nvram variables buffer. +Prevent block reserved by alloc_etherdev from being freed. +Signed-off-by: George Kashperko +--- +--- +--- a/driver/siutils.c ++++ b/driver/siutils.c +@@ -647,7 +647,10 @@ si_detach(si_t *sih) + #if !defined(BCMBUSTYPE) || (BCMBUSTYPE == SI_BUS) + if (sii != &ksii) + #endif /* !BCMBUSTYPE || (BCMBUSTYPE == SI_BUS) */ +- MFREE(sii->osh, sii, sizeof(si_info_t)); ++ do { ++ MFREE(sii->osh, sii, sizeof(si_info_t)); ++ nvram_exit((void *)&(sii->pub)); ++ } while (0); + } + + void * +--- a/driver/wl_linux.c ++++ b/driver/wl_linux.c +@@ -1477,7 +1477,6 @@ wl_free_if(wl_info_t *wl, wl_if_t *wlif) + free_netdev(wlif->dev); + #endif + } +- MFREE(wl->osh, wlif, sizeof(wl_if_t)); + } + + #ifdef AP diff --git a/package/broadcom-wl/patches/006-fix-mem-leak-on-unload.patch b/package/broadcom-wl/patches/006-fix-mem-leak-on-unload.patch deleted file mode 100644 index 41c246ff8..000000000 --- a/package/broadcom-wl/patches/006-fix-mem-leak-on-unload.patch +++ /dev/null @@ -1,31 +0,0 @@ -From: George Kashperko - -Release nvram variables buffer. -Prevent block reserved by alloc_etherdev from being freed. -Signed-off-by: George Kashperko ---- ---- ---- a/driver/siutils.c -+++ b/driver/siutils.c -@@ -647,7 +647,10 @@ si_detach(si_t *sih) - #if !defined(BCMBUSTYPE) || (BCMBUSTYPE == SI_BUS) - if (sii != &ksii) - #endif /* !BCMBUSTYPE || (BCMBUSTYPE == SI_BUS) */ -- MFREE(sii->osh, sii, sizeof(si_info_t)); -+ do { -+ MFREE(sii->osh, sii, sizeof(si_info_t)); -+ nvram_exit((void *)&(sii->pub)); -+ } while (0); - } - - void * ---- a/driver/wl_linux.c -+++ b/driver/wl_linux.c -@@ -1477,7 +1477,6 @@ wl_free_if(wl_info_t *wl, wl_if_t *wlif) - free_netdev(wlif->dev); - #endif - } -- MFREE(wl->osh, wlif, sizeof(wl_if_t)); - } - - #ifdef AP diff --git a/package/broadcom-wl/patches/006-generic-dma-api.patch b/package/broadcom-wl/patches/006-generic-dma-api.patch index a4ac1d841..a90bbe1f9 100644 --- a/package/broadcom-wl/patches/006-generic-dma-api.patch +++ b/package/broadcom-wl/patches/006-generic-dma-api.patch @@ -11,8 +11,8 @@ Signed-off-by: George Kashperko --- driver/linux_osl.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) ---- broadcom-wl-5.10.56.27.3.orig/driver/linux_osl.c 2011-05-17 23:40:00.000000000 +0300 -+++ broadcom-wl-5.10.56.27.3/driver/linux_osl.c 2011-05-17 23:46:01.000000000 +0300 +--- a/driver/linux_osl.c ++++ b/driver/linux_osl.c @@ -25,6 +25,9 @@ #include #endif /* mips */ diff --git a/package/broadcom-wl/patches/007-add-bcma-support.patch b/package/broadcom-wl/patches/007-add-bcma-support.patch new file mode 100644 index 000000000..2639abcf6 --- /dev/null +++ b/package/broadcom-wl/patches/007-add-bcma-support.patch @@ -0,0 +1,184 @@ +--- a/driver/wl_linux.c ++++ b/driver/wl_linux.c +@@ -85,10 +85,9 @@ typedef void wlc_hw_info_t; + #include + #endif /* BCMJTAG */ + +- +-#ifdef CONFIG_SSB +-#include +-#endif ++#if defined(CONFIG_SSB) || defined(CONFIG_BCMA) ++#include ++#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */ + + /* Linux wireless extension support */ + #ifdef CONFIG_WIRELESS_EXT +@@ -997,62 +996,32 @@ static struct pci_driver wl_pci_driver = + #endif /* CONFIG_PCI */ + #endif + ++#ifdef BCMJTAG ++static bcmjtag_driver_t wl_jtag_driver = { ++ wl_jtag_probe, ++ wl_jtag_detach, ++ wl_jtag_poll, ++ }; ++#endif /* BCMJTAG */ + +-static int wl_ssb_probe(struct ssb_device *dev, const struct ssb_device_id *id) ++#if defined(CONFIG_SSB) || defined(CONFIG_BCMA) ++static void * glue_attach_cb(u16 vendor, u16 device, ++ ulong mmio, void *dev, u32 irq) + { +- wl_info_t *wl; +- void *mmio; +- +- if (dev->bus->bustype != SSB_BUSTYPE_SSB) { +- printk("Attaching to SSB behind PCI is not supported. Please remove the b43 ssb bridge\n"); +- return -EINVAL; +- } +- +- mmio = (void *) 0x18000000 + dev->core_index * 0x1000; +- wl = wl_attach(id->vendor, id->coreid, (ulong) mmio, SI_BUS, dev, dev->irq); +- if (!wl) { +- printk("wl_attach failed\n"); +- return -ENODEV; +- } +- +- ssb_set_drvdata(dev, wl); +- +- return 0; ++ return wl_attach(vendor, device, mmio, SI_BUS, dev, irq); + } + +-static void wl_ssb_remove(struct ssb_device *dev) ++static void glue_remove_cb(void *wldev) + { +- wl_info_t *wl = (wl_info_t *) ssb_get_drvdata(dev); ++ wl_info_t *wl = (wl_info_t *)wldev; + + WL_LOCK(wl); + WL_APSTA_UPDN(("wl%d (%s): wl_remove() -> wl_down()\n", wl->pub->unit, wl->dev->name)); + wl_down(wl); + WL_UNLOCK(wl); + wl_free(wl); +- ssb_set_drvdata(dev, NULL); + } +- +-static const struct ssb_device_id wl_ssb_tbl[] = { +- SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_80211, SSB_ANY_REV), +- SSB_DEVTABLE_END +-}; +- +-#ifdef CONFIG_SSB +-static struct ssb_driver wl_ssb_driver = { +- .name = KBUILD_MODNAME, +- .id_table = wl_ssb_tbl, +- .probe = wl_ssb_probe, +- .remove = wl_ssb_remove, +-}; +-#endif +- +-#ifdef BCMJTAG +-static bcmjtag_driver_t wl_jtag_driver = { +- wl_jtag_probe, +- wl_jtag_detach, +- wl_jtag_poll, +- }; +-#endif /* BCMJTAG */ ++#endif/* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */ + + + /** +@@ -1067,11 +1036,13 @@ wl_module_init(void) + { + int error = -ENODEV; + +-#ifdef CONFIG_SSB +- error = ssb_driver_register(&wl_ssb_driver); ++#if defined(CONFIG_SSB) || defined(CONFIG_BCMA) ++ wl_glue_set_attach_callback(&glue_attach_cb); ++ wl_glue_set_remove_callback(&glue_remove_cb); ++ error = wl_glue_register(); + if (error) + return error; +-#endif /* CONFIG_SSB */ ++#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */ + + #ifdef CONFIG_PCI + error = pci_register_driver(&wl_pci_driver); +@@ -1082,7 +1053,9 @@ wl_module_init(void) + return 0; + + error_pci: +- ssb_driver_unregister(&wl_ssb_driver); ++#if defined(CONFIG_SSB) || defined(CONFIG_BCMA) ++ wl_glue_unregister(); ++#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */ + return error; + } + +@@ -1099,9 +1072,9 @@ wl_module_exit(void) + #ifdef CONFIG_PCI + pci_unregister_driver(&wl_pci_driver); + #endif /* CONFIG_PCI */ +-#ifdef CONFIG_SSB +- ssb_driver_unregister(&wl_ssb_driver); +-#endif /* CONFIG_SSB */ ++#if defined(CONFIG_SSB) || defined(CONFIG_BCMA) ++ wl_glue_unregister(); ++#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */ + } + + module_init(wl_module_init); +--- a/driver/linux_osl.c ++++ b/driver/linux_osl.c +@@ -25,9 +25,9 @@ + #include + #endif /* mips */ + #include +-#ifdef CONFIG_SSB +-#include +-#endif ++#if defined(CONFIG_SSB) || defined(CONFIG_BCMA) ++#include ++#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */ + + #define PCI_CFG_RETRY 10 + +@@ -370,15 +370,17 @@ osl_dma_consistent_align(void) + static struct device * + osl_get_dmadev(osl_t *osh) + { +-#ifdef CONFIG_SSB ++#if defined(CONFIG_SSB) || defined(CONFIG_BCMA) + if (osh->bustype == SI_BUS) { +- /* This can be SiliconBackplane emulated as pci with Broadcom or +- * ssb device. Less harmful is to check for pci_bus_type and if +- * no match then assume we got ssb */ ++ /* This can be SiliconBackplane emulated as pci with Broadcom, ++ * ssb or bcma device. Less harmful is to check for pci_bus_type and if ++ * no match then assume we got either ssb or bcma */ + if (((struct pci_dev *)osh->pdev)->dev.bus != &pci_bus_type) +- return ((struct ssb_device *)osh->pdev)->dma_dev; ++ { ++ return wl_glue_get_dmadev(osh->pdev); ++ } + } +-#endif ++#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */ + return &((struct pci_dev *)osh->pdev)->dev; + } + +--- a/driver/Makefile ++++ b/driver/Makefile +@@ -1,7 +1,7 @@ + BUILD_TYPE=wl_apsta + include $(src)/$(BUILD_TYPE)/buildflags.mk + +-EXTRA_CFLAGS += -I$(src)/include -I$(src) -DBCMDRIVER $(WLFLAGS) ++EXTRA_CFLAGS += -I$(src)/include -I$(src) -I$(realpath $(src)/../glue) -DBCMDRIVER $(WLFLAGS) + + wl-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 + diff --git a/package/broadcom-wl/patches/910-fallback-sprom.patch b/package/broadcom-wl/patches/910-fallback-sprom.patch index 407ec5ac1..749ecbf31 100644 --- a/package/broadcom-wl/patches/910-fallback-sprom.patch +++ b/package/broadcom-wl/patches/910-fallback-sprom.patch @@ -23,7 +23,7 @@ /* * Apply CRC over SROM content regardless SROM is present or not, * and use variable sromrev's existance in flash to decide -@@ -2120,6 +2130,58 @@ BCMATTACHFN(initvars_srom_pci)(si_t *sih +@@ -2120,6 +2129,58 @@ BCMATTACHFN(initvars_srom_pci)(si_t *sih goto varscont; } -- cgit v1.2.3