Skip to content

Commit 67a529b

Browse files
dlechbroonie
authored andcommitted
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: 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-1-13bde357d5b6@baylibre.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 2c625f0 commit 67a529b

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

include/linux/adi-axi-common.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
* https://wiki.analog.com/resources/fpga/docs/hdl/regmap
99
*/
1010

11+
#include <linux/types.h>
12+
1113
#ifndef ADI_AXI_COMMON_H_
1214
#define ADI_AXI_COMMON_H_
1315

@@ -21,6 +23,25 @@
2123
#define ADI_AXI_PCORE_VER_MINOR(version) (((version) >> 8) & 0xff)
2224
#define ADI_AXI_PCORE_VER_PATCH(version) ((version) & 0xff)
2325

26+
/**
27+
* adi_axi_pcore_ver_gteq() - check if a version is satisfied
28+
* @version: the full version read from the hardware
29+
* @major: the major version to compare against
30+
* @minor: the minor version to compare against
31+
*
32+
* ADI AXI IP Cores use semantic versioning, so this can be used to check for
33+
* feature availability.
34+
*
35+
* Return: true if the version is greater than or equal to the specified
36+
* major and minor version, false otherwise.
37+
*/
38+
static inline bool adi_axi_pcore_ver_gteq(u32 version, u32 major, u32 minor)
39+
{
40+
return ADI_AXI_PCORE_VER_MAJOR(version) > (major) ||
41+
(ADI_AXI_PCORE_VER_MAJOR(version) == (major) &&
42+
ADI_AXI_PCORE_VER_MINOR(version) >= (minor));
43+
}
44+
2445
#define ADI_AXI_INFO_FPGA_TECH(info) (((info) >> 24) & 0xff)
2546
#define ADI_AXI_INFO_FPGA_FAMILY(info) (((info) >> 16) & 0xff)
2647
#define ADI_AXI_INFO_FPGA_SPEED_GRADE(info) (((info) >> 8) & 0xff)

0 commit comments

Comments
 (0)