diff mbox

[RFC,2/4] ARM: Exynos4: Add thermal sensor driver platform device support

Message ID 1319629012-21205-2-git-send-email-amit.kachhap@linaro.org
State New
Headers show

Commit Message

Amit Daniel Kachhap Oct. 26, 2011, 11:36 a.m. UTC
This patch adds necessary source definations needed for TMU driver and
the platform device support.

Signed-off-by: SangWook Ju <sw.ju@samsung.com>
Signed-off-by: Amit Daniel Kachhap <amit.kachhap@linaro.org>
---
 arch/arm/mach-exynos4/Makefile                |    3 +-
 arch/arm/mach-exynos4/dev-tmu.c               |   71 +++++++++++++++++++++++++
 arch/arm/mach-exynos4/include/mach/irqs.h     |    3 +
 arch/arm/mach-exynos4/include/mach/map.h      |    1 +
 arch/arm/mach-exynos4/include/mach/regs-tmu.h |   58 ++++++++++++++++++++
 arch/arm/plat-samsung/include/plat/devs.h     |    2 +
 6 files changed, 137 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-exynos4/dev-tmu.c
 create mode 100644 arch/arm/mach-exynos4/include/mach/regs-tmu.h
diff mbox

Patch

diff --git a/arch/arm/mach-exynos4/Makefile b/arch/arm/mach-exynos4/Makefile
index cbc9767..0a97fad 100644
--- a/arch/arm/mach-exynos4/Makefile
+++ b/arch/arm/mach-exynos4/Makefile
@@ -38,7 +38,8 @@  obj-y					+= dev-audio.o
 obj-$(CONFIG_EXYNOS4_DEV_AHCI)		+= dev-ahci.o
 obj-$(CONFIG_EXYNOS4_DEV_PD)		+= dev-pd.o
 obj-$(CONFIG_EXYNOS4_DEV_SYSMMU)	+= dev-sysmmu.o
-obj-$(CONFIG_EXYNOS4_DEV_DWMCI)	+= dev-dwmci.o
+obj-$(CONFIG_EXYNOS4_DEV_DWMCI)		+= dev-dwmci.o
+obj-$(CONFIG_EXYNOS4_THERMAL)		+= dev-tmu.o
 
 obj-$(CONFIG_EXYNOS4_SETUP_FIMC)	+= setup-fimc.o
 obj-$(CONFIG_EXYNOS4_SETUP_FIMD0)	+= setup-fimd0.o
diff --git a/arch/arm/mach-exynos4/dev-tmu.c b/arch/arm/mach-exynos4/dev-tmu.c
new file mode 100644
index 0000000..3aa7729
--- /dev/null
+++ b/arch/arm/mach-exynos4/dev-tmu.c
@@ -0,0 +1,71 @@ 
+/* linux/arch/arm/plat-exynos4/dev-tmu.c
+ *
+ * Copyright 2011 by SAMSUNG
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/kernel.h>
+#include <linux/string.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <asm/irq.h>
+
+#include <mach/irqs.h>
+#include <mach/map.h>
+#include <plat/devs.h>
+#include <mach/exynos4-tmu.h>
+
+static struct resource exynos4_tmu_resource[] = {
+	[0] = {
+		.start	= EXYNOS4_PA_TMU,
+		.end	= EXYNOS4_PA_TMU + 0xFFFF - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {
+		.start	= IRQ_TMU_TRIG0,
+		.end	= IRQ_TMU_TRIG0,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+struct platform_device exynos4_device_tmu = {
+	.name		= "exynos4-tmu",
+	.id		= -1,
+	.num_resources	= ARRAY_SIZE(exynos4_tmu_resource),
+	.resource	= exynos4_tmu_resource,
+};
+EXPORT_SYMBOL(exynos4_device_tmu);
+
+static struct tmu_data default_tmu_data __initdata = {
+	.te1 = 0,	/* cooling stop temp */
+	.te2 = 0,	/* cooling stop temp */
+	.cooling = 84,  /*Cooling temp*/
+	.mode =	0,	/* 0: 1-point compensation, 1: 2-point compensation */
+};
+
+int exynos4_tmu_get_irqno(int num)
+{
+	return platform_get_irq(&exynos4_device_tmu, num);
+}
+
+struct tmu_platform_device *exynos4_tmu_get_platdata(void)
+{
+	return platform_get_drvdata(&exynos4_device_tmu);
+}
+
+void __init exynos4_tmu_set_platdata(struct tmu_data *pd)
+{
+	struct tmu_platform_device *npd;
+	npd = kmalloc(sizeof(struct tmu_platform_device), GFP_KERNEL);
+	if (!npd)
+		printk(KERN_ERR "%s: no memory for platform data\n", __func__);
+	if (!pd)
+		memcpy(&npd->data, &default_tmu_data, sizeof(struct tmu_data));
+	else
+		memcpy(&npd->data, pd, sizeof(struct tmu_data));
+
+	platform_set_drvdata(&exynos4_device_tmu, npd);
+}
diff --git a/arch/arm/mach-exynos4/include/mach/irqs.h b/arch/arm/mach-exynos4/include/mach/irqs.h
index f8952f8..c51dc97 100644
--- a/arch/arm/mach-exynos4/include/mach/irqs.h
+++ b/arch/arm/mach-exynos4/include/mach/irqs.h
@@ -119,6 +119,9 @@ 
 #define COMBINER_GROUP(x)	((x) * MAX_IRQ_IN_COMBINER + IRQ_SPI(128))
 #define COMBINER_IRQ(x, y)	(COMBINER_GROUP(x) + y)
 
