Linux MultiMedia Card development
 help / color / mirror / Atom feed
* [PATCH wireless-next v2 00/12] wifi: cw1200: add XRadio XR819 support
@ 2026-12-01  8:39 Arthur Heymans
  2026-12-01  8:39 ` [PATCH wireless-next v2 01/12] wifi: cw1200: avoid removing the debugfs directory twice Arthur Heymans
                   ` (12 more replies)
  0 siblings, 13 replies; 17+ messages in thread
From: Arthur Heymans @ 2026-12-01  8:39 UTC (permalink / raw)
  To: linux-wireless, Johannes Berg
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, devicetree,
	Ulf Hansson, linux-mmc, Solomon Peachy, linux-kernel,
	Arthur Heymans

The XRadio XR819 is a 2.4 GHz 802.11b/g/n SDIO chip found on Allwinner
boards such as the Orange Pi Zero. XRadio likely bought the IP from
ST-Ericsson: the XR819's host interface is based on the WSM interface
of the CW1x60, and it reports the CW1x60 hardware revision. This series
therefore adds it to cw1200 rather than adding a new driver.

Patches 1-5 fix existing cw1200 bugs. They do not depend on the XR819
changes and carry Fixes: tags:

  1  a double debugfs removal on unbind
  2  SDD elements read without length checks or unaligned access
  3  SDIO transfers from stack buffers
  4  GPIO interrupt setup not unwound on error
  5  mac80211 unregistered after the interrupt is freed, so every
     unbind of an associated device ends with "stuck in firmware,
     killing BH"

Patches 6-7 add the vendor prefix and a binding for the SDIO function,
with an optional GPIO interrupt and MAC address. Patches 8-11 add the
XR819: a first-stage loader written to SRAM before the usual firmware
download, two preparatory SDIO probe cleanups (per-device platform data
storage and checking sdio_enable_func()/IRQ subscribe errors), and the
XR819 SDIO support (ID 0020:2281 and card reset on probe so that the
device can be bound again after an unbind). Patch 12 takes over the
orphaned driver as Odd Fixes, as I presume someone needs to do it?

Changes since v1:
- Remove "Prepared with ..." lines from individual commit messages
  (keep AI tool disclosure here in the cover letter).
- dt-bindings: vendor-prefixes: use "Guangzhou Xradio Technology Co.,
  Ltd." (Conor Dooley).
- dt-bindings: xradio,xr819: reference wireless-controller.yaml# with
  unevaluatedProperties: false, and note in the description that power
  supplies, active-low reset, and any optional host-provided 32.768 kHz
  clock are described on the parent MMC controller via vmmc-supply /
  vqmmc-supply and mmc-pwrseq-simple.
- Split per-device platform data storage and sdio_enable_func() / IRQ
  subscription error checks out of the XR819 SDIO patch into two
  preceding patches (Ulf Hansson).

v1: https://lore.kernel.org/r/20261119175002.458988-1-arthur@aheymans.xyz

Firmware
--------
The vendor firmware is not redistributable, and it speaks a dialect of
WSM that cw1200 does not: it reads bits 6-7 of the message ID as an
interface number where cw1200 puts a link ID, and its TX confirmations
carry per-rate retry counts in place of the media and queue delays.
The firmware these patches are tested with therefore comes from a
reverse-engineering project and speaks the WSM that cw1200 expects.
The firmware is written in rust and runs on a ARM966E-S core. It
is licensed MIT OR Apache-2.0 and builds the three files the driver
requests, xr819/boot_xr819.bin, xr819/fw_xr819.bin and
xr819/sdd_xr819.bin (this one is pure calibration data).
Code repo:

  https://github.com/ArthurHeymans/xradio-open-firmware

Documentation on the hardware obtained through reverse engineering and
black box testing.

  https://arthurheymans.github.io/xradio-open-firmware/

I plan to submit them to linux-firmware once the driver side is
settled.

Testing
-------
Tested on an Orange Pi Zero against an Intel peer with WPA2: station,
access point, a 10-minute traffic soak, and repeated unbind and bind
with both the SDIO and a GPIO interrupt. SPI is build-tested only, and
without CW1200 hardware, patches 1-5 and 9-10 are tested on the XR819
only. Details:
https://arthurheymans.github.io/xradio-open-firmware/orange-pi-zero-smoke.html

Tools
-----
The patches were written with AI coding assistants from my instructions:
OpenAI Codex for patches 1-4 and 6-11, Anthropic Claude for patches 5
and 12, and Gemini for the v2 split and binding adjustments. The
assistants also ran the board tests above on my hardware. I have
reviewed every patch and take responsibility for them.

Arthur Heymans (12):
  wifi: cw1200: avoid removing the debugfs directory twice
  wifi: cw1200: check SDD element lengths before reading them
  wifi: cw1200: bounce SDIO transfers that use stack buffers
  wifi: cw1200: unwind GPIO interrupt setup on error
  wifi: cw1200: unregister from mac80211 before freeing the interrupt
  dt-bindings: vendor-prefixes: add XRadio
  dt-bindings: net: wireless: add XRadio XR819
  wifi: cw1200: load the XR819 bootloader into SRAM
  wifi: cw1200: copy platform data into per-device storage
  wifi: cw1200: check sdio_enable_func() and IRQ subscribe errors
  wifi: cw1200: add XR819 SDIO support
  MAINTAINERS: add myself for the cw1200 driver

 .../bindings/net/wireless/xradio,xr819.yaml   |  55 +++++
 .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
 MAINTAINERS                                   |   4 +-
 drivers/net/wireless/st/cw1200/Kconfig        |   6 +-
 drivers/net/wireless/st/cw1200/cw1200.h       |   9 +
 drivers/net/wireless/st/cw1200/cw1200_sdio.c  | 200 ++++++++++++++----
 drivers/net/wireless/st/cw1200/cw1200_spi.c   |   2 +
 drivers/net/wireless/st/cw1200/debug.c        |  19 +-
 drivers/net/wireless/st/cw1200/debug.h        |   1 -
 drivers/net/wireless/st/cw1200/fwio.c         |  67 +++++-
 drivers/net/wireless/st/cw1200/fwio.h         |   3 +
 drivers/net/wireless/st/cw1200/hwio.h         |   1 +
 drivers/net/wireless/st/cw1200/main.c         |  50 ++++-
 drivers/net/wireless/st/cw1200/sta.c          |  26 ++-
 include/linux/mmc/sdio_ids.h                  |   1 +
 15 files changed, 367 insertions(+), 79 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/wireless/xradio,xr819.yaml


base-commit: e1dd8486807c1acf9551250b7f81e116a21e6ad6
-- 
2.56.0


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH wireless-next v2 01/12] wifi: cw1200: avoid removing the debugfs directory twice
  2026-12-01  8:39 [PATCH wireless-next v2 00/12] wifi: cw1200: add XRadio XR819 support Arthur Heymans
@ 2026-12-01  8:39 ` Arthur Heymans
  2026-12-01  8:39 ` [PATCH wireless-next v2 02/12] wifi: cw1200: check SDD element lengths before reading them Arthur Heymans
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Arthur Heymans @ 2026-12-01  8:39 UTC (permalink / raw)
  To: linux-wireless, Johannes Berg
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, devicetree,
	Ulf Hansson, linux-mmc, Solomon Peachy, linux-kernel,
	Arthur Heymans

Unregistering the wiphy removes its cw1200 debugfs directory. On SDIO
unbind, cw1200_debug_release() then tries to remove the stale dentry.
Leave directory removal to the wiphy and free the counters as before.

Fixes: fa8eeae10257 ("cw1200: Remove "ITP" debug subsystem.")
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
---
 drivers/net/wireless/st/cw1200/debug.c | 19 ++++++++-----------
 drivers/net/wireless/st/cw1200/debug.h |  1 -
 2 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/drivers/net/wireless/st/cw1200/debug.c b/drivers/net/wireless/st/cw1200/debug.c
