diff mbox

SPI: IMX5/6: Set inactive state of SPI clock (SCLK CTL) according to SPI clock polarity

Message ID 503B73B1.9010801@de.bosch.com (mailing list archive)
State New, archived
Headers show

Commit Message

Knut Wohlrab Aug. 27, 2012, 1:18 p.m. UTC
For our SPI device we need a SPI clock with active low polarity and a a 
high inactive state.

We add the setting of the inactive state ECSPIx_CONFIGREG:SCLK CTL 
according to the clock polarity ECSPIx_CONFIGREG:SCLK POL:

Device tree _without_ "spi-cpol" = 0 = clock active high polarity = 
inactive state low
Device tree with "spi-cpol" = 1 = clock active low polarity = inactive 
state high

Are there real world examples for a need of an individual setting of 
clock polarity/inactive state?
diff mbox

Patch

From 84b2a00868e4775987dc8ed11f9372eea578f7c3 Mon Sep 17 00:00:00 2001
From: Knut Wohlrab <knut.wohlrab@de.bosch.com>
Date: Mon, 27 Aug 2012 13:54:57 +0200
Subject: [PATCH] SPI IMX: Set inactive state of SPI clock (SCLK CTL)
 according to SPI clock polarity

Signed-off-by: Knut Wohlrab <knut.wohlrab@de.bosch.com>
---
 drivers/spi/spi-imx.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index e834ff8..d64655b 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -197,6 +197,7 @@  static unsigned int spi_imx_clkdiv_2(unsigned int fin,
 #define MX51_ECSPI_CONFIG_SCLKPOL(cs)	(1 << ((cs) +  4))
 #define MX51_ECSPI_CONFIG_SBBCTRL(cs)	(1 << ((cs) +  8))
 #define MX51_ECSPI_CONFIG_SSBPOL(cs)	(1 << ((cs) + 12))
+#define MX51_ECSPI_CONFIG_SCLKCTL(cs)	(1 << ((cs) + 20))
 
 #define MX51_ECSPI_INT		0x10
 #define MX51_ECSPI_INT_TEEN		(1 <<  0)
@@ -287,9 +288,10 @@  static int __maybe_unused mx51_ecspi_config(struct spi_imx_data *spi_imx,
 	if (config->mode & SPI_CPHA)
 		cfg |= MX51_ECSPI_CONFIG_SCLKPHA(config->cs);
 
-	if (config->mode & SPI_CPOL)
+	if (config->mode & SPI_CPOL) {
 		cfg |= MX51_ECSPI_CONFIG_SCLKPOL(config->cs);
-
+		cfg |= MX51_ECSPI_CONFIG_SCLKCTL(config->cs);
+	}
 	if (config->mode & SPI_CS_HIGH)
 		cfg |= MX51_ECSPI_CONFIG_SSBPOL(config->cs);
 
-- 
1.7.0.4