summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonghwa Lee <jonghwa3.lee@samsung.com>2014-10-24 05:45:02 (GMT)
committerChanho Park <chanho61.park@samsung.com>2014-11-18 03:01:06 (GMT)
commite6939f25b5352491d56fbd63ef06539ff8fc2896 (patch)
treea0026411a6509d7df5a73d6c1c62d4f4f921aad6
parent764843b0d3d44e4a7a689bd85b019d6c97447f03 (diff)
downloadlinux-3.10-e6939f25b5352491d56fbd63ef06539ff8fc2896.zip
linux-3.10-e6939f25b5352491d56fbd63ef06539ff8fc2896.tar.gz
linux-3.10-e6939f25b5352491d56fbd63ef06539ff8fc2896.tar.bz2
power: charger-manager: Support different polling mode for sleep state.
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. Change-Id: I787a3abd646bdc0be81dccbafbd635c22c84951c Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
-rw-r--r--drivers/power/charger-manager.c19
-rw-r--r--include/linux/power/charger-manager.h9
2 files changed, 22 insertions, 6 deletions
diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c
index c739a89..7f2a57f 100644
--- a/drivers/power/charger-manager.c
+++ b/drivers/power/charger-manager.c
@@ -202,7 +202,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:
@@ -213,7 +221,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;
@@ -1054,6 +1062,7 @@ static struct charger_desc *of_cm_parse_desc(struct device *dev)
u32 poll_mode = CM_POLL_DISABLE;
u32 battery_stat = CM_NO_BATTERY;
int num_chgs = 0;
+ int ret;
desc = devm_kzalloc(dev, sizeof(*desc), GFP_KERNEL);
if (!desc)
@@ -1062,7 +1071,11 @@ 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 */
+ ret = of_property_read_u32(np, "cm-poll-mode-sleep", &poll_mode);
+ desc->poll_mode_sleep = (!ret) ? poll_mode : -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 d380ba3..a644a28 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
@@ -171,7 +173,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;