linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: omap2-mcspi: Fix native cs with new set_cs
@ 2015-05-12 17:38 Michael Welling
  2015-05-12 18:57 ` Nishanth Menon
  2015-05-12 19:17 ` Mark Brown
  0 siblings, 2 replies; 20+ messages in thread
From: Michael Welling @ 2015-05-12 17:38 UTC (permalink / raw)
  To: broonie, linux-omap, linux-arm-kernel, linux-next, linux-spi,
	linux-kernel
  Cc: Michael Welling

GPIO chip select patch series appears to have broken the native chip select
support. This patch pulls the manual native chip select toggling out of
the transfer_one routine and adds a set_cs routine.

Tested natively on AM3354 with SPI serial flash on spi0cs0.

Signed-off-by: Michael Welling <mwelling@ieee.org>
---
 drivers/spi/spi-omap2-mcspi.c |   33 +++++++++++----------------------
 1 file changed, 11 insertions(+), 22 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 90cf7e7..a7d85c5 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -243,17 +243,20 @@ static void omap2_mcspi_set_enable(const struct spi_device *spi, int enable)
 	mcspi_read_cs_reg(spi, OMAP2_MCSPI_CHCTRL0);
 }
 
-static void omap2_mcspi_force_cs(struct spi_device *spi, int cs_active)
+static void omap2_mcspi_set_cs(struct spi_device *spi, bool enable)
 {
 	u32 l;
 
-	l = mcspi_cached_chconf0(spi);
-	if (cs_active)
-		l |= OMAP2_MCSPI_CHCONF_FORCE;
-	else
-		l &= ~OMAP2_MCSPI_CHCONF_FORCE;
+	if (spi->controller_state) {
+		l = mcspi_cached_chconf0(spi);
 
-	mcspi_write_chconf0(spi, l);
+		if (enable)
+			l &= ~OMAP2_MCSPI_CHCONF_FORCE;
+		else
+			l |= OMAP2_MCSPI_CHCONF_FORCE;
+
+		mcspi_write_chconf0(spi, l);
+	}
 }
 
 static void omap2_mcspi_set_master_mode(struct spi_master *master)
@@ -1075,7 +1078,6 @@ static int omap2_mcspi_work_one(struct omap2_mcspi *mcspi,
 
 	struct spi_master		*master;
 	struct omap2_mcspi_dma		*mcspi_dma;
-	int				cs_active = 0;
 	struct omap2_mcspi_cs		*cs;
 	struct omap2_mcspi_device_config *cd;
 	int				par_override = 0;
@@ -1118,11 +1120,6 @@ static int omap2_mcspi_work_one(struct omap2_mcspi *mcspi,
 			mcspi_read_cs_reg(spi, OMAP2_MCSPI_MODULCTRL);
 	}
 
-	if (!cs_active) {
-		omap2_mcspi_force_cs(spi, 1);
-		cs_active = 1;
-	}
-
 	chconf = mcspi_cached_chconf0(spi);
 	chconf &= ~OMAP2_MCSPI_CHCONF_TRM_MASK;
 	chconf &= ~OMAP2_MCSPI_CHCONF_TURBO;
@@ -1169,12 +1166,6 @@ static int omap2_mcspi_work_one(struct omap2_mcspi *mcspi,
 	if (t->delay_usecs)
 		udelay(t->delay_usecs);
 
-	/* ignore the "leave it on after last xfer" hint */
-	if (t->cs_change) {
-		omap2_mcspi_force_cs(spi, 0);
-		cs_active = 0;
-	}
-
 	omap2_mcspi_set_enable(spi, 0);
 
 	if (mcspi->fifo_depth > 0)
@@ -1187,9 +1178,6 @@ out:
 		status = omap2_mcspi_setup_transfer(spi, NULL);
 	}
 
-	if (cs_active)
-		omap2_mcspi_force_cs(spi, 0);
-
 	if (cd && cd->cs_per_word) {
 		chconf = mcspi->ctx.modulctrl;
 		chconf |= OMAP2_MCSPI_MODULCTRL_SINGLE;
@@ -1334,6 +1322,7 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
 	master->setup = omap2_mcspi_setup;
 	master->auto_runtime_pm = true;
 	master->transfer_one = omap2_mcspi_transfer_one;
+	master->set_cs = omap2_mcspi_set_cs;
 	master->cleanup = omap2_mcspi_cleanup;
 	master->dev.of_node = node;
 	master->max_speed_hz = OMAP2_MCSPI_MAX_FREQ;
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2015-05-25 12:00 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-12 17:38 [PATCH] spi: omap2-mcspi: Fix native cs with new set_cs Michael Welling
2015-05-12 18:57 ` Nishanth Menon
     [not found]   ` <55524D20.2050203-l0cyMroinI0@public.gmane.org>
2015-05-12 19:19     ` Mark Brown
2015-05-12 19:21       ` Nishanth Menon
2015-05-12 19:17 ` Mark Brown
     [not found]   ` <20150512191758.GX3066-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-05-21  2:07     ` Michael Welling
2015-05-21 10:18       ` Mark Brown
2015-05-21 21:04         ` Michael Welling
2015-05-21 21:16           ` Mark Brown
2015-05-21 23:48             ` Michael Welling
2015-05-22 12:25               ` Mark Brown
2015-05-22 15:31                 ` Michael Welling
2015-05-24  2:13                 ` [PATCH 0/4] spi: omap2-mcspi: Fixes for recent updates Michael Welling
2015-05-24  2:13                   ` [PATCH 1/4] spi: omap2-mcspi: Remove unnecessary delay Michael Welling
2015-05-24  2:13                   ` [PATCH 2/4] spi: omap2-mcspi: Fix set_cs function for active high Michael Welling
2015-05-24  2:13                   ` [PATCH 3/4] spi: omap2-mcspi: Fix GPIO chip select support Michael Welling
2015-05-24  2:13                   ` [PATCH 4/4] spi: omap2-mcspi: Handle error on gpio_request Michael Welling
2015-05-24  8:13                     ` Nicholas Mc Guire
2015-05-24 16:52                       ` Michael Welling
     [not found]                   ` <1432433625-23407-1-git-send-email-mwelling-EkmVulN54Sk@public.gmane.org>
2015-05-25 12:00                     ` [PATCH 0/4] spi: omap2-mcspi: Fixes for recent updates Mark Brown

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).