diff mbox series

soc/tegra: fuse: Expose Tegra production status

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

Commit Message

Jon Hunter June 14, 2022, 10: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>
---
 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 b0a8405dbdb1..276b22144ff5 100644
--- a/drivers/soc/tegra/fuse/fuse-tegra.c
+++ b/drivers/soc/tegra/fuse/fuse-tegra.c
@@ -426,6 +426,20 @@  static ssize_t minor_show(struct device *dev, struct device_attribute *attr,
 
 static DEVICE_ATTR_RO(minor);
 
+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 *tegra_soc_attr[] = {
 	&dev_attr_major.attr,
 	&dev_attr_minor.attr,
@@ -456,6 +470,7 @@  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