alpaca: Add configuration for keeping USB always connected

USB on the Primus acts up when we toggle USB in Alpaca, so add a
configuration option to force it on at all times.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
This commit is contained in:
Bjorn Andersson
2021-01-22 17:26:17 -06:00
parent dde2030cda
commit e685d367bc
3 changed files with 11 additions and 2 deletions

View File

@@ -73,7 +73,11 @@ void *alpaca_open(struct device *dev)
err(1, "failed to open %s", dev->alpaca_dev);
alpaca_device_power(alpaca, 0);
alpaca_usb_device_power(alpaca, 0);
if (dev->usb_always_on)
alpaca_usb_device_power(alpaca, 1);
else
alpaca_usb_device_power(alpaca, 0);
usleep(500000);
@@ -156,7 +160,9 @@ int alpaca_power_on(struct device *dev)
int alpaca_power_off(struct device *dev)
{
alpaca_device_power(dev->cdb, 0);
alpaca_usb_device_power(dev->cdb, 0);
if (!dev->usb_always_on)
alpaca_usb_device_power(dev->cdb, 0);
return 0;
}

View File

@@ -19,6 +19,7 @@ struct device {
unsigned voltage;
bool tickle_mmc;
bool pshold_shutdown;
bool usb_always_on;
struct fastboot *fastboot;
unsigned int fastboot_key_timeout;

View File

@@ -138,6 +138,8 @@ static void parse_board(struct device_parser *dp)
dev->description = strdup(value);
} else if (!strcmp(key, "fastboot_key_timeout")) {
dev->fastboot_key_timeout = strtoul(value, NULL, 10);
} else if (!strcmp(key, "usb_always_on")) {
dev->usb_always_on = !strcmp(value, "true");
} else {
fprintf(stderr, "device parser: unknown key \"%s\"\n", key);
exit(1);