linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Gregory CLEMENT <gregory.clement@bootlin.com>
To: Mark Brown <broonie@kernel.org>,
	linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>,
	Gregory CLEMENT <gregory.clement@bootlin.com>,
	Ludovic Desroches <ludovic.desroches@microchip.com>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH 7/7] spi: atmel: Improve CS0 case support on AT91RM9200
Date: Thu, 17 Oct 2019 16:18:46 +0200	[thread overview]
Message-ID: <20191017141846.7523-8-gregory.clement@bootlin.com> (raw)
In-Reply-To: <20191017141846.7523-1-gregory.clement@bootlin.com>

Thanks to the recent change in this driver, it is now possible to
prevent using the CS0 with GPIO during setup. It then allows to remove
the special handling of this case in the cs_activate() and
cs_deactivate() functions.

Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
---
 drivers/spi/spi-atmel.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
index ac5e2ddf9e1b..d88e2aa64839 100644
--- a/drivers/spi/spi-atmel.c
+++ b/drivers/spi/spi-atmel.c
@@ -371,7 +371,7 @@ static void cs_activate(struct atmel_spi *as, struct spi_device *spi)
 
 		mr = spi_readl(as, MR);
 		mr = SPI_BFINS(PCS, ~(1 << chip_select), mr);
-		if (spi->cs_gpiod && spi->chip_select != 0)
+		if (spi->cs_gpiod)
 			gpiod_set_value(spi->cs_gpiod, 1);
 		spi_writel(as, MR, mr);
 	}
@@ -402,7 +402,7 @@ static void cs_deactivate(struct atmel_spi *as, struct spi_device *spi)
 
 	if (!spi->cs_gpiod)
 		spi_writel(as, CR, SPI_BIT(LASTXFER));
-	else if (atmel_spi_is_v2(as) || spi->chip_select != 0)
+	else
 		gpiod_set_value(spi->cs_gpiod, 0);
 }
 
@@ -1193,7 +1193,16 @@ static void initialize_native_cs_for_gpio(struct atmel_spi *as)
 	if (!master->cs_gpiods)
 		return; /* No CS GPIO */
 
-	for (i = 0; i < 4; i++)
+	/*
+	 * On the first version of the controller (AT91RM9200), CS0
+	 * can't be used associated with GPIO
+	 */
+	if (atmel_spi_is_v2(as))
+		i = 0;
+	else
+		i = 1;
+
+	for (; i < 4; i++)
 		if (master->cs_gpiods[i])
 			as->native_cs_free |= BIT(i);
 
-- 
2.23.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2019-10-17 14:22 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-17 14:18 [PATCH 0/7] atmel-spi: Allow using more than 4 GPIOs as CS Gregory CLEMENT
2019-10-17 14:18 ` [PATCH 1/7] spi: atmel: Remove and fix erroneous comments Gregory CLEMENT
2019-10-18 18:07   ` Applied "spi: atmel: Remove and fix erroneous comments" to the spi tree Mark Brown
2019-10-17 14:18 ` [PATCH 2/7] spi: atmel: Fix CS high support Gregory CLEMENT
2019-10-18 18:07   ` Applied "spi: atmel: Fix CS high support" to the spi tree Mark Brown
2019-10-17 14:18 ` [PATCH 3/7] spi: atmel: Configure GPIO per CS instead of by controller Gregory CLEMENT
2019-10-18 18:07   ` Applied "spi: atmel: Configure GPIO per CS instead of by controller" to the spi tree Mark Brown
2019-10-17 14:18 ` [PATCH 4/7] spi: atmel: Remove useless private field Gregory CLEMENT
2019-10-18 18:07   ` Applied "spi: atmel: Remove useless private field" to the spi tree Mark Brown
2019-10-17 14:18 ` [PATCH 5/7] spi: atmel: Remove platform data support Gregory CLEMENT
2019-10-18 18:07   ` Applied "spi: atmel: Remove platform data support" to the spi tree Mark Brown
2019-10-17 14:18 ` [PATCH 6/7] spi: atmel: Improve and fix GPIO CS usage Gregory CLEMENT
2019-10-18 18:07   ` Applied "spi: atmel: Improve and fix GPIO CS usage" to the spi tree Mark Brown
2019-10-17 14:18 ` Gregory CLEMENT [this message]
2019-10-18 18:07   ` Applied "spi: atmel: Improve CS0 case support on AT91RM9200" " Mark Brown

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=20191017141846.7523-8-gregory.clement@bootlin.com \
    --to=gregory.clement@bootlin.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=broonie@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=ludovic.desroches@microchip.com \
    --cc=thomas.petazzoni@bootlin.com \
    /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).