mirror of
https://github.com/Fishwaldo/build.git
synced 2025-03-31 11:11:49 +00:00
146 lines
4.6 KiB
Diff
146 lines
4.6 KiB
Diff
From 7ffd3d083ac59f2b40ebea5b10334c541a5c6311 Mon Sep 17 00:00:00 2001
|
|
From: jamess_huang <Jamess_Huang@asus.com>
|
|
Date: Thu, 22 Feb 2018 15:28:45 +0800
|
|
Subject: [PATCH 49/50] added timeout when force entering UMS mode
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Change-Id: I971d105a86628fa4282d1d801e05fabebf0b6569
|
|
Reviewed-on: https://tp-biosrd-v02/gerrit/82232
|
|
Reviewed-by: Jamess Huang(黃以民) <Jamess_Huang@asus.com>
|
|
Tested-by: Jamess Huang(黃以民) <Jamess_Huang@asus.com>
|
|
---
|
|
arch/arm/mach-rockchip/rk3288-board.c | 4 +++-
|
|
cmd/usb_mass_storage.c | 4 ++++
|
|
common/autoboot.c | 8 ++++++--
|
|
drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c | 1 +
|
|
drivers/usb/gadget/f_mass_storage.c | 10 +++++++++-
|
|
include/linux/usb/gadget.h | 3 +++
|
|
6 files changed, 26 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/arch/arm/mach-rockchip/rk3288-board.c b/arch/arm/mach-rockchip/rk3288-board.c
|
|
index f73520925b..1e40429af9 100644
|
|
--- a/arch/arm/mach-rockchip/rk3288-board.c
|
|
+++ b/arch/arm/mach-rockchip/rk3288-board.c
|
|
@@ -101,6 +101,7 @@ void usb_current_limit_ctrl(bool unlock_current)
|
|
{
|
|
int tmp;
|
|
|
|
+ printf("%s: unlock_current = %d\n", __func__, unlock_current);
|
|
tmp = readl(RKIO_GPIO6_PHYS + GPIO_SWPORT_DR);
|
|
if(unlock_current == true)
|
|
writel(tmp | 0x40, RKIO_GPIO6_PHYS + GPIO_SWPORT_DR);
|
|
@@ -120,6 +121,7 @@ void rk3288_maskrom_ctrl(bool enable_emmc)
|
|
{
|
|
int tmp;
|
|
|
|
+ printf("%s: enable_emmc = %d\n", __func__, enable_emmc);
|
|
tmp = readl(RKIO_GPIO6_PHYS + GPIO_SWPORT_DR);
|
|
if(enable_emmc == true)
|
|
writel(tmp | 0x80, RKIO_GPIO6_PHYS + GPIO_SWPORT_DR);
|
|
diff --git a/cmd/usb_mass_storage.c b/cmd/usb_mass_storage.c
|
|
index 4c3da13115..806b2e3dc0 100644
|
|
--- a/cmd/usb_mass_storage.c
|
|
+++ b/cmd/usb_mass_storage.c
|
|
@@ -215,6 +215,10 @@ int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag,
|
|
usb_gadget_handle_interrupts(controller_index);
|
|
|
|
rc = fsg_main_thread(NULL);
|
|
+
|
|
+ if (rc == -ETIMEDOUT) {
|
|
+ goto cleanup_register;
|
|
+ }
|
|
if (rc) {
|
|
/* Check I/O error */
|
|
if (rc == -EIO)
|
|
diff --git a/common/autoboot.c b/common/autoboot.c
|
|
index d63a4d7e79..81b6579f7c 100644
|
|
--- a/common/autoboot.c
|
|
+++ b/common/autoboot.c
|
|
@@ -29,6 +29,7 @@ DECLARE_GLOBAL_DATA_PTR;
|
|
static int stored_bootdelay;
|
|
|
|
bool force_ums = false;
|
|
+bool getdescriptor = false;
|
|
|
|
#if defined(CONFIG_AUTOBOOT_KEYED)
|
|
#if defined(CONFIG_AUTOBOOT_STOP_STR_SHA256)
|
|
@@ -356,8 +357,11 @@ void autoboot_command(const char *s)
|
|
local_args[1]=str2;
|
|
local_args[2]=str3;
|
|
local_args[3]=str4;
|
|
- do_usb_mass_storage(NULL, 0, 4, local_args);
|
|
- return;
|
|
+
|
|
+ if (do_usb_mass_storage(NULL, 0, 4, local_args) == -ETIMEDOUT) {
|
|
+ rk3288_maskrom_ctrl(false);
|
|
+ usb_current_limit_ctrl(false);
|
|
+ }
|
|
}
|
|
|
|
if (stored_bootdelay != -1 && s && !abortboot(stored_bootdelay)) {
|
|
diff --git a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
|
|
index 0d6d2fba8a..b9277b8b0a 100644
|
|
--- a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
|
|
+++ b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
|
|
@@ -1368,6 +1368,7 @@ static void dwc2_ep0_setup(struct dwc2_udc *dev)
|
|
debug_cond(DEBUG_SETUP != 0,
|
|
"%s: *** USB_REQ_GET_DESCRIPTOR\n",
|
|
__func__);
|
|
+ getdescriptor = true;
|
|
break;
|
|
|
|
case USB_REQ_SET_INTERFACE:
|
|
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
|
|
index 1ecb92ac6b..aad8fa4951 100644
|
|
--- a/drivers/usb/gadget/f_mass_storage.c
|
|
+++ b/drivers/usb/gadget/f_mass_storage.c
|
|
@@ -666,7 +666,7 @@ static void busy_indicator(void)
|
|
static int sleep_thread(struct fsg_common *common)
|
|
{
|
|
int rc = 0;
|
|
- int i = 0, k = 0;
|
|
+ int i = 0, k = 0, j = 0;
|
|
|
|
/* Wait until a signal arrives or we are woken up */
|
|
for (;;) {
|
|
@@ -677,6 +677,7 @@ static int sleep_thread(struct fsg_common *common)
|
|
busy_indicator();
|
|
i = 0;
|
|
k++;
|
|
+ j++;
|
|
}
|
|
|
|
if (k == 10) {
|
|
@@ -691,6 +692,13 @@ static int sleep_thread(struct fsg_common *common)
|
|
k = 0;
|
|
}
|
|
|
|
+ if (j == 300) { //about 3 seconds
|
|
+ if(force_ums && !getdescriptor) {
|
|
+ printf("wait for usb get descriptor cmd timeout\n");
|
|
+ return -ETIMEDOUT;
|
|
+ }
|
|
+ }
|
|
+
|
|
usb_gadget_handle_interrupts(0);
|
|
}
|
|
common->thread_wakeup_needed = 0;
|
|
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
|
|
index b824f13477..305cc56b04 100644
|
|
--- a/include/linux/usb/gadget.h
|
|
+++ b/include/linux/usb/gadget.h
|
|
@@ -24,6 +24,9 @@
|
|
|
|
struct usb_ep;
|
|
|
|
+extern bool force_ums;
|
|
+extern bool getdescriptor;
|
|
+
|
|
/**
|
|
* struct usb_request - describes one i/o request
|
|
* @buf: Buffer used for data. Always provide this; some controllers
|
|
--
|
|
2.17.1
|
|
|