Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

David Lechner and committed by
Mark Brown
67a529b7 2c625f0f

+21
+21
include/linux/adi-axi-common.h
··· 8 8 * https://wiki.analog.com/resources/fpga/docs/hdl/regmap 9 9 */ 10 10 11 + #include <linux/types.h> 12 + 11 13 #ifndef ADI_AXI_COMMON_H_ 12 14 #define ADI_AXI_COMMON_H_ 13 15 ··· 22 20 #define ADI_AXI_PCORE_VER_MAJOR(version) (((version) >> 16) & 0xff) 23 21 #define ADI_AXI_PCORE_VER_MINOR(version) (((version) >> 8) & 0xff) 24 22 #define ADI_AXI_PCORE_VER_PATCH(version) ((version) & 0xff) 23 + 24 + /** 25 + * adi_axi_pcore_ver_gteq() - check if a version is satisfied 26 + * @version: the full version read from the hardware 27 + * @major: the major version to compare against 28 + * @minor: the minor version to compare against 29 + * 30 + * ADI AXI IP Cores use semantic versioning, so this can be used to check for 31 + * feature availability. 32 + * 33 + * Return: true if the version is greater than or equal to the specified 34 + * major and minor version, false otherwise. 35 + */ 36 + static inline bool adi_axi_pcore_ver_gteq(u32 version, u32 major, u32 minor) 37 + { 38 + return ADI_AXI_PCORE_VER_MAJOR(version) > (major) || 39 + (ADI_AXI_PCORE_VER_MAJOR(version) == (major) && 40 + ADI_AXI_PCORE_VER_MINOR(version) >= (minor)); 41 + } 25 42 26 43 #define ADI_AXI_INFO_FPGA_TECH(info) (((info) >> 24) & 0xff) 27 44 #define ADI_AXI_INFO_FPGA_FAMILY(info) (((info) >> 16) & 0xff)