devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Reichel <sre@debian.org>
To: Sebastian Reichel <sre@ring0.de>, Luciano Coelho <luca@coelho.fi>
Cc: Rob Herring <rob.herring@calxeda.com>,
	Pawel Moll <pawel.moll@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Stephen Warren <swarren@wwwdotorg.org>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Rob Landley <rob@landley.net>, Tony Lindgren <tony@atomide.com>,
	Russell King <linux@arm.linux.org.uk>,
	"John W. Linville" <linville@tuxdriver.com>,
	Felipe Balbi <balbi@ti.com>,
	Sachin Kamat <sachin.kamat@linaro.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Bill Pemberton <wfp5p@virginia.edu>,
	devicetree@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
	Sebastian Reichel <sre@debian.org>
Subject: [PATCH 4/4] wl1251: spi: add device tree support
Date: Sun, 27 Oct 2013 17:14:29 +0100	[thread overview]
Message-ID: <1382890469-25286-5-git-send-email-sre@debian.org> (raw)
In-Reply-To: <1382890469-25286-1-git-send-email-sre@debian.org>

Add device tree support for the spi variant of wl1251
and document the binding.

Signed-off-by: Sebastian Reichel <sre@debian.org>
---
 .../devicetree/bindings/net/wireless/ti,wl1251.txt | 36 ++++++++++++++++++++++
 drivers/net/wireless/ti/wl1251/spi.c               | 23 ++++++++++----
 2 files changed, 53 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt

diff --git a/Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt b/Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt
new file mode 100644
index 0000000..5f8a154
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt
@@ -0,0 +1,36 @@
+* Texas Instruments wl1251 controller
+
+The wl1251 chip can be connected via SPI or via SDIO. The linux
+kernel currently only supports device tree for the SPI variant.
+
+Required properties:
+- compatible : Should be "ti,wl1251"
+- interrupts : Should contain interrupt line
+- interrupt-parent : Should be the phandle for the interrupt
+  controller that services interrupts for this device
+- vio-supply : phandle to regulator providing VIO
+- power-gpio : GPIO connected to chip's PMEN pin
+- For additional required properties on SPI, please consult
+  Documentation/devicetree/bindings/spi/spi-bus.txt
+
+Optional properties:
+- ti,use-eeprom : If found, configuration will be loaded from eeprom.
+
+Examples:
+
+&spi1 {
+	wl1251_spi@0 {
+		compatible = "ti,wl1251";
+
+		reg = <0>;
+		spi-max-frequency = <48000000>;
+		spi-cpol;
+		spi-cpha;
+
+		interrupt-parent = <&gpio2>;
+		interrupts = <10 IRQ_TYPE_NONE>; /* gpio line 42 */
+
+		vio-supply = <&vio>;
+		power-gpio = <&gpio3 23 GPIO_ACTIVE_HIGH>; /* 87 */
+	};
+};
diff --git a/drivers/net/wireless/ti/wl1251/spi.c b/drivers/net/wireless/ti/wl1251/spi.c
index efea57a..ee6ce4c 100644
--- a/drivers/net/wireless/ti/wl1251/spi.c
+++ b/drivers/net/wireless/ti/wl1251/spi.c
@@ -27,6 +27,8 @@
 #include <linux/spi/spi.h>
 #include <linux/wl12xx.h>
 #include <linux/gpio.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
 #include <linux/regulator/consumer.h>
 
 #include "wl1251.h"
