xref: /openbmc/u-boot/board/ti/sdp4430/cmd_bat.c (revision 87a62bce)
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2010 Texas Instruments
4  */
5 
6 #include <common.h>
7 #include <command.h>
8 
9 #ifdef CONFIG_CMD_BAT
10 #include <twl6030.h>
11 
12 int 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 
30 bat_cmd_usage:
31 	return cmd_usage(cmdtp);
32 }
33 
34 U_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 );
41 #endif /* CONFIG_CMD_BAT */
42