Linux-Wireless Archive mirror
 help / color / mirror / Atom feed
From: Jerome Pouiller <Jerome.Pouiller@silabs.com>
To: devel@driverdev.osuosl.org, linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Kalle Valo" <kvalo@codeaurora.org>,
	"David S . Miller" <davem@davemloft.net>,
	"Jérôme Pouiller" <jerome.pouiller@silabs.com>
Subject: [PATCH 27/31] staging: wfx: map 'compatible' attribute with board name
Date: Thu, 13 Jan 2022 09:55:20 +0100	[thread overview]
Message-ID: <20220113085524.1110708-28-Jerome.Pouiller@silabs.com> (raw)
In-Reply-To: <20220113085524.1110708-1-Jerome.Pouiller@silabs.com>

From: Jérôme Pouiller <jerome.pouiller@silabs.com>

"WF200" only designates the chip. To make a WiFi board, the chip must be
associated with an antenna. The antenna configuration is located in
separate files (aka PDS files in Silabs wording). Currently, user has to
write in his DT something like:

    compatible = "silabs,wf200";
    config = "brd4001a.pds";

It is far better to embed a list of known boards (chip + antenna) in the
driver. So the user just have to declare:

    compatible = "silabs,brd4001a";

This patch add the configurations for the evaluation boards sold by
Silabs. To provide a full plug-and-play experience, the associated PDS
files[1] will be available in linux-firmware.

This patch does not break compatibility with existing setups.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
---
 .../bindings/net/wireless/silabs,wfx.yaml     | 11 ++--
 drivers/staging/wfx/bus_sdio.c                | 35 +++++++++++--
 drivers/staging/wfx/bus_spi.c                 | 52 ++++++++++++++++---
 drivers/staging/wfx/main.h                    |  1 +
 4 files changed, 83 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/wfx/Documentation/devicetree/bindings/net/wireless/silabs,wfx.yaml b/drivers/staging/wfx/Documentation/devicetree/bindings/net/wireless/silabs,wfx.yaml
index 510edd12ed19..44aeba0f7276 100644
--- a/drivers/staging/wfx/Documentation/devicetree/bindings/net/wireless/silabs,wfx.yaml
+++ b/drivers/staging/wfx/Documentation/devicetree/bindings/net/wireless/silabs,wfx.yaml
@@ -39,7 +39,12 @@ description:
 
 properties:
   compatible:
-    const: silabs,wf200
+    items:
+      - enum:
+          - silabs,brd4001a # WGM160P Evaluation Board
+          - silabs,brd8022a # WF200 Evaluation Board
+          - silabs,brd8023a # WFM200 Evaluation Board
+      - const: silabs,wf200 # Chip alone without antenna
   reg:
     description:
       When used on SDIO bus, <reg> must be set to 1. When used on SPI bus, it is
