linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] staging: wilc1000: make use of descriptor-based interface for GPIO
@ 2018-07-20 12:01 Ajay Singh
  2018-07-20 12:01 ` [PATCH 1/4] staging: wilc1000: remove gpio parameter from wilc_netdev_init() Ajay Singh
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Ajay Singh @ 2018-07-20 12:01 UTC (permalink / raw)
  To: linux-wireless
  Cc: devel, gregkh, ganesh.krishna, venkateswara.kaja, aditya.shankar,
	adham.abozaeid, robh+dt, mark.rutland, linus.walleij, Ajay Singh

This patch series contains changes mainly related to make use of
descriptor-based interface instead of integer-based interface for GPIO.
Modified the compatible string to use 'microchip' instead of 'atmel' prefix.
Also added the DT binding reference file.

This patch is created on top of [1] patch series.

[1]. https://www.spinics.net/lists/linux-wireless/msg175360.html

Ajay Singh (4):
  staging: wilc1000: remove gpio parameter from wilc_netdev_init()
  staging: wilc1000: rename variable from 'gpio' to 'gpio_irq'
  staging: wilc1000: change compatible string from atmel to microchip
  staging: wilc1000: use descriptor-based interface for GPIO

 drivers/staging/wilc1000/TODO                      |  4 ---
 drivers/staging/wilc1000/linux_wlan.c              | 42 +++++++++-------------
 .../staging/wilc1000/microchip,wilc1000,sdio.txt   | 32 +++++++++++++++++
 .../staging/wilc1000/microchip,wilc1000,spi.txt    | 26 ++++++++++++++
 drivers/staging/wilc1000/wilc_sdio.c               | 38 ++++++++++++++------
 drivers/staging/wilc1000/wilc_spi.c                | 40 +++++++++++++--------
 drivers/staging/wilc1000/wilc_wfi_netdevice.h      |  5 +--
 7 files changed, 130 insertions(+), 57 deletions(-)
 create mode 100644 drivers/staging/wilc1000/microchip,wilc1000,sdio.txt
 create mode 100644 drivers/staging/wilc1000/microchip,wilc1000,spi.txt

-- 
2.7.4

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

* [PATCH 1/4] staging: wilc1000: remove gpio parameter from wilc_netdev_init()
  2018-07-20 12:01 [PATCH 0/4] staging: wilc1000: make use of descriptor-based interface for GPIO Ajay Singh
@ 2018-07-20 12:01 ` Ajay Singh
  2018-07-20 12:01 ` [PATCH 2/4] staging: wilc1000: rename variable from 'gpio' to 'gpio_irq' Ajay Singh
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Ajay Singh @ 2018-07-20 12:01 UTC (permalink / raw)
  To: linux-wireless
  Cc: devel, gregkh, ganesh.krishna, venkateswara.kaja, aditya.shankar,
	adham.abozaeid, robh+dt, mark.rutland, linus.walleij, Ajay Singh

Instead of passing the gpio as parameter to wilc_netdev_init() now
setting its value after finishing wilc_netdev_init() call. Avoided
passing of extra parameter to wilc_netdev_init().

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
---
 drivers/staging/wilc1000/linux_wlan.c         | 3 +--
 drivers/staging/wilc1000/wilc_sdio.c          | 4 ++--
 drivers/staging/wilc1000/wilc_spi.c           | 3 ++-
 drivers/staging/wilc1000/wilc_wfi_netdevice.h | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c
index 2f4bf8e..8f43a1f 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -1053,7 +1053,7 @@ static const struct net_device_ops wilc_netdev_ops = {
 };
 
 int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
-		     int gpio, const struct wilc_hif_func *ops)
+		     const struct wilc_hif_func *ops)
 {
 	int i, ret;
 	struct wilc_vif *vif;
@@ -1066,7 +1066,6 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
 
 	*wilc = wl;
 	wl->io_type = io_type;
-	wl->gpio = gpio;
 	wl->hif_func = ops;
 	INIT_LIST_HEAD(&wl->txq_head.list);
 	INIT_LIST_HEAD(&wl->rxq_head.list);
diff --git a/drivers/staging/wilc1000/wilc_sdio.c b/drivers/staging/wilc1000/wilc_sdio.c
index 4ab43f9..7a2fc79 100644
--- a/drivers/staging/wilc1000/wilc_sdio.c
+++ b/drivers/staging/wilc1000/wilc_sdio.c
@@ -118,14 +118,14 @@ static int linux_sdio_probe(struct sdio_func *func,
 	}
 
 	dev_dbg(&func->dev, "Initializing netdev\n");
-	ret = wilc_netdev_init(&wilc, &func->dev, HIF_SDIO, gpio,
-			       &wilc_hif_sdio);
+	ret = wilc_netdev_init(&wilc, &func->dev, HIF_SDIO, &wilc_hif_sdio);
 	if (ret) {
 		dev_err(&func->dev, "Couldn't initialize netdev\n");
 		return ret;
 	}
 	sdio_set_drvdata(func, wilc);
 	wilc->dev = &func->dev;
+	wilc->gpio = gpio;
 
 	dev_info(&func->dev, "Driver Initializing success\n");
 	return 0;
diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c
index 6475263..69b2c3c 100644
--- a/drivers/staging/wilc1000/wilc_spi.c
+++ b/drivers/staging/wilc1000/wilc_spi.c
@@ -113,12 +113,13 @@ static int wilc_bus_probe(struct spi_device *spi)
 	if (gpio < 0)
 		gpio = GPIO_NUM;
 
-	ret = wilc_netdev_init(&wilc, NULL, HIF_SPI, GPIO_NUM, &wilc_hif_spi);
+	ret = wilc_netdev_init(&wilc, NULL, HIF_SPI, &wilc_hif_spi);
 	if (ret)
 		return ret;
 
 	spi_set_drvdata(spi, wilc);
 	wilc->dev = &spi->dev;
+	wilc->gpio = gpio;
 
 	return 0;
 }
diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
index 765681a..add76c7 100644
--- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h
+++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
@@ -174,7 +174,7 @@ void wilc_frmw_to_linux(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset);
 void wilc_mac_indicate(struct wilc *wilc);
 void wilc_netdev_cleanup(struct wilc *wilc);
 int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
-		     int gpio, const struct wilc_hif_func *ops);
+		     const struct wilc_hif_func *ops);
 void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size);
 int wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid, u8 mode);
 
-- 
2.7.4

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

* [PATCH 2/4] staging: wilc1000: rename variable from 'gpio' to 'gpio_irq'
  2018-07-20 12:01 [PATCH 0/4] staging: wilc1000: make use of descriptor-based interface for GPIO Ajay Singh
  2018-07-20 12:01 ` [PATCH 1/4] staging: wilc1000: remove gpio parameter from wilc_netdev_init() Ajay Singh
