From patchwork Wed Oct 26 11:36:50 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Daniel Kachhap X-Patchwork-Id: 4830 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 2A14523E0B for ; Wed, 26 Oct 2011 11:37:12 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id 1C997A182D5 for ; Wed, 26 Oct 2011 11:37:12 +0000 (UTC) Received: by mail-fx0-f52.google.com with SMTP id n26so2021542faa.11 for ; Wed, 26 Oct 2011 04:37:12 -0700 (PDT) Received: by 10.223.58.146 with SMTP id g18mr32055474fah.13.1319629031978; Wed, 26 Oct 2011 04:37:11 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.1.71 with SMTP id 7cs9550lak; Wed, 26 Oct 2011 04:37:11 -0700 (PDT) Received: by 10.68.66.36 with SMTP id c4mr5077784pbt.39.1319629030556; Wed, 26 Oct 2011 04:37:10 -0700 (PDT) Received: from mail-pz0-f42.google.com (mail-pz0-f42.google.com [209.85.210.42]) by mx.google.com with ESMTPS id i5si2156458pbd.160.2011.10.26.04.37.09 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 26 Oct 2011 04:37:10 -0700 (PDT) Received-SPF: pass (google.com: domain of amitdanielk@gmail.com designates 209.85.210.42 as permitted sender) client-ip=209.85.210.42; Authentication-Results: mx.google.com; spf=pass (google.com: domain of amitdanielk@gmail.com designates 209.85.210.42 as permitted sender) smtp.mail=amitdanielk@gmail.com; dkim=pass (test mode) header.i=@gmail.com Received: by pzk36 with SMTP id 36so4187821pzk.1 for ; Wed, 26 Oct 2011 04:37:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=aWwZqFlZDiqz7+AevzAIQLYRvgFDBnK4M+XL1c237Hg=; b=CYPUzWXhdJpfk9W8BZX3bgNNxDBACDinzRgx0NzWRJfxrflLUHjkHiX3y74tsDIN+q Kk+UJdwRS/rZYKxUTfRNmiiOQp+PBUQRKjlUD4MIOpaO3af/WE7IFt9QgkNSsFFhbmjp bAPTIs2lZXtw6/5xIEcpbE9QC+KHdhSAabOpQ= Received: by 10.68.57.102 with SMTP id h6mr64964301pbq.7.1319629027688; Wed, 26 Oct 2011 04:37:07 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id 3sm5064379pbx.14.2011.10.26.04.37.05 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 26 Oct 2011 04:37:07 -0700 (PDT) Sender: amit kachhap From: Amit Daniel Kachhap To: linaro-dev@lists.linaro.org Cc: amit.kachhap@linaro.org, patches@linaro.org Subject: [RFC PATCH 2/4] ARM: Exynos4: Add thermal sensor driver platform device support Date: Wed, 26 Oct 2011 17:06:50 +0530 Message-Id: <1319629012-21205-2-git-send-email-amit.kachhap@linaro.org> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1319628954-21177-1-git-send-email-amit.kachhap@linaro.org> References: <1319628954-21177-1-git-send-email-amit.kachhap@linaro.org> This patch adds necessary source definations needed for TMU driver and the platform device support. Signed-off-by: SangWook Ju Signed-off-by: Amit Daniel Kachhap --- 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 --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 +#include +#include +#include +#include + +#include +#include +#include +#include + +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