From c95fa541d23bf3f2a8c59dd0b86167cfb2bb8a05 Mon Sep 17 00:00:00 2001 From: Kartik Date: Fri, 11 Nov 2022 18:04:57 +0000 Subject: [PATCH] soc/tegra: fuse-helper: Add platform helper functions Various downstream drivers needs platform information i.e. if it is running on silicon or simulation. This patch adds following functions: * tegra_platform_is_silicon() * tegra_platform_is_sim() * tegra_platform_is_fpga() * tegra_platform_is_vdk() Bug 3777983 Change-Id: Ice319748c5bbdbf3f4e16c3464f60e4a8e316b46 Signed-off-by: Kartik Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2807762 Reviewed-by: Laxman Dewangan Reviewed-by: Jonathan Hunter Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2894847 GVS: Gerrit_Virtual_Submit Tested-by: Laxman Dewangan --- include/soc/tegra/fuse-helper.h | 42 ++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/include/soc/tegra/fuse-helper.h b/include/soc/tegra/fuse-helper.h index 02fd432a..fb8ccba2 100644 --- a/include/soc/tegra/fuse-helper.h +++ b/include/soc/tegra/fuse-helper.h @@ -4,6 +4,7 @@ */ #include +#include #include #define FUSE_SKU_INFO 0x10 @@ -19,18 +20,47 @@ static inline u32 tegra_get_sku_id(void) #ifdef CONFIG_TEGRA_FUSE_UPSTREAM -/* - * For upstream the following functions to determine if the - * platform is silicon and simulator are not supported and - * so for now, always assume that we are silicon. - */ static inline bool tegra_platform_is_silicon(void) { - return true; + const struct soc_device_attribute tegra_soc_attrs[] = { + { .revision = "Silicon*" }, + {/* sentinel */} + }; + + if (soc_device_match(tegra_soc_attrs)) + return true; + + return false; } static inline bool tegra_platform_is_sim(void) { + return !tegra_platform_is_silicon(); +} + +static inline bool tegra_platform_is_fpga(void) +{ + const struct soc_device_attribute tegra_soc_attrs[] = { + { .revision = "*FPGA" }, + {/* sentinel */} + }; + + if (soc_device_match(tegra_soc_attrs)) + return true; + + return false; +} + +static inline bool tegra_platform_is_vdk(void) +{ + const struct soc_device_attribute tegra_soc_attrs[] = { + { .revision = "VDK" }, + {/* sentinel */} + }; + + if (soc_device_match(tegra_soc_attrs)) + return true; + return false; }