summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBitan Biswas <bbiswas@nvidia.com>2011-07-21 17:32:53 +0530
committerVarun Colbert <vcolbert@nvidia.com>2011-07-27 16:02:52 -0700
commit8155a9c8bfcc387fe139072b7cbb83c3f367c2ae (patch)
tree6021cb78cc1aad9277f8adc2d9b6b4d9f559bcef
parent585e08935c728c331c5b891d9eff43931da284ea (diff)
arm: tegra: fuse: tsensor specific fuse public API added
Defined public fuse API to extract tegra3 tsensor configuration parameters. bug 851791 Change-Id: Ia14e2d515ee1d695556492464e8ceaf4b0d13477 Reviewed-on: http://git-master/r/42367 Reviewed-by: Bitan Biswas <bbiswas@nvidia.com> Tested-by: Bitan Biswas <bbiswas@nvidia.com> Reviewed-by: Varun Wadekar <vwadekar@nvidia.com> Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com> Reviewed-by: Scott Williams <scwilliams@nvidia.com>
-rw-r--r--arch/arm/mach-tegra/fuse.c67
-rw-r--r--arch/arm/mach-tegra/include/mach/tegra_fuse.h27
-rw-r--r--arch/arm/mach-tegra/tegra3_tsensor.c11
3 files changed, 102 insertions, 3 deletions
diff --git a/arch/arm/mach-tegra/fuse.c b/arch/arm/mach-tegra/fuse.c
index 52c01b140b05..87f35303b21c 100644
--- a/arch/arm/mach-tegra/fuse.c
+++ b/arch/arm/mach-tegra/fuse.c
@@ -26,6 +26,7 @@
#include <linux/moduleparam.h>
#include <mach/iomap.h>
+#include <mach/tegra_fuse.h>
#include "fuse.h"
#include "apbio.h"
@@ -51,6 +52,14 @@
#define FUSE_GPU_INFO 0x390
#define FUSE_GPU_INFO_MASK (1<<2)
#define FUSE_SPARE_BIT 0x244
+/* fuse registers used in public fuse data read API */
+#define FUSE_TEST_PROGRAM_REVISION_0 0x128
+/* fuse spare bits are used to get Tj-ADT values */
+#define FUSE_SPARE_BIT_0_0 0x244
+#define NUM_TSENSOR_SPARE_BITS 28
+/* tsensor calibration register */
+#define FUSE_TSENSOR_CALIB_0 0x198
+
#endif
struct tegra_id {
@@ -106,6 +115,64 @@ void tegra_init_fuse(void)
tegra_cpu_process_id(), tegra_core_process_id());
}
+#ifdef CONFIG_ARCH_TEGRA_2x_SOC
+int tegra_fuse_get_revision(u32 *rev)
+{
+ return -ENOENT;
+}
+EXPORT_SYMBOL(tegra_fuse_get_revision);
+
+int tegra_fuse_get_tsensor_calibration_data(u32 *calib)
+{
+ return -ENOENT;
+}
+EXPORT_SYMBOL(tegra_fuse_get_tsensor_calibration_data);
+
+int tegra_fuse_get_tsensor_spare_bits(u32 *spare_bits)
+{
+ return -ENOENT;
+}
+EXPORT_SYMBOL(tegra_fuse_get_tsensor_spare_bits);
+
+#else
+
+int tegra_fuse_get_revision(u32 *rev)
+{
+ /* fuse revision */
+ *rev = tegra_fuse_readl(FUSE_TEST_PROGRAM_REVISION_0);
+ return 0;
+}
+EXPORT_SYMBOL(tegra_fuse_get_revision);
+
+int tegra_fuse_get_tsensor_calibration_data(u32 *calib)
+{
+ /* tsensor calibration fuse */
+ *calib = tegra_fuse_readl(FUSE_TSENSOR_CALIB_0);
+ return 0;
+}
+EXPORT_SYMBOL(tegra_fuse_get_tsensor_calibration_data);
+
+int tegra_fuse_get_tsensor_spare_bits(u32 *spare_bits)
+{
+ u32 value;
+ int i;
+
+ BUG_ON(NUM_TSENSOR_SPARE_BITS > (sizeof(u32) * 8));
+ if (!spare_bits)
+ return -ENOMEM;
+ *spare_bits = 0;
+ /* spare bits 0-27 */
+ for (i = 0; i < NUM_TSENSOR_SPARE_BITS; i++) {
+ value = tegra_fuse_readl(FUSE_SPARE_BIT_0_0 +
+ (i << 2));
+ if (value)
+ *spare_bits |= BIT(i);
+ }
+ return 0;
+}
+EXPORT_SYMBOL(tegra_fuse_get_tsensor_spare_bits);
+#endif
+
unsigned long long tegra_chip_uid(void)
{
#if defined(CONFIG_ARCH_TEGRA_2x_SOC)
diff --git a/arch/arm/mach-tegra/include/mach/tegra_fuse.h b/arch/arm/mach-tegra/include/mach/tegra_fuse.h
new file mode 100644
index 000000000000..d264745c70c0
--- /dev/null
+++ b/arch/arm/mach-tegra/include/mach/tegra_fuse.h
@@ -0,0 +1,27 @@
+/*
+ * arch/arm/mach-tegra/include/mach/tegra_fuse.h
+ *
+ * Tegra Public Fuse header file
+ *
+ * Copyright (c) 2011, NVIDIA Corporation.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef _MACH_TEGRA_PUBLIC_FUSE_H_
+#define _MACH_TEGRA_PUBLIC_FUSE_H_
+
+int tegra_fuse_get_revision(u32 *rev);
+int tegra_fuse_get_tsensor_calibration_data(u32 *calib);
+int tegra_fuse_get_tsensor_spare_bits(u32 *spare_bits);
+
+#endif /* _MACH_TEGRA_PUBLIC_FUSE_H_*/
+
diff --git a/arch/arm/mach-tegra/tegra3_tsensor.c b/arch/arm/mach-tegra/tegra3_tsensor.c
index caadf4097647..199536a35adb 100644
--- a/arch/arm/mach-tegra/tegra3_tsensor.c
+++ b/arch/arm/mach-tegra/tegra3_tsensor.c
@@ -20,8 +20,8 @@
#ifdef CONFIG_SENSORS_TEGRA_TSENSOR
#include <mach/tsensor.h>
+#include <mach/tegra_fuse.h>
#include <devices.h>
-#include "fuse.h"
static struct tegra_tsensor_platform_data tsensor_data = {
.hysteresis = 5,
@@ -31,15 +31,17 @@ static struct tegra_tsensor_platform_data tsensor_data = {
};
/* fuse revision constants used for tsensor */
-#define FUSE_TEST_PROGRAM_REVISION_0 0x128
#define TSENSOR_FUSE_REVISION_DECIMAL 8
#define TSENSOR_FUSE_REVISION_INTEGER 0
void __init tegra_tsensor_init(void)
{
unsigned int reg, fuse_rev_integer, fuse_rev_decimal;
+ int err;
/* tsensor driver is instantiated based on fuse revision */
- reg = tegra_fuse_readl(FUSE_TEST_PROGRAM_REVISION_0);
+ err = tegra_fuse_get_revision(&reg);
+ if (err)
+ goto errLabel;
fuse_rev_decimal = (reg & 0xf);
fuse_rev_integer = ((reg >> 4) & 0x7);
pr_info("\nTegra3 fuse revision %d.%d ", fuse_rev_integer,
@@ -50,7 +52,10 @@ void __init tegra_tsensor_init(void)
tegra_tsensor_device.dev.platform_data = &tsensor_data;
platform_device_register(&tegra_tsensor_device);
}
+errLabel:
+ return;
}
+
#else
void __init tegra_tsensor_init(void) { }
#endif