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

Commit 0ea2cb70 authored by Jack Pham's avatar Jack Pham
Browse files

usb: host: ehci-msm2: Add bus voting support to driver



The controller driver may need to update MSM BUS client parameters
in order to vote for required bandwidth guarantees from the bus
(NOC, fabric, memory, etc.). Add support for msm_bus voting to
the driver. The specific parameters can be specified in device tree.

Change-Id: Ide84d28f95e23e77a6091f6a749796295d4ffa80
Signed-off-by: default avatarJack Pham <jackp@codeaurora.org>
parent df3f9b21
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -248,7 +248,12 @@ Optional properties :
- qcom,pm-qos-latency: This property represents the maximum tolerable CPU latency in
  microsecs, which is used as a vote to keep the CPUs in a high enough power state when
  USB bus is in use (not suspended).

- Refer to "Documentation/devicetree/bindings/arm/msm/msm-bus.txt" for
  below optional properties:
    - qcom,msm-bus,name
    - qcom,msm-bus,num_cases - Two cases (NONE and MAX) for voting are supported.
    - qcom,msm-bus,num_paths
    - qcom,msm-bus,vectors

Example MSM HSUSB EHCI controller device node :
	ehci: qcom,ehci-host@f9a55000 {
+33 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@
#include <linux/of_gpio.h>
#include <linux/irq.h>
#include <linux/clk/msm-clk.h>
#include <linux/msm-bus.h>

#include <linux/usb/ulpi.h>
#include <linux/usb/msm_hsusb_hw.h>
@@ -95,6 +96,8 @@ struct msm_hcd {
	void __iomem				*usb_phy_ctrl_reg;
	struct pinctrl				*hsusb_pinctrl;
	struct pm_qos_request			pm_qos_req_dma;
	struct msm_bus_scale_pdata		*bus_scale_table;
	u32					bus_perf_client;
};

static inline struct msm_hcd *hcd_to_mhcd(struct usb_hcd *hcd)
@@ -804,6 +807,13 @@ static int msm_ehci_suspend(struct msm_hcd *mhcd)
		enable_irq(mhcd->async_irq);
	}

	if (mhcd->bus_perf_client) {
		int ret = msm_bus_scale_client_update_request(
						mhcd->bus_perf_client, 0);
		if (ret)
			dev_err(mhcd->dev, "Failed to vote for bus scaling\n");
	}

	pm_qos_update_request(&mhcd->pm_qos_req_dma, PM_QOS_DEFAULT_VALUE);

	pm_relax(mhcd->dev);
@@ -862,6 +872,14 @@ static int msm_ehci_resume(struct msm_hcd *mhcd)
	if (pdata)
		pm_qos_update_request(&mhcd->pm_qos_req_dma,
			pdata->pm_qos_latency + 1);

	if (mhcd->bus_perf_client) {
		int ret = msm_bus_scale_client_update_request(
						mhcd->bus_perf_client, 1);
		if (ret)
			dev_err(mhcd->dev, "Failed to vote for bus scaling\n");
	}

	/* Vote for TCXO when waking up the phy */
	if (mhcd->xo_clk)
		clk_prepare_enable(mhcd->xo_clk);
@@ -1553,6 +1571,18 @@ static int ehci_msm2_probe(struct platform_device *pdev)
		goto vbus_deinit;
	}

	mhcd->bus_scale_table = msm_bus_cl_get_pdata(pdev);
	if (!mhcd->bus_scale_table) {
		dev_dbg(&pdev->dev, "bus scaling is disabled\n");
	} else {
		mhcd->bus_perf_client =
			msm_bus_scale_register_client(mhcd->bus_scale_table);
		ret = msm_bus_scale_client_update_request(
						mhcd->bus_perf_client, 1);
		if (ret)
			dev_err(&pdev->dev, "Failed to vote for bus scaling\n");
	}

	pdata = mhcd->dev->platform_data;
	if (pdata && (!pdata->dock_connect_irq ||
				!irq_read_line(pdata->dock_connect_irq)))
@@ -1693,6 +1723,9 @@ static int ehci_msm2_remove(struct platform_device *pdev)

	usb_remove_hcd(hcd);

	if (mhcd->bus_perf_client)
		msm_bus_scale_unregister_client(mhcd->bus_perf_client);

	pdata = pdev->dev.platform_data;
	if (pdata && pdata->pm_qos_latency)
		pm_qos_remove_request(&mhcd->pm_qos_req_dma);