The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH 0/2] spi: axi-spi-engine: improve version checks
@ 2025-08-15 17:40 David Lechner
  2025-08-15 17:40 ` [PATCH 1/2] include: adi-axi-common: add version check function David Lechner
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: David Lechner @ 2025-08-15 17:40 UTC (permalink / raw)
  To: Michael Hennerich, Nuno Sá, Mark Brown
  Cc: linux-kernel, linux-spi, David Lechner

We have a pending major version bump for the axi-spi-engine so to
prepare for that, improve the existing version checks for feature
enablement.

Unless Nuno knows something I don't, it should be fine for the header
file patch to go through the SPI tree.

Signed-off-by: David Lechner <dlechner@baylibre.com>
---
David Lechner (2):
      include: adi-axi-common: add version check function
      spi: axi-spi-engine: use adi_axi_pcore_ver_gteq()

 drivers/spi/spi-axi-spi-engine.c | 17 +++++++----------
 include/linux/adi-axi-common.h   | 21 +++++++++++++++++++++
 2 files changed, 28 insertions(+), 10 deletions(-)
---
base-commit: bbe4656eae2729b8ca87116defa19c568898d08f
change-id: 20250815-spi-axi-spi-enigne-improve-version-checks-cdceedf356d6

Best regards,
-- 
David Lechner <dlechner@baylibre.com>


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

* [PATCH 1/2] include: adi-axi-common: add version check function
  2025-08-15 17:40 [PATCH 0/2] spi: axi-spi-engine: improve version checks David Lechner
@ 2025-08-15 17:40 ` David Lechner
  2025-08-15 17:40 ` [PATCH 2/2] spi: axi-spi-engine: use adi_axi_pcore_ver_gteq() David Lechner
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: David Lechner @ 2025-08-15 17:40 UTC (permalink / raw)
  To: Michael Hennerich, Nuno Sá, Mark Brown
  Cc: linux-kernel, linux-spi, David Lechner

Add a version check function for checking ADI AXI IP core versions.

These cores use a semantic versioning scheme, so it is useful to have
a version check function that can check the minor version to enable
features in driver while maintaining backward compatibility.

Signed-off-by: David Lechner <dlechner@baylibre.com>
---
 include/linux/adi-axi-common.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/include/linux/adi-axi-common.h b/include/linux/adi-axi-common.h
index f64f4ad4bedae312ec450bd5fed09ceaedd5397e..37962ba530dfc1275c17771cade2e75fd7e81cd3 100644
--- a/include/linux/adi-axi-common.h
+++ b/include/linux/adi-axi-common.h
@@ -8,6 +8,8 @@
  * https://wiki.analog.com/resources/fpga/docs/hdl/regmap
  */
 
+#include <linux/types.h>
+
 #ifndef ADI_AXI_COMMON_H_
 #define ADI_AXI_COMMON_H_
 
@@ -21,6 +23,25 @@
 #define ADI_AXI_PCORE_VER_MINOR(version)	(((version) >> 8) & 0xff)
 #define ADI_AXI_PCORE_VER_PATCH(version)	((version) & 0xff)
 
+/**
+ * adi_axi_pcore_ver_gteq() - check if a version is satisfied
+ * @version: the full version read from the hardware
+ * @major: the major version to compare against
+ * @minor: the minor version to compare against
+ *
+ * ADI AXI IP Cores use semantic versioning, so this can be used to check for
+ * feature availability.
+ *
+ * Return: true if the version is greater than or equal to the specified
+ *         major and minor version, false otherwise.
+ */
+static inline bool adi_axi_pcore_ver_gteq(u32 version, u32 major, u32 minor)
+{
+	return ADI_AXI_PCORE_VER_MAJOR(version) > (major) ||
+	       (ADI_AXI_PCORE_VER_MAJOR(version) == (major) &&
+		ADI_AXI_PCORE_VER_MINOR(version) >= (minor));
+}
+
 #define ADI_AXI_INFO_FPGA_TECH(info)            (((info) >> 24) & 0xff)
 #define ADI_AXI_INFO_FPGA_FAMILY(info)          (((info) >> 16) & 0xff)
 #define ADI_AXI_INFO_FPGA_SPEED_GRADE(info)     (((info) >> 8) & 0xff)

-- 
2.43.0


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

* [PATCH 2/2] spi: axi-spi-engine: use adi_axi_pcore_ver_gteq()
  2025-08-15 17:40 [PATCH 0/2] spi: axi-spi-engine: improve version checks David Lechner
  2025-08-15 17:40 ` [PATCH 1/2] include: adi-axi-common: add version check function David Lechner
