From patchwork Tue May 7 13:01:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kachhap X-Patchwork-Id: 2533401 Return-Path: X-Original-To: patchwork-linux-samsung-soc@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 A18563FCA5 for ; Tue, 7 May 2013 13:04:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932621Ab3EGNCz (ORCPT ); Tue, 7 May 2013 09:02:55 -0400 Received: from mail-pa0-f49.google.com ([209.85.220.49]:49020 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932605Ab3EGNCv (ORCPT ); Tue, 7 May 2013 09:02:51 -0400 Received: by mail-pa0-f49.google.com with SMTP id bi5so476492pad.22 for ; Tue, 07 May 2013 06:02:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=Z3QCO/no/pSFqQVpsBRe6NJmMLjlhQ/5S7CEcyks7mM=; b=vHBplCASSSpEwQjf6JVuExW6SbGr4HriPlSx3XLsRNOxBZ/LnrRGSEwh4T+7g65sgB NK53XWylXB9pGJVorshRDZ2WWOsXwMg/Z/1eMVYrL72b0qNeaJhqTvjHwjyefERY+XnU YL9AzXK2ApbSqh8mwkr3H0crDgia2r8DWEUFKSyyhPVacPrX2glz+i3h3Aei8rV6PlQd IFLyhom41dewS7s9inB+mictocbJk3TKuB9ptYad0teDdIKmvo0j91joBDcsuB+FzeKS qgV4VbkqVsyKCcdi1rf85q2taZ8NuRnPI5cxwsuO++KvwzzHGSIC5BUnofZ9r55mvWLI Mhyg== X-Received: by 10.66.149.170 with SMTP id ub10mr2794318pab.58.1367931770433; Tue, 07 May 2013 06:02:50 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPSA id l4sm28220809pbo.6.2013.05.07.06.02.46 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 07 May 2013 06:02:49 -0700 (PDT) From: Amit Daniel Kachhap To: linux-pm@vger.kernel.org Cc: Zhang Rui , linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, amit.kachhap@gmail.com, Kukjin Kim , Eduardo Valentin Subject: [PATCH V3 16/21] thermal: exynos: Add features to check instead of using SOC type Date: Tue, 7 May 2013 18:31:06 +0530 Message-Id: <1367931671-3906-17-git-send-email-amit.daniel@samsung.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1367931671-3906-1-git-send-email-amit.daniel@samsung.com> References: <1367931671-3906-1-git-send-email-amit.daniel@samsung.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org This patch adds several features supported by TMU as bitfields. This features varies across different SOC type and comparing the features present in the TMU is more logical than comparing the soc itself. Acked-by: Kukjin Kim Signed-off-by: Amit Daniel Kachhap --- drivers/thermal/samsung/exynos_tmu.c | 6 +++--- drivers/thermal/samsung/exynos_tmu.h | 22 ++++++++++++++++++++++ drivers/thermal/samsung/exynos_tmu_data.c | 2 ++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 94d6e8e..c1a8c5f 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -152,7 +152,7 @@ static int exynos_tmu_initialize(struct platform_device *pdev) goto out; } - if (data->soc == SOC_ARCH_EXYNOS) + if (TMU_SUPPORTS(pdata, TRIM_RELOAD)) __raw_writel(1, data->base + reg->triminfo_ctrl); /* Save trimming info in order to perform calibration */ @@ -261,7 +261,7 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on) pdata->trigger_enable[2] << reg->inten_rise2_shift | pdata->trigger_enable[1] << reg->inten_rise1_shift | pdata->trigger_enable[0] << reg->inten_rise0_shift; - if (pdata->threshold_falling) + if (TMU_SUPPORTS(pdata, FALLING_TRIP)) interrupt_en |= interrupt_en << reg->inten_fall0_shift; } else { @@ -303,7 +303,7 @@ static int exynos_tmu_set_emulation(void *drv_data, unsigned long temp) unsigned int val; int ret = -EINVAL; - if (data->soc == SOC_ARCH_EXYNOS4210) + if (!TMU_SUPPORTS(pdata, EMULATION)) goto out; if (temp && temp < MCELSIUS) diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h index 1e5e492..de1c342 100644 --- a/drivers/thermal/samsung/exynos_tmu.h +++ b/drivers/thermal/samsung/exynos_tmu.h @@ -46,6 +46,25 @@ enum soc_type { }; /** + * EXYNOS TMU supported features. + * TMU_SUPPORT_EMULATION - This features is used to set user defined + * temperature to the TMU controller. + * TMU_SUPPORT_MULTI_INST - This features denotes that the soc + * has many instances of TMU. + * TMU_SUPPORT_TRIM_RELOAD - This features shows that trimming can + * be reloaded. + * TMU_SUPPORT_FALLING_TRIP - This features shows that interrupt can + * be registered for falling trips also. + * TMU_SUPPORT - macro to compare the above features with the supplied. + */ +#define TMU_SUPPORT_EMULATION BIT(0) +#define TMU_SUPPORT_MULTI_INST BIT(1) +#define TMU_SUPPORT_TRIM_RELOAD BIT(2) +#define TMU_SUPPORT_FALLING_TRIP BIT(3) + +#define TMU_SUPPORTS(a, b) (a->features & TMU_SUPPORT_ ## b) + +/** * struct exynos_tmu_register - register descriptors to access registers and * bitfields. The register validity, offsets and bitfield values may vary * slightly across different exynos SOC's. @@ -166,6 +185,8 @@ struct exynos_tmu_registers { * @freq_clip_table: Table representing frequency reduction percentage. * @freq_tab_count: Count of the above table as frequency reduction may * applicable to only some of the trigger levels. + * @features: a bitfield value indicating the features supported in SOC like + * emulation, multi instance etc * * This structure is required for configuration of exynos_tmu driver. */ @@ -192,5 +213,6 @@ struct exynos_tmu_platform_data { struct freq_clip_table freq_tab[4]; unsigned int freq_tab_count; struct exynos_tmu_registers *registers; + unsigned int features; }; #endif /* _LINUX_EXYNOS_THERMAL_H */ diff --git a/drivers/thermal/samsung/exynos_tmu_data.c b/drivers/thermal/samsung/exynos_tmu_data.c index 7322597..8a587d4 100644 --- a/drivers/thermal/samsung/exynos_tmu_data.c +++ b/drivers/thermal/samsung/exynos_tmu_data.c @@ -154,5 +154,7 @@ struct exynos_tmu_platform_data const exynos5250_default_tmu_data = { .freq_tab_count = 2, .type = SOC_ARCH_EXYNOS, .registers = &exynos5250_tmu_registers, + .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_TRIM_RELOAD | + TMU_SUPPORT_FALLING_TRIP), }; #endif