mirror of
https://xff.cz/git/u-boot/
synced 2025-09-01 00:32:04 +02:00
axp: Support more LED blinking modes
Signed-off-by: Ondrej Jirman <megous@megous.com>
This commit is contained in:
20
cmd/axp.c
20
cmd/axp.c
@@ -123,7 +123,25 @@ static int do_axp(cmd_tbl_t *cmdtp, int flag, int argc,
|
||||
if (argc < 3)
|
||||
return CMD_RET_USAGE;
|
||||
|
||||
ret = axp_led_set(!strcmp(argv[2], "1"));
|
||||
if (strlen(argv[2]) != 1)
|
||||
return CMD_RET_USAGE;
|
||||
switch (argv[2][0]) {
|
||||
case '0':
|
||||
ret = axp_led_set(0);
|
||||
break;
|
||||
case '1':
|
||||
ret = axp_led_set(1);
|
||||
break;
|
||||
case 'a':
|
||||
ret = axp_led_set(2);
|
||||
break;
|
||||
case 'b':
|
||||
ret = axp_led_set(3);
|
||||
break;
|
||||
default:
|
||||
return CMD_RET_USAGE;
|
||||
}
|
||||
|
||||
if (ret)
|
||||
return CMD_RET_FAILURE;
|
||||
} else if (!strcmp(argv[1], "led_chgctl")) {
|
||||
|
@@ -504,7 +504,7 @@ int axp_led_set_charger_controlled(void)
|
||||
return pmic_bus_write(AXP_CHGLED, val);
|
||||
}
|
||||
|
||||
int axp_led_set(bool on)
|
||||
int axp_led_set(int mode)
|
||||
{
|
||||
int ret;
|
||||
u8 val;
|
||||
@@ -514,7 +514,22 @@ int axp_led_set(bool on)
|
||||
return ret;
|
||||
|
||||
val &= ~(AXP_CHGLED_CTRL_CHARGER | AXP_CHGLED_SETUP_MASK);
|
||||
val |= on ? AXP_CHGLED_SETUP_ON : AXP_CHGLED_SETUP_OFF;
|
||||
switch (mode) {
|
||||
case 0:
|
||||
val |= AXP_CHGLED_SETUP_OFF;
|
||||
break;
|
||||
case 1:
|
||||
val |= AXP_CHGLED_SETUP_ON;
|
||||
break;
|
||||
case 2:
|
||||
val |= AXP_CHGLED_SETUP_BLINK_FAST;
|
||||
break;
|
||||
case 3:
|
||||
val |= AXP_CHGLED_SETUP_BLINK_SLOW;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
return pmic_bus_write(AXP_CHGLED, val);
|
||||
}
|
||||
|
@@ -146,5 +146,5 @@ int axp_battery_get_capacity(int* capacity);
|
||||
int axp_usb_get_max_current(int* mA);
|
||||
int axp_usb_set_max_current(int mA);
|
||||
int axp_led_set_charger_controlled(void);
|
||||
int axp_led_set(bool on);
|
||||
int axp_led_set(int mode);
|
||||
int axp_pok_set_quick(void);
|
||||
|
Reference in New Issue
Block a user