Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752918AbcD0FiJ (ORCPT ); Wed, 27 Apr 2016 01:38:09 -0400 Received: from mga04.intel.com ([192.55.52.120]:63622 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752641AbcD0FiG (ORCPT ); Wed, 27 Apr 2016 01:38:06 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,540,1455004800"; d="asc'?scan'208";a="793216754" 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 , Kishon Vijay Abraham I Subject: Re: [RESEND PATCH v2 6/7] usb: xhci: plat: add generic PHY support In-Reply-To: <1461675460-2295-7-git-send-email-jszhang@marvell.com> References: <1461675460-2295-1-git-send-email-jszhang@marvell.com> <1461675460-2295-7-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:35:58 +0300 Message-ID: <87eg9rpq9t.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: 6039 Lines: 217 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi, Jisheng Zhang writes: > Marvell BG4CT SoC needs two phy: one for usb2 and another for usb3. Add > the calls to retrieve generic PHY to xhci plat in order to support this. > > Signed-off-by: Jisheng Zhang > --- > drivers/usb/host/xhci-plat.c | 87 ++++++++++++++++++++++++++++++++++++++= ------ > 1 file changed, 75 insertions(+), 12 deletions(-) > > diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c > index 83669d0..d7f4f3c 100644 > --- a/drivers/usb/host/xhci-plat.c > +++ b/drivers/usb/host/xhci-plat.c > @@ -16,6 +16,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -134,6 +135,37 @@ static const struct of_device_id usb_xhci_of_match[]= =3D { > MODULE_DEVICE_TABLE(of, usb_xhci_of_match); > #endif >=20=20 > +static int xhci_plat_phy_init(struct usb_hcd *hcd) > +{ > + int ret; > + > + if (hcd->phy) { > + ret =3D phy_init(hcd->phy); > + if (ret) > + return ret; > + > + ret =3D phy_power_on(hcd->phy); > + if (ret) { > + phy_exit(hcd->phy); > + return ret; > + } > + } else { > + ret =3D usb_phy_init(hcd->usb_phy); > + } > + > + return ret; > +} > + > +static void xhci_plat_phy_exit(struct usb_hcd *hcd) > +{ > + if (hcd->phy) { > + phy_power_off(hcd->phy); > + phy_exit(hcd->phy); > + } else { > + usb_phy_shutdown(hcd->usb_phy); > + } > +} > + > static int xhci_plat_probe(struct platform_device *pdev) > { > struct device_node *node =3D pdev->dev.of_node; > @@ -145,6 +177,7 @@ static int xhci_plat_probe(struct platform_device *pd= ev) > struct usb_hcd *hcd; > struct clk *clk; > struct usb_phy *usb_phy; > + struct phy *phy; so, one phy driver using USB PHY layer and another using generic PHY layer ? Why ? I think the first thing your series should do would be to add proper suport for both APIs with two PHYs and make them all optional for xhci-plat. > @@ -232,22 +265,44 @@ static int xhci_plat_probe(struct platform_device *= pdev) > if (HCC_MAX_PSA(xhci->hcc_params) >=3D 4) > xhci->shared_hcd->can_do_streams =3D 1; >=20=20 > + hcd->phy =3D devm_phy_get(&pdev->dev, "usb2-phy"); > + if (IS_ERR(hcd->phy)) { > + ret =3D PTR_ERR(hcd->phy); > + if (ret =3D=3D -EPROBE_DEFER) > + goto put_usb3_hcd; > + hcd->phy =3D NULL; > + } > + > + phy =3D devm_phy_get(&pdev->dev, "usb-phy"); > + if (IS_ERR(phy)) { > + ret =3D PTR_ERR(phy); > + if (ret =3D=3D -EPROBE_DEFER) > + goto put_usb3_hcd; > + phy =3D NULL; > + } > + > usb_phy =3D devm_usb_get_phy_by_phandle(&pdev->dev, "usb-phy", 0); > if (IS_ERR(usb_phy)) { > ret =3D PTR_ERR(usb_phy); > if (ret =3D=3D -EPROBE_DEFER) > goto put_usb3_hcd; > usb_phy =3D NULL; > - } else { > - ret =3D usb_phy_init(usb_phy); > - if (ret) > - goto put_usb3_hcd; > } > + > xhci->shared_hcd->usb_phy =3D usb_phy; > + xhci->shared_hcd->phy =3D phy; > + > + ret =3D xhci_plat_phy_init(hcd); > + if (ret) > + goto put_usb3_hcd; > + > + ret =3D xhci_plat_phy_init(xhci->shared_hcd); > + if (ret) > + goto disable_usb2_phy; >=20=20 > ret =3D usb_add_hcd(hcd, irq, IRQF_SHARED); > if (ret) > - goto disable_usb_phy; > + goto disable_usb3_phy; >=20=20 > ret =3D usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED); > if (ret) > @@ -259,8 +314,11 @@ static int xhci_plat_probe(struct platform_device *p= dev) > dealloc_usb2_hcd: > usb_remove_hcd(hcd); >=20=20 > -disable_usb_phy: > - usb_phy_shutdown(usb_phy); > +disable_usb3_phy: > + xhci_plat_phy_exit(xhci->shared_hcd); > + > +disable_usb2_phy: > + xhci_plat_phy_exit(hcd); >=20=20 > put_usb3_hcd: > usb_put_hcd(xhci->shared_hcd); > @@ -281,11 +339,11 @@ static int xhci_plat_remove(struct platform_device = *dev) > struct clk *clk =3D xhci->clk; >=20=20 > usb_remove_hcd(xhci->shared_hcd); > - usb_phy_shutdown(xhci->shared_hcd->usb_phy); > - > - usb_remove_hcd(hcd); > + xhci_plat_phy_exit(xhci->shared_hcd); > usb_put_hcd(xhci->shared_hcd); >=20=20 > + usb_remove_hcd(hcd); > + xhci_plat_phy_exit(hcd); > clk_disable_unprepare(clk); > usb_put_hcd(hcd); >=20=20 > @@ -311,7 +369,8 @@ static int xhci_plat_suspend(struct device *dev) > if (ret) > return ret; >=20=20 > - usb_phy_shutdown(xhci->shared_hcd->usb_phy); > + xhci_plat_phy_exit(xhci->shared_hcd); > + xhci_plat_phy_exit(hcd); > clk_disable_unprepare(xhci->clk); >=20=20 > return ret; > @@ -327,7 +386,11 @@ static int xhci_plat_resume(struct device *dev) > if (ret) > return ret; >=20=20 > - ret =3D usb_phy_init(xhci->shared_hcd->usb_phy); > + ret =3D xhci_plat_phy_init(hcd); > + if (ret) > + return ret; > + > + ret =3D xhci_plat_phy_init(xhci->shared_hcd); > if (ret) > return ret; >=20=20 > --=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 iQIcBAEBAgAGBQJXIE+/AAoJEIaOsuA1yqREF98P/2qS2I/BDj5y48hZVmqcyYyl aRe4MCqeCA2fGgtnO3Ey26nGBh1P/QTudxz4FFp7bZ1gEyYAotsP/ghJKAO6q3i+ 4dlf1p5yKbiOP5k5Sk+IjewJfZBWW1kdHHcqVIdTZwbW44ElkMh8rU84UROMDNyw UTmiCnSa7NYcGE8iz3vxgmZiRTrx/Yei4h2J81fhm+7oVozTPa8Fa1ZD/Fxj26O+ wG2EWvEe6uZhB6G1Fa3dRdyQCUPCX82JgXWD6UFBgRHloJx9BlF3MTp3xpssi7G2 W1YOBZ/KPnIWhlJv2x9DnLI1cPhSa8N9dCok7a7rIpwEsZ/EvPwj3xPHD4L5kaax jBpjLoZ+EsVXYW81KBiAomN7XWPTLRYSe2KLLbHkvTWDrV4LQeMQvWwiW3W0xbV5 9DbiaT8r5n3innH72d0v702G5u+8TGC9Zr8r75zrwvVwaMqaRWMOiI1MY7xseWew a4itT0mhwfezZLSrKnhm4klkwDuguhhiM+eIJTpQfi8DMraVCa/4d80+DshirxlV ePamvPL0ub4VkUD26xJOZ7CWEodIGD/FImpoeOzglj5oa8hswSYhX4PVagyBcObb lujrwUZpLsf2G+DFoQIj05xfihR6J+ACf2OIWKr0WeCqdKrE+9CJshBisr+3W1wL g2Lc2OaVg0M/etwG5nWJ =DmIj -----END PGP SIGNATURE----- --=-=-=--