Message ID | 1397136261-16408-1-git-send-email-gautam.vivek@samsung.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Thu, Apr 10, 2014 at 6:54 PM, Vivek Gautam <gautam.vivek@samsung.com> wrote: > Add support to consume phy provided by Generic phy framework. > Keeping the support for older usb-phy intact right now, in order > to prevent any functionality break in absence of relevant > device tree side change for ohci-exynos. > Once we move to new phy in the device nodes for ohci, we can > remove the support for older phys. Any comments on this please. I think whatever the approach we follow, that can be common to both ehci-exynos[1], and ohci-exynos, since both are needed to move to the new generic phy framework, keeping support for older usb-phy so as to have smooth transition, in order to avoid any regression. > Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com> > Cc: Jingoo Han <jg1.han@samsung.com> > Cc: Alan Stern <stern@rowland.harvard.edu> > --- > > Based on 'usb-next' branch of Greg's usb tree. > Tested with local dt patches, similar to ehci dt changes posted by Kamil[1]. > Tested on Exynos5250 smdk. > [1] [PATCH v6 4/8] dts: Add usb2phy to Exynos 5250 https://lkml.org/lkml/2014/1/29/302 > > .../devicetree/bindings/usb/exynos-usb.txt | 14 ++++ > drivers/usb/host/ohci-exynos.c | 79 ++++++++++++++++++-- > 2 files changed, 85 insertions(+), 8 deletions(-) > [snip]
On Thu, 10 Apr 2014, Vivek Gautam wrote: > Add support to consume phy provided by Generic phy framework. > Keeping the support for older usb-phy intact right now, in order > to prevent any functionality break in absence of relevant > device tree side change for ohci-exynos. > Once we move to new phy in the device nodes for ohci, we can > remove the support for older phys. > > Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com> > Cc: Jingoo Han <jg1.han@samsung.com> > Cc: Alan Stern <stern@rowland.harvard.edu> > +static int exynos_ohci_phyg_on(struct phy *phy, bool on) > +{ > + int ret = 0; > + > + if (phy) { > + if (on) > + ret = phy_power_on(phy); > + else > + ret = phy_power_off(phy); > + } > + > + return ret; > +} This would be cleaner if you had separate routines for exynos_ohci_phyg_of and exynos_ohci_phyg_off. For example: static int exynos_ohci_phyg_on(struct phy *phy) { return phy ? phy_power_on(phy) : 0; } > @@ -88,16 +104,49 @@ static int exynos_ohci_probe(struct platform_device *pdev) > "samsung,exynos5440-ohci")) > goto skip_phy; > > - phy = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2); > - if (IS_ERR(phy)) { > - usb_put_hcd(hcd); > - dev_warn(&pdev->dev, "no platform data or transceiver defined\n"); > - return -EPROBE_DEFER; > + exynos_ohci->phy = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2); > + if (IS_ERR(exynos_ohci->phy)) { > + err = PTR_ERR(exynos_ohci->phy); > + if (err == -ENXIO || err == -ENODEV) { > + exynos_ohci->phy = NULL; > + } else if (err == -EPROBE_DEFER) { > + usb_put_hcd(hcd); > + return err; > + } else { > + dev_err(&pdev->dev, "no usb2 phy configured\n"); > + usb_put_hcd(hcd); > + return err; > + } Instead of all the calls to usb_put_hcd() here and below, just goto fail_clk. Or add a new fail_phy label at the same spot and goto it. Otherwise this looks basically okay. Alan Stern
On Tue, 22 Apr 2014, Vivek Gautam wrote: > On Thu, Apr 10, 2014 at 6:54 PM, Vivek Gautam <gautam.vivek@samsung.com> wrote: > > Add support to consume phy provided by Generic phy framework. > > Keeping the support for older usb-phy intact right now, in order > > to prevent any functionality break in absence of relevant > > device tree side change for ohci-exynos. > > Once we move to new phy in the device nodes for ohci, we can > > remove the support for older phys. > > Any comments on this please. > I think whatever the approach we follow, that can be common to both > ehci-exynos[1], and ohci-exynos, since > both are needed to move to the new generic phy framework, keeping > support for older usb-phy > so as to have smooth transition, in order to avoid any regression. I lost my copies of the ehci-exynos patch, but probably the same comments apply as for the ohci-exynos patch. Alan Stern
Hi Alan, On Tue, Apr 22, 2014 at 11:28 PM, Alan Stern <stern@rowland.harvard.edu> wrote: Thanks for reviewing this. Please find my comments inline below. > On Thu, 10 Apr 2014, Vivek Gautam wrote: > >> Add support to consume phy provided by Generic phy framework. >> Keeping the support for older usb-phy intact right now, in order >> to prevent any functionality break in absence of relevant >> device tree side change for ohci-exynos. >> Once we move to new phy in the device nodes for ohci, we can >> remove the support for older phys. >> >> Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com> >> Cc: Jingoo Han <jg1.han@samsung.com> >> Cc: Alan Stern <stern@rowland.harvard.edu> > >> +static int exynos_ohci_phyg_on(struct phy *phy, bool on) >> +{ >> + int ret = 0; >> + >> + if (phy) { >> + if (on) >> + ret = phy_power_on(phy); >> + else >> + ret = phy_power_off(phy); >> + } >> + >> + return ret; >> +} > > This would be cleaner if you had separate routines for > exynos_ohci_phyg_of and exynos_ohci_phyg_off. For example: > > static int exynos_ohci_phyg_on(struct phy *phy) > { > return phy ? phy_power_on(phy) : 0; > } Sure, i will make two separate routines here. > >> @@ -88,16 +104,49 @@ static int exynos_ohci_probe(struct platform_device *pdev) >> "samsung,exynos5440-ohci")) >> goto skip_phy; >> >> - phy = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2); >> - if (IS_ERR(phy)) { >> - usb_put_hcd(hcd); >> - dev_warn(&pdev->dev, "no platform data or transceiver defined\n"); >> - return -EPROBE_DEFER; >> + exynos_ohci->phy = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2); >> + if (IS_ERR(exynos_ohci->phy)) { >> + err = PTR_ERR(exynos_ohci->phy); >> + if (err == -ENXIO || err == -ENODEV) { >> + exynos_ohci->phy = NULL; >> + } else if (err == -EPROBE_DEFER) { >> + usb_put_hcd(hcd); >> + return err; >> + } else { >> + dev_err(&pdev->dev, "no usb2 phy configured\n"); >> + usb_put_hcd(hcd); >> + return err; >> + } > > Instead of all the calls to usb_put_hcd() here and below, just goto > fail_clk. Or add a new fail_phy label at the same spot and goto it. Sure, i can use a new label here. > > Otherwise this looks basically okay. Sure, i will send the next version of this patch after rework.
Hi, On Tue, Apr 22, 2014 at 11:29 PM, Alan Stern <stern@rowland.harvard.edu> wrote: > On Tue, 22 Apr 2014, Vivek Gautam wrote: > >> On Thu, Apr 10, 2014 at 6:54 PM, Vivek Gautam <gautam.vivek@samsung.com> wrote: >> > Add support to consume phy provided by Generic phy framework. >> > Keeping the support for older usb-phy intact right now, in order >> > to prevent any functionality break in absence of relevant >> > device tree side change for ohci-exynos. >> > Once we move to new phy in the device nodes for ohci, we can >> > remove the support for older phys. >> >> Any comments on this please. >> I think whatever the approach we follow, that can be common to both >> ehci-exynos[1], and ohci-exynos, since >> both are needed to move to the new generic phy framework, keeping >> support for older usb-phy >> so as to have smooth transition, in order to avoid any regression. > > I lost my copies of the ehci-exynos patch, but probably the same > comments apply as for the ohci-exynos patch. Ok, i will be reworking on the ehci-exynos patch also (which was earlier posted by Kamil [1]), after addressing the review comments on that, and will post the same. [1] [PATCH v6 8/8] usb: ehci-exynos: Change to use phy provided by the generic phy framework https://lkml.org/lkml/2014/1/29/298
diff --git a/Documentation/devicetree/bindings/usb/exynos-usb.txt b/Documentation/devicetree/bindings/usb/exynos-usb.txt index d967ba1..ef0bc09 100644 --- a/Documentation/devicetree/bindings/usb/exynos-usb.txt +++ b/Documentation/devicetree/bindings/usb/exynos-usb.txt @@ -38,6 +38,10 @@ Required properties: - interrupts: interrupt number to the cpu. - clocks: from common clock binding: handle to usb clock. - clock-names: from common clock binding: Shall be "usbhost". + - port: if in the SoC there are OHCI phys, they should be listed here. +One phy per port. Each port should have its reg entry with a consecutive +number. Also it should contain phys and phy-names entries specifying the +phy used by the port. Example: usb@12120000 { @@ -47,6 +51,16 @@ Example: clocks = <&clock 285>; clock-names = "usbhost"; + + #address-cells = <1>; + #size-cells = <0>; + port@0 { + reg = <0>; + phys = <&usb2phy 1>; + phy-names = "host"; + status = "disabled"; + }; + }; DWC3 diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c index 68588d8..52eb821 100644 --- a/drivers/usb/host/ohci-exynos.c +++ b/drivers/usb/host/ohci-exynos.c @@ -18,6 +18,7 @@ #include <linux/module.h> #include <linux/of.h> #include <linux/platform_device.h> +#include <linux/phy/phy.h> #include <linux/usb/phy.h> #include <linux/usb/samsung_usb_phy.h> #include <linux/usb.h> @@ -37,6 +38,7 @@ struct exynos_ohci_hcd { struct clk *clk; struct usb_phy *phy; struct usb_otg *otg; + struct phy *phy_g; }; static void exynos_ohci_phy_enable(struct platform_device *pdev) @@ -57,12 +59,26 @@ static void exynos_ohci_phy_disable(struct platform_device *pdev) usb_phy_shutdown(exynos_ohci->phy); } +static int exynos_ohci_phyg_on(struct phy *phy, bool on) +{ + int ret = 0; + + if (phy) { + if (on) + ret = phy_power_on(phy); + else + ret = phy_power_off(phy); + } + + return ret; +} + static int exynos_ohci_probe(struct platform_device *pdev) { struct exynos_ohci_hcd *exynos_ohci; struct usb_hcd *hcd; struct resource *res; - struct usb_phy *phy; + struct device_node *child; int irq; int err; @@ -88,16 +104,49 @@ static int exynos_ohci_probe(struct platform_device *pdev) "samsung,exynos5440-ohci")) goto skip_phy; - phy = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2); - if (IS_ERR(phy)) { - usb_put_hcd(hcd); - dev_warn(&pdev->dev, "no platform data or transceiver defined\n"); - return -EPROBE_DEFER; + exynos_ohci->phy = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2); + if (IS_ERR(exynos_ohci->phy)) { + err = PTR_ERR(exynos_ohci->phy); + if (err == -ENXIO || err == -ENODEV) { + exynos_ohci->phy = NULL; + } else if (err == -EPROBE_DEFER) { + usb_put_hcd(hcd); + return err; + } else { + dev_err(&pdev->dev, "no usb2 phy configured\n"); + usb_put_hcd(hcd); + return err; + } } else { - exynos_ohci->phy = phy; - exynos_ohci->otg = phy->otg; + exynos_ohci->otg = exynos_ohci->phy->otg; } + /* Getting generic phy: + * We are keeping both types of phys as a part of transiting OHCI + * to generic phy framework, so that in absence of supporting dts + * changes the functionality doesn't break. + * Once we move the ohci dt nodes to use new generic phys, + * we can remove support for older PHY in this driver. + */ + child = of_get_next_child(pdev->dev.of_node, NULL); + exynos_ohci->phy_g = devm_of_phy_get(&pdev->dev, child, 0); + of_node_put(child); + if (IS_ERR(exynos_ohci->phy_g)) { + err = PTR_ERR(exynos_ohci->phy_g); + if (err == -ENOSYS || err == -ENODEV) { + exynos_ohci->phy_g = NULL; + } else if (err == -EPROBE_DEFER) { + usb_put_hcd(hcd); + return err; + } else { + dev_err(&pdev->dev, "no usb2 phy configured\n"); + usb_put_hcd(hcd); + return err; + } + } + + if (!exynos_ohci->phy && !exynos_ohci->phy_g) + dev_dbg(&pdev->dev, "Failed to get usb2 phy\n"); skip_phy: exynos_ohci->clk = devm_clk_get(&pdev->dev, "usbhost"); @@ -140,6 +189,11 @@ skip_phy: platform_set_drvdata(pdev, hcd); exynos_ohci_phy_enable(pdev); + err = exynos_ohci_phyg_on(exynos_ohci->phy_g, true); + if (err) { + dev_err(&pdev->dev, "Failed to enable phy\n"); + goto fail_io; + } err = usb_add_hcd(hcd, irq, IRQF_SHARED); if (err) { @@ -151,6 +205,7 @@ skip_phy: fail_add_hcd: exynos_ohci_phy_disable(pdev); + exynos_ohci_phyg_on(exynos_ohci->phy_g, false); fail_io: clk_disable_unprepare(exynos_ohci->clk); fail_clk: @@ -169,6 +224,7 @@ static int exynos_ohci_remove(struct platform_device *pdev) exynos_ohci->otg->set_host(exynos_ohci->otg, &hcd->self); exynos_ohci_phy_disable(pdev); + exynos_ohci_phyg_on(exynos_ohci->phy_g, false); clk_disable_unprepare(exynos_ohci->clk); @@ -205,6 +261,7 @@ static int exynos_ohci_suspend(struct device *dev) exynos_ohci->otg->set_host(exynos_ohci->otg, &hcd->self); exynos_ohci_phy_disable(pdev); + exynos_ohci_phyg_on(exynos_ohci->phy_g, false); clk_disable_unprepare(exynos_ohci->clk); @@ -218,6 +275,7 @@ static int exynos_ohci_resume(struct device *dev) struct usb_hcd *hcd = dev_get_drvdata(dev); struct exynos_ohci_hcd *exynos_ohci = to_exynos_ohci(hcd); struct platform_device *pdev = to_platform_device(dev); + int ret; clk_prepare_enable(exynos_ohci->clk); @@ -225,6 +283,11 @@ static int exynos_ohci_resume(struct device *dev) exynos_ohci->otg->set_host(exynos_ohci->otg, &hcd->self); exynos_ohci_phy_enable(pdev); + ret = exynos_ohci_phyg_on(exynos_ohci->phy_g, true); + if (ret) { + dev_err(dev, "Failed to enable phy\n"); + return ret; + } ohci_resume(hcd, false);
Add support to consume phy provided by Generic phy framework. Keeping the support for older usb-phy intact right now, in order to prevent any functionality break in absence of relevant device tree side change for ohci-exynos. Once we move to new phy in the device nodes for ohci, we can remove the support for older phys. Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com> Cc: Jingoo Han <jg1.han@samsung.com> Cc: Alan Stern <stern@rowland.harvard.edu> --- Based on 'usb-next' branch of Greg's usb tree. Tested with local dt patches, similar to ehci dt changes posted by Kamil[1]. Tested on Exynos5250 smdk. [1] [PATCH v6 4/8] dts: Add usb2phy to Exynos 5250 https://lkml.org/lkml/2014/1/29/302 .../devicetree/bindings/usb/exynos-usb.txt | 14 ++++ drivers/usb/host/ohci-exynos.c | 79 ++++++++++++++++++-- 2 files changed, 85 insertions(+), 8 deletions(-)