mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Teresa Gámez" <t.gamez@phytec.de>
To: barebox@lists.infradead.org
Subject: [PATCH 2/3] omap3_spi: Add CS check for AM33xx
Date: Tue, 18 Jun 2013 13:25:46 +0200	[thread overview]
Message-ID: <1371554747-9052-3-git-send-email-t.gamez@phytec.de> (raw)
In-Reply-To: <1371554747-9052-1-git-send-email-t.gamez@phytec.de>

AM33xx has only 2 McSPI busses and 2 CS for each bus.
Added comment and the check.

Signed-off-by: Teresa Gámez <t.gamez@phytec.de>
---
 drivers/spi/omap3_spi.c |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/omap3_spi.c b/drivers/spi/omap3_spi.c
index e6581df..1eb0e6a 100644
--- a/drivers/spi/omap3_spi.c
+++ b/drivers/spi/omap3_spi.c
@@ -326,11 +326,17 @@ static int omap3_spi_transfer(struct spi_device *spi, struct spi_message *mesg)
 static int omap3_spi_setup(struct spi_device *spi)
 {
 	struct spi_master *master = spi->master;
+	int is_not_valid;
 
-	if (((master->bus_num == 1) && (spi->chip_select > 3)) ||
+	if (IS_ENABLED(CONFIG_ARCH_OMAP3))
+		is_not_valid = ((master->bus_num == 1) && (spi->chip_select > 3)) ||
 			((master->bus_num == 2) && (spi->chip_select > 1)) ||
 			((master->bus_num == 3) && (spi->chip_select > 1)) ||
-			((master->bus_num == 4) && (spi->chip_select > 0))) {
+			((master->bus_num == 4) && (spi->chip_select > 0));
+	else
+		is_not_valid = (spi->chip_select > 1);
+
+	if (is_not_valid) {
 		printf("SPI error: unsupported chip select %i \
 			on bus %i\n", spi->chip_select, master->bus_num);
 		return -EINVAL;
@@ -368,12 +374,20 @@ static int omap3_spi_probe(struct device_d *dev)
 	 * McSPI3 has 2 CS (bus 3, cs 0 - 1)
 	 * McSPI4 has 1 CS (bus 4, cs 0)
 	 *
+	 * AM335x McSPI has 2 busses with 2 chip selects:
+	 * McSPI0 has 2 CS (bus 0, cs 0 - 1)
+	 * McSPI1 has 2 CS (bus 1, cs 0 - 1)
+	 *
 	 * The board code has to make sure that it does not use
 	 * invalid buses or chip selects.
 	 */
 
 	master->bus_num = dev->id;
-	master->num_chipselect = 4;
+
+	if (IS_ENABLED(CONFIG_ARCH_OMAP3))
+		master->num_chipselect = 4;
+	else
+		master->num_chipselect = 2;
 	master->setup = omap3_spi_setup;
 	master->transfer = omap3_spi_transfer;
 
-- 
1.7.0.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2013-06-18 11:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-18 11:25 [PATCH 0/3] More AM33xx SPI patches Teresa Gámez
2013-06-18 11:25 ` [PATCH 1/3] ARM: OMAP: AM33xx: Add muxing function for spi0 Teresa Gámez
2013-06-18 11:25 ` Teresa Gámez [this message]
2013-06-18 11:25 ` [PATCH 3/3] ARM: OMAP: pcm051: Add spi flash support Teresa Gámez
2013-06-18 12:11   ` Alexander Aring

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=1371554747-9052-3-git-send-email-t.gamez@phytec.de \
    --to=t.gamez@phytec.de \
    --cc=barebox@lists.infradead.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