Unverified Commit 67a529b7 authored by David Lechner's avatar David Lechner Committed by Mark Brown
Browse files

include: adi-axi-common: add version check function



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: default avatarDavid Lechner <dlechner@baylibre.com>
Reviewed-by: default avatarNuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250815-spi-axi-spi-enigne-improve-version-checks-v1-1-13bde357d5b6@baylibre.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 2c625f0f
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -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)