From patchwork Sat May 12 09:40:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Daniel Kachhap X-Patchwork-Id: 8568 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 1EE9A23F04 for ; Sat, 12 May 2012 09:41:33 +0000 (UTC) Received: from mail-ob0-f180.google.com (mail-ob0-f180.google.com [209.85.214.180]) by fiordland.canonical.com (Postfix) with ESMTP id D869FA18B54 for ; Sat, 12 May 2012 09:41:32 +0000 (UTC) Received: by mail-ob0-f180.google.com with SMTP id un3so1806614obb.11 for ; Sat, 12 May 2012 02:41:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :dkim-signature:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=bsCmg9/LgWfQbqzrt122/kqjukCyy8fJFJ8vdxFB/uw=; b=idsu3Gz1KXDlM7q1gz6DQTkhrj1WqyANREe4MjE4nQcv5m6oVg/9MNezsLZUfhKde9 IR6iWxK7OGVIeWJNJ6GHLkVnAQ7B+77ix1rnhrRu66lnne45e2ardBye2koso8BiOUmP 720t8bvHQP5p8Iblq78AfTRd87Baf1TDR16ApNwJCNpRp/jfqJQfb6xxmAHFNxCcgPJf uHuQL6XzgERplc7pAzEwV+oejJTg59/M5RzgL3H6wibNSDmy1HHp8JP/dWX+QYYxQTK7 he3HhgVRsK1om6PBEduK3AoD++y6X+7aXo9qkn2u0djlNfx3DGcjp5VbcJrx7wzUiEI5 pdag== Received: by 10.50.220.136 with SMTP id pw8mr605575igc.1.1336815692549; Sat, 12 May 2012 02:41:32 -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.231.73.147 with SMTP id q19csp229843ibj; Sat, 12 May 2012 02:41:32 -0700 (PDT) Received: by 10.68.226.129 with SMTP id rs1mr3685792pbc.29.1336815691861; Sat, 12 May 2012 02:41:31 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id hz7si14214662pbc.96.2012.05.12.02.41.31 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 12 May 2012 02:41:31 -0700 (PDT) Received-SPF: pass (google.com: domain of amitdanielk@gmail.com designates 209.85.160.50 as permitted sender) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=pass (google.com: domain of amitdanielk@gmail.com designates 209.85.160.50 as permitted sender) smtp.mail=amitdanielk@gmail.com; dkim=pass header.i=@gmail.com Received: by mail-pb0-f50.google.com with SMTP id rr4so5283788pbb.37 for ; Sat, 12 May 2012 02:41:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=bsCmg9/LgWfQbqzrt122/kqjukCyy8fJFJ8vdxFB/uw=; b=tf78l5zPBizK0xqy8A+Dkk6I5rlxmV4q4Bfkh8dJfwPUzsmA8ULISjCT+pP4ATTOAt x8ARnog4uz+NJaFhOmxR0vHCXRA6131KS+y/hd2KxZ88W/tDCbocqD9LYsJmHYxSmLNN 17US4IokHQBuhzYwMM7HsYhDXAtX3mUWW417qlTtA4lP4MFWYRJzuwtPK2coCrGuBkB6 DzUdBZnHwfIIp/6xsfy8fY+G0+ili9kBI0IP9DbSecyUYf1FszxR5zSjhJKmlq1QSYdX ydRfXVCTsnkQ4VXe4RrBcg+1xg+P4T1ZL3dpeFy5W0lQpexSBzToi9fKXlVM6STUIYgO ExvA== Received: by 10.68.189.198 with SMTP id gk6mr3683045pbc.31.1336815691054; Sat, 12 May 2012 02:41:31 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id vc4sm9944379pbc.8.2012.05.12.02.41.26 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 12 May 2012 02:41:30 -0700 (PDT) Sender: amit kachhap From: Amit Daniel Kachhap To: linux-pm@lists.linux-foundation.org, akpm@linux-foundation.org Cc: linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, durgadoss.r@intel.com, lenb@kernel.org, rui.zhang@intel.com, linux-acpi@vger.kernel.org, linaro-dev@lists.linaro.org, lm-sensors@lm-sensors.org, amit.kachhap@linaro.org, khali@linux-fr.org, guenter.roeck@ericsson.com, patches@linaro.org Subject: [PATCH v4 5/5] ARM: exynos: Add thermal sensor driver platform data support Date: Sat, 12 May 2012 15:10:45 +0530 Message-Id: <1336815645-29625-6-git-send-email-amit.kachhap@linaro.org> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1336815645-29625-1-git-send-email-amit.kachhap@linaro.org> References: <1336815645-29625-1-git-send-email-amit.kachhap@linaro.org> X-Gm-Message-State: ALoCoQmsUmScVIFWkoCPkhV0Adm30eWCQlAb0TkEKvgLN8MjKF8HUG/rsAhXUG0fkyXignzV2Gsp This patch adds necessary default platform data support needed for TMU driver. This dt/non-dt values are tested for origen exynos4210 and smdk exynos5250 platforms. Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/exynos_thermal.c | 111 +++++++++++++++++++++++++++++++++++++- 1 files changed, 110 insertions(+), 1 deletions(-) diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c index 48106d8..e4e6759 100644 --- a/drivers/thermal/exynos_thermal.c +++ b/drivers/thermal/exynos_thermal.c @@ -662,14 +662,121 @@ static irqreturn_t exynos_tmu_irq(int irq, void *id) static struct thermal_sensor_conf exynos_sensor_conf = { .name = "exynos-therm", .read_temperature = (int (*)(void *))exynos_tmu_read, +}; + +#if defined(CONFIG_CPU_EXYNOS4210) +static struct exynos_tmu_platform_data const exynos4_default_tmu_data = { + .threshold = 80, + .trigger_levels[0] = 5, + .trigger_levels[1] = 20, + .trigger_levels[2] = 30, + .trigger_level0_en = 1, + .trigger_level1_en = 1, + .trigger_level2_en = 1, + .trigger_level3_en = 0, + .gain = 15, + .reference_voltage = 7, + .cal_type = TYPE_ONE_POINT_TRIMMING, + .freq_tab[0] = { + .freq_clip_max = 800 * 1000, + .temp_level = 85, + }, + .freq_tab[1] = { + .freq_clip_max = 200 * 1000, + .temp_level = 100, + }, + .freq_tab_count = 2, + .type = SOC_ARCH_EXYNOS4, +}; +#define EXYNOS4_TMU_DRV_DATA (&exynos4_default_tmu_data) +#else +#define EXYNOS4_TMU_DRV_DATA (NULL) +#endif + +#if defined(CONFIG_SOC_EXYNOS5250) +static struct exynos_tmu_platform_data const exynos5_default_tmu_data = { + .trigger_levels[0] = 85, + .trigger_levels[1] = 103, + .trigger_levels[2] = 110, + .trigger_level0_en = 1, + .trigger_level1_en = 1, + .trigger_level2_en = 1, + .trigger_level3_en = 0, + .gain = 8, + .reference_voltage = 16, + .noise_cancel_mode = 4, + .cal_type = TYPE_ONE_POINT_TRIMMING, + .efuse_value = 55, + .freq_tab[0] = { + .freq_clip_max = 800 * 1000, + .temp_level = 85, + }, + .freq_tab[1] = { + .freq_clip_max = 200 * 1000, + .temp_level = 103, + }, + .freq_tab_count = 2, + .type = SOC_ARCH_EXYNOS5, +}; +#define EXYNOS5_TMU_DRV_DATA (&exynos5_default_tmu_data) +#else +#define EXYNOS5_TMU_DRV_DATA (NULL) +#endif + +#ifdef CONFIG_OF +static const struct of_device_id exynos_tmu_match[] = { + { + .compatible = "samsung,exynos4-tmu", + .data = (void *)EXYNOS4_TMU_DRV_DATA, + }, + { + .compatible = "samsung,exynos5-tmu", + .data = (void *)EXYNOS5_TMU_DRV_DATA, + }, + {}, +}; +MODULE_DEVICE_TABLE(of, exynos_tmu_match); +#else +#define exynos_tmu_match NULL +#endif + +static struct platform_device_id exynos_tmu_driver_ids[] = { + { + .name = "exynos4-tmu", + .driver_data = (kernel_ulong_t)EXYNOS4_TMU_DRV_DATA, + }, + { + .name = "exynos5-tmu", + .driver_data = (kernel_ulong_t)EXYNOS5_TMU_DRV_DATA, + }, + { }, +}; +MODULE_DEVICE_TABLE(platform, exynos4_tmu_driver_ids); + +static inline struct exynos_tmu_platform_data *exynos_get_driver_data( + struct platform_device *pdev) +{ +#ifdef CONFIG_OF + if (pdev->dev.of_node) { + const struct of_device_id *match; + match = of_match_node(exynos_tmu_match, pdev->dev.of_node); + if (!match) + return NULL; + return (struct exynos_tmu_platform_data *) match->data; + } +#endif + return (struct exynos_tmu_platform_data *) + platform_get_device_id(pdev)->driver_data; } -; static int __devinit exynos_tmu_probe(struct platform_device *pdev) { struct exynos_tmu_data *data; struct exynos_tmu_platform_data *pdata = pdev->dev.platform_data; int ret, i; + if (!pdata) + pdata = exynos_get_driver_data(pdev); + if (!pdata) { dev_err(&pdev->dev, "No platform init data supplied.\n"); return -ENODEV; @@ -832,11 +939,13 @@ static struct platform_driver exynos_tmu_driver = { .driver = { .name = "exynos-tmu", .owner = THIS_MODULE, + .of_match_table = exynos_tmu_match, }, .probe = exynos_tmu_probe, .remove = __devexit_p(exynos_tmu_remove), .suspend = exynos_tmu_suspend, .resume = exynos_tmu_resume, + .id_table = exynos_tmu_driver_ids, }; module_platform_driver(exynos_tmu_driver);