From 4183caa916c3f7c3005837b896655745adf0c703 Mon Sep 17 00:00:00 2001 From: "faqiang.zhu" Date: Wed, 26 Sep 2018 16:24:36 +0800 Subject: MA-12283-4 remove the limitation of lock when use uuu For imx8 chips, if boot from usb, lock status will be ignored for the convenience of using uuu. For imx6 and imx7, the presistdata partition is ignored, so unlock operation can alway succeed. Change-Id: I842bab9fd2c04f8a864f4a134b63efc4436f71a4 Signed-off-by: faqiang.zhu (cherry picked from commit bea54d4fbee5871187d80b67a5ace10577714f1e) --- drivers/usb/gadget/f_fastboot.c | 31 +++++++++++++++++-------------- drivers/usb/gadget/fastboot_lock_unlock.c | 7 +++++++ 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index e1e027be1c..a9e92d4225 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -3426,21 +3426,24 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req) fb_response_str = response; #ifdef CONFIG_FASTBOOT_LOCK - int status; - status = fastboot_get_lock_stat(); - - if (status == FASTBOOT_LOCK) { - pr_err("device is LOCKed!\n"); - strcpy(response, "FAIL device is locked."); - fastboot_tx_write_str(response); - return; + /* for imx8 boot from USB, lock status can be ignored for uuu.*/ + if (!(is_imx8() || is_imx8m()) || !(is_boot_from_usb())) { + int status; + status = fastboot_get_lock_stat(); + + if (status == FASTBOOT_LOCK) { + pr_err("device is LOCKed!\n"); + strcpy(response, "FAIL device is locked."); + fastboot_tx_write_str(response); + return; - } else if (status == FASTBOOT_LOCK_ERROR) { - pr_err("write lock status into device!\n"); - fastboot_set_lock_stat(FASTBOOT_LOCK); - strcpy(response, "FAILdevice is locked."); - fastboot_tx_write_str(response); - return; + } else if (status == FASTBOOT_LOCK_ERROR) { + pr_err("write lock status into device!\n"); + fastboot_set_lock_stat(FASTBOOT_LOCK); + strcpy(response, "FAILdevice is locked."); + fastboot_tx_write_str(response); + return; + } } #endif fastboot_fail("no flash device defined"); diff --git a/drivers/usb/gadget/fastboot_lock_unlock.c b/drivers/usb/gadget/fastboot_lock_unlock.c index 307d927cdd..b575a78eef 100644 --- a/drivers/usb/gadget/fastboot_lock_unlock.c +++ b/drivers/usb/gadget/fastboot_lock_unlock.c @@ -38,6 +38,7 @@ #include "fastboot_lock_unlock.h" #include #include +#include #ifdef CONFIG_IMX_TRUSTY_OS #include #include @@ -476,6 +477,12 @@ FbLockEnableResult fastboot_lock_enable() { int mmc_id; FbLockEnableResult ret; + /* for imx6 and imx7 platforms, ignore presistdata partition + * for the convenience of using uuu + */ + if (is_mx6() || is_mx7() || is_mx7ulp()) + return FASTBOOT_UL_ENABLE; + bdata = (unsigned char *)memalign(ALIGN_BYTES, SECTOR_SIZE); if (bdata == NULL) return FASTBOOT_UL_ERROR; -- cgit v1.2.3