diff --git a/drivers/bus/mhi/core/mhi_init.c b/drivers/bus/mhi/core/mhi_init.c index 3df8868a305e..526d7fd140e8 100644 --- a/drivers/bus/mhi/core/mhi_init.c +++ b/drivers/bus/mhi/core/mhi_init.c @@ -1494,7 +1494,6 @@ static int of_parse_dt(struct mhi_controller *mhi_cntrl, int ret; enum mhi_ee i; u32 *ee; - u32 bhie_offset; /* parse MHI channel configuration */ ret = of_parse_ch_cfg(mhi_cntrl, of_node); @@ -1535,9 +1534,9 @@ static int of_parse_dt(struct mhi_controller *mhi_cntrl, of_property_read_u32_index(of_node, "mhi,ee", ret, ee); } - ret = of_property_read_u32(of_node, "mhi,bhie-offset", &bhie_offset); + ret = of_property_read_u32(of_node, "mhi,bhie-offset", &mhi_cntrl->bhie_offset); if (!ret) - mhi_cntrl->bhie = mhi_cntrl->regs + bhie_offset; + MHI_LOG("bhie-offset = 0x%x\n", mhi_cntrl->bhie_offset); of_property_read_string(of_node, "mhi,name", &mhi_cntrl->name); @@ -1776,7 +1775,6 @@ EXPORT_SYMBOL(mhi_alloc_controller); int mhi_prepare_for_power_up(struct mhi_controller *mhi_cntrl) { int ret; - u32 bhie_off; mutex_lock(&mhi_cntrl->pm_mutex); @@ -1798,24 +1796,24 @@ int mhi_prepare_for_power_up(struct mhi_controller *mhi_cntrl) * This controller supports rddm, we need to manually clear * BHIE RX registers since por values are undefined. */ - if (!mhi_cntrl->bhie) { + if (!mhi_cntrl->bhie_offset) { ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->regs, BHIEOFF, - &bhie_off); + &mhi_cntrl->bhie_offset); if (ret) { MHI_CNTRL_ERR("Error getting bhie offset\n"); goto bhie_error; } - if (bhie_off >= mhi_cntrl->len) { + if (mhi_cntrl->bhie_offset >= mhi_cntrl->len) { MHI_ERR("Invalid BHIE=0x%x len=0x%x\n", - bhie_off, mhi_cntrl->len); + mhi_cntrl->bhie_offset, mhi_cntrl->len); ret = -EINVAL; goto bhie_error; } - - mhi_cntrl->bhie = mhi_cntrl->regs + bhie_off; } + mhi_cntrl->bhie = mhi_cntrl->regs + mhi_cntrl->bhie_offset; + memset_io(mhi_cntrl->bhie + BHIE_RXVECADDR_LOW_OFFS, 0, BHIE_RXVECSTATUS_OFFS - BHIE_RXVECADDR_LOW_OFFS + 4); diff --git a/drivers/bus/mhi/core/mhi_pm.c b/drivers/bus/mhi/core/mhi_pm.c index 36ddf0be3b64..0fad46875bab 100644 --- a/drivers/bus/mhi/core/mhi_pm.c +++ b/drivers/bus/mhi/core/mhi_pm.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 @@ -984,24 +984,24 @@ int mhi_async_power_up(struct mhi_controller *mhi_cntrl) mhi_cntrl->bhi = mhi_cntrl->regs + val; /* setup bhie offset if not set */ - if (mhi_cntrl->fbc_download && !mhi_cntrl->bhie) { - ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->regs, BHIEOFF, &val); + if (mhi_cntrl->fbc_download && !mhi_cntrl->bhie_offset) { + ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->regs, BHIEOFF, + &mhi_cntrl->bhie_offset); if (ret) { write_unlock_irq(&mhi_cntrl->pm_lock); MHI_CNTRL_ERR("Error getting bhie offset\n"); goto error_bhi_offset; } - if (val >= mhi_cntrl->len) { + if (mhi_cntrl->bhie_offset >= mhi_cntrl->len) { ret = -ENODEV; write_unlock_irq(&mhi_cntrl->pm_lock); - MHI_ERR("Invalid bhie offset:%x\n", val); + MHI_ERR("Invalid bhie offset:%x\n", mhi_cntrl->bhie_offset); goto error_bhi_offset; } - - mhi_cntrl->bhie = mhi_cntrl->regs + val; } + mhi_cntrl->bhie = mhi_cntrl->regs + mhi_cntrl->bhie_offset; mhi_cntrl->write_reg(mhi_cntrl, mhi_cntrl->bhi, BHI_INTVEC, 0); mhi_cntrl->power_down = false; mhi_cntrl->pm_state = MHI_PM_POR; diff --git a/include/linux/mhi.h b/include/linux/mhi.h index 1988d2ea1fd4..9e96d615dfd5 100644 --- a/include/linux/mhi.h +++ b/include/linux/mhi.h @@ -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. */ #ifndef _MHI_H_ #define _MHI_H_ @@ -305,6 +305,7 @@ struct mhi_controller { size_t seg_len; u32 session_id; u32 sequence_id; + u32 bhie_offset; bool img_pre_alloc; struct image_info *fbc_image;