Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753018AbcD0Fj3 (ORCPT ); Wed, 27 Apr 2016 01:39:29 -0400 Received: from mga04.intel.com ([192.55.52.120]:20343 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752622AbcD0Fj2 (ORCPT ); Wed, 27 Apr 2016 01:39:28 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,540,1455004800"; d="asc'?scan'208";a="963570478" From: Felipe Balbi To: Jisheng Zhang , mathias.nyman@linux.intel.com, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, yendapally.reddy@broadcom.com, Jisheng Zhang , Mark Brown Subject: Re: [RESEND PATCH v2 7/7] usb: xhci: plat: add vbus regulator control In-Reply-To: <1461675460-2295-8-git-send-email-jszhang@marvell.com> References: <1461675460-2295-1-git-send-email-jszhang@marvell.com> <1461675460-2295-8-git-send-email-jszhang@marvell.com> User-Agent: Notmuch/0.21+96~g9bbc54b (http://notmuchmail.org) Emacs/25.0.90.3 (x86_64-pc-linux-gnu) Date: Wed, 27 Apr 2016 08:37:20 +0300 Message-ID: <87bn4vpq7j.fsf@intel.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5503 Lines: 188 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi, Jisheng Zhang writes: > The Marvell BG4CT STB board has board level vbus control through gpio. > This patch adds the vbus regulator control to support this board. > > Signed-off-by: Jisheng Zhang > --- > drivers/usb/host/xhci-plat.c | 40 ++++++++++++++++++++++++++++++++++++++= +- > drivers/usb/host/xhci.h | 2 ++ > 2 files changed, 41 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c > index d7f4f3c..0310c13 100644 > --- a/drivers/usb/host/xhci-plat.c > +++ b/drivers/usb/host/xhci-plat.c > @@ -18,6 +18,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -178,6 +179,7 @@ static int xhci_plat_probe(struct platform_device *pd= ev) > struct clk *clk; > struct usb_phy *usb_phy; > struct phy *phy; > + struct regulator *vbus; > int ret; > int irq; >=20=20 > @@ -249,13 +251,30 @@ static int xhci_plat_probe(struct platform_device *= pdev) >=20=20 > device_wakeup_enable(hcd->self.controller); >=20=20 > + vbus =3D devm_regulator_get(&pdev->dev, "vbus"); devm_regulator_get_optional() ?? > + if (PTR_ERR(vbus) =3D=3D -ENODEV) { > + vbus =3D NULL; > + } else if (IS_ERR(vbus)) { > + ret =3D PTR_ERR(vbus); > + goto disable_clk; > + } else if (vbus) { > + ret =3D regulator_enable(vbus); > + if (ret) { > + dev_err(&pdev->dev, > + "failed to enable usb vbus regulator: %d\n", > + ret); > + goto disable_clk; > + } > + } > + > xhci->clk =3D clk; > + xhci->vbus =3D vbus; > xhci->main_hcd =3D hcd; > xhci->shared_hcd =3D usb_create_shared_hcd(driver, &pdev->dev, > dev_name(&pdev->dev), hcd); > if (!xhci->shared_hcd) { > ret =3D -ENOMEM; > - goto disable_clk; > + goto disable_vbus; > } >=20=20 > if ((node && of_property_read_bool(node, "usb3-lpm-capable")) || > @@ -323,6 +342,10 @@ disable_usb2_phy: > put_usb3_hcd: > usb_put_hcd(xhci->shared_hcd); >=20=20 > +disable_vbus: > + if (vbus) > + regulator_disable(vbus); > + > disable_clk: > clk_disable_unprepare(clk); >=20=20 > @@ -337,6 +360,7 @@ static int xhci_plat_remove(struct platform_device *d= ev) > struct usb_hcd *hcd =3D platform_get_drvdata(dev); > struct xhci_hcd *xhci =3D hcd_to_xhci(hcd); > struct clk *clk =3D xhci->clk; > + struct regulator *vbus =3D xhci->vbus; >=20=20 > usb_remove_hcd(xhci->shared_hcd); > xhci_plat_phy_exit(xhci->shared_hcd); > @@ -347,6 +371,9 @@ static int xhci_plat_remove(struct platform_device *d= ev) > clk_disable_unprepare(clk); > usb_put_hcd(hcd); >=20=20 > + if (vbus) > + regulator_disable(vbus); > + > return 0; > } >=20=20 > @@ -356,6 +383,7 @@ static int xhci_plat_suspend(struct device *dev) > int ret; > struct usb_hcd *hcd =3D dev_get_drvdata(dev); > struct xhci_hcd *xhci =3D hcd_to_xhci(hcd); > + struct regulator *vbus =3D xhci->vbus; >=20=20 > /* > * xhci_suspend() needs `do_wakeup` to know whether host is allowed > @@ -373,6 +401,9 @@ static int xhci_plat_suspend(struct device *dev) > xhci_plat_phy_exit(hcd); > clk_disable_unprepare(xhci->clk); >=20=20 > + if (vbus) > + ret =3D regulator_disable(vbus); > + > return ret; > } >=20=20 > @@ -381,11 +412,18 @@ static int xhci_plat_resume(struct device *dev) > int ret; > struct usb_hcd *hcd =3D dev_get_drvdata(dev); > struct xhci_hcd *xhci =3D hcd_to_xhci(hcd); > + struct regulator *vbus =3D xhci->vbus; >=20=20 > ret =3D clk_prepare_enable(xhci->clk); > if (ret) > return ret; >=20=20 > + if (vbus) { > + ret =3D regulator_enable(vbus); > + if (ret) > + return ret; > + } > + > ret =3D xhci_plat_phy_init(hcd); > if (ret) > return ret; > diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h > index 6c629c9..5fa8662 100644 > --- a/drivers/usb/host/xhci.h > +++ b/drivers/usb/host/xhci.h > @@ -1550,6 +1550,8 @@ struct xhci_hcd { > struct msix_entry *msix_entries; > /* optional clock */ > struct clk *clk; > + /* optional regulator */ > + struct regulator *vbus; > /* data structures */ > struct xhci_device_context_array *dcbaa; > struct xhci_ring *cmd_ring; > --=20 > 2.8.1 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-usb" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html =2D-=20 balbi --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXIFARAAoJEIaOsuA1yqREkGIP/2xV0A3BUgg0MJVpFFgF405V uPs4ToPlXWLQGbpZxgGkrTlW9lp2E89SIbbcCXrZbtWWPC9ZNg376/7qitTcCEaG 3a8tF+TVPp8fcuaOCGDR0lAtpjHc6Sg6F+JXaz6CjWuggyN3+goAttS/IlpJGWQw m0AkMJuR1ISwZAP8KoUKjd6IxclpJOg2GbGAix3L1oy5N1pr6jfU8wZBU2D85tr5 WDK7oHCC+76XwyDlaXOwEvR51oLOi/eE+lOyCkKzcC7tCmQonYgPPiJiu5sj9rju B2ZsC/cOTZnEscWVea+qigX0G3Fi16yfNXsnIfMbxJkrAmVZGtF9+odm4h87dWhw cd/VB+26FYuk2RxsObyYIsaanz3Ye/79aWu2506Ld6E6aLpOT51/DLG7LMl5/ABn 4KTnA2rbAwn311MGT0qtcw65Oq1ZYXbti29HUrlYtm0/Y7RGPO9XV8lewjE20MI6 ENrNbZAfneXNB2nycP6W3slaBw514xKkLgt5lxOywtbsGSNcrEGIRPg1jV4hrjfG MczZW0dyB0iPca0X0XZisvk8ZOc4INvG4WMg/CpECSupHSi9DK8BFFfWzgTFKiIz 4PkGE0xs/kvPU9BxVR6fV8CxWLgAe1hlxlv9kGwKTyZXpQEyZ6vxLIDBhsW5enAy 2079s9bT0nUhMVhaXMVe =jBZX -----END PGP SIGNATURE----- --=-=-=--