]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
spi/orion: add device tree binding
authorAndrew Lunn <andrew@lunn.ch>
Mon, 23 Jul 2012 10:08:09 +0000 (12:08 +0200)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Mon, 23 Jul 2012 10:43:39 +0000 (11:43 +0100)
Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Acked-by: Jason Cooper <jason@lakedaemon.net>
Acked-by: Sebastian Hesselbarth <sebastian.hesselbarth@googlemail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Documentation/devicetree/bindings/spi/spi-orion.txt [new file with mode: 0644]
drivers/spi/spi-orion.c

diff --git a/Documentation/devicetree/bindings/spi/spi-orion.txt b/Documentation/devicetree/bindings/spi/spi-orion.txt
new file mode 100644 (file)
index 0000000..a3ff50f
--- /dev/null
@@ -0,0 +1,19 @@
+Marvell Orion SPI device
+
+Required properties:
+- compatible : should be "marvell,orion-spi".
+- reg : offset and length of the register set for the device
+- cell-index : Which of multiple SPI controllers is this.
+Optional properties:
+- interrupts : Is currently not used.
+
+Example:
+       spi@10600 {
+              compatible = "marvell,orion-spi";
+              #address-cells = <1>;
+              #size-cells = <0>;
+              cell-index = <0>;
+              reg = <0x10600 0x28>;
+              interrupts = <23>;
+              status = "disabled";
+       };
index dfd04e91fa6da35d14c89f3aeb874935d41da339..74312a862ba80b235f731cf6fbe867b0f96ffdff 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/io.h>
 #include <linux/spi/spi.h>
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/clk.h>
 #include <asm/unaligned.h>
 
@@ -453,6 +454,8 @@ static int __init orion_spi_probe(struct platform_device *pdev)
        struct orion_spi_info *spi_info;
        unsigned long tclk_hz;
        int status = 0;
+       const u32 *iprop;
+       int size;
 
        spi_info = pdev->dev.platform_data;
 
@@ -464,6 +467,12 @@ static int __init orion_spi_probe(struct platform_device *pdev)
 
        if (pdev->id != -1)
                master->bus_num = pdev->id;
+       if (pdev->dev.of_node) {
+               iprop = of_get_property(pdev->dev.of_node, "cell-index",
+                                       &size);
+               if (iprop && size == sizeof(*iprop))
+                       master->bus_num = *iprop;
+       }
 
        /* we support only mode 0, and no options */
        master->mode_bits = 0;
@@ -511,6 +520,7 @@ static int __init orion_spi_probe(struct platform_device *pdev)
        if (orion_spi_reset(spi) < 0)
                goto out_rel_mem;
 
+       master->dev.of_node = pdev->dev.of_node;
        status = spi_register_master(master);
        if (status < 0)
                goto out_rel_mem;
@@ -552,10 +562,17 @@ static int __exit orion_spi_remove(struct platform_device *pdev)
 
 MODULE_ALIAS("platform:" DRIVER_NAME);
 
+static const struct of_device_id orion_spi_of_match_table[] __devinitdata = {
+       { .compatible = "marvell,orion-spi", },
+       {}
+};
+MODULE_DEVICE_TABLE(of, orion_spi_of_match_table);
+
 static struct platform_driver orion_spi_driver = {
        .driver = {
                .name   = DRIVER_NAME,
                .owner  = THIS_MODULE,
+               .of_match_table = of_match_ptr(orion_spi_of_match_table),
        },
        .remove         = __exit_p(orion_spi_remove),
 };