blob: c820435386d4e46c32c1e5b11aab2bedb02630f6 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Balaji T K3e664f62010-11-25 16:22:04 +05302/*
3 * Copyright (C) 2010 Texas Instruments
Balaji T K3e664f62010-11-25 16:22:04 +05304 */
5
6#include <common.h>
7#include <command.h>
8
9#ifdef CONFIG_CMD_BAT
10#include <twl6030.h>
11
12int do_vbat(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
13{
14 if (argc == 2) {
15 if (strncmp(argv[1], "startcharge", 12) == 0)
16 twl6030_start_usb_charging();
17 else if (strncmp(argv[1], "stopcharge", 11) == 0)
18 twl6030_stop_usb_charging();
19 else if (strncmp(argv[1], "status", 7) == 0) {
20 twl6030_get_battery_voltage();
21 twl6030_get_battery_current();
22 } else {
23 goto bat_cmd_usage;
24 }
25 } else {
26 goto bat_cmd_usage;
27 }
28 return 0;
29
30bat_cmd_usage:
31 return cmd_usage(cmdtp);
32}
33
34U_BOOT_CMD(
35 bat, 2, 1, do_vbat,
36 "battery charging, voltage/current measurements",
37 "status - display battery voltage and current\n"
38 "bat startcharge - start charging via USB\n"
39 "bat stopcharge - stop charging\n"
40);
Masahiro Yamada08019cc2017-10-26 21:24:24 +090041#endif /* CONFIG_CMD_BAT */