aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ti
diff options
context:
space:
mode:
authorUri Mashiach <uri.mashiach@compulab.co.il>2015-12-30 08:35:32 -0500
committerKalle Valo <kvalo@codeaurora.org>2016-01-29 04:10:10 -0500
commit04654c386145239c8bcb35878b0b0537ce916766 (patch)
tree5b47238b7db91e4df8e406356ffddc41f1f723ab /drivers/net/wireless/ti
parent4c1ce07bcf62536ed42a4ba43e5fb580be61ac48 (diff)
wlcore/wl12xx: spi: add device tree support
Add DT support for the wl1271 SPI WiFi. Add documentation file for the wl1271 SPI WiFi. Signed-off-by: Uri Mashiach <uri.mashiach@compulab.co.il> Acked-by: Rob Herring <robh@kernel.org> Tested-By: Sebastian Reichel <sre@kernel.org> Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com> Acked-by: Igor Grinberg <grinberg@compulab.co.il> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Diffstat (limited to 'drivers/net/wireless/ti')
-rw-r--r--drivers/net/wireless/ti/wlcore/Kconfig2
-rw-r--r--drivers/net/wireless/ti/wlcore/spi.c47
2 files changed, 44 insertions, 5 deletions
diff --git a/drivers/net/wireless/ti/wlcore/Kconfig b/drivers/net/wireless/ti/wlcore/Kconfig
index 969c9d79bfc8..8a8f1e711384 100644
--- a/drivers/net/wireless/ti/wlcore/Kconfig
+++ b/drivers/net/wireless/ti/wlcore/Kconfig
@@ -13,7 +13,7 @@ config WLCORE
13 13
14config WLCORE_SPI 14config WLCORE_SPI
15 tristate "TI wlcore SPI support" 15 tristate "TI wlcore SPI support"
16 depends on WLCORE && SPI_MASTER 16 depends on WLCORE && SPI_MASTER && OF
17 select CRC7 17 select CRC7
18 ---help--- 18 ---help---
19 This module adds support for the SPI interface of adapters using 19 This module adds support for the SPI interface of adapters using
diff --git a/drivers/net/wireless/ti/wlcore/spi.c b/drivers/net/wireless/ti/wlcore/spi.c
index dec151247d0d..020ac1a4b408 100644
--- a/drivers/net/wireless/ti/wlcore/spi.c
+++ b/drivers/net/wireless/ti/wlcore/spi.c
@@ -30,6 +30,7 @@
30#include <linux/spi/spi.h> 30#include <linux/spi/spi.h>
31#include <linux/wl12xx.h> 31#include <linux/wl12xx.h>
32#include <linux/platform_device.h> 32#include <linux/platform_device.h>
33#include <linux/of_irq.h>
33#include <linux/regulator/consumer.h> 34#include <linux/regulator/consumer.h>
34 35
35#include "wlcore.h" 36#include "wlcore.h"
@@ -357,6 +358,39 @@ static struct wl1271_if_operations spi_ops = {
357 .set_block_size = NULL, 358 .set_block_size = NULL,
358}; 359};
359 360
361static const struct of_device_id wlcore_spi_of_match_table[] = {
362 { .compatible = "ti,wl1271" },
363 { }
364};
365MODULE_DEVICE_TABLE(of, wlcore_spi_of_match_table);
366
367/**
368 * wlcore_probe_of - DT node parsing.
369 * @spi: SPI slave device parameters.
370 * @res: resource parameters.
371 * @glue: wl12xx SPI bus to slave device glue parameters.
372 * @pdev_data: wlcore device parameters
373 */
374static int wlcore_probe_of(struct spi_device *spi, struct wl12xx_spi_glue *glue,
375 struct wlcore_platdev_data *pdev_data)
376{
377 struct device_node *dt_node = spi->dev.of_node;
378 int ret;
379
380 if (of_find_property(dt_node, "clock-xtal", NULL))
381 pdev_data->ref_clock_xtal = true;
382
383 ret = of_property_read_u32(dt_node, "ref-clock-frequency",
384 &pdev_data->ref_clock_freq);
385 if (IS_ERR_VALUE(ret)) {
386 dev_err(glue->dev,
387 "can't get reference clock frequency (%d)\n", ret);
388 return ret;
389 }
390
391 return 0;
392}
393
360static int wl1271_probe(struct spi_device *spi) 394static int wl1271_probe(struct spi_device *spi)
361{ 395{
362 struct wl12xx_spi_glue *glue; 396 struct wl12xx_spi_glue *glue;
@@ -366,8 +400,6 @@ static int wl1271_probe(struct spi_device *spi)
366 400
367 memset(&pdev_data, 0x00, sizeof(pdev_data)); 401 memset(&pdev_data, 0x00, sizeof(pdev_data));
368 402
369 /* TODO: add DT parsing when needed */
370
371 pdev_data.if_ops = &spi_ops; 403 pdev_data.if_ops = &spi_ops;
372 404
373 glue = devm_kzalloc(&spi->dev, sizeof(*glue), GFP_KERNEL); 405 glue = devm_kzalloc(&spi->dev, sizeof(*glue), GFP_KERNEL);
@@ -392,6 +424,13 @@ static int wl1271_probe(struct spi_device *spi)
392 return PTR_ERR(glue->reg); 424 return PTR_ERR(glue->reg);
393 } 425 }
394 426
427 ret = wlcore_probe_of(spi, glue, &pdev_data);
428 if (IS_ERR_VALUE(ret)) {
429 dev_err(glue->dev,
430 "can't get device tree parameters (%d)\n", ret);
431 return ret;
432 }
433
395 ret = spi_setup(spi); 434 ret = spi_setup(spi);
396 if (ret < 0) { 435 if (ret < 0) {
397 dev_err(glue->dev, "spi_setup failed\n"); 436 dev_err(glue->dev, "spi_setup failed\n");
@@ -409,7 +448,7 @@ static int wl1271_probe(struct spi_device *spi)
409 memset(res, 0x00, sizeof(res)); 448 memset(res, 0x00, sizeof(res));
410 449
411 res[0].start = spi->irq; 450 res[0].start = spi->irq;
412 res[0].flags = IORESOURCE_IRQ; 451 res[0].flags = IORESOURCE_IRQ | irq_get_trigger_type(spi->irq);
413 res[0].name = "irq"; 452 res[0].name = "irq";
414 453
415 ret = platform_device_add_resources(glue->core, res, ARRAY_SIZE(res)); 454 ret = platform_device_add_resources(glue->core, res, ARRAY_SIZE(res));
@@ -447,10 +486,10 @@ static int wl1271_remove(struct spi_device *spi)
447 return 0; 486 return 0;
448} 487}
449 488
450
451static struct spi_driver wl1271_spi_driver = { 489static struct spi_driver wl1271_spi_driver = {
452 .driver = { 490 .driver = {
453 .name = "wl1271_spi", 491 .name = "wl1271_spi",
492 .of_match_table = of_match_ptr(wlcore_spi_of_match_table),
454 }, 493 },
455 494
456 .probe = wl1271_probe, 495 .probe = wl1271_probe,