Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit efe0d604 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "mhi: core: get bhie offset from devicetree node"

parents 8fa5b27a aad82aa0
Loading
Loading
Loading
Loading
+32 −8
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ const char * const mhi_ee_str[MHI_EE_MAX] = {
	[MHI_EE_PTHRU] = "PASS THRU",
	[MHI_EE_EDL] = "EDL",
	[MHI_EE_DISABLE_TRANSITION] = "DISABLE",
	[MHI_EE_NOT_SUPPORTED] = "NOT SUPPORTED",
};

const char * const mhi_state_tran_str[MHI_ST_TRANSITION_MAX] = {
@@ -1148,6 +1149,9 @@ static int of_parse_dt(struct mhi_controller *mhi_cntrl,
		       struct device_node *of_node)
{
	int ret;
	enum mhi_ee i;
	u32 *ee;
	u32 bhie_offset;

	/* parse MHI channel configuration */
	ret = of_parse_ch_cfg(mhi_cntrl, of_node);
@@ -1175,6 +1179,23 @@ static int of_parse_dt(struct mhi_controller *mhi_cntrl,
	if (of_property_read_bool(of_node, "mhi,m2-no-db-access"))
		mhi_cntrl->db_access &= ~MHI_PM_M2;

	/* parse the device ee table */
	for (i = MHI_EE_PBL, ee = mhi_cntrl->ee_table; i < MHI_EE_MAX;
	     i++, ee++) {
		/* setup the default ee before checking for override */
		*ee = i;
		ret = of_property_match_string(of_node, "mhi,ee-names",
					       mhi_ee_str[i]);
		if (ret < 0)
			continue;

		of_property_read_u32_index(of_node, "mhi,ee", ret, ee);
	}

	ret = of_property_read_u32(of_node, "mhi,bhie-offset", &bhie_offset);
	if (!ret)
		mhi_cntrl->bhie = mhi_cntrl->regs + bhie_offset;

	return 0;

error_ev_cfg:
@@ -1389,6 +1410,7 @@ 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) {
			ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->regs, BHIEOFF,
					   &bhie_off);
			if (ret) {
@@ -1396,9 +1418,11 @@ int mhi_prepare_for_power_up(struct mhi_controller *mhi_cntrl)
				goto bhie_error;
			}

		memset_io(mhi_cntrl->regs + bhie_off + BHIE_RXVECADDR_LOW_OFFS,
			  0, BHIE_RXVECSTATUS_OFFS - BHIE_RXVECADDR_LOW_OFFS +
			  4);
			mhi_cntrl->bhie = mhi_cntrl->regs + bhie_off;
		}

		memset_io(mhi_cntrl->bhie + BHIE_RXVECADDR_LOW_OFFS, 0,
			  BHIE_RXVECSTATUS_OFFS - BHIE_RXVECADDR_LOW_OFFS + 4);
	}

	mhi_cntrl->pre_init = true;
+16 −1
Original line number Diff line number Diff line
@@ -173,12 +173,24 @@ void mhi_ring_chan_db(struct mhi_controller *mhi_cntrl,
				    db);
}

static enum mhi_ee mhi_translate_dev_ee(struct mhi_controller *mhi_cntrl,
					u32 dev_ee)
{
	enum mhi_ee i;

	for (i = MHI_EE_PBL; i < MHI_EE_MAX; i++)
		if (mhi_cntrl->ee_table[i] == dev_ee)
			return i;

	return MHI_EE_NOT_SUPPORTED;
}

enum mhi_ee mhi_get_exec_env(struct mhi_controller *mhi_cntrl)
{
	u32 exec;
	int ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->bhi, BHI_EXECENV, &exec);

	return (ret) ? MHI_EE_MAX : exec;
	return (ret) ? MHI_EE_MAX : mhi_translate_dev_ee(mhi_cntrl, exec);
}

enum mhi_dev_state mhi_get_mhi_state(struct mhi_controller *mhi_cntrl)
@@ -1171,6 +1183,9 @@ int mhi_process_ctrl_ev_ring(struct mhi_controller *mhi_cntrl,
			enum MHI_ST_TRANSITION st = MHI_ST_TRANSITION_MAX;
			enum mhi_ee event = MHI_TRE_GET_EV_EXECENV(local_rp);

			/* convert device ee to host ee */
			event = mhi_translate_dev_ee(mhi_cntrl, event);

			MHI_LOG("MHI EE received event:%s\n",
				TO_MHI_EXEC_STR(event));
			switch (event) {
+2 −2
Original line number Diff line number Diff line
@@ -815,8 +815,8 @@ int mhi_async_power_up(struct mhi_controller *mhi_cntrl)

	mhi_cntrl->bhi = mhi_cntrl->regs + val;

	/* setup bhie offset */
	if (mhi_cntrl->fbc_download) {
	/* 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 (ret) {
			write_unlock_irq(&mhi_cntrl->pm_lock);
+9 −7
Original line number Diff line number Diff line
@@ -81,15 +81,16 @@ enum mhi_device_type {
 * @MHI_EE_EDL - device in emergency download mode
 */
enum mhi_ee {
	MHI_EE_PBL = 0x0,
	MHI_EE_SBL = 0x1,
	MHI_EE_AMSS = 0x2,
	MHI_EE_RDDM = 0x3,
	MHI_EE_WFW = 0x4,
	MHI_EE_PTHRU = 0x5,
	MHI_EE_EDL = 0x6,
	MHI_EE_PBL,
	MHI_EE_SBL,
	MHI_EE_AMSS,
	MHI_EE_RDDM,
	MHI_EE_WFW,
	MHI_EE_PTHRU,
	MHI_EE_EDL,
	MHI_EE_MAX_SUPPORTED = MHI_EE_EDL,
	MHI_EE_DISABLE_TRANSITION, /* local EE, not related to mhi spec */
	MHI_EE_NOT_SUPPORTED,
	MHI_EE_MAX,
};

@@ -254,6 +255,7 @@ struct mhi_controller {
	u32 saved_pm_state; /* saved state during fast suspend */
	u32 db_access; /* db access only on these states */
	enum mhi_ee ee;
	u32 ee_table[MHI_EE_MAX]; /* ee conversion from dev to host */
	enum mhi_dev_state dev_state;
	enum mhi_dev_state saved_dev_state;
	bool wake_set;