]> git.sur5r.net Git - u-boot/blobdiff - drivers/usb/gadget/f_fastboot.c
usb: Fastboot function config for better consistency with other functions
[u-boot] / drivers / usb / gadget / f_fastboot.c
index fd9fc8af6ec153347b5491b23f955d69cfea45b8..206b6d17aea610ccb8ef0b8cec6c66ed241b2d4d 100644 (file)
@@ -123,6 +123,7 @@ static struct usb_gadget_strings *fastboot_strings[] = {
 };
 
 static void rx_handler_command(struct usb_ep *ep, struct usb_request *req);
+static int strcmp_l1(const char *s1, const char *s2);
 
 static void fastboot_complete(struct usb_ep *ep, struct usb_request *req)
 {
@@ -137,6 +138,7 @@ static int fastboot_bind(struct usb_configuration *c, struct usb_function *f)
        int id;
        struct usb_gadget *gadget = c->cdev->gadget;
        struct f_fastboot *f_fb = func_to_fastboot(f);
+       const char *s;
 
        /* DYNAMIC interface numbers assignments */
        id = usb_interface_id(c, f);
@@ -162,6 +164,10 @@ static int fastboot_bind(struct usb_configuration *c, struct usb_function *f)
 
        hs_ep_out.bEndpointAddress = fs_ep_out.bEndpointAddress;
 
+       s = getenv("serial#");
+       if (s)
+               g_dnl_set_serialnumber((char *)s);
+
        return 0;
 }
 
@@ -321,8 +327,20 @@ static void compl_do_reset(struct usb_ep *ep, struct usb_request *req)
        do_reset(NULL, 0, 0, NULL);
 }
 
+int __weak fb_set_reboot_flag(void)
+{
+       return -ENOSYS;
+}
+
 static void cb_reboot(struct usb_ep *ep, struct usb_request *req)
 {
+       char *cmd = req->buf;
+       if (!strcmp_l1("reboot-bootloader", cmd)) {
+               if (fb_set_reboot_flag()) {
+                       fastboot_tx_write_str("FAILCannot set reboot flag");
+                       return;
+               }
+       }
        fastboot_func->in_req->complete = compl_do_reset;
        fastboot_tx_write_str("OKAY");
 }