mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonghwa Lee <jonghwa3.lee@samsung.com>
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 <jonghwa3.lee@samsung.com>
Subject: [PATCH 09/10] power: charger-manager: Support different polling mode for sleep state.
Date: Thu, 30 Oct 2014 21:43:15 +0900	[thread overview]
Message-ID: <1414672996-28355-10-git-send-email-jonghwa3.lee@samsung.com> (raw)
In-Reply-To: <1414672996-28355-1-git-send-email-jonghwa3.lee@samsung.com>

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 <jonghwa3.lee@samsung.com>
---
 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;
-- 
1.7.9.5


  parent reply	other threads:[~2014-10-30 12:44 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-30 12:43 [PATCH V2 0/10] Improve charger manager driver for optimized operation Jonghwa Lee
2014-10-30 12:43 ` [PATCH 01/10] power: charger-manager: Use thermal subsystem interface only to get temperature Jonghwa Lee
2014-10-30 13:11   ` Krzysztof Kozłowski
2014-10-31  2:25     ` jonghwa3.lee
2014-10-30 12:43 ` [PATCH 02/10] power: charger-manager: Use power_supply_changed() not private uevent Jonghwa Lee
2014-10-30 12:43 ` [PATCH 03/10] power: charger-manager: Remove deprecated function, cm_notify_event() Jonghwa Lee
2014-10-30 12:43 ` [PATCH 04/10] power: charger-manager: Fix to use CHARGE_NOW/FULL property correctly Jonghwa Lee
2014-10-30 12:43 ` [PATCH 05/10] power: charger-manager: Concentrate scattered power_supply_changed() calls Jonghwa Lee
2014-10-30 12:43 ` [PATCH 06/10] power: charger-manager: Get external power souce information only from EXTCON Jonghwa Lee
2014-10-30 12:43 ` [PATCH 07/10] power: charger-manager: Make chraging decision focusing on battery status Jonghwa Lee
2014-10-30 12:43 ` [PATCH 08/10] power: charger-manager: Not to start charging directly in cable nofitication Jonghwa Lee
2014-10-30 12:43 ` Jonghwa Lee [this message]
2014-10-30 12:43 ` [PATCH 10/10] power: charger-manager: Support to change polling rate in runtime Jonghwa Lee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1414672996-28355-10-git-send-email-jonghwa3.lee@samsung.com \
    --to=jonghwa3.lee@samsung.com \
    --cc=anton@enomsg.org \
    --cc=cw00.choi@samsung.com \
    --cc=dbaryshkov@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=myungjoo.ham@samsung.com \
    --cc=pavel@ucw.cz \
    --cc=sre@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®