Devicetree
 help / color / mirror / Atom feed
From: Ernst Schwab <eschwab-BGeptl67XyCzQB+pC5nmwQ@public.gmane.org>
To: grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
Subject: [PATCH] of: add bus-number specification to spi_mpc8xxx
Date: Tue, 16 Feb 2010 15:08:50 +0100	[thread overview]
Message-ID: <20100216150850.d966cd79.eschwab@online.de> (raw)

From: Ernst Schwab <eschwab-BGeptl67XyCzQB+pC5nmwQ@public.gmane.org>

Added devicetree parsing for SPI bus number. If no bus number is specified,
a dynamically assigned bus number will be used (typically 32766).

Signed-off-by: Ernst Schwab <eschwab-BGeptl67XyCzQB+pC5nmwQ@public.gmane.org>
---
diff -upr a/Documentation/powerpc/dts-bindings/fsl/spi.txt b/Documentation/powerpc/dts-bindings/fsl/spi.txt
--- a/Documentation/powerpc/dts-bindings/fsl/spi.txt
+++ b/Documentation/powerpc/dts-bindings/fsl/spi.txt
@@ -4,6 +4,8 @@ Required properties:
 - cell-index : SPI controller index.
 - compatible : should be "fsl,spi".
 - mode : the SPI operation mode, it can be "cpu" or "cpu-qe".
+- bus-number : number of the SPI bus. If unspecified, a dynamically
+  assigned bus number will be used.
 - reg : Offset and length of the register set for the device
 - interrupts : <a b> where a is the interrupt number and b is a
   field that represents an encoding of the sense and level
@@ -21,4 +23,5 @@ Example:
 		interrupts = <82 0>;
 		interrupt-parent = <700>;
 		mode = "cpu";
+		bus-number = <0>;
 	};
diff -upr a/drivers/spi/spi_mpc8xxx.c b/drivers/spi/spi_mpc8xxx.c
--- a/drivers/spi/spi_mpc8xxx.c
+++ b/drivers/spi/spi_mpc8xxx.c
@@ -1230,6 +1230,8 @@ static int __devinit of_mpc8xxx_spi_prob
 	struct resource mem;
 	struct resource irq;
 	const void *prop;
+	const int *bus_num;
+	int len;
 	int ret = -ENOMEM;
 
 	pinfo = kzalloc(sizeof(*pinfo), GFP_KERNEL);
@@ -1239,8 +1241,16 @@ static int __devinit of_mpc8xxx_spi_prob
 	pdata = &pinfo->pdata;
 	dev->platform_data = pdata;
 
-	/* Allocate bus num dynamically. */
-	pdata->bus_num = -1;
+
+	bus_num = of_get_property(np, "bus-number", &len);
+	if (bus_num && len == sizeof(*bus_num)) {
+		/* bus number is specified in node */
+		pdata->bus_num = *bus_num;
+	} else {
+		/* Allocate bus num dynamically. */
+		pdata->bus_num = -1;
+	}
+
 
 	/* SPI controller is either clocked from QE or SoC clock. */
 	pdata->sysclk = get_brgfreq();

             reply	other threads:[~2010-02-16 14:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-16 14:08 Ernst Schwab [this message]
     [not found] ` <20100216150850.d966cd79.eschwab-BGeptl67XyCzQB+pC5nmwQ@public.gmane.org>
2010-02-16 14:28   ` [PATCH] of: add bus-number specification to spi_mpc8xxx Grant Likely
     [not found]     ` <fa686aa41002160628g62bd6564h50e712e8fb9c384d-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-02-16 15:08       ` Ernst Schwab
     [not found]         ` <20100216160832.730cb00b.eschwab-BGeptl67XyCzQB+pC5nmwQ@public.gmane.org>
2010-02-16 15:18           ` Grant Likely
     [not found]             ` <fa686aa41002160718u36fe6f7ey7be83ab69317ec76-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-02-16 18:59               ` Ernst Schwab
     [not found]                 ` <20100216195943.e40e104e.eschwab-BGeptl67XyCzQB+pC5nmwQ@public.gmane.org>
2010-02-16 21:23                   ` Grant Likely
     [not found]                     ` <fa686aa41002161323v72dbcdb4rd28ece040c878972-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-02-17 11:11                       ` Ernst Schwab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100216150850.d966cd79.eschwab@online.de \
    --to=eschwab-bgeptl67xyczqb+pc5nmwq@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox