From 8ad12ed3b1738be72035990e94de9d98d72d764a Mon Sep 17 00:00:00 2001 From: Sujeev Dias Date: Mon, 30 Jul 2018 21:45:14 -0700 Subject: [PATCH] mhi: core: update MHI host support for WLAN FW execution environment MHI based WLAN devices sends WFW execution environment to indicate device up notification. Adding host support to handle such event. CRs-Fixed: 2289352 Change-Id: I4be4766e46495b542a965a33242c16b498cca1da Signed-off-by: Sujeev Dias --- Documentation/devicetree/bindings/bus/mhi.txt | 4 ++-- drivers/bus/mhi/core/mhi_boot.c | 4 ++-- drivers/bus/mhi/core/mhi_init.c | 5 ++-- drivers/bus/mhi/core/mhi_internal.h | 7 +++--- drivers/bus/mhi/core/mhi_main.c | 7 +++--- drivers/bus/mhi/core/mhi_pm.c | 24 ++++++++++++------- include/linux/mhi.h | 6 ++--- 7 files changed, 31 insertions(+), 26 deletions(-) diff --git a/Documentation/devicetree/bindings/bus/mhi.txt b/Documentation/devicetree/bindings/bus/mhi.txt index c6417eade80c..837c33cd0748 100644 --- a/Documentation/devicetree/bindings/bus/mhi.txt +++ b/Documentation/devicetree/bindings/bus/mhi.txt @@ -81,8 +81,8 @@ mhi channel node properties: BIT(0) = Channel supported in PBL EE BIT(1) = Channel supported in SBL EE BIT(2) = Channel supported in AMSS EE - BIT(3) = Channel supported in BHIe EE - BIT(4) = Channel supported in RDDM EE + BIT(3) = Channel supported in RDDM EE + BIT(4) = Channel supported in WFW EE BIT(5) = Channel supported in PTHRU EE BIT(6) = Channel supported in EDL EE diff --git a/drivers/bus/mhi/core/mhi_boot.c b/drivers/bus/mhi/core/mhi_boot.c index 334a09ff8932..8fa1d037c3df 100644 --- a/drivers/bus/mhi/core/mhi_boot.c +++ b/drivers/bus/mhi/core/mhi_boot.c @@ -556,9 +556,9 @@ void mhi_fw_load_worker(struct work_struct *work) goto error_read; } - /* wait for BHIE event */ + /* wait for SBL event */ ret = wait_event_timeout(mhi_cntrl->state_event, - mhi_cntrl->ee == MHI_EE_BHIE || + mhi_cntrl->ee == MHI_EE_SBL || MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state), msecs_to_jiffies(mhi_cntrl->timeout_ms)); diff --git a/drivers/bus/mhi/core/mhi_init.c b/drivers/bus/mhi/core/mhi_init.c index 59592fb17cf8..76960cef1a70 100644 --- a/drivers/bus/mhi/core/mhi_init.c +++ b/drivers/bus/mhi/core/mhi_init.c @@ -27,8 +27,8 @@ const char * const mhi_ee_str[MHI_EE_MAX] = { [MHI_EE_PBL] = "PBL", [MHI_EE_SBL] = "SBL", [MHI_EE_AMSS] = "AMSS", - [MHI_EE_BHIE] = "BHIE", [MHI_EE_RDDM] = "RDDM", + [MHI_EE_WFW] = "WFW", [MHI_EE_PTHRU] = "PASS THRU", [MHI_EE_EDL] = "EDL", [MHI_EE_DISABLE_TRANSITION] = "DISABLE", @@ -38,8 +38,7 @@ const char * const mhi_state_tran_str[MHI_ST_TRANSITION_MAX] = { [MHI_ST_TRANSITION_PBL] = "PBL", [MHI_ST_TRANSITION_READY] = "READY", [MHI_ST_TRANSITION_SBL] = "SBL", - [MHI_ST_TRANSITION_AMSS] = "AMSS", - [MHI_ST_TRANSITION_BHIE] = "BHIE", + [MHI_ST_TRANSITION_MISSION_MODE] = "MISSION MODE", }; const char * const mhi_state_str[MHI_STATE_MAX] = { diff --git a/drivers/bus/mhi/core/mhi_internal.h b/drivers/bus/mhi/core/mhi_internal.h index c7ff92747e1a..aa1e043033fb 100644 --- a/drivers/bus/mhi/core/mhi_internal.h +++ b/drivers/bus/mhi/core/mhi_internal.h @@ -382,12 +382,13 @@ extern const char * const mhi_ee_str[MHI_EE_MAX]; #define MHI_IN_PBL(ee) (ee == MHI_EE_PBL || ee == MHI_EE_PTHRU || \ ee == MHI_EE_EDL) +#define MHI_IN_MISSION_MODE(ee) (ee == MHI_EE_AMSS || ee == MHI_EE_WFW) + enum MHI_ST_TRANSITION { MHI_ST_TRANSITION_PBL, MHI_ST_TRANSITION_READY, MHI_ST_TRANSITION_SBL, - MHI_ST_TRANSITION_AMSS, - MHI_ST_TRANSITION_BHIE, + MHI_ST_TRANSITION_MISSION_MODE, MHI_ST_TRANSITION_MAX, }; @@ -480,9 +481,9 @@ enum mhi_ch_ee_mask { MHI_CH_EE_PBL = BIT(MHI_EE_PBL), MHI_CH_EE_SBL = BIT(MHI_EE_SBL), MHI_CH_EE_AMSS = BIT(MHI_EE_AMSS), - MHI_CH_EE_BHIE = BIT(MHI_EE_BHIE), MHI_CH_EE_RDDM = BIT(MHI_EE_RDDM), MHI_CH_EE_PTHRU = BIT(MHI_EE_PTHRU), + MHI_CH_EE_WFW = BIT(MHI_EE_WFW), MHI_CH_EE_EDL = BIT(MHI_EE_EDL), }; diff --git a/drivers/bus/mhi/core/mhi_main.c b/drivers/bus/mhi/core/mhi_main.c index 0eef26eaeac7..c22b474678b2 100644 --- a/drivers/bus/mhi/core/mhi_main.c +++ b/drivers/bus/mhi/core/mhi_main.c @@ -613,7 +613,7 @@ static void mhi_create_time_sync_dev(struct mhi_controller *mhi_cntrl) if (!mhi_tsync || !mhi_tsync->db) return; - if (mhi_cntrl->ee != MHI_EE_AMSS) + if (!MHI_IN_MISSION_MODE(mhi_cntrl->ee)) return; mhi_dev = mhi_alloc_device(mhi_cntrl); @@ -973,15 +973,14 @@ int mhi_process_ctrl_ev_ring(struct mhi_controller *mhi_cntrl, case MHI_EE_SBL: st = MHI_ST_TRANSITION_SBL; break; + case MHI_EE_WFW: case MHI_EE_AMSS: - st = MHI_ST_TRANSITION_AMSS; + st = MHI_ST_TRANSITION_MISSION_MODE; break; case MHI_EE_RDDM: mhi_cntrl->status_cb(mhi_cntrl, mhi_cntrl->priv_data, MHI_CB_EE_RDDM); - /* fall thru to wake up the event */ - case MHI_EE_BHIE: write_lock_irq(&mhi_cntrl->pm_lock); mhi_cntrl->ee = event; write_unlock_irq(&mhi_cntrl->pm_lock); diff --git a/drivers/bus/mhi/core/mhi_pm.c b/drivers/bus/mhi/core/mhi_pm.c index cbae02a8dc64..132fb705323f 100644 --- a/drivers/bus/mhi/core/mhi_pm.c +++ b/drivers/bus/mhi/core/mhi_pm.c @@ -319,8 +319,8 @@ int mhi_pm_m0_transition(struct mhi_controller *mhi_cntrl) read_lock_bh(&mhi_cntrl->pm_lock); mhi_cntrl->wake_get(mhi_cntrl, false); - /* ring all event rings and CMD ring only if we're in AMSS */ - if (mhi_cntrl->ee == MHI_EE_AMSS) { + /* ring all event rings and CMD ring only if we're in mission mode */ + if (MHI_IN_MISSION_MODE(mhi_cntrl->ee)) { struct mhi_event *mhi_event = mhi_cntrl->mhi_event; struct mhi_cmd *mhi_cmd = &mhi_cntrl->mhi_cmd[PRIMARY_CMD_RING]; @@ -420,16 +420,21 @@ int mhi_pm_m3_transition(struct mhi_controller *mhi_cntrl) return 0; } -static int mhi_pm_amss_transition(struct mhi_controller *mhi_cntrl) +static int mhi_pm_mission_mode_transition(struct mhi_controller *mhi_cntrl) { int i; struct mhi_event *mhi_event; - MHI_LOG("Processing AMSS Transition\n"); + MHI_LOG("Processing Mission Mode Transition\n"); write_lock_irq(&mhi_cntrl->pm_lock); - mhi_cntrl->ee = MHI_EE_AMSS; + if (MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state)) + mhi_cntrl->ee = mhi_get_exec_env(mhi_cntrl); write_unlock_irq(&mhi_cntrl->pm_lock); + + if (!MHI_IN_MISSION_MODE(mhi_cntrl->ee)) + return -EIO; + wake_up_all(&mhi_cntrl->state_event); /* add elements to all HW event rings */ @@ -708,10 +713,11 @@ void mhi_pm_st_worker(struct work_struct *work) write_lock_irq(&mhi_cntrl->pm_lock); mhi_cntrl->ee = MHI_EE_SBL; write_unlock_irq(&mhi_cntrl->pm_lock); + wake_up_all(&mhi_cntrl->state_event); mhi_create_devices(mhi_cntrl); break; - case MHI_ST_TRANSITION_AMSS: - mhi_pm_amss_transition(mhi_cntrl); + case MHI_ST_TRANSITION_MISSION_MODE: + mhi_pm_mission_mode_transition(mhi_cntrl); break; case MHI_ST_TRANSITION_READY: mhi_ready_state_transition(mhi_cntrl); @@ -871,11 +877,11 @@ int mhi_sync_power_up(struct mhi_controller *mhi_cntrl) return ret; wait_event_timeout(mhi_cntrl->state_event, - mhi_cntrl->ee == MHI_EE_AMSS || + MHI_IN_MISSION_MODE(mhi_cntrl->ee) || MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state), msecs_to_jiffies(mhi_cntrl->timeout_ms)); - return (mhi_cntrl->ee == MHI_EE_AMSS) ? 0 : -EIO; + return (MHI_IN_MISSION_MODE(mhi_cntrl->ee)) ? 0 : -EIO; } EXPORT_SYMBOL(mhi_sync_power_up); diff --git a/include/linux/mhi.h b/include/linux/mhi.h index ced8dd1a769e..b6b313944e61 100644 --- a/include/linux/mhi.h +++ b/include/linux/mhi.h @@ -77,8 +77,8 @@ enum mhi_device_type { * @MHI_EE_PBL - device in PBL * @MHI_EE_SBL - device in SBL * @MHI_EE_AMSS - device in mission mode (firmware fully loaded) - * @MHI_EE_BHIE - device in special SBL that support BHI/e protocol * @MHI_EE_RDDM - device in ram dump collection mode + * @MHI_EE_WFW - device in WLAN firmware mode * @MHI_EE_PTHRU - device in PBL but configured in pass thru mode * @MHI_EE_EDL - device in emergency download mode */ @@ -86,8 +86,8 @@ enum mhi_ee { MHI_EE_PBL = 0x0, MHI_EE_SBL = 0x1, MHI_EE_AMSS = 0x2, - MHI_EE_BHIE = 0x3, - MHI_EE_RDDM = 0x4, + MHI_EE_RDDM = 0x3, + MHI_EE_WFW = 0x4, MHI_EE_PTHRU = 0x5, MHI_EE_EDL = 0x6, MHI_EE_MAX_SUPPORTED = MHI_EE_EDL,