2020-03-07 08:55:44

by Ajay Singh

[permalink] [raw]
Subject: [PATCH v2 0/3] staging: wilc1000: handle DT binding documentation comments

From: Ajay Singh <[email protected]>

This patch series contains changes to handle DT binding documentation
related review comments. The changes were suggested during the full
driver review [1] & [2].
First submitting these patches to staging and later will include them
as part of the full driver review patch series.

Changes since v1:
- keep the bindings changes separate from code.
- only add binding to '/driver/staging/wilc1000'.
- remove redefines for common property.

[1]. https://patchwork.kernel.org/patch/11415897
[2]. https://patchwork.kernel.org/patch/11415901

Ajay Singh (3):
staging: wilc1000: use 'interrupts' property instead of 'irq-gpio'
staging: wilc1000: modified 'clock-names' and 'compatible' property
staging: wilc1000: updated DT binding documentation

.../wilc1000/microchip,wilc1000,sdio.yaml | 68 ------------------
.../wilc1000/microchip,wilc1000,spi.yaml | 61 ----------------
.../staging/wilc1000/microchip,wilc1000.yaml | 72 +++++++++++++++++++
drivers/staging/wilc1000/netdev.c | 24 +++----
drivers/staging/wilc1000/netdev.h | 1 -
drivers/staging/wilc1000/sdio.c | 35 ++++-----
drivers/staging/wilc1000/spi.c | 17 +----
drivers/staging/wilc1000/wlan.h | 1 -
8 files changed, 96 insertions(+), 183 deletions(-)
delete mode 100644 drivers/staging/wilc1000/microchip,wilc1000,sdio.yaml
delete mode 100644 drivers/staging/wilc1000/microchip,wilc1000,spi.yaml
create mode 100644 drivers/staging/wilc1000/microchip,wilc1000.yaml

--
2.24.0


2020-03-07 08:55:47

by Ajay Singh

[permalink] [raw]
Subject: [PATCH v2 1/3] staging: wilc1000: use 'interrupts' property instead of 'irq-gpio'

From: Ajay Singh <[email protected]>

Make use of 'interrupts' property instead of using gpio for handling
the interrupt as suggested in [1].

[1]. https://lore.kernel.org/linux-wireless/20200303015558.GA6876@bogus

Signed-off-by: Ajay Singh <[email protected]>
---
drivers/staging/wilc1000/netdev.c | 24 ++++++++----------------
drivers/staging/wilc1000/netdev.h | 1 -
drivers/staging/wilc1000/sdio.c | 31 ++++++++++++-------------------
drivers/staging/wilc1000/spi.c | 15 +--------------
drivers/staging/wilc1000/wlan.h | 1 -
5 files changed, 21 insertions(+), 51 deletions(-)

diff --git a/drivers/staging/wilc1000/netdev.c b/drivers/staging/wilc1000/netdev.c
index 045f5cdfdca0..a61c1a7aefa8 100644
--- a/drivers/staging/wilc1000/netdev.c
+++ b/drivers/staging/wilc1000/netdev.c
@@ -46,29 +46,21 @@ static irqreturn_t isr_bh_routine(int irq, void *userdata)

static int init_irq(struct net_device *dev)
{
- int ret = 0;
struct wilc_vif *vif = netdev_priv(dev);
struct wilc *wl = vif->wilc;
-
- ret = gpiod_direction_input(wl->gpio_irq);
- if (ret) {
- netdev_err(dev, "could not obtain gpio for WILC_INTR\n");
- return ret;
- }
-
- wl->dev_irq_num = gpiod_to_irq(wl->gpio_irq);
+ int ret;

ret = request_threaded_irq(wl->dev_irq_num, isr_uh_routine,
isr_bh_routine,
IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
"WILC_IRQ", dev);
- if (ret < 0)
- netdev_err(dev, "Failed to request IRQ\n");
- else
- netdev_dbg(dev, "IRQ request succeeded IRQ-NUM= %d\n",
- wl->dev_irq_num);
+ if (ret) {
+ netdev_err(dev, "Failed to request IRQ [%d]\n", ret);
+ return ret;
+ }
+ netdev_dbg(dev, "IRQ request succeeded IRQ-NUM= %d\n", wl->dev_irq_num);

- return ret;
+ return 0;
}