@@ -87,7 +92,7 @@ examples:
         #size-cells = <0>;
 
         wfx@0 {
-            compatible = "silabs,wf200";
+            compatible = "silabs,brd8022a", "silabs,wf200";
             pinctrl-names = "default";
             pinctrl-0 = <&wfx_irq &wfx_gpios>;
             reg = <0>;
@@ -115,7 +120,7 @@ examples:
         #size-cells = <0>;
 
         mmc@1 {
-            compatible = "silabs,wf200";
+            compatible = "silabs,brd8022a", "silabs,wf200";
             pinctrl-names = "default";
             pinctrl-0 = <&wfx_wakeup>;
             reg = <1>;
diff --git a/drivers/staging/wfx/bus_sdio.c b/drivers/staging/wfx/bus_sdio.c
index 5c45ccd85a7d..361585763f30 100644
--- a/drivers/staging/wfx/bus_sdio.c
+++ b/drivers/staging/wfx/bus_sdio.c
@@ -10,6 +10,7 @@
 #include <linux/mmc/sdio_func.h>
 #include <linux/mmc/card.h>
 #include <linux/interrupt.h>
+#include <linux/of_device.h>
 #include <linux/of_irq.h>
 #include <linux/irq.h>
 #include <linux/align.h>
@@ -20,7 +21,28 @@
 #include "main.h"
 #include "bh.h"
 
-static const struct wfx_platform_data wfx_sdio_pdata = {
+static const struct wfx_platform_data pdata_wf200 = {
+	.file_fw = "wfm_wf200",
+	.file_pds = "wf200.pds",
+};
+
+static const struct wfx_platform_data pdata_brd4001a = {
+	.file_fw = "wfm_wf200",
+	.file_pds = "brd4001a.pds",
+};
+
+static const struct wfx_platform_data pdata_brd8022a = {
+	.file_fw = "wfm_wf200",
+	.file_pds = "brd8022a.pds",
+};
+
+static const struct wfx_platform_data pdata_brd8023a = {
+	.file_fw = "wfm_wf200",
+	.file_pds = "brd8023a.pds",
+};
+
+/* Legacy DT don't use it */
+static const struct wfx_platform_data pdata_wfx_sdio = {
 	.file_fw = "wfm_wf200",
 	.file_pds = "wf200.pds",
 };
@@ -167,14 +189,18 @@ static const struct wfx_hwbus_ops wfx_sdio_hwbus_ops = {
 };
 
 static const struct of_device_id wfx_sdio_of_match[] = {
-	{ .compatible = "silabs,wfx-sdio" },
-	{ .compatible = "silabs,wf200" },
+	{ .compatible = "silabs,wf200",    .data = &pdata_wf200 },
+	{ .compatible = "silabs,brd4001a", .data = &pdata_brd4001a },
+	{ .compatible = "silabs,brd8022a", .data = &pdata_brd8022a },
+	{ .compatible = "silabs,brd8023a", .data = &pdata_brd8023a },
+	{ .compatible = "silabs,wfx-sdio", .data = &pdata_wfx_sdio },
 	{ },
 };
 MODULE_DEVICE_TABLE(of, wfx_sdio_of_match);
 
 static int wfx_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id)
 {
+	const struct wfx_platform_data *pdata = of_device_get_match_data(&func->dev);
 	struct device_node *np = func->dev.of_node;
 	struct wfx_sdio_priv *bus;
 	int ret;
@@ -216,8 +242,7 @@ static int wfx_sdio_probe(struct sdio_func *func, const struct sdio_device_id *i
 	if (ret)
 		return ret;
 
-	bus->core = wfx_init_common(&func->dev, &wfx_sdio_pdata,
-				    &wfx_sdio_hwbus_ops, bus);
+	bus->core = wfx_init_common(&func->dev, pdata, &wfx_sdio_hwbus_ops, bus);
 	if (!bus->core) {
 		ret = -EIO;
 		goto sdio_release;
diff --git a/drivers/staging/wfx/bus_spi.c b/drivers/staging/wfx/bus_spi.c
index 417bb74c88b9..9aa52d76cdda 100644
--- a/drivers/staging/wfx/bus_spi.c
+++ b/drivers/staging/wfx/bus_spi.c
@@ -23,12 +23,36 @@
 #define SET_WRITE 0x7FFF        /* usage: and operation */
 #define SET_READ 0x8000         /* usage: or operation */
 
-#define WFX_RESET_INVERTED 1
+static const struct wfx_platform_data pdata_wf200 = {
+	.file_fw = "wfm_wf200",
+	.file_pds = "wf200.pds",
+	.use_rising_clk = true,
+};
+
+static const struct wfx_platform_data pdata_brd4001a = {
+	.file_fw = "wfm_wf200",
+	.file_pds = "brd4001a.pds",
+	.use_rising_clk = true,
+};
+
+static const struct wfx_platform_data pdata_brd8022a = {
+	.file_fw = "wfm_wf200",
+	.file_pds = "brd8022a.pds",
+	.use_rising_clk = true,
+};
+
+static const struct wfx_platform_data pdata_brd8023a = {
+	.file_fw = "wfm_wf200",
+	.file_pds = "brd8023a.pds",
+	.use_rising_clk = true,
+};
 
-static const struct wfx_platform_data wfx_spi_pdata = {
+/* Legacy DT don't use it */
+static const struct wfx_platform_data pdata_wfx_spi = {
 	.file_fw = "wfm_wf200",
 	.file_pds = "wf200.pds",
 	.use_rising_clk = true,
+	.reset_inverted = true,
 };
 
 struct wfx_spi_priv {
@@ -175,6 +199,7 @@ static const struct wfx_hwbus_ops wfx_spi_hwbus_ops = {
 
 static int wfx_spi_probe(struct spi_device *func)
 {
+	struct wfx_platform_data *pdata;
 	struct wfx_spi_priv *bus;
 	int ret;
 
@@ -183,6 +208,12 @@ static int wfx_spi_probe(struct spi_device *func)
 	ret = spi_setup(func);
 	if (ret)
 		return ret;
+	pdata = (struct wfx_platform_data *)spi_get_device_id(func)->driver_data;
+	if (!pdata) {
+		dev_err(&func->dev, "unable to retrieve driver data (please report)\n");
+		return -ENODEV;
+	}
+
 	/* Trace below is also displayed by spi_setup() if compiled with DEBUG */
 	dev_dbg(&func->dev, "SPI params: CS=%d, mode=%d bits/word=%d speed=%d\n",
 		func->chip_select, func->mode, func->bits_per_word, func->max_speed_hz);
@@ -206,7 +237,7 @@ static int wfx_spi_probe(struct spi_device *func)
 		dev_warn(&func->dev, "gpio reset is not defined, trying to load firmware anyway\n");
 	} else {
 		gpiod_set_consumer_name(bus->gpio_reset, "wfx reset");
-		if (spi_get_device_id(func)->driver_data & WFX_RESET_INVERTED)
+		if (pdata->reset_inverted)
 			gpiod_toggle_active_low(bus->gpio_reset);
 		gpiod_set_value_cansleep(bus->gpio_reset, 1);
 		usleep_range(100, 150);
@@ -214,8 +245,7 @@ static int wfx_spi_probe(struct spi_device *func)
 		usleep_range(2000, 2500);
 	}
 
-	bus->core = wfx_init_common(&func->dev, &wfx_spi_pdata,
-				    &wfx_spi_hwbus_ops, bus);
+	bus->core = wfx_init_common(&func->dev, pdata, &wfx_spi_hwbus_ops, bus);
 	if (!bus->core)
 		return -EIO;
 
@@ -235,16 +265,22 @@ static int wfx_spi_remove(struct spi_device *func)
  * stripped.
  */
 static const struct spi_device_id wfx_spi_id[] = {
-	{ "wfx-spi", WFX_RESET_INVERTED },
-	{ "wf200", 0 },
+	{ "wf200",    (kernel_ulong_t)&pdata_wf200 },
+	{ "brd4001a", (kernel_ulong_t)&pdata_brd4001a },
+	{ "brd8022a", (kernel_ulong_t)&pdata_brd8022a },
+	{ "brd8023a", (kernel_ulong_t)&pdata_brd8023a },
+	{ "wfx-spi",  (kernel_ulong_t)&pdata_wfx_spi },
 	{ },
 };
 MODULE_DEVICE_TABLE(spi, wfx_spi_id);
 
 #ifdef CONFIG_OF
 static const struct of_device_id wfx_spi_of_match[] = {
-	{ .compatible = "silabs,wfx-spi", .data = (void *)WFX_RESET_INVERTED },
 	{ .compatible = "silabs,wf200" },
+	{ .compatible = "silabs,brd4001a" },
+	{ .compatible = "silabs,brd8022a" },
+	{ .compatible = "silabs,brd8023a" },
+	{ .compatible = "silabs,wfx-spi" },
 	{ },
 };
 MODULE_DEVICE_TABLE(of, wfx_spi_of_match);
diff --git a/drivers/staging/wfx/main.h b/drivers/staging/wfx/main.h
index 68c665307153..fcd26b24519e 100644
--- a/drivers/staging/wfx/main.h
+++ b/drivers/staging/wfx/main.h
@@ -23,6 +23,7 @@ struct wfx_platform_data {
 	const char *file_fw;
 	const char *file_pds;
 	struct gpio_desc *gpio_wakeup;
+	bool reset_inverted;
 	/* if true HIF D_out is sampled on the rising edge of the clock (intended to be used in
 	 * 50Mhz SDIO)
 	 */
-- 
2.34.1


  parent reply	other threads:[~2022-01-13  8:58 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-13  8:54 [PATCH 00/31] staging/wfx: apply suggestions from the linux-wireless review Jerome Pouiller
2022-01-13  8:54 ` [PATCH 01/31] staging: wfx: fix Makefile and Kconfig licenses Jerome Pouiller
2022-01-13  8:54 ` [PATCH 02/31] staging: wfx: fix HIF API license Jerome Pouiller
2022-01-13 11:50   ` Kalle Valo
2022-01-13 12:16     ` Jérôme Pouiller
2022-01-13  8:54 ` [PATCH 03/31] staging: wfx: fix missing headers Jerome Pouiller
2022-01-13  8:54 ` [PATCH 04/31] staging: wfx: fix comment correctness Jerome Pouiller
2022-01-13  8:54 ` [PATCH 05/31] staging: wfx: explain uncommon Makefile statement Jerome Pouiller
2022-01-13  8:54 ` [PATCH 06/31] staging: wfx: remove unnecessary braces Jerome Pouiller
2022-01-13  8:55 ` [PATCH 07/31] staging: wfx: remove useless #ifdef Jerome Pouiller
2022-01-13  8:55 ` [PATCH 08/31] staging: wfx: use IS_ALIGNED() Jerome Pouiller
2022-01-13  8:55 ` [PATCH 09/31] staging: wfx: replace magic value by WFX_HIF_BUFFER_SIZE Jerome Pouiller
2022-01-13  8:55 ` [PATCH 10/31] stagigg: wfx: replace magic number by HIF_ID_IS_INDICATION Jerome Pouiller
2022-01-13  8:55 ` [PATCH 11/31] staging: wfx: preserve endianness of struct hif_ind_startup Jerome Pouiller
2022-01-13  8:55 ` [PATCH 12/31] staging: wfx: fix ambiguous function name Jerome Pouiller
2022-01-13  8:55 ` [PATCH 13/31] " Jerome Pouiller
2022-01-13  8:55 ` [PATCH 14/31] staging: wfx: prefix functions from hif_*.h with wfx_ Jerome Pouiller
2022-01-13  8:55 ` [PATCH 15/31] staging: wfx: prefix functions from hwio.h " Jerome Pouiller
2022-01-13  8:55 ` [PATCH 16/31] staging: wfx: prefix functions from debug.h " Jerome Pouiller
2022-01-13  8:55 ` [PATCH 17/31] staging: wfx: prefix tx_policy_is_equal() " Jerome Pouiller
2022-01-13  8:55 ` [PATCH 18/31] staging: wfx: prefix structs hif_* " Jerome Pouiller
2022-01-13  8:55 ` [PATCH 19/31] staging: wfx: prefix structs tx_policy and hwbus_ops " Jerome Pouiller
2022-01-13  8:55 ` [PATCH 20/31] staging: wfx: reformat code on 100 columns Jerome Pouiller
2022-01-13  8:55 ` [PATCH 21/31] staging: wfx: reformat comments " Jerome Pouiller
2022-01-13  8:55 ` [PATCH 22/31] staging: wfx: fix structs alignments Jerome Pouiller
2022-01-13  8:55 ` [PATCH 23/31] staging: wfx: use explicit labels for errors Jerome Pouiller
2022-01-13  8:55 ` [PATCH 24/31] staging: wfx: replace compiletime_assert() by BUILD_BUG_ON_MSG() Jerome Pouiller
2022-01-13  8:55 ` [PATCH 25/31] staging: wfx: do not display functions names in logs Jerome Pouiller
2022-01-13  8:55 ` [PATCH 26/31] staging: wfx: remove force_ps_timeout Jerome Pouiller
2022-01-13  8:55 ` Jerome Pouiller [this message]
2022-01-13  8:55 ` [PATCH 28/31] staging: wfx: fix firmware location Jerome Pouiller
2022-01-13  8:55 ` [PATCH 29/31] staging: wfx: drop legacy compatible values Jerome Pouiller
2022-01-13  8:55 ` [PATCH 30/31] staging: wfx: rename "config-file" DT attribute Jerome Pouiller
2022-01-13  8:55 ` [PATCH 31/31] staging: wfx: do not probe the device if not in the DT Jerome Pouiller

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=20220113085524.1110708-28-Jerome.Pouiller@silabs.com \
    --to=jerome.pouiller@silabs.com \
    --cc=davem@davemloft.net \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kvalo@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).