[PATCHv2 2/3] omap3_spi: Add CS check for AM33xx

Teresa Gámez t.gamez at phytec.de
Tue Jun 18 09:15:46 EDT 2013


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




More information about the barebox mailing list