From patchwork Thu Apr 24 20:23:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 4053721 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8C07EBFF02 for ; Thu, 24 Apr 2014 20:24:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B19E220353 for ; Thu, 24 Apr 2014 20:24:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D8B042025A for ; Thu, 24 Apr 2014 20:24:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752710AbaDXUYP (ORCPT ); Thu, 24 Apr 2014 16:24:15 -0400 Received: from top.free-electrons.com ([176.31.233.9]:40777 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752675AbaDXUYP (ORCPT ); Thu, 24 Apr 2014 16:24:15 -0400 Received: by mail.free-electrons.com (Postfix, from userid 106) id 68D82938; Thu, 24 Apr 2014 22:24:14 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from localhost.localdomain (unknown [190.2.108.30]) by mail.free-electrons.com (Postfix) with ESMTPSA id A75E4941; Thu, 24 Apr 2014 22:24:10 +0200 (CEST) From: Ezequiel Garcia To: , Cc: Jason Cooper , Zhang Rui , Sebastian Hesselbarth , Andrew Lunn , Thomas Petazzoni , Gregory Clement , Lior Amsalem , Tawfik Bayouk , , Ezequiel Garcia Subject: [PATCH v2 03/10] thermal: armada: Add generic infrastructure to handle the sensor Date: Thu, 24 Apr 2014 17:23:17 -0300 Message-Id: <1398371004-15807-4-git-send-email-ezequiel.garcia@free-electrons.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1398371004-15807-1-git-send-email-ezequiel.garcia@free-electrons.com> References: <1398371004-15807-1-git-send-email-ezequiel.garcia@free-electrons.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In order to support similar SoC where the sensor value and valid bit can have different offset and/or mask, we add such fields to the per-variant structure, instead of having the values hardcoded. Signed-off-by: Ezequiel Garcia --- drivers/thermal/armada_thermal.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c index 4de6e56..3e4d8ef 100644 --- a/drivers/thermal/armada_thermal.c +++ b/drivers/thermal/armada_thermal.c @@ -24,10 +24,7 @@ #include #include -#define THERMAL_VALID_OFFSET 9 #define THERMAL_VALID_MASK 0x1 -#define THERMAL_TEMP_OFFSET 10 -#define THERMAL_TEMP_MASK 0x1ff /* Thermal Manager Control and Status Register */ #define PMU_TDC0_SW_RST_MASK (0x1 << 1) @@ -58,6 +55,11 @@ struct armada_thermal_data { unsigned long coef_b; unsigned long coef_m; unsigned long coef_div; + + /* Offset and mask to access the sensor temperature */ + unsigned int temp_offset; + unsigned int temp_mask; + unsigned int is_valid_offset; }; static void armadaxp_init_sensor(struct armada_thermal_priv *priv) @@ -108,7 +110,7 @@ static bool armada_is_valid(struct armada_thermal_priv *priv) { unsigned long reg = readl_relaxed(priv->sensor); - return (reg >> THERMAL_VALID_OFFSET) & THERMAL_VALID_MASK; + return (reg >> priv->data->is_valid_offset) & THERMAL_VALID_MASK; } static int armada_get_temp(struct thermal_zone_device *thermal, @@ -126,7 +128,7 @@ static int armada_get_temp(struct thermal_zone_device *thermal, } reg = readl_relaxed(priv->sensor); - reg = (reg >> THERMAL_TEMP_OFFSET) & THERMAL_TEMP_MASK; + reg = (reg >> priv->data->temp_offset) & priv->data->temp_mask; /* Get formula coeficients */ b = priv->data->coef_b; @@ -143,6 +145,8 @@ static struct thermal_zone_device_ops ops = { static const struct armada_thermal_data armadaxp_data = { .init_sensor = armadaxp_init_sensor, + .temp_offset = 10, + .temp_mask = 0x1ff, .coef_b = 3153000000UL, .coef_m = 10000000UL, .coef_div = 13825, @@ -151,6 +155,9 @@ static const struct armada_thermal_data armadaxp_data = { static const struct armada_thermal_data armada370_data = { .is_valid = armada_is_valid, .init_sensor = armada370_init_sensor, + .is_valid_offset = 9, + .temp_offset = 10, + .temp_mask = 0x1ff, .coef_b = 3153000000UL, .coef_m = 10000000UL, .coef_div = 13825,