aboutsummaryrefslogtreecommitdiffstats
path: root/package/kernel/broadcom-wl/patches/007-use-glue-driver.patch
blob: 2639abcf6acb14e3a2069149ad08b99cc7a31132 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
--- 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,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 <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