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 <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2650491
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2894844
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
Tested-by: Laxman Dewangan <ldewangan@nvidia.com>
This commit is contained in:
Jon Hunter
2021-12-21 10:29:52 +00:00
committed by mobile promotions
parent deec76e8ee
commit 6f721a9441

View File

@@ -0,0 +1,35 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2022-2023, NVIDIA CORPORATION. All rights reserved.
*/
#include <soc/tegra/fuse.h>
#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 */