diff options
Diffstat (limited to 'drivers/usb/gadget/f_fastboot.c')
-rw-r--r-- | drivers/usb/gadget/f_fastboot.c | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index b7ceff6699..79ddb689a0 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -313,7 +313,7 @@ static struct usb_gadget_strings *fastboot_strings[] = { #define MAX_PTN 32 struct fastboot_ptentry g_ptable[MAX_PTN]; unsigned int g_pcount; -struct fastboot_device_info fastboot_devinfo; +struct fastboot_device_info fastboot_devinfo = {0xff, 0xff}; enum { @@ -1249,20 +1249,24 @@ static void parameters_setup(void) CONFIG_FASTBOOT_BUF_SIZE; } -static int _fastboot_setup_dev(void) +static int _fastboot_setup_dev(int *switched) { char *fastboot_env; + struct fastboot_device_info devinfo;; + fastboot_env = getenv("fastboot_dev"); if (fastboot_env) { if (!strcmp(fastboot_env, "sata")) { - fastboot_devinfo.type = DEV_SATA; - fastboot_devinfo.dev_id = 0; + devinfo.type = DEV_SATA; + devinfo.dev_id = 0; #if defined(CONFIG_FASTBOOT_STORAGE_MMC) } else if (!strncmp(fastboot_env, "mmc", 3)) { - fastboot_devinfo.type = DEV_MMC; - fastboot_devinfo.dev_id = mmc_get_env_dev(); + devinfo.type = DEV_MMC; + devinfo.dev_id = mmc_get_env_dev(); #endif + } else { + return 1; } } else { return 1; @@ -1274,6 +1278,16 @@ static int _fastboot_setup_dev(void) fastboot_firmwareinfo.type = ANDROID_MCU_FRIMWARE_DEV_TYPE; #endif + if (switched) { + if (devinfo.type != fastboot_devinfo.type || devinfo.dev_id != fastboot_devinfo.dev_id) + *switched = 1; + else + *switched = 0; + } + + fastboot_devinfo.type = devinfo.type; + fastboot_devinfo.dev_id = devinfo.dev_id; + return 0; } @@ -1369,6 +1383,9 @@ static int _fastboot_parts_load_from_ptable(void) printf("flash target is MMC:%d\n", mmc_no); mmc = find_mmc_device(mmc_no); + + /* Force to init mmc */ + mmc->has_init = 0; if (mmc && mmc_init(mmc)) printf("MMC card init failed!\n"); @@ -1738,6 +1755,7 @@ fail: void fastboot_setup(void) { + int sw, ret; #ifdef CONFIG_USB_GADGET struct tag_serialnr serialnr; char serial[17]; @@ -1750,11 +1768,11 @@ void fastboot_setup(void) board_fastboot_setup(); /*get the fastboot dev*/ - _fastboot_setup_dev(); - + ret = _fastboot_setup_dev(&sw); /*load partitions information for the fastboot dev*/ - _fastboot_load_partitions(); + if (!ret && sw) + _fastboot_load_partitions(); parameters_setup(); #ifdef CONFIG_AVB_SUPPORT |