@ 2018-07-20 12:01 ` Ajay Singh
  2018-07-20 12:01 ` [PATCH 3/4] staging: wilc1000: change compatible string from atmel to microchip Ajay Singh
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Ajay Singh @ 2018-07-20 12:01 UTC (permalink / raw)
  To: linux-wireless
  Cc: devel, gregkh, ganesh.krishna, venkateswara.kaja, aditya.shankar,
	adham.abozaeid, robh+dt, mark.rutland, linus.walleij, Ajay Singh

Rename from 'gpio' to 'gpio_irq', so its inlcude the information about
the purpose of GPIO.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
---
 drivers/staging/wilc1000/linux_wlan.c         | 17 +++++++++--------
 drivers/staging/wilc1000/wilc_sdio.c          |  2 +-
 drivers/staging/wilc1000/wilc_spi.c           |  2 +-
 drivers/staging/wilc1000/wilc_wfi_netdevice.h |  2 +-
 4 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c
index 8f43a1f..74e7180 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -127,9 +127,9 @@ static int init_irq(struct net_device *dev)
 	struct wilc_vif *vif = netdev_priv(dev);
 	struct wilc *wl = vif->wilc;
 
-	if ((gpio_request(wl->gpio, "WILC_INTR") == 0) &&
-	    (gpio_direction_input(wl->gpio) == 0)) {
-		wl->dev_irq_num = gpio_to_irq(wl->gpio);
+	if ((gpio_request(wl->gpio_irq, "WILC_INTR") == 0) &&
+	    (gpio_direction_input(wl->gpio_irq) == 0)) {
+		wl->dev_irq_num = gpio_to_irq(wl->gpio_irq);
 	} else {
 		ret = -1;
 		netdev_err(dev, "could not obtain gpio for WILC_INTR\n");
@@ -140,13 +140,14 @@ static int init_irq(struct net_device *dev)
 					      isr_bh_routine,
 					      IRQF_TRIGGER_LOW | IRQF_ONESHOT,
 					      "WILC_IRQ", dev) < 0) {
-		netdev_err(dev, "Failed to request IRQ GPIO: %d\n", wl->gpio);
-		gpio_free(wl->gpio);
+		netdev_err(dev, "Failed to request IRQ GPIO: %d\n",
+			   wl->gpio_irq);
+		gpio_free(wl->gpio_irq);
 		ret = -1;
 	} else {
 		netdev_dbg(dev,
 			   "IRQ request succeeded IRQ-NUM= %d on GPIO: %d\n",
-			   wl->dev_irq_num, wl->gpio);
+			   wl->dev_irq_num, wl->gpio_irq);
 	}
 
 	return ret;
