mirror of
https://xff.cz/git/u-boot/
synced 2025-09-27 21:41:16 +02:00
usb: ums: wait for usb cable connection before enter ums mode
Before this change ums mode can not be entered when device was using the same usb port for usb/uart communication. Switching USB cable from UART to USB always causes ums exit. Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com>
This commit is contained in:
committed by
Marek Vasut
parent
7da7651251
commit
3603e31db5
@@ -42,6 +42,30 @@ int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag,
|
|||||||
|
|
||||||
g_dnl_register("ums");
|
g_dnl_register("ums");
|
||||||
|
|
||||||
|
/* Timeout unit: seconds */
|
||||||
|
int cable_ready_timeout = UMS_CABLE_READY_TIMEOUT;
|
||||||
|
|
||||||
|
if (!usb_cable_connected()) {
|
||||||
|
puts("Please connect USB cable.\n");
|
||||||
|
|
||||||
|
while (!usb_cable_connected()) {
|
||||||
|
if (ctrlc()) {
|
||||||
|
puts("\rCTRL+C - Operation aborted.\n");
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
if (!cable_ready_timeout) {
|
||||||
|
puts("\rUSB cable not detected.\n" \
|
||||||
|
"Command exit.\n");
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\rAuto exit in: %.2d s.", cable_ready_timeout);
|
||||||
|
mdelay(1000);
|
||||||
|
cable_ready_timeout--;
|
||||||
|
}
|
||||||
|
puts("\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
usb_gadget_handle_interrupts();
|
usb_gadget_handle_interrupts();
|
||||||
|
|
||||||
|
@@ -20,6 +20,9 @@
|
|||||||
#define UMS_NUM_SECTORS 0
|
#define UMS_NUM_SECTORS 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Wait at maximum 60 seconds for cable connection */
|
||||||
|
#define UMS_CABLE_READY_TIMEOUT 60
|
||||||
|
|
||||||
struct ums {
|
struct ums {
|
||||||
int (*read_sector)(struct ums *ums_dev,
|
int (*read_sector)(struct ums *ums_dev,
|
||||||
ulong start, lbaint_t blkcnt, void *buf);
|
ulong start, lbaint_t blkcnt, void *buf);
|
||||||
|
Reference in New Issue
Block a user