index 7dad6d3ba239..6b8b6ca35103 100644
--- a/drivers/net/wireless/st/cw1200/debug.c
+++ b/drivers/net/wireless/st/cw1200/debug.c
@@ -359,19 +359,20 @@ static const struct file_operations fops_wsm_dumps = {
 
 int cw1200_debug_init(struct cw1200_common *priv)
 {
+	struct dentry *dir;
 	int ret = -ENOMEM;
 	struct cw1200_debug_priv *d = kzalloc_obj(struct cw1200_debug_priv);
 	priv->debug = d;
 	if (!d)
 		return ret;
 
-	d->debugfs_phy = debugfs_create_dir("cw1200",
-					    priv->hw->wiphy->debugfsdir);
-	debugfs_create_file("status", 0400, d->debugfs_phy, priv,
+	/* wiphy_unregister() removes the whole subtree. */
+	dir = debugfs_create_dir("cw1200", priv->hw->wiphy->debugfsdir);
+	debugfs_create_file("status", 0400, dir, priv,
 			    &cw1200_status_fops);
-	debugfs_create_file("counters", 0400, d->debugfs_phy, priv,
+	debugfs_create_file("counters", 0400, dir, priv,
 			    &cw1200_counters_fops);
-	debugfs_create_file("wsm_dumps", 0200, d->debugfs_phy, priv,
+	debugfs_create_file("wsm_dumps", 0200, dir, priv,
 			    &fops_wsm_dumps);
 
 	return 0;
@@ -379,10 +380,6 @@ int cw1200_debug_init(struct cw1200_common *priv)
 
 void cw1200_debug_release(struct cw1200_common *priv)
 {
-	struct cw1200_debug_priv *d = priv->debug;
-	if (d) {
-		debugfs_remove_recursive(d->debugfs_phy);
-		priv->debug = NULL;
-		kfree(d);
-	}
+	kfree(priv->debug);
+	priv->debug = NULL;
 }
diff --git a/drivers/net/wireless/st/cw1200/debug.h b/drivers/net/wireless/st/cw1200/debug.h
index 80bc1567533a..339a375b4c18 100644
--- a/drivers/net/wireless/st/cw1200/debug.h
+++ b/drivers/net/wireless/st/cw1200/debug.h
@@ -10,7 +10,6 @@
 #define CW1200_DEBUG_H_INCLUDED
 
 struct cw1200_debug_priv {
-	struct dentry *debugfs_phy;
 	int tx;
 	int tx_agg;
 	int rx;
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH wireless-next v2 02/12] wifi: cw1200: check SDD element lengths before reading them
  2026-12-01  8:39 [PATCH wireless-next v2 00/12] wifi: cw1200: add XRadio XR819 support Arthur Heymans
  2026-12-01  8:39 ` [PATCH wireless-next v2 01/12] wifi: cw1200: avoid removing the debugfs directory twice Arthur Heymans
@ 2026-12-01  8:39 ` Arthur Heymans
  2026-12-01  8:39 ` [PATCH wireless-next v2 03/12] wifi: cw1200: bounce SDIO transfers that use stack buffers Arthur Heymans
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Arthur Heymans @ 2026-12-01  8:39 UTC (permalink / raw)
  To: linux-wireless, Johannes Berg
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, devicetree,
	Ulf Hansson, linux-mmc, Solomon Peachy, linux-kernel,
	Arthur Heymans

SDD elements have byte alignment. Read the PTA and reference clock
fields with get_unaligned_le16() and reject short elements instead of
using incomplete board configuration data.

Fixes: a910e4a94f69 ("cw1200: add driver for the ST-E CW1100 & CW1200 WLAN chipsets")
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
---
 drivers/net/wireless/st/cw1200/sta.c | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/st/cw1200/sta.c b/drivers/net/wireless/st/cw1200/sta.c
index 5d8eaa700779..db9f0c4a07aa 100644
--- a/drivers/net/wireless/st/cw1200/sta.c
+++ b/drivers/net/wireless/st/cw1200/sta.c
@@ -11,6 +11,7 @@
 #include <linux/firmware.h>
 #include <linux/module.h>
 #include <linux/etherdevice.h>
+#include <linux/unaligned.h>
 
 #include "cw1200.h"
 #include "sta.h"
@@ -1072,28 +1073,34 @@ static int cw1200_parse_sdd_file(struct cw1200_common *priv)
 	while (p + 2 <= priv->sdd->data + priv->sdd->size) {
 		if (p + p[1] + 2 > priv->sdd->data + priv->sdd->size) {
 			pr_warn("Malformed sdd structure\n");
-			return -1;
+			return -EINVAL;
 		}
 		switch (p[0]) {
 		case SDD_PTA_CFG_ELT_ID: {
 			u16 v;
+
 			if (p[1] < 4) {
 				pr_warn("SDD_PTA_CFG_ELT_ID malformed\n");
-				ret = -1;
-				break;
+				return -EINVAL;
 			}
-			v = le16_to_cpu(*((__le16 *)(p + 2)));
+			v = get_unaligned_le16(p + 2);
 			if (!v)  /* non-zero means this is enabled */
 				break;
 
-			v = le16_to_cpu(*((__le16 *)(p + 4)));
+			v = get_unaligned_le16(p + 4);
 			priv->conf_listen_interval = (v >> 7) & 0x1F;
 			pr_debug("PTA found; Listen Interval %d\n",
 				 priv->conf_listen_interval);
 			break;
 		}
 		case SDD_REFERENCE_FREQUENCY_ELT_ID: {
-			u16 clk = le16_to_cpu(*((__le16 *)(p + 2)));
+			u16 clk;
+
+			if (p[1] < sizeof(clk)) {
+				pr_warn("SDD reference frequency malformed\n");
+				return -EINVAL;
+			}
+			clk = get_unaligned_le16(p + 2);
 			if (clk != priv->hw_refclk)
 				pr_warn("SDD file doesn't match configured refclk (%d vs %d)\n",
 					clk, priv->hw_refclk);
@@ -1147,7 +1154,12 @@ int cw1200_setup_mac(struct cw1200_common *priv)
 			pr_err("Can't load sdd file %s.\n", priv->sdd_path);
 			return ret;
 		}
-		cw1200_parse_sdd_file(priv);
+		ret = cw1200_parse_sdd_file(priv);
+		if (ret) {
+			release_firmware(priv->sdd);
+			priv->sdd = NULL;
+			return ret;
+		}
 	}
 
 	cfg.dpdData = priv->sdd->data;
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH wireless-next v2 03/12] wifi: cw1200: bounce SDIO transfers that use stack buffers
  2026-12-01  8:39 [PATCH wireless-next v2 00/12] wifi: cw1200: add XRadio XR819 support Arthur Heymans
  2026-12-01  8:39 ` [PATCH wireless-next v2 01/12] wifi: cw1200: avoid removing the debugfs directory twice Arthur Heymans
  2026-12-01  8:39 ` [PATCH wireless-next v2 02/12] wifi: cw1200: check SDD element lengths before reading them Arthur Heymans
@ 2026-12-01  8:39 ` Arthur Heymans
  2026-12-01  8:39 ` [PATCH wireless-next v2 04/12] wifi: cw1200: unwind GPIO interrupt setup on error Arthur Heymans
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Arthur Heymans @ 2026-12-01  8:39 UTC (permalink / raw)
  To: linux-wireless, Johannes Berg
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, devicetree,
	Ulf Hansson, linux-mmc, Solomon Peachy, linux-kernel,
	Arthur Heymans

Register accesses pass stack words to sdio_memcpy_fromio() and
sdio_memcpy_toio(). Use a heap buffer for stack and non-linear
addresses; keep the direct path for ordinary packet buffers.

Fixes: a910e4a94f69 ("cw1200: add driver for the ST-E CW1100 & CW1200 WLAN chipsets")
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
---
 drivers/net/wireless/st/cw1200/cw1200_sdio.c | 35 ++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/st/cw1200/cw1200_sdio.c b/drivers/net/wireless/st/cw1200/cw1200_sdio.c
index 2b6afe221268..1894359ee9b4 100644
--- a/drivers/net/wireless/st/cw1200/cw1200_sdio.c
+++ b/drivers/net/wireless/st/cw1200/cw1200_sdio.c
@@ -10,6 +10,9 @@
 #include <linux/interrupt.h>
 #include <linux/gpio/consumer.h>
 #include <linux/delay.h>
+#include <linux/mm.h>
+#include <linux/slab.h>
+#include <linux/sched/task_stack.h>
 #include <linux/mmc/host.h>
 #include <linux/mmc/sdio_func.h>
 #include <linux/mmc/card.h>
@@ -61,14 +64,42 @@ static int cw1200_sdio_memcpy_fromio(struct hwbus_priv *self,
 				     unsigned int addr,
 				     void *dst, int count)
 {
-	return sdio_memcpy_fromio(self->func, dst, addr, count);
+	void *bounce;
+	int ret;
+
+	if (virt_addr_valid(dst) && !object_is_on_stack(dst))
+		return sdio_memcpy_fromio(self->func, dst, addr, count);
+
+	bounce = kmalloc(count, GFP_KERNEL);
+	if (!bounce)
+		return -ENOMEM;
+
+	ret = sdio_memcpy_fromio(self->func, bounce, addr, count);
+	if (!ret)
+		memcpy(dst, bounce, count);
+	kfree(bounce);
+
+	return ret;
 }
 
 static int cw1200_sdio_memcpy_toio(struct hwbus_priv *self,
 				   unsigned int addr,
 				   const void *src, int count)
 {
-	return sdio_memcpy_toio(self->func, addr, (void *)src, count);
+	void *bounce;
+	int ret;
+
+	if (virt_addr_valid(src) && !object_is_on_stack(src))
+		return sdio_memcpy_toio(self->func, addr, (void *)src, count);
+
+	bounce = kmemdup(src, count, GFP_KERNEL);
+	if (!bounce)
+		return -ENOMEM;
+
+	ret = sdio_memcpy_toio(self->func, addr, bounce, count);
+	kfree(bounce);
+
+	return ret;
 }
 
 static void cw1200_sdio_lock(struct hwbus_priv *self)
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH wireless-next v2 04/12] wifi: cw1200: unwind GPIO interrupt setup on error
  2026-12-01  8:39 [PATCH wireless-next v2 00/12] wifi: cw1200: add XRadio XR819 support Arthur Heymans
                   ` (2 preceding siblings ...)
  2026-12-01  8:39 ` [PATCH wireless-next v2 03/12] wifi: cw1200: bounce SDIO transfers that use stack buffers Arthur Heymans
@ 2026-12-01  8:39 ` Arthur Heymans
  2026-12-01  8:39 ` [PATCH wireless-next v2 05/12] wifi: cw1200: unregister from mac80211 before freeing the interrupt Arthur Heymans
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Arthur Heymans @ 2026-12-01  8:39 UTC (permalink / raw)
  To: linux-wireless, Johannes Berg
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, devicetree,
	Ulf Hansson, linux-mmc, Solomon Peachy, linux-kernel,
	Arthur Heymans

If requesting the GPIO interrupt fails, the wake reference and the
card interrupt enables remain set. Drop the wake reference and restore
the original CCCR interrupt-enable byte on the error paths.

Fixes: a910e4a94f69 ("cw1200: add driver for the ST-E CW1100 & CW1200 WLAN chipsets")
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
---
 drivers/net/wireless/st/cw1200/cw1200_sdio.c | 38 ++++++++++----------
 1 file changed, 18 insertions(+), 20 deletions(-)

diff --git a/drivers/net/wireless/st/cw1200/cw1200_sdio.c b/drivers/net/wireless/st/cw1200/cw1200_sdio.c
index 1894359ee9b4..dda201e69735 100644
--- a/drivers/net/wireless/st/cw1200/cw1200_sdio.c
+++ b/drivers/net/wireless/st/cw1200/cw1200_sdio.c
@@ -143,37 +143,35 @@ static irqreturn_t cw1200_gpio_irq(int irq, void *dev_id)
 static int cw1200_request_irq(struct hwbus_priv *self)
 {
 	int ret;
-	u8 cccr;
+	int err;
+	u8 ien;
 
-	cccr = sdio_f0_readb(self->func, SDIO_CCCR_IENx, &ret);
-	if (WARN_ON(ret))
-		goto err;
-
-	/* Master interrupt enable ... */
-	cccr |= BIT(0);
-
-	/* ... for our function */
-	cccr |= BIT(self->func->num);
+	ien = sdio_f0_readb(self->func, SDIO_CCCR_IENx, &ret);
+	if (ret)
+		return ret;
 
-	sdio_f0_writeb(self->func, cccr, SDIO_CCCR_IENx, &ret);
-	if (WARN_ON(ret))
-		goto err;
+	sdio_f0_writeb(self->func, ien | BIT(0) | BIT(self->func->num),
+		       SDIO_CCCR_IENx, &ret);
+	if (ret)
+		return ret;
 
 	ret = enable_irq_wake(self->pdata->irq);
-	if (WARN_ON(ret))
-		goto err;
+	if (ret)
+		goto restore_ien;
 
 	/* Request the IRQ */
 	ret =  request_threaded_irq(self->pdata->irq, cw1200_gpio_hardirq,
 				    cw1200_gpio_irq,
 				    IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
 				    "cw1200_wlan_irq", self);
-	if (WARN_ON(ret))
-		goto err;
-
-	return 0;
+	if (!ret)
+		return 0;
 
-err:
+	disable_irq_wake(self->pdata->irq);
+restore_ien:
+	sdio_f0_writeb(self->func, ien, SDIO_CCCR_IENx, &err);
+	if (err)
+		dev_warn(&self->func->dev, "cannot restore interrupt enables: %d\n", err);
 	return ret;
 }
 
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH wireless-next v2 05/12] wifi: cw1200: unregister from mac80211 before freeing the interrupt
  2026-12-01  8:39 [PATCH wireless-next v2 00/12] wifi: cw1200: add XRadio XR819 support Arthur Heymans
                   ` (3 preceding siblings ...)
  2026-12-01  8:39 ` [PATCH wireless-next v2 04/12] wifi: cw1200: unwind GPIO interrupt setup on error Arthur Heymans
@ 2026-12-01  8:39 ` Arthur Heymans
  2026-12-01  8:39 ` [PATCH wireless-next v2 06/12] dt-bindings: vendor-prefixes: add XRadio Arthur Heymans
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Arthur Heymans @ 2026-12-01  8:39 UTC (permalink / raw)
  To: linux-wireless, Johannes Berg
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, devicetree,
	Ulf Hansson, linux-mmc, Solomon Peachy, linux-kernel,
	Arthur Heymans

Removing the device unregisters the hardware from mac80211 only after the
bus driver has freed the interrupt and cw1200_core_release() has disabled
the device interrupts. Unregistering removes the interfaces, which sends
WSM commands such as RESET and CONFIGURATION, and their confirmations
then never arrive. Each unbind of an associated device waits for the
command timeout and ends with:

  CMD req (0x0009) stuck in firmware, killing BH
  [BH] Fatal error, exiting.

Add cw1200_core_unregister() and call it from the SDIO and SPI remove
paths while the interrupt still works. The interrupt is still freed
before cw1200_core_release() frees the device, as the handler uses it.

Tested on an Orange Pi Zero (XR819 over SDIO) with both the SDIO and a
GPIO interrupt: repeated unbind and bind while associated no longer
logs the error. The SPI change is build-tested only.

Fixes: a910e4a94f69 ("cw1200: add driver for the ST-E CW1100 & CW1200 WLAN chipsets")
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
---
 drivers/net/wireless/st/cw1200/cw1200.h      |  1 +
 drivers/net/wireless/st/cw1200/cw1200_sdio.c |  2 ++
 drivers/net/wireless/st/cw1200/cw1200_spi.c  |  2 ++
 drivers/net/wireless/st/cw1200/main.c        | 13 +++++++++++--
 4 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/st/cw1200/cw1200.h b/drivers/net/wireless/st/cw1200/cw1200.h
index 48f808cdc1cb..6dc85ef6e0fa 100644
--- a/drivers/net/wireless/st/cw1200/cw1200.h
+++ b/drivers/net/wireless/st/cw1200/cw1200.h
@@ -293,6 +293,7 @@ int cw1200_core_probe(const struct hwbus_ops *hwbus_ops,
 		      struct cw1200_common **pself,
 		      int ref_clk, const u8 *macaddr,
 		      const char *sdd_path, bool have_5ghz);
+void cw1200_core_unregister(struct cw1200_common *self);
 void cw1200_core_release(struct cw1200_common *self);
 
 #define FWLOAD_BLOCK_SIZE (1024)
diff --git a/drivers/net/wireless/st/cw1200/cw1200_sdio.c b/drivers/net/wireless/st/cw1200/cw1200_sdio.c
index dda201e69735..4f4bd668ebd2 100644
--- a/drivers/net/wireless/st/cw1200/cw1200_sdio.c
+++ b/drivers/net/wireless/st/cw1200/cw1200_sdio.c
@@ -359,6 +359,8 @@ static void cw1200_sdio_disconnect(struct sdio_func *func)
 	struct hwbus_priv *self = sdio_get_drvdata(func);
 
 	if (self) {
+		if (self->core)
+			cw1200_core_unregister(self->core);
 		cw1200_sdio_irq_unsubscribe(self);
 		if (self->core) {
 			cw1200_core_release(self->core);
diff --git a/drivers/net/wireless/st/cw1200/cw1200_spi.c b/drivers/net/wireless/st/cw1200/cw1200_spi.c
index f71e71e06359..c08d1ce5605d 100644
--- a/drivers/net/wireless/st/cw1200/cw1200_spi.c
+++ b/drivers/net/wireless/st/cw1200/cw1200_spi.c
@@ -437,6 +437,8 @@ static void cw1200_spi_disconnect(struct spi_device *func)
 	struct hwbus_priv *self = spi_get_drvdata(func);
 
 	if (self) {
+		if (self->core)
+			cw1200_core_unregister(self->core);
 		cw1200_spi_irq_unsubscribe(self);
 		if (self->core) {
 			cw1200_core_release(self->core);
diff --git a/drivers/net/wireless/st/cw1200/main.c b/drivers/net/wireless/st/cw1200/main.c
index 5d569eeb353f..ee9fcecb0100 100644
--- a/drivers/net/wireless/st/cw1200/main.c
+++ b/drivers/net/wireless/st/cw1200/main.c
@@ -456,8 +456,6 @@ static void cw1200_unregister_common(struct ieee80211_hw *dev)
 	struct cw1200_common *priv = dev->priv;
 	int i;
 
-	ieee80211_unregister_hw(dev);
-
 	timer_delete_sync(&priv->mcast_timeout);
 	cw1200_unregister_bh(priv);
 
@@ -594,6 +592,17 @@ int cw1200_core_probe(const struct hwbus_ops *hwbus_ops,
 }
 EXPORT_SYMBOL_GPL(cw1200_core_probe);
 
+/*
+ * Removing the interfaces sends WSM commands, which need the device
+ * interrupt for their confirmations, so the bus driver calls this before
+ * it frees its interrupt and calls cw1200_core_release().
+ */
+void cw1200_core_unregister(struct cw1200_common *self)
+{
+	ieee80211_unregister_hw(self->hw);
+}
+EXPORT_SYMBOL_GPL(cw1200_core_unregister);
+
 void cw1200_core_release(struct cw1200_common *self)
 {
 	/* Disable device interrupts */
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH wireless-next v2 06/12] dt-bindings: vendor-prefixes: add XRadio
  2026-12-01  8:39 [PATCH wireless-next v2 00/12] wifi: cw1200: add XRadio XR819 support Arthur Heymans
                   ` (4 preceding siblings ...)
  2026-12-01  8:39 ` [PATCH wireless-next v2 05/12] wifi: cw1200: unregister from mac80211 before freeing the interrupt Arthur Heymans
@ 2026-12-01  8:39 ` Arthur Heymans
  2026-12-01  8:39 ` [PATCH wireless-next v2 07/12] dt-bindings: net: wireless: add XRadio XR819 Arthur Heymans
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Arthur Heymans @ 2026-12-01  8:39 UTC (permalink / raw)
  To: linux-wireless, Johannes Berg
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, devicetree,
	Ulf Hansson, linux-mmc, Solomon Peachy, linux-kernel,
	Arthur Heymans

Add the vendor prefix for XRadio Wi-Fi chips.

Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml
index 5471a06f93f1..8311091bdfaa 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
+++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
@@ -1959,6 +1959,8 @@ patternProperties:
     description: Xilinx
   "^xnano,.*":
     description: Xnano
+  "^xradio,.*":
+    description: Guangzhou Xradio Technology Co., Ltd.
   "^xunlong,.*":
     description: Shenzhen Xunlong Software CO.,Limited
   "^xylon,.*":
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH wireless-next v2 07/12] dt-bindings: net: wireless: add XRadio XR819
  2026-12-01  8:39 [PATCH wireless-next v2 00/12] wifi: cw1200: add XRadio XR819 support Arthur Heymans
                   ` (5 preceding siblings ...)
  2026-12-01  8:39 ` [PATCH wireless-next v2 06/12] dt-bindings: vendor-prefixes: add XRadio Arthur Heymans
@ 2026-12-01  8:39 ` Arthur Heymans
  2026-12-01  8:39 ` [PATCH wireless-next v2 08/12] wifi: cw1200: load the XR819 bootloader into SRAM Arthur Heymans
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Arthur Heymans @ 2026-12-01  8:39 UTC (permalink / raw)
  To: linux-wireless, Johannes Berg
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, devicetree,
	Ulf Hansson, linux-mmc, Solomon Peachy, linux-kernel,
	Arthur Heymans

The XR819 exposes one SDIO function. Boards may provide a MAC address
and wire a GPIO interrupt instead of using the SDIO interrupt.

Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
---
 .../bindings/net/wireless/xradio,xr819.yaml   | 55 +++++++++++++++++++
 MAINTAINERS                                   |  1 +
 2 files changed, 56 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/wireless/xradio,xr819.yaml

diff --git a/Documentation/devicetree/bindings/net/wireless/xradio,xr819.yaml b/Documentation/devicetree/bindings/net/wireless/xradio,xr819.yaml
new file mode 100644
index 000000000000..64cd8d5ad0a5
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/wireless/xradio,xr819.yaml
@@ -0,0 +1,55 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/wireless/xradio,xr819.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: XRadio XR819 SDIO wireless controller
+
+maintainers:
+  - Arthur Heymans <arthur@aheymans.xyz>
+
+description: |
+  The XR819 is a 2.4 GHz IEEE 802.11b/g/n controller connected to the host
+  through SDIO. Its out-of-band interrupt may be connected to a host GPIO.
+
+  Power supplies, the active-low reset line, and any host-provided 32.768 kHz
+  low-power clock are required before SDIO enumeration and are therefore
+  described on the parent MMC controller using vmmc-supply/vqmmc-supply and
+  mmc-pwrseq-simple.
+
+allOf:
+  - $ref: wireless-controller.yaml#
+
+properties:
+  compatible:
+    const: xradio,xr819
+
+  reg:
+    const: 1
+
+  interrupts:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    mmc {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        wifi@1 {
+            compatible = "xradio,xr819";
+            reg = <1>;
+            interrupt-parent = <&pio>;
+            interrupts = <10 IRQ_TYPE_EDGE_RISING>;
+            local-mac-address = [02 00 00 00 00 01];
+        };
+    };
diff --git a/MAINTAINERS b/MAINTAINERS
index 0cf311e6c4be..6e7b5f6beba4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7211,6 +7211,7 @@ F:	Documentation/process/cve.rst
 CW1200 WLAN driver
 S:	Orphan
 L:	linux-wireless@vger.kernel.org
+F:	Documentation/devicetree/bindings/net/wireless/xradio,xr819.yaml
 F:	drivers/net/wireless/st/
 F:	include/linux/platform_data/net-cw1200.h
 
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH wireless-next v2 08/12] wifi: cw1200: load the XR819 bootloader into SRAM
  2026-12-01  8:39 [PATCH wireless-next v2 00/12] wifi: cw1200: add XRadio XR819 support Arthur Heymans
                   ` (6 preceding siblings ...)
  2026-12-01  8:39 ` [PATCH wireless-next v2 07/12] dt-bindings: net: wireless: add XRadio XR819 Arthur Heymans
@ 2026-12-01  8:39 ` Arthur Heymans
  2026-12-01  8:39 ` [PATCH wireless-next v2 09/12] wifi: cw1200: copy platform data into per-device storage Arthur Heymans
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Arthur Heymans @ 2026-12-01  8:39 UTC (permalink / raw)
  To: linux-wireless, Johannes Berg
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, devicetree,
	Ulf Hansson, linux-mmc, Solomon Peachy, linux-kernel,
	Arthur Heymans

XR819 shares the CW1x60 revision field but needs a first-stage loader
at 0x08000000. Write it before releasing the CPU from reset, then use
the existing firmware download path.

Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
---
 drivers/net/wireless/st/cw1200/cw1200.h |  8 +++
 drivers/net/wireless/st/cw1200/fwio.c   | 67 +++++++++++++++++++++++--
 drivers/net/wireless/st/cw1200/fwio.h   |  3 ++
 drivers/net/wireless/st/cw1200/hwio.h   |  1 +
 drivers/net/wireless/st/cw1200/main.c   | 37 +++++++++++---
 5 files changed, 105 insertions(+), 11 deletions(-)

diff --git a/drivers/net/wireless/st/cw1200/cw1200.h b/drivers/net/wireless/st/cw1200/cw1200.h
index 6dc85ef6e0fa..b25b60d377f6 100644
--- a/drivers/net/wireless/st/cw1200/cw1200.h
+++ b/drivers/net/wireless/st/cw1200/cw1200.h
@@ -116,7 +116,9 @@ struct cw1200_common {
 		CW1200_HW_REV_CUT20 = 20,
 		CW1200_HW_REV_CUT22 = 22,
 		CW1X60_HW_REV       = 40,
+		XR819_HW_REV        = 41,
 	} hw_revision;
+	bool				is_xr819;
 	int                             hw_refclk;
 	bool				hw_have_5ghz;
 	const struct firmware		*sdd;
@@ -293,6 +295,12 @@ int cw1200_core_probe(const struct hwbus_ops *hwbus_ops,
 		      struct cw1200_common **pself,
 		      int ref_clk, const u8 *macaddr,
 		      const char *sdd_path, bool have_5ghz);
+int cw1200_core_probe_xr819(const struct hwbus_ops *hwbus_ops,
+			    struct hwbus_priv *hwbus,
+			    struct device *pdev,
+			    struct cw1200_common **pself,
+			    int ref_clk, const u8 *macaddr,
+			    const char *sdd_path);
 void cw1200_core_unregister(struct cw1200_common *self);
 void cw1200_core_release(struct cw1200_common *self);
 
diff --git a/drivers/net/wireless/st/cw1200/fwio.c b/drivers/net/wireless/st/cw1200/fwio.c
index 2a03dc533b6a..08b6f02e3ffd 100644
--- a/drivers/net/wireless/st/cw1200/fwio.c
+++ b/drivers/net/wireless/st/cw1200/fwio.c
@@ -14,6 +14,7 @@
 #include <linux/vmalloc.h>
 #include <linux/sched.h>
 #include <linux/firmware.h>
+#include <linux/unaligned.h>
 
 #include "cw1200.h"
 #include "fwio.h"
@@ -116,6 +117,11 @@ static int cw1200_load_firmware_cw1200(struct cw1200_common *priv)
 		if (!priv->sdd_path)
 			priv->sdd_path = SDD_FILE_CW1X60;
 		break;
+	case XR819_HW_REV:
+		fw_path = FIRMWARE_XR819;
+		if (!priv->sdd_path)
+			priv->sdd_path = SDD_FILE_XR819;
+		break;
 	default:
 		pr_err("Invalid silicon revision %d.\n", priv->hw_revision);
 		return -EINVAL;
@@ -128,9 +134,11 @@ static int cw1200_load_firmware_cw1200(struct cw1200_common *priv)
 	APB_WRITE(DOWNLOAD_STATUS_REG, DOWNLOAD_PENDING);
 	APB_WRITE(DOWNLOAD_FLAGS_REG, 0);
 
-	/* Write the NOP Instruction */
-	REG_WRITE(ST90TDS_SRAM_BASE_ADDR_REG_ID, 0xFFF20000);
-	REG_WRITE(ST90TDS_AHB_DPORT_REG_ID, 0xEAFFFFFE);
+	if (!priv->is_xr819) {
+		/* Write the NOP Instruction */
+		REG_WRITE(ST90TDS_SRAM_BASE_ADDR_REG_ID, 0xFFF20000);
+		REG_WRITE(ST90TDS_AHB_DPORT_REG_ID, 0xEAFFFFFE);
+	}
 
 	/* Release CPU from RESET */
 	REG_READ(ST90TDS_CONFIG_REG_ID, val32);
@@ -261,6 +269,45 @@ static int cw1200_load_firmware_cw1200(struct cw1200_common *priv)
 #undef REG_READ
 }
 
+static int cw1200_load_bootloader_xr819(struct cw1200_common *priv)
+{
+	const struct firmware *bootloader;
+	u32 addr = XR819_BOOT_BASE;
+	size_t i;
+	int ret;
+
+	ret = request_firmware(&bootloader, BOOTLOADER_XR819, priv->pdev);
+	if (ret) {
+		dev_err(priv->pdev, "can't load bootloader file %s\n",
+			BOOTLOADER_XR819);
+		return ret;
+	}
+
+	if (!bootloader->size || bootloader->size > U32_MAX - addr ||
+	    !IS_ALIGNED(bootloader->size, sizeof(u32))) {
+		dev_err(priv->pdev, "invalid bootloader size %zu\n", bootloader->size);
+		ret = -EINVAL;
+		goto release;
+	}
+
+	for (i = 0; i < bootloader->size; i += sizeof(u32), addr += sizeof(u32)) {
+		u32 word = get_unaligned_le32(bootloader->data + i);
+
+		ret = cw1200_reg_write_32(priv, ST90TDS_SRAM_BASE_ADDR_REG_ID,
+					  addr);
+		if (ret)
+			goto release;
+
+		ret = cw1200_reg_write_32(priv, ST90TDS_AHB_DPORT_REG_ID, word);
+		if (ret)
+			goto release;
+	}
+
+release:
+	release_firmware(bootloader);
+	return ret;
+}
+
 
 static int config_reg_read(struct cw1200_common *priv, u32 *val)
 {
@@ -443,8 +490,13 @@ int cw1200_load_firmware(struct cw1200_common *priv)
 		break;
 	}
 	case 4:
-		pr_info("CW1x60 silicon detected.\n");
-		priv->hw_revision = CW1X60_HW_REV;
+		if (priv->is_xr819) {
+			dev_info(priv->pdev, "XR819 silicon detected\n");
+			priv->hw_revision = XR819_HW_REV;
+		} else {
+			pr_info("CW1x60 silicon detected.\n");
+			priv->hw_revision = CW1X60_HW_REV;
+		}
 		break;
 	default:
 		pr_err("Unsupported silicon major revision %d.\n",
@@ -473,6 +525,11 @@ int cw1200_load_firmware(struct cw1200_common *priv)
 			ret = -ENOTSUPP;
 			goto out;
 		}
+		if (priv->is_xr819) {
+			ret = cw1200_load_bootloader_xr819(priv);
+			if (ret)
+				goto out;
+		}
 		ret = cw1200_load_firmware_cw1200(priv);
 		break;
 	default:
diff --git a/drivers/net/wireless/st/cw1200/fwio.h b/drivers/net/wireless/st/cw1200/fwio.h
index c287160a492e..a3effef6d500 100644
--- a/drivers/net/wireless/st/cw1200/fwio.h
+++ b/drivers/net/wireless/st/cw1200/fwio.h
@@ -25,6 +25,9 @@
 #define SDD_FILE_20		"sdd_20.bin"
 #define SDD_FILE_11		"sdd_11.bin"
 #define SDD_FILE_10		"sdd_10.bin"
+#define BOOTLOADER_XR819	"xr819/boot_xr819.bin"
+#define FIRMWARE_XR819		"xr819/fw_xr819.bin"
+#define SDD_FILE_XR819		"xr819/sdd_xr819.bin"
 
 int cw1200_load_firmware(struct cw1200_common *priv);
 
diff --git a/drivers/net/wireless/st/cw1200/hwio.h b/drivers/net/wireless/st/cw1200/hwio.h
index d1e629a566c2..376dd1525fe2 100644
--- a/drivers/net/wireless/st/cw1200/hwio.h
+++ b/drivers/net/wireless/st/cw1200/hwio.h
@@ -89,6 +89,7 @@ struct download_cntl_t {
 
 
 #define SYS_BASE_ADDR_SILICON		(0)
+#define XR819_BOOT_BASE			0x08000000
 #define PAC_BASE_ADDRESS_SILICON	(SYS_BASE_ADDR_SILICON + 0x09000000)
 #define PAC_SHARED_MEMORY_SILICON	(PAC_BASE_ADDRESS_SILICON)
 
diff --git a/drivers/net/wireless/st/cw1200/main.c b/drivers/net/wireless/st/cw1200/main.c
index ee9fcecb0100..998b8e45e503 100644
--- a/drivers/net/wireless/st/cw1200/main.c
+++ b/drivers/net/wireless/st/cw1200/main.c
@@ -515,12 +515,13 @@ u32 cw1200_dpll_from_clk(u16 clk_khz)
 	}
 }
 
-int cw1200_core_probe(const struct hwbus_ops *hwbus_ops,
-		      struct hwbus_priv *hwbus,
-		      struct device *pdev,
-		      struct cw1200_common **core,
-		      int ref_clk, const u8 *macaddr,
-		      const char *sdd_path, bool have_5ghz)
+static int __cw1200_core_probe(const struct hwbus_ops *hwbus_ops,
+			       struct hwbus_priv *hwbus,
+			       struct device *pdev,
+			       struct cw1200_common **core,
+			       int ref_clk, const u8 *macaddr,
+			       const char *sdd_path, bool have_5ghz,
+			       bool is_xr819)
 {
 	int err = -EINVAL;
 	struct ieee80211_hw *dev;
@@ -535,6 +536,7 @@ int cw1200_core_probe(const struct hwbus_ops *hwbus_ops,
 		goto err;
 
 	priv = dev->priv;
+	priv->is_xr819 = is_xr819;
 	priv->hw_refclk = ref_clk;
 	if (cw1200_refclk)
 		priv->hw_refclk = cw1200_refclk;
@@ -590,8 +592,31 @@ int cw1200_core_probe(const struct hwbus_ops *hwbus_ops,
 	*core = NULL;
 	return err;
 }
+
+int cw1200_core_probe(const struct hwbus_ops *hwbus_ops,
+		      struct hwbus_priv *hwbus,
+		      struct device *pdev,
+		      struct cw1200_common **core,
+		      int ref_clk, const u8 *macaddr,
+		      const char *sdd_path, bool have_5ghz)
+{
+	return __cw1200_core_probe(hwbus_ops, hwbus, pdev, core, ref_clk,
+				   macaddr, sdd_path, have_5ghz, false);
+}
 EXPORT_SYMBOL_GPL(cw1200_core_probe);
 
+int cw1200_core_probe_xr819(const struct hwbus_ops *hwbus_ops,
+			    struct hwbus_priv *hwbus,
+			    struct device *pdev,
+			    struct cw1200_common **core,
+			    int ref_clk, const u8 *macaddr,
+			    const char *sdd_path)
+{
+	return __cw1200_core_probe(hwbus_ops, hwbus, pdev, core, ref_clk,
+				   macaddr, sdd_path, false, true);
+}
+EXPORT_SYMBOL_GPL(cw1200_core_probe_xr819);
+
 /*
  * Removing the interfaces sends WSM commands, which need the device
  * interrupt for their confirmations, so the bus driver calls this before
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH wireless-next v2 09/12] wifi: cw1200: copy platform data into per-device storage
  2026-12-01  8:39 [PATCH wireless-next v2 00/12] wifi: cw1200: add XRadio XR819 support Arthur Heymans
                   ` (7 preceding siblings ...)
  2026-12-01  8:39 ` [PATCH wireless-next v2 08/12] wifi: cw1200: load the XR819 bootloader into SRAM Arthur Heymans
@ 2026-12-01  8:39 ` Arthur Heymans
  2026-12-01  8:47   ` Ulf Hansson
  2026-12-01  8:39 ` [PATCH wireless-next v2 10/12] wifi: cw1200: check sdio_enable_func() and IRQ subscribe errors Arthur Heymans
                   ` (3 subsequent siblings)
  12 siblings, 1 reply; 17+ messages in thread
From: Arthur Heymans @ 2026-12-01  8:39 UTC (permalink / raw)
  To: linux-wireless, Johannes Berg
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, devicetree,
	Ulf Hansson, linux-mmc, Solomon Peachy, linux-kernel,
	Arthur Heymans

Instead of pointing self->pdata directly at global_plat_data, copy it
into per-device storage in struct hwbus_priv so probe can override
device-specific parameters without mutating global state.

Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
---
 drivers/net/wireless/st/cw1200/cw1200_sdio.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/st/cw1200/cw1200_sdio.c b/drivers/net/wireless/st/cw1200/cw1200_sdio.c
index 4f4bd668ebd2..2f25cf0028eb 100644
--- a/drivers/net/wireless/st/cw1200/cw1200_sdio.c
+++ b/drivers/net/wireless/st/cw1200/cw1200_sdio.c
@@ -50,6 +50,7 @@ struct hwbus_priv {
 	struct sdio_func	*func;
 	struct cw1200_common	*core;
 	const struct cw1200_platform_data_sdio *pdata;
+	struct cw1200_platform_data_sdio pdata_storage;
 };
 
 static const struct sdio_device_id cw1200_sdio_ids[] = {
@@ -324,7 +325,8 @@ static int cw1200_sdio_probe(struct sdio_func *func,
 
 	func->card->quirks |= MMC_QUIRK_LENIENT_FN0;
 
-	self->pdata = global_plat_data; /* FIXME */
+	self->pdata_storage = *global_plat_data;
+	self->pdata = &self->pdata_storage;
 	self->func = func;
 	sdio_set_drvdata(func, self);
 	sdio_claim_host(func);
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH wireless-next v2 10/12] wifi: cw1200: check sdio_enable_func() and IRQ subscribe errors
  2026-12-01  8:39 [PATCH wireless-next v2 00/12] wifi: cw1200: add XRadio XR819 support Arthur Heymans
                   ` (8 preceding siblings ...)
  2026-12-01  8:39 ` [PATCH wireless-next v2 09/12] wifi: cw1200: copy platform data into per-device storage Arthur Heymans
@ 2026-12-01  8:39 ` Arthur Heymans
  2026-12-01  8:47   ` Ulf Hansson
  2026-12-01  8:39 ` [PATCH wireless-next v2 11/12] wifi: cw1200: add XR819 SDIO support Arthur Heymans
                   ` (2 subsequent siblings)
  12 siblings, 1 reply; 17+ messages in thread
From: Arthur Heymans @ 2026-12-01  8:39 UTC (permalink / raw)
  To: linux-wireless, Johannes Berg
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, devicetree,
	Ulf Hansson, linux-mmc, Solomon Peachy, linux-kernel,
	Arthur Heymans

cw1200_sdio_probe() ignores the return value of sdio_enable_func() and
overwrites the status from cw1200_sdio_irq_subscribe() before checking
it. Handle both errors and unwind setup on failure.

Fixes: a910e4a94f69 ("cw1200: add driver for the ST-E CW1100 & CW1200 WLAN chipsets")
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
---
 drivers/net/wireless/st/cw1200/cw1200_sdio.c | 24 ++++++++++++--------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/st/cw1200/cw1200_sdio.c b/drivers/net/wireless/st/cw1200/cw1200_sdio.c
index 2f25cf0028eb..b992f6cd6e79 100644
--- a/drivers/net/wireless/st/cw1200/cw1200_sdio.c
+++ b/drivers/net/wireless/st/cw1200/cw1200_sdio.c
@@ -330,10 +330,14 @@ static int cw1200_sdio_probe(struct sdio_func *func,
 	self->func = func;
 	sdio_set_drvdata(func, self);
 	sdio_claim_host(func);
-	sdio_enable_func(func);
+	status = sdio_enable_func(func);
 	sdio_release_host(func);
+	if (status)
+		goto clear_drvdata;
 
 	status = cw1200_sdio_irq_subscribe(self);
+	if (status)
+		goto disable_func;
 
 	status = cw1200_core_probe(&cw1200_sdio_hwbus_ops,
 				   self, &func->dev, &self->core,
@@ -341,15 +345,17 @@ static int cw1200_sdio_probe(struct sdio_func *func,
 				   self->pdata->macaddr,
 				   self->pdata->sdd_file,
 				   self->pdata->have_5ghz);
-	if (status) {
-		cw1200_sdio_irq_unsubscribe(self);
-		sdio_claim_host(func);
-		sdio_disable_func(func);
-		sdio_release_host(func);
-		sdio_set_drvdata(func, NULL);
-		kfree(self);
-	}
+	if (!status)
+		return 0;
 
+	cw1200_sdio_irq_unsubscribe(self);
+disable_func:
+	sdio_claim_host(func);
+	sdio_disable_func(func);
+	sdio_release_host(func);
+clear_drvdata:
+	sdio_set_drvdata(func, NULL);
+	kfree(self);
 	return status;
 }
 
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH wireless-next v2 11/12] wifi: cw1200: add XR819 SDIO support
  2026-12-01  8:39 [PATCH wireless-next v2 00/12] wifi: cw1200: add XRadio XR819 support Arthur Heymans
                   ` (9 preceding siblings ...)
  2026-12-01  8:39 ` [PATCH wireless-next v2 10/12] wifi: cw1200: check sdio_enable_func() and IRQ subscribe errors Arthur Heymans
@ 2026-12-01  8:39 ` Arthur Heymans
  2026-12-01  8:48   ` Ulf Hansson
  2026-12-01  8:39 ` [PATCH wireless-next v2 12/12] MAINTAINERS: add myself for the cw1200 driver Arthur Heymans
  2026-12-01 16:07 ` [PATCH wireless-next v2 00/12] wifi: cw1200: add XRadio XR819 support Pablo Mazzini
  12 siblings, 1 reply; 17+ messages in thread
From: Arthur Heymans @ 2026-12-01  8:39 UTC (permalink / raw)
  To: linux-wireless, Johannes Berg
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, devicetree,
	Ulf Hansson, linux-mmc, Solomon Peachy, linux-kernel,
	Arthur Heymans

Match SDIO ID 0020:2281 and use the XR819 download path. Reset the
card on probe: disabling the function leaves the host interface in
queue mode, and a second firmware download fails without the reset.

Use the board MAC address and GPIO interrupt when provided. Otherwise
use the SDIO interrupt.

Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
---
 drivers/net/wireless/st/cw1200/Kconfig       |  6 +-
 drivers/net/wireless/st/cw1200/cw1200_sdio.c | 97 +++++++++++++++++---
 include/linux/mmc/sdio_ids.h                 |  1 +
 3 files changed, 90 insertions(+), 14 deletions(-)

diff --git a/drivers/net/wireless/st/cw1200/Kconfig b/drivers/net/wireless/st/cw1200/Kconfig
index 03575e9894bb..8c2f759d8bd8 100644
--- a/drivers/net/wireless/st/cw1200/Kconfig
+++ b/drivers/net/wireless/st/cw1200/Kconfig
@@ -3,7 +3,8 @@ config CW1200
 	tristate "CW1200 WLAN support"
 	depends on MAC80211 && CFG80211
 	help
-	  This is a driver for the ST-E CW1100 & CW1200 WLAN chipsets.
+	  This is a driver for the ST-E CW1100, CW1200 and XRadio XR819
+	  WLAN chipsets.
 	  This option just enables the driver core, see below for
 	  specific bus support.
 
@@ -13,7 +14,8 @@ config CW1200_WLAN_SDIO
 	tristate "Support SDIO platforms"
 	depends on CW1200 && MMC
 	help
-	  Enable support for the CW1200 connected via an SDIO bus.
+	  Enable support for CW1200-family devices connected via an SDIO bus,
+	  including the XRadio XR819.
 	  By default this driver only supports the Sagrad SG901-1091/1098 EVK
 	  and similar designs that utilize a hardware reset circuit. To
 	  support different CW1200 SDIO designs you will need to override
diff --git a/drivers/net/wireless/st/cw1200/cw1200_sdio.c b/drivers/net/wireless/st/cw1200/cw1200_sdio.c
index b992f6cd6e79..330a4d0946bc 100644
--- a/drivers/net/wireless/st/cw1200/cw1200_sdio.c
+++ b/drivers/net/wireless/st/cw1200/cw1200_sdio.c
@@ -18,6 +18,9 @@
 #include <linux/mmc/card.h>
 #include <linux/mmc/sdio.h>
 #include <linux/mmc/sdio_ids.h>
+#include <linux/of.h>
+#include <linux/of_irq.h>
+#include <linux/of_net.h>
 #include <net/mac80211.h>
 
 #include "cw1200.h"
@@ -51,14 +54,27 @@ struct hwbus_priv {
 	struct cw1200_common	*core;
 	const struct cw1200_platform_data_sdio *pdata;
 	struct cw1200_platform_data_sdio pdata_storage;
+	u8 macaddr[ETH_ALEN];
+	bool is_xr819;
 };
 
 static const struct sdio_device_id cw1200_sdio_ids[] = {
 	{ SDIO_DEVICE(SDIO_VENDOR_ID_STE, SDIO_DEVICE_ID_STE_CW1200) },
+	{ SDIO_DEVICE(SDIO_VENDOR_ID_STE, SDIO_DEVICE_ID_STE_XR819) },
 	{ /* end: all zeroes */			},
 };
 MODULE_DEVICE_TABLE(sdio, cw1200_sdio_ids);
 
+static const struct of_device_id cw1200_sdio_of_match[] = {
+	{ .compatible = "xradio,xr819" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, cw1200_sdio_of_match);
+
+MODULE_FIRMWARE("xr819/boot_xr819.bin");
+MODULE_FIRMWARE("xr819/fw_xr819.bin");
+MODULE_FIRMWARE("xr819/sdd_xr819.bin");
+
 /* hwbus_ops implemetation */
 
 static int cw1200_sdio_memcpy_fromio(struct hwbus_priv *self,
@@ -143,6 +159,7 @@ static irqreturn_t cw1200_gpio_irq(int irq, void *dev_id)
 
 static int cw1200_request_irq(struct hwbus_priv *self)
 {
+	unsigned long trigger = irq_get_trigger_type(self->pdata->irq);
 	int ret;
 	int err;
 	u8 ien;
@@ -161,10 +178,10 @@ static int cw1200_request_irq(struct hwbus_priv *self)
 		goto restore_ien;
 
 	/* Request the IRQ */
-	ret =  request_threaded_irq(self->pdata->irq, cw1200_gpio_hardirq,
-				    cw1200_gpio_irq,
-				    IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
-				    "cw1200_wlan_irq", self);
+	ret = request_threaded_irq(self->pdata->irq, cw1200_gpio_hardirq,
+				   cw1200_gpio_irq, IRQF_ONESHOT |
+				   (trigger ?: IRQF_TRIGGER_HIGH),
+				   "cw1200_wlan_irq", self);
 	if (!ret)
 		return 0;
 
@@ -304,11 +321,28 @@ static const struct hwbus_ops cw1200_sdio_hwbus_ops = {
 	.power_mgmt		= cw1200_sdio_pm,
 };
 
+static int cw1200_sdio_core_probe(struct hwbus_priv *self,
+				  struct sdio_func *func)
+{
+	if (self->is_xr819)
+		return cw1200_core_probe_xr819(&cw1200_sdio_hwbus_ops, self,
+						&func->dev, &self->core,
+						self->pdata->ref_clk,
+						self->pdata->macaddr,
+						self->pdata->sdd_file);
+
+	return cw1200_core_probe(&cw1200_sdio_hwbus_ops, self, &func->dev,
+				 &self->core, self->pdata->ref_clk,
+				 self->pdata->macaddr, self->pdata->sdd_file,
+				 self->pdata->have_5ghz);
+}
+
 /* Probe Function to be called by SDIO stack when device is discovered */
 static int cw1200_sdio_probe(struct sdio_func *func,
 			     const struct sdio_device_id *id)
 {
 	struct hwbus_priv *self;
+	int irq;
 	int status;
 
 	pr_info("cw1200_wlan_sdio: Probe called\n");
@@ -327,7 +361,41 @@ static int cw1200_sdio_probe(struct sdio_func *func,
 
 	self->pdata_storage = *global_plat_data;
 	self->pdata = &self->pdata_storage;
+	self->is_xr819 = id->device == SDIO_DEVICE_ID_STE_XR819;
+	if (self->is_xr819) {
+		func->card->quirks |= MMC_QUIRK_BROKEN_BYTE_MODE_512;
+		self->pdata_storage.ref_clk = 24000;
+		self->pdata_storage.have_5ghz = false;
+		self->pdata_storage.sdd_file = "xr819/sdd_xr819.bin";
+
+		if (of_property_present(func->dev.of_node, "interrupts") ||
+		    of_property_present(func->dev.of_node, "interrupts-extended")) {
+			irq = of_irq_get(func->dev.of_node, 0);
+			if (irq <= 0) {
+				status = dev_err_probe(&func->dev, irq ?: -EINVAL,
+						       "cannot map GPIO interrupt\n");
+				goto free_self;
+			}
+			self->pdata_storage.irq = irq;
+		}
+
+		status = of_get_mac_address(func->dev.of_node, self->macaddr);
+		if (status == -EPROBE_DEFER)
+			goto free_self;
+		if (!status)
+			self->pdata_storage.macaddr = self->macaddr;
+	}
 	self->func = func;
+	if (self->is_xr819) {
+		/* Disabling the function leaves the HIF in queue mode. Reset
+		 * the single-function XR819 before starting another download.
+		 */
+		sdio_claim_host(func);
+		status = mmc_hw_reset(func->card);
+		sdio_release_host(func);
+		if (status)
+			goto free_self;
+	}
 	sdio_set_drvdata(func, self);
 	sdio_claim_host(func);
 	status = sdio_enable_func(func);
@@ -335,16 +403,19 @@ static int cw1200_sdio_probe(struct sdio_func *func,
 	if (status)
 		goto clear_drvdata;
 
+	if (self->is_xr819) {
+		sdio_claim_host(func);
+		status = sdio_set_block_size(func, SDIO_BLOCK_SIZE);
+		sdio_release_host(func);
+		if (status)
+			goto disable_func;
+	}
+
 	status = cw1200_sdio_irq_subscribe(self);
 	if (status)
 		goto disable_func;
 
-	status = cw1200_core_probe(&cw1200_sdio_hwbus_ops,
-				   self, &func->dev, &self->core,
-				   self->pdata->ref_clk,
-				   self->pdata->macaddr,
-				   self->pdata->sdd_file,
-				   self->pdata->have_5ghz);
+	status = cw1200_sdio_core_probe(self, func);
 	if (!status)
 		return 0;
 
@@ -355,6 +426,7 @@ static int cw1200_sdio_probe(struct sdio_func *func,
 	sdio_release_host(func);
 clear_drvdata:
 	sdio_set_drvdata(func, NULL);
+free_self:
 	kfree(self);
 	return status;
 }
@@ -416,11 +488,12 @@ static struct sdio_driver sdio_driver = {
 	.id_table	= cw1200_sdio_ids,
 	.probe		= cw1200_sdio_probe,
 	.remove		= cw1200_sdio_disconnect,
-#ifdef CONFIG_PM
 	.drv = {
+#ifdef CONFIG_PM
 		.pm = &cw1200_pm_ops,
-	}
 #endif
+		.of_match_table = cw1200_sdio_of_match,
+	},
 };
 
 /* Init Module function -> Called by insmod */
diff --git a/include/linux/mmc/sdio_ids.h b/include/linux/mmc/sdio_ids.h
index dfffda3d8002..35789be747a5 100644
--- a/include/linux/mmc/sdio_ids.h
+++ b/include/linux/mmc/sdio_ids.h
@@ -27,6 +27,7 @@
 
 #define SDIO_VENDOR_ID_STE			0x0020
 #define SDIO_DEVICE_ID_STE_CW1200		0x2280
+#define SDIO_DEVICE_ID_STE_XR819		0x2281
 
 #define SDIO_VENDOR_ID_INTEL			0x0089
 #define SDIO_DEVICE_ID_INTEL_IWMC3200WIMAX	0x1402
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH wireless-next v2 12/12] MAINTAINERS: add myself for the cw1200 driver
  2026-12-01  8:39 [PATCH wireless-next v2 00/12] wifi: cw1200: add XRadio XR819 support Arthur Heymans
                   ` (10 preceding siblings ...)
  2026-12-01  8:39 ` [PATCH wireless-next v2 11/12] wifi: cw1200: add XR819 SDIO support Arthur Heymans
@ 2026-12-01  8:39 ` Arthur Heymans
  2026-12-01 16:07 ` [PATCH wireless-next v2 00/12] wifi: cw1200: add XRadio XR819 support Pablo Mazzini
  12 siblings, 0 replies; 17+ messages in thread
From: Arthur Heymans @ 2026-12-01  8:39 UTC (permalink / raw)
  To: linux-wireless, Johannes Berg
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, devicetree,
	Ulf Hansson, linux-mmc, Solomon Peachy, linux-kernel,
	Arthur Heymans

The driver has been orphaned. I am adding XR819 support to it and can
look after fixes, so take it over as Odd Fixes.

Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
---
 MAINTAINERS | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 6e7b5f6beba4..3ee6e717bfc2 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7209,8 +7209,9 @@ S:	Maintained
 F:	Documentation/process/cve.rst
 
 CW1200 WLAN driver
-S:	Orphan
+M:	Arthur Heymans <arthur@aheymans.xyz>
 L:	linux-wireless@vger.kernel.org
+S:	Odd Fixes
 F:	Documentation/devicetree/bindings/net/wireless/xradio,xr819.yaml
 F:	drivers/net/wireless/st/
 F:	include/linux/platform_data/net-cw1200.h
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH wireless-next v2 09/12] wifi: cw1200: copy platform data into per-device storage
  2026-12-01  8:39 ` [PATCH wireless-next v2 09/12] wifi: cw1200: copy platform data into per-device storage Arthur Heymans
@ 2026-12-01  8:47   ` Ulf Hansson
  0 siblings, 0 replies; 17+ messages in thread
From: Ulf Hansson @ 2026-12-01  8:47 UTC (permalink / raw)
  To: Arthur Heymans
  Cc: linux-wireless, Johannes Berg, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, devicetree, Ulf Hansson, linux-mmc, Solomon Peachy,
	linux-kernel

On Tue, Dec 1, 2026 at 9:40 AM Arthur Heymans <arthur@aheymans.xyz> wrote:
>
> Instead of pointing self->pdata directly at global_plat_data, copy it
> into per-device storage in struct hwbus_priv so probe can override
> device-specific parameters without mutating global state.
>
> Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>

Reviewed-by: Ulf Hansson <ulfh@kernel.org>

Kind regards
Uffe

> ---
>  drivers/net/wireless/st/cw1200/cw1200_sdio.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/st/cw1200/cw1200_sdio.c b/drivers/net/wireless/st/cw1200/cw1200_sdio.c
> index 4f4bd668ebd2..2f25cf0028eb 100644
> --- a/drivers/net/wireless/st/cw1200/cw1200_sdio.c
> +++ b/drivers/net/wireless/st/cw1200/cw1200_sdio.c
> @@ -50,6 +50,7 @@ struct hwbus_priv {
>         struct sdio_func        *func;
>         struct cw1200_common    *core;
>         const struct cw1200_platform_data_sdio *pdata;
> +       struct cw1200_platform_data_sdio pdata_storage;
>  };
>
>  static const struct sdio_device_id cw1200_sdio_ids[] = {
> @@ -324,7 +325,8 @@ static int cw1200_sdio_probe(struct sdio_func *func,
>
>         func->card->quirks |= MMC_QUIRK_LENIENT_FN0;
>
> -       self->pdata = global_plat_data; /* FIXME */
> +       self->pdata_storage = *global_plat_data;
> +       self->pdata = &self->pdata_storage;
>         self->func = func;
>         sdio_set_drvdata(func, self);
>         sdio_claim_host(func);
> --
> 2.56.0
>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH wireless-next v2 10/12] wifi: cw1200: check sdio_enable_func() and IRQ subscribe errors
  2026-12-01  8:39 ` [PATCH wireless-next v2 10/12] wifi: cw1200: check sdio_enable_func() and IRQ subscribe errors Arthur Heymans
@ 2026-12-01  8:47   ` Ulf Hansson
  0 siblings, 0 replies; 17+ messages in thread
From: Ulf Hansson @ 2026-12-01  8:47 UTC (permalink / raw)
  To: Arthur Heymans
  Cc: linux-wireless, Johannes Berg, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, devicetree, Ulf Hansson, linux-mmc, Solomon Peachy,
	linux-kernel

On Tue, Dec 1, 2026 at 9:40 AM Arthur Heymans <arthur@aheymans.xyz> wrote:
>
> cw1200_sdio_probe() ignores the return value of sdio_enable_func() and
> overwrites the status from cw1200_sdio_irq_subscribe() before checking
> it. Handle both errors and unwind setup on failure.
>
> Fixes: a910e4a94f69 ("cw1200: add driver for the ST-E CW1100 & CW1200 WLAN chipsets")
> Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>

Reviewed-by: Ulf Hansson <ulfh@kernel.org>

Kind regards
Uffe

> ---
>  drivers/net/wireless/st/cw1200/cw1200_sdio.c | 24 ++++++++++++--------
>  1 file changed, 15 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/wireless/st/cw1200/cw1200_sdio.c b/drivers/net/wireless/st/cw1200/cw1200_sdio.c
> index 2f25cf0028eb..b992f6cd6e79 100644
> --- a/drivers/net/wireless/st/cw1200/cw1200_sdio.c
> +++ b/drivers/net/wireless/st/cw1200/cw1200_sdio.c
> @@ -330,10 +330,14 @@ static int cw1200_sdio_probe(struct sdio_func *func,
>         self->func = func;
>         sdio_set_drvdata(func, self);
>         sdio_claim_host(func);
> -       sdio_enable_func(func);
> +       status = sdio_enable_func(func);
>         sdio_release_host(func);
> +       if (status)
> +               goto clear_drvdata;
>
>         status = cw1200_sdio_irq_subscribe(self);
> +       if (status)
> +               goto disable_func;
>
>         status = cw1200_core_probe(&cw1200_sdio_hwbus_ops,
>                                    self, &func->dev, &self->core,
> @@ -341,15 +345,17 @@ static int cw1200_sdio_probe(struct sdio_func *func,
>                                    self->pdata->macaddr,
>                                    self->pdata->sdd_file,
>                                    self->pdata->have_5ghz);
> -       if (status) {
> -               cw1200_sdio_irq_unsubscribe(self);
> -               sdio_claim_host(func);
> -               sdio_disable_func(func);
> -               sdio_release_host(func);
> -               sdio_set_drvdata(func, NULL);
> -               kfree(self);
> -       }
> +       if (!status)
> +               return 0;
>
> +       cw1200_sdio_irq_unsubscribe(self);
> +disable_func:
> +       sdio_claim_host(func);
> +       sdio_disable_func(func);
> +       sdio_release_host(func);
> +clear_drvdata:
> +       sdio_set_drvdata(func, NULL);
> +       kfree(self);
>         return status;
>  }
>
> --
> 2.56.0
>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH wireless-next v2 11/12] wifi: cw1200: add XR819 SDIO support
  2026-12-01  8:39 ` [PATCH wireless-next v2 11/12] wifi: cw1200: add XR819 SDIO support Arthur Heymans
@ 2026-12-01  8:48   ` Ulf Hansson
  0 siblings, 0 replies; 17+ messages in thread
From: Ulf Hansson @ 2026-12-01  8:48 UTC (permalink / raw)
  To: Arthur Heymans
  Cc: linux-wireless, Johannes Berg, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, devicetree, Ulf Hansson, linux-mmc, Solomon Peachy,
	linux-kernel

On Tue, Dec 1, 2026 at 9:40 AM Arthur Heymans <arthur@aheymans.xyz> wrote:
>
> Match SDIO ID 0020:2281 and use the XR819 download path. Reset the
> card on probe: disabling the function leaves the host interface in
> queue mode, and a second firmware download fails without the reset.
>
> Use the board MAC address and GPIO interrupt when provided. Otherwise
> use the SDIO interrupt.
>
> Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>

Reviewed-by: Ulf Hansson <ulfh@kernel.org>

And feel free to funnel this via the wireless tree.

Kind regards
Uffe

> ---
>  drivers/net/wireless/st/cw1200/Kconfig       |  6 +-
>  drivers/net/wireless/st/cw1200/cw1200_sdio.c | 97 +++++++++++++++++---
>  include/linux/mmc/sdio_ids.h                 |  1 +
>  3 files changed, 90 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/net/wireless/st/cw1200/Kconfig b/drivers/net/wireless/st/cw1200/Kconfig
> index 03575e9894bb..8c2f759d8bd8 100644
> --- a/drivers/net/wireless/st/cw1200/Kconfig
> +++ b/drivers/net/wireless/st/cw1200/Kconfig
> @@ -3,7 +3,8 @@ config CW1200
>         tristate "CW1200 WLAN support"
>         depends on MAC80211 && CFG80211
>         help
> -         This is a driver for the ST-E CW1100 & CW1200 WLAN chipsets.
> +         This is a driver for the ST-E CW1100, CW1200 and XRadio XR819
> +         WLAN chipsets.
>           This option just enables the driver core, see below for
>           specific bus support.
>
> @@ -13,7 +14,8 @@ config CW1200_WLAN_SDIO
>         tristate "Support SDIO platforms"
>         depends on CW1200 && MMC
>         help
> -         Enable support for the CW1200 connected via an SDIO bus.
> +         Enable support for CW1200-family devices connected via an SDIO bus,
> +         including the XRadio XR819.
>           By default this driver only supports the Sagrad SG901-1091/1098 EVK
>           and similar designs that utilize a hardware reset circuit. To
>           support different CW1200 SDIO designs you will need to override
> diff --git a/drivers/net/wireless/st/cw1200/cw1200_sdio.c b/drivers/net/wireless/st/cw1200/cw1200_sdio.c
> index b992f6cd6e79..330a4d0946bc 100644
> --- a/drivers/net/wireless/st/cw1200/cw1200_sdio.c
> +++ b/drivers/net/wireless/st/cw1200/cw1200_sdio.c
> @@ -18,6 +18,9 @@
>  #include <linux/mmc/card.h>
>  #include <linux/mmc/sdio.h>
>  #include <linux/mmc/sdio_ids.h>
> +#include <linux/of.h>
> +#include <linux/of_irq.h>
> +#include <linux/of_net.h>
>  #include <net/mac80211.h>
>
>  #include "cw1200.h"
> @@ -51,14 +54,27 @@ struct hwbus_priv {
>         struct cw1200_common    *core;
>         const struct cw1200_platform_data_sdio *pdata;
>         struct cw1200_platform_data_sdio pdata_storage;
> +       u8 macaddr[ETH_ALEN];
> +       bool is_xr819;
>  };
>
>  static const struct sdio_device_id cw1200_sdio_ids[] = {
>         { SDIO_DEVICE(SDIO_VENDOR_ID_STE, SDIO_DEVICE_ID_STE_CW1200) },
> +       { SDIO_DEVICE(SDIO_VENDOR_ID_STE, SDIO_DEVICE_ID_STE_XR819) },
>         { /* end: all zeroes */                 },
>  };
>  MODULE_DEVICE_TABLE(sdio, cw1200_sdio_ids);
>
> +static const struct of_device_id cw1200_sdio_of_match[] = {
> +       { .compatible = "xradio,xr819" },
> +       { }
> +};
> +MODULE_DEVICE_TABLE(of, cw1200_sdio_of_match);
> +
> +MODULE_FIRMWARE("xr819/boot_xr819.bin");
> +MODULE_FIRMWARE("xr819/fw_xr819.bin");
> +MODULE_FIRMWARE("xr819/sdd_xr819.bin");
> +
>  /* hwbus_ops implemetation */
>
>  static int cw1200_sdio_memcpy_fromio(struct hwbus_priv *self,
> @@ -143,6 +159,7 @@ static irqreturn_t cw1200_gpio_irq(int irq, void *dev_id)
>
>  static int cw1200_request_irq(struct hwbus_priv *self)
>  {
> +       unsigned long trigger = irq_get_trigger_type(self->pdata->irq);
>         int ret;
>         int err;
>         u8 ien;
> @@ -161,10 +178,10 @@ static int cw1200_request_irq(struct hwbus_priv *self)
>                 goto restore_ien;
>
>         /* Request the IRQ */
> -       ret =  request_threaded_irq(self->pdata->irq, cw1200_gpio_hardirq,
> -                                   cw1200_gpio_irq,
> -                                   IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
> -                                   "cw1200_wlan_irq", self);
> +       ret = request_threaded_irq(self->pdata->irq, cw1200_gpio_hardirq,
> +                                  cw1200_gpio_irq, IRQF_ONESHOT |
> +                                  (trigger ?: IRQF_TRIGGER_HIGH),
> +                                  "cw1200_wlan_irq", self);
>         if (!ret)
>                 return 0;
>
> @@ -304,11 +321,28 @@ static const struct hwbus_ops cw1200_sdio_hwbus_ops = {
>         .power_mgmt             = cw1200_sdio_pm,
>  };
>
> +static int cw1200_sdio_core_probe(struct hwbus_priv *self,
> +                                 struct sdio_func *func)
> +{
> +       if (self->is_xr819)
> +               return cw1200_core_probe_xr819(&cw1200_sdio_hwbus_ops, self,
> +                                               &func->dev, &self->core,
> +                                               self->pdata->ref_clk,
> +                                               self->pdata->macaddr,
> +                                               self->pdata->sdd_file);
> +
> +       return cw1200_core_probe(&cw1200_sdio_hwbus_ops, self, &func->dev,
> +                                &self->core, self->pdata->ref_clk,
> +                                self->pdata->macaddr, self->pdata->sdd_file,
> +                                self->pdata->have_5ghz);
> +}
> +
>  /* Probe Function to be called by SDIO stack when device is discovered */
>  static int cw1200_sdio_probe(struct sdio_func *func,
>                              const struct sdio_device_id *id)
>  {
>         struct hwbus_priv *self;
> +       int irq;
>         int status;
>
>         pr_info("cw1200_wlan_sdio: Probe called\n");
> @@ -327,7 +361,41 @@ static int cw1200_sdio_probe(struct sdio_func *func,
>
>         self->pdata_storage = *global_plat_data;
>         self->pdata = &self->pdata_storage;
> +       self->is_xr819 = id->device == SDIO_DEVICE_ID_STE_XR819;
> +       if (self->is_xr819) {
> +               func->card->quirks |= MMC_QUIRK_BROKEN_BYTE_MODE_512;
> +               self->pdata_storage.ref_clk = 24000;
> +               self->pdata_storage.have_5ghz = false;
> +               self->pdata_storage.sdd_file = "xr819/sdd_xr819.bin";
> +
> +               if (of_property_present(func->dev.of_node, "interrupts") ||
> +                   of_property_present(func->dev.of_node, "interrupts-extended")) {
> +                       irq = of_irq_get(func->dev.of_node, 0);
> +                       if (irq <= 0) {
> +                               status = dev_err_probe(&func->dev, irq ?: -EINVAL,
> +                                                      "cannot map GPIO interrupt\n");
> +                               goto free_self;
> +                       }
> +                       self->pdata_storage.irq = irq;
> +               }
> +
> +               status = of_get_mac_address(func->dev.of_node, self->macaddr);
> +               if (status == -EPROBE_DEFER)
> +                       goto free_self;
> +               if (!status)
> +                       self->pdata_storage.macaddr = self->macaddr;
> +       }
>         self->func = func;
> +       if (self->is_xr819) {
> +               /* Disabling the function leaves the HIF in queue mode. Reset
> +                * the single-function XR819 before starting another download.
> +                */
> +               sdio_claim_host(func);
> +               status = mmc_hw_reset(func->card);
> +               sdio_release_host(func);
> +               if (status)
> +                       goto free_self;
> +       }
>         sdio_set_drvdata(func, self);
>         sdio_claim_host(func);
>         status = sdio_enable_func(func);
> @@ -335,16 +403,19 @@ static int cw1200_sdio_probe(struct sdio_func *func,
>         if (status)
>                 goto clear_drvdata;
>
> +       if (self->is_xr819) {
> +               sdio_claim_host(func);
> +               status = sdio_set_block_size(func, SDIO_BLOCK_SIZE);
> +               sdio_release_host(func);
> +               if (status)
> +                       goto disable_func;
> +       }
> +
>         status = cw1200_sdio_irq_subscribe(self);
>         if (status)
>                 goto disable_func;
>
> -       status = cw1200_core_probe(&cw1200_sdio_hwbus_ops,
> -                                  self, &func->dev, &self->core,
> -                                  self->pdata->ref_clk,
> -                                  self->pdata->macaddr,
> -                                  self->pdata->sdd_file,
> -                                  self->pdata->have_5ghz);
> +       status = cw1200_sdio_core_probe(self, func);
>         if (!status)
>                 return 0;
>
> @@ -355,6 +426,7 @@ static int cw1200_sdio_probe(struct sdio_func *func,
>         sdio_release_host(func);
>  clear_drvdata:
>         sdio_set_drvdata(func, NULL);
> +free_self:
>         kfree(self);
>         return status;
>  }
> @@ -416,11 +488,12 @@ static struct sdio_driver sdio_driver = {
>         .id_table       = cw1200_sdio_ids,
>         .probe          = cw1200_sdio_probe,
>         .remove         = cw1200_sdio_disconnect,
> -#ifdef CONFIG_PM
>         .drv = {
> +#ifdef CONFIG_PM
>                 .pm = &cw1200_pm_ops,
> -       }
>  #endif
> +               .of_match_table = cw1200_sdio_of_match,
> +       },
>  };
>
>  /* Init Module function -> Called by insmod */
> diff --git a/include/linux/mmc/sdio_ids.h b/include/linux/mmc/sdio_ids.h
> index dfffda3d8002..35789be747a5 100644
> --- a/include/linux/mmc/sdio_ids.h
> +++ b/include/linux/mmc/sdio_ids.h
> @@ -27,6 +27,7 @@
>
>  #define SDIO_VENDOR_ID_STE                     0x0020
>  #define SDIO_DEVICE_ID_STE_CW1200              0x2280
> +#define SDIO_DEVICE_ID_STE_XR819               0x2281
>
>  #define SDIO_VENDOR_ID_INTEL                   0x0089
>  #define SDIO_DEVICE_ID_INTEL_IWMC3200WIMAX     0x1402
> --
> 2.56.0
>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH wireless-next v2 00/12] wifi: cw1200: add XRadio XR819 support
  2026-12-01  8:39 [PATCH wireless-next v2 00/12] wifi: cw1200: add XRadio XR819 support Arthur Heymans
                   ` (11 preceding siblings ...)
  2026-12-01  8:39 ` [PATCH wireless-next v2 12/12] MAINTAINERS: add myself for the cw1200 driver Arthur Heymans
@ 2026-12-01 16:07 ` Pablo Mazzini
  12 siblings, 0 replies; 17+ messages in thread
From: Pablo Mazzini @ 2026-12-01 16:07 UTC (permalink / raw)
  To: Arthur Heymans
  Cc: Pablo Mazzini, linux-wireless, Johannes Berg, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, devicetree, Ulf Hansson,
	linux-mmc, Solomon Peachy, linux-kernel

On Tue, Dec 1, 2026 at 9:39 AM Arthur Heymans <arthur@aheymans.xyz> wrote:
> The vendor firmware is not redistributable, and it speaks a dialect of
> WSM that cw1200 does not: it reads bits 6-7 of the message ID as an
> interface number where cw1200 puts a link ID,

cw1200 only uses non-zero link IDs in AP mode. In station mode these
bits are 0, which is interface 0 for the vendor firmware.

[...]
> It is licensed MIT OR Apache-2.0 and builds the three files the driver
> requests, xr819/boot_xr819.bin, xr819/fw_xr819.bin and
> xr819/sdd_xr819.bin (this one is pure calibration data).

These are the names the vendor firmware already has in Armbian and
other distributions, so on those systems the driver loads the vendor
firmware, which then asserts on the first WSM_SWITCH_CHANNEL_REQ.
Could the open firmware use different names?

My series "[PATCH wireless-next 0/4] wifi: cw1200: add XRadio XR819
support" from Nov 2 handles that, and runs the vendor firmware in
station mode.

Thanks,
Pablo

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2026-12-01 16:08 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01  8:39 [PATCH wireless-next v2 00/12] wifi: cw1200: add XRadio XR819 support Arthur Heymans
2026-12-01  8:39 ` [PATCH wireless-next v2 01/12] wifi: cw1200: avoid removing the debugfs directory twice Arthur Heymans
2026-12-01  8:39 ` [PATCH wireless-next v2 02/12] wifi: cw1200: check SDD element lengths before reading them Arthur Heymans
2026-12-01  8:39 ` [PATCH wireless-next v2 03/12] wifi: cw1200: bounce SDIO transfers that use stack buffers Arthur Heymans
2026-12-01  8:39 ` [PATCH wireless-next v2 04/12] wifi: cw1200: unwind GPIO interrupt setup on error Arthur Heymans
2026-12-01  8:39 ` [PATCH wireless-next v2 05/12] wifi: cw1200: unregister from mac80211 before freeing the interrupt Arthur Heymans
2026-12-01  8:39 ` [PATCH wireless-next v2 06/12] dt-bindings: vendor-prefixes: add XRadio Arthur Heymans
2026-12-01  8:39 ` [PATCH wireless-next v2 07/12] dt-bindings: net: wireless: add XRadio XR819 Arthur Heymans
2026-12-01  8:39 ` [PATCH wireless-next v2 08/12] wifi: cw1200: load the XR819 bootloader into SRAM Arthur Heymans
2026-12-01  8:39 ` [PATCH wireless-next v2 09/12] wifi: cw1200: copy platform data into per-device storage Arthur Heymans
2026-12-01  8:47   ` Ulf Hansson
2026-12-01  8:39 ` [PATCH wireless-next v2 10/12] wifi: cw1200: check sdio_enable_func() and IRQ subscribe errors Arthur Heymans
2026-12-01  8:47   ` Ulf Hansson
2026-12-01  8:39 ` [PATCH wireless-next v2 11/12] wifi: cw1200: add XR819 SDIO support Arthur Heymans
2026-12-01  8:48   ` Ulf Hansson
2026-12-01  8:39 ` [PATCH wireless-next v2 12/12] MAINTAINERS: add myself for the cw1200 driver Arthur Heymans
2026-12-01 16:07 ` [PATCH wireless-next v2 00/12] wifi: cw1200: add XRadio XR819 support Pablo Mazzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox