From patchwork Fri Sep 12 11:11:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonghwa Lee X-Patchwork-Id: 4893841 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 20E67BEEA5 for ; Fri, 12 Sep 2014 11:11:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B2FAA20295 for ; Fri, 12 Sep 2014 11:11:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 236DF20266 for ; Fri, 12 Sep 2014 11:11:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754052AbaILLLg (ORCPT ); Fri, 12 Sep 2014 07:11:36 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:35439 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752905AbaILLLf (ORCPT ); Fri, 12 Sep 2014 07:11:35 -0400 Received: from epcpsbgr5.samsung.com (u145.gpu120.samsung.co.kr [203.254.230.145]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NBS00CK3CF9TN30@mailout1.samsung.com> for linux-pm@vger.kernel.org; Fri, 12 Sep 2014 20:11:33 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.113]) by epcpsbgr5.samsung.com (EPCPMTA) with SMTP id D8.85.04513.5E4D2145; Fri, 12 Sep 2014 20:11:33 +0900 (KST) X-AuditID: cbfee691-f79546d0000011a1-c9-5412d4e518f9 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id BA.AF.05196.5E4D2145; Fri, 12 Sep 2014 20:11:33 +0900 (KST) Received: from localhost.localdomain ([10.252.82.199]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NBS00I6JCF58I00@mmp2.samsung.com>; Fri, 12 Sep 2014 20:11:33 +0900 (KST) From: Jonghwa Lee To: linux-pm@vger.kernel.org Cc: dbaryshkov@gmail.com, dwmw2@infradead.org, anton@enomsg.org, cw00.choi@samsung.com, myungjoo.ham@samsung.com, Jonghwa Lee Subject: [PATCH 2/6] power: charger-manager: Monitoring temperature becomes mandatory option. Date: Fri, 12 Sep 2014 20:11:23 +0900 Message-id: <1410520287-24825-3-git-send-email-jonghwa3.lee@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1410520287-24825-1-git-send-email-jonghwa3.lee@samsung.com> References: <1410520287-24825-1-git-send-email-jonghwa3.lee@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrJLMWRmVeSWpSXmKPExsWyRsSkUPfpFaEQg7MTJS0ObtW0uP7lOavF pCfvmS0mrpzMbNF59gmzxefeI4wWtxtXsDmwe0zo/8TosXPWXXaPzSu0PPq2rGL0+LxJLoA1 issmJTUnsyy1SN8ugSvj5PWbTAXrtSo23trH2MA4TbmLkZNDQsBE4ujnjcwQtpjEhXvr2boY uTiEBJYySqzYOoMNpmj63uNMEInpjBKfV6yActqYJD6/2s8OUsUmoCPxf99NMFtEQEZi6pX9 rCBFzAJzGCV2z/4KtkNYIF7iT1szI4jNIqAqsfZ7O1icV8BD4vnFb0ANHEDrFCTmTLIBCXMK eEosPrcNbKYQUMm+6W/ZIS6azi4x54IWxBgBiW+TD7FAtMpKbDoA9Y2kxMEVN1gmMAovYGRY xSiaWpBcUJyUXmSqV5yYW1yal66XnJ+7iREY4qf/PZu4g/H+AetDjAIcjEo8vBUsgiFCrIll xZW5hxhNgTZMZJYSTc4HRlJeSbyhsZmR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Xbv7lsPrki4L76N3TIcfHc1Ozfaqb2I+bppiosRSnJFoqMVcVJwIABW8fPC3AgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-9.1 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 Monitoring battery temperature becomes mandatory for charger manager working. If there is no way to measure temperature, it stops probing and won't work. And also it will use thermal susbsystem inteface only to make driver simple. Signed-off-by: Jonghwa Lee --- drivers/power/Kconfig | 1 + drivers/power/charger-manager.c | 75 +++++++-------------------------- include/linux/power/charger-manager.h | 3 +- 3 files changed, 18 insertions(+), 61 deletions(-) diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig index c2613fd..12bf79d 100644 --- a/drivers/power/Kconfig +++ b/drivers/power/Kconfig @@ -317,6 +317,7 @@ config CHARGER_MANAGER bool "Battery charger manager for multiple chargers" depends on REGULATOR select EXTCON + select THERMAL help Say Y to enable charger-manager support, which allows multiple chargers attached to a battery and multiple batteries attached to a diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c index 88c2bc7..7ae2e94 100644 --- a/drivers/power/charger-manager.c +++ b/drivers/power/charger-manager.c @@ -548,19 +548,11 @@ static int cm_get_battery_temperature(struct charger_manager *cm, { int ret; - if (!cm->desc->measure_battery_temp) - return -ENODEV; - -#ifdef CONFIG_THERMAL ret = thermal_zone_get_temp(cm->tzd_batt, (unsigned long *)temp); if (!ret) /* Calibrate temperature unit */ *temp /= 100; -#else - ret = cm->fuel_gauge->get_property(cm->fuel_gauge, - POWER_SUPPLY_PROP_TEMP, - (union power_supply_propval *)temp); -#endif + return ret; } @@ -947,12 +939,11 @@ static enum power_supply_property default_charger_props[] = { POWER_SUPPLY_PROP_CAPACITY, POWER_SUPPLY_PROP_ONLINE, POWER_SUPPLY_PROP_CHARGE_FULL, + POWER_SUPPLY_PROP_TEMP, /* * Optional properties are: * POWER_SUPPLY_PROP_CHARGE_NOW, * POWER_SUPPLY_PROP_CURRENT_NOW, - * POWER_SUPPLY_PROP_TEMP, and - * POWER_SUPPLY_PROP_TEMP_AMBIENT, */ }; @@ -1355,50 +1346,6 @@ err: return ret; } -static int cm_init_thermal_data(struct charger_manager *cm) -{ - struct charger_desc *desc = cm->desc; - union power_supply_propval val; - int ret; - - /* Verify whether fuel gauge provides battery temperature */ - ret = cm->fuel_gauge->get_property(cm->fuel_gauge, - POWER_SUPPLY_PROP_TEMP, &val); - - if (!ret) { - cm->charger_psy.properties[cm->charger_psy.num_properties] = - POWER_SUPPLY_PROP_TEMP; - cm->charger_psy.num_properties++; - cm->desc->measure_battery_temp = true; - } -#ifdef CONFIG_THERMAL - cm->tzd_batt = cm->fuel_gauge->tzd; - - if (ret && desc->thermal_zone) { - cm->tzd_batt = - thermal_zone_get_zone_by_name(desc->thermal_zone); - if (IS_ERR(cm->tzd_batt)) - return PTR_ERR(cm->tzd_batt); - - /* Use external thermometer */ - cm->charger_psy.properties[cm->charger_psy.num_properties] = - POWER_SUPPLY_PROP_TEMP_AMBIENT; - cm->charger_psy.num_properties++; - cm->desc->measure_battery_temp = true; - ret = 0; - } -#endif - if (cm->desc->measure_battery_temp) { - /* NOTICE : Default allowable minimum charge temperature is 0 */ - if (!desc->temp_max) - desc->temp_max = CM_DEFAULT_CHARGE_TEMP_MAX; - if (!desc->temp_diff) - desc->temp_diff = CM_DEFAULT_RECHARGE_TEMP_DIFF; - } - - return ret; -} - static struct of_device_id charger_manager_match[] = { { .compatible = "charger-manager", @@ -1458,11 +1405,16 @@ static struct charger_desc *of_cm_parse_desc(struct device *dev) of_property_read_string(np, "cm-thermal-zone", &desc->thermal_zone); + /* NOTICE : Default allowable minimum charge temperature is 0 */ of_property_read_u32(np, "cm-battery-cold", &desc->temp_min); if (of_get_property(np, "cm-battery-cold-in-minus", NULL)) desc->temp_min *= -1; of_property_read_u32(np, "cm-battery-hot", &desc->temp_max); + if (!desc->temp_max) + desc->temp_max = CM_DEFAULT_CHARGE_TEMP_MAX; of_property_read_u32(np, "cm-battery-temp-diff", &desc->temp_diff); + if (!desc->temp_diff) + desc->temp_diff = CM_DEFAULT_RECHARGE_TEMP_DIFF; of_property_read_u32(np, "cm-charging-max", &desc->charging_max_duration_ms); @@ -1669,10 +1621,15 @@ static int charger_manager_probe(struct platform_device *pdev) cm->charger_psy.num_properties++; } - ret = cm_init_thermal_data(cm); - if (ret) { - dev_err(&pdev->dev, "Failed to initialize thermal data\n"); - cm->desc->measure_battery_temp = false; + if (desc->thermal_zone) + cm->tzd_batt = + thermal_zone_get_zone_by_name(desc->thermal_zone); + else + cm->tzd_batt = cm->fuel_gauge->tzd; + + if (!cm->tzd_batt) { + pr_err("No way to monitor battery temperature.\n"); + return -ENODEV; } INIT_DELAYED_WORK(&cm->fullbatt_vchk_work, fullbatt_vchk); diff --git a/include/linux/power/charger-manager.h b/include/linux/power/charger-manager.h index 8e111f3..e692674 100644 --- a/include/linux/power/charger-manager.h +++ b/include/linux/power/charger-manager.h @@ -234,9 +234,8 @@ struct charger_manager { struct power_supply *fuel_gauge; struct power_supply **charger_stat; -#ifdef CONFIG_THERMAL struct thermal_zone_device *tzd_batt; -#endif + bool charger_enabled; unsigned long fullbatt_vchk_jiffies_at;