@ 2025-08-15 17:40 ` David Lechner
  2025-09-11 16:23 ` [PATCH 0/2] spi: axi-spi-engine: improve version checks Nuno Sá
  2025-09-12  3:30 ` Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: David Lechner @ 2025-08-15 17:40 UTC (permalink / raw)
  To: Michael Hennerich, Nuno Sá, Mark Brown
  Cc: linux-kernel, linux-spi, David Lechner

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>
---
 drivers/spi/spi-axi-spi-engine.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-engine.c
index 512d53a8ef4d1460a411685920f4f95802816483..e06f412190fd243161a0b3df992f26157531f6a1 100644
--- a/drivers/spi/spi-axi-spi-engine.c
+++ b/drivers/spi/spi-axi-spi-engine.c
@@ -1050,7 +1050,7 @@ static int spi_engine_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	if (ADI_AXI_PCORE_VER_MINOR(version) >= 1) {
+	if (adi_axi_pcore_ver_gteq(version, 1, 1)) {
 		unsigned int sizes = readl(spi_engine->base +
 				SPI_ENGINE_REG_OFFLOAD_MEM_ADDR_WIDTH);
 
@@ -1064,7 +1064,7 @@ static int spi_engine_probe(struct platform_device *pdev)
 	}
 
 	/* IP v1.5 dropped the requirement for SYNC in offload messages. */
-	spi_engine->offload_requires_sync = ADI_AXI_PCORE_VER_MINOR(version) < 5;
+	spi_engine->offload_requires_sync = !adi_axi_pcore_ver_gteq(version, 1, 5);
 
 	writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_RESET);
 	writel_relaxed(0xff, spi_engine->base + SPI_ENGINE_REG_INT_PENDING);
@@ -1091,15 +1091,12 @@ static int spi_engine_probe(struct platform_device *pdev)
 	host->put_offload = spi_engine_put_offload;
 	host->num_chipselect = 8;
 
-	/* Some features depend of the IP core version. */
-	if (ADI_AXI_PCORE_VER_MAJOR(version) >= 1) {
-		if (ADI_AXI_PCORE_VER_MINOR(version) >= 2) {
-			host->mode_bits |= SPI_CS_HIGH;
-			host->setup = spi_engine_setup;
-		}
-		if (ADI_AXI_PCORE_VER_MINOR(version) >= 3)
-			host->mode_bits |= SPI_MOSI_IDLE_LOW | SPI_MOSI_IDLE_HIGH;
+	if (adi_axi_pcore_ver_gteq(version, 1, 2)) {
+		host->mode_bits |= SPI_CS_HIGH;
+		host->setup = spi_engine_setup;
 	}
+	if (adi_axi_pcore_ver_gteq(version, 1, 3))
+		host->mode_bits |= SPI_MOSI_IDLE_LOW | SPI_MOSI_IDLE_HIGH;
 
 	if (host->max_speed_hz == 0)
 		return dev_err_probe(&pdev->dev, -EINVAL, "spi_clk rate is 0");

-- 
2.43.0


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

* Re: [PATCH 0/2] spi: axi-spi-engine: improve version checks
  2025-08-15 17:40 [PATCH 0/2] spi: axi-spi-engine: improve version checks David Lechner
  2025-08-15 17:40 ` [PATCH 1/2] include: adi-axi-common: add version check function David Lechner
  2025-08-15 17:40 ` [PATCH 2/2] spi: axi-spi-engine: use adi_axi_pcore_ver_gteq() David Lechner
@ 2025-09-11 16:23 ` Nuno Sá
  2025-09-12  3:30 ` Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: Nuno Sá @ 2025-09-11 16:23 UTC (permalink / raw)
  To: David Lechner, Michael Hennerich, Nuno Sá, Mark Brown
  Cc: linux-kernel, linux-spi

On Fri, 2025-08-15 at 12:40 -0500, David Lechner wrote:
> We have a pending major version bump for the axi-spi-engine so to
> prepare for that, improve the existing version checks for feature
> enablement.
> 
> Unless Nuno knows something I don't, it should be fine for the header
> file patch to go through the SPI tree.
> 
> Signed-off-by: David Lechner <dlechner@baylibre.com>
> ---
> David Lechner (2):
>       include: adi-axi-common: add version check function
>       spi: axi-spi-engine: use adi_axi_pcore_ver_gteq()
> 
>  drivers/spi/spi-axi-spi-engine.c | 17 +++++++----------
>  include/linux/adi-axi-common.h   | 21 +++++++++++++++++++++
>  2 files changed, 28 insertions(+), 10 deletions(-)
> ---
> base-commit: bbe4656eae2729b8ca87116defa19c568898d08f
> change-id: 20250815-spi-axi-spi-enigne-improve-version-checks-cdceedf356d6
> 
> Best regards,

LGTM,

Reviewed-by: Nuno Sá <nuno.sa@analog.com>

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

* Re: [PATCH 0/2] spi: axi-spi-engine: improve version checks
  2025-08-15 17:40 [PATCH 0/2] spi: axi-spi-engine: improve version checks David Lechner
                   ` (2 preceding siblings ...)
  2025-09-11 16:23 ` [PATCH 0/2] spi: axi-spi-engine: improve version checks Nuno Sá
@ 2025-09-12  3:30 ` Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2025-09-12  3:30 UTC (permalink / raw)
  To: Michael Hennerich, Nuno Sá, David Lechner; +Cc: linux-kernel, linux-spi

On Fri, 15 Aug 2025 12:40:01 -0500, David Lechner wrote:
> We have a pending major version bump for the axi-spi-engine so to
> prepare for that, improve the existing version checks for feature
> enablement.
> 
> Unless Nuno knows something I don't, it should be fine for the header
> file patch to go through the SPI tree.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/2] include: adi-axi-common: add version check function
      commit: 67a529b7d3c50a56c162476509361f4fe11350dd
[2/2] spi: axi-spi-engine: use adi_axi_pcore_ver_gteq()
      commit: 30db1b21fa37a2f37c7f4d71864405a05e889833

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


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

end of thread, other threads:[~2025-09-12  3:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-15 17:40 [PATCH 0/2] spi: axi-spi-engine: improve version checks David Lechner
2025-08-15 17:40 ` [PATCH 1/2] include: adi-axi-common: add version check function David Lechner
2025-08-15 17:40 ` [PATCH 2/2] spi: axi-spi-engine: use adi_axi_pcore_ver_gteq() David Lechner
2025-09-11 16:23 ` [PATCH 0/2] spi: axi-spi-engine: improve version checks Nuno Sá
2025-09-12  3:30 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox