ASR_BASE

Change-Id: Icf3719cc0afe3eeb3edc7fa80a2eb5199ca9dda1
diff --git a/package/kernel/broadcom-wl/patches/003-compat-2.6.35.patch b/package/kernel/broadcom-wl/patches/003-compat-2.6.35.patch
new file mode 100644
index 0000000..89b6653
--- /dev/null
+++ b/package/kernel/broadcom-wl/patches/003-compat-2.6.35.patch
@@ -0,0 +1,39 @@
+--- a/driver/wl_linux.c
++++ b/driver/wl_linux.c
+@@ -2082,7 +2082,11 @@ static void
+ _wl_set_multicast_list(struct net_device *dev)
+ {
+ 	wl_info_t *wl;
++#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,34)
+ 	struct dev_mc_list *mclist;
++#else
++	struct netdev_hw_addr *ha;
++#endif
+ 	int i;
+ 
+ 	if (!dev)
+@@ -2098,14 +2102,24 @@ _wl_set_multicast_list(struct net_device
+ 		wl->pub->allmulti = (dev->flags & IFF_ALLMULTI)? TRUE: FALSE;
+ 
+ 		/* copy the list of multicasts into our private table */
++#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,34)
+ 		for (i = 0, mclist = dev->mc_list; mclist && (i < dev->mc_count);
+ 			i++, mclist = mclist->next) {
++#else
++		i = 0;
++		netdev_for_each_mc_addr(ha, dev) {
++#endif
+ 			if (i >= MAXMULTILIST) {
+ 				wl->pub->allmulti = TRUE;
+ 				i = 0;
+ 				break;
+ 			}
++#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,34)
+ 			wl->pub->multicast[i] = *((struct ether_addr*) mclist->dmi_addr);
++#else
++			wl->pub->multicast[i] = *((struct ether_addr*) ha->addr);
++			i++;
++#endif
+ 		}
+ 		wl->pub->nmulticast = i;
+ 		wlc_set(wl->wlc, WLC_SET_PROMISC, (dev->flags & IFF_PROMISC));
diff --git a/package/kernel/broadcom-wl/patches/004-remove-pcmcia.patch b/package/kernel/broadcom-wl/patches/004-remove-pcmcia.patch
new file mode 100644
index 0000000..36dda47
--- /dev/null
+++ b/package/kernel/broadcom-wl/patches/004-remove-pcmcia.patch
@@ -0,0 +1,22 @@
+--- a/driver/include/linuxver.h
++++ b/driver/include/linuxver.h
+@@ -111,7 +111,7 @@ typedef irqreturn_t(*FN_ISR) (int irq, v
+ #endif /* not SANDGATE2G */
+ #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 67) */
+ 
+-#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
++#if 0
+ 
+ #include <pcmcia/cs_types.h>
+ #include <pcmcia/cs.h>
+--- a/driver/linux_osl.c
++++ b/driver/linux_osl.c
+@@ -62,7 +62,7 @@ struct osl_info {
+ };
+ 
+ /* PCMCIA attribute space access macros */
+-#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
++#if 0
+ struct pcmcia_dev {
+ 	dev_link_t link;	/* PCMCIA device pointer */
+ 	dev_node_t node;	/* PCMCIA node structure */
diff --git a/package/kernel/broadcom-wl/patches/005-fix-mem-leak-on-unload.patch b/package/kernel/broadcom-wl/patches/005-fix-mem-leak-on-unload.patch
new file mode 100644
index 0000000..41c246f
--- /dev/null
+++ b/package/kernel/broadcom-wl/patches/005-fix-mem-leak-on-unload.patch
@@ -0,0 +1,31 @@
+From: George Kashperko <george@znau.edu.ua>
+
+Release nvram variables buffer.
+Prevent block reserved by alloc_etherdev from being freed.
+Signed-off-by: George Kashperko <george@znau.edu.ua>
+---
+---
+--- 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/kernel/broadcom-wl/patches/006-generic-dma-api.patch b/package/kernel/broadcom-wl/patches/006-generic-dma-api.patch
new file mode 100644
index 0000000..d6dd5f0
--- /dev/null
+++ b/package/kernel/broadcom-wl/patches/006-generic-dma-api.patch
@@ -0,0 +1,88 @@
+From: George Kashperko <george@znau.edu.ua>
+
+broadcom-wl driver bound to ssb device with ssb driver probe
+have osh handle struct pdev pointer value initialized with
+ssb_device pointer. Later on pdev is used with legacy pci
+dma api as pci_dev thus causing oops sometimes.
+
+The patch replaces legacy pci dma api and pass relevant
+device struct pointer to avoid crashes.
+Signed-off-by: George Kashperko <george@znau.edu.ua>
+---
+ driver/linux_osl.c |   28 +++++++++++++++++++++++-----
+ 1 file changed, 23 insertions(+), 5 deletions(-)
+--- a/driver/linux_osl.c
++++ b/driver/linux_osl.c
+@@ -25,6 +25,9 @@
+ #include <asm/paccess.h>
+ #endif /* mips */
+ #include <pcicfg.h>
++#ifdef CONFIG_SSB
++#include <linux/ssb/ssb.h>
++#endif
+ 
+ #define PCI_CFG_RETRY 		10
+ 
+@@ -364,12 +367,27 @@ osl_dma_consistent_align(void)
+ 	return (PAGE_SIZE);
+ }
+ 
++static struct device *
++osl_get_dmadev(osl_t *osh)
++{
++#ifdef CONFIG_SSB
++	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 */
++		if (((struct pci_dev *)osh->pdev)->dev.bus != &pci_bus_type)
++			return ((struct ssb_device *)osh->pdev)->dma_dev;
++	}
++#endif
++	return &((struct pci_dev *)osh->pdev)->dev;
++}
++
+ void*
+ osl_dma_alloc_consistent(osl_t *osh, uint size, ulong *pap)
+ {
+ 	ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
+ 
+-	return (pci_alloc_consistent(osh->pdev, size, (dma_addr_t*)pap));
++	return (dma_alloc_coherent(osl_get_dmadev(osh), size, (dma_addr_t*)pap, GFP_ATOMIC));
+ }
+ 
+ void
+@@ -377,7 +395,7 @@ osl_dma_free_consistent(osl_t *osh, void
+ {
+ 	ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
+ 
+-	pci_free_consistent(osh->pdev, size, va, (dma_addr_t)pa);
++	dma_free_coherent(osl_get_dmadev(osh), size, va, (dma_addr_t)pa);
+ }
+ 
+ uint BCMFASTPATH
+@@ -386,13 +404,13 @@ osl_dma_map(osl_t *osh, void *va, uint s
+ 	ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
+ 
+ 	if (direction == DMA_TX)
+-		return (pci_map_single(osh->pdev, va, size, PCI_DMA_TODEVICE));
++		return (dma_map_single(osl_get_dmadev(osh), va, size, PCI_DMA_TODEVICE));
+ 	else {
+ #ifdef mips
+ 		dma_cache_inv((uint)va, size);
+ 		return (virt_to_phys(va));
+ #else /* mips */
+-		return (pci_map_single(osh->pdev, va, size, PCI_DMA_FROMDEVICE));
++		return (dma_map_single(osl_get_dmadev(osh), va, size, PCI_DMA_FROMDEVICE));
+ #endif /* mips */
+ 	}
+ }
+@@ -404,7 +422,7 @@ osl_dma_unmap(osl_t *osh, uint pa, uint
+ 
+ 	ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
+ 	dir = (direction == DMA_TX)? PCI_DMA_TODEVICE: PCI_DMA_FROMDEVICE;
+-	pci_unmap_single(osh->pdev, (uint32)pa, size, dir);
++	dma_unmap_single(osl_get_dmadev(osh), (uint32)pa, size, dir);
+ }
+ 
+ 
diff --git a/package/kernel/broadcom-wl/patches/007-use-glue-driver.patch b/package/kernel/broadcom-wl/patches/007-use-glue-driver.patch
new file mode 100644
index 0000000..a30dcc4
--- /dev/null
+++ b/package/kernel/broadcom-wl/patches/007-use-glue-driver.patch
@@ -0,0 +1,188 @@
+--- a/driver/wl_linux.c
++++ b/driver/wl_linux.c
+@@ -85,10 +85,9 @@ typedef void wlc_hw_info_t;
+ #include <bcmjtag.h>
+ #endif	/* BCMJTAG */
+ 
+-
+-#ifdef CONFIG_SSB
+-#include <linux/ssb/ssb.h>
+-#endif
++#if defined(CONFIG_SSB) || defined(CONFIG_BCMA)
++#include <wl_glue.h>
++#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,11 @@ wl_module_init(void)
+ 	return 0;
+ 
+ error_pci:
+-	ssb_driver_unregister(&wl_ssb_driver);
++#if defined(CONFIG_SSB) || defined(CONFIG_BCMA)
++	wl_glue_unregister();
++	wl_glue_set_attach_callback(NULL);
++	wl_glue_set_remove_callback(NULL);
++#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */
+ 	return error;
+ }
+ 
+@@ -1099,9 +1074,11 @@ 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();
++	wl_glue_set_attach_callback(NULL);
++	wl_glue_set_remove_callback(NULL);
++#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 <asm/paccess.h>
+ #endif /* mips */
+ #include <pcicfg.h>
+-#ifdef CONFIG_SSB
+-#include <linux/ssb/ssb.h>
+-#endif
++#if defined(CONFIG_SSB) || defined(CONFIG_BCMA)
++#include <wl_glue.h>
++#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/kernel/broadcom-wl/patches/008-fix_virtual_interfaces.patch b/package/kernel/broadcom-wl/patches/008-fix_virtual_interfaces.patch
new file mode 100644
index 0000000..23831df
--- /dev/null
+++ b/package/kernel/broadcom-wl/patches/008-fix_virtual_interfaces.patch
@@ -0,0 +1,132 @@
+--- a/driver/wl_linux.c
++++ b/driver/wl_linux.c
+@@ -354,6 +354,7 @@ static int wl_read_proc(char *buffer, ch
+ static int wl_dump(wl_info_t *wl, struct bcmstrbuf *b);
+ #endif /* BCMDBG */
+ struct wl_if *wl_alloc_if(wl_info_t *wl, int iftype, uint unit, struct wlc_if* wlc_if);
++static void wl_link_if(wl_info_t *wl, wl_if_t *wlif);
+ static void wl_free_if(wl_info_t *wl, wl_if_t *wlif);
+ 
+ 
+@@ -566,6 +567,9 @@ wl_attach(uint16 vendor, uint16 device,
+ 	wl->dev = dev;
+ 	wl_if_setup(dev);
+ 
++	/* add the interface to the interface linked list */
++	wl_link_if(wl, wlif);
++
+ 	/* map chip registers (47xx: and sprom) */
+ 	dev->base_addr = regs;
+ 
+@@ -1106,10 +1110,14 @@ wl_free(wl_info_t *wl)
+ 			free_irq(wl->dev->irq, wl);
+ 	}
+ 
+-	if (wl->dev) {
+-		wl_free_if(wl, WL_DEV_IF(wl->dev));
+-		wl->dev = NULL;
++	/* free all interfaces */
++	while (wl->if_list) {
++        	if ((wl->if_list->dev != wl->dev) || wl->if_list->next == NULL)
++			wl_free_if(wl, wl->if_list);
++		else
++			wl_free_if(wl, wl->if_list->next);
+ 	}
++	wl->dev = NULL;
+ 
+ #ifdef TOE
+ 	wl_toe_detach(wl->toei);
+@@ -1355,10 +1363,12 @@ wl_txflowcontrol(wl_info_t *wl, bool sta
+ 
+ 	ASSERT(prio == ALLPRIO);
+ 	for (wlif = wl->if_list; wlif != NULL; wlif = wlif->next) {
+-		if (state == ON)
+-			netif_stop_queue(wlif->dev);
+-		else
+-			netif_wake_queue(wlif->dev);
++		if (wlif->dev_registed) {
++			if (state == ON)
++				netif_stop_queue(wlif->dev);
++			else
++				netif_wake_queue(wlif->dev);
++		}
+ 	}
+ }
+ 
+@@ -1398,7 +1408,6 @@ wl_alloc_if(wl_info_t *wl, int iftype, u
+ {
+ 	struct net_device *dev;
+ 	wl_if_t *wlif;
+-	wl_if_t *p;
+ 
+ 	dev = alloc_etherdev(sizeof(wl_if_t));
+ 	wlif = netdev_priv(dev);
+@@ -1411,9 +1420,13 @@ wl_alloc_if(wl_info_t *wl, int iftype, u
+ 	wlif->wlcif = wlcif;
+ 	wlif->subunit = subunit;
+ 
+-	/* match current flow control state */
+-	if (iftype != WL_IFTYPE_MON && wl->dev && netif_queue_stopped(wl->dev))
+-		netif_stop_queue(dev);
++	return wlif;
++}
++
++static void
++wl_link_if(wl_info_t *wl, wl_if_t *wlif)
++{
++	wl_if_t *p;
+ 
+ 	/* add the interface to the interface linked list */
+ 	if (wl->if_list == NULL)
+@@ -1424,7 +1437,6 @@ wl_alloc_if(wl_info_t *wl, int iftype, u
+ 			p = p->next;
+ 		p->next = wlif;
+ 	}
+-	return wlif;
+ }
+ 
+ static void
+@@ -1504,6 +1516,9 @@ _wl_add_if(wl_task_t *task)
+ 	wl_info_t *wl = wlif->wl;
+ 	struct net_device *dev = wlif->dev;
+ 
++	/* add the interface to the interface linked list */
++	wl_link_if(wl, wlif);
++
+ 	if (wlif->type == WL_IFTYPE_WDS)
+ 		dev->netdev_ops = &wl_wds_ops;
+ 
+@@ -1516,6 +1531,14 @@ _wl_add_if(wl_task_t *task)
+ 	}
+ 	wlif->dev_registed = TRUE;
+ 
++	/* match current flow control state */
++	if (wl->dev) {
++		if (netif_queue_stopped(wl->dev))
++			netif_stop_queue(dev);
++		else
++			netif_wake_queue(dev);
++	}
++
+ done:
+ 	MFREE(wl->osh, task, sizeof(wl_task_t));
+ 	atomic_dec(&wl->callbacks);
+@@ -1545,6 +1568,8 @@ wl_add_if(wl_info_t *wl, struct wlc_if*
+ 		return NULL;
+ 	}
+ 
++	wl_if_setup(wlif->dev);
++
+ 	sprintf(wlif->dev->name, "%s%d.%d", devname, wl->pub->unit, wlif->subunit);
+ 	if (remote)
+ 		bcopy(remote, &wlif->remote, ETHER_ADDR_LEN);
+@@ -2778,6 +2803,9 @@ wl_add_monitor(wl_task_t *task)
+ 	dev = wlif->dev;
+ 	wl->monitor = dev;
+ 
++	/* add the interface to the interface linked list */
++	wl_link_if(wl, wlif);
++
+ 	/* override some fields */
+ 	sprintf(dev->name, "prism%d", wl->pub->unit);
+ 	bcopy(wl->dev->dev_addr, dev->dev_addr, ETHER_ADDR_LEN);
diff --git a/package/kernel/broadcom-wl/patches/009-fix_compile_3_2.patch b/package/kernel/broadcom-wl/patches/009-fix_compile_3_2.patch
new file mode 100644
index 0000000..cb388a1
--- /dev/null
+++ b/package/kernel/broadcom-wl/patches/009-fix_compile_3_2.patch
@@ -0,0 +1,27 @@
+--- a/driver/wl_linux.c
++++ b/driver/wl_linux.c
+@@ -463,6 +463,16 @@ wl_schedule_fn(wl_info_t *wl, void (*fn)
+ }
+ #endif /* DSLCPE_DELAY */
+ 
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0)
++#define WL_DEFAULT_OPS \
++	.ndo_open = wl_open, \
++	.ndo_stop = wl_close, \
++	.ndo_start_xmit = wl_start, \
++	.ndo_get_stats = wl_get_stats, \
++	.ndo_set_mac_address = wl_set_mac_address, \
++	.ndo_set_rx_mode = wl_set_multicast_list, \
++	.ndo_do_ioctl = wl_ioctl
++#else
+ #define WL_DEFAULT_OPS \
+ 	.ndo_open = wl_open, \
+ 	.ndo_stop = wl_close, \
+@@ -471,6 +481,7 @@ wl_schedule_fn(wl_info_t *wl, void (*fn)
+ 	.ndo_set_mac_address = wl_set_mac_address, \
+ 	.ndo_set_multicast_list = wl_set_multicast_list, \
+ 	.ndo_do_ioctl = wl_ioctl
++#endif
+ 
+ static const struct net_device_ops wl_ops = {
+ 	WL_DEFAULT_OPS,
diff --git a/package/kernel/broadcom-wl/patches/010-remove_irqf_samble_random.patch b/package/kernel/broadcom-wl/patches/010-remove_irqf_samble_random.patch
new file mode 100644
index 0000000..7b60873
--- /dev/null
+++ b/package/kernel/broadcom-wl/patches/010-remove_irqf_samble_random.patch
@@ -0,0 +1,11 @@
+--- a/driver/wl_linux.c
++++ b/driver/wl_linux.c
+@@ -695,7 +695,7 @@ wl_attach(uint16 vendor, uint16 device,
+ 	if (wl->bustype != JTAG_BUS)
+ #endif	/* BCMJTAG */
+ 	{
+-		if (request_irq(irq, wl_isr, IRQF_SHARED|IRQF_SAMPLE_RANDOM, dev->name, wl)) {
++		if (request_irq(irq, wl_isr, IRQF_SHARED, dev->name, wl)) {
+ 			WL_ERROR(("wl%d: request_irq() failed\n", unit));
+ 			goto fail;
+ 		}
diff --git a/package/kernel/broadcom-wl/patches/011-fix_compile_3_4.patch b/package/kernel/broadcom-wl/patches/011-fix_compile_3_4.patch
new file mode 100644
index 0000000..585d53c
--- /dev/null
+++ b/package/kernel/broadcom-wl/patches/011-fix_compile_3_4.patch
@@ -0,0 +1,12 @@
+--- a/driver/wl_linux.c
++++ b/driver/wl_linux.c
+@@ -49,7 +49,9 @@
+ #include <linux/ieee80211.h>
+ #endif
+ 
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)
+ #include <asm/system.h>
++#endif
+ #include <asm/io.h>
+ #include <asm/irq.h>
+ #include <asm/pgtable.h>
diff --git a/package/kernel/broadcom-wl/patches/012-compat-3.10.patch b/package/kernel/broadcom-wl/patches/012-compat-3.10.patch
new file mode 100644
index 0000000..e36028a
--- /dev/null
+++ b/package/kernel/broadcom-wl/patches/012-compat-3.10.patch
@@ -0,0 +1,47 @@
+--- a/driver/wl_linux.c
++++ b/driver/wl_linux.c
+@@ -349,7 +349,7 @@ static void wl_mic_error(wl_info_t *wl,
+ 	defined(WL_MONITOR)
+ static int wl_schedule_task(wl_info_t *wl, void (*fn)(struct wl_task *), void *context);
+ #endif
+-#if defined(CONFIG_PROC_FS)
++#if defined(CONFIG_PROC_FS) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0))
+ static int wl_read_proc(char *buffer, char **start, off_t offset, int length, int *eof, void *data);
+ #endif /* defined(CONFIG_PROC_FS) */
+ #ifdef BCMDBG
+@@ -517,7 +517,7 @@ wl_attach(uint16 vendor, uint16 device,
+ 	struct net_device *dev;
+ 	wl_if_t *wlif;
+ 	wl_info_t *wl;
+-#if defined(CONFIG_PROC_FS)
++#if defined(CONFIG_PROC_FS) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0))
+ 	char tmp[128];
+ #endif
+ 	osl_t *osh;
+@@ -664,7 +664,7 @@ wl_attach(uint16 vendor, uint16 device,
+ 			WL_ERROR(("wl%d: Error setting MPC variable to 0\n", unit));
+ 		}
+ 	}
+-#if defined(CONFIG_PROC_FS)
++#if defined(CONFIG_PROC_FS) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0))
+ 	/* create /proc/net/wl<unit> */
+ 	sprintf(tmp, "net/wl%d", wl->pub->unit);
+ 	create_proc_read_entry(tmp, 0, 0, wl_read_proc, (void*)wl);
+@@ -810,7 +810,7 @@ wl_dbus_disconnect_cb(void *arg)
+ }
+ #endif /* BCMDBUS */
+ 
+-#if defined(CONFIG_PROC_FS)
++#if defined(CONFIG_PROC_FS) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0))
+ static int
+ wl_read_proc(char *buffer, char **start, off_t offset, int length, int *eof, void *data)
+ {
+@@ -1149,7 +1149,7 @@ wl_free(wl_info_t *wl)
+ 
+ 	/* free common resources */
+ 	if (wl->wlc) {
+-#if defined(CONFIG_PROC_FS)
++#if defined(CONFIG_PROC_FS) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0))
+ 		char tmp[128];
+ 		/* remove /proc/net/wl<unit> */
+ 		sprintf(tmp, "net/wl%d", wl->pub->unit);
diff --git a/package/kernel/broadcom-wl/patches/013-interface-name.patch b/package/kernel/broadcom-wl/patches/013-interface-name.patch
new file mode 100644
index 0000000..dbe1bdb
--- /dev/null
+++ b/package/kernel/broadcom-wl/patches/013-interface-name.patch
@@ -0,0 +1,11 @@
+--- a/driver/wl_linux.c
++++ b/driver/wl_linux.c
+@@ -1583,7 +1583,7 @@ wl_add_if(wl_info_t *wl, struct wlc_if*
+ 
+ 	wl_if_setup(wlif->dev);
+ 
+-	sprintf(wlif->dev->name, "%s%d.%d", devname, wl->pub->unit, wlif->subunit);
++	sprintf(wlif->dev->name, "%s%d-%d", devname, wl->pub->unit, wlif->subunit);
+ 	if (remote)
+ 		bcopy(remote, &wlif->remote, ETHER_ADDR_LEN);
+ 
diff --git a/package/kernel/broadcom-wl/patches/014-fix-band-reporting.patch b/package/kernel/broadcom-wl/patches/014-fix-band-reporting.patch
new file mode 100644
index 0000000..b231fed
--- /dev/null
+++ b/package/kernel/broadcom-wl/patches/014-fix-band-reporting.patch
@@ -0,0 +1,41 @@
+--- a/driver/wl_iw.c
++++ b/driver/wl_iw.c
+@@ -314,7 +314,7 @@ wl_iw_get_name(
+ )
+ {
+ 	int phytype, err;
+-	uint band[3];
++	uint i, band[3], bands;
+ 	char cap[5];
+ 
+ 	WL_TRACE(("%s: SIOCGIWNAME\n", dev->name));
+@@ -335,16 +335,20 @@ wl_iw_get_name(
+ 			break;
+ 		case WLC_PHY_TYPE_LP:
+ 		case WLC_PHY_TYPE_G:
+-			if (band[0] >= 2)
+-				strcpy(cap, "abg");
+-			else
+-				strcpy(cap, "bg");
+-			break;
+ 		case WLC_PHY_TYPE_N:
+-			if (band[0] >= 2)
+-				strcpy(cap, "abgn");
+-			else
+-				strcpy(cap, "bgn");
++			bands = 0;
++			for (i = 1; i <= band[0]; i++) {
++				bands |= dtoh32(band[i]);
++			}
++			strcpy(cap, "");
++			if (bands & WLC_BAND_5G)
++				strcat(cap, "a");
++			if (bands & WLC_BAND_2G)
++				strcat(cap, "bg");
++			if (phytype == WLC_PHY_TYPE_N)
++				strcat(cap, "n");
++			break;
++		default:
+ 			break;
+ 	}
+ done:
diff --git a/package/kernel/broadcom-wl/patches/015-support-probe-of-wds-interfaces.patch b/package/kernel/broadcom-wl/patches/015-support-probe-of-wds-interfaces.patch
new file mode 100644
index 0000000..f44921a
--- /dev/null
+++ b/package/kernel/broadcom-wl/patches/015-support-probe-of-wds-interfaces.patch
@@ -0,0 +1,11 @@
+--- a/shared/wl.c
++++ b/shared/wl.c
+@@ -27,7 +27,7 @@ wl_probe(char *name)
+ {
+ 	int ret, val;
+ 
+-	if ((name[0] != 'w') || (name[1] != 'l'))
++	if ((name[0] != 'w') || ((name[1] != 'l') && ((name[1] != 'd') || (name[2] != 's'))))
+ 		return -1;
+ 
+ 	/* Check interface */
diff --git a/package/kernel/broadcom-wl/patches/020-musl-fixes.patch b/package/kernel/broadcom-wl/patches/020-musl-fixes.patch
new file mode 100644
index 0000000..a985b9c
--- /dev/null
+++ b/package/kernel/broadcom-wl/patches/020-musl-fixes.patch
@@ -0,0 +1,75 @@
+--- a/shared/wl_linux.c
++++ b/shared/wl_linux.c
+@@ -13,6 +13,7 @@
+  */
+ 
+ #include <stdio.h>
++#include <stdint.h>
+ #include <unistd.h>
+ #include <string.h>
+ #include <errno.h>
+@@ -20,10 +21,10 @@
+ #include <net/if.h>
+ #include <linux/types.h>
+ 
+-typedef u_int64_t u64;
+-typedef u_int32_t u32;
+-typedef u_int16_t u16;
+-typedef u_int8_t u8;
++typedef uint64_t u64;
++typedef uint32_t u32;
++typedef uint16_t u16;
++typedef uint8_t u8;
+ #include <linux/sockios.h>
+ #include <linux/ethtool.h>
+ 
+--- a/shared/linux_timer.c
++++ b/shared/linux_timer.c
+@@ -125,7 +125,7 @@ void unblock_timer();
+ 
+ static struct event *event_queue = NULL;
+ static struct event *event_freelist;
+-static uint g_granularity;
++static unsigned int g_granularity;
+ static int g_maxevents = 0;
+ 
+ uclock_t uclock()
+--- a/shared/wl.c
++++ b/shared/wl.c
+@@ -14,6 +14,7 @@
+ #include <typedefs.h>
+ #include <string.h>
+ #include <stdio.h>
++#include <stdlib.h>
+ #include <unistd.h>
+ #include <errno.h>
+ #include <sys/ioctl.h>
+@@ -263,3 +264,28 @@ wl_printlasterror(char *name)
+ 		fprintf(stderr, err_buf);
+ }
+ */
++
++static int in_assert;			/* bss inits to 0. */
++
++void __assert(const char *assertion, const char * filename,
++	      unsigned int linenumber, register const char * function)
++{
++	if (!in_assert) {
++		in_assert = 1;
++
++		fprintf(stderr,
++#ifdef ASSERT_SHOW_PROGNAME
++				"%s: %s: %d: %s: Assertion `%s' failed.\n", __uclibc_progname,
++#else
++				"%s: %d: %s: Assertion `%s' failed.\n",
++#endif
++				filename,
++				linenumber,
++				/* Function name isn't available with some compilers. */
++				((function == NULL) ? "?function?" : function),
++				assertion
++				);
++	}
++	/* shouldn't we? fflush(stderr); */
++	abort();
++}
diff --git a/package/kernel/broadcom-wl/patches/030-remove_devinit_devexit.patch b/package/kernel/broadcom-wl/patches/030-remove_devinit_devexit.patch
new file mode 100644
index 0000000..ead108e
--- /dev/null
+++ b/package/kernel/broadcom-wl/patches/030-remove_devinit_devexit.patch
@@ -0,0 +1,74 @@
+--- a/driver/include/linuxver.h
++++ b/driver/include/linuxver.h
+@@ -139,22 +139,6 @@ typedef	struct pcmcia_device dev_link_t;
+ 
+ #endif /* CONFIG_PCMCIA */
+ 
+-#ifndef __exit
+-#define __exit
+-#endif
+-#ifndef __devexit
+-#define __devexit
+-#endif
+-#ifndef __devinit
+-#define __devinit	__init
+-#endif
+-#ifndef __devinitdata
+-#define __devinitdata
+-#endif
+-#ifndef __devexit_p
+-#define __devexit_p(x)	x
+-#endif
+-
+ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 0))
+ 
+ #define pci_get_drvdata(dev)		(dev)->sysdata
+--- a/driver/wl_linux.c
++++ b/driver/wl_linux.c
+@@ -854,7 +854,7 @@ wl_read_proc(char *buffer, char **start,
+  */
+ #if !defined(BCMJTAG)
+ #ifdef CONFIG_PCI
+-static void __devexit wl_remove(struct pci_dev *pdev);
++static void wl_remove(struct pci_dev *pdev);
+ /** 
+  * determines if a device is a WL device, and if so, attaches it.
+  *
+@@ -862,7 +862,7 @@ static void __devexit wl_remove(struct p
+  * and if so, performs a wl_attach() on it.
+  *
+  */
+-int __devinit
++int
+ wl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
+ {
+ 	int rc;
+@@ -976,7 +976,7 @@ wl_resume(struct pci_dev *pdev)
+ }
+ #endif /* LINUXSTA_PS */
+ 
+-static void __devexit
++static void
+ wl_remove(struct pci_dev *pdev)
+ {
+ 	wl_info_t *wl = (wl_info_t *) pci_get_drvdata(pdev);
+@@ -1007,7 +1007,7 @@ static struct pci_driver wl_pci_driver =
+ 	suspend:	wl_suspend,
+ 	resume:		wl_resume,
+ #endif /* LINUXSTA_PS */
+-	remove:		__devexit_p(wl_remove),
++	remove:		wl_remove,
+ 	id_table:	wl_id_table,
+ 	};
+ #endif	/* CONFIG_PCI */
+--- a/driver/wl_linux.h
++++ b/driver/wl_linux.h
+@@ -33,7 +33,7 @@ extern irqreturn_t wl_isr(int irq, void
+ extern irqreturn_t wl_isr(int irq, void *dev_id, struct pt_regs *ptregs);
+ #endif
+ 
+-extern int __devinit wl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
++extern int wl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
+ extern void wl_free(wl_info_t *wl);
+ extern int  wl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
+ extern struct net_device * wl_netdev_get(wl_info_t *wl);
diff --git a/package/kernel/broadcom-wl/patches/040-remove_last_rx_usage.patch b/package/kernel/broadcom-wl/patches/040-remove_last_rx_usage.patch
new file mode 100644
index 0000000..9f4b0b0
--- /dev/null
+++ b/package/kernel/broadcom-wl/patches/040-remove_last_rx_usage.patch
@@ -0,0 +1,10 @@
+--- broadcom-wl-5.10.56.27.3/driver/wl_linux.c.orig	2018-01-13 18:25:14.944667645 +0100
++++ broadcom-wl-5.10.56.27.3/driver/wl_linux.c	2018-01-13 18:25:25.836667888 +0100
+@@ -2762,7 +2762,6 @@
+ 	bcopy(oskb->data + D11_PHY_HDR_LEN, pdata, oskb->len - D11_PHY_HDR_LEN);
+ 
+ 	skb->dev = wl->monitor;
+-	skb->dev->last_rx = jiffies;
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
+ 	skb_reset_mac_header(skb);
+ #else
diff --git a/package/kernel/broadcom-wl/patches/100-fix_nvram_two_devices.patch b/package/kernel/broadcom-wl/patches/100-fix_nvram_two_devices.patch
new file mode 100644
index 0000000..6cf6fae
--- /dev/null
+++ b/package/kernel/broadcom-wl/patches/100-fix_nvram_two_devices.patch
@@ -0,0 +1,32 @@
+--- a/driver/nvram_stub.c
++++ b/driver/nvram_stub.c
+@@ -22,6 +22,7 @@ typedef struct _vars {
+ #define	VARS_T_OH	sizeof(vars_t)
+ 
+ static vars_t *vars = NULL;
++static int nvram_init_done = 0;
+ extern char *nvram_buf[];
+ 
+ int
+@@ -33,6 +34,10 @@ BCMATTACHFN(nvram_init)(void *si)
+ 	uint nvs, bufsz;
+ 	vars_t *new;
+ 
++	nvram_init_done++;
++	if (nvram_init_done != 1)
++		return 0;
++
+ 	osh = si_osh(sih);
+ 
+ 	nvs = R_REG(osh, &nvh->len) - sizeof(struct nvram_header);
+@@ -79,6 +84,10 @@ BCMATTACHFN(nvram_exit)(void *si)
+ 	vars_t *this, *next;
+ 	si_t *sih;
+ 
++	nvram_init_done--;
++	if (nvram_init_done != 0)
++		return;
++
+ 	sih = (si_t *)si;
+ 	this = vars;
+ 	while (this) {
diff --git a/package/kernel/broadcom-wl/patches/110-add_number_to_dev_name.patch b/package/kernel/broadcom-wl/patches/110-add_number_to_dev_name.patch
new file mode 100644
index 0000000..95f0beb
--- /dev/null
+++ b/package/kernel/broadcom-wl/patches/110-add_number_to_dev_name.patch
@@ -0,0 +1,11 @@
+--- a/driver/wl_linux.c
++++ b/driver/wl_linux.c
+@@ -1425,7 +1425,7 @@ wl_alloc_if(wl_info_t *wl, int iftype, u
+ 	dev = alloc_etherdev(sizeof(wl_if_t));
+ 	wlif = netdev_priv(dev);
+ 	bzero(wlif, sizeof(wl_if_t));
+-	strncpy(dev->name, name, IFNAMSIZ);
++	snprintf(dev->name, IFNAMSIZ, name, subunit);
+ 
+ 	wlif->type = iftype;
+ 	wlif->dev = dev;
diff --git a/package/kernel/broadcom-wl/patches/120-fixup-mac-addresses.patch b/package/kernel/broadcom-wl/patches/120-fixup-mac-addresses.patch
new file mode 100644
index 0000000..422f7f7
--- /dev/null
+++ b/package/kernel/broadcom-wl/patches/120-fixup-mac-addresses.patch
@@ -0,0 +1,93 @@
+--- a/driver/nvram_stub.c
++++ b/driver/nvram_stub.c
+@@ -5,6 +5,8 @@
+ #include <siutils.h>
+ #include <bcmendian.h>
+ #include <bcmnvram.h>
++#include <proto/ethernet.h>
++#include <linux/errno.h>
+ 
+ #ifdef BCMDBG_ERR
+ #define NVR_MSG(x) printf x
+@@ -24,6 +26,7 @@ typedef struct _vars {
+ static vars_t *vars = NULL;
+ static int nvram_init_done = 0;
+ extern char *nvram_buf[];
++static void fixup_mac_addr(vars_t *new);
+ 
+ int
+ BCMATTACHFN(nvram_init)(void *si)
+@@ -55,6 +58,7 @@ BCMATTACHFN(nvram_init)(void *si)
+ 	vars = new;
+ 
+ 	bcopy((char *)(&nvh[1]), new->vars, nvs);
++	fixup_mac_addr(new);
+ 	return 0;
+ }
+ 
+@@ -164,3 +168,65 @@ nvram_getall(char *buf, int count)
+ 	*buf = '\0';
+ 	return 0;
+ }
++
++static bool nvram_is_valid_mac(struct ether_addr *mac)
++{
++	return mac && !(mac->octet[0] == 0x00 && mac->octet[1] == 0x90 && mac->octet[2] == 0x4c);
++}
++
++static int nvram_increase_mac_addr(struct ether_addr *mac, u8 num)
++{
++	u8 *oui = mac->octet + ETHER_ADDR_LEN/2 - 1;
++	u8 *p = mac->octet + ETHER_ADDR_LEN - 1;
++
++	do {
++		(*p) += num;
++		if (*p > num)
++			break;
++		p--;
++		num = 1;
++	} while (p != oui);
++
++	if (p == oui) {
++		pr_err("unable to fetch mac address\n");
++		return -ENOENT;
++	}
++	return 0;
++}
++
++static void nvram_change_mac_addr(vars_t *new, struct ether_addr *valid, const char *name)
++{
++	char *macaddr_c;
++	struct ether_addr macaddr;
++
++	macaddr_c = findvar(new->vars, new->vars + new->size, name);
++	if (!macaddr_c)
++		return;
++
++	bcm_ether_atoe(macaddr_c, &macaddr);
++	if (nvram_is_valid_mac(&macaddr))
++		return;
++	nvram_increase_mac_addr(valid, 1);
++	bcm_ether_ntoa(valid, macaddr_c);
++}
++
++static void fixup_mac_addr(vars_t *new)
++{
++	char *macaddr_base_c;
++	struct ether_addr macaddr_base;
++
++	macaddr_base_c = findvar(new->vars, new->vars + new->size, "et0macaddr");
++	if (!macaddr_base_c)
++		return;
++
++	bcm_ether_atoe(macaddr_base_c, &macaddr_base);
++	if (!nvram_is_valid_mac(&macaddr_base))
++		return;
++
++	/* jump over the first free address so it can be used for wan */
++	nvram_increase_mac_addr(&macaddr_base, 1);
++	nvram_change_mac_addr(new, &macaddr_base, "sb/1/macaddr");
++	nvram_change_mac_addr(new, &macaddr_base, "pci/1/1/macaddr");
++	nvram_change_mac_addr(new, &macaddr_base, "pci/1/2/macaddr");
++	nvram_change_mac_addr(new, &macaddr_base, "pci/2/1/macaddr");
++}
diff --git a/package/kernel/broadcom-wl/patches/200-add_bcm_a8xx_support.patch b/package/kernel/broadcom-wl/patches/200-add_bcm_a8xx_support.patch
new file mode 100644
index 0000000..c1d1344
--- /dev/null
+++ b/package/kernel/broadcom-wl/patches/200-add_bcm_a8xx_support.patch
@@ -0,0 +1,12 @@
+--- a/driver/wl_linux.c
++++ b/driver/wl_linux.c
+@@ -876,7 +876,8 @@ wl_pci_probe(struct pci_dev *pdev, const
+ 
+ 	if ((pdev->vendor != PCI_VENDOR_ID_BROADCOM) ||
+ 	    (((pdev->device & 0xff00) != 0x4300) &&
+-	     ((pdev->device & 0xff00) != 0x4700)))
++	     ((pdev->device & 0xff00) != 0x4700) &&
++	     ((pdev->device & 0xff00) != 0xa800)))
+ 		return (-ENODEV);
+ 
+ 	rc = pci_enable_device(pdev);
diff --git a/package/kernel/broadcom-wl/patches/910-fallback-sprom.patch b/package/kernel/broadcom-wl/patches/910-fallback-sprom.patch
new file mode 100644
index 0000000..a85e40b
--- /dev/null
+++ b/package/kernel/broadcom-wl/patches/910-fallback-sprom.patch
@@ -0,0 +1,78 @@
+--- a/driver/bcmsrom.c
++++ b/driver/bcmsrom.c
+@@ -39,6 +39,11 @@
+ #include <sbsdpcmdev.h>
+ #endif 
+ 
++#if defined(CONFIG_SSB_PCIHOST) && defined(CONFIG_BOARD_BCM963XX)
++#include <linux/ssb/ssb.h>
++extern int bcm63xx_get_fallback_sprom(uint pci_bus, uint pci_slot, struct ssb_sprom *out);
++#endif
++
+ #ifdef WLTEST
+ #include <sbsprom.h>
+ #endif /* WLTEST */
+@@ -2120,6 +2125,63 @@ BCMATTACHFN(initvars_srom_pci)(si_t *sih
+ 			goto varscont;
+ 		}
+ 
++#if defined(CONFIG_SSB_PCIHOST) && defined(CONFIG_BOARD_BCM963XX)
++		base = vp = MALLOC(osh, MAXSZ_NVRAM_VARS);
++
++		if( base != NULL )
++		{
++			char eabuf[18];
++			struct ssb_sprom bcm63xx_sprom;
++			uint pci_bus = osl_pci_bus(osh), pci_slot = osl_pci_slot(osh);
++
++			bcm63xx_get_fallback_sprom(pci_bus, pci_slot, &bcm63xx_sprom);
++			printk("BCM%X(%02x:%02x) using sprom version %i\n", sih->chip, pci_bus, pci_slot, bcm63xx_sprom.revision);
++
++			varbuf_init(&b, base, MAXSZ_NVRAM_VARS);
++
++			varbuf_append(&b, vstr_sromrev, bcm63xx_sprom.revision);
++			varbuf_append(&b, vstr_boardrev, bcm63xx_sprom.board_rev);
++
++			/* ToDo: map bcm63xx_sprom.country_code */
++			varbuf_append(&b, vstr_noccode);
++
++			varbuf_append(&b, vstr_aa2g, bcm63xx_sprom.ant_available_bg);
++
++			varbuf_append(&b, vstr_pa0b[0], bcm63xx_sprom.pa0b0);
++			varbuf_append(&b, vstr_pa1b[0], bcm63xx_sprom.pa1b0);
++			varbuf_append(&b, vstr_pa0b[1], bcm63xx_sprom.pa0b1);
++			varbuf_append(&b, vstr_pa1b[1], bcm63xx_sprom.pa1b1);
++			varbuf_append(&b, vstr_pa0b[2], bcm63xx_sprom.pa0b2);
++			varbuf_append(&b, vstr_pa1b[2], bcm63xx_sprom.pa1b2);
++
++			varbuf_append(&b, vstr_pa0maxpwr, bcm63xx_sprom.maxpwr_bg);
++			varbuf_append(&b, vstr_pa0itssit, bcm63xx_sprom.itssi_bg);
++
++			varbuf_append(&b, vstr_boardflags, (bcm63xx_sprom.boardflags_hi << 16) | bcm63xx_sprom.boardflags_lo);
++			varbuf_append(&b, vstr_boardflags2, (bcm63xx_sprom.boardflags2_hi << 16) | bcm63xx_sprom.boardflags2_lo);
++
++			snprintf(eabuf, sizeof(eabuf), "%02x:%02x:%02x:%02x:%02x:%02x",
++				bcm63xx_sprom.il0mac[0], bcm63xx_sprom.il0mac[1], bcm63xx_sprom.il0mac[2],
++				bcm63xx_sprom.il0mac[3], bcm63xx_sprom.il0mac[4], bcm63xx_sprom.il0mac[5]
++			);
++
++			varbuf_append(&b, vstr_macaddr, eabuf);
++
++			/* final nullbyte terminator */
++			ASSERT(b.size >= 1);
++			vp = b.buf;
++			*vp++ = '\0';
++
++			ASSERT((vp - base) <= MAXSZ_NVRAM_VARS);
++			goto varsdone;
++		}
++		else
++		{
++			err = -2;
++			goto errout;
++		}
++#endif
++
+ 		BS_ERROR(("SROM CRC Error\n"));
+ 
+ #if defined(WLTEST)
diff --git a/package/kernel/broadcom-wl/patches/912-pci-bus-nvram-hack.patch b/package/kernel/broadcom-wl/patches/912-pci-bus-nvram-hack.patch
new file mode 100644
index 0000000..65e8bd3
--- /dev/null
+++ b/package/kernel/broadcom-wl/patches/912-pci-bus-nvram-hack.patch
@@ -0,0 +1,11 @@
+--- a/driver/siutils.c
++++ b/driver/siutils.c
+@@ -1859,7 +1859,7 @@ BCMINITFN(si_devpath)(si_t *sih, char *p
+ 	case PCI_BUS:
+ 		ASSERT((SI_INFO(sih))->osh != NULL);
+ 		slen = snprintf(path, (size_t)size, "pci/%u/%u/",
+-		                OSL_PCI_BUS((SI_INFO(sih))->osh),
++		                OSL_PCI_BUS((SI_INFO(sih))->osh) + 1,
+ 		                OSL_PCI_SLOT((SI_INFO(sih))->osh));
+ 		break;
+ 	case PCMCIA_BUS:
diff --git a/package/kernel/broadcom-wl/patches/913-avoid-dbe-on-ifs_ctl-readw-hack.patch b/package/kernel/broadcom-wl/patches/913-avoid-dbe-on-ifs_ctl-readw-hack.patch
new file mode 100644
index 0000000..412bce9
--- /dev/null
+++ b/package/kernel/broadcom-wl/patches/913-avoid-dbe-on-ifs_ctl-readw-hack.patch
@@ -0,0 +1,12 @@
+--- a/driver/linux_osl.c
++++ b/driver/linux_osl.c
+@@ -723,6 +723,9 @@ osl_readl(volatile uint32 *r)
+ uint16
+ osl_readw(volatile uint16 *r)
+ {
++	uint32 addr = (uintptr)r & 0xffff3fff;
++	if (addr == 0xa8000688)	/* ifs_ctl */
++		readl(r);
+ 	return (readw(r));
+ }
+ 
diff --git a/package/kernel/broadcom-wl/patches/914-eliminate-date-time-error.patch b/package/kernel/broadcom-wl/patches/914-eliminate-date-time-error.patch
new file mode 100644
index 0000000..394a06d
--- /dev/null
+++ b/package/kernel/broadcom-wl/patches/914-eliminate-date-time-error.patch
@@ -0,0 +1,21 @@
+--- a/driver/wl_linux.c
++++ b/driver/wl_linux.c
+@@ -762,7 +762,7 @@ wl_attach(uint16 vendor, uint16 device,
+ 		dev->name, device);
+ 
+ #ifdef BCMDBG
+-	printf(" (Compiled in " SRCBASE " at " __TIME__ " on " __DATE__ ")");
++	printf(" (Compiled in " SRCBASE ")");
+ #endif /* BCMDBG */
+ 	printf("\n");
+ 
+@@ -2298,8 +2298,7 @@ wl_sendup(wl_info_t *wl, wl_if_t *wlif,
+ void
+ wl_dump_ver(wl_info_t *wl, struct bcmstrbuf *b)
+ {
+-	bcm_bprintf(b, "wl%d: %s %s version %s\n", wl->pub->unit,
+-		__DATE__, __TIME__, EPI_VERSION_STR);
++	bcm_bprintf(b, "wl%d: version %s\n", wl->pub->unit, EPI_VERSION_STR);
+ }
+ 
+ #ifdef BCMDBG
diff --git a/package/kernel/broadcom-wl/patches/915-fix-wl_timer-for-4_15.patch b/package/kernel/broadcom-wl/patches/915-fix-wl_timer-for-4_15.patch
new file mode 100644
index 0000000..daf3160
--- /dev/null
+++ b/package/kernel/broadcom-wl/patches/915-fix-wl_timer-for-4_15.patch
@@ -0,0 +1,55 @@
+--- a/driver/wl_linux.c
++++ b/driver/wl_linux.c
+@@ -235,7 +235,11 @@
+ 
+ };
+ 
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
++static void wl_timer(struct timer_list *tl);
++#else
+ static void wl_timer(ulong data);
++#endif
+ static void _wl_timer(wl_timer_t *t);
+ 
+ #ifdef WLC_HIGH_ONLY
+@@ -2512,6 +2517,18 @@
+ }
+ #endif /* WLC_HIGH_ONLY */
+ 
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
++static void
++wl_timer(struct timer_list *tl)
++{
++	wl_timer_t *t = from_timer(t, tl, timer);
++#ifndef WLC_HIGH_ONLY
++	_wl_timer(t);
++#else
++	wl_schedule_task(t->wl, wl_timer_task, t);
++#endif /* WLC_HIGH_ONLY */
++}
++#else
+ static void
+ wl_timer(ulong data)
+ {
+@@ -2522,6 +2539,7 @@
+ 	wl_schedule_task(t->wl, wl_timer_task, t);
+ #endif /* WLC_HIGH_ONLY */
+ }
++#endif /* linux >= 4.15.0 */
+ 
+ static void
+ _wl_timer(wl_timer_t *t)
+@@ -2573,9 +2591,13 @@
+ 
+ 	bzero(t, sizeof(wl_timer_t));
+ 
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
++	timer_setup(&t->timer, wl_timer, 0);
++#else
+ 	init_timer(&t->timer);
+ 	t->timer.data = (ulong) t;
+ 	t->timer.function = wl_timer;
++#endif
+ 	t->wl = wl;
+ 	t->fn = fn;
+ 	t->arg = arg;
diff --git a/package/kernel/broadcom-wl/patches/916-fix-compilation-for-5_4.patch b/package/kernel/broadcom-wl/patches/916-fix-compilation-for-5_4.patch
new file mode 100644
index 0000000..bc7b63d
--- /dev/null
+++ b/package/kernel/broadcom-wl/patches/916-fix-compilation-for-5_4.patch
@@ -0,0 +1,18 @@
+--- a/driver/wl_iw.c
++++ b/driver/wl_iw.c
+@@ -112,10 +112,14 @@
+ 	ifr.ifr_data = (caddr_t) &ioc;
+ 
+ 	/* Must be up for virtually all useful ioctls */
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
++	dev_open(dev, NULL);
++#else
+ 	dev_open(dev);
++#endif
+ 
+ 	fs = get_fs();
+-	set_fs(get_ds());
++	set_fs(KERNEL_DS);
+ 	ret = dev->netdev_ops->ndo_do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
+ 	set_fs(fs);
+