Commit e2ec3e461250fc82781c8a83387c140c6fc30a5a

Authored by Alexey Firago
Committed by Lukasz Majewski
1 parent 8a41802f21

fastboot: add support for reboot-bootloader command

The "fastboot reboot-bootloader" command is defined to
re-enter into fastboot mode after rebooting into
bootloader. This command is usually used after updating
bootloader via fastboot.

This commit implements only a generic side of the
command - setting of the reset flag and then resetting.
Setting of the reset flag is implemented using __weak
fb_set_reboot_flag() function. The actual setting and
checking of the reset flag should be implemented by
a boot script and/or board/SoC specific code.

Signed-off-by: Alexey Firago <alexey_firago@mentor.com>
Tested-by: Steve Rae <srae@broadcom.com>
[Test HW: bcm28155_ap board]

Showing 1 changed file with 13 additions and 0 deletions Side-by-side Diff

drivers/usb/gadget/f_fastboot.c
... ... @@ -123,6 +123,7 @@
123 123 };
124 124  
125 125 static void rx_handler_command(struct usb_ep *ep, struct usb_request *req);
  126 +static int strcmp_l1(const char *s1, const char *s2);
126 127  
127 128 static void fastboot_complete(struct usb_ep *ep, struct usb_request *req)
128 129 {
129 130  
... ... @@ -326,8 +327,20 @@
326 327 do_reset(NULL, 0, 0, NULL);
327 328 }
328 329  
  330 +int __weak fb_set_reboot_flag(void)
  331 +{
  332 + return -ENOSYS;
  333 +}
  334 +
329 335 static void cb_reboot(struct usb_ep *ep, struct usb_request *req)
330 336 {
  337 + char *cmd = req->buf;
  338 + if (!strcmp_l1("reboot-bootloader", cmd)) {
  339 + if (fb_set_reboot_flag()) {
  340 + fastboot_tx_write_str("FAILCannot set reboot flag");
  341 + return;
  342 + }
  343 + }
331 344 fastboot_func->in_req->complete = compl_do_reset;
332 345 fastboot_tx_write_str("OKAY");
333 346 }