diff --git a/include/soc/tegra/fuse-helper.h b/include/soc/tegra/fuse-helper.h index fde88999..02fd432a 100644 --- a/include/soc/tegra/fuse-helper.h +++ b/include/soc/tegra/fuse-helper.h @@ -3,9 +3,11 @@ * Copyright (c) 2022-2023, NVIDIA CORPORATION. All rights reserved. */ +#include #include -#define FUSE_SKU_INFO 0x10 +#define FUSE_SKU_INFO 0x10 +#define FUSE_BEGIN 0x100 static inline u32 tegra_get_sku_id(void) { @@ -32,4 +34,32 @@ static inline bool tegra_platform_is_sim(void) return false; } +/* + * tegra_fuse_control_read() - allows reading fuse offsets < 0x100. + * @offset: Offset to be read. + * @value: Pointer to an unsigned integer where the value is stored. + * + * Function tegra_fuse_control_read() allows reading fuse_offsets < 0x100 + * by using the already upstreamed tegra_fuse_readl() function. + * + * Return: Returns a negative integer in case of error, 0 in case + * of success. + */ +static inline int tegra_fuse_control_read(unsigned long offset, u32 *value) +{ + /* + * Allow reading offsets between 0x0 - 0xff. + * For offsets > 0xff, use tegra_fuse_readl instead. + */ + if (WARN_ON(offset > 0xff)) + return -EINVAL; + + /* + * This will overflow the offset value, which is safe as + * tegra_fuse_readl() would again add 0x100 to it. + */ + offset -= FUSE_BEGIN; + + return tegra_fuse_readl(offset, value); +} #endif /* CONFIG_TEGRA_FUSE_UPSTREAM */