hc
2025-02-14 bbb9540dc49f70f6b703d1c8d1b85fa5f602d86e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
 * (C) Copyright 2017 Rockchip Electronics Co., Ltd
 *
 * SPDX-License-Identifier:     GPL-2.0+
 */
 
#include <common.h>
#include <command.h>
#include <dm.h>
#include <power/charge_display.h>
#include <power/charge_animation.h>
 
static int do_charge_display(cmd_tbl_t *cmdtp, int flag, int argc,
                char *const argv[])
{
 
   struct charge_animation_pdata *pdata;
   struct udevice *dev;
   int screen_voltage;
   int on_voltage;
   int on_soc;
   int save[3];
   int ret;
 
   if (argc != 4 && argc != 1)
       return CMD_RET_USAGE;
 
   ret = uclass_get_device(UCLASS_CHARGE_DISPLAY, 0, &dev);
   if (ret) {
       if (ret != -ENODEV) {
           printf("Get UCLASS CHARGE DISPLAY failed: %d\n", ret);
           return ret;
       }
 
       return 0;
   }
 
   if (argc == 4) {
       pdata = dev_get_platdata(dev);
       save[0] = pdata->exit_charge_level;
       save[1] = pdata->exit_charge_voltage;
       save[2] = pdata->screen_on_voltage;
 
       on_soc = simple_strtoul(argv[1], NULL, 0);
       on_voltage = simple_strtoul(argv[2], NULL, 0);
       screen_voltage = simple_strtoul(argv[3], NULL, 0);
       debug("new: on_soc=%d, on_voltage=%d, screen_voltage=%d\n",
             on_soc, on_voltage, screen_voltage);
 
       pdata->exit_charge_level = on_soc;
       pdata->exit_charge_voltage = on_voltage;
       pdata->screen_on_voltage = screen_voltage;
 
       charge_display_show(dev);
 
       pdata->exit_charge_level = save[0];
       pdata->exit_charge_voltage = save[1];
       pdata->screen_on_voltage = save[2];
   } else if (argc == 1) {
       charge_display_show(dev);
   } else {
       return CMD_RET_USAGE;
   }
 
   return 0;
}
 
U_BOOT_CMD(charge, 4, 0, do_charge_display,
      "Charge display",
      "-charge\n"
      "-charge <power on soc> <power on voltage> <screen on voltage>"
);