From: Boerge Struempfel <boerge.struempfel@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: boerge.struempfel@gmail.com, bstruempfel@ultratronik.de,
andy.shevchenko@gmail.com, festevam@gmail.com,
amit.kumar-mahapatra@amd.com, broonie@kernel.org,
Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
NXP Linux Team <linux-imx@nxp.com>,
linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v6 2/5] spi: spi-imx: add support for SPI_MOSI_IDLE_LOW mode bit
Date: Wed, 24 May 2023 11:19:45 +0200 [thread overview]
Message-ID: <20230524091948.41779-3-boerge.struempfel@gmail.com> (raw)
In-Reply-To: <20230524091948.41779-1-boerge.struempfel@gmail.com>
By default, the spi-imx controller pulls the mosi line high, whenever it
is idle. This behaviour can be inverted per CS by setting the
corresponding DATA_CTL bit in the config register of the controller.
Also, since the controller mode-bits have to be touched anyways, the
SPI_CPOL and SPI_CPHA are replaced by the combined SPI_MODE_X_MASK flag.
Signed-off-by: Boerge Struempfel <boerge.struempfel@gmail.com>
---
drivers/spi/spi-imx.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index 34e5f81ec431..1c4172fcba2d 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -281,6 +281,7 @@ static bool spi_imx_can_dma(struct spi_controller *controller, struct spi_device
#define MX51_ECSPI_CONFIG_SCLKPOL(cs) (1 << ((cs & 3) + 4))
#define MX51_ECSPI_CONFIG_SBBCTRL(cs) (1 << ((cs & 3) + 8))
#define MX51_ECSPI_CONFIG_SSBPOL(cs) (1 << ((cs & 3) + 12))
+#define MX51_ECSPI_CONFIG_DATACTL(cs) (1 << ((cs & 3) + 16))
#define MX51_ECSPI_CONFIG_SCLKCTL(cs) (1 << ((cs & 3) + 20))
#define MX51_ECSPI_INT 0x10
@@ -573,6 +574,11 @@ static int mx51_ecspi_prepare_message(struct spi_imx_data *spi_imx,
cfg &= ~MX51_ECSPI_CONFIG_SCLKCTL(spi_get_chipselect(spi, 0));
}
+ if (spi->mode & SPI_MOSI_IDLE_LOW)
+ cfg |= MX51_ECSPI_CONFIG_DATACTL(spi_get_chipselect(spi, 0));
+ else
+ cfg &= ~MX51_ECSPI_CONFIG_DATACTL(spi_get_chipselect(spi, 0));
+
if (spi->mode & SPI_CS_HIGH)
cfg |= MX51_ECSPI_CONFIG_SSBPOL(spi_get_chipselect(spi, 0));
else
@@ -1743,7 +1749,8 @@ static int spi_imx_probe(struct platform_device *pdev)
spi_imx->controller->prepare_message = spi_imx_prepare_message;
spi_imx->controller->unprepare_message = spi_imx_unprepare_message;
spi_imx->controller->slave_abort = spi_imx_slave_abort;
- spi_imx->controller->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_NO_CS;
+ spi_imx->controller->mode_bits = SPI_MODE_X_MASK | SPI_CS_HIGH | SPI_NO_CS |
+ SPI_MOSI_IDLE_LOW;
if (is_imx35_cspi(spi_imx) || is_imx51_ecspi(spi_imx) ||
is_imx53_ecspi(spi_imx))
--
2.40.1
next prev parent reply other threads:[~2023-05-24 9:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-24 9:19 [PATCH v6 0/5] spi: add SPI_MOSI_IDLE_LOW mode bit Boerge Struempfel
2023-05-24 9:19 ` [PATCH v6 1/5] " Boerge Struempfel
2023-05-24 9:19 ` Boerge Struempfel [this message]
2023-05-24 9:47 ` [PATCH v6 2/5] spi: spi-imx: add support for " Frieder Schrempf
2023-05-24 11:42 ` Börge Strümpfel
2023-05-30 12:46 ` Mark Brown
2023-05-30 13:27 ` Börge Strümpfel
2023-05-24 9:19 ` [PATCH v6 3/5] spi: spidev: add two new spi mode bits Boerge Struempfel
2023-05-24 9:19 ` [PATCH v6 4/5] spi: spidev_test: Sorted the options into logical groups Boerge Struempfel
2023-05-24 9:19 ` [PATCH v6 5/5] spi: spidev_test Add three missing spi mode bits Boerge Struempfel
2023-05-30 17:40 ` [PATCH v6 0/5] spi: add SPI_MOSI_IDLE_LOW mode bit 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=20230524091948.41779-3-boerge.struempfel@gmail.com \
--to=boerge.struempfel@gmail.com \
--cc=amit.kumar-mahapatra@amd.com \
--cc=andy.shevchenko@gmail.com \
--cc=broonie@kernel.org \
--cc=bstruempfel@ultratronik.de \
--cc=festevam@gmail.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.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;
as well as URLs for NNTP newsgroup(s).