diff --git a/drivers/bus/mhi/core/mhi_boot.c b/drivers/bus/mhi/core/mhi_boot.c index 53de26ec464e..d5a90cb2ecb7 100644 --- a/drivers/bus/mhi/core/mhi_boot.c +++ b/drivers/bus/mhi/core/mhi_boot.c @@ -139,6 +139,31 @@ void mhi_dump_sfr(struct mhi_controller *mhi_cntrl) } EXPORT_SYMBOL(mhi_dump_sfr); +bool mhi_scan_rddm_cookie(struct mhi_controller *mhi_cntrl, u32 cookie) +{ + int ret; + u32 val; + + if (!mhi_cntrl->rddm_supported || !cookie) + return false; + + MHI_CNTRL_LOG("Checking BHI debug register for 0x%x\n", cookie); + + if (!MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state)) + return false; + + ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->bhi, BHI_ERRDBG2, &val); + if (ret) + return false; + + MHI_CNTRL_LOG("BHI_ERRDBG2 value:0x%x\n", val); + if (val == cookie) + return true; + + return false; +} +EXPORT_SYMBOL(mhi_scan_rddm_cookie); + /* setup rddm vector table for rddm transfer and program rxvec */ void mhi_rddm_prepare(struct mhi_controller *mhi_cntrl, struct image_info *img_info) diff --git a/include/linux/mhi.h b/include/linux/mhi.h index 84e4d5dcdafe..6e79d52d7050 100644 --- a/include/linux/mhi.h +++ b/include/linux/mhi.h @@ -797,6 +797,14 @@ int mhi_pm_fast_resume(struct mhi_controller *mhi_cntrl, bool notify_client); */ int mhi_download_rddm_img(struct mhi_controller *mhi_cntrl, bool in_panic); +/** + * mhi_scan_rddm_cookie - Look for supplied cookie value in the BHI debug + * registers set by device to indicate rddm readiness for debugging purposes. + * @mhi_cntrl: MHI controller + * @cookie: cookie/pattern value to match + */ +bool mhi_scan_rddm_cookie(struct mhi_controller *mhi_cntrl, u32 cookie); + /** * mhi_force_rddm_mode - Force external device into rddm mode * to collect device ramdump. This is useful if host driver assert