From patchwork Tue May 8 16:18:18 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: 8475 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 8389623E23 for ; Tue, 8 May 2012 16:19:06 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id 53A65A18863 for ; Tue, 8 May 2012 16:19:06 +0000 (UTC) Received: by mail-yx0-f180.google.com with SMTP id q6so659836yen.11 for ; Tue, 08 May 2012 09:19:06 -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=aOcmPqCPife/CCUxGvbWTZu+Zjn4KDyWMgCvHWS49q4=; b=lYXiDXyn0mgWDG/VdCNPjufv1ucVuQVFtijkAl5dgNHs4Y1Eqmipoc/xnBXiEzOU0t 8FHWqGEdXfZnkdf/cNOgBESdcbDpCs4F8OWvE0FzFNrXp60ktvoqDRrilab15ITf+53f UGbLQ/jhWc6oqA3orzgQ+rbKjJek8wbzOf20aZGqhwsz2KendtWLBxyeUobVY2Mj1VgM sheVKT2+UISqi3uWg1NU7rOkJvCGqvKqJ2Hrs0gZOkDCHwTWmBBPYyqt9L9nSpxSUCiC blui4o782P+Op3DGVjx6qRVQkzemRXrgaj5NwpHeNOb3KicxIOUwtvN6MmV+oe1NR62s d4nw== Received: by 10.42.142.71 with SMTP id r7mr10073463icu.7.1336493945947; Tue, 08 May 2012 09:19:05 -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 q19csp211215ibj; Tue, 8 May 2012 09:19:05 -0700 (PDT) Received: by 10.68.191.230 with SMTP id hb6mr8325575pbc.167.1336493945215; Tue, 08 May 2012 09:19:05 -0700 (PDT) Received: from mail-pz0-f50.google.com (mail-pz0-f50.google.com [209.85.210.50]) by mx.google.com with ESMTPS id wq6si1806598pbc.291.2012.05.08.09.19.04 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 08 May 2012 09:19:05 -0700 (PDT) Received-SPF: pass (google.com: domain of amitdanielk@gmail.com designates 209.85.210.50 as permitted sender) client-ip=209.85.210.50; Authentication-Results: mx.google.com; spf=pass (google.com: domain of amitdanielk@gmail.com designates 209.85.210.50 as permitted sender) smtp.mail=amitdanielk@gmail.com; dkim=pass header.i=@gmail.com Received: by mail-pz0-f50.google.com with SMTP id h15so3701109dan.37 for ; Tue, 08 May 2012 09:19:04 -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=aOcmPqCPife/CCUxGvbWTZu+Zjn4KDyWMgCvHWS49q4=; b=tkQEFQywvXOdbEt2SNSWSLFW0+G15C4YEJ3bwLTgpBvSNSyWcZwqo1qIsn8Aig/SJQ VvoYuCKdhjRs8R95xXR6dcLihmVsGhZgkSN+xv8a6w9F+hTcm/JfzdM9PhNswceARSIh cMwKBrA8yUuo3rRoYa8vP0PtkDTbCe2/vhDDLfa4vIXz5z5LaRWTus822T7qfs2Tfu2L Bgudc1x9kSmjq7gNnJK5Z3irjeAMFZogWQq+yNrCWe+otIcOQn0AvNeNlXbCH78r0kxe fL8AeHsY+K60fwJBLdPxqb9bgsLqqG9h/SKGcmZ+pN4o2gb/cwgSCKLuNuS3hfbIELXA GbFg== Received: by 10.68.221.98 with SMTP id qd2mr9806434pbc.3.1336493944192; Tue, 08 May 2012 09:19:04 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id oj3sm2833966pbb.20.2012.05.08.09.18.59 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 08 May 2012 09:19:03 -0700 (PDT) Sender: amit kachhap From: Amit Daniel Kachhap To: akpm@linux-foundation.org, linux-pm@lists.linux-foundation.org Cc: durgadoss.r@intel.com, linux-acpi@vger.kernel.org, lenb@kernel.org, rui.zhang@intel.com, amit.kachhap@linaro.org, linaro-dev@lists.linaro.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, patches@linaro.org Subject: [PATCH v3 6/6] ARM: exynos: Add thermal sensor driver platform data support Date: Tue, 8 May 2012 21:48:18 +0530 Message-Id: <1336493898-7039-7-git-send-email-amit.kachhap@linaro.org> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1336493898-7039-6-git-send-email-amit.kachhap@linaro.org> References: <1336493898-7039-1-git-send-email-amit.kachhap@linaro.org> <1336493898-7039-2-git-send-email-amit.kachhap@linaro.org> <1336493898-7039-3-git-send-email-amit.kachhap@linaro.org> <1336493898-7039-4-git-send-email-amit.kachhap@linaro.org> <1336493898-7039-5-git-send-email-amit.kachhap@linaro.org> <1336493898-7039-6-git-send-email-amit.kachhap@linaro.org> X-Gm-Message-State: ALoCoQn8g82twUf8KlitKjFI+mwEWWkod4qmXBEQFcg1BQz24r1in8ngmPOFEBu9nwVnlwKW8Bi9 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 | 107 +++++++++++++++++++++++++++++++++++++- 1 files changed, 106 insertions(+), 1 deletions(-) diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c index f818432..3471d9d 100644 --- a/drivers/thermal/exynos_thermal.c +++ b/drivers/thermal/exynos_thermal.c @@ -646,14 +646,117 @@ 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 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, + }, + .freq_tab[1] = { + .freq_clip_max = 200 * 1000, + }, + .freq_tab_count = 2, + .type = SOC_ARCH_EXYNOS4, +}; +#define EXYNOS4_TMU_DRV_DATA ((kernel_ulong_t)&exynos4_default_tmu_data) +#else +#define EXYNOS4_TMU_DRV_DATA ((kernel_ulong_t)NULL) +#endif + +#if defined(CONFIG_SOC_EXYNOS5250) +static struct exynos_tmu_platform_data 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, + }, + .freq_tab[1] = { + .freq_clip_max = 200 * 1000, + }, + .freq_tab_count = 2, + .type = SOC_ARCH_EXYNOS5, +}; +#define EXYNOS5_TMU_DRV_DATA ((kernel_ulong_t)&exynos5_default_tmu_data) +#else +#define EXYNOS5_TMU_DRV_DATA ((kernel_ulong_t)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 = EXYNOS4_TMU_DRV_DATA, + }, + { + .name = "exynos5-tmu", + .driver_data = 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; @@ -813,11 +916,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);