From: Rajkumar Ayyasamy <quic_arajkuma@xxxxxxxxxxx> 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. Signed-off-by: Rajkumar Ayyasamy <quic_arajkuma@xxxxxxxxxxx> Signed-off-by: Gokul Sriram Palanisamy <quic_gokulsri@xxxxxxxxxxx> --- drivers/bus/mhi/host/main.c | 44 +++++++++++++++++++++++++++++++++++++ include/linux/mhi.h | 8 +++++++ 2 files changed, 52 insertions(+) diff --git a/drivers/bus/mhi/host/main.c b/drivers/bus/mhi/host/main.c index 26baa04badf4..de804a701b85 100644 --- a/drivers/bus/mhi/host/main.c +++ b/drivers/bus/mhi/host/main.c @@ -1772,3 +1772,47 @@ void mhi_debug_reg_dump(struct mhi_controller *mhi_cntrl) } } EXPORT_SYMBOL_GPL(mhi_debug_reg_dump); + +bool mhi_scan_rddm_cookie(struct mhi_controller *mhi_cntrl, u32 cookie) +{ + struct device *dev = &mhi_cntrl->mhi_dev->dev; + int ret; + int i; + u32 val; + bool result = false; + struct { + char *name; + u32 offset; + } error_reg[] = { + { "ERROR_DBG1", BHI_ERRDBG1 }, + { "ERROR_DBG2", BHI_ERRDBG2 }, + { "ERROR_DBG3", BHI_ERRDBG3 }, + { NULL }, + }; + + if (!mhi_cntrl->rddm_size || !cookie) + return false; + + dev_dbg(dev, "Checking BHI debug register for 0x%x\n", cookie); + + if (!MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state)) + return false; + + /* look for an RDDM cookie match in any of the error debug registers */ + for (i = 0; error_reg[i].name; i++) { + ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->bhi, + error_reg[i].offset, &val); + if (ret) + break; + dev_dbg(dev, "reg:%s value:0x%x\n", error_reg[i].name, val); + + if (!(val ^ cookie)) { + dev_err(dev, "RDDM cookie found in %s\n", + error_reg[i].name); + return true; + } + } + dev_dbg(dev, "RDDM cookie not found\n"); + return result; +} +EXPORT_SYMBOL_GPL(mhi_scan_rddm_cookie); diff --git a/include/linux/mhi.h b/include/linux/mhi.h index c0c9bfc28e4a..2f90de8616f3 100644 --- a/include/linux/mhi.h +++ b/include/linux/mhi.h @@ -839,4 +839,12 @@ int mhi_get_channel_doorbell_offset(struct mhi_controller *mhi_cntrl, u32 *chdb_ * @mhi_cntrl: MHI controller */ void mhi_debug_reg_dump(struct mhi_controller *mhi_cntrl); + +/** + * 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); #endif /* _MHI_H_ */ -- 2.34.1