Commit 48f892dc7370a23882239be06b4ec2ce60273e57
Exists in
v2017.01-smarct4x
and in
37 other branches
Merge git://git.denx.de/u-boot-usb
Showing 8 changed files Side-by-side Diff
common/cmd_dfu.c
... | ... | @@ -15,6 +15,8 @@ |
15 | 15 | |
16 | 16 | static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
17 | 17 | { |
18 | + bool dfu_reset = false; | |
19 | + | |
18 | 20 | if (argc < 4) |
19 | 21 | return CMD_RET_USAGE; |
20 | 22 | |
21 | 23 | |
22 | 24 | |
23 | 25 | |
24 | 26 | |
... | ... | @@ -36,17 +38,28 @@ |
36 | 38 | |
37 | 39 | int controller_index = simple_strtoul(usb_controller, NULL, 0); |
38 | 40 | board_usb_init(controller_index, USB_INIT_DEVICE); |
39 | - | |
41 | + dfu_clear_detach(); | |
40 | 42 | g_dnl_register("usb_dnl_dfu"); |
41 | 43 | while (1) { |
42 | - if (dfu_reset()) | |
44 | + if (dfu_detach()) { | |
43 | 45 | /* |
46 | + * Check if USB bus reset is performed after detach, | |
47 | + * which indicates that -R switch has been passed to | |
48 | + * dfu-util. In this case reboot the device | |
49 | + */ | |
50 | + if (dfu_usb_get_reset()) { | |
51 | + dfu_reset = true; | |
52 | + goto exit; | |
53 | + } | |
54 | + | |
55 | + /* | |
44 | 56 | * This extra number of usb_gadget_handle_interrupts() |
45 | 57 | * calls is necessary to assure correct transmission |
46 | 58 | * completion with dfu-util |
47 | 59 | */ |
48 | - if (++i == 10) | |
60 | + if (++i == 10000) | |
49 | 61 | goto exit; |
62 | + } | |
50 | 63 | |
51 | 64 | if (ctrlc()) |
52 | 65 | goto exit; |
53 | 66 | |
... | ... | @@ -58,8 +71,10 @@ |
58 | 71 | done: |
59 | 72 | dfu_free_entities(); |
60 | 73 | |
61 | - if (dfu_reset()) | |
74 | + if (dfu_reset) | |
62 | 75 | run_command("reset", 0); |
76 | + | |
77 | + dfu_clear_detach(); | |
63 | 78 | |
64 | 79 | return ret; |
65 | 80 | } |
drivers/dfu/dfu.c
... | ... | @@ -17,20 +17,41 @@ |
17 | 17 | #include <linux/list.h> |
18 | 18 | #include <linux/compiler.h> |
19 | 19 | |
20 | -static bool dfu_reset_request; | |
20 | +static bool dfu_detach_request; | |
21 | 21 | static LIST_HEAD(dfu_list); |
22 | 22 | static int dfu_alt_num; |
23 | 23 | static int alt_num_cnt; |
24 | 24 | static struct hash_algo *dfu_hash_algo; |
25 | 25 | |
26 | -bool dfu_reset(void) | |
26 | +/* | |
27 | + * The purpose of the dfu_usb_get_reset() function is to | |
28 | + * provide information if after USB_DETACH request | |
29 | + * being sent the dfu-util performed reset of USB | |
30 | + * bus. | |
31 | + * | |
32 | + * Described behaviour is the only way to distinct if | |
33 | + * user has typed -e (detach) or -R (reset) when invoking | |
34 | + * dfu-util command. | |
35 | + * | |
36 | + */ | |
37 | +__weak bool dfu_usb_get_reset(void) | |
27 | 38 | { |
28 | - return dfu_reset_request; | |
39 | + return true; | |
29 | 40 | } |
30 | 41 | |
31 | -void dfu_trigger_reset() | |
42 | +bool dfu_detach(void) | |
32 | 43 | { |
33 | - dfu_reset_request = true; | |
44 | + return dfu_detach_request; | |
45 | +} | |
46 | + | |
47 | +void dfu_trigger_detach(void) | |
48 | +{ | |
49 | + dfu_detach_request = true; | |
50 | +} | |
51 | + | |
52 | +void dfu_clear_detach(void) | |
53 | +{ | |
54 | + dfu_detach_request = false; | |
34 | 55 | } |
35 | 56 | |
36 | 57 | static int dfu_find_alt_num(const char *s) |
drivers/usb/gadget/atmel_usba_udc.c
... | ... | @@ -171,7 +171,7 @@ |
171 | 171 | { |
172 | 172 | struct usba_ep *ep = to_usba_ep(_ep); |
173 | 173 | struct usba_udc *udc = ep->udc; |
174 | - unsigned long flags, ept_cfg, maxpacket; | |
174 | + unsigned long flags = 0, ept_cfg, maxpacket; | |
175 | 175 | unsigned int nr_trans; |
176 | 176 | |
177 | 177 | DBG(DBG_GADGET, "%s: ep_enable: desc=%p\n", ep->ep.name, desc); |
... | ... | @@ -274,7 +274,7 @@ |
274 | 274 | struct usba_ep *ep = to_usba_ep(_ep); |
275 | 275 | struct usba_udc *udc = ep->udc; |
276 | 276 | LIST_HEAD(req_list); |
277 | - unsigned long flags; | |
277 | + unsigned long flags = 0; | |
278 | 278 | |
279 | 279 | DBG(DBG_GADGET, "ep_disable: %s\n", ep->ep.name); |
280 | 280 | |
... | ... | @@ -339,7 +339,7 @@ |
339 | 339 | struct usba_request *req = to_usba_req(_req); |
340 | 340 | struct usba_ep *ep = to_usba_ep(_ep); |
341 | 341 | struct usba_udc *udc = ep->udc; |
342 | - unsigned long flags; | |
342 | + unsigned long flags = 0; | |
343 | 343 | int ret; |
344 | 344 | |
345 | 345 | DBG(DBG_GADGET | DBG_QUEUE | DBG_REQ, "%s: queue req %p, len %u\n", |
... | ... | @@ -401,7 +401,7 @@ |
401 | 401 | static int usba_ep_set_halt(struct usb_ep *_ep, int value) |
402 | 402 | { |
403 | 403 | struct usba_ep *ep = to_usba_ep(_ep); |
404 | - unsigned long flags; | |
404 | + unsigned long flags = 0; | |
405 | 405 | int ret = 0; |
406 | 406 | |
407 | 407 | DBG(DBG_GADGET, "endpoint %s: %s HALT\n", ep->ep.name, |
... | ... | @@ -480,7 +480,7 @@ |
480 | 480 | static int usba_udc_wakeup(struct usb_gadget *gadget) |
481 | 481 | { |
482 | 482 | struct usba_udc *udc = to_usba_udc(gadget); |
483 | - unsigned long flags; | |
483 | + unsigned long flags = 0; | |
484 | 484 | u32 ctrl; |
485 | 485 | int ret = -EINVAL; |
486 | 486 | |
... | ... | @@ -499,7 +499,7 @@ |
499 | 499 | usba_udc_set_selfpowered(struct usb_gadget *gadget, int is_selfpowered) |
500 | 500 | { |
501 | 501 | struct usba_udc *udc = to_usba_udc(gadget); |
502 | - unsigned long flags; | |
502 | + unsigned long flags = 0; | |
503 | 503 | |
504 | 504 | spin_lock_irqsave(&udc->lock, flags); |
505 | 505 | if (is_selfpowered) |
drivers/usb/gadget/ci_udc.c
drivers/usb/gadget/f_dfu.c
drivers/usb/gadget/s3c_udc_otg.c
... | ... | @@ -149,6 +149,11 @@ |
149 | 149 | struct s3c_usbotg_phy *phy; |
150 | 150 | static unsigned int usb_phy_ctrl; |
151 | 151 | |
152 | +bool dfu_usb_get_reset(void) | |
153 | +{ | |
154 | + return !!(readl(®->gintsts) & INT_RESET); | |
155 | +} | |
156 | + | |
152 | 157 | void otg_phy_init(struct s3c_udc *dev) |
153 | 158 | { |
154 | 159 | dev->pdata->phy_control(1); |
... | ... | @@ -283,7 +288,7 @@ |
283 | 288 | { |
284 | 289 | struct s3c_udc *dev = the_controller; |
285 | 290 | int retval = 0; |
286 | - unsigned long flags; | |
291 | + unsigned long flags = 0; | |
287 | 292 | |
288 | 293 | debug_cond(DEBUG_SETUP != 0, "%s: %s\n", __func__, "no name"); |
289 | 294 | |
... | ... | @@ -331,7 +336,7 @@ |
331 | 336 | int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) |
332 | 337 | { |
333 | 338 | struct s3c_udc *dev = the_controller; |
334 | - unsigned long flags; | |
339 | + unsigned long flags = 0; | |
335 | 340 | |
336 | 341 | if (!dev) |
337 | 342 | return -ENODEV; |
... | ... | @@ -575,7 +580,7 @@ |
575 | 580 | { |
576 | 581 | struct s3c_ep *ep; |
577 | 582 | struct s3c_udc *dev; |
578 | - unsigned long flags; | |
583 | + unsigned long flags = 0; | |
579 | 584 | |
580 | 585 | debug("%s: %p\n", __func__, _ep); |
581 | 586 | |
... | ... | @@ -639,7 +644,7 @@ |
639 | 644 | static int s3c_ep_disable(struct usb_ep *_ep) |
640 | 645 | { |
641 | 646 | struct s3c_ep *ep; |
642 | - unsigned long flags; | |
647 | + unsigned long flags = 0; | |
643 | 648 | |
644 | 649 | debug("%s: %p\n", __func__, _ep); |
645 | 650 | |
... | ... | @@ -697,7 +702,7 @@ |
697 | 702 | { |
698 | 703 | struct s3c_ep *ep; |
699 | 704 | struct s3c_request *req; |
700 | - unsigned long flags; | |
705 | + unsigned long flags = 0; | |
701 | 706 | |
702 | 707 | debug("%s: %p\n", __func__, _ep); |
703 | 708 |
drivers/usb/gadget/s3c_udc_otg_xfer_dma.c
... | ... | @@ -466,7 +466,7 @@ |
466 | 466 | struct s3c_udc *dev = _dev; |
467 | 467 | u32 intr_status; |
468 | 468 | u32 usb_status, gintmsk; |
469 | - unsigned long flags; | |
469 | + unsigned long flags = 0; | |
470 | 470 | |
471 | 471 | spin_lock_irqsave(&dev->lock, flags); |
472 | 472 | |
... | ... | @@ -585,7 +585,7 @@ |
585 | 585 | struct s3c_request *req; |
586 | 586 | struct s3c_ep *ep; |
587 | 587 | struct s3c_udc *dev; |
588 | - unsigned long flags; | |
588 | + unsigned long flags = 0; | |
589 | 589 | u32 ep_num, gintsts; |
590 | 590 | |
591 | 591 | req = container_of(_req, struct s3c_request, req); |
... | ... | @@ -1033,7 +1033,7 @@ |
1033 | 1033 | { |
1034 | 1034 | struct s3c_ep *ep; |
1035 | 1035 | struct s3c_udc *dev; |
1036 | - unsigned long flags; | |
1036 | + unsigned long flags = 0; | |
1037 | 1037 | u8 ep_num; |
1038 | 1038 | |
1039 | 1039 | ep = container_of(_ep, struct s3c_ep, ep); |
include/dfu.h
... | ... | @@ -150,11 +150,14 @@ |
150 | 150 | char *dfu_extract_token(char** e, int *n); |
151 | 151 | void dfu_trigger_reset(void); |
152 | 152 | int dfu_get_alt(char *name); |
153 | -bool dfu_reset(void); | |
153 | +bool dfu_detach(void); | |
154 | +void dfu_trigger_detach(void); | |
155 | +void dfu_clear_detach(void); | |
154 | 156 | int dfu_init_env_entities(char *interface, char *devstr); |
155 | 157 | unsigned char *dfu_get_buf(struct dfu_entity *dfu); |
156 | 158 | unsigned char *dfu_free_buf(void); |
157 | 159 | unsigned long dfu_get_buf_size(void); |
160 | +bool dfu_usb_get_reset(void); | |
158 | 161 | |
159 | 162 | int dfu_read(struct dfu_entity *de, void *buf, int size, int blk_seq_num); |
160 | 163 | int dfu_write(struct dfu_entity *de, void *buf, int size, int blk_seq_num); |