Skip to content

Commit 7ba2f0b

Browse files
committed
spi: spi-axi-spi-engine: Add support for MOSI idle configuration
Implement MOSI idle low and MOSI idle high to better support peripherals that request specific MOSI behavior. Acked-by: Nuno Sa <nuno.sa@analog.com> Reviewed-by: David Lechner <dlechner@baylibre.com> Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
1 parent 5774056 commit 7ba2f0b

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

drivers/spi/spi-axi-spi-engine-ex.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#define SPI_ENGINE_CONFIG_CPHA BIT(0)
5151
#define SPI_ENGINE_CONFIG_CPOL BIT(1)
5252
#define SPI_ENGINE_CONFIG_3WIRE BIT(2)
53+
#define SPI_ENGINE_CONFIG_SDO_IDLE_HIGH BIT(3)
5354

5455
#define SPI_ENGINE_INST_TRANSFER 0x0
5556
#define SPI_ENGINE_INST_ASSERT 0x1
@@ -146,6 +147,10 @@ static unsigned int spi_engine_get_config(struct spi_device *spi)
146147
config |= SPI_ENGINE_CONFIG_CPHA;
147148
if (spi->mode & SPI_3WIRE)
148149
config |= SPI_ENGINE_CONFIG_3WIRE;
150+
if (spi->mode & SPI_MOSI_IDLE_HIGH)
151+
config |= SPI_ENGINE_CONFIG_SDO_IDLE_HIGH;
152+
if (spi->mode & SPI_MOSI_IDLE_LOW)
153+
config &= ~SPI_ENGINE_CONFIG_SDO_IDLE_HIGH;
149154

150155
return config;
151156
}
@@ -785,9 +790,13 @@ static int spi_engine_probe(struct platform_device *pdev)
785790
host->num_chipselect = 8;
786791

787792
/* Some features depend of the IP core version. */
788-
if (ADI_AXI_PCORE_VER_MINOR(version) >= 2) {
789-
host->mode_bits |= SPI_CS_HIGH;
790-
host->setup = spi_engine_setup;
793+
if (ADI_AXI_PCORE_VER_MAJOR(version) >= 1) {
794+
if (ADI_AXI_PCORE_VER_MINOR(version) >= 2) {
795+
host->mode_bits |= SPI_CS_HIGH;
796+
host->setup = spi_engine_setup;
797+
}
798+
if (ADI_AXI_PCORE_VER_MINOR(version) >= 3)
799+
host->mode_bits |= SPI_MOSI_IDLE_LOW | SPI_MOSI_IDLE_HIGH;
791800
}
792801

793802
if (host->max_speed_hz == 0)

0 commit comments

Comments
 (0)