@@ -240,13 +242,13 @@ static const struct wl1251_if_operations wl1251_spi_ops = {
 
 static int wl1251_spi_probe(struct spi_device *spi)
 {
-	struct wl1251_platform_data *pdata;
+	struct wl1251_platform_data *pdata = spi->dev.platform_data;
+	struct device_node *np = spi->dev.of_node;
 	struct ieee80211_hw *hw;
 	struct wl1251 *wl;
 	int ret;
 
-	pdata = spi->dev.platform_data;
-	if (!pdata) {
+	if (!np && !pdata) {
 		wl1251_error("no platform data");
 		return -ENODEV;
 	}
@@ -273,7 +275,18 @@ static int wl1251_spi_probe(struct spi_device *spi)
 		goto out_free;
 	}
 
-	wl->power_gpio = pdata->power_gpio;
+	if (np) {
+		wl->use_eeprom = of_property_read_bool(np, "ti,use-eeprom");
+		wl->power_gpio = of_get_named_gpio(np, "power-gpio", 0);
+	} else if (pdata) {
+		wl->power_gpio = pdata->power_gpio;
+		wl->use_eeprom = pdata->use_eeprom;
+	}
+
+	if (wl->power_gpio == -EPROBE_DEFER) {
+		ret = -EPROBE_DEFER;
+		goto out_free;
+	}
 
 	if (gpio_is_valid(wl->power_gpio)) {
 		ret = devm_gpio_request_one(&spi->dev, wl->power_gpio,
@@ -295,8 +308,6 @@ static int wl1251_spi_probe(struct spi_device *spi)
 		goto out_free;
 	}
 
-	wl->use_eeprom = pdata->use_eeprom;
-
 	irq_set_status_flags(wl->irq, IRQ_NOAUTOEN);
 	ret = devm_request_irq(&spi->dev, wl->irq, wl1251_irq, 0,
 							DRIVER_NAME, wl);
-- 
1.8.4.rc3


  parent reply	other threads:[~2013-10-27 16:14 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-27 16:14 [PATCH 0/4] wl1251 device tree support Sebastian Reichel
2013-10-27 16:14 ` [PATCH 1/4] wl1251: split wl251 platform data to a separate structure Sebastian Reichel
     [not found]   ` <1382890469-25286-2-git-send-email-sre-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org>
2013-11-05 12:13     ` Pavel Machek
2013-11-14 18:51   ` Tony Lindgren
2013-11-14 23:03     ` Sebastian Reichel
2013-11-14 23:22       ` Tony Lindgren
2013-11-15 14:32         ` John W. Linville
     [not found]           ` <20131115143254.GA7079-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
2013-11-15 14:55             ` Sebastian Reichel
2013-12-10  3:28           ` Tony Lindgren
2013-10-27 16:14 ` [PATCH 2/4] wl1251: move power GPIO handling into the driver Sebastian Reichel
2013-10-27 16:24   ` Alexander Shiyan
2013-10-27 20:12     ` Sebastian Reichel
2013-10-28 17:29       ` Grazvydas Ignotas
2013-10-28 19:23         ` Mark Brown
2013-10-28 23:26           ` Sebastian Reichel
2013-10-29  1:33             ` Mark Brown
     [not found]   ` <1382890469-25286-3-git-send-email-sre-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org>
2013-11-05 13:11     ` Pavel Machek
2013-10-27 16:14 ` [PATCH 3/4] wl1251: spi: add vio regulator support Sebastian Reichel
     [not found]   ` <1382890469-25286-4-git-send-email-sre-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org>
2013-11-05 13:12     ` Pavel Machek
2013-10-27 16:14 ` Sebastian Reichel [this message]
2013-10-28  6:37   ` [PATCH 4/4] wl1251: spi: add device tree support Kumar Gala
2013-10-28 17:15     ` Grazvydas Ignotas
2013-10-28 19:30       ` Kumar Gala
2013-10-28 22:38     ` Tomasz Figa
2013-10-29  8:28       ` Kumar Gala
     [not found] ` <1382890469-25286-1-git-send-email-sre-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org>
2013-12-06  0:22   ` [PATCHv2 0/5] wl1251 " Sebastian Reichel
2013-12-06  0:22     ` [PATCHv2 1/5] wl1251: split wl251 platform data to a separate structure Sebastian Reichel
2013-12-06  0:22     ` [PATCHv2 2/5] wl1251: move power GPIO handling into the driver Sebastian Reichel
2013-12-06  0:22     ` [PATCHv2 3/5] wl1251: spi: add vio regulator support Sebastian Reichel
2013-12-06  0:22     ` [PATCHv2 4/5] wl1251: spi: add device tree support Sebastian Reichel
2013-12-06  0:22     ` [PATCHv2 5/5] Documentation: dt: wireless: Add wl1251 Sebastian Reichel

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=1382890469-25286-5-git-send-email-sre@debian.org \
    --to=sre@debian.org \
    --cc=balbi@ti.com \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=linville@tuxdriver.com \
    --cc=luca@coelho.fi \
    --cc=mark.rutland@arm.com \
    --cc=netdev@vger.kernel.org \
    --cc=pawel.moll@arm.com \
    --cc=rob.herring@calxeda.com \
    --cc=rob@landley.net \
    --cc=sachin.kamat@linaro.org \
    --cc=sre@ring0.de \
    --cc=swarren@wwwdotorg.org \
    --cc=tony@atomide.com \
    --cc=wfp5p@virginia.edu \
    /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 NNTP newsgroup(s).