@@ -160,7 +161,7 @@ static void deinit_irq(struct net_device *dev)
 	/* Deinitialize IRQ */
 	if (wilc->dev_irq_num) {
 		free_irq(wilc->dev_irq_num, wilc);
-		gpio_free(wilc->gpio);
+		gpio_free(wilc->gpio_irq);
 	}
 }
 
@@ -651,7 +652,7 @@ static int wilc_wlan_initialize(struct net_device *dev, struct wilc_vif *vif)
 			goto fail_locks;
 		}
 
-		if (wl->gpio >= 0 && init_irq(dev)) {
+		if (wl->gpio_irq >= 0 && init_irq(dev)) {
 			ret = -EIO;
 			goto fail_locks;
 		}
diff --git a/drivers/staging/wilc1000/wilc_sdio.c b/drivers/staging/wilc1000/wilc_sdio.c
index 7a2fc79..07cb8a6 100644
--- a/drivers/staging/wilc1000/wilc_sdio.c
+++ b/drivers/staging/wilc1000/wilc_sdio.c
@@ -125,7 +125,7 @@ static int linux_sdio_probe(struct sdio_func *func,
 	}
 	sdio_set_drvdata(func, wilc);
 	wilc->dev = &func->dev;
-	wilc->gpio = gpio;
+	wilc->gpio_irq = gpio;
 
 	dev_info(&func->dev, "Driver Initializing success\n");
 	return 0;
diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c
index 69b2c3c..8cb286b 100644
--- a/drivers/staging/wilc1000/wilc_spi.c
+++ b/drivers/staging/wilc1000/wilc_spi.c
@@ -119,7 +119,7 @@ static int wilc_bus_probe(struct spi_device *spi)
 
 	spi_set_drvdata(spi, wilc);
 	wilc->dev = &spi->dev;
-	wilc->gpio = gpio;
+	wilc->gpio_irq = gpio;
 
 	return 0;
 }
diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
index add76c7..74c2a17 100644
--- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h
+++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
@@ -121,7 +121,7 @@ struct wilc {
 	const struct wilc_hif_func *hif_func;
 	int io_type;
 	int mac_status;
-	int gpio;
+	int gpio_irq;
 	bool initialized;
 	int dev_irq_num;
 	int close;
-- 
2.7.4

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

* [PATCH 3/4] staging: wilc1000: change compatible string from atmel to microchip
  2018-07-20 12:01 [PATCH 0/4] staging: wilc1000: make use of descriptor-based interface for GPIO Ajay Singh
  2018-07-20 12:01 ` [PATCH 1/4] staging: wilc1000: remove gpio parameter from wilc_netdev_init() Ajay Singh
  2018-07-20 12:01 ` [PATCH 2/4] staging: wilc1000: rename variable from 'gpio' to 'gpio_irq' Ajay Singh
@ 2018-07-20 12:01 ` Ajay Singh
  2018-07-20 12:01 ` [PATCH 4/4] staging: wilc1000: use descriptor-based interface for GPIO Ajay Singh
  2018-07-24  8:04 ` [PATCH 0/4] staging: wilc1000: make use of " Claudiu Beznea
  4 siblings, 0 replies; 7+ messages in thread
From: Ajay Singh @ 2018-07-20 12:01 UTC (permalink / raw)
  To: linux-wireless
  Cc: devel, gregkh, ganesh.krishna, venkateswara.kaja, aditya.shankar,
	adham.abozaeid, robh+dt, mark.rutland, linus.walleij, Ajay Singh

Use 'microchip' in compatible string instead of 'atmel', also replace '_'
with '-' before the module. Remove 'wilc1000' prefix from device table
name.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
---
 drivers/staging/wilc1000/wilc_sdio.c | 11 +++++++++--
 drivers/staging/wilc1000/wilc_spi.c  | 14 +++++++-------
 2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_sdio.c b/drivers/staging/wilc1000/wilc_sdio.c
index 07cb8a6..afb91e5 100644
--- a/drivers/staging/wilc1000/wilc_sdio.c
+++ b/drivers/staging/wilc1000/wilc_sdio.c
@@ -199,21 +199,28 @@ static int wilc_sdio_resume(struct device *dev)
 	return 0;
 }
 
+static const struct of_device_id wilc_of_match[] = {
+	{ .compatible = "microchip,wilc1000-sdio", },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, wilc_of_match);
+
 static const struct dev_pm_ops wilc_sdio_pm_ops = {
 	.suspend = wilc_sdio_suspend,
 	.resume = wilc_sdio_resume,
 };
 
-static struct sdio_driver wilc1000_sdio_driver = {
+static struct sdio_driver wilc_sdio_driver = {
 	.name		= SDIO_MODALIAS,
 	.id_table	= wilc_sdio_ids,
 	.probe		= linux_sdio_probe,
 	.remove		= linux_sdio_remove,
 	.drv = {
 		.pm = &wilc_sdio_pm_ops,
+		.of_match_table = wilc_of_match,
 	}
 };
-module_driver(wilc1000_sdio_driver,
+module_driver(wilc_sdio_driver,
 	      sdio_register_driver,
 	      sdio_unregister_driver);
 MODULE_LICENSE("GPL");
diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c
index 8cb286b..7d4c7c5 100644
--- a/drivers/staging/wilc1000/wilc_spi.c
+++ b/drivers/staging/wilc1000/wilc_spi.c
@@ -130,21 +130,21 @@ static int wilc_bus_remove(struct spi_device *spi)
 	return 0;
 }
 
-static const struct of_device_id wilc1000_of_match[] = {
-	{ .compatible = "atmel,wilc_spi", },
-	{}
+static const struct of_device_id wilc_of_match[] = {
+	{ .compatible = "microchip,wilc1000-spi", },
+	{ /* sentinel */ }
 };
-MODULE_DEVICE_TABLE(of, wilc1000_of_match);
+MODULE_DEVICE_TABLE(of, wilc_of_match);
 
-static struct spi_driver wilc1000_spi_driver = {
+static struct spi_driver wilc_spi_driver = {
 	.driver = {
 		.name = MODALIAS,
-		.of_match_table = wilc1000_of_match,
+		.of_match_table = wilc_of_match,
 	},
 	.probe =  wilc_bus_probe,
 	.remove = wilc_bus_remove,
 };
-module_spi_driver(wilc1000_spi_driver);
+module_spi_driver(wilc_spi_driver);
 MODULE_LICENSE("GPL");
 
 static int wilc_spi_tx(struct wilc *wilc, u8 *b, u32 len)
-- 
2.7.4

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

* [PATCH 4/4] staging: wilc1000: use descriptor-based interface for GPIO
  2018-07-20 12:01 [PATCH 0/4] staging: wilc1000: make use of descriptor-based interface for GPIO Ajay Singh
                   ` (2 preceding siblings ...)
  2018-07-20 12:01 ` [PATCH 3/4] staging: wilc1000: change compatible string from atmel to microchip Ajay Singh
@ 2018-07-20 12:01 ` Ajay Singh
  2018-07-20 20:29   ` Linus Walleij
  2018-07-24  8:04 ` [PATCH 0/4] staging: wilc1000: make use of " Claudiu Beznea
  4 siblings, 1 reply; 7+ messages in thread
From: Ajay Singh @ 2018-07-20 12:01 UTC (permalink / raw)
  To: linux-wireless
  Cc: devel, gregkh, ganesh.krishna, venkateswara.kaja, aditya.shankar,
	adham.abozaeid, robh+dt, mark.rutland, linus.walleij, Ajay Singh

Now making use of descriptor-based interface instead of integer-based
interface for IRQ GPIO.
Added device tree binding reference for WILC SDIO and SPI interface
module. Also moved the code to free gpio descriptor in module remove
as the reference was fetched in probe function.
Updated the TODO file

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
---
 drivers/staging/wilc1000/TODO                      |  4 ---
 drivers/staging/wilc1000/linux_wlan.c              | 40 +++++++++-------------
 .../staging/wilc1000/microchip,wilc1000,sdio.txt   | 32 +++++++++++++++++
 .../staging/wilc1000/microchip,wilc1000,spi.txt    | 26 ++++++++++++++
 drivers/staging/wilc1000/wilc_sdio.c               | 23 +++++++++----
 drivers/staging/wilc1000/wilc_spi.c                | 23 +++++++++----
 drivers/staging/wilc1000/wilc_wfi_netdevice.h      |  3 +-
 7 files changed, 108 insertions(+), 43 deletions(-)
 create mode 100644 drivers/staging/wilc1000/microchip,wilc1000,sdio.txt
 create mode 100644 drivers/staging/wilc1000/microchip,wilc1000,spi.txt

diff --git a/drivers/staging/wilc1000/TODO b/drivers/staging/wilc1000/TODO
index 725bede..3d82bb0 100644
--- a/drivers/staging/wilc1000/TODO
+++ b/drivers/staging/wilc1000/TODO
@@ -3,7 +3,3 @@ TODO:
 - make spi and sdio components coexist in one build
 - support soft-ap and p2p mode
 - support resume/suspend function
-- convert all uses of the old GPIO API from <linux/gpio.h> to the
-  GPIO descriptor API in <linux/gpio/consumer.h> and look up GPIO
-  lines from device tree, ACPI or board files, board files should
-  use <linux/gpio/machine.h>
diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c
index 74e7180..64c5d69 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -1,6 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <linux/irq.h>
-#include <linux/gpio.h>
 #include <linux/kthread.h>
 #include <linux/firmware.h>
 #include <linux/netdevice.h>
@@ -127,28 +126,23 @@ static int init_irq(struct net_device *dev)
 	struct wilc_vif *vif = netdev_priv(dev);
 	struct wilc *wl = vif->wilc;
 
-	if ((gpio_request(wl->gpio_irq, "WILC_INTR") == 0) &&
-	    (gpio_direction_input(wl->gpio_irq) == 0)) {
-		wl->dev_irq_num = gpio_to_irq(wl->gpio_irq);
-	} else {
-		ret = -1;
+	ret = gpiod_direction_input(wl->gpio_irq);
+	if (ret) {
 		netdev_err(dev, "could not obtain gpio for WILC_INTR\n");
+		return ret;
 	}
 
-	if (ret != -1 && request_threaded_irq(wl->dev_irq_num,
-					      isr_uh_routine,
-					      isr_bh_routine,
-					      IRQF_TRIGGER_LOW | IRQF_ONESHOT,
-					      "WILC_IRQ", dev) < 0) {
-		netdev_err(dev, "Failed to request IRQ GPIO: %d\n",
-			   wl->gpio_irq);
-		gpio_free(wl->gpio_irq);
-		ret = -1;
-	} else {
-		netdev_dbg(dev,
-			   "IRQ request succeeded IRQ-NUM= %d on GPIO: %d\n",
-			   wl->dev_irq_num, wl->gpio_irq);
-	}
+	wl->dev_irq_num = gpiod_to_irq(wl->gpio_irq);
+
+	ret = request_threaded_irq(wl->dev_irq_num, isr_uh_routine,
+				   isr_bh_routine,
+				   IRQF_TRIGGER_LOW | 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);
 
 	return ret;
 }
@@ -159,10 +153,8 @@ static void deinit_irq(struct net_device *dev)
 	struct wilc *wilc = vif->wilc;
 
 	/* Deinitialize IRQ */
-	if (wilc->dev_irq_num) {
+	if (wilc->dev_irq_num)
 		free_irq(wilc->dev_irq_num, wilc);
-		gpio_free(wilc->gpio_irq);
-	}
 }
 
 void wilc_mac_indicate(struct wilc *wilc)
