diff options
author | Vic Yang <victoryang@chromium.org> | 2013-08-27 12:36:47 +0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2013-08-30 15:39:31 +0000 |
commit | ea41735a4cfc658642b861fd2f68dd451824ca74 (patch) | |
tree | e607a5ce7138005715748992b0abc0ecf263fb85 /common/charger_common.c | |
parent | 8f79405766c0172e0e958ce54b0a2b6f4a7c8be6 (diff) | |
download | chrome-ec-ea41735a4cfc658642b861fd2f68dd451824ca74.tar.gz |
Add BQ24192 charger driver
This is the initial version of BQ24192 charger driver. For now, it only
probes for BQ24192 chip on initialization and get BQ24192 into host
mode.
Also, charger_closest_current() is identical across all charger drivers.
Let's move it to charger_common.c.
BUG=chrome-os-partner:22238
TEST=Build all boards. Boot Kirby and see BQ24192 initialized.
BRANCH=None
Change-Id: I5291362ff0e69b281bffd6d609ce6dc48eb10898
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/167457
Diffstat (limited to 'common/charger_common.c')
-rw-r--r-- | common/charger_common.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/common/charger_common.c b/common/charger_common.c index bb301c48a5..0c86a73156 100644 --- a/common/charger_common.c +++ b/common/charger_common.c @@ -25,6 +25,25 @@ int charger_closest_voltage(int voltage) return voltage - (voltage % info->voltage_step); } +int charger_closest_current(int current) +{ + const struct charger_info * const info = charger_get_info(); + + /* + * If the requested current is non-zero but below our minimum, + * return the minimum. See crosbug.com/p/8662. + */ + if (current > 0 && current < info->current_min) + return info->current_min; + + /* Clip to max */ + if (current > info->current_max) + return info->current_max; + + /* Otherwise round down to nearest current step */ + return current - (current % info->current_step); +} + static int print_info(void) { int rv; |