aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChanwoo Choi <cw00.choi@samsung.com>2012-07-12 02:03:29 -0400
committerAnton Vorontsov <anton.vorontsov@linaro.org>2012-07-13 21:31:17 -0400
commit45cd4fb28b43756afcd752ed1e8b3b836c1b1a2a (patch)
tree2c4d2303c772f4a149be6c4b9b8a0a2dd04d0aa9
parentbee737bccb03ebd27f2d52706e9aed2fa2c8dcc4 (diff)
charger-manager: Set current limit of regulator for over current protection
This patch support the protection of host device from over current. The Charger-manager set proper current limit of charger(regulator) for charging according to type of charger cable when external connector is attached. Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
-rw-r--r--drivers/power/charger-manager.c15
-rw-r--r--include/linux/power/charger-manager.h8
2 files changed, 23 insertions, 0 deletions
diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c
index d1e99e7957d2..526e5c931294 100644
--- a/drivers/power/charger-manager.c
+++ b/drivers/power/charger-manager.c
@@ -1001,6 +1001,21 @@ static void charger_extcon_work(struct work_struct *work)
1001{ 1001{
1002 struct charger_cable *cable = 1002 struct charger_cable *cable =
1003 container_of(work, struct charger_cable, wq); 1003 container_of(work, struct charger_cable, wq);
1004 int ret;
1005
1006 if (cable->attached && cable->min_uA != 0 && cable->max_uA != 0) {
1007 ret = regulator_set_current_limit(cable->charger->consumer,
1008 cable->min_uA, cable->max_uA);
1009 if (ret < 0) {
1010 pr_err("Cannot set current limit of %s (%s)\n",
1011 cable->charger->regulator_name, cable->name);
1012 return;
1013 }
1014
1015 pr_info("Set current limit of %s : %duA ~ %duA\n",
1016 cable->charger->regulator_name,
1017 cable->min_uA, cable->max_uA);
1018 }
1004 1019
1005 try_charger_enable(cable->cm, cable->attached); 1020 try_charger_enable(cable->cm, cable->attached);
1006} 1021}
diff --git a/include/linux/power/charger-manager.h b/include/linux/power/charger-manager.h
index 6cb9fbc9a153..cd22029e32aa 100644
--- a/include/linux/power/charger-manager.h
+++ b/include/linux/power/charger-manager.h
@@ -94,6 +94,14 @@ struct charger_cable {
94 bool attached; 94 bool attached;
95 95
96 struct charger_regulator *charger; 96 struct charger_regulator *charger;
97
98 /*
99 * Set min/max current of regulator to protect over-current issue
100 * according to a kind of charger cable when cable is attached.
101 */
102 int min_uA;
103 int max_uA;
104
97 struct charger_manager *cm; 105 struct charger_manager *cm;
98}; 106};
99 107