Re: [PATCH 3/4] usb: add support to the PHY framework for HCD

From: Antoine Ténart
Date: Tue Jul 15 2014 - 05:09:55 EST


Hi Vivek,

On Mon, Jul 14, 2014 at 02:38:03PM +0530, Vivek Gautam wrote:
> On Wed, Jul 9, 2014 at 3:47 PM, Antoine Ténart
> <antoine.tenart@xxxxxxxxxxxxxxxxxx> wrote:
> > diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
> > index bec31e2efb88..b985af5b167c 100644
> > --- a/drivers/usb/core/hcd.c
> > +++ b/drivers/usb/core/hcd.c
> > @@ -42,6 +42,7 @@
> > #include <linux/pm_runtime.h>
> > #include <linux/types.h>
> >
> > +#include <linux/phy/phy.h>
> > #include <linux/usb.h>
> > #include <linux/usb/hcd.h>
> > #include <linux/usb/phy.h>
> > @@ -2631,21 +2632,35 @@ int usb_add_hcd(struct usb_hcd *hcd,
> > int retval;
> > struct usb_device *rhdev;
> >
> > - if (IS_ENABLED(CONFIG_USB_PHY) && !hcd->phy) {
> > - struct usb_phy *phy = usb_get_phy_dev(hcd->self.controller, 0);
> > + if (IS_ENABLED(CONFIG_USB_PHY) && !hcd->phy && !hcd->usb_phy) {
> > + struct phy *phy = of_phy_get(hcd->self.controller->of_node, 0);
> >
> > - if (IS_ERR(phy)) {
> > - retval = PTR_ERR(phy);
> > - if (retval == -EPROBE_DEFER)
> > - return retval;
> > - } else {
> > - retval = usb_phy_init(phy);
> > + if (!IS_ERR(phy)) {
> > + retval = phy_init(hcd->phy);
> > if (retval) {
> > - usb_put_phy(phy);
> > + phy_exit(hcd->phy);
> > return retval;
> > }
> > + retval = phy_power_on(hcd->phy);
> > hcd->phy = phy;
> > hcd->remove_phy = 1;
> > + } else {
> > + struct usb_phy *phy =
> > + usb_get_phy_dev(hcd->self.controller, 0);
> > +
> > + if (IS_ERR(phy)) {
> > + retval = PTR_ERR(phy);
> > + if (retval == -EPROBE_DEFER)
> > + return retval;
> > + } else {
> > + retval = usb_phy_init(phy);
> > + if (retval) {
> > + usb_put_phy(phy);
> > + return retval;
> > + }
> > + hcd->usb_phy = phy;
> > + hcd->remove_phy = 1;
> > + }
> > }
> > }
>
> Just a note here:
> There had already been a patch for adding the generic phy support in
> usb/core/hcd.c in 3.16 cycle by
> Sergei and Yoshihiro [1], though structurally a bit different, was not
> picked since there wasn't any user of the patch
> till then. Do you mind modifying on top of that patch
>
> [1] https://www.mail-archive.com/linux-usb@xxxxxxxxxxxxxxx/msg43471.html

Sure, I'll rework my series taking in account this patch. I'll cook a v2
for later today.

Thanks!

Antoine

--
Antoine Ténart, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/