summaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
authorJonas Gorski <jonas.gorski@gmail.com>2017-03-01 04:08:14 -0500
committerMark Brown <broonie@kernel.org>2017-03-13 11:51:50 -0400
commit7ab2463550e2a3a5b97dfa82e5bf8038b986f007 (patch)
tree2d1d586fae6c8c47d1e03557c810b5d16102dbbe /drivers/spi
parent8c0951afd8a7585a4281980b9a21dcc8a419cad9 (diff)
spi/bcm63xx-hsspi: allow for probing through devicetree
Add required binding support to probe through device tree. Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com> Acked-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/spi-bcm63xx-hsspi.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/drivers/spi/spi-bcm63xx-hsspi.c b/drivers/spi/spi-bcm63xx-hsspi.c
index 79096d17ebde..5514cd02e93a 100644
--- a/drivers/spi/spi-bcm63xx-hsspi.c
+++ b/drivers/spi/spi-bcm63xx-hsspi.c
@@ -19,6 +19,7 @@
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20#include <linux/spi/spi.h> 20#include <linux/spi/spi.h>
21#include <linux/mutex.h> 21#include <linux/mutex.h>
22#include <linux/of.h>
22 23
23#define HSSPI_GLOBAL_CTRL_REG 0x0 24#define HSSPI_GLOBAL_CTRL_REG 0x0
24#define GLOBAL_CTRL_CS_POLARITY_SHIFT 0 25#define GLOBAL_CTRL_CS_POLARITY_SHIFT 0
@@ -91,6 +92,7 @@
91 92
92#define HSSPI_MAX_SYNC_CLOCK 30000000 93#define HSSPI_MAX_SYNC_CLOCK 30000000
93 94
95#define HSSPI_SPI_MAX_CS 8
94#define HSSPI_BUS_NUM 1 /* 0 is legacy SPI */ 96#define HSSPI_BUS_NUM 1 /* 0 is legacy SPI */
95 97
96struct bcm63xx_hsspi { 98struct bcm63xx_hsspi {
@@ -332,7 +334,7 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev)
332 struct device *dev = &pdev->dev; 334 struct device *dev = &pdev->dev;
333 struct clk *clk; 335 struct clk *clk;
334 int irq, ret; 336 int irq, ret;
335 u32 reg, rate; 337 u32 reg, rate, num_cs = HSSPI_SPI_MAX_CS;
336 338
337 irq = platform_get_irq(pdev, 0); 339 irq = platform_get_irq(pdev, 0);
338 if (irq < 0) { 340 if (irq < 0) {
@@ -382,8 +384,17 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev)
382 mutex_init(&bs->bus_mutex); 384 mutex_init(&bs->bus_mutex);
383 init_completion(&bs->done); 385 init_completion(&bs->done);
384 386
385 master->bus_num = HSSPI_BUS_NUM; 387 master->dev.of_node = dev->of_node;
386 master->num_chipselect = 8; 388 if (!dev->of_node)
389 master->bus_num = HSSPI_BUS_NUM;
390
391 of_property_read_u32(dev->of_node, "num-cs", &num_cs);
392 if (num_cs > 8) {
393 dev_warn(dev, "unsupported number of cs (%i), reducing to 8\n",
394 num_cs);
395 num_cs = HSSPI_SPI_MAX_CS;
396 }
397 master->num_chipselect = num_cs;
387 master->setup = bcm63xx_hsspi_setup; 398 master->setup = bcm63xx_hsspi_setup;
388 master->transfer_one_message = bcm63xx_hsspi_transfer_one; 399 master->transfer_one_message = bcm63xx_hsspi_transfer_one;
389 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | 400 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH |
@@ -469,10 +480,16 @@ static int bcm63xx_hsspi_resume(struct device *dev)
469static SIMPLE_DEV_PM_OPS(bcm63xx_hsspi_pm_ops, bcm63xx_hsspi_suspend, 480static SIMPLE_DEV_PM_OPS(bcm63xx_hsspi_pm_ops, bcm63xx_hsspi_suspend,
470 bcm63xx_hsspi_resume); 481 bcm63xx_hsspi_resume);
471 482
483static const struct of_device_id bcm63xx_hsspi_of_match[] = {
484 { .compatible = "brcm,bcm6328-hsspi", },
485 { },
486};
487
472static struct platform_driver bcm63xx_hsspi_driver = { 488static struct platform_driver bcm63xx_hsspi_driver = {
473 .driver = { 489 .driver = {
474 .name = "bcm63xx-hsspi", 490 .name = "bcm63xx-hsspi",
475 .pm = &bcm63xx_hsspi_pm_ops, 491 .pm = &bcm63xx_hsspi_pm_ops,
492 .of_match_table = bcm63xx_hsspi_of_match,
476 }, 493 },
477 .probe = bcm63xx_hsspi_probe, 494 .probe = bcm63xx_hsspi_probe,
478 .remove = bcm63xx_hsspi_remove, 495 .remove = bcm63xx_hsspi_remove,