From 0e5a6b80ffa6017696ac3e0a8a9f6c68e2dddbab Mon Sep 17 00:00:00 2001 From: Bhaumik Bhatt Date: Thu, 30 Jul 2020 10:27:59 -0700 Subject: [PATCH] mhi: core: Check for RDDM cookie set by device to indicate readiness If the device is unable to send the mission mode execution environment change event but has already entered mission mode with the ability to allow ramdump collection, it can set a unique cookie pattern to indicate the availability of ramdumps. Allow the controller to query for this unique pattern upon any bootup failure or timeout. Change-Id: Id1f58b75d3f22e9e21b142cbea74d61cc65615b4 Signed-off-by: Bhaumik Bhatt --- drivers/bus/mhi/core/mhi_boot.c | 25 +++++++++++++++++++++++++ include/linux/mhi.h | 8 ++++++++ 2 files changed, 33 insertions(+) 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