cdba: Support sending break with CDB assist

Add special key 'B' to send a break, currently only implemented with the
CDB assist.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
This commit is contained in:
Bjorn Andersson
2019-08-26 10:10:49 -07:00
parent 91ee23ae86
commit f068352970
8 changed files with 21 additions and 6 deletions

3
bad.c
View File

@@ -195,6 +195,9 @@ static int handle_stdin(int fd, void *buf)
case MSG_VBUS_OFF:
device_vbus(selected_device, false);
break;
case MSG_SEND_BREAK:
device_send_break(selected_device);
break;
default:
fprintf(stderr, "unk %d len %d\n", msg->type, msg->len);
exit(1);

View File

@@ -542,8 +542,10 @@ int cdb_target_write(struct device *dev, const void *buf, size_t len)
return write(cdb->target_tty, buf, len);
}
void cdb_target_break(struct cdb_assist *cdb)
void cdb_send_break(struct device *dev)
{
struct cdb_assist *cdb = dev->cdb;
tcsendbreak(cdb->target_tty, 0);
}

View File

@@ -15,7 +15,7 @@ int cdb_assist_power_off(struct device *dev);
void cdb_assist_vbus(struct device *dev, bool on);
void cdb_gpio(struct cdb_assist *cdb, int gpio, bool on);
int cdb_target_write(struct device *dev, const void *buf, size_t len);
void cdb_target_break(struct cdb_assist *cdb);
void cdb_send_break(struct device *dev);
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);

8
cdba.c
View File

@@ -193,11 +193,11 @@ static int tty_callback(int *ssh_fds)
write(ssh_fds[0], &hdr, sizeof(hdr));
write(ssh_fds[0], "\001", 1);
break;
#if 0
case 'b':
device_break(device);
case 'B':
hdr.type = MSG_SEND_BREAK;
hdr.len = 0;
write(ssh_fds[0], &hdr, sizeof(hdr));
break;
#endif
}
special = false;

1
cdba.h
View File

@@ -27,6 +27,7 @@ enum {
MSG_VBUS_ON,
MSG_VBUS_OFF,
MSG_FASTBOOT_REBOOT,
MSG_SEND_BREAK,
};
#endif

View File

@@ -173,3 +173,9 @@ void device_fastboot_key(struct device *device, bool on)
if (device->fastboot_key)
device->fastboot_key(device, on);
}
void device_send_break(struct device *device)
{
if (device->send_break)
device->send_break(device);
}

View File

@@ -28,6 +28,7 @@ struct device {
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);
void (*send_break)(struct device *dev);
bool set_active;
void *cdb;
@@ -50,5 +51,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);
void device_send_break(struct device *device);
#endif

View File

@@ -103,6 +103,7 @@ static void parse_board(struct device_parser *dp)
dev->vbus = cdb_assist_vbus;
dev->write = cdb_target_write;
dev->fastboot_key = cdb_fastboot_key;
dev->send_break = cdb_send_break;
} else if (!strcmp(key, "conmux")) {
dev->cdb_serial = strdup(value);