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

Commit 97f6f5b2 authored by Vijayavardhan Vennapusa's avatar Vijayavardhan Vennapusa Committed by Manu Gautam
Browse files

usb_bam: Allow HSUSB BAM to be enabled on bootup itself



HSUSB BAM is not NDP BAM and it must be enabled early before
starting peripheral controller to avoid switching USB core mode
from legacy to BAM with ongoing data transfers.
Also, there could be a possibility that USB OTG driver puts USB
in LPM after its probe incase USB is not connected and before
USB BAM driver is probed. This may result in unclocked access
while enabling USB BAM. To handle this make sure that USB BAM
is probed only after USB OTG and use pm_runtime APIs before
enabling HSUSB BAM.

CRs-Fixed: 848418
Change-Id: I0a5be01e5361ffa10e72b539930cf5e08497621a
Signed-off-by: default avatarVijayavardhan Vennapusa <vvreddy@codeaurora.org>
parent da880e97
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -2327,8 +2327,11 @@ int usb_bam_connect_ipa(struct usb_bam_connect_ipa_params *ipa_params)

		/* On re-connect assume out from lpm for all BAMs */
		info[cur_bam].in_lpm = false;
	} else
	} else {
		spin_unlock(&usb_bam_lock);
		if (!ctx.pipes_enabled_per_bam[cur_bam])
			pr_debug("No BAM reset on connect, just pipe reset\n");
	}

	if (ipa_params->dir == USB_TO_PEER_PERIPHERAL) {
		if (info[cur_bam].prod_pipes_enabled_per_bam == 0)
@@ -2866,6 +2869,8 @@ static struct msm_usb_bam_platform_data *usb_bam_dt_to_pdata(
	else
		pdata->override_threshold = threshold;

	pdata->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)
		ctx.max_connections++;
@@ -3078,7 +3083,17 @@ static int usb_bam_init(int bam_type)
	if (pdata->disable_clk_gating)
		props.options |= SPS_BAM_NO_LOCAL_CLK_GATING;

	/*
	 * HSUSB BAM is not NDP BAM and it must be enabled early before
	 * 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) {
		pr_debug("Register and enable HSUSB BAM\n");
		props.options |= SPS_BAM_OPT_ENABLE_AT_BOOT;
	}
	ret = sps_register_bam_device(&props, &(ctx.h_bam[bam_type]));

	if (ret < 0) {
		pr_err("%s: register bam error %d\n", __func__, ret);
		ret = -EFAULT;
@@ -3224,6 +3239,11 @@ static int usb_bam_probe(struct platform_device *pdev)

	dev_dbg(&pdev->dev, "usb_bam_probe\n");

	if (!usb_device) {
		pr_err("OTG not yet probed\n");
		return -EPROBE_DEFER;
	}

	ret = device_create_file(&pdev->dev, &dev_attr_inactivity_timer);
	if (ret) {
		dev_err(&pdev->dev, "failed to create fs node\n");
+2 −0
Original line number Diff line number Diff line
@@ -210,6 +210,7 @@ struct usb_bam_pipe_connect {
 *		can work at in bam2bam mode when connected to HS host.
 * @max_mbps_superspeed: Maximum Mbits per seconds that the USB core
 *		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 usb_bam_pipe_connect *connections;
@@ -222,6 +223,7 @@ struct msm_usb_bam_platform_data {
	u32 override_threshold;
	u32 max_mbps_highspeed;
	u32 max_mbps_superspeed;
	bool enable_hsusb_bam_on_boot;
};

#ifdef CONFIG_USB_BAM