Loading drivers/platform/msm/usb_bam.c +84 −76 Original line number Diff line number Diff line Loading @@ -102,7 +102,6 @@ struct usb_bam_sps_type { struct usb_bam_ctx_type { struct usb_bam_sps_type usb_bam_sps; struct resource *io_res; void __iomem *regs; int irq; struct platform_device *usb_bam_pdev; struct workqueue_struct *usb_bam_wq; Loading @@ -112,6 +111,7 @@ struct usb_bam_ctx_type { u32 inactivity_timer_ms; bool is_bam_inactivity; struct usb_bam_pipe_connect *usb_bam_connections; struct msm_usb_bam_data *usb_bam_data; spinlock_t usb_bam_lock; }; Loading @@ -125,13 +125,13 @@ static char *bam_enable_strings[MAX_BAMS] = { * CI_CTRL & DWC3_CTRL shouldn't be used simultaneously * since both share the same prod & cons rm resourses */ static enum ipa_client_type ipa_rm_resource_prod[MAX_BAMS] = { static enum ipa_rm_resource_name ipa_rm_resource_prod[MAX_BAMS] = { [CI_CTRL] = IPA_RM_RESOURCE_USB_PROD, [HSIC_CTRL] = IPA_RM_RESOURCE_HSIC_PROD, [DWC3_CTRL] = IPA_RM_RESOURCE_USB_PROD, }; static enum ipa_client_type ipa_rm_resource_cons[MAX_BAMS] = { static enum ipa_rm_resource_name ipa_rm_resource_cons[MAX_BAMS] = { [CI_CTRL] = IPA_RM_RESOURCE_USB_CONS, [HSIC_CTRL] = IPA_RM_RESOURCE_HSIC_CONS, [DWC3_CTRL] = IPA_RM_RESOURCE_USB_CONS, Loading Loading @@ -319,8 +319,6 @@ static int usb_bam_alloc_buffer(struct usb_bam_pipe_connect *pipe_connect) { int ret = 0; struct usb_bam_ctx_type *ctx = &msm_usb_bam[pipe_connect->bam_type]; struct msm_usb_bam_platform_data *pdata = ctx->usb_bam_pdev->dev.platform_data; struct sps_mem_buffer *data_buf = &(pipe_connect->data_mem_buf); struct sps_mem_buffer *desc_buf = &(pipe_connect->desc_mem_buf); Loading Loading @@ -359,7 +357,7 @@ static int usb_bam_alloc_buffer(struct usb_bam_pipe_connect *pipe_connect) } data_buf->phys_base = pipe_connect->data_fifo_base_offset + pdata->usb_bam_fifo_baseaddr; ctx->usb_bam_data->usb_bam_fifo_baseaddr; data_buf->size = pipe_connect->data_fifo_size; data_buf->base = ioremap(data_buf->phys_base, data_buf->size); if (!data_buf->base) { Loading @@ -371,7 +369,7 @@ static int usb_bam_alloc_buffer(struct usb_bam_pipe_connect *pipe_connect) memset_io(data_buf->base, 0, data_buf->size); desc_buf->phys_base = pipe_connect->desc_fifo_base_offset + pdata->usb_bam_fifo_baseaddr; ctx->usb_bam_data->usb_bam_fifo_baseaddr; desc_buf->size = pipe_connect->desc_fifo_size; desc_buf->base = ioremap(desc_buf->phys_base, desc_buf->size); if (!desc_buf->base) { Loading Loading @@ -1068,7 +1066,6 @@ int usb_bam_connect(enum usb_ctrl cur_bam, int idx, u32 *bam_pipe_idx) struct usb_bam_pipe_connect *pipe_connect = &ctx->usb_bam_connections[idx]; struct device *bam_dev = &ctx->usb_bam_pdev->dev; struct msm_usb_bam_platform_data *pdata = bam_dev->platform_data; enum usb_bam_mode cur_mode; if (pipe_connect->enabled) { Loading @@ -1094,7 +1091,7 @@ int usb_bam_connect(enum usb_ctrl cur_bam, int idx, u32 *bam_pipe_idx) spin_lock(&ctx->usb_bam_lock); /* Check if BAM requires RESET before connect and reset of first pipe */ if ((pdata->reset_on_connect == true) && if ((ctx->usb_bam_data->reset_on_connect == true) && (ctx->pipes_enabled_per_bam == 0)) { spin_unlock(&ctx->usb_bam_lock); Loading Loading @@ -1595,8 +1592,6 @@ static int ss_usb_cons_release_resource(void) static void usb_bam_ipa_create_resources(enum usb_ctrl cur_bam) { struct usb_bam_ctx_type *ctx = &msm_usb_bam[cur_bam]; struct msm_usb_bam_platform_data *pdata = ctx->usb_bam_pdev->dev.platform_data; struct ipa_rm_create_params usb_prod_create_params; struct ipa_rm_create_params usb_cons_create_params; int ret; Loading @@ -1605,7 +1600,8 @@ static void usb_bam_ipa_create_resources(enum usb_ctrl cur_bam) memset(&usb_prod_create_params, 0, sizeof(usb_prod_create_params)); usb_prod_create_params.name = ipa_rm_resource_prod[cur_bam]; usb_prod_create_params.reg_params.notify_cb = usb_prod_notify_cb; usb_prod_create_params.reg_params.user_data = &pdata->bam_type; usb_prod_create_params.reg_params.user_data = &ctx->usb_bam_data->bam_type; usb_prod_create_params.floor_voltage = IPA_VOLTAGE_SVS; ret = ipa_rm_create_resource(&usb_prod_create_params); if (ret) { Loading @@ -1628,6 +1624,22 @@ static void usb_bam_ipa_create_resources(enum usb_ctrl cur_bam) } } static void usb_bam_ipa_delete_resources(enum usb_ctrl cur_bam) { int ret; ret = ipa_rm_delete_resource(ipa_rm_resource_prod[cur_bam]); if (ret) log_event_err("%s: Failed to delete USB_PROD resource\n", __func__); ret = ipa_rm_delete_resource(ipa_rm_resource_cons[cur_bam]); if (ret) log_event_err("%s: Failed to delete USB_CONS resource\n", __func__); } static void wait_for_prod_granted(enum usb_ctrl cur_bam) { int ret; Loading Loading @@ -2134,16 +2146,14 @@ static int usb_bam_set_ipa_perf(enum usb_ctrl cur_bam, int ret; struct usb_bam_ctx_type *ctx = &msm_usb_bam[cur_bam]; struct ipa_rm_perf_profile ipa_rm_perf_prof; struct msm_usb_bam_platform_data *pdata = ctx->usb_bam_pdev->dev.platform_data; if (usb_connection_speed == USB_SPEED_SUPER) ipa_rm_perf_prof.max_supported_bandwidth_mbps = pdata->max_mbps_superspeed; ctx->usb_bam_data->max_mbps_superspeed; else /* Bam2Bam is supported only for SS and HS (HW limitation) */ ipa_rm_perf_prof.max_supported_bandwidth_mbps = pdata->max_mbps_highspeed; ctx->usb_bam_data->max_mbps_highspeed; /* * Having a max mbps property in dtsi file is a must Loading Loading @@ -2180,7 +2190,6 @@ int usb_bam_connect_ipa(enum usb_ctrl cur_bam, struct usb_bam_ctx_type *ctx = &msm_usb_bam[cur_bam]; struct usb_bam_pipe_connect *pipe_connect; struct device *bam_dev = &ctx->usb_bam_pdev->dev; struct msm_usb_bam_platform_data *pdata = bam_dev->platform_data; int ret; bool bam2bam, is_dpl; Loading Loading @@ -2256,7 +2265,8 @@ int usb_bam_connect_ipa(enum usb_ctrl cur_bam, /* Check if BAM requires RESET before connect and reset first pipe */ spin_lock(&ctx->usb_bam_lock); if (pdata->reset_on_connect && !ctx->pipes_enabled_per_bam) { if (ctx->usb_bam_data->reset_on_connect && !ctx->pipes_enabled_per_bam) { spin_unlock(&ctx->usb_bam_lock); if (cur_bam == CI_CTRL) msm_hw_bam_disable(1); Loading Loading @@ -2606,8 +2616,6 @@ int usb_bam_disconnect_pipe(enum usb_ctrl bam_type, u8 idx) struct usb_bam_pipe_connect *pipe_connect; struct device *bam_dev = &ctx->usb_bam_pdev->dev; int ret; struct msm_usb_bam_platform_data *pdata = ctx->usb_bam_pdev->dev.platform_data; pipe_connect = &ctx->usb_bam_connections[idx]; Loading Loading @@ -2635,7 +2643,8 @@ int usb_bam_disconnect_pipe(enum usb_ctrl bam_type, u8 idx) log_event_dbg("%s: success disconnecting pipe %d\n", __func__, idx); if (pdata->reset_on_disconnect && !ctx->pipes_enabled_per_bam) { if (ctx->usb_bam_data->reset_on_disconnect && !ctx->pipes_enabled_per_bam) { if (bam_type == CI_CTRL) msm_hw_bam_disable(1); Loading Loading @@ -2803,10 +2812,10 @@ static void usb_bam_sps_events(enum sps_callback_case sps_cb_case, void *user) } } static struct msm_usb_bam_platform_data *usb_bam_dt_to_pdata( static struct msm_usb_bam_data *usb_bam_dt_to_data( struct platform_device *pdev, u32 usb_addr) { struct msm_usb_bam_platform_data *pdata; struct msm_usb_bam_data *usb_bam_data; struct device_node *node = pdev->dev.of_node; int rc = 0; u8 i = 0; Loading @@ -2815,8 +2824,9 @@ static struct msm_usb_bam_platform_data *usb_bam_dt_to_pdata( u32 threshold, max_connections = 0; static struct usb_bam_pipe_connect *usb_bam_connections; pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) usb_bam_data = devm_kzalloc(&pdev->dev, sizeof(*usb_bam_data), GFP_KERNEL); if (!usb_bam_data) return NULL; rc = of_property_read_u32(node, "qcom,bam-type", &bam); Loading @@ -2830,7 +2840,7 @@ static struct msm_usb_bam_platform_data *usb_bam_dt_to_pdata( __func__, bam); return NULL; } pdata->bam_type = bam; usb_bam_data->bam_type = bam; rc = of_property_read_u32(node, "qcom,bam-mode", &bam_mode); if (rc) { Loading @@ -2840,49 +2850,49 @@ static struct msm_usb_bam_platform_data *usb_bam_dt_to_pdata( bam_mode = USB_BAM_DEVICE; } pdata->reset_on_connect = of_property_read_bool(node, usb_bam_data->reset_on_connect = of_property_read_bool(node, "qcom,reset-bam-on-connect"); pdata->reset_on_disconnect = of_property_read_bool(node, usb_bam_data->reset_on_disconnect = of_property_read_bool(node, "qcom,reset-bam-on-disconnect"); rc = of_property_read_u32(node, "qcom,usb-bam-num-pipes", &pdata->usb_bam_num_pipes); &usb_bam_data->usb_bam_num_pipes); if (rc) { log_event_err("Invalid usb bam num pipes property\n"); return NULL; } rc = of_property_read_u32(node, "qcom,usb-bam-max-mbps-highspeed", &pdata->max_mbps_highspeed); &usb_bam_data->max_mbps_highspeed); if (rc) pdata->max_mbps_highspeed = 0; usb_bam_data->max_mbps_highspeed = 0; rc = of_property_read_u32(node, "qcom,usb-bam-max-mbps-superspeed", &pdata->max_mbps_superspeed); &usb_bam_data->max_mbps_superspeed); if (rc) pdata->max_mbps_superspeed = 0; usb_bam_data->max_mbps_superspeed = 0; rc = of_property_read_u32(node, "qcom,usb-bam-fifo-baseaddr", &addr); if (rc) pr_debug("%s: Invalid usb base address property\n", __func__); else pdata->usb_bam_fifo_baseaddr = addr; usb_bam_data->usb_bam_fifo_baseaddr = addr; pdata->ignore_core_reset_ack = of_property_read_bool(node, usb_bam_data->ignore_core_reset_ack = of_property_read_bool(node, "qcom,ignore-core-reset-ack"); pdata->disable_clk_gating = of_property_read_bool(node, usb_bam_data->disable_clk_gating = of_property_read_bool(node, "qcom,disable-clk-gating"); rc = of_property_read_u32(node, "qcom,usb-bam-override-threshold", &threshold); if (rc) pdata->override_threshold = USB_THRESHOLD; usb_bam_data->override_threshold = USB_THRESHOLD; else pdata->override_threshold = threshold; usb_bam_data->override_threshold = threshold; pdata->enable_hsusb_bam_on_boot = of_property_read_bool(node, usb_bam_data->enable_hsusb_bam_on_boot = of_property_read_bool(node, "qcom,enable-hsusb-bam-on-boot"); for_each_child_of_node(pdev->dev.of_node, node) Loading Loading @@ -2918,7 +2928,7 @@ static struct msm_usb_bam_platform_data *usb_bam_dt_to_pdata( goto err; if (usb_bam_connections[i].mem_type == OCI_MEM) { if (!pdata->usb_bam_fifo_baseaddr) { if (!usb_bam_data->usb_bam_fifo_baseaddr) { log_event_err("%s: base address is missing\n", __func__); goto err; Loading Loading @@ -3002,7 +3012,7 @@ static struct msm_usb_bam_platform_data *usb_bam_dt_to_pdata( msm_usb_bam[bam].usb_bam_connections = usb_bam_connections; msm_usb_bam[bam].max_connections = max_connections; return pdata; return usb_bam_data; err: log_event_err("%s: failed\n", __func__); return NULL; Loading @@ -3011,9 +3021,8 @@ static struct msm_usb_bam_platform_data *usb_bam_dt_to_pdata( static int usb_bam_init(struct platform_device *pdev) { int ret; struct msm_usb_bam_platform_data *pdata = pdev->dev.platform_data; enum usb_ctrl bam_type = pdata->bam_type; struct usb_bam_ctx_type *ctx = &msm_usb_bam[bam_type]; struct usb_bam_ctx_type *ctx = dev_get_drvdata(&pdev->dev); enum usb_ctrl bam_type = ctx->usb_bam_data->bam_type; struct sps_bam_props props; memset(&props, 0, sizeof(props)); Loading @@ -3022,23 +3031,22 @@ static int usb_bam_init(struct platform_device *pdev) bam_enable_strings[bam_type]); props.phys_addr = ctx->io_res->start; props.virt_addr = ctx->regs; props.virt_size = resource_size(ctx->io_res); props.irq = ctx->irq; props.summing_threshold = pdata->override_threshold; props.event_threshold = pdata->override_threshold; props.num_pipes = pdata->usb_bam_num_pipes; props.summing_threshold = ctx->usb_bam_data->override_threshold; props.event_threshold = ctx->usb_bam_data->override_threshold; props.num_pipes = ctx->usb_bam_data->usb_bam_num_pipes; props.callback = usb_bam_sps_events; props.user = bam_enable_strings[bam_type]; /* * HSUSB and HSIC Cores don't support RESET ACK signal to BAMs. * Hence let BAM to ignore acknowledge from USB while resetting PIPE. * HSUSB and HSIC Cores don't support RESET ACK signal to BAMs * Hence, let BAM to ignore acknowledge from USB while resetting PIPE */ if (pdata->ignore_core_reset_ack && bam_type != DWC3_CTRL) if (ctx->usb_bam_data->ignore_core_reset_ack && bam_type != DWC3_CTRL) props.options = SPS_BAM_NO_EXT_P_RST; if (pdata->disable_clk_gating) if (ctx->usb_bam_data->disable_clk_gating) props.options |= SPS_BAM_NO_LOCAL_CLK_GATING; /* Loading @@ -3046,7 +3054,8 @@ static int usb_bam_init(struct platform_device *pdev) * starting peripheral controller to avoid switching USB core mode * from legacy to BAM with ongoing data transfers. */ if (pdata->enable_hsusb_bam_on_boot && bam_type == CI_CTRL) { if (ctx->usb_bam_data->enable_hsusb_bam_on_boot && bam_type == CI_CTRL) { pr_debug("Register and enable HSUSB BAM\n"); props.options |= SPS_BAM_OPT_ENABLE_AT_BOOT; } Loading @@ -3063,9 +3072,8 @@ static int usb_bam_init(struct platform_device *pdev) static int enable_usb_bam(struct platform_device *pdev) { int ret; struct msm_usb_bam_platform_data *pdata = pdev->dev.platform_data; enum usb_ctrl bam_type = pdata->bam_type; struct usb_bam_ctx_type *ctx = &msm_usb_bam[bam_type]; struct usb_bam_ctx_type *ctx = dev_get_drvdata(&pdev->dev); enum usb_ctrl bam_type = ctx->usb_bam_data->bam_type; ret = usb_bam_init(pdev); if (ret) { Loading Loading @@ -3132,14 +3140,19 @@ void usb_bam_register_panic_hdlr(void) &usb_bam_panic_blk); } static void usb_bam_unregister_panic_hdlr(void) { atomic_notifier_chain_unregister(&panic_notifier_list, &usb_bam_panic_blk); } static int usb_bam_probe(struct platform_device *pdev) { int ret, i, irq; struct resource *io_res; void __iomem *regs; enum usb_ctrl bam_type; struct usb_bam_ctx_type *ctx; struct msm_usb_bam_platform_data *pdata; struct msm_usb_bam_data *usb_bam_data; dev_dbg(&pdev->dev, "usb_bam_probe\n"); Loading @@ -3155,25 +3168,19 @@ static int usb_bam_probe(struct platform_device *pdev) return irq; } regs = devm_ioremap(&pdev->dev, io_res->start, resource_size(io_res)); if (!regs) { log_event_err("%s: ioremap failed\n", __func__); return -ENOMEM; } /* specify BAM physical address to be filled in BAM connections */ pdata = usb_bam_dt_to_pdata(pdev, io_res->start); if (!pdata) usb_bam_data = usb_bam_dt_to_data(pdev, io_res->start); if (!usb_bam_data) return -EINVAL; pdev->dev.platform_data = pdata; bam_type = pdata->bam_type; bam_type = usb_bam_data->bam_type; ctx = &msm_usb_bam[bam_type]; dev_set_drvdata(&pdev->dev, ctx); ctx->usb_bam_pdev = pdev; ctx->irq = irq; ctx->regs = regs; ctx->io_res = io_res; ctx->usb_bam_data = usb_bam_data; for (i = 0; i < ctx->max_connections; i++) { ctx->usb_bam_connections[i].enabled = 0; Loading Loading @@ -3314,15 +3321,15 @@ EXPORT_SYMBOL(usb_bam_get_bam_type); bool msm_usb_bam_enable(enum usb_ctrl bam, bool bam_enable) { struct msm_usb_bam_platform_data *pdata; struct msm_usb_bam_data *usb_bam_data; struct usb_bam_ctx_type *ctx = &msm_usb_bam[bam]; if (!ctx->usb_bam_pdev) return 0; pdata = ctx->usb_bam_pdev->dev.platform_data; usb_bam_data = ctx->usb_bam_data; if ((bam != CI_CTRL) || !(bam_enable || pdata->enable_hsusb_bam_on_boot)) usb_bam_data->enable_hsusb_bam_on_boot)) return 0; msm_hw_bam_disable(1); Loading Loading @@ -3404,10 +3411,11 @@ EXPORT_SYMBOL(msm_bam_hsic_lpm_ok); static int usb_bam_remove(struct platform_device *pdev) { struct msm_usb_bam_platform_data *pdata = pdev->dev.platform_data; enum usb_ctrl bam_type = pdata->bam_type; struct usb_bam_ctx_type *ctx = &msm_usb_bam[bam_type]; struct usb_bam_ctx_type *ctx = dev_get_drvdata(&pdev->dev); usb_bam_ipa_delete_resources(ctx->usb_bam_data->bam_type); usb_bam_unregister_panic_hdlr(); sps_deregister_bam_device(ctx->h_bam); destroy_workqueue(ctx->usb_bam_wq); return 0; Loading drivers/usb/dwc3/core.c +3 −2 Original line number Diff line number Diff line Loading @@ -428,6 +428,9 @@ static void dwc3_event_buffers_cleanup(struct dwc3 *dwc) { struct dwc3_event_buffer *evt; if (!dwc->ev_buf) return; evt = dwc->ev_buf; evt->lpos = 0; Loading Loading @@ -692,8 +695,6 @@ static void dwc3_core_exit(struct dwc3 *dwc) phy_exit(dwc->usb2_generic_phy); phy_exit(dwc->usb3_generic_phy); usb_phy_set_suspend(dwc->usb2_phy, 1); usb_phy_set_suspend(dwc->usb3_phy, 1); phy_power_off(dwc->usb2_generic_phy); phy_power_off(dwc->usb3_generic_phy); } Loading drivers/usb/dwc3/dwc3-msm.c +9 −0 Original line number Diff line number Diff line Loading @@ -1867,6 +1867,9 @@ static void dwc3_msm_notify_event(struct dwc3 *dwc, unsigned int event) dev_dbg(mdwc->dev, "DWC3_GSI_EVT_BUF_SETUP\n"); for (i = 0; i < mdwc->num_gsi_event_buffers; i++) { evt = mdwc->gsi_ev_buff[i]; if (!evt) break; dev_dbg(mdwc->dev, "Evt buf %p dma %08llx length %d\n", evt->buf, (unsigned long long) evt->dma, evt->length); Loading @@ -1892,6 +1895,9 @@ static void dwc3_msm_notify_event(struct dwc3 *dwc, unsigned int event) break; case DWC3_GSI_EVT_BUF_CLEANUP: dev_dbg(mdwc->dev, "DWC3_GSI_EVT_BUF_CLEANUP\n"); if (!mdwc->gsi_ev_buff) break; for (i = 0; i < mdwc->num_gsi_event_buffers; i++) { evt = mdwc->gsi_ev_buff[i]; evt->lpos = 0; Loading @@ -1911,6 +1917,9 @@ static void dwc3_msm_notify_event(struct dwc3 *dwc, unsigned int event) break; case DWC3_GSI_EVT_BUF_FREE: dev_dbg(mdwc->dev, "DWC3_GSI_EVT_BUF_FREE\n"); if (!mdwc->gsi_ev_buff) break; for (i = 0; i < mdwc->num_gsi_event_buffers; i++) { evt = mdwc->gsi_ev_buff[i]; if (evt) Loading include/linux/usb_bam.h +2 −2 Original line number Diff line number Diff line Loading @@ -198,7 +198,7 @@ struct usb_bam_pipe_connect { }; /** * struct msm_usb_bam_platform_data: pipe connection information * struct msm_usb_bam_data: pipe connection information * between USB/HSIC BAM and another BAM. USB/HSIC BAM can be * either src BAM or dst BAM * @usb_bam_num_pipes: max number of pipes to use. Loading @@ -218,7 +218,7 @@ struct usb_bam_pipe_connect { * can work at in bam2bam mode when connected to SS host. * @enable_hsusb_bam_on_boot: Enable HSUSB BAM (non-NDP) on bootup itself */ struct msm_usb_bam_platform_data { struct msm_usb_bam_data { u8 max_connections; int usb_bam_num_pipes; phys_addr_t usb_bam_fifo_baseaddr; Loading Loading
drivers/platform/msm/usb_bam.c +84 −76 Original line number Diff line number Diff line Loading @@ -102,7 +102,6 @@ struct usb_bam_sps_type { struct usb_bam_ctx_type { struct usb_bam_sps_type usb_bam_sps; struct resource *io_res; void __iomem *regs; int irq; struct platform_device *usb_bam_pdev; struct workqueue_struct *usb_bam_wq; Loading @@ -112,6 +111,7 @@ struct usb_bam_ctx_type { u32 inactivity_timer_ms; bool is_bam_inactivity; struct usb_bam_pipe_connect *usb_bam_connections; struct msm_usb_bam_data *usb_bam_data; spinlock_t usb_bam_lock; }; Loading @@ -125,13 +125,13 @@ static char *bam_enable_strings[MAX_BAMS] = { * CI_CTRL & DWC3_CTRL shouldn't be used simultaneously * since both share the same prod & cons rm resourses */ static enum ipa_client_type ipa_rm_resource_prod[MAX_BAMS] = { static enum ipa_rm_resource_name ipa_rm_resource_prod[MAX_BAMS] = { [CI_CTRL] = IPA_RM_RESOURCE_USB_PROD, [HSIC_CTRL] = IPA_RM_RESOURCE_HSIC_PROD, [DWC3_CTRL] = IPA_RM_RESOURCE_USB_PROD, }; static enum ipa_client_type ipa_rm_resource_cons[MAX_BAMS] = { static enum ipa_rm_resource_name ipa_rm_resource_cons[MAX_BAMS] = { [CI_CTRL] = IPA_RM_RESOURCE_USB_CONS, [HSIC_CTRL] = IPA_RM_RESOURCE_HSIC_CONS, [DWC3_CTRL] = IPA_RM_RESOURCE_USB_CONS, Loading Loading @@ -319,8 +319,6 @@ static int usb_bam_alloc_buffer(struct usb_bam_pipe_connect *pipe_connect) { int ret = 0; struct usb_bam_ctx_type *ctx = &msm_usb_bam[pipe_connect->bam_type]; struct msm_usb_bam_platform_data *pdata = ctx->usb_bam_pdev->dev.platform_data; struct sps_mem_buffer *data_buf = &(pipe_connect->data_mem_buf); struct sps_mem_buffer *desc_buf = &(pipe_connect->desc_mem_buf); Loading Loading @@ -359,7 +357,7 @@ static int usb_bam_alloc_buffer(struct usb_bam_pipe_connect *pipe_connect) } data_buf->phys_base = pipe_connect->data_fifo_base_offset + pdata->usb_bam_fifo_baseaddr; ctx->usb_bam_data->usb_bam_fifo_baseaddr; data_buf->size = pipe_connect->data_fifo_size; data_buf->base = ioremap(data_buf->phys_base, data_buf->size); if (!data_buf->base) { Loading @@ -371,7 +369,7 @@ static int usb_bam_alloc_buffer(struct usb_bam_pipe_connect *pipe_connect) memset_io(data_buf->base, 0, data_buf->size); desc_buf->phys_base = pipe_connect->desc_fifo_base_offset + pdata->usb_bam_fifo_baseaddr; ctx->usb_bam_data->usb_bam_fifo_baseaddr; desc_buf->size = pipe_connect->desc_fifo_size; desc_buf->base = ioremap(desc_buf->phys_base, desc_buf->size); if (!desc_buf->base) { Loading Loading @@ -1068,7 +1066,6 @@ int usb_bam_connect(enum usb_ctrl cur_bam, int idx, u32 *bam_pipe_idx) struct usb_bam_pipe_connect *pipe_connect = &ctx->usb_bam_connections[idx]; struct device *bam_dev = &ctx->usb_bam_pdev->dev; struct msm_usb_bam_platform_data *pdata = bam_dev->platform_data; enum usb_bam_mode cur_mode; if (pipe_connect->enabled) { Loading @@ -1094,7 +1091,7 @@ int usb_bam_connect(enum usb_ctrl cur_bam, int idx, u32 *bam_pipe_idx) spin_lock(&ctx->usb_bam_lock); /* Check if BAM requires RESET before connect and reset of first pipe */ if ((pdata->reset_on_connect == true) && if ((ctx->usb_bam_data->reset_on_connect == true) && (ctx->pipes_enabled_per_bam == 0)) { spin_unlock(&ctx->usb_bam_lock); Loading Loading @@ -1595,8 +1592,6 @@ static int ss_usb_cons_release_resource(void) static void usb_bam_ipa_create_resources(enum usb_ctrl cur_bam) { struct usb_bam_ctx_type *ctx = &msm_usb_bam[cur_bam]; struct msm_usb_bam_platform_data *pdata = ctx->usb_bam_pdev->dev.platform_data; struct ipa_rm_create_params usb_prod_create_params; struct ipa_rm_create_params usb_cons_create_params; int ret; Loading @@ -1605,7 +1600,8 @@ static void usb_bam_ipa_create_resources(enum usb_ctrl cur_bam) memset(&usb_prod_create_params, 0, sizeof(usb_prod_create_params)); usb_prod_create_params.name = ipa_rm_resource_prod[cur_bam]; usb_prod_create_params.reg_params.notify_cb = usb_prod_notify_cb; usb_prod_create_params.reg_params.user_data = &pdata->bam_type; usb_prod_create_params.reg_params.user_data = &ctx->usb_bam_data->bam_type; usb_prod_create_params.floor_voltage = IPA_VOLTAGE_SVS; ret = ipa_rm_create_resource(&usb_prod_create_params); if (ret) { Loading @@ -1628,6 +1624,22 @@ static void usb_bam_ipa_create_resources(enum usb_ctrl cur_bam) } } static void usb_bam_ipa_delete_resources(enum usb_ctrl cur_bam) { int ret; ret = ipa_rm_delete_resource(ipa_rm_resource_prod[cur_bam]); if (ret) log_event_err("%s: Failed to delete USB_PROD resource\n", __func__); ret = ipa_rm_delete_resource(ipa_rm_resource_cons[cur_bam]); if (ret) log_event_err("%s: Failed to delete USB_CONS resource\n", __func__); } static void wait_for_prod_granted(enum usb_ctrl cur_bam) { int ret; Loading Loading @@ -2134,16 +2146,14 @@ static int usb_bam_set_ipa_perf(enum usb_ctrl cur_bam, int ret; struct usb_bam_ctx_type *ctx = &msm_usb_bam[cur_bam]; struct ipa_rm_perf_profile ipa_rm_perf_prof; struct msm_usb_bam_platform_data *pdata = ctx->usb_bam_pdev->dev.platform_data; if (usb_connection_speed == USB_SPEED_SUPER) ipa_rm_perf_prof.max_supported_bandwidth_mbps = pdata->max_mbps_superspeed; ctx->usb_bam_data->max_mbps_superspeed; else /* Bam2Bam is supported only for SS and HS (HW limitation) */ ipa_rm_perf_prof.max_supported_bandwidth_mbps = pdata->max_mbps_highspeed; ctx->usb_bam_data->max_mbps_highspeed; /* * Having a max mbps property in dtsi file is a must Loading Loading @@ -2180,7 +2190,6 @@ int usb_bam_connect_ipa(enum usb_ctrl cur_bam, struct usb_bam_ctx_type *ctx = &msm_usb_bam[cur_bam]; struct usb_bam_pipe_connect *pipe_connect; struct device *bam_dev = &ctx->usb_bam_pdev->dev; struct msm_usb_bam_platform_data *pdata = bam_dev->platform_data; int ret; bool bam2bam, is_dpl; Loading Loading @@ -2256,7 +2265,8 @@ int usb_bam_connect_ipa(enum usb_ctrl cur_bam, /* Check if BAM requires RESET before connect and reset first pipe */ spin_lock(&ctx->usb_bam_lock); if (pdata->reset_on_connect && !ctx->pipes_enabled_per_bam) { if (ctx->usb_bam_data->reset_on_connect && !ctx->pipes_enabled_per_bam) { spin_unlock(&ctx->usb_bam_lock); if (cur_bam == CI_CTRL) msm_hw_bam_disable(1); Loading Loading @@ -2606,8 +2616,6 @@ int usb_bam_disconnect_pipe(enum usb_ctrl bam_type, u8 idx) struct usb_bam_pipe_connect *pipe_connect; struct device *bam_dev = &ctx->usb_bam_pdev->dev; int ret; struct msm_usb_bam_platform_data *pdata = ctx->usb_bam_pdev->dev.platform_data; pipe_connect = &ctx->usb_bam_connections[idx]; Loading Loading @@ -2635,7 +2643,8 @@ int usb_bam_disconnect_pipe(enum usb_ctrl bam_type, u8 idx) log_event_dbg("%s: success disconnecting pipe %d\n", __func__, idx); if (pdata->reset_on_disconnect && !ctx->pipes_enabled_per_bam) { if (ctx->usb_bam_data->reset_on_disconnect && !ctx->pipes_enabled_per_bam) { if (bam_type == CI_CTRL) msm_hw_bam_disable(1); Loading Loading @@ -2803,10 +2812,10 @@ static void usb_bam_sps_events(enum sps_callback_case sps_cb_case, void *user) } } static struct msm_usb_bam_platform_data *usb_bam_dt_to_pdata( static struct msm_usb_bam_data *usb_bam_dt_to_data( struct platform_device *pdev, u32 usb_addr) { struct msm_usb_bam_platform_data *pdata; struct msm_usb_bam_data *usb_bam_data; struct device_node *node = pdev->dev.of_node; int rc = 0; u8 i = 0; Loading @@ -2815,8 +2824,9 @@ static struct msm_usb_bam_platform_data *usb_bam_dt_to_pdata( u32 threshold, max_connections = 0; static struct usb_bam_pipe_connect *usb_bam_connections; pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) usb_bam_data = devm_kzalloc(&pdev->dev, sizeof(*usb_bam_data), GFP_KERNEL); if (!usb_bam_data) return NULL; rc = of_property_read_u32(node, "qcom,bam-type", &bam); Loading @@ -2830,7 +2840,7 @@ static struct msm_usb_bam_platform_data *usb_bam_dt_to_pdata( __func__, bam); return NULL; } pdata->bam_type = bam; usb_bam_data->bam_type = bam; rc = of_property_read_u32(node, "qcom,bam-mode", &bam_mode); if (rc) { Loading @@ -2840,49 +2850,49 @@ static struct msm_usb_bam_platform_data *usb_bam_dt_to_pdata( bam_mode = USB_BAM_DEVICE; } pdata->reset_on_connect = of_property_read_bool(node, usb_bam_data->reset_on_connect = of_property_read_bool(node, "qcom,reset-bam-on-connect"); pdata->reset_on_disconnect = of_property_read_bool(node, usb_bam_data->reset_on_disconnect = of_property_read_bool(node, "qcom,reset-bam-on-disconnect"); rc = of_property_read_u32(node, "qcom,usb-bam-num-pipes", &pdata->usb_bam_num_pipes); &usb_bam_data->usb_bam_num_pipes); if (rc) { log_event_err("Invalid usb bam num pipes property\n"); return NULL; } rc = of_property_read_u32(node, "qcom,usb-bam-max-mbps-highspeed", &pdata->max_mbps_highspeed); &usb_bam_data->max_mbps_highspeed); if (rc) pdata->max_mbps_highspeed = 0; usb_bam_data->max_mbps_highspeed = 0; rc = of_property_read_u32(node, "qcom,usb-bam-max-mbps-superspeed", &pdata->max_mbps_superspeed); &usb_bam_data->max_mbps_superspeed); if (rc) pdata->max_mbps_superspeed = 0; usb_bam_data->max_mbps_superspeed = 0; rc = of_property_read_u32(node, "qcom,usb-bam-fifo-baseaddr", &addr); if (rc) pr_debug("%s: Invalid usb base address property\n", __func__); else pdata->usb_bam_fifo_baseaddr = addr; usb_bam_data->usb_bam_fifo_baseaddr = addr; pdata->ignore_core_reset_ack = of_property_read_bool(node, usb_bam_data->ignore_core_reset_ack = of_property_read_bool(node, "qcom,ignore-core-reset-ack"); pdata->disable_clk_gating = of_property_read_bool(node, usb_bam_data->disable_clk_gating = of_property_read_bool(node, "qcom,disable-clk-gating"); rc = of_property_read_u32(node, "qcom,usb-bam-override-threshold", &threshold); if (rc) pdata->override_threshold = USB_THRESHOLD; usb_bam_data->override_threshold = USB_THRESHOLD; else pdata->override_threshold = threshold; usb_bam_data->override_threshold = threshold; pdata->enable_hsusb_bam_on_boot = of_property_read_bool(node, usb_bam_data->enable_hsusb_bam_on_boot = of_property_read_bool(node, "qcom,enable-hsusb-bam-on-boot"); for_each_child_of_node(pdev->dev.of_node, node) Loading Loading @@ -2918,7 +2928,7 @@ static struct msm_usb_bam_platform_data *usb_bam_dt_to_pdata( goto err; if (usb_bam_connections[i].mem_type == OCI_MEM) { if (!pdata->usb_bam_fifo_baseaddr) { if (!usb_bam_data->usb_bam_fifo_baseaddr) { log_event_err("%s: base address is missing\n", __func__); goto err; Loading Loading @@ -3002,7 +3012,7 @@ static struct msm_usb_bam_platform_data *usb_bam_dt_to_pdata( msm_usb_bam[bam].usb_bam_connections = usb_bam_connections; msm_usb_bam[bam].max_connections = max_connections; return pdata; return usb_bam_data; err: log_event_err("%s: failed\n", __func__); return NULL; Loading @@ -3011,9 +3021,8 @@ static struct msm_usb_bam_platform_data *usb_bam_dt_to_pdata( static int usb_bam_init(struct platform_device *pdev) { int ret; struct msm_usb_bam_platform_data *pdata = pdev->dev.platform_data; enum usb_ctrl bam_type = pdata->bam_type; struct usb_bam_ctx_type *ctx = &msm_usb_bam[bam_type]; struct usb_bam_ctx_type *ctx = dev_get_drvdata(&pdev->dev); enum usb_ctrl bam_type = ctx->usb_bam_data->bam_type; struct sps_bam_props props; memset(&props, 0, sizeof(props)); Loading @@ -3022,23 +3031,22 @@ static int usb_bam_init(struct platform_device *pdev) bam_enable_strings[bam_type]); props.phys_addr = ctx->io_res->start; props.virt_addr = ctx->regs; props.virt_size = resource_size(ctx->io_res); props.irq = ctx->irq; props.summing_threshold = pdata->override_threshold; props.event_threshold = pdata->override_threshold; props.num_pipes = pdata->usb_bam_num_pipes; props.summing_threshold = ctx->usb_bam_data->override_threshold; props.event_threshold = ctx->usb_bam_data->override_threshold; props.num_pipes = ctx->usb_bam_data->usb_bam_num_pipes; props.callback = usb_bam_sps_events; props.user = bam_enable_strings[bam_type]; /* * HSUSB and HSIC Cores don't support RESET ACK signal to BAMs. * Hence let BAM to ignore acknowledge from USB while resetting PIPE. * HSUSB and HSIC Cores don't support RESET ACK signal to BAMs * Hence, let BAM to ignore acknowledge from USB while resetting PIPE */ if (pdata->ignore_core_reset_ack && bam_type != DWC3_CTRL) if (ctx->usb_bam_data->ignore_core_reset_ack && bam_type != DWC3_CTRL) props.options = SPS_BAM_NO_EXT_P_RST; if (pdata->disable_clk_gating) if (ctx->usb_bam_data->disable_clk_gating) props.options |= SPS_BAM_NO_LOCAL_CLK_GATING; /* Loading @@ -3046,7 +3054,8 @@ static int usb_bam_init(struct platform_device *pdev) * starting peripheral controller to avoid switching USB core mode * from legacy to BAM with ongoing data transfers. */ if (pdata->enable_hsusb_bam_on_boot && bam_type == CI_CTRL) { if (ctx->usb_bam_data->enable_hsusb_bam_on_boot && bam_type == CI_CTRL) { pr_debug("Register and enable HSUSB BAM\n"); props.options |= SPS_BAM_OPT_ENABLE_AT_BOOT; } Loading @@ -3063,9 +3072,8 @@ static int usb_bam_init(struct platform_device *pdev) static int enable_usb_bam(struct platform_device *pdev) { int ret; struct msm_usb_bam_platform_data *pdata = pdev->dev.platform_data; enum usb_ctrl bam_type = pdata->bam_type; struct usb_bam_ctx_type *ctx = &msm_usb_bam[bam_type]; struct usb_bam_ctx_type *ctx = dev_get_drvdata(&pdev->dev); enum usb_ctrl bam_type = ctx->usb_bam_data->bam_type; ret = usb_bam_init(pdev); if (ret) { Loading Loading @@ -3132,14 +3140,19 @@ void usb_bam_register_panic_hdlr(void) &usb_bam_panic_blk); } static void usb_bam_unregister_panic_hdlr(void) { atomic_notifier_chain_unregister(&panic_notifier_list, &usb_bam_panic_blk); } static int usb_bam_probe(struct platform_device *pdev) { int ret, i, irq; struct resource *io_res; void __iomem *regs; enum usb_ctrl bam_type; struct usb_bam_ctx_type *ctx; struct msm_usb_bam_platform_data *pdata; struct msm_usb_bam_data *usb_bam_data; dev_dbg(&pdev->dev, "usb_bam_probe\n"); Loading @@ -3155,25 +3168,19 @@ static int usb_bam_probe(struct platform_device *pdev) return irq; } regs = devm_ioremap(&pdev->dev, io_res->start, resource_size(io_res)); if (!regs) { log_event_err("%s: ioremap failed\n", __func__); return -ENOMEM; } /* specify BAM physical address to be filled in BAM connections */ pdata = usb_bam_dt_to_pdata(pdev, io_res->start); if (!pdata) usb_bam_data = usb_bam_dt_to_data(pdev, io_res->start); if (!usb_bam_data) return -EINVAL; pdev->dev.platform_data = pdata; bam_type = pdata->bam_type; bam_type = usb_bam_data->bam_type; ctx = &msm_usb_bam[bam_type]; dev_set_drvdata(&pdev->dev, ctx); ctx->usb_bam_pdev = pdev; ctx->irq = irq; ctx->regs = regs; ctx->io_res = io_res; ctx->usb_bam_data = usb_bam_data; for (i = 0; i < ctx->max_connections; i++) { ctx->usb_bam_connections[i].enabled = 0; Loading Loading @@ -3314,15 +3321,15 @@ EXPORT_SYMBOL(usb_bam_get_bam_type); bool msm_usb_bam_enable(enum usb_ctrl bam, bool bam_enable) { struct msm_usb_bam_platform_data *pdata; struct msm_usb_bam_data *usb_bam_data; struct usb_bam_ctx_type *ctx = &msm_usb_bam[bam]; if (!ctx->usb_bam_pdev) return 0; pdata = ctx->usb_bam_pdev->dev.platform_data; usb_bam_data = ctx->usb_bam_data; if ((bam != CI_CTRL) || !(bam_enable || pdata->enable_hsusb_bam_on_boot)) usb_bam_data->enable_hsusb_bam_on_boot)) return 0; msm_hw_bam_disable(1); Loading Loading @@ -3404,10 +3411,11 @@ EXPORT_SYMBOL(msm_bam_hsic_lpm_ok); static int usb_bam_remove(struct platform_device *pdev) { struct msm_usb_bam_platform_data *pdata = pdev->dev.platform_data; enum usb_ctrl bam_type = pdata->bam_type; struct usb_bam_ctx_type *ctx = &msm_usb_bam[bam_type]; struct usb_bam_ctx_type *ctx = dev_get_drvdata(&pdev->dev); usb_bam_ipa_delete_resources(ctx->usb_bam_data->bam_type); usb_bam_unregister_panic_hdlr(); sps_deregister_bam_device(ctx->h_bam); destroy_workqueue(ctx->usb_bam_wq); return 0; Loading
drivers/usb/dwc3/core.c +3 −2 Original line number Diff line number Diff line Loading @@ -428,6 +428,9 @@ static void dwc3_event_buffers_cleanup(struct dwc3 *dwc) { struct dwc3_event_buffer *evt; if (!dwc->ev_buf) return; evt = dwc->ev_buf; evt->lpos = 0; Loading Loading @@ -692,8 +695,6 @@ static void dwc3_core_exit(struct dwc3 *dwc) phy_exit(dwc->usb2_generic_phy); phy_exit(dwc->usb3_generic_phy); usb_phy_set_suspend(dwc->usb2_phy, 1); usb_phy_set_suspend(dwc->usb3_phy, 1); phy_power_off(dwc->usb2_generic_phy); phy_power_off(dwc->usb3_generic_phy); } Loading
drivers/usb/dwc3/dwc3-msm.c +9 −0 Original line number Diff line number Diff line Loading @@ -1867,6 +1867,9 @@ static void dwc3_msm_notify_event(struct dwc3 *dwc, unsigned int event) dev_dbg(mdwc->dev, "DWC3_GSI_EVT_BUF_SETUP\n"); for (i = 0; i < mdwc->num_gsi_event_buffers; i++) { evt = mdwc->gsi_ev_buff[i]; if (!evt) break; dev_dbg(mdwc->dev, "Evt buf %p dma %08llx length %d\n", evt->buf, (unsigned long long) evt->dma, evt->length); Loading @@ -1892,6 +1895,9 @@ static void dwc3_msm_notify_event(struct dwc3 *dwc, unsigned int event) break; case DWC3_GSI_EVT_BUF_CLEANUP: dev_dbg(mdwc->dev, "DWC3_GSI_EVT_BUF_CLEANUP\n"); if (!mdwc->gsi_ev_buff) break; for (i = 0; i < mdwc->num_gsi_event_buffers; i++) { evt = mdwc->gsi_ev_buff[i]; evt->lpos = 0; Loading @@ -1911,6 +1917,9 @@ static void dwc3_msm_notify_event(struct dwc3 *dwc, unsigned int event) break; case DWC3_GSI_EVT_BUF_FREE: dev_dbg(mdwc->dev, "DWC3_GSI_EVT_BUF_FREE\n"); if (!mdwc->gsi_ev_buff) break; for (i = 0; i < mdwc->num_gsi_event_buffers; i++) { evt = mdwc->gsi_ev_buff[i]; if (evt) Loading
include/linux/usb_bam.h +2 −2 Original line number Diff line number Diff line Loading @@ -198,7 +198,7 @@ struct usb_bam_pipe_connect { }; /** * struct msm_usb_bam_platform_data: pipe connection information * struct msm_usb_bam_data: pipe connection information * between USB/HSIC BAM and another BAM. USB/HSIC BAM can be * either src BAM or dst BAM * @usb_bam_num_pipes: max number of pipes to use. Loading @@ -218,7 +218,7 @@ struct usb_bam_pipe_connect { * can work at in bam2bam mode when connected to SS host. * @enable_hsusb_bam_on_boot: Enable HSUSB BAM (non-NDP) on bootup itself */ struct msm_usb_bam_platform_data { struct msm_usb_bam_data { u8 max_connections; int usb_bam_num_pipes; phys_addr_t usb_bam_fifo_baseaddr; Loading