1 From 776041498c2b285a7f745c924e10fc11ef720eae Mon Sep 17 00:00:00 2001
2 From: Jonas Gorski <jonas.gorski@gmail.com>
3 Date: Thu, 10 Sep 2015 14:53:53 +0200
4 Subject: [PATCH 3/3] spi/bcm63xx-hsspi: allow for probing through devicetree
6 Add required binding support to probe through device tree.
8 Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
10 drivers/spi/spi-bcm63xx-hsspi.c | 23 ++++++++++++++++++++---
11 1 file changed, 20 insertions(+), 3 deletions(-)
13 --- a/drivers/spi/spi-bcm63xx-hsspi.c
14 +++ b/drivers/spi/spi-bcm63xx-hsspi.c
16 #include <linux/interrupt.h>
17 #include <linux/spi/spi.h>
18 #include <linux/mutex.h>
19 +#include <linux/of.h>
21 #define HSSPI_GLOBAL_CTRL_REG 0x0
22 #define GLOBAL_CTRL_CS_POLARITY_SHIFT 0
25 #define HSSPI_MAX_SYNC_CLOCK 30000000
27 +#define HSSPI_SPI_MAX_CS 8
28 #define HSSPI_BUS_NUM 1 /* 0 is legacy SPI */
30 struct bcm63xx_hsspi {
31 @@ -332,7 +334,7 @@ static int bcm63xx_hsspi_probe(struct pl
32 struct device *dev = &pdev->dev;
36 + u32 reg, rate, num_cs = HSSPI_SPI_MAX_CS;
38 irq = platform_get_irq(pdev, 0);
40 @@ -382,8 +384,17 @@ static int bcm63xx_hsspi_probe(struct pl
41 mutex_init(&bs->bus_mutex);
42 init_completion(&bs->done);
44 - master->bus_num = HSSPI_BUS_NUM;
45 - master->num_chipselect = 8;
46 + master->dev.of_node = dev->of_node;
48 + master->bus_num = HSSPI_BUS_NUM;
50 + of_property_read_u32(dev->of_node, "num-cs", &num_cs);
52 + dev_warn(dev, "unsupported number of cs (%i), reducing to 8\n",
54 + num_cs = HSSPI_SPI_MAX_CS;
56 + master->num_chipselect = num_cs;
57 master->setup = bcm63xx_hsspi_setup;
58 master->transfer_one_message = bcm63xx_hsspi_transfer_one;
59 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH |
60 @@ -469,10 +480,16 @@ static int bcm63xx_hsspi_resume(struct d
61 static SIMPLE_DEV_PM_OPS(bcm63xx_hsspi_pm_ops, bcm63xx_hsspi_suspend,
62 bcm63xx_hsspi_resume);
64 +static const struct of_device_id bcm63xx_hsspi_of_match[] = {
65 + { .compatible = "brcm,bcm6328-hsspi", },
69 static struct platform_driver bcm63xx_hsspi_driver = {
71 .name = "bcm63xx-hsspi",
72 .pm = &bcm63xx_hsspi_pm_ops,
73 + .of_match_table = bcm63xx_hsspi_of_match,
75 .probe = bcm63xx_hsspi_probe,
76 .remove = bcm63xx_hsspi_remove,