-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path0053-wifi-brcmfmac-Add-optional-lpo-clock-enable-support.patch
247 lines (225 loc) · 8.51 KB
/
0053-wifi-brcmfmac-Add-optional-lpo-clock-enable-support.patch
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
diff -up linux-6.12/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c.112~ linux-6.12/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
--- linux-6.12/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c.112~ 2024-11-17 23:15:08.000000000 +0100
+++ linux-6.12/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c 2024-12-05 22:28:09.198282694 +0100
@@ -947,8 +947,8 @@ int brcmf_sdiod_probe(struct brcmf_sdio_
/* try to attach to the target device */
sdiodev->bus = brcmf_sdio_probe(sdiodev);
- if (!sdiodev->bus) {
- ret = -ENODEV;
+ if (IS_ERR(sdiodev->bus)) {
+ ret = PTR_ERR(sdiodev->bus);
goto out;
}
brcmf_sdiod_host_fixup(sdiodev->func2->card->host);
diff -up linux-6.12/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c.112~ linux-6.12/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
--- linux-6.12/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c.112~ 2024-11-17 23:15:08.000000000 +0100
+++ linux-6.12/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c 2024-12-05 22:28:09.198378855 +0100
@@ -561,7 +561,8 @@ struct brcmf_mp_device *brcmf_get_module
if (!found) {
/* No platform data for this device, try OF and DMI data */
brcmf_dmi_probe(settings, chip, chiprev);
- brcmf_of_probe(dev, bus_type, settings);
+ if (brcmf_of_probe(dev, bus_type, settings) == -EPROBE_DEFER)
+ return ERR_PTR(-EPROBE_DEFER);
brcmf_acpi_probe(dev, bus_type, settings);
}
return settings;
diff -up linux-6.12/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c.112~ linux-6.12/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
--- linux-6.12/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c.112~ 2024-12-05 22:28:08.488886481 +0100
+++ linux-6.12/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c 2024-12-05 22:33:53.581870477 +0100
@@ -6,6 +6,7 @@
#include <linux/of.h>
#include <linux/of_irq.h>
#include <linux/of_net.h>
+#include <linux/clk.h>
#include <defs.h>
#include "debug.h"
@@ -65,12 +66,13 @@ static int brcmf_of_get_country_codes(st
return 0;
}
-void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type,
- struct brcmf_mp_device *settings)
+int brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type,
+ struct brcmf_mp_device *settings)
{
struct brcmfmac_sdio_pd *sdio = &settings->bus.sdio;
struct device_node *root, *np = dev->of_node;
struct of_phandle_args oirq;
+ struct clk *clk;
const char *prop;
int irq;
int err;
@@ -106,15 +108,22 @@ void brcmf_of_probe(struct device *dev,
board_type = devm_kstrdup(dev, tmp, GFP_KERNEL);
if (!board_type) {
of_node_put(root);
- return;
+ return 0;
}
strreplace(board_type, '/', '-');
settings->board_type = board_type;
}
of_node_put(root);
+ clk = devm_clk_get_optional_enabled(dev, "lpo");
+ if (IS_ERR(clk))
+ return PTR_ERR(clk);
+
+ brcmf_dbg(INFO, "%s LPO clock\n", clk ? "enable" : "no");
+ clk_set_rate(clk, 32768);
+
if (!np || !of_device_is_compatible(np, "brcm,bcm4329-fmac"))
- return;
+ return 0;
err = brcmf_of_get_country_codes(dev, settings);
if (err)
@@ -123,23 +132,25 @@ void brcmf_of_probe(struct device *dev,
of_get_mac_address(np, settings->mac);
if (bus_type != BRCMF_BUSTYPE_SDIO)
- return;
+ return 0;
if (of_property_read_u32(np, "brcm,drive-strength", &val) == 0)
sdio->drive_strength = val;
/* make sure there are interrupts defined in the node */
if (of_irq_parse_one(np, 0, &oirq))
- return;
+ return 0;
irq = irq_create_of_mapping(&oirq);
if (!irq) {
brcmf_err("interrupt could not be mapped\n");
- return;
+ return 0;
}
irqf = irqd_get_trigger_type(irq_get_irq_data(irq));
sdio->oob_irq_supported = true;
sdio->oob_irq_nr = irq;
sdio->oob_irq_flags = irqf;
+
+ return 0;
}
diff -up linux-6.12/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.h.112~ linux-6.12/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.h
--- linux-6.12/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.h.112~ 2024-11-17 23:15:08.000000000 +0100
+++ linux-6.12/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.h 2024-12-05 22:28:09.198510082 +0100
@@ -3,11 +3,12 @@
* Copyright (c) 2014 Broadcom Corporation
*/
#ifdef CONFIG_OF
-void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type,
- struct brcmf_mp_device *settings);
+int brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type,
+ struct brcmf_mp_device *settings);
#else
-static void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type,
- struct brcmf_mp_device *settings)
+static int brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type,
+ struct brcmf_mp_device *settings)
{
+ return 0;
}
#endif /* CONFIG_OF */
diff -up linux-6.12/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c.112~ linux-6.12/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
--- linux-6.12/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c.112~ 2024-11-17 23:15:08.000000000 +0100
+++ linux-6.12/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c 2024-12-05 22:28:09.198623496 +0100
@@ -2452,6 +2452,9 @@ brcmf_pcie_probe(struct pci_dev *pdev, c
ret = -ENOMEM;
goto fail;
}
+ ret = PTR_ERR_OR_ZERO(devinfo->settings);
+ if (ret < 0)
+ goto fail;
bus = kzalloc(sizeof(*bus), GFP_KERNEL);
if (!bus) {
diff -up linux-6.12/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c.112~ linux-6.12/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
--- linux-6.12/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c.112~ 2024-11-17 23:15:08.000000000 +0100
+++ linux-6.12/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c 2024-12-05 22:28:09.198867055 +0100
@@ -3943,7 +3943,7 @@ static const struct brcmf_buscore_ops br
.write32 = brcmf_sdio_buscore_write32,
};
-static bool
+static int
brcmf_sdio_probe_attach(struct brcmf_sdio *bus)
{
struct brcmf_sdio_dev *sdiodev;
@@ -3953,6 +3953,7 @@ brcmf_sdio_probe_attach(struct brcmf_sdi
u32 reg_val;
u32 drivestrength;
u32 enum_base;
+ int ret = -EBADE;
sdiodev = bus->sdiodev;
sdio_claim_host(sdiodev->func1);
@@ -4001,8 +4002,9 @@ brcmf_sdio_probe_attach(struct brcmf_sdi
BRCMF_BUSTYPE_SDIO,
bus->ci->chip,
bus->ci->chiprev);
- if (!sdiodev->settings) {
+ if (IS_ERR_OR_NULL(sdiodev->settings)) {
brcmf_err("Failed to get device parameters\n");
+ ret = PTR_ERR_OR_ZERO(sdiodev->settings);
goto fail;
}
/* platform specific configuration:
@@ -4071,7 +4073,7 @@ brcmf_sdio_probe_attach(struct brcmf_sdi
/* allocate header buffer */
bus->hdrbuf = kzalloc(MAX_HDR_READ + bus->head_align, GFP_KERNEL);
if (!bus->hdrbuf)
- return false;
+ return -ENOMEM;
/* Locate an appropriately-aligned portion of hdrbuf */
bus->rxhdr = (u8 *) roundup((unsigned long)&bus->hdrbuf[0],
bus->head_align);
@@ -4082,11 +4084,11 @@ brcmf_sdio_probe_attach(struct brcmf_sdi
if (bus->poll)
bus->pollrate = 1;
- return true;
+ return 0;
fail:
sdio_release_host(sdiodev->func1);
- return false;
+ return ret;
}
static int
@@ -4451,8 +4453,10 @@ struct brcmf_sdio *brcmf_sdio_probe(stru
/* Allocate private bus interface state */
bus = kzalloc(sizeof(*bus), GFP_ATOMIC);
- if (!bus)
+ if (!bus) {
+ ret = -ENOMEM;
goto fail;
+ }
bus->sdiodev = sdiodev;
sdiodev->bus = bus;
@@ -4467,6 +4471,7 @@ struct brcmf_sdio *brcmf_sdio_probe(stru
dev_name(&sdiodev->func1->dev));
if (!wq) {
brcmf_err("insufficient memory to create txworkqueue\n");
+ ret = -ENOMEM;
goto fail;
}
brcmf_sdiod_freezer_count(sdiodev);
@@ -4474,7 +4479,8 @@ struct brcmf_sdio *brcmf_sdio_probe(stru
bus->brcmf_wq = wq;
/* attempt to attach to the dongle */
- if (!(brcmf_sdio_probe_attach(bus))) {
+ ret = brcmf_sdio_probe_attach(bus);
+ if (ret < 0) {
brcmf_err("brcmf_sdio_probe_attach failed\n");
goto fail;
}
@@ -4546,7 +4552,7 @@ struct brcmf_sdio *brcmf_sdio_probe(stru
fail:
brcmf_sdio_remove(bus);
- return NULL;
+ return ERR_PTR(ret);
}
/* Detach and free everything */
diff -up linux-6.12/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c.112~ linux-6.12/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
--- linux-6.12/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c.112~ 2024-11-17 23:15:08.000000000 +0100
+++ linux-6.12/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c 2024-12-05 22:28:09.199077692 +0100
@@ -1272,6 +1272,9 @@ static int brcmf_usb_probe_cb(struct brc
ret = -ENOMEM;
goto fail;
}
+ ret = PTR_ERR_OR_ZERO(devinfo->settings);
+ if (ret < 0)
+ goto fail;
if (!brcmf_usb_dlneeded(devinfo)) {
ret = brcmf_alloc(devinfo->dev, devinfo->settings);