Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Balaji T K | 13c3c50 | 2010-11-25 16:22:04 +0530 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2010 Texas Instruments |
Balaji T K | 13c3c50 | 2010-11-25 16:22:04 +0530 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <command.h> |
| 8 | |
| 9 | #ifdef CONFIG_CMD_BAT |
| 10 | #include <twl6030.h> |
| 11 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 12 | int do_vbat(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) |
Balaji T K | 13c3c50 | 2010-11-25 16:22:04 +0530 | [diff] [blame] | 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 | ); |
Masahiro Yamada | ad8841c | 2017-10-26 21:24:24 +0900 | [diff] [blame] | 41 | #endif /* CONFIG_CMD_BAT */ |