Balaji T K | 3e664f6 | 2010-11-25 16:22:04 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 Texas Instruments |
| 3 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame^] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Balaji T K | 3e664f6 | 2010-11-25 16:22:04 +0530 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <command.h> |
| 9 | |
| 10 | #ifdef CONFIG_CMD_BAT |
| 11 | #include <twl6030.h> |
| 12 | |
| 13 | int 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 | |
| 31 | bat_cmd_usage: |
| 32 | return cmd_usage(cmdtp); |
| 33 | } |
| 34 | |
| 35 | U_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 */ |