linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tobias Klauser <tklauser-93Khv+1bN0NyDzI6CaY1VQ@public.gmane.org>
To: Grant Likely
	<grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>,
	spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
	Frederic Lambert
	<frdrc66-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>
Subject: [PATCH] spi/spi-altera: Allow to explicitely override bus number via dts
Date: Tue, 31 Jan 2012 16:54:06 +0100	[thread overview]
Message-ID: <1328025246-23450-1-git-send-email-tklauser@distanz.ch> (raw)

From: Frederic Lambert <frdrc66-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Until now we let the code in spi.c assign us the bus number if the platform
device didn't specify its id. This patch adds the possibility to explicitely
specify the bus number via device tree.

Signed-off-by: Frederic Lambert <frdrc66-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Signed-off-by: Tobias Klauser <tklauser-93Khv+1bN0NyDzI6CaY1VQ@public.gmane.org>
---
 .../devicetree/bindings/spi/spi_altera.txt         |    3 +++
 drivers/spi/spi-altera.c                           |    9 +++++++++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/Documentation/devicetree/bindings/spi/spi_altera.txt b/Documentation/devicetree/bindings/spi/spi_altera.txt
index dda3759..3e0e921 100644
--- a/Documentation/devicetree/bindings/spi/spi_altera.txt
+++ b/Documentation/devicetree/bindings/spi/spi_altera.txt
@@ -2,3 +2,6 @@ Altera SPI
 
 Required properties:
 - compatible : should be "ALTR,spi-1.0".
+
+Optional property:
+- bus-number : SPI bus number
diff --git a/drivers/spi/spi-altera.c b/drivers/spi/spi-altera.c
index 4813a63..d5bf52b 100644
--- a/drivers/spi/spi-altera.c
+++ b/drivers/spi/spi-altera.c
@@ -226,6 +226,15 @@ static int __devinit altera_spi_probe(struct platform_device *pdev)
 	if (!master)
 		return err;
 
+	/* bus_num is dynamically assigned when undefined (see spi.c)  */
+	/* look for a DTS entry to override this */
+	if (pdev->id == -1 && pdev->dev.of_node != 0) {
+		u32 tmp;
+
+		if (of_property_read_u32(pdev->dev.of_node, "bus-number", &tmp) == 0)
+			pdev->id = tmp;
+	}
+
 	/* setup the master state. */
 	master->bus_num = pdev->id;
 	master->num_chipselect = 16;
-- 
1.7.5.4

             reply	other threads:[~2012-01-31 15:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-31 15:54 Tobias Klauser [this message]
     [not found] ` <1328025246-23450-1-git-send-email-tklauser-93Khv+1bN0NyDzI6CaY1VQ@public.gmane.org>
2012-02-01 13:55   ` [PATCH] spi/spi-altera: Allow to explicitely override bus number via dts Mark Brown
     [not found]     ` <20120201135524.GD13723-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2012-02-01 14:01       ` Frederic LAMBERT
     [not found]         ` <CAMVnO+kWX=NYi+YU9H5nRc9UksCJLQUi-_Kj9UASwoiqZj9tGA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-02-01 14:08           ` Mark Brown
     [not found]             ` <20120201140838.GE13723-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2012-02-01 14:25               ` Frederic LAMBERT
     [not found]                 ` <CAMVnO+m5DTYeK9mHcciqU-y7HGP-d9FXWkvTV4ZJJLTRqjK7LQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-02-01 14:35                   ` Mark Brown
     [not found]                     ` <20120201143558.GF13723-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2012-02-01 14:53                       ` Frederic LAMBERT
     [not found]                         ` <CAMVnO+n2SW=e7EP-MjLbFeF7ZW6e=FwL=UdOd=cd-XN=C132Qg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-02-01 15:05                           ` Mark Brown
     [not found]                             ` <20120201150517.GG13723-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2012-02-01 15:29                               ` Frederic LAMBERT
     [not found]                                 ` <CAMVnO+kvjbxW7EdMe_YF=oSp0bR-RqaP_rPM57tyHzGKhsoNxg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-02-01 15:42                                   ` Mark Brown
     [not found]                                     ` <20120201154204.GH13723-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2012-02-01 15:52                                       ` Frederic LAMBERT
     [not found]                                         ` <CAMVnO+nB77XOQHfL1zZLve_=z6vFk_HMF+hj=iMTAuOAYSRExA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-02-01 17:57                                           ` Grant Likely
2012-02-01 18:10                                           ` Mark Brown
2012-02-01 17:59   ` Grant Likely

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=1328025246-23450-1-git-send-email-tklauser@distanz.ch \
    --to=tklauser-93khv+1bn0nydzi6cay1vq@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=frdrc66-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org \
    --cc=rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org \
    --cc=spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@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;
as well as URLs for NNTP newsgroup(s).