arm: tegra: tsensor: driver instantiation
Bitan Biswas [Fri, 10 Jun 2011 07:39:00 +0000 (12:39 +0530)]
Tegra internal tsensor driver supported for fuse revision 0.8
and above.

Bug 661228

Original-Change-Id: I820f6b5f20c20bb2d1ba04266148f5969ab84444
Reviewed-on: http://git-master/r/36054
Reviewed-by: Varun Colbert <vcolbert@nvidia.com>
Tested-by: Varun Colbert <vcolbert@nvidia.com>

Rebase-Id: R4725524b5e3f83b4cd3dd7d0020ef2d6e09a87d0

arch/arm/mach-tegra/Makefile
arch/arm/mach-tegra/board-cardhu.c
arch/arm/mach-tegra/board-enterprise.c
arch/arm/mach-tegra/board.h
arch/arm/mach-tegra/tegra3_tsensor.c [new file with mode: 0644]

index a539587..0459873 100644 (file)
@@ -81,6 +81,7 @@ ifeq ($(CONFIG_TEGRA_MC_PROFILE),y)
 obj-$(CONFIG_ARCH_TEGRA_2x_SOC)         += tegra2_mc.o
 obj-$(CONFIG_ARCH_TEGRA_3x_SOC)         += tegra3_mc_stats.o
 endif
+obj-$(CONFIG_ARCH_TEGRA_3x_SOC)         += tegra3_tsensor.o
 
 obj-${CONFIG_TEGRA_SPI_SLAVE}           += spi_tegra_slave.o
 
index b240d7d..051a0c8 100644 (file)
@@ -640,6 +640,7 @@ static void __init tegra_cardhu_init(void)
        cardhu_edp_init();
 #endif
        cardhu_uart_init();
+       tegra_tsensor_init();
        platform_add_devices(cardhu_devices, ARRAY_SIZE(cardhu_devices));
        cardhu_sdhci_init();
        cardhu_regulator_init();
index 6a6ab5d..981bbdb 100644 (file)
@@ -409,6 +409,7 @@ static void __init tegra_enterprise_init(void)
        enterprise_pinmux_init();
        enterprise_i2c_init();
        enterprise_uart_init();
+       tegra_tsensor_init();
        platform_add_devices(enterprise_devices, ARRAY_SIZE(enterprise_devices));
        enterprise_regulator_init();
        enterprise_sdhci_init();
index f9107b6..2665a6f 100644 (file)
@@ -43,6 +43,7 @@ void __init tegra_reserve(unsigned long carveout_size, unsigned long fb_size,
 int __init tegra_pcie_init(bool init_port0, bool init_port1);
 void tegra_init_cache(void);
 void __init tegra_protected_aperture_init(unsigned long aperture);
+void __init tegra_tsensor_init(void);
 void tegra_move_framebuffer(unsigned long to, unsigned long from,
        unsigned long size);
 bool is_tegra_debug_uartport_hs(void);
diff --git a/arch/arm/mach-tegra/tegra3_tsensor.c b/arch/arm/mach-tegra/tegra3_tsensor.c
new file mode 100644 (file)
index 0000000..cbf5c5a
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * arch/arm/mach-tegra/tegra3_tsensor.c
+ *
+ * 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.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include "board.h"
+
+#ifdef CONFIG_SENSORS_TEGRA_TSENSOR
+#include <mach/tsensor.h>
+#include "devices.h"
+#include "fuse.h"
+
+static struct tegra_tsensor_platform_data tsensor_data = {
+       .hysteresis = 5,
+       .sw_intr_temperature = 75,
+       .hw_clk_div_temperature = 80,
+       .hw_reset_temperature = 90,
+};
+
+/* 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;
+       /* tsensor driver is instantiated based on fuse revision */
+       reg = tegra_fuse_readl(FUSE_TEST_PROGRAM_REVISION_0);
+       fuse_rev_decimal = (reg & 0xf);
+       fuse_rev_integer = ((reg >> 4) & 0x7);
+       pr_info("\nTegra3 fuse revision %d.%d \n", fuse_rev_integer,
+               fuse_rev_decimal);
+       if ((fuse_rev_decimal >= TSENSOR_FUSE_REVISION_DECIMAL) &&
+               (fuse_rev_integer >= TSENSOR_FUSE_REVISION_INTEGER)) {
+               /* set platform data for device before register */
+               tegra_tsensor_device.dev.platform_data = &tsensor_data;
+               platform_device_register(&tegra_tsensor_device);
+       }
+}
+#else
+void __init tegra_tsensor_init(void) { }
+#endif
+