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