diff mbox series

[V2] soc/tegra: fuse: Expose Tegra production status

Message ID 20220627114119.110825-1-jonathanh@nvidia.com
State Accepted
Headers show
Series [V2] soc/tegra: fuse: Expose Tegra production status | expand

Commit Message

Jon Hunter June 27, 2022, 11:41 a.m. UTC
From: Bitan Biswas <bbiswas@nvidia.com>

For Tegra194 and Tegra234 devices there is a production fuse register
that indicates if the device is a production device. Expose the
production status of the chip via the sysfs for Tegra194 and Tegra234
devices. Note that '0' implies not production or unknown and '1'
indicates the device is a production device.

Signed-off-by: Bitan Biswas <bbiswas@nvidia.com>
[ Re-worked for upstream submission by Jon Hunter <jonathanh@nvidia.com> ]
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
Changes since V1:
- Fixed unused-variable warning observed with ARM multi_v7_defconfig

 drivers/soc/tegra/fuse/fuse-tegra.c | 15 +++++++++++++++
 include/soc/tegra/fuse.h            |  1 +
 2 files changed, 16 insertions(+)
diff mbox series

Patch

diff --git a/drivers/soc/tegra/fuse/fuse-tegra.c b/drivers/soc/tegra/fuse/fuse-tegra.c
index 6542267a224d..8ee6092753b1 100644
--- a/drivers/soc/tegra/fuse/fuse-tegra.c
+++ b/drivers/soc/tegra/fuse/fuse-tegra.c
@@ -452,10 +452,25 @@  static ssize_t platform_show(struct device *dev, struct device_attribute *attr,
 
 static DEVICE_ATTR_RO(platform);
 
+static ssize_t production_show(struct device *dev,
+			       struct device_attribute *attr, char *buf)
+{
+	u32 reg = 0;
+
+	if (tegra_is_silicon())
+		if (tegra_fuse_readl(TEGRA_FUSE_PRODUCTION_MODE, &reg))
+			dev_err(dev, "failed to read production fuse!\n");
+
+	return sprintf(buf, "%d\n", reg);
+}
+
+static DEVICE_ATTR_RO(production);
+
 static struct attribute *tegra194_soc_attr[] = {
 	&dev_attr_major.attr,
 	&dev_attr_minor.attr,
 	&dev_attr_platform.attr,
+	&dev_attr_production.attr,
 	NULL,
 };
 
diff --git a/include/soc/tegra/fuse.h b/include/soc/tegra/fuse.h
index 67d2bc856fbc..d035e04cb869 100644
--- a/include/soc/tegra/fuse.h
+++ b/include/soc/tegra/fuse.h
@@ -18,6 +18,7 @@ 
 #define TEGRA194	0x19
 #define TEGRA234	0x23
 
+#define TEGRA_FUSE_PRODUCTION_MODE 0x0
 #define TEGRA_FUSE_SKU_CALIB_0	0xf0
 #define TEGRA30_FUSE_SATA_CALIB	0x124
 #define TEGRA_FUSE_USB_CALIB_EXT_0 0x250