Register SPI controllers through device tree. We will wire up the clocks at a later stage. Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>master
parent
2a2b16210b
commit
b50fd8c2b3
@ -0,0 +1,50 @@ |
||||
From 0a0c39044332a75eaf4a3c5654079df953b0d839 Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Gorski <jogo@openwrt.org>
|
||||
Date: Mon, 7 Sep 2015 21:00:38 +0200
|
||||
Subject: [PATCH 3/8] spi/bcm63xx: document device tree bindings
|
||||
|
||||
Add documentation for the bindings of the low speed SPI controller found
|
||||
on most bcm63xx SoCs.
|
||||
|
||||
Signed-off-by: Jonas Gorski <jogo@openwrt.org>
|
||||
---
|
||||
.../devicetree/bindings/spi/spi-bcm63xx.txt | 33 ++++++++++++++++++++++
|
||||
1 file changed, 33 insertions(+)
|
||||
create mode 100644 Documentation/devicetree/bindings/spi/spi-bcm63xx.txt
|
||||
|
||||
--- /dev/null
|
||||
+++ b/Documentation/devicetree/bindings/spi/spi-bcm63xx.txt
|
||||
@@ -0,0 +1,33 @@
|
||||
+Binding for Broadcom BCM6348/BCM6358 SPI controller
|
||||
+
|
||||
+Required properties:
|
||||
+- compatible: must contain one of "brcm,bcm6348-spi", "brcm,bcm6358-spi".
|
||||
+- reg: Base address and size of the controllers memory area.
|
||||
+- interrupts: Interrupt for the SPI block.
|
||||
+- clocks: phandle of the SPI clock.
|
||||
+- clock-names: has to be "spi".
|
||||
+- #address-cells: <1>, as required by generic SPI binding.
|
||||
+- #size-cells: <0>, also as required by generic SPI binding.
|
||||
+
|
||||
+Optional properties:
|
||||
+- num-cs: some controllers have less than 8 cs signals. Defaults to 8
|
||||
+ if absent.
|
||||
+
|
||||
+Child nodes as per the generic SPI binding.
|
||||
+
|
||||
+Example:
|
||||
+
|
||||
+ spi@10000800 {
|
||||
+ compatible = "brcm,bcm6368-spi", "brcm,bcm6358-spi";
|
||||
+ reg = <0x10000800 0x70c>;
|
||||
+
|
||||
+ interrupts = <1>;
|
||||
+
|
||||
+ clocks = <&clkctl 9>;
|
||||
+ clock-names = "spi";
|
||||
+
|
||||
+ num-cs = <5>;
|
||||
+
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+ };
|
@ -0,0 +1,98 @@ |
||||
From 3353228a04a004ec67073871f40cf58dc4e209aa Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Gorski <jonas.gorski@gmail.com>
|
||||
Date: Mon, 7 Sep 2015 21:01:38 +0200
|
||||
Subject: [PATCH 4/8] spi/bcm63xx: add support for probing through devicetree
|
||||
|
||||
Add required binding support to probe through device tree.
|
||||
|
||||
Use the compatible instead of the resource size for identifiying the
|
||||
block type, and allow reducing the number of cs lines through OF.
|
||||
|
||||
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
|
||||
---
|
||||
drivers/spi/spi-bcm63xx.c | 42 ++++++++++++++++++++++++++++++++++++------
|
||||
1 file changed, 36 insertions(+), 6 deletions(-)
|
||||
|
||||
--- a/drivers/spi/spi-bcm63xx.c
|
||||
+++ b/drivers/spi/spi-bcm63xx.c
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <linux/completion.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/pm_runtime.h>
|
||||
+#include <linux/of.h>
|
||||
|
||||
/* BCM 6338/6348 SPI core */
|
||||
#define SPI_6348_RSET_SIZE 64
|
||||
@@ -485,21 +486,48 @@ static const struct platform_device_id b
|
||||
},
|
||||
};
|
||||
|
||||
+static const struct of_device_id bcm63xx_spi_of_match[] = {
|
||||
+ { .compatible = "brcm,bcm6348-spi", .data = &bcm6348_spi_reg_offsets },
|
||||
+ { .compatible = "brcm,bcm6358-spi", .data = &bcm6358_spi_reg_offsets },
|
||||
+ { },
|
||||
+};
|
||||
+
|
||||
static int bcm63xx_spi_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct resource *r;
|
||||
const unsigned long *bcm63xx_spireg;
|
||||
struct device *dev = &pdev->dev;
|
||||
- int irq;
|
||||
+ int irq, bus_num;
|
||||
struct spi_master *master;
|
||||
struct clk *clk;
|
||||
struct bcm63xx_spi *bs;
|
||||
int ret;
|
||||
+ u32 num_cs = BCM63XX_SPI_MAX_CS;
|
||||
|
||||
- if (!pdev->id_entry->driver_data)
|
||||
- return -EINVAL;
|
||||
+ if (dev->of_node) {
|
||||
+ const struct of_device_id *match;
|
||||
|
||||
- bcm63xx_spireg = (const unsigned long *)pdev->id_entry->driver_data;
|
||||
+ match = of_match_node(bcm63xx_spi_of_match, dev->of_node);
|
||||
+ if (!match)
|
||||
+ return -EINVAL;
|
||||
+ bcm63xx_spireg = match->data;
|
||||
+
|
||||
+ of_property_read_u32(dev->of_node, "num-cs", &num_cs);
|
||||
+ if (num_cs > BCM63XX_SPI_MAX_CS) {
|
||||
+ dev_warn(dev, "unsupported number of cs (%i), reducing to 8\n",
|
||||
+ num_cs);
|
||||
+ num_cs = BCM63XX_SPI_MAX_CS;
|
||||
+ }
|
||||
+
|
||||
+ bus_num = -1;
|
||||
+ } else if (pdev->id_entry->driver_data) {
|
||||
+ const struct platform_device_id *match = pdev->id_entry;
|
||||
+
|
||||
+ bcm63xx_spireg = (const unsigned long *)match->driver_data;
|
||||
+ bus_num = BCM63XX_SPI_BUS_NUM;
|
||||
+ } else {
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
|
||||
irq = platform_get_irq(pdev, 0);
|
||||
if (irq < 0) {
|
||||
@@ -544,8 +572,9 @@ static int bcm63xx_spi_probe(struct plat
|
||||
goto out_err;
|
||||
}
|
||||
|
||||
- master->bus_num = BCM63XX_SPI_BUS_NUM;
|
||||
- master->num_chipselect = BCM63XX_SPI_MAX_CS;
|
||||
+ master->dev.of_node = dev->of_node;
|
||||
+ master->bus_num = bus_num;
|
||||
+ master->num_chipselect = num_cs;
|
||||
master->transfer_one_message = bcm63xx_spi_transfer_one;
|
||||
master->mode_bits = MODEBITS;
|
||||
master->bits_per_word_mask = SPI_BPW_MASK(8);
|
||||
@@ -634,6 +663,7 @@ static struct platform_driver bcm63xx_sp
|
||||
.driver = {
|
||||
.name = "bcm63xx-spi",
|
||||
.pm = &bcm63xx_spi_pm_ops,
|
||||
+ .of_match_table = bcm63xx_spi_of_match,
|
||||
},
|
||||
.id_table = bcm63xx_spi_dev_match,
|
||||
.probe = bcm63xx_spi_probe,
|
@ -0,0 +1,35 @@ |
||||
From d03f23df6ff47898d76f06b3aa5dadcfa1ec8f4f Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Gorski <jonas.gorski@gmail.com>
|
||||
Date: Sun, 19 Feb 2017 23:40:22 +0100
|
||||
Subject: [PATCH 1/3] spi/bcm63xx-hsspi: allow providing clock rate through a
|
||||
second clock
|
||||
|
||||
Instead of requiring the hsspi clock to have a rate, allow using a second
|
||||
clock for providing the Hz rate, which is probably more correct anyway.
|
||||
|
||||
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
|
||||
---
|
||||
drivers/spi/spi-bcm63xx-hsspi.c | 12 ++++++++++--
|
||||
1 file changed, 10 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/drivers/spi/spi-bcm63xx-hsspi.c
|
||||
+++ b/drivers/spi/spi-bcm63xx-hsspi.c
|
||||
@@ -351,8 +351,16 @@ static int bcm63xx_hsspi_probe(struct pl
|
||||
return PTR_ERR(clk);
|
||||
|
||||
rate = clk_get_rate(clk);
|
||||
- if (!rate)
|
||||
- return -EINVAL;
|
||||
+ if (!rate) {
|
||||
+ struct clk *pll_clk = devm_clk_get(dev, "pll");
|
||||
+
|
||||
+ if (IS_ERR(pll_clk))
|
||||
+ return PTR_ERR(pll_clk);
|
||||
+
|
||||
+ rate = clk_get_rate(pll_clk);
|
||||
+ if (!rate)
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
|
||||
ret = clk_prepare_enable(clk);
|
||||
if (ret)
|
@ -0,0 +1,51 @@ |
||||
From ff759cc25db31bbb3469abb16a0306f110c4c7fa Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Gorski <jonas.gorski@gmail.com>
|
||||
Date: Thu, 10 Sep 2015 14:52:32 +0200
|
||||
Subject: [PATCH 2/3] dt-bindings: spi: document bcm63xx HS SPI devicetree
|
||||
bindings
|
||||
|
||||
Add documentation for the bindings of the high speed SPI controller found
|
||||
on newer bcm63xx SoCs.
|
||||
|
||||
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
|
||||
---
|
||||
.../devicetree/bindings/spi/spi-bcm63xx-hsspi.txt | 33 ++++++++++++++++++++++
|
||||
1 file changed, 33 insertions(+)
|
||||
create mode 100644 Documentation/devicetree/bindings/spi/spi-bcm63xx-hsspi.txt
|
||||
|
||||
--- /dev/null
|
||||
+++ b/Documentation/devicetree/bindings/spi/spi-bcm63xx-hsspi.txt
|
||||
@@ -0,0 +1,33 @@
|
||||
+Binding for Broadcom BCM6328 High Speed SPI controller
|
||||
+
|
||||
+Required properties:
|
||||
+- compatible: must contain of "brcm,bcm6328-hsspi".
|
||||
+- reg: Base address and size of the controllers memory area.
|
||||
+- interrupts: Interrupt for the SPI block.
|
||||
+- clocks: phandles of the SPI clock and the PLL clock.
|
||||
+- clock-names: must be "hsspi", "pll".
|
||||
+- #address-cells: <1>, as required by generic SPI binding.
|
||||
+- #size-cells: <0>, also as required by generic SPI binding.
|
||||
+
|
||||
+Optional properties:
|
||||
+- num-cs: some controllers have less than 8 cs signals. Defaults to 8
|
||||
+ if absent.
|
||||
+
|
||||
+Child nodes as per the generic SPI binding.
|
||||
+
|
||||
+Example:
|
||||
+
|
||||
+ spi@10001000 {
|
||||
+ compatible = "brcm,bcm6328-hsspi";
|
||||
+ reg = <0x10001000 0x600>;
|
||||
+
|
||||
+ interrupts = <29>;
|
||||
+
|
||||
+ clocks = <&clkctl 9>, <&hsspi_pll>;
|
||||
+ clock-names = "hsspi", "pll";
|
||||
+
|
||||
+ num-cs = <2>;
|
||||
+
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+ };
|
@ -0,0 +1,76 @@ |
||||
From 776041498c2b285a7f745c924e10fc11ef720eae Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Gorski <jonas.gorski@gmail.com>
|
||||
Date: Thu, 10 Sep 2015 14:53:53 +0200
|
||||
Subject: [PATCH 3/3] 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>
|
||||
---
|
||||
drivers/spi/spi-bcm63xx-hsspi.c | 23 ++++++++++++++++++++---
|
||||
1 file changed, 20 insertions(+), 3 deletions(-)
|
||||
|
||||
--- a/drivers/spi/spi-bcm63xx-hsspi.c
|
||||
+++ b/drivers/spi/spi-bcm63xx-hsspi.c
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/spi/spi.h>
|
||||
#include <linux/mutex.h>
|
||||
+#include <linux/of.h>
|
||||
|
||||
#define HSSPI_GLOBAL_CTRL_REG 0x0
|
||||
#define GLOBAL_CTRL_CS_POLARITY_SHIFT 0
|
||||
@@ -91,6 +92,7 @@
|
||||
|
||||
#define HSSPI_MAX_SYNC_CLOCK 30000000
|
||||
|
||||
+#define HSSPI_SPI_MAX_CS 8
|
||||
#define HSSPI_BUS_NUM 1 /* 0 is legacy SPI */
|
||||
|
||||
struct bcm63xx_hsspi {
|
||||
@@ -332,7 +334,7 @@ static int bcm63xx_hsspi_probe(struct pl
|
||||
struct device *dev = &pdev->dev;
|
||||
struct clk *clk;
|
||||
int irq, ret;
|
||||
- u32 reg, rate;
|
||||
+ u32 reg, rate, num_cs = HSSPI_SPI_MAX_CS;
|
||||
|
||||
irq = platform_get_irq(pdev, 0);
|
||||
if (irq < 0) {
|
||||
@@ -382,8 +384,17 @@ static int bcm63xx_hsspi_probe(struct pl
|
||||
mutex_init(&bs->bus_mutex);
|
||||
init_completion(&bs->done);
|
||||
|
||||
- master->bus_num = HSSPI_BUS_NUM;
|
||||
- master->num_chipselect = 8;
|
||||
+ master->dev.of_node = dev->of_node;
|
||||
+ if (!dev->of_node)
|
||||
+ master->bus_num = HSSPI_BUS_NUM;
|
||||
+
|
||||
+ of_property_read_u32(dev->of_node, "num-cs", &num_cs);
|
||||
+ if (num_cs > 8) {
|
||||
+ dev_warn(dev, "unsupported number of cs (%i), reducing to 8\n",
|
||||
+ num_cs);
|
||||
+ num_cs = HSSPI_SPI_MAX_CS;
|
||||
+ }
|
||||
+ master->num_chipselect = num_cs;
|
||||
master->setup = bcm63xx_hsspi_setup;
|
||||
master->transfer_one_message = bcm63xx_hsspi_transfer_one;
|
||||
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH |
|
||||
@@ -469,10 +480,16 @@ static int bcm63xx_hsspi_resume(struct d
|
||||
static SIMPLE_DEV_PM_OPS(bcm63xx_hsspi_pm_ops, bcm63xx_hsspi_suspend,
|
||||
bcm63xx_hsspi_resume);
|
||||
|
||||
+static const struct of_device_id bcm63xx_hsspi_of_match[] = {
|
||||
+ { .compatible = "brcm,bcm6328-hsspi", },
|
||||
+ { },
|
||||
+};
|
||||
+
|
||||
static struct platform_driver bcm63xx_hsspi_driver = {
|
||||
.driver = {
|
||||
.name = "bcm63xx-hsspi",
|
||||
.pm = &bcm63xx_hsspi_pm_ops,
|
||||
+ .of_match_table = bcm63xx_hsspi_of_match,
|
||||
},
|
||||
.probe = bcm63xx_hsspi_probe,
|
||||
.remove = bcm63xx_hsspi_remove,
|
@ -0,0 +1,35 @@ |
||||
From 39d2882058345b5994680b8731848a0343878019 Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Gorski <jonas.gorski@gmail.com>
|
||||
Date: Sat, 4 Feb 2017 12:58:50 +0100
|
||||
Subject: [PATCH 7/8] MIPS: BCM63XX: do not register SPI controllers
|
||||
|
||||
We now register them through DT, so no need to keep them here.
|
||||
|
||||
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
|
||||
---
|
||||
arch/mips/bcm63xx/boards/board_bcm963xx.c | 7 -------
|
||||
1 file changed, 7 deletions(-)
|
||||
|
||||
--- a/arch/mips/bcm63xx/boards/board_common.c
|
||||
+++ b/arch/mips/bcm63xx/boards/board_common.c
|
||||
@@ -29,9 +29,7 @@
|
||||
#include <bcm63xx_dev_enet.h>
|
||||
#include <bcm63xx_dev_dsp.h>
|
||||
#include <bcm63xx_dev_flash.h>
|
||||
-#include <bcm63xx_dev_hsspi.h>
|
||||
#include <bcm63xx_dev_pcmcia.h>
|
||||
-#include <bcm63xx_dev_spi.h>
|
||||
#include <bcm63xx_dev_usb_ehci.h>
|
||||
#include <bcm63xx_dev_usb_ohci.h>
|
||||
#include <bcm63xx_dev_usb_usbd.h>
|
||||
@@ -250,10 +248,6 @@ int __init board_register_devices(void)
|
||||
bcm63xx_register_fallback_sprom(&board.fallback_sprom)))
|
||||
pr_err(PFX "failed to register fallback SPROM\n");
|
||||
|
||||
- bcm63xx_spi_register();
|
||||
-
|
||||
- bcm63xx_hsspi_register();
|
||||
-
|
||||
if (board.num_spis)
|
||||
spi_register_board_info(board.spis, board.num_spis);
|
||||
|
Loading…
Reference in new issue