cdb_assist: Support togging the fastboot key

For some devices it's not possible to use fastboot boot and
as such they will not enter fastboot unless the fastboot key
is held. Expose this functionality in the device api.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
This commit is contained in:
Bjorn Andersson
2018-04-20 21:50:22 +00:00
parent 6b334bd512
commit 2205666349
5 changed files with 22 additions and 1 deletions

View File

@@ -583,3 +583,10 @@ void cdb_set_voltage(struct cdb_assist *cdb, unsigned mV)
n = sprintf(buf, "u%d\r\n", mV);
cdb_ctrl_write(cdb, buf, n);
}
void cdb_fastboot_key(struct device *dev, bool on)
{
struct cdb_assist *cdb = dev->cdb;
cdb_gpio(cdb, 1, on);
}

View File

@@ -19,5 +19,6 @@ void cdb_target_break(struct cdb_assist *cdb);
unsigned int cdb_vref(struct cdb_assist *cdb);
void cdb_assist_print_status(struct device *dev);
void cdb_set_voltage(struct cdb_assist *cdb, unsigned mV);
void cdb_fastboot_key(struct device *dev, bool on);
#endif

View File

@@ -138,3 +138,9 @@ void device_boot(struct device *device, const void *data, size_t len)
fastboot_download(device->fastboot, data, len);
device->boot(device);
}
void device_fastboot_key(struct device *device, bool on)
{
if (device->fastboot_key)
device->fastboot_key(device, on);
}

View File

@@ -25,6 +25,7 @@ struct device {
void (*print_status)(struct device *dev);
void (*vbus)(struct device *dev, bool on);
int (*write)(struct device *dev, const void *buf, size_t len);
void (*fastboot_key)(struct device *dev, bool on);
bool set_active;
void *cdb;
@@ -46,5 +47,6 @@ void device_boot(struct device *device, const void *data, size_t len);
void device_fastboot_boot(struct device *device);
void device_fastboot_flash_reboot(struct device *device);
void device_fastboot_key(struct device *device, bool on);
#endif

View File

@@ -99,6 +99,7 @@ static void parse_board(struct device_parser *dp)
dev->print_status = cdb_assist_print_status;
dev->vbus = cdb_assist_vbus;
dev->write = cdb_target_write;
dev->fastboot_key = cdb_fastboot_key;
} else if (!strcmp(key, "conmux")) {
dev->cdb_serial = strdup(value);
@@ -111,9 +112,13 @@ static void parse_board(struct device_parser *dp)
} else if (!strcmp(key, "fastboot")) {
dev->serial = strdup(value);
dev->boot = device_fastboot_boot;
if (!dev->boot)
dev->boot = device_fastboot_boot;
} else if (!strcmp(key, "fastboot_set_active")) {
dev->set_active = !strcmp(value, "true");
} else if (!strcmp(key, "broken_fastboot_boot")) {
if (!strcmp(value, "true"))
dev->boot = device_fastboot_flash_reboot;
} else {
fprintf(stderr, "device parser: unknown key \"%s\"\n", key);
exit(1);