From patchwork Tue Feb 10 22:50:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Hall X-Patchwork-Id: 5809251 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5254C9F36A for ; Tue, 10 Feb 2015 22:50:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5B466201FE for ; Tue, 10 Feb 2015 22:50:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5C056201F4 for ; Tue, 10 Feb 2015 22:50:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754459AbbBJWud (ORCPT ); Tue, 10 Feb 2015 17:50:33 -0500 Received: from mail-ie0-f180.google.com ([209.85.223.180]:42696 "EHLO mail-ie0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752360AbbBJWuc (ORCPT ); Tue, 10 Feb 2015 17:50:32 -0500 Received: by iery20 with SMTP id y20so20192493ier.9; Tue, 10 Feb 2015 14:50:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=Us661sjzos7dLUv7U1/dCnpD1dOGnhwk0IvY0nQB7a4=; b=EcrXLY36RvPUbF/K5SKZIVqk4zcWLJlQWBE6UGw399PgQheEXr5HX6kUNd7CTWl8C2 djOA4UHrS3GdLrd50AImjaA3FILPkz9YX6xDeDFFbPFBGjKw5dmn17Y9Rd4mqV80bAra nsftl+4KX8NCUZo5oEwUCau7NnPZmSpAzR0VTXOVeAbJqhIW8bbQCQOvVf0+Do6uTupy XRo5PoOM3blqQLHidQgb7t5eH6eH2xW/ecbfiLzlWDG8xCuK9vByYhSnfI+N7n4obu8D SnitZmth1X+2Mj2Kq1cXHof+hrN7Hy4VkCqnIZ8g0uiJ7dz93t5XdQ7L8iRYv8W90bzZ GTAg== X-Received: by 10.107.16.32 with SMTP id y32mr35807742ioi.39.1423608631727; Tue, 10 Feb 2015 14:50:31 -0800 (PST) Received: from metric.localdomain (CPE-76-177-97-210.natcky.res.rr.com. [76.177.97.210]) by mx.google.com with ESMTPSA id ig15sm233996igb.10.2015.02.10.14.50.30 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Feb 2015 14:50:31 -0800 (PST) From: Tyler Hall To: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: devicetree@vger.kernel.org, Ezequiel Garcia , Zhang Rui , Eduardo Valentin , Tyler Hall Subject: [PATCH] thermal: armada: read stable temp on Armada XP Date: Tue, 10 Feb 2015 17:50:15 -0500 Message-Id: <1423608615-6575-1-git-send-email-tylerwhall@gmail.com> X-Mailer: git-send-email 2.3.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_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 The current register being used to read the temperature returns a noisy value that is prone to variance and occasional outliers. The value in the thermal manager control and status register appears to have the same scale but much less variability. Add a "marvell,armadaxp-filtered-thermal" config which is set up to read from the Thermal Manager Control and Status Register at 0x184c4 rather than the Thermal Sensor Status Register at 0x182b0. The only difference is the temperature value shift. The original "marvell,armadaxp-thermal" is retained for device tree compatibility. This also fixes Armada XP clearing the disable bit in the wrong register. Bit 0 of the sensor register was being cleared but that bit is read-only. The disable bit doesn't seem to have an effect on the temperature sensor value, however, so this doesn't make a material difference. This problem was detected when running with the watchdog(8) daemon polling the thermal value. In one instance I observed a single read of over 200 degrees C which caused a spurious watchdog-initiated reboot. I have since observed individual outliers of ~20 degrees C. With this change and the corresponding device tree update, the temperature is much more stable. Signed-off-by: Tyler Hall --- If there's a better way to handle this than a separate binding, I'm open to suggestions. My conclusions about these registers are based on experimental data. The documentation is very sparse, but the Thermal Manager Control and Status Register looks like the preferred register given the way it is laid out in the public spec. I have the small corresponding patch to the dts which I can submit separately. Thanks Tyler .../devicetree/bindings/thermal/armada-thermal.txt | 8 ++++++++ drivers/thermal/armada_thermal.c | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/Documentation/devicetree/bindings/thermal/armada-thermal.txt b/Documentation/devicetree/bindings/thermal/armada-thermal.txt index 4698e0e..0d6a3f1 100644 --- a/Documentation/devicetree/bindings/thermal/armada-thermal.txt +++ b/Documentation/devicetree/bindings/thermal/armada-thermal.txt @@ -7,6 +7,14 @@ Required properties: marvell,armada375-thermal marvell,armada380-thermal marvell,armadaxp-thermal + marvell,armadaxp-filtered-thermal + + Note: "marvell,armadaxp-filtered-thermal" is adjusted to read + the hardware-filtered value in the thermal manager + control/status register rather than the raw sensor value in the + thermal sensor status register. "marvell,armadaxp-thermal" + remains for backward compatibility. The sensor reg address must + also point to the appropriate register. - reg: Device's register space. Two entries are expected, see the examples below. diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c index c2556cf..d3c2ad3 100644 --- a/drivers/thermal/armada_thermal.c +++ b/drivers/thermal/armada_thermal.c @@ -196,6 +196,15 @@ static const struct armada_thermal_data armadaxp_data = { .coef_div = 13825, }; +static const struct armada_thermal_data armadaxp_filt_data = { + .init_sensor = armadaxp_init_sensor, + .temp_shift = 1, + .temp_mask = 0x1ff, + .coef_b = 3153000000UL, + .coef_m = 10000000UL, + .coef_div = 13825, +}; + static const struct armada_thermal_data armada370_data = { .is_valid = armada_is_valid, .init_sensor = armada370_init_sensor, @@ -236,6 +245,10 @@ static const struct of_device_id armada_thermal_id_table[] = { .data = &armadaxp_data, }, { + .compatible = "marvell,armadaxp-filtered-thermal", + .data = &armadaxp_filt_data, + }, + { .compatible = "marvell,armada370-thermal", .data = &armada370_data, },