diff mbox

spi-orion: add device tree binding

Message ID 20120723100809.GC18778@lunn.ch (mailing list archive)
State New, archived
Headers show

Commit Message

Andrew Lunn July 23, 2012, 10:08 a.m. UTC
From 528a19e9eda968cc673331d566cbfe20962d3b32 Mon Sep 17 00:00:00 2001
From: Michael Walle <michael@walle.cc>
Date: Wed, 6 Jun 2012 19:16:28 +0200
Subject: [PATCHv3] spi-orion: add device tree binding

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>
---
v2: Add interrupts properties as optional. Not used at the moment.
    Add cell-index, since some SoCs have multiple SPI busses.
v3: Rebased onto 3.5-rc7 without the refactor patch.

---
 Documentation/devicetree/bindings/spi/spi-orion.txt |   19 +++++++++++++++++++
 drivers/spi/spi-orion.c                             |   17 +++++++++++++++++
 2 files changed, 36 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/spi-orion.txt

Comments

Mark Brown July 23, 2012, 10:43 a.m. UTC | #1
On Mon, Jul 23, 2012 at 12:08:09PM +0200, Andrew Lunn wrote:
> From 528a19e9eda968cc673331d566cbfe20962d3b32 Mon Sep 17 00:00:00 2001
> From: Michael Walle <michael@walle.cc>
> Date: Wed, 6 Jun 2012 19:16:28 +0200
> Subject: [PATCHv3] spi-orion: add device tree binding

I really shouldn't need to remind you about the format for sending
patches :(

> +Optional properties:
> +- interrupts : Is currently not used.

Would it not be better to just omit this if it doesn't do anything and
doesn't have any semantics defined?

I've applied this.  If you could send the other patches that'd be
helpful...
Mark Brown July 23, 2012, 10:44 a.m. UTC | #2
On Mon, Jul 23, 2012 at 12:08:09PM +0200, Andrew Lunn wrote:

> 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>

Hrm, I thought you said Linus W had acked this?
Andrew Lunn July 23, 2012, 10:50 a.m. UTC | #3
On Mon, Jul 23, 2012 at 11:44:19AM +0100, Mark Brown wrote:
> On Mon, Jul 23, 2012 at 12:08:09PM +0200, Andrew Lunn wrote:
> 
> > 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>
> 
> Hrm, I thought you said Linus W had acked this?

He acked the refactor patch, not this one.

   Andrew
Andrew Lunn July 23, 2012, 10:59 a.m. UTC | #4
On Mon, Jul 23, 2012 at 11:43:34AM +0100, Mark Brown wrote:
> On Mon, Jul 23, 2012 at 12:08:09PM +0200, Andrew Lunn wrote:
> > From 528a19e9eda968cc673331d566cbfe20962d3b32 Mon Sep 17 00:00:00 2001
> > From: Michael Walle <michael@walle.cc>
> > Date: Wed, 6 Jun 2012 19:16:28 +0200
> > Subject: [PATCHv3] spi-orion: add device tree binding
> 
> I really shouldn't need to remind you about the format for sending
> patches :(
> 
> > +Optional properties:
> > +- interrupts : Is currently not used.
> 
> Would it not be better to just omit this if it doesn't do anything and
> doesn't have any semantics defined?

I was specifically asked to include this, which is why it appeared in
v2, not the first version. I forget who it was who asked for it, maybe
Arnd Bergmann? I can dig through my email archive if you want to know.

> 
> I've applied this.  If you could send the other patches that'd be
> helpful...

O.K.

Thanks
	Andrew
Mark Brown July 23, 2012, 11:12 a.m. UTC | #5
On Mon, Jul 23, 2012 at 12:59:45PM +0200, Andrew Lunn wrote:
> On Mon, Jul 23, 2012 at 11:43:34AM +0100, Mark Brown wrote:
> > On Mon, Jul 23, 2012 at 12:08:09PM +0200, Andrew Lunn wrote:

> > > +Optional properties:
> > > +- interrupts : Is currently not used.

> > Would it not be better to just omit this if it doesn't do anything and
> > doesn't have any semantics defined?

> I was specifically asked to include this, which is why it appeared in
> v2, not the first version. I forget who it was who asked for it, maybe
> Arnd Bergmann? I can dig through my email archive if you want to know.

If you're going to include it you should define some sematics for it.
You could define an optional "yohNg1ai" property too...
Arnd Bergmann July 23, 2012, 5:43 p.m. UTC | #6
On Monday 23 July 2012, Mark Brown wrote:
> On Mon, Jul 23, 2012 at 12:59:45PM +0200, Andrew Lunn wrote:
> > On Mon, Jul 23, 2012 at 11:43:34AM +0100, Mark Brown wrote:
> > > On Mon, Jul 23, 2012 at 12:08:09PM +0200, Andrew Lunn wrote:
> 
> > > > +Optional properties:
> > > > +- interrupts : Is currently not used.
> 
> > > Would it not be better to just omit this if it doesn't do anything and
> > > doesn't have any semantics defined?
> 
> > I was specifically asked to include this, which is why it appeared in
> > v2, not the first version. I forget who it was who asked for it, maybe
> > Arnd Bergmann? I can dig through my email archive if you want to know.
> 
> If you're going to include it you should define some sematics for it.
> You could define an optional "yohNg1ai" property too...

Agreed. I'm rather sure I did not ask for an unused property to be
documented. However, the documentation should definitely match the
example and the what kinds of properties are used in the device tree.

If the device has an interrupt that is not used by Linux, I would
document what the interrupt is for.

	Arnd
diff mbox

Patch

diff --git a/Documentation/devicetree/bindings/spi/spi-orion.txt b/Documentation/devicetree/bindings/spi/spi-orion.txt
new file mode 100644
index 0000000..a3ff50f
--- /dev/null
+++ b/Documentation/devicetree/bindings/spi/spi-orion.txt
@@ -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";
+       };
diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c
index dfd04e9..74312a8 100644
--- a/drivers/spi/spi-orion.c
+++ b/drivers/spi/spi-orion.c
@@ -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),
 };