static void deinit_irq(struct net_device *dev)
@@ -501,7 +493,7 @@ static int wilc_wlan_initialize(struct net_device *dev, struct wilc_vif *vif)
if (ret)
goto fail_wilc_wlan;

- if (wl->gpio_irq && init_irq(dev)) {
+ if (wl->dev_irq_num && init_irq(dev)) {
ret = -EIO;
goto fail_threads;
}
diff --git a/drivers/staging/wilc1000/netdev.h b/drivers/staging/wilc1000/netdev.h
index e3689e2a4abb..61cbec674a62 100644
--- a/drivers/staging/wilc1000/netdev.h
+++ b/drivers/staging/wilc1000/netdev.h
@@ -209,7 +209,6 @@ struct wilc {
const struct wilc_hif_func *hif_func;
int io_type;
s8 mac_status;
- struct gpio_desc *gpio_irq;
struct clk *rtc_clk;
bool initialized;
int dev_irq_num;
diff --git a/drivers/staging/wilc1000/sdio.c b/drivers/staging/wilc1000/sdio.c
index 2301e90c21ca..44b426874c1b 100644
--- a/drivers/staging/wilc1000/sdio.c
+++ b/drivers/staging/wilc1000/sdio.c
@@ -8,6 +8,7 @@
#include <linux/mmc/sdio_func.h>
#include <linux/mmc/host.h>
#include <linux/mmc/sdio.h>
+#include <linux/of_irq.h>

#include "netdev.h"
#include "cfg80211.h"
@@ -122,33 +123,32 @@ static int wilc_sdio_probe(struct sdio_func *func,
{
struct wilc *wilc;
int ret;
- struct gpio_desc *gpio = NULL;
struct wilc_sdio *sdio_priv;

sdio_priv = kzalloc(sizeof(*sdio_priv), GFP_KERNEL);
if (!sdio_priv)
return -ENOMEM;

- if (IS_ENABLED(CONFIG_WILC1000_HW_OOB_INTR)) {
- gpio = gpiod_get(&func->dev, "irq", GPIOD_IN);
- if (IS_ERR(gpio)) {
- /* get the GPIO descriptor from hardcode GPIO number */
- gpio = gpio_to_desc(GPIO_NUM);
- if (!gpio)
- dev_err(&func->dev, "failed to get irq gpio\n");
- }
- }
-
ret = wilc_cfg80211_init(&wilc, &func->dev, WILC_HIF_SDIO,
&wilc_hif_sdio);
if (ret) {
kfree(sdio_priv);
return ret;
}
+
+ if (IS_ENABLED(CONFIG_WILC1000_HW_OOB_INTR)) {
+ struct device_node *np = func->card->dev.of_node;
+ int irq_num = of_irq_get(np, 0);
+
+ if (irq_num > 0) {
+ wilc->dev_irq_num = irq_num;
+ sdio_priv->irq_gpio = true;
+ }
+ }
+
sdio_set_drvdata(func, wilc);
wilc->bus_data = sdio_priv;
wilc->dev = &func->dev;
- wilc->gpio_irq = gpio;

wilc->rtc_clk = devm_clk_get(&func->card->dev, "rtc_clk");
if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER)
@@ -164,10 +164,6 @@ static void wilc_sdio_remove(struct sdio_func *func)
{
struct wilc *wilc = sdio_get_drvdata(func);

- /* free the GPIO in module remove */
- if (wilc->gpio_irq)
- gpiod_put(wilc->gpio_irq);
-
if (!IS_ERR(wilc->rtc_clk))
clk_disable_unprepare(wilc->rtc_clk);

@@ -592,9 +588,6 @@ static int wilc_sdio_init(struct wilc *wilc, bool resume)
int loop, ret;
u32 chipid;

- if (!resume)
- sdio_priv->irq_gpio = wilc->dev_irq_num;
-
/**
* function 0 csa enable
**/
diff --git a/drivers/staging/wilc1000/spi.c b/drivers/staging/wilc1000/spi.c
index dfd25df75780..852f318a86f0 100644
--- a/drivers/staging/wilc1000/spi.c
+++ b/drivers/staging/wilc1000/spi.c
@@ -151,21 +151,12 @@ static int wilc_bus_probe(struct spi_device *spi)
{
int ret;
struct wilc *wilc;
- struct gpio_desc *gpio;
struct wilc_spi *spi_priv;

spi_priv = kzalloc(sizeof(*spi_priv), GFP_KERNEL);
if (!spi_priv)
return -ENOMEM;

- gpio = gpiod_get(&spi->dev, "irq", GPIOD_IN);
- if (IS_ERR(gpio)) {
- /* get the GPIO descriptor from hardcode GPIO number */
- gpio = gpio_to_desc(GPIO_NUM);
- if (!gpio)
- dev_err(&spi->dev, "failed to get the irq gpio\n");
- }
-
ret = wilc_cfg80211_init(&wilc, &spi->dev, WILC_HIF_SPI, &wilc_hif_spi);
if (ret) {
kfree(spi_priv);
@@ -175,7 +166,7 @@ static int wilc_bus_probe(struct spi_device *spi)
spi_set_drvdata(spi, wilc);
wilc->dev = &spi->dev;
wilc->bus_data = spi_priv;
- wilc->gpio_irq = gpio;
+ wilc->dev_irq_num = spi->irq;

wilc->rtc_clk = devm_clk_get(&spi->dev, "rtc_clk");
if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER)
@@ -190,10 +181,6 @@ static int wilc_bus_remove(struct spi_device *spi)
{
struct wilc *wilc = spi_get_drvdata(spi);

- /* free the GPIO in module remove */
- if (wilc->gpio_irq)
- gpiod_put(wilc->gpio_irq);
-
if (!IS_ERR(wilc->rtc_clk))
clk_disable_unprepare(wilc->rtc_clk);

diff --git a/drivers/staging/wilc1000/wlan.h b/drivers/staging/wilc1000/wlan.h
index 5999c5490ea5..7689569cd82f 100644
--- a/drivers/staging/wilc1000/wlan.h
+++ b/drivers/staging/wilc1000/wlan.h
@@ -206,7 +206,6 @@
#define WILC_TX_BUFF_SIZE (64 * 1024)

#define MODALIAS "WILC_SPI"
-#define GPIO_NUM 0x44

#define WILC_PKT_HDR_CONFIG_FIELD BIT(31)
#define WILC_PKT_HDR_OFFSET_FIELD GENMASK(30, 22)
--
2.24.0

2020-03-07 08:55:59

by Ajay Singh

[permalink] [raw]
Subject: [PATCH v2 2/3] staging: wilc1000: modified 'clock-names' and 'compatible' property

From: Ajay Singh <[email protected]>

Modified the 'clock-names' property by removing '_clk' from its name and
remove '_spi/sdio' from 'compatible' string.

Signed-off-by: Ajay Singh <[email protected]>
---
drivers/staging/wilc1000/sdio.c | 4 ++--
drivers/staging/wilc1000/spi.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/wilc1000/sdio.c b/drivers/staging/wilc1000/sdio.c
index 44b426874c1b..36eb589263bf 100644
--- a/drivers/staging/wilc1000/sdio.c
+++ b/drivers/staging/wilc1000/sdio.c
@@ -150,7 +150,7 @@ static int wilc_sdio_probe(struct sdio_func *func,
wilc->bus_data = sdio_priv;
wilc->dev = &func->dev;

- wilc->rtc_clk = devm_clk_get(&func->card->dev, "rtc_clk");
+ wilc->rtc_clk = devm_clk_get(&func->card->dev, "rtc");
if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER)
return -EPROBE_DEFER;
else if (!IS_ERR(wilc->rtc_clk))
@@ -997,7 +997,7 @@ static int wilc_sdio_resume(struct device *dev)
}

static const struct of_device_id wilc_of_match[] = {
- { .compatible = "microchip,wilc1000-sdio", },
+ { .compatible = "microchip,wilc1000", },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, wilc_of_match);
diff --git a/drivers/staging/wilc1000/spi.c b/drivers/staging/wilc1000/spi.c
index 852f318a86f0..d77582c55326 100644
--- a/drivers/staging/wilc1000/spi.c
+++ b/drivers/staging/wilc1000/spi.c
@@ -189,7 +189,7 @@ static int wilc_bus_remove(struct spi_device *spi)
}

static const struct of_device_id wilc_of_match[] = {
- { .compatible = "microchip,wilc1000-spi", },
+ { .compatible = "microchip,wilc1000", },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, wilc_of_match);
--
2.24.0

2020-03-07 08:56:02

by Ajay Singh

[permalink] [raw]
Subject: [PATCH v2 3/3] staging: wilc1000: updated DT binding documentation

From: Ajay Singh <[email protected]>

Merged the DT binding documentation of SDIO and SPI into a single file.
Removed documentation for some of the properties which are not required
and handled review comments received in [1] & [2].

[1]. https://lore.kernel.org/linux-wireless/20200303020230.GA15543@bogus
[2]. https://lore.kernel.org/linux-wireless/20200303015558.GA6876@bogus

Signed-off-by: Ajay Singh <[email protected]>
---
.../wilc1000/microchip,wilc1000,sdio.yaml | 68 ------------------
.../wilc1000/microchip,wilc1000,spi.yaml | 61 ----------------
.../staging/wilc1000/microchip,wilc1000.yaml | 72 +++++++++++++++++++
3 files changed, 72 insertions(+), 129 deletions(-)
delete mode 100644 drivers/staging/wilc1000/microchip,wilc1000,sdio.yaml
delete mode 100644 drivers/staging/wilc1000/microchip,wilc1000,spi.yaml
create mode 100644 drivers/staging/wilc1000/microchip,wilc1000.yaml

diff --git a/drivers/staging/wilc1000/microchip,wilc1000,sdio.yaml b/drivers/staging/wilc1000/microchip,wilc1000,sdio.yaml
deleted file mode 100644
index b338f569f7e2..000000000000
--- a/drivers/staging/wilc1000/microchip,wilc1000,sdio.yaml
+++ /dev/null
@@ -1,68 +0,0 @@
-# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
-%YAML 1.2
----
-$id: http://devicetree.org/schemas/net/wireless/microchip,wilc1000,sdio.yaml#
-$schema: http://devicetree.org/meta-schemas/core.yaml#
-
-title: Microchip WILC wireless SDIO devicetree bindings
-
-maintainers:
- - Adham Abozaeid <[email protected]>
- - Ajay Singh <[email protected]>
-
-description:
- The wilc1000 chips can be connected via SDIO. The node is used to
- specify child node to the SDIO controller that connects the device
- to the system.
-
-properties:
- compatible:
- const: microchip,wilc1000-sdio
-
- irq-gpios:
- description: The GPIO phandle connect to a host IRQ.
- maxItems: 1
-
- reg:
- description: Slot ID used in the controller.
- maxItems: 1
-
- clocks:
- description: phandle to the clock connected on rtc clock line.
- maxItems: 1
-
- bus-width:
- description: The number of data lines wired up the slot.
- allOf:
- - $ref: /schemas/types.yaml#/definitions/uint32
- - enum: [1, 4, 8]
- - default: 1
-
-required:
- - compatible
- - irq-gpios
- - reg
-
-examples:
- - |
- mmc1: mmc@fc000000 {
- #address-cells = <1>;
- #size-cells = <0>;
- pinctrl-names = "default";
- pinctrl-0 = <&pinctrl_mmc1_clk_cmd_dat0 &pinctrl_mmc1_dat1_3>;
- non-removable;
- vmmc-supply = <&vcc_mmc1_reg>;
- vqmmc-supply = <&vcc_3v3_reg>;
- status = "okay";
- wilc_sdio@0 {
- compatible = "microchip,wilc1000-sdio";
- irq-gpios = <&pioC 27 0>;
- reg = <0>;
- clocks = <&pck1>;
- clock-names = "rtc_clk";
- assigned-clocks = <&pck1>;
- assigned-clock-rates = <32768>;
- status = "okay";
- bus-width = <4>;
- };
- };
diff --git a/drivers/staging/wilc1000/microchip,wilc1000,spi.yaml b/drivers/staging/wilc1000/microchip,wilc1000,spi.yaml
deleted file mode 100644
index cc8ed64ce627..000000000000
--- a/drivers/staging/wilc1000/microchip,wilc1000,spi.yaml
+++ /dev/null
@@ -1,61 +0,0 @@
-# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
-%YAML 1.2
----
-$id: http://devicetree.org/schemas/net/wireless/microchip,wilc1000,spi.yaml#
-$schema: http://devicetree.org/meta-schemas/core.yaml#
-
-title: Microchip WILC wireless SPI devicetree bindings
-
-maintainers:
- - Adham Abozaeid <[email protected]>
- - Ajay Singh <[email protected]>
-
-description:
- The wilc1000 chips can be connected via SPI. This document describes
- the binding for the SPI connected module.
-
-properties:
- compatible:
- const: microchip,wilc1000-spi
-
- spi-max-frequency:
- description: Maximum SPI clocking speed of device in Hz.
- maxItems: 1
-
- reg:
- description: Chip select address of device.
- maxItems: 1
-
- irq-gpios:
- description: The GPIO phandle connect to a host IRQ.
- maxItems: 1
-
- clocks:
- description: phandle to the clock connected on rtc clock line.
- maxItems: 1
-
-required:
- - compatible
- - spi-max-frequency
- - reg
- - irq-gpios
-
-examples:
- - |
- spi1: spi@fc018000 {
- #address-cells = <1>;
- #size-cells = <0>;
- cs-gpios = <&pioB 21 0>;
- status = "okay";
- wilc_spi@0 {
- compatible = "microchip,wilc1000-spi";
- spi-max-frequency = <48000000>;
- reg = <0>;
- irq-gpios = <&pioC 27 0>;
- clocks = <&pck1>;
- clock-names = "rtc_clk";
- assigned-clocks = <&pck1>;
- assigned-clock-rates = <32768>;
- status = "okay";
- };
- };
diff --git a/drivers/staging/wilc1000/microchip,wilc1000.yaml b/drivers/staging/wilc1000/microchip,wilc1000.yaml
new file mode 100644
index 000000000000..bc6cc5d3f347
--- /dev/null
+++ b/drivers/staging/wilc1000/microchip,wilc1000.yaml
@@ -0,0 +1,72 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/wireless/microchip,wilc1000.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Microchip WILC wireless devicetree bindings
+
+maintainers:
+ - Adham Abozaeid <[email protected]>
+ - Ajay Singh <[email protected]>
+
+description:
+ The wilc1000 chips can be connected via SPI or SDIO. This document
+ describes the binding to connect wilc devices.
+
+properties:
+ compatible:
+ const: microchip,wilc1000
+
+ spi-max-frequency: true
+
+ interrupts:
+ maxItems: 1
+
+ clocks:
+ description: phandle to the clock connected on rtc clock line.
+ maxItems: 1
+
+ clock-names:
+ const: rtc
+
+required:
+ - compatible
+ - interrupts
+
+examples:
+ - |
+ spi1: spi@fc018000 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ cs-gpios = <&pioB 21 0>;
+ wifi@0 {
+ compatible = "microchip,wilc1000";
+ spi-max-frequency = <48000000>;
+ reg = <0>;
+ interrupt-parent = <&pioC>;
+ interrupts = <27 0>;
+ clocks = <&pck1>;
+ clock-names = "rtc";
+ };
+ };
+
+ - |
+ mmc1: mmc@fc000000 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_mmc1_clk_cmd_dat0 &pinctrl_mmc1_dat1_3>;
+ non-removable;
+ vmmc-supply = <&vcc_mmc1_reg>;
+ vqmmc-supply = <&vcc_3v3_reg>;
+ bus-width = <4>;
+ wifi@0 {
+ compatible = "microchip,wilc1000";
+ reg = <0>;
+ interrupt-parent = <&pioC>;
+ interrupts = <27 0>;
+ clocks = <&pck1>;
+ clock-names = "rtc";
+ };
+ };
--
2.24.0