@@ -652,7 +644,7 @@ static int wilc_wlan_initialize(struct net_device *dev, struct wilc_vif *vif)
 			goto fail_locks;
 		}
 
-		if (wl->gpio_irq >= 0 && init_irq(dev)) {
+		if (wl->gpio_irq && init_irq(dev)) {
 			ret = -EIO;
 			goto fail_locks;
 		}
diff --git a/drivers/staging/wilc1000/microchip,wilc1000,sdio.txt b/drivers/staging/wilc1000/microchip,wilc1000,sdio.txt
new file mode 100644
index 0000000..4f7d1c2
--- /dev/null
+++ b/drivers/staging/wilc1000/microchip,wilc1000,sdio.txt
@@ -0,0 +1,32 @@
+* Microchip WILC wireless SDIO device
+
+The wilc1000 chips can be connected via SDIO. The node is used to specifiy
+child node to the SDIO controller that connects the device to the system.
+
+Required properties:
+- compatible	:	Should be "microchip,wilc1000-spi"
+- irq-gpios	:	Connect to a host IRQ
+- reg		:	Slot ID used in the controller
+
+Optional:
+- bus-width	:	Number of data lines wired up the slot. Default 1 bit.
+
+
+Examples:
+mmc1: mmc@fc000000 {
+		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>;
+			status = "okay";
+			reg = <0>;
+			bus-width = <4>;
+		}
+	};
+}
diff --git a/drivers/staging/wilc1000/microchip,wilc1000,spi.txt b/drivers/staging/wilc1000/microchip,wilc1000,spi.txt
new file mode 100644
index 0000000..87db87b
--- /dev/null
+++ b/drivers/staging/wilc1000/microchip,wilc1000,spi.txt
@@ -0,0 +1,26 @@
+* Microchip WILC wireless SPI device
+
+The wilc1000 chips can be connected via SPI. This document describes
+the binding for the SPI connected module.
+
+Required properties:
+- compatible		: Should be "microchip,wilc1000-spi"
+- spi-max-frequency	: Maximum SPI clocking speed of device in Hz
+- reg			: Chip select address of device
+- irq-gpios		: Connect to a host IRQ
+
+
+Examples:
+
+spi1: spi@fc018000 {
+		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>;
+			status = "okay";
+		};
+};
diff --git a/drivers/staging/wilc1000/wilc_sdio.c b/drivers/staging/wilc1000/wilc_sdio.c
index afb91e5..8a47147 100644
--- a/drivers/staging/wilc1000/wilc_sdio.c
+++ b/drivers/staging/wilc1000/wilc_sdio.c
@@ -6,7 +6,7 @@
  */
 
 #include <linux/mmc/sdio_func.h>
