diff options
| -rw-r--r-- | Documentation/devicetree/bindings/mhi/msm_mhi.txt | 2 | ||||
| -rw-r--r-- | drivers/platform/msm/mhi/mhi_iface.c | 49 | ||||
| -rw-r--r-- | drivers/platform/msm/mhi/mhi_main.c | 38 | ||||
| -rw-r--r-- | drivers/platform/msm/mhi/mhi_states.c | 22 | ||||
| -rw-r--r-- | include/linux/msm_mhi.h | 2 |
5 files changed, 69 insertions, 44 deletions
diff --git a/Documentation/devicetree/bindings/mhi/msm_mhi.txt b/Documentation/devicetree/bindings/mhi/msm_mhi.txt index 5f950604d186..9c5c2fee78d0 100644 --- a/Documentation/devicetree/bindings/mhi/msm_mhi.txt +++ b/Documentation/devicetree/bindings/mhi/msm_mhi.txt @@ -17,7 +17,7 @@ Main node properties: Definition: "qcom,mhi" - qcom,pci-dev_id - Usage: required + Usage: optional Value type: <u32> Definition: Device id reported by modem diff --git a/drivers/platform/msm/mhi/mhi_iface.c b/drivers/platform/msm/mhi/mhi_iface.c index 64a09a2f9fbb..a5936ea5a6aa 100644 --- a/drivers/platform/msm/mhi/mhi_iface.c +++ b/drivers/platform/msm/mhi/mhi_iface.c @@ -153,16 +153,19 @@ static int mhi_pci_probe(struct pci_dev *pcie_device, u32 slot = PCI_SLOT(pcie_device->devfn); unsigned long msi_requested, msi_required; struct msm_pcie_register_event *mhi_pci_link_event; + struct pcie_core_info *core; + int i; + char node[32]; /* Find correct device context based on bdf & dev_id */ mutex_lock(&mhi_device_drv->lock); list_for_each_entry(itr, &mhi_device_drv->head, node) { - struct pcie_core_info *core = &itr->core; - - if (core->domain == domain && - core->bus == bus && - core->dev_id == dev_id && + core = &itr->core; + if (core->domain == domain && core->bus == bus && + (core->dev_id == PCI_ANY_ID || (core->dev_id == dev_id)) && core->slot == slot) { + /* change default dev_id to actual dev_id */ + core->dev_id = dev_id; mhi_dev_ctxt = itr; break; } @@ -171,6 +174,11 @@ static int mhi_pci_probe(struct pci_dev *pcie_device, if (!mhi_dev_ctxt) return -EPROBE_DEFER; + snprintf(node, sizeof(node), "mhi_%04x_%02u.%02u.%02u", + core->dev_id, core->domain, core->bus, core->slot); + mhi_dev_ctxt->mhi_ipc_log = + ipc_log_context_create(MHI_IPC_LOG_PAGES, node, 0); + mhi_log(mhi_dev_ctxt, MHI_MSG_INFO, "Processing Domain:%02u Bus:%04u dev:0x%04x slot:%04u\n", domain, bus, dev_id, slot); @@ -280,9 +288,22 @@ static int mhi_pci_probe(struct pci_dev *pcie_device, mutex_lock(&mhi_dev_ctxt->pm_lock); write_lock_irq(&mhi_dev_ctxt->pm_xfer_lock); mhi_dev_ctxt->mhi_pm_state = MHI_PM_POR; - ret_val = set_mhi_base_state(mhi_dev_ctxt); + write_unlock_irq(&mhi_dev_ctxt->pm_xfer_lock); + /* notify all registered clients we probed */ + for (i = 0; i < MHI_MAX_CHANNELS; i++) { + struct mhi_client_handle *client_handle = + mhi_dev_ctxt->client_handle_list[i]; + + if (!client_handle) + continue; + client_handle->dev_id = core->dev_id; + mhi_notify_client(client_handle, MHI_CB_MHI_PROBED); + } + write_lock_irq(&mhi_dev_ctxt->pm_xfer_lock); + ret_val = set_mhi_base_state(mhi_dev_ctxt); write_unlock_irq(&mhi_dev_ctxt->pm_xfer_lock); + if (ret_val) { mhi_log(mhi_dev_ctxt, MHI_MSG_ERROR, @@ -344,7 +365,6 @@ static int mhi_plat_probe(struct platform_device *pdev) int r = 0, len; struct mhi_device_ctxt *mhi_dev_ctxt; struct pcie_core_info *core; - char node[32]; struct device_node *of_node = pdev->dev.of_node; u64 address_window[2]; @@ -377,7 +397,7 @@ static int mhi_plat_probe(struct platform_device *pdev) core = &mhi_dev_ctxt->core; r = of_property_read_u32(of_node, "qcom,pci-dev_id", &core->dev_id); if (r) - return r; + core->dev_id = PCI_ANY_ID; r = of_property_read_u32(of_node, "qcom,pci-slot", &core->slot); if (r) @@ -391,14 +411,6 @@ static int mhi_plat_probe(struct platform_device *pdev) if (r) return r; - snprintf(node, sizeof(node), - "mhi_%04x_%02u.%02u.%02u", - core->dev_id, core->domain, core->bus, core->slot); - mhi_dev_ctxt->mhi_ipc_log = - ipc_log_context_create(MHI_IPC_LOG_PAGES, node, 0); - if (!mhi_dev_ctxt->mhi_ipc_log) - pr_err("%s: Error creating ipc_log buffer\n", __func__); - r = of_property_read_u32(of_node, "qcom,mhi-ready-timeout", &mhi_dev_ctxt->poll_reset_timeout_ms); if (r) @@ -407,10 +419,6 @@ static int mhi_plat_probe(struct platform_device *pdev) mhi_dev_ctxt->dev_space.start_win_addr = address_window[0]; mhi_dev_ctxt->dev_space.end_win_addr = address_window[1]; - mhi_log(mhi_dev_ctxt, MHI_MSG_INFO, - "Start Addr:0x%llx End_Addr:0x%llx\n", - mhi_dev_ctxt->dev_space.start_win_addr, - mhi_dev_ctxt->dev_space.end_win_addr); r = of_property_read_u32(of_node, "qcom,bhi-alignment", &mhi_dev_ctxt->bhi_ctxt.alignment); @@ -471,7 +479,6 @@ static int mhi_plat_probe(struct platform_device *pdev) mutex_lock(&mhi_device_drv->lock); list_add_tail(&mhi_dev_ctxt->node, &mhi_device_drv->head); mutex_unlock(&mhi_device_drv->lock); - mhi_log(mhi_dev_ctxt, MHI_MSG_INFO, "Exited\n"); return 0; } diff --git a/drivers/platform/msm/mhi/mhi_main.c b/drivers/platform/msm/mhi/mhi_main.c index 702f9ad5ddfb..739915c4af6f 100644 --- a/drivers/platform/msm/mhi/mhi_main.c +++ b/drivers/platform/msm/mhi/mhi_main.c @@ -562,6 +562,7 @@ int mhi_register_channel(struct mhi_client_handle **client_handle, (*client_handle)->domain = mhi_dev_ctxt->core.domain; (*client_handle)->bus = mhi_dev_ctxt->core.bus; (*client_handle)->slot = mhi_dev_ctxt->core.slot; + (*client_handle)->enabled = false; client_config = (*client_handle)->client_config; client_config->mhi_dev_ctxt = mhi_dev_ctxt; client_config->user_data = client_info->user_data; @@ -588,11 +589,8 @@ int mhi_register_channel(struct mhi_client_handle **client_handle, } if (mhi_dev_ctxt->dev_exec_env == MHI_EXEC_ENV_AMSS && - mhi_dev_ctxt->flags.mhi_initialized) { - mhi_log(mhi_dev_ctxt, MHI_MSG_INFO, - "Exec env is AMSS notify client now chan:%u\n", chan); - mhi_notify_client(*client_handle, MHI_CB_MHI_ENABLED); - } + mhi_dev_ctxt->flags.mhi_initialized) + (*client_handle)->enabled = true; mhi_log(mhi_dev_ctxt, MHI_MSG_VERBOSE, "Successfuly registered chan:%u\n", chan); @@ -1789,6 +1787,8 @@ int mhi_register_device(struct mhi_device *mhi_device, u32 dev_id = pci_dev->device; u32 slot = PCI_SLOT(pci_dev->devfn); int ret, i; + char node[32]; + struct pcie_core_info *core; of_node = of_parse_phandle(mhi_device->dev->of_node, node_name, 0); if (!of_node) @@ -1801,13 +1801,13 @@ int mhi_register_device(struct mhi_device *mhi_device, mutex_lock(&mhi_device_drv->lock); list_for_each_entry(itr, &mhi_device_drv->head, node) { struct platform_device *pdev = itr->plat_dev; - struct pcie_core_info *core = &itr->core; - if (pdev->dev.of_node == of_node && - core->domain == domain && - core->bus == bus && - core->dev_id == dev_id && - core->slot == slot) { + core = &itr->core; + if (pdev->dev.of_node == of_node && core->domain == domain && + core->bus == bus && core->slot == slot && + (core->dev_id == PCI_ANY_ID || (core->dev_id == dev_id))) { + /* change default dev_id to current dev_id */ + core->dev_id = dev_id; mhi_dev_ctxt = itr; break; } @@ -1818,6 +1818,11 @@ int mhi_register_device(struct mhi_device *mhi_device, if (!mhi_dev_ctxt) return -EPROBE_DEFER; + snprintf(node, sizeof(node), "mhi_%04x_%02u.%02u.%02u", + core->dev_id, core->domain, core->bus, core->slot); + mhi_dev_ctxt->mhi_ipc_log = + ipc_log_context_create(MHI_IPC_LOG_PAGES, node, 0); + mhi_log(mhi_dev_ctxt, MHI_MSG_INFO, "Registering Domain:%02u Bus:%04u dev:0x%04x slot:%04u\n", domain, bus, dev_id, slot); @@ -1899,6 +1904,17 @@ int mhi_register_device(struct mhi_device *mhi_device, mhi_dev_ctxt->bhi_ctxt.rddm_size); } + /* notify all the registered clients we probed */ + for (i = 0; i < MHI_MAX_CHANNELS; i++) { + struct mhi_client_handle *client_handle = + mhi_dev_ctxt->client_handle_list[i]; + + if (!client_handle) + continue; + client_handle->dev_id = core->dev_id; + mhi_notify_client(client_handle, MHI_CB_MHI_PROBED); + } + mhi_log(mhi_dev_ctxt, MHI_MSG_INFO, "Exit success\n"); return 0; } diff --git a/drivers/platform/msm/mhi/mhi_states.c b/drivers/platform/msm/mhi/mhi_states.c index c0c23c4e0756..e38355841c22 100644 --- a/drivers/platform/msm/mhi/mhi_states.c +++ b/drivers/platform/msm/mhi/mhi_states.c @@ -590,26 +590,26 @@ static int process_reset_transition( } static void enable_clients(struct mhi_device_ctxt *mhi_dev_ctxt, - enum MHI_EXEC_ENV exec_env) + enum MHI_EXEC_ENV exec_env) { struct mhi_client_handle *client_handle = NULL; - struct mhi_cb_info cb_info; - int i = 0, r = 0; - struct mhi_chan_info chan_info; - - cb_info.cb_reason = MHI_CB_MHI_ENABLED; + struct mhi_chan_info *chan_info; + int i = 0; mhi_log(mhi_dev_ctxt, MHI_MSG_INFO, "Enabling Clients, exec env %d.\n", exec_env); + for (i = 0; i < MHI_MAX_CHANNELS; ++i) { - if (!VALID_CHAN_NR(i)) + if (!mhi_dev_ctxt->client_handle_list[i]) continue; + client_handle = mhi_dev_ctxt->client_handle_list[i]; - r = get_chan_props(mhi_dev_ctxt, i, &chan_info); - if (!r && client_handle && - exec_env == GET_CHAN_PROPS(CHAN_BRINGUP_STAGE, - chan_info.flags)) + chan_info = &client_handle->client_config->chan_info; + if (exec_env == GET_CHAN_PROPS(CHAN_BRINGUP_STAGE, + chan_info->flags)) { + client_handle->enabled = true; mhi_notify_client(client_handle, MHI_CB_MHI_ENABLED); + } } mhi_log(mhi_dev_ctxt, MHI_MSG_INFO, "Done.\n"); diff --git a/include/linux/msm_mhi.h b/include/linux/msm_mhi.h index e655f7397527..01fe2e78b9d5 100644 --- a/include/linux/msm_mhi.h +++ b/include/linux/msm_mhi.h @@ -81,6 +81,7 @@ enum MHI_CB_REASON { MHI_CB_MHI_SHUTDOWN, MHI_CB_SYS_ERROR, MHI_CB_RDDM, + MHI_CB_MHI_PROBED, }; enum MHI_FLAGS { @@ -119,6 +120,7 @@ struct mhi_client_handle { u32 domain; u32 bus; u32 slot; + bool enabled; struct mhi_client_config *client_config; }; |
