mbox series

[0/3] USB DWC3 QCOM Multi power domain support

Message ID 1630346073-7099-1-git-send-email-sanm@codeaurora.org
Headers show
Series USB DWC3 QCOM Multi power domain support | expand

Message

Sandeep Maheswaram Aug. 30, 2021, 5:54 p.m. UTC
Add multi pd support to set performance state for cx domain
to maintain minimum corner voltage for USB clocks.

Add corresponding dt bindings, driver changes and dt changes.

Sandeep Maheswaram (3):
  dt-bindings: usb: qcom,dwc3: Add multi-pd bindings for dwc3 qcom
  usb: dwc3: qcom: Add multi-pd support
  arm64: dts: qcom: sc7280: Add cx power domain support

 .../devicetree/bindings/usb/qcom,dwc3.yaml         | 13 +++++-
 arch/arm64/boot/dts/qcom/sc7280.dtsi               |  5 ++-
 drivers/usb/dwc3/dwc3-qcom.c                       | 49 ++++++++++++++++++++++
 3 files changed, 65 insertions(+), 2 deletions(-)

Comments

Felipe Balbi Aug. 31, 2021, 5:34 a.m. UTC | #1
Hi,

Sandeep Maheswaram <sanm@codeaurora.org> writes:
> Add multi pd support to set performance state for cx domain
> to maintain minimum corner voltage for USB clocks.
>
> Signed-off-by: Sandeep Maheswaram <sanm@codeaurora.org>
> ---
>  drivers/usb/dwc3/dwc3-qcom.c | 49 ++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 49 insertions(+)
>
> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> index 9abbd01..777a647 100644
> --- a/drivers/usb/dwc3/dwc3-qcom.c
> +++ b/drivers/usb/dwc3/dwc3-qcom.c
> @@ -17,6 +17,7 @@
>  #include <linux/of_platform.h>
>  #include <linux/platform_device.h>
>  #include <linux/phy/phy.h>
> +#include <linux/pm_domain.h>
>  #include <linux/usb/of.h>
>  #include <linux/reset.h>
>  #include <linux/iopoll.h>
> @@ -89,6 +90,10 @@ struct dwc3_qcom {
>  	bool			pm_suspended;
>  	struct icc_path		*icc_path_ddr;
>  	struct icc_path		*icc_path_apps;
> +	/* power domain for cx */
> +	struct device		*pd_cx;
> +	/* power domain for usb gdsc */
> +	struct device		*pd_usb_gdsc;
>  };
>  
>  static inline void dwc3_qcom_setbits(void __iomem *base, u32 offset, u32 val)
> @@ -521,6 +526,46 @@ static int dwc3_qcom_setup_irq(struct platform_device *pdev)
>  	return 0;
>  }
>  
> +static int dwc3_qcom_attach_pd(struct device *dev)
> +{
> +	struct dwc3_qcom *qcom = dev_get_drvdata(dev);
> +	struct device_link *link;
> +
> +	/* Do nothing when in a single power domain */
> +	if (dev->pm_domain)
> +		return 0;
> +
> +	qcom->pd_cx = dev_pm_domain_attach_by_name(dev, "cx");
> +	if (IS_ERR(qcom->pd_cx))
> +		return PTR_ERR(qcom->pd_cx);
> +	/* Do nothing when power domain missing */
> +	if (!qcom->pd_cx)
> +		return 0;
> +	link = device_link_add(dev, qcom->pd_cx,
> +			DL_FLAG_STATELESS |
> +			DL_FLAG_PM_RUNTIME |
> +			DL_FLAG_RPM_ACTIVE);
> +	if (!link) {
> +		dev_err(dev, "Failed to add device_link to cx pd.\n");

do you need to call dev_pm_domain_dettach() here?

> +		return -EINVAL;
> +	}
> +
> +	qcom->pd_usb_gdsc = dev_pm_domain_attach_by_name(dev, "usb_gdsc");
> +	if (IS_ERR(qcom->pd_usb_gdsc))

do you need to call dev_pm_domain_dettach() here?

> +		return PTR_ERR(qcom->pd_usb_gdsc);
> +
> +	link = device_link_add(dev, qcom->pd_usb_gdsc,
> +			DL_FLAG_STATELESS |
> +			DL_FLAG_PM_RUNTIME |
> +			DL_FLAG_RPM_ACTIVE);
> +	if (!link) {
> +		dev_err(dev, "Failed to add device_link to usb gdsc pd.\n");

do you need to call dev_pm_domain_dettach() here?