From patchwork Mon Jun 8 01:11:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 6562591 Return-Path: X-Original-To: patchwork-linux-samsung-soc@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 19B2B9F326 for ; Mon, 8 Jun 2015 01:11:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3424420547 for ; Mon, 8 Jun 2015 01:11:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3E68C20534 for ; Mon, 8 Jun 2015 01:11:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751364AbbFHBLw (ORCPT ); Sun, 7 Jun 2015 21:11:52 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:28230 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751003AbbFHBLu (ORCPT ); Sun, 7 Jun 2015 21:11:50 -0400 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NPL00KJ8PZO0300@mailout2.w1.samsung.com>; Mon, 08 Jun 2015 02:11:48 +0100 (BST) X-AuditID: cbfec7f5-f794b6d000001495-d7-5574ebd3186c Received: from eusync2.samsung.com ( [203.254.199.212]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 26.5F.05269.3DBE4755; Mon, 8 Jun 2015 02:11:47 +0100 (BST) Received: from localhost.localdomain ([10.252.80.64]) by eusync2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NPL00JPPPZHTX70@eusync2.samsung.com>; Mon, 08 Jun 2015 02:11:47 +0100 (BST) From: Krzysztof Kozlowski To: Sebastian Reichel , Dmitry Eremin-Solenikov , David Woodhouse , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Kukjin Kim , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Cc: Krzysztof Kozlowski Subject: [PATCH 1/2] power_supply: max17042: Add OF support for setting thresholds Date: Mon, 08 Jun 2015 10:11:38 +0900 Message-id: <1433725899-13849-1-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplluLIzCtJLcpLzFFi42I5/e/4Fd3Lr0tCDa606VpMevKe2WL+kXOs FhNXTma2eP3C0KL/8Wtmi02Pr7FaXN41h83ic+8RRosZ5/cxWZzeXeLA5bFz1l12j80rtDw2 repk89i8pN6jb8sqRo/Pm+QC2KK4bFJSczLLUov07RK4Mm7P2cNWMFO0YuWZVWwNjD8Euhg5 OSQETCR+3zzEAmGLSVy4t56ti5GLQ0hgKaPE9ON/WSGc/4wSFx7uYgapYhMwlti8fAlYlYjA YSaJQ0dWMoEkmAUMJX6++8MOYgsLhEgcnNXACmKzCKhKrP/3nw3E5hVwl7i1YyfUOjmJk8cm s05g5F7AyLCKUTS1NLmgOCk910ivODG3uDQvXS85P3cTIySQvu5gXHrM6hCjAAejEg/vgUUl oUKsiWXFlbmHGCU4mJVEeO/eBwrxpiRWVqUW5ccXleakFh9ilOZgURLnnbnrfYiQQHpiSWp2 ampBahFMlomDU6qB8Xio05ugkyfC91y5Pf3Z8Z8/Zpn+dPzHcOes8+X7tm62k4XOPuplkz37 aGPv5UjdS5PdZG9HvZ5x5IzGy4mFn2blhn+Y8Kn/45zL29rUN+2W/btU5aXc3wmXfQR5L8Sn W/1ScYnKzzjqrLMyP2OxzecHRbkz3+e9ct/8MUdng/CRNeUOJdo3XZYosRRnJBpqMRcVJwIA oLjoFiACAAA= Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 commit edd4ab055931 ("power: max17042_battery: add HEALTH and TEMP_* properties support") added support for setting voltage and temperature thresholds with platform data. For DeviceTree default of 0 was always used. This caused reporting battery health always as over voltage or over heated. Signed-off-by: Krzysztof Kozlowski Fixes: edd4ab055931 ("power: max17042_battery: add HEALTH and TEMP_* properties support") --- .../devicetree/bindings/power_supply/max17042_battery.txt | 13 +++++++++++++ drivers/power/max17042_battery.c | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/Documentation/devicetree/bindings/power_supply/max17042_battery.txt b/Documentation/devicetree/bindings/power_supply/max17042_battery.txt index 5bc9b685cf8a..3f3894aaeebc 100644 --- a/Documentation/devicetree/bindings/power_supply/max17042_battery.txt +++ b/Documentation/devicetree/bindings/power_supply/max17042_battery.txt @@ -9,10 +9,23 @@ Optional properties : (datasheet-recommended value is 10000). Defining this property enables current-sense functionality. +Optional threshold properties : + If skipped the condition won't be reported. + - maxim,cold-temp : Temperature threshold to report battery + as cold (in tenths of degree Celsius). + - maxim,over-heat-temp : Temperature threshold to report battery + as over heated (in tenths of degree Celsius). + - maxim,dead-volt : Voltage threshold to report battery + as dead (in mV). + - maxim,over-volt : Voltage threshold to report battery + as over voltage (in mV). + Example: battery-charger@36 { compatible = "maxim,max17042"; reg = <0x36>; maxim,rsns-microohm = <10000>; + maxim,over-heat-temp = <600>; + maxim,over-volt = <4300>; }; diff --git a/drivers/power/max17042_battery.c b/drivers/power/max17042_battery.c index 62908eba2763..a8e16364c2aa 100644 --- a/drivers/power/max17042_battery.c +++ b/drivers/power/max17042_battery.c @@ -818,6 +818,15 @@ max17042_get_pdata(struct device *dev) pdata->enable_current_sense = true; } + if (of_property_read_s32(np, "maxim,cold-temp", &pdata->temp_min)) + pdata->temp_min = INT_MIN; + if (of_property_read_s32(np, "maxim,over-heat-temp", &pdata->temp_max)) + pdata->temp_max = INT_MAX; + if (of_property_read_s32(np, "maxim,dead-volt", &pdata->vmin)) + pdata->vmin = INT_MIN; + if (of_property_read_s32(np, "maxim,over-volt", &pdata->vmax)) + pdata->vmax = INT_MAX; + return pdata; } #else