+#define IRQ_TMU_TRIG0		COMBINER_IRQ(2, 4)
+#define IRQ_TMU_TRIG1		COMBINER_IRQ(3, 4)
+
 #define IRQ_SYSMMU_MDMA0_0	COMBINER_IRQ(4, 0)
 #define IRQ_SYSMMU_SSS_0	COMBINER_IRQ(4, 1)
 #define IRQ_SYSMMU_FIMC0_0	COMBINER_IRQ(4, 2)
diff --git a/arch/arm/mach-exynos4/include/mach/map.h b/arch/arm/mach-exynos4/include/mach/map.h
index d32296d..75ac921 100644
--- a/arch/arm/mach-exynos4/include/mach/map.h
+++ b/arch/arm/mach-exynos4/include/mach/map.h
@@ -66,6 +66,7 @@ 
 #define EXYNOS4_PA_COREPERI		0x10500000
 #define EXYNOS4_PA_TWD			0x10500600
 #define EXYNOS4_PA_L2CC			0x10502000
+#define EXYNOS4_PA_TMU                 0x100C0000
 
 #define EXYNOS4_PA_MDMA			0x10810000
 #define EXYNOS4_PA_PDMA0		0x12680000
diff --git a/arch/arm/mach-exynos4/include/mach/regs-tmu.h b/arch/arm/mach-exynos4/include/mach/regs-tmu.h
new file mode 100644
index 0000000..64ddc06
--- /dev/null
+++ b/arch/arm/mach-exynos4/include/mach/regs-tmu.h
@@ -0,0 +1,58 @@ 
+/* linux/arch/arm/mach-exynos4/include/mach/regs-tmu.h
+
+* Copyright (c) 2011 Samsung Electronics Co., Ltd.
+*      http://www.samsung.com/
+*
+* EXYNOS4 - Clock register definitions
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License version 2 as
+* published by the Free Software Foundation.
+*/
+
+#ifndef __ASM_ARCH_REGS_THERMAL_H
+#define __ASM_ARCH_REGS_THERMAL_H __FILE__
+
+/*Register definations*/
+#define TRIMINFO			 (0x0)
+#define TRIMINFO_CONFIG			(0x10)
+#define TRIMINFO_CONTROL		(0x14)
+#define TMU_CON0			(0x20)
+#define TMU_CON1			(0x24)
+#define TMU_STATUS			(0x28)
+#define SAMPLING_INTERNAL		(0x2C)
+#define CNT_VALUE0			(0x30)
+#define CNT_VALUE1			(0x34)
+#define CURRENT_TEMP			(0x40)
+#define THRESHOLD_TEMP			(0x44)
+#define TRG_LEV0			(0x50)
+#define TRG_LEV1			(0x54)
+#define TRG_LEV2			(0x58)
+#define TRG_LEV3			(0x5C)
+#define PAST_TMEP0			(0x60)
+#define PAST_TMEP1			(0x64)
+#define PAST_TMEP2			(0x68)
+#define PAST_TMEP3			(0x6C)
+#define INTEN				(0x70)
+#define INTSTAT				(0x74)
+#define INTCLEAR			(0x78)
+
+/*Register control bits*/
+#define INTEN0			(1)
+#define INTEN1			(1<<4)
+#define INTEN2			(1<<8)
+#define INTEN3			(1<<12)
+
+#define TRIM_TEMP_MASK		(0xFF)
+
+#define INTCLEAR0		(1)
+#define INTCLEAR1		(1<<4)
+#define INTCLEAR2		(1<<8)
+#define	INTCLEAR3		(1<<12)
+
+#define INTSTAT0		(1)
+#define INTSTAT1		(1<<4)
+#define INTSTAT2		(1<<8)
+#define	INTSTAT3		(1<<12)
+
+#endif
diff --git a/arch/arm/plat-samsung/include/plat/devs.h b/arch/arm/plat-samsung/include/plat/devs.h
index 24ebb1e..e7f46c6 100644
--- a/arch/arm/plat-samsung/include/plat/devs.h
+++ b/arch/arm/plat-samsung/include/plat/devs.h
@@ -149,6 +149,8 @@  extern struct platform_device s5p_device_ehci;
 
 extern struct platform_device exynos4_device_sysmmu;
 
+extern struct platform_device exynos4_device_tmu;
+
 /* s3c2440 specific devices */
 
 #ifdef CONFIG_CPU_S3C2440