diff options
author | Bitan Biswas <bbiswas@nvidia.com> | 2011-07-21 17:32:53 +0530 |
---|---|---|
committer | Dan Willemsen <dwillemsen@nvidia.com> | 2011-11-30 21:47:55 -0800 |
commit | b51228481e6105e24c42ff30470ad31efa4e0279 (patch) | |
tree | 6df130e29ac95d0e88f31c0cba2eb3108ad64029 | |
parent | 858bfc00630c812916b4d905b07a445d487d0f15 (diff) |
arm: tegra: fuse: tsensor specific fuse public API added
Defined public fuse API to extract tegra3 tsensor configuration
parameters.
bug 851791
Original-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>
Rebase-Id: R1090e6ad78bcef23670ff647de86e695780f5b76
-rw-r--r-- | arch/arm/mach-tegra/fuse.c | 67 | ||||
-rw-r--r-- | arch/arm/mach-tegra/include/mach/tegra_fuse.h | 27 | ||||
-rw-r--r-- | arch/arm/mach-tegra/tegra3_tsensor.c | 11 |
3 files changed, 103 insertions, 2 deletions
diff --git a/arch/arm/mach-tegra/fuse.c b/arch/arm/mach-tegra/fuse.c index f3ee7e343a3b..17d12caca0df 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 cbf5c5ab2522..019513218939 100644 --- a/arch/arm/mach-tegra/tegra3_tsensor.c +++ b/arch/arm/mach-tegra/tegra3_tsensor.c @@ -20,6 +20,8 @@ #ifdef CONFIG_SENSORS_TEGRA_TSENSOR #include <mach/tsensor.h> +#include <mach/tegra_fuse.h> + #include "devices.h" #include "fuse.h" @@ -31,15 +33,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(®); + if (err) + goto errLabel; fuse_rev_decimal = (reg & 0xf); fuse_rev_integer = ((reg >> 4) & 0x7); pr_info("\nTegra3 fuse revision %d.%d \n", fuse_rev_integer, @@ -50,7 +54,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 |