diff --git a/drivers/bus/mhi/core/mhi_main.c b/drivers/bus/mhi/core/mhi_main.c index 2315552b831b..0ddbbeec7b8d 100644 --- a/drivers/bus/mhi/core/mhi_main.c +++ b/drivers/bus/mhi/core/mhi_main.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved. */ +/* Copyright (c) 2018-2021, The Linux Foundation. All rights reserved. */ #include #include @@ -266,6 +266,19 @@ enum mhi_dev_state mhi_get_mhi_state(struct mhi_controller *mhi_cntrl) } EXPORT_SYMBOL(mhi_get_mhi_state); +void mhi_soc_reset(struct mhi_controller *mhi_cntrl) +{ + if (mhi_cntrl->reset) { + mhi_cntrl->reset(mhi_cntrl); + return; + } + + /* Generic MHI SoC reset */ + mhi_write_reg(mhi_cntrl, mhi_cntrl->regs, MHI_SOC_RESET_REQ_OFFSET, + MHI_SOC_RESET_REQ); +} +EXPORT_SYMBOL(mhi_soc_reset); + int mhi_queue_sclist(struct mhi_device *mhi_dev, struct mhi_chan *mhi_chan, void *buf, diff --git a/include/linux/mhi.h b/include/linux/mhi.h index 9e96d615dfd5..d4dc08370cf0 100644 --- a/include/linux/mhi.h +++ b/include/linux/mhi.h @@ -258,6 +258,7 @@ struct reg_write_info { * @time_get: Return host time in us * @lpm_disable: Request controller to disable link level low power modes * @lpm_enable: Controller may enable link level low power modes again + * @reset: Controller specific reset function (optional) * @priv_data: Points to bus master's private data */ struct mhi_controller { @@ -390,6 +391,7 @@ struct mhi_controller { struct mhi_link_info *link_info); void (*write_reg)(struct mhi_controller *mhi_cntrl, void __iomem *base, u32 offset, u32 val); + void (*reset)(struct mhi_controller *mhi_cntrl); /* channel to control DTR messaging */ struct mhi_device *dtr_dev; @@ -887,6 +889,13 @@ enum mhi_ee mhi_get_exec_env(struct mhi_controller *mhi_cntrl); */ enum mhi_dev_state mhi_get_mhi_state(struct mhi_controller *mhi_cntrl); +/** + * mhi_soc_reset - Trigger a device reset. This can be used as a last resort + * to reset and recover a device. + * @mhi_cntrl: MHI controller + */ +void mhi_soc_reset(struct mhi_controller *mhi_cntrl); + /** * mhi_set_mhi_state - Set device state * @mhi_cntrl: MHI controller