From: Luca Casati <luk00casati@gmail.com>
To: linux-wireless@vger.kernel.org
Cc: johannes@sipsolutions.net, arend.vanspriel@broadcom.com,
b43-dev@lists.infradead.org, alessio.ferri@mythread.it,
Luca Casati <luk00casati@gmail.com>
Subject: [PATCH wireless-next v2 4/5] b43: N-PHY: use wl's delays in the 2057 RC calibration
Date: Fri, 6 Nov 2026 22:15:15 +0100 [thread overview]
Message-ID: <20261106211516.273791-5-luk00casati@gmail.com> (raw)
In-Reply-To: <20261106211516.273791-1-luk00casati@gmail.com>
b43_radio_2057_rccal() follows wl's sequence, but sleeps with
usleep_range(x, 2 * x) where wl waits x us, and polls DONE every
500 us where wl polls about every 30 us. Every step takes about twice
as long as in wl.
That breaks the first run. Its poll comes straight after the start,
while RCCAL_DONE_OSCCAP still has the done bit set from before, so it
returns at once and the run is stopped. wl does the same, but writes
the stop about 40 us after the start; b43 writes it about 85 us in,
while the cal is running. RCCAL_SCAP_VAL then reads 0 or 0x1f instead
of 8 on a BCM43228 (radio 2057 rev 9), which detunes the TX low-pass
filter set up in the rev7+ workarounds. With only that delay fixed it
reads 7; with all of wl's delays it reads 8, as with wl.
Use wl's delays, with udelay(): the whole cal busy-waits about 2 ms,
as brcmsmac's version does.
mmiotraces: https://github.com/Luca00casati/b43patch/blob/755c2d8/traces/excerpts/patch4-rccal.txt
Found and fixed with the help of an AI coding assistant (Claude Opus 5.5),
by comparing mmiotraces of b43 and wl on the same card.
Signed-off-by: Luca Casati <luk00casati@gmail.com>
---
drivers/net/wireless/broadcom/b43/phy_n.c | 26 +++++++++++------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/net/wireless/broadcom/b43/phy_n.c b/drivers/net/wireless/broadcom/b43/phy_n.c
index 36c07d891..ab8fab018 100644
--- a/drivers/net/wireless/broadcom/b43/phy_n.c
+++ b/drivers/net/wireless/broadcom/b43/phy_n.c
@@ -940,12 +940,12 @@ static u16 b43_radio_2057_rccal(struct b43_wldev *dev)
/* Start, wait, stop */
b43_radio_write(dev, R2057_RCCAL_START_R1_Q1_P1, 0x55);
- if (!b43_radio_wait_value(dev, R2057_RCCAL_DONE_OSCCAP, 2, 2, 500,
+ if (!b43_radio_wait_value(dev, R2057_RCCAL_DONE_OSCCAP, 2, 2, 30,
5000000))
b43dbg(dev->wl, "Radio 0x2057 rccal timeout\n");
- usleep_range(35, 70);
+ udelay(35);
b43_radio_write(dev, R2057_RCCAL_START_R1_Q1_P1, 0x15);
- usleep_range(70, 140);
+ udelay(70);
/* Setup cal */
if (special) {
@@ -958,15 +958,15 @@ static u16 b43_radio_2057_rccal(struct b43_wldev *dev)
b43_radio_write(dev, R2057_RCCAL_X1, 0x6E);
/* Start, wait, stop */
- usleep_range(35, 70);
+ udelay(35);
b43_radio_write(dev, R2057_RCCAL_START_R1_Q1_P1, 0x55);
- usleep_range(70, 140);
- if (!b43_radio_wait_value(dev, R2057_RCCAL_DONE_OSCCAP, 2, 2, 500,
+ udelay(70);
+ if (!b43_radio_wait_value(dev, R2057_RCCAL_DONE_OSCCAP, 2, 2, 30,
5000000))
b43dbg(dev->wl, "Radio 0x2057 rccal timeout\n");
- usleep_range(35, 70);
+ udelay(35);
b43_radio_write(dev, R2057_RCCAL_START_R1_Q1_P1, 0x15);
- usleep_range(70, 140);
+ udelay(70);
/* Setup cal */
if (special) {
@@ -980,18 +980,18 @@ static u16 b43_radio_2057_rccal(struct b43_wldev *dev)
}
/* Start, wait, stop */
- usleep_range(35, 70);
+ udelay(35);
b43_radio_write(dev, R2057_RCCAL_START_R1_Q1_P1, 0x55);
- usleep_range(70, 140);
- if (!b43_radio_wait_value(dev, R2057_RCCAL_DONE_OSCCAP, 2, 2, 500,
+ udelay(70);
+ if (!b43_radio_wait_value(dev, R2057_RCCAL_DONE_OSCCAP, 2, 2, 30,
5000000)) {
b43err(dev->wl, "Radio 0x2057 rcal timeout\n");
return 0;
}
tmp = b43_radio_read(dev, R2057_RCCAL_DONE_OSCCAP);
- usleep_range(35, 70);
+ udelay(35);
b43_radio_write(dev, R2057_RCCAL_START_R1_Q1_P1, 0x15);
- usleep_range(70, 140);
+ udelay(70);
if (special)
b43_radio_mask(dev, R2057_RCCAL_MASTER, ~0x1);
--
2.43.0
next prev parent reply other threads:[~2026-11-06 21:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 21:15 [PATCH wireless-next v2 0/5] b43: N-PHY: fix calibrations on rev7+ (BCM43228) Luca Casati
2026-11-06 21:15 ` [PATCH wireless-next v2 1/5] b43: N-PHY: fix the TX tone sample table Luca Casati
2026-11-06 22:12 ` Alessio Ferri
2026-11-06 21:15 ` [PATCH wireless-next v2 2/5] b43: N-PHY: fix TX IQ/LO calibration Luca Casati
2026-11-06 21:15 ` [PATCH wireless-next v2 3/5] b43: N-PHY: fix rev3+ RSSI calibration Luca Casati
2026-11-07 12:00 ` Alessio Ferri
2026-11-06 21:15 ` Luca Casati [this message]
2026-11-06 21:15 ` [PATCH wireless-next v2 5/5] b43: N-PHY: add the missing override to the rev7 TX_PU command Luca Casati
2026-11-07 11:48 ` [PATCH wireless-next v2 0/5] b43: N-PHY: fix calibrations on rev7+ (BCM43228) Alessio Ferri
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261106211516.273791-5-luk00casati@gmail.com \
--to=luk00casati@gmail.com \
--cc=alessio.ferri@mythread.it \
--cc=arend.vanspriel@broadcom.com \
--cc=b43-dev@lists.infradead.org \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox