From patchwork Thu Oct 30 12:43:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonghwa Lee X-Patchwork-Id: 5197331 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 7C232C11AC for ; Thu, 30 Oct 2014 12:44:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 90A0420179 for ; Thu, 30 Oct 2014 12:44:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8F14A20165 for ; Thu, 30 Oct 2014 12:44:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759285AbaJ3MoV (ORCPT ); Thu, 30 Oct 2014 08:44:21 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:23881 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759953AbaJ3Mnc (ORCPT ); Thu, 30 Oct 2014 08:43:32 -0400 Received: from epcpsbgr4.samsung.com (u144.gpu120.samsung.co.kr [203.254.230.144]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NE900H13COAFX70@mailout1.samsung.com>; Thu, 30 Oct 2014 21:43:22 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.116]) by epcpsbgr4.samsung.com (EPCPMTA) with SMTP id 3F.EE.18167.A6232545; Thu, 30 Oct 2014 21:43:22 +0900 (KST) X-AuditID: cbfee690-f79ab6d0000046f7-3d-5452326ac5e7 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 3A.91.20081.A6232545; Thu, 30 Oct 2014 21:43:22 +0900 (KST) Received: from localhost.localdomain ([10.252.82.199]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NE900852CO56T50@mmp1.samsung.com>; Thu, 30 Oct 2014 21:43:22 +0900 (KST) From: Jonghwa Lee To: linux-kernel@vger.kernel.org Cc: linux-pm@vger.kernel.org, sre@kernel.org, dbaryshkov@gmail.com, dwmw2@infradead.org, anton@enomsg.org, pavel@ucw.cz, myungjoo.ham@samsung.com, cw00.choi@samsung.com, Jonghwa Lee Subject: [PATCH 09/10] power: charger-manager: Support different polling mode for sleep state. Date: Thu, 30 Oct 2014 21:43:15 +0900 Message-id: <1414672996-28355-10-git-send-email-jonghwa3.lee@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1414672996-28355-1-git-send-email-jonghwa3.lee@samsung.com> References: <1414672996-28355-1-git-send-email-jonghwa3.lee@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrELMWRmVeSWpSXmKPExsWyRsSkRDfLKCjE4PYuVYuDWzUtrn95zmox 6cl7ZouJKyczW3SefcJscXnXHDaLz71HGC1uN65gs7h76iibxendJQ5cHhP6PzF67Jx1l91j 8wotj02rOtk8+rasYvRYsfo7u8fnTXIB7FFcNimpOZllqUX6dglcGdtOTmQqeCJR8W/VBZYG xssiXYycHBICJhJdF74zQ9hiEhfurWfrYuTiEBJYyihxccZvdpiirev2skIkFjFKvN6yjRnC aWOSuNO0AqyKTUBH4v++m2C2iICCxObeZ2AdzAJXGCVuLl7PBJIQFkiQWLRtPVgRi4CqxI43 txlBbF4BT4kze5cCTeUAWqcgMWeSDUiYEyi86cpMFhBbSMBD4sGuLnaQmRIC+9glVs6awggx R0Di2+RDLBC9shKbDkC9IylxcMUNlgmMwgsYGVYxiqYWJBcUJ6UXmegVJ+YWl+al6yXn525i BEbF6X/PJuxgvHfA+hCjAAejEg+v5onAECH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XznExzbBy+XG/g4J5eocMbV3blQK9G7NW+ 8IXS/zh9N6lIpdz3XRZxIMAx/uyvrAWSys1rd0+ckKn7JME2eJ2YhGvx+2+qutwnOBPdb9e0 9PgElXsqsRRnJBpqMRcVJwIA7BfqwM8CAAA= 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=-7.5 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 Add additional polling mode for sleep state to define different mode with normal state. With this change, charger-manager can work differently in normal state or sleep state. e.g, polling aways for normal and polling only when charing for sleep. If there is no defined polling mode for sleep state it just follows the normal state's. In addition to, polling rate is still same in sleep. Signed-off-by: Jonghwa Lee --- drivers/power/charger-manager.c | 20 +++++++++++++++++--- include/linux/power/charger-manager.h | 9 ++++++--- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c index 1ccb9be..0a0834f 100644 --- a/drivers/power/charger-manager.c +++ b/drivers/power/charger-manager.c @@ -291,7 +291,15 @@ static bool is_full_charged(struct charger_manager *cm) */ static bool is_polling_required(struct charger_manager *cm) { - switch (cm->desc->polling_mode) { + enum polling_modes polling_mode; + + if (cm_suspended + && cm->desc->poll_mode_sleep >= 0) + polling_mode = cm->desc->poll_mode_sleep; + else + polling_mode = cm->desc->poll_mode_normal; + + switch (polling_mode) { case CM_POLL_DISABLE: return false; case CM_POLL_ALWAYS: @@ -302,7 +310,7 @@ static bool is_polling_required(struct charger_manager *cm) return is_charging(cm); default: dev_warn(cm->dev, "Incorrect polling_mode (%d)\n", - cm->desc->polling_mode); + polling_mode); } return false; @@ -1158,7 +1166,13 @@ static struct charger_desc *of_cm_parse_desc(struct device *dev) of_property_read_string(np, "cm-name", &desc->psy_name); of_property_read_u32(np, "cm-poll-mode", &poll_mode); - desc->polling_mode = poll_mode; + desc->poll_mode_normal = poll_mode; + + /* Polling mode in sleep state */ + if (!of_property_read_u32(np, "cm-poll-mode-sleep", &poll_mode)) + desc->poll_mode_sleep = poll_mode; + else + desc->poll_mode_sleep = -EINVAL; of_property_read_u32(np, "cm-poll-interval", &desc->polling_interval_ms); diff --git a/include/linux/power/charger-manager.h b/include/linux/power/charger-manager.h index 37fb181..a30a0b6 100644 --- a/include/linux/power/charger-manager.h +++ b/include/linux/power/charger-manager.h @@ -131,8 +131,10 @@ struct charger_regulator { /** * struct charger_desc * @psy_name: the name of power-supply-class for charger manager - * @polling_mode: - * Determine which polling mode will be used + * @poll_mode_normal: + * Determine which polling mode will be used in normal state. + * @poll_mode_sleep: + * Determine which polling mode will be used in sleep state. * @fullbatt_vchkdrop_uV: * Check voltage drop after the battery is fully charged. * If it has dropped more than fullbatt_vchkdrop_uV @@ -170,7 +172,8 @@ struct charger_regulator { struct charger_desc { const char *psy_name; - enum polling_modes polling_mode; + enum polling_modes poll_mode_normal; + enum polling_modes poll_mode_sleep; unsigned int polling_interval_ms; unsigned int fullbatt_vchkdrop_uV;