From patchwork Thu Nov 13 15:01:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartlomiej Zolnierkiewicz X-Patchwork-Id: 5297861 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 852959F2F1 for ; Thu, 13 Nov 2014 15:05:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A547C2020E for ; Thu, 13 Nov 2014 15:05:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C9895201F4 for ; Thu, 13 Nov 2014 15:05:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754016AbaKMPEy (ORCPT ); Thu, 13 Nov 2014 10:04:54 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:50413 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752931AbaKMPEw (ORCPT ); Thu, 13 Nov 2014 10:04:52 -0500 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NEZ00G9UGK25840@mailout1.samsung.com>; Fri, 14 Nov 2014 00:04:50 +0900 (KST) X-AuditID: cbfee61b-f79d76d0000024d6-b4-5464c8921f52 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 67.80.09430.298C4645; Fri, 14 Nov 2014 00:04:50 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NEZ00J8WGELNZ00@mmp2.samsung.com>; Fri, 14 Nov 2014 00:04:50 +0900 (KST) From: Bartlomiej Zolnierkiewicz To: Eduardo Valentin Cc: Zhang Rui , Amit Daniel Kachhap , Lukasz Majewski , Kyungmin Park , linux-samsung-soc@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, b.zolnierkie@samsung.com Subject: [PATCH v2 17/33] thermal: exynos: add get_th_reg() helper Date: Thu, 13 Nov 2014 16:01:12 +0100 Message-id: <1415890888-8881-18-git-send-email-b.zolnierkie@samsung.com> X-Mailer: git-send-email 1.7.10.4 In-reply-to: <1415890888-8881-1-git-send-email-b.zolnierkie@samsung.com> References: <1415890888-8881-1-git-send-email-b.zolnierkie@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprBLMWRmVeSWpSXmKPExsVy+t9jQd1JJ1JCDD6/NbRouBpisXHGelaL +VeusVqcbXrDbvHm4WZGi8u75rBZfO49wmgx4/w+JosnD/vYHDg9ds66y+6xeM9LJo++LasY PT5vkgtgieKySUnNySxLLdK3S+DKuN/UwVTwQKzi38nr7A2Mr4W6GDk5JARMJFYe3MMIYYtJ XLi3nq2LkYtDSGA6o8Sh6f+ZIZwuJokF758wgVSxCVhJTGxfBdYhIqAlceLSdiaQImaBZUwS l77NBysSFnCSuPVgNdAoDg4WAVWJ/mvKIGFeAQ+JKV/XM0NsU5TofjaBDcTmBIq/mvoXbKaQ gLvEtUfvmCcw8i5gZFjFKJpakFxQnJSea6RXnJhbXJqXrpecn7uJERxez6R3MK5qsDjEKMDB qMTD+4IlJUSINbGsuDL3EKMEB7OSCK/3YaAQb0piZVVqUX58UWlOavEhRmkOFiVx3oOt1oFC AumJJanZqakFqUUwWSYOTqkGRu+aCvHuUwdUHk41Ylwck57uvWZz91EO+WjtrtnhRqcnsZq8 WLeh2Ff2+bk339e89lfY3b2o7/AsT7WvC1XOWKXs/Kgu/VT0k47LuuVPfzyIvz2Vxfjd0zne olpPuGQLMj6sjeN0Z/cUDlr/9YSZxvYZhVHSV3dfubL0+dUV4ZMME+IPp07eek+JpTgj0VCL uag4EQAcaDl0KwIAAA== Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Factor out code for preparing threshold register value from exynos_tmu_initialize() into get_th_reg(). This is a preparation for introducing per-SoC type tmu_initialize method. There should be no functional changes caused by this patch. Cc: Amit Daniel Kachhap Cc: Lukasz Majewski Cc: Eduardo Valentin Cc: Zhang Rui Signed-off-by: Bartlomiej Zolnierkiewicz Acked-by: Kyungmin Park --- drivers/thermal/samsung/exynos_tmu.c | 37 ++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index b0c0715..6e82fdd 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -158,6 +158,25 @@ static void sanitize_temp_error(struct exynos_tmu_data *data, u32 trim_info) EXYNOS_TMU_TEMP_MASK; } +static u32 get_th_reg(struct exynos_tmu_data *data, u32 threshold, bool falling) +{ + struct exynos_tmu_platform_data *pdata = data->pdata; + int i; + + for (i = 0; i < pdata->non_hw_trigger_levels; i++) { + u8 temp = pdata->trigger_levels[i]; + + if (falling) + temp -= pdata->threshold_falling; + else + threshold &= ~(0xff << 8 * i); + + threshold |= temp_to_code(data, temp) << 8 * i; + } + + return threshold; +} + static int exynos_tmu_initialize(struct platform_device *pdev) { struct exynos_tmu_data *data = platform_get_drvdata(pdev); @@ -221,8 +240,6 @@ static int exynos_tmu_initialize(struct platform_device *pdev) } sanitize_temp_error(data, trim_info); - rising_threshold = readl(data->base + reg->threshold_th0); - if (data->soc == SOC_ARCH_EXYNOS4210) { /* Write temperature code for threshold */ threshold_code = temp_to_code(data, pdata->threshold); @@ -235,18 +252,10 @@ static int exynos_tmu_initialize(struct platform_device *pdev) exynos_tmu_clear_irqs(data); } else { /* Write temperature code for rising and falling threshold */ - for (i = 0; i < pdata->non_hw_trigger_levels; i++) { - threshold_code = temp_to_code(data, - pdata->trigger_levels[i]); - rising_threshold &= ~(0xff << 8 * i); - rising_threshold |= threshold_code << 8 * i; - if (data->soc != SOC_ARCH_EXYNOS5440) { - threshold_code = temp_to_code(data, - pdata->trigger_levels[i] - - pdata->threshold_falling); - falling_threshold |= threshold_code << 8 * i; - } - } + rising_threshold = readl(data->base + reg->threshold_th0); + rising_threshold = get_th_reg(data, rising_threshold, false); + if (data->soc != SOC_ARCH_EXYNOS5440) + falling_threshold = get_th_reg(data, 0, true); writel(rising_threshold, data->base + reg->threshold_th0);