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 | |
Balaji T K | 13c3c50 | 2010-11-25 16:22:04 +0530 | [diff] [blame] | 6 | #include <command.h> |
| 7 | |
| 8 | #ifdef CONFIG_CMD_BAT |
| 9 | #include <twl6030.h> |
| 10 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 11 | 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] | 12 | { |
| 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 | |
| 29 | bat_cmd_usage: |
| 30 | return cmd_usage(cmdtp); |
| 31 | } |
| 32 | |
| 33 | U_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 Yamada | ad8841c | 2017-10-26 21:24:24 +0900 | [diff] [blame] | 40 | #endif /* CONFIG_CMD_BAT */ |