blob: 6bf44d926550ab6dc78bc96b8cb4bc72ebf7da70 [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
Balaji T K13c3c502010-11-25 16:22:04 +05306#include <command.h>
7
8#ifdef CONFIG_CMD_BAT
9#include <twl6030.h>
10
Simon Glassed38aef2020-05-10 11:40:03 -060011int do_vbat(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
Balaji T K13c3c502010-11-25 16:22:04 +053012{
13 if (argc == 2) {
14 if (strncmp(argv[1], "startcharge", 12) == 0)
15 twl6030_start_usb_charging();
16 else if (strncmp(argv[1], "stopcharge", 11) == 0)
17 twl6030_stop_usb_charging();
18 else if (strncmp(argv[1], "status", 7) == 0) {
19 twl6030_get_battery_voltage();
20 twl6030_get_battery_current();
21 } else {
22 goto bat_cmd_usage;
23 }
24 } else {
25 goto bat_cmd_usage;
26 }
27 return 0;
28
29bat_cmd_usage:
30 return cmd_usage(cmdtp);
31}
32
33U_BOOT_CMD(
34 bat, 2, 1, do_vbat,
35 "battery charging, voltage/current measurements",
36 "status - display battery voltage and current\n"
37 "bat startcharge - start charging via USB\n"
38 "bat stopcharge - stop charging\n"
39);
Masahiro Yamadaad8841c2017-10-26 21:24:24 +090040#endif /* CONFIG_CMD_BAT */