From 2205666349877bb3ea7a1e34b597ea6767fadf24 Mon Sep 17 00:00:00 2001 From: Bjorn Andersson Date: Fri, 20 Apr 2018 21:50:22 +0000 Subject: [PATCH] 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 --- cdb_assist.c | 7 +++++++ cdb_assist.h | 1 + device.c | 6 ++++++ device.h | 2 ++ device_parser.c | 7 ++++++- 5 files changed, 22 insertions(+), 1 deletion(-) diff --git a/cdb_assist.c b/cdb_assist.c index 2aa9667..1c0ce11 100644 --- a/cdb_assist.c +++ b/cdb_assist.c @@ -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); +} diff --git a/cdb_assist.h b/cdb_assist.h index 6d33d72..ec94029 100644 --- a/cdb_assist.h +++ b/cdb_assist.h @@ -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 diff --git a/device.c b/device.c index 81d439a..cabac0e 100644 --- a/device.c +++ b/device.c @@ -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); +} diff --git a/device.h b/device.h index 46dc0c0..974d686 100644 --- a/device.h +++ b/device.h @@ -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 diff --git a/device_parser.c b/device_parser.c index aca9fca..6a3fa6f 100644 --- a/device_parser.c +++ b/device_parser.c @@ -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);