Skip to content

Commit 30db1b2

Browse files
dlechbroonie
authored andcommitted
spi: axi-spi-engine: use adi_axi_pcore_ver_gteq()
Make use of the adi_axi_pcore_ver_gteq() helper to make version checks more readable and robust against a major version bump. Signed-off-by: David Lechner <dlechner@baylibre.com> Reviewed-by: Nuno Sá <nuno.sa@analog.com> Link: https://patch.msgid.link/20250815-spi-axi-spi-enigne-improve-version-checks-v1-2-13bde357d5b6@baylibre.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 67a529b commit 30db1b2

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ static int spi_engine_probe(struct platform_device *pdev)
10501050
return -ENODEV;
10511051
}
10521052

1053-
if (ADI_AXI_PCORE_VER_MINOR(version) >= 1) {
1053+
if (adi_axi_pcore_ver_gteq(version, 1, 1)) {
10541054
unsigned int sizes = readl(spi_engine->base +
10551055
SPI_ENGINE_REG_OFFLOAD_MEM_ADDR_WIDTH);
10561056

@@ -1064,7 +1064,7 @@ static int spi_engine_probe(struct platform_device *pdev)
10641064
}
10651065

10661066
/* IP v1.5 dropped the requirement for SYNC in offload messages. */
1067-
spi_engine->offload_requires_sync = ADI_AXI_PCORE_VER_MINOR(version) < 5;
1067+
spi_engine->offload_requires_sync = !adi_axi_pcore_ver_gteq(version, 1, 5);
10681068

10691069
writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_RESET);
10701070
writel_relaxed(0xff, spi_engine->base + SPI_ENGINE_REG_INT_PENDING);
@@ -1091,15 +1091,12 @@ static int spi_engine_probe(struct platform_device *pdev)
10911091
host->put_offload = spi_engine_put_offload;
10921092
host->num_chipselect = 8;
10931093

1094-
/* Some features depend of the IP core version. */
1095-
if (ADI_AXI_PCORE_VER_MAJOR(version) >= 1) {
1096-
if (ADI_AXI_PCORE_VER_MINOR(version) >= 2) {
1097-
host->mode_bits |= SPI_CS_HIGH;
1098-
host->setup = spi_engine_setup;
1099-
}
1100-
if (ADI_AXI_PCORE_VER_MINOR(version) >= 3)
1101-
host->mode_bits |= SPI_MOSI_IDLE_LOW | SPI_MOSI_IDLE_HIGH;
1094+
if (adi_axi_pcore_ver_gteq(version, 1, 2)) {
1095+
host->mode_bits |= SPI_CS_HIGH;
1096+
host->setup = spi_engine_setup;
11021097
}
1098+
if (adi_axi_pcore_ver_gteq(version, 1, 3))
1099+
host->mode_bits |= SPI_MOSI_IDLE_LOW | SPI_MOSI_IDLE_HIGH;
11031100

11041101
if (host->max_speed_hz == 0)
11051102
return dev_err_probe(&pdev->dev, -EINVAL, "spi_clk rate is 0");

0 commit comments

Comments
 (0)