blob: 6c1e6ca393c66b3183b76ddc1272897a2f58c342 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Balaji T K13c3c502010-11-25 16:22:04 +05302/*
3 * Copyright (C) 2010 Texas Instruments
Balaji T K13c3c502010-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
Simon Glassed38aef2020-05-10 11:40:03 -060012int do_vbat(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
Balaji T K13c3c502010-11-25 16:22:04 +053013{
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 Yamadaad8841c2017-10-26 21:24:24 +090041#endif /* CONFIG_CMD_BAT */