Skip to content

Commit

Permalink
charger-manager: Set current limit of regulator for over current prot…
Browse files Browse the repository at this point in the history
…ection

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>
  • Loading branch information
Chanwoo Choi authored and Anton Vorontsov committed Jul 14, 2012
1 parent bee737b commit 45cd4fb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
15 changes: 15 additions & 0 deletions drivers/power/charger-manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,21 @@ static void charger_extcon_work(struct work_struct *work)
{
struct charger_cable *cable =
container_of(work, struct charger_cable, wq);
int ret;

if (cable->attached && cable->min_uA != 0 && cable->max_uA != 0) {
ret = regulator_set_current_limit(cable->charger->consumer,
cable->min_uA, cable->max_uA);
if (ret < 0) {
pr_err("Cannot set current limit of %s (%s)\n",
cable->charger->regulator_name, cable->name);
return;
}

pr_info("Set current limit of %s : %duA ~ %duA\n",
cable->charger->regulator_name,
cable->min_uA, cable->max_uA);
}

try_charger_enable(cable->cm, cable->attached);
}
Expand Down
8 changes: 8 additions & 0 deletions include/linux/power/charger-manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ struct charger_cable {
bool attached;

struct charger_regulator *charger;

/*
* Set min/max current of regulator to protect over-current issue
* according to a kind of charger cable when cable is attached.
*/
int min_uA;
int max_uA;

struct charger_manager *cm;
};

Expand Down

0 comments on commit 45cd4fb

Please sign in to comment.