From 6f721a94414d79f740c970f02e1f55688f67b67b Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Tue, 21 Dec 2021 10:29:52 +0000 Subject: [PATCH] platform: tegra: cvnas: Add support for upstream Linux kernels When building the CVNAS driver as an external module against upstream Linux kernels, there are some downstream fuse APIs that are not found. To fix building CVNAS for upstream kernels ... 1. Use the device-tree machine compatibility string instead of the downstream fuse function tegra_get_chip_id(). 2. For the functions tegra_platform_is_silicon() and tegra_platform_is_sim() add implementations in a fuse-helper.h that always assume that platform is silicon and not a simulator. Note this assumption is only applied to upstream kernels and downstream kernel still use the downstream implementation. Long term we need to revisit this. 3. Copy the downstream implementation for function tegra_get_sku_id() to the fuse-helper.h so that this is available for upstream kernels. The functions implemented in fuse-helper.h are only used if the compiler flag CONFIG_TEGRA_FUSE_UPSTREAM is defined. Bug 3459526 Change-Id: I5bbd08ac2560c236f932606ce5ad0e73dc71205a Signed-off-by: Jon Hunter Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2650491 Reviewed-by: Sachin Nikam Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2894844 Reviewed-by: Laxman Dewangan GVS: Gerrit_Virtual_Submit Tested-by: Laxman Dewangan --- include/soc/tegra/fuse-helper.h | 35 +++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 include/soc/tegra/fuse-helper.h diff --git a/include/soc/tegra/fuse-helper.h b/include/soc/tegra/fuse-helper.h new file mode 100644 index 00000000..fafbb83c --- /dev/null +++ b/include/soc/tegra/fuse-helper.h @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2022-2023, NVIDIA CORPORATION. All rights reserved. + */ + +#include + +#ifdef CONFIG_TEGRA_FUSE_UPSTREAM + +#define FUSE_SKU_INFO 0x10 + +/* + * 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; +} + +static inline bool tegra_platform_is_sim(void) +{ + return false; +} + +static inline u32 tegra_get_sku_id(void) +{ + if (!tegra_sku_info.sku_id) + tegra_fuse_readl(FUSE_SKU_INFO, &tegra_sku_info.sku_id); + + return tegra_sku_info.sku_id; +} + +#endif /* CONFIG_TEGRA_FUSE_UPSTREAM */