From patchwork Thu Jul 12 13:41:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kachhap X-Patchwork-Id: 1189071 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 8BF2540B30 for ; Thu, 12 Jul 2012 13:42:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161016Ab2GLNmR (ORCPT ); Thu, 12 Jul 2012 09:42:17 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:39554 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161092Ab2GLNmN (ORCPT ); Thu, 12 Jul 2012 09:42:13 -0400 Received: by mail-pb0-f46.google.com with SMTP id rp8so3754294pbb.19 for ; Thu, 12 Jul 2012 06:42:11 -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=Ro+JYJAS67HoMtmha5iW8y9GG0ssSwNsYDpdczWOh+g=; b=c3AOcPX7i/PCoPy5r6JGTRCwIweqMe9o4a/gN3p3cBm2sGMLLsMu4Ll+l5Bak3Eyme F4kxZxOe3/lN8tSIr3pL8Wx0VEXa57Dw2r6q8GWQXE788WqQR0Y4L9lFGZXAT9l1m5V1 WbBj8+GK0CGTI0or5o8P7F6SmCu4ARJgT8+HP9jG96P0luB74xdCKWV8inV94tcCtDHr ocHTK4vU0z3FlSfnbyRbu3qTu/Sd2csf+wLQxkGxI4iWJLHi383FVTTMvn9nKbPRtEUf v1iA7ibnj7CtG0IZmJpjNzrwSOFkVBC4bCMw2/G0f6FZ1D7Ym+z812tcMxX+l1AIsbuW mQkA== Received: by 10.68.222.163 with SMTP id qn3mr5589638pbc.135.1342100531858; Thu, 12 Jul 2012 06:42:11 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id ms9sm1105479pbb.43.2012.07.12.06.42.07 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 12 Jul 2012 06:42:11 -0700 (PDT) From: Amit Daniel Kachhap To: linux-pm@lists.linux-foundation.org, lenb@kernel.org Cc: linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, lm-sensors@lm-sensors.org, amit.kachhap@linaro.org, akpm@linux-foundation.org, Donggeun Kim , SangWook Ju , Durgadoss , Jean Delvare Subject: [RESEND PATCH v4 5/5] ARM: exynos: add thermal sensor driver platform data support Date: Thu, 12 Jul 2012 19:11:08 +0530 Message-Id: <1342100468-19426-6-git-send-email-amit.kachhap@linaro.org> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1342100468-19426-1-git-send-email-amit.kachhap@linaro.org> References: <1342100468-19426-1-git-send-email-amit.kachhap@linaro.org> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Add 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 Cc: Donggeun Kim Acked-by: Guenter Roeck Cc: SangWook Ju Cc: Durgadoss Cc: Len Brown Cc: Jean Delvare Signed-off-by: Andrew Morton --- 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 52255fb..b561295 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);