-#include <linux/of_gpio.h>
+#include <linux/mmc/host.h>
 
 #include "wilc_wfi_netdevice.h"
 
@@ -108,13 +108,17 @@ static int linux_sdio_probe(struct sdio_func *func,
 			    const struct sdio_device_id *id)
 {
 	struct wilc *wilc;
-	int gpio, ret;
+	int ret;
+	struct gpio_desc *gpio = NULL;
 
-	gpio = -1;
 	if (IS_ENABLED(CONFIG_WILC1000_HW_OOB_INTR)) {
-		gpio = of_get_gpio(func->dev.of_node, 0);
-		if (gpio < 0)
-			gpio = GPIO_NUM;
+		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");
+		}
 	}
 
 	dev_dbg(&func->dev, "Initializing netdev\n");
@@ -133,7 +137,12 @@ static int linux_sdio_probe(struct sdio_func *func,
 
 static void linux_sdio_remove(struct sdio_func *func)
 {
-	wilc_netdev_cleanup(sdio_get_drvdata(func));
+	struct wilc *wilc = sdio_get_drvdata(func);
+
+	/* free the GPIO in module remove */
+	if (wilc->gpio_irq)
+		gpiod_put(wilc->gpio_irq);
+	wilc_netdev_cleanup(wilc);
 }
 
 static int sdio_reset(struct wilc *wilc)
diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c
index 7d4c7c5..fa9371b 100644
--- a/drivers/staging/wilc1000/wilc_spi.c
+++ b/drivers/staging/wilc1000/wilc_spi.c
@@ -6,7 +6,6 @@
  */
 
 #include <linux/spi/spi.h>
-#include <linux/of_gpio.h>
 
 #include "wilc_wfi_netdevice.h"
 
@@ -106,12 +105,17 @@ static u8 crc7(u8 crc, const u8 *buffer, u32 len)
 
 static int wilc_bus_probe(struct spi_device *spi)
 {
-	int ret, gpio;
+	int ret;
 	struct wilc *wilc;
-
-	gpio = of_get_gpio(spi->dev.of_node, 0);
-	if (gpio < 0)
-		gpio = GPIO_NUM;
+	struct gpio_desc *gpio;
+
+	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_netdev_init(&wilc, NULL, HIF_SPI, &wilc_hif_spi);
 	if (ret)
@@ -126,7 +130,12 @@ static int wilc_bus_probe(struct spi_device *spi)
 
 static int wilc_bus_remove(struct spi_device *spi)
 {
-	wilc_netdev_cleanup(spi_get_drvdata(spi));
+	struct wilc *wilc = spi_get_drvdata(spi);
+
+	/* free the GPIO in module remove */
+	if (wilc->gpio_irq)
+		gpiod_put(wilc->gpio_irq);
+	wilc_netdev_cleanup(wilc);
 	return 0;
 }
 
diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
index 74c2a17..331a971 100644
--- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h
+++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
@@ -7,6 +7,7 @@
 #include <net/cfg80211.h>
 #include <net/ieee80211_radiotap.h>
 #include <linux/if_arp.h>
+#include <linux/gpio/consumer.h>
 
 #include "host_interface.h"
 #include "wilc_wlan.h"
@@ -121,7 +122,7 @@ struct wilc {
 	const struct wilc_hif_func *hif_func;
 	int io_type;
 	int mac_status;
-	int gpio_irq;
+	struct gpio_desc *gpio_irq;
 	bool initialized;
 	int dev_irq_num;
 	int close;
-- 
2.7.4

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

* Re: [PATCH 4/4] staging: wilc1000: use descriptor-based interface for GPIO
  2018-07-20 12:01 ` [PATCH 4/4] staging: wilc1000: use descriptor-based interface for GPIO Ajay Singh
@ 2018-07-20 20:29   ` Linus Walleij
  0 siblings, 0 replies; 7+ messages in thread
From: Linus Walleij @ 2018-07-20 20:29 UTC (permalink / raw)
  To: ajay.kathat
  Cc: linux-wireless, devel, Greg KH, ganesh.krishna,
	venkateswara.kaja, aditya.shankar, adham.abozaeid, Rob Herring,
	Mark Rutland

On Fri, Jul 20, 2018 at 2:02 PM Ajay Singh <ajay.kathat@microchip.com> wrote:

> Now making use of descriptor-based interface instead of integer-based
> interface for IRQ GPIO.
> Added device tree binding reference for WILC SDIO and SPI interface
> module. Also moved the code to free gpio descriptor in module remove
> as the reference was fetched in probe function.
> Updated the TODO file
>
> Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Thanks Ajay!

Yours,
Linus Walleij

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

* Re: [PATCH 0/4] staging: wilc1000: make use of descriptor-based interface for GPIO
  2018-07-20 12:01 [PATCH 0/4] staging: wilc1000: make use of descriptor-based interface for GPIO Ajay Singh
                   ` (3 preceding siblings ...)
  2018-07-20 12:01 ` [PATCH 4/4] staging: wilc1000: use descriptor-based interface for GPIO Ajay Singh
@ 2018-07-24  8:04 ` Claudiu Beznea
  4 siblings, 0 replies; 7+ messages in thread
From: Claudiu Beznea @ 2018-07-24  8:04 UTC (permalink / raw)
  To: Ajay Singh, linux-wireless
  Cc: devel, gregkh, ganesh.krishna, venkateswara.kaja, aditya.shankar,
	adham.abozaeid, robh+dt, mark.rutland, linus.walleij

Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>

On 20.07.2018 15:01, Ajay Singh wrote:
> This patch series contains changes mainly related to make use of
> descriptor-based interface instead of integer-based interface for GPIO.
> Modified the compatible string to use 'microchip' instead of 'atmel' prefix.
> Also added the DT binding reference file.
> 
> This patch is created on top of [1] patch series.
> 
> [1]. https://www.spinics.net/lists/linux-wireless/msg175360.html
> 
> Ajay Singh (4):
>   staging: wilc1000: remove gpio parameter from wilc_netdev_init()
>   staging: wilc1000: rename variable from 'gpio' to 'gpio_irq'
>   staging: wilc1000: change compatible string from atmel to microchip
>   staging: wilc1000: use descriptor-based interface for GPIO
> 
>  drivers/staging/wilc1000/TODO                      |  4 ---
>  drivers/staging/wilc1000/linux_wlan.c              | 42 +++++++++-------------
>  .../staging/wilc1000/microchip,wilc1000,sdio.txt   | 32 +++++++++++++++++
>  .../staging/wilc1000/microchip,wilc1000,spi.txt    | 26 ++++++++++++++
>  drivers/staging/wilc1000/wilc_sdio.c               | 38 ++++++++++++++------
>  drivers/staging/wilc1000/wilc_spi.c                | 40 +++++++++++++--------
>  drivers/staging/wilc1000/wilc_wfi_netdevice.h      |  5 +--
>  7 files changed, 130 insertions(+), 57 deletions(-)
>  create mode 100644 drivers/staging/wilc1000/microchip,wilc1000,sdio.txt
>  create mode 100644 drivers/staging/wilc1000/microchip,wilc1000,spi.txt
> 

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

end of thread, other threads:[~2018-07-24  9:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-20 12:01 [PATCH 0/4] staging: wilc1000: make use of descriptor-based interface for GPIO Ajay Singh
2018-07-20 12:01 ` [PATCH 1/4] staging: wilc1000: remove gpio parameter from wilc_netdev_init() Ajay Singh
2018-07-20 12:01 ` [PATCH 2/4] staging: wilc1000: rename variable from 'gpio' to 'gpio_irq' Ajay Singh
2018-07-20 12:01 ` [PATCH 3/4] staging: wilc1000: change compatible string from atmel to microchip Ajay Singh
2018-07-20 12:01 ` [PATCH 4/4] staging: wilc1000: use descriptor-based interface for GPIO Ajay Singh
2018-07-20 20:29   ` Linus Walleij
2018-07-24  8:04 ` [PATCH 0/4] staging: wilc1000: make use of " Claudiu Beznea

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 NNTP newsgroup(s).