usb: hcd: add generic PHY support
PATCH v3 1/1 usb: hcd: add generic PHY support
From Sergei Shtylyov <[email protected]>
Add the generic PHY support, analogous to the USB PHY support. Intended it to be used with the PCI EHCI/OHCI drivers and the xHCI platform driver.
---
This patch is against the 'usb-next' branch of Greg KH's 'usb.git' repo. (commit id = 70d2f61fc7559df3d5be32a9d01efdb9ee1b11d8)
Changes in version 3:
- rebased the current usb-next.
- I tested this patch on my R-Car H2 USB 3.0 driver (not merged yet)
drivers/usb/core/hcd.c | 42 ++++++++++++++++++++++++++++++++++++++++-- include/linux/usb/hcd.h | 3 ++- 2 files changed, 42 insertions(+), 3 deletions(-)
drivers/usb/core/hcd.c +40 -2
@@ -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>
@@ -2649,6 +2650,29 @@ int usb_add_hcd(struct usb_hcd *hcd, } } +if (IS_ENABLED (CONFIG_GENERIC_PHY )) { +struct phy *phy =phy_get (hcd->self.controller,"usb" ); + +if (IS_ERR (phy)) { + retval =PTR_ERR (phy); +if (retval = -EPROBE_DEFER ) + goto err_phy; + }else { + retval =phy_init (phy); +if (retval) { +phy_put (phy); + goto err_phy; + } + retval =phy_power_on (phy); +if (retval) { +phy_exit (phy); +phy_put (phy); + goto err_phy; + } + hcd->gen_phy = phy; + } + } +dev_info (hcd->self.controller,"%s\n" , hcd->product_desc);/* Keep old behaviour if authorized_default is not in [0, 1]. */
@@ -2664,7 +2688,7 @@ int usb_add_hcd(struct usb_hcd *hcd,*/ if ((retval =hcd_buffer_create (hcd)) !=0 ) {dev_dbg (hcd->self.controller,"pool alloc failed\n" ); - goto err_remove_phy; + goto err_create_buf; }if ((retval =usb_register_bus (&hcd->self)) <0 )
@@ -2791,7 +2815,14 @@ err_allocate_root_hub:usb_deregister_bus (&hcd->self); err_register_bus:hcd_buffer_destroy (hcd); -err_remove_phy: +err_create_buf: +if (IS_ENABLED (CONFIG_GENERIC_PHY ) && hcd->gen_phy) { +phy_power_off (hcd->gen_phy); +phy_exit (hcd->gen_phy); +phy_put (hcd->gen_phy); + hcd->gen_phy =NULL ; + } +err_phy:if (hcd->remove_phy && hcd->phy) {usb_phy_shutdown (hcd->phy);usb_put_phy (hcd->phy);
@@ -2868,6 +2899,13 @@ void usb_remove_hcd(struct usb_hcd *hcd)usb_deregister_bus (&hcd->self);hcd_buffer_destroy (hcd); + +if (IS_ENABLED (CONFIG_GENERIC_PHY ) && hcd->gen_phy) { +phy_power_off (hcd->gen_phy); +phy_exit (hcd->gen_phy); +phy_put (hcd->gen_phy); + hcd->gen_phy =NULL ; + }if (hcd->remove_phy && hcd->phy) {usb_phy_shutdown (hcd->phy);usb_put_phy (hcd->phy);
include/linux/usb/hcd.h +2 -1
@@ -106,7 +106,8 @@ struct usb_hcd {* OTG and some Host controllers need software interaction with phys; * other external phys should be software-transparent */ -struct usb_phy *phy; +struct usb_phy *phy; +struct phy *gen_phy;/* Flags that need to be manipulated atomically because they can * change while the host controller is running. Always use
Signature · 1 line
1.7.9.5
Hello.
Quoted 1 line · Yoshihiro Shimoda
From Sergei Shtylyov <[email protected]>
Should be "From:".
Quoted 8 lines
Add the generic PHY support, analogous to the USB PHY support. Intended it to be used with the PCI EHCI/OHCI drivers and the xHCI platform driver.
Signed-off-by Sergei Shtylyov <[email protected]>Signed-off-by Yoshihiro Shimoda <[email protected]>---
This patch is against the 'usb-next' branch of Greg KH's 'usb.git' repo. (commit id =70d2f61fc7559df3d5be32a9d01efdb9ee1b11d8)
I was pondering on reposting this patch, along with the R8A779x device
tree changes using it as Greg KH requested to see the users of this patch...
WBR, Sergei
Hi Sergei,
Quoted 32 lines · Yoshihiro Shimoda
From Sergei Shtylyov <[email protected]>
Add the generic PHY support, analogous to the USB PHY support. Intended it to be used with the PCI EHCI/OHCI drivers and the xHCI platform driver.
Signed-off-by Sergei Shtylyov <[email protected]>Signed-off-by Yoshihiro Shimoda <[email protected]>---
This patch is against the 'usb-next' branch of Greg KH's 'usb.git' repo. (commit id =70d2f61fc7559df3d5be32a9d01efdb9ee1b11d8)Changes in version 3:
- rebased the current usb-next.
- I tested this patch on my R-Car H2 USB 3.0 driver (not merged yet)drivers/usb/core/hcd.c | 42 ++++++++++++++++++++++++++++++++++++++++-- include/linux/usb/hcd.h | 3 ++- 2 files changed, 42 insertions(+), 3 deletions(-)drivers/usb/core/hcd.c +1
-0@@ -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>
drivers/usb/core/hcd.c int usb_add_hcd(struct usb_hcd *hcd, · line 2654
Quoted 5 lines
drivers/usb/core/hcd.c +2
-0@@ -2649,6 +2650,29 @@ int usb_add_hcd(struct usb_hcd *hcd, } } +if (IS_ENABLED (CONFIG_GENERIC_PHY )) { +struct phy *phy =phy_get (hcd->self.controller,"usb" );
The xHCI host controller is going to have two controllers (main and shared) USB2 controller and
USB3 controller. So they will have two different PHYs. For example, the DWC3, which has a xHCI controller, has to have 2 different phys -- usb2-phy and usb3-phy.
So, how the two 'hcd's' will be able to differentiate and get two separate PHYs. Unfortunately, the xHCI with DWC3 doesn't have a device node too, so it needs to have
a way out to look up the PHYs (in a way suggested by Heikki :
usb: dwc3: host: convey the PHYs to xhci
(https://lkml.org/lkml/2014/6/5/585) and related patch series.
But this also has an issue, since we need to have two separate constant strings to distinguish between the two PHYs,
while creating the lookup table.
So how do you suggest me to get link the two PHYs in DWC3 with the XHCI host controller, the issue which i am
facing currently while working with the patch:
usb: host: xhci-plat: Add support to get PHYs and the related patch
series, since we need to handle PHY from the hcd.
Quoted 84 lines
drivers/usb/core/hcd.c +37
-2+ +if (IS_ERR (phy)) { + retval =PTR_ERR (phy); +if (retval = -EPROBE_DEFER ) + goto err_phy; + }else { + retval =phy_init (phy); +if (retval) { +phy_put (phy); + goto err_phy; + } + retval =phy_power_on (phy); +if (retval) { +phy_exit (phy); +phy_put (phy); + goto err_phy; + } + hcd->gen_phy = phy; + } + } +dev_info (hcd->self.controller,"%s\n" , hcd->product_desc);/* Keep old behaviour if authorized_default is not in [0, 1]. */ @@ -2664,7 +2688,7 @@ int usb_add_hcd(struct usb_hcd *hcd,*/ if ((retval =hcd_buffer_create (hcd)) !=0 ) {dev_dbg (hcd->self.controller,"pool alloc failed\n" ); - goto err_remove_phy; + goto err_create_buf; }if ((retval =usb_register_bus (&hcd->self)) <0 )@@ -2791,7 +2815,14 @@ err_allocate_root_hub:usb_deregister_bus (&hcd->self); err_register_bus:hcd_buffer_destroy (hcd); -err_remove_phy: +err_create_buf: +if (IS_ENABLED (CONFIG_GENERIC_PHY ) && hcd->gen_phy) { +phy_power_off (hcd->gen_phy); +phy_exit (hcd->gen_phy); +phy_put (hcd->gen_phy); + hcd->gen_phy =NULL ; + } +err_phy:if (hcd->remove_phy && hcd->phy) {usb_phy_shutdown (hcd->phy);usb_put_phy (hcd->phy);@@ -2868,6 +2899,13 @@ void usb_remove_hcd(struct usb_hcd *hcd)usb_deregister_bus (&hcd->self);hcd_buffer_destroy (hcd); + +if (IS_ENABLED (CONFIG_GENERIC_PHY ) && hcd->gen_phy) { +phy_power_off (hcd->gen_phy); +phy_exit (hcd->gen_phy); +phy_put (hcd->gen_phy); + hcd->gen_phy =NULL ; + }if (hcd->remove_phy && hcd->phy) {usb_phy_shutdown (hcd->phy);usb_put_phy (hcd->phy);include/linux/usb/hcd.h +2
-2@@ -106,7 +106,8 @@ struct usb_hcd {* OTG and some Host controllers need software interaction with phys; * other external phys should be software-transparent */ -struct usb_phy *phy; +struct usb_phy *phy; +struct phy *gen_phy;/* Flags that need to be manipulated atomically because they can * change while the host controller is running. Always use -- 1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 4 lines
Best Regards Vivek Gautam Samsung R&D Institute, Bangalore India
Hi,
Quoted 59 lines · Vivek Gautam
Hi Sergei,
Quoted 32 lines · Yoshihiro Shimoda
From Sergei Shtylyov <[email protected]>
Add the generic PHY support, analogous to the USB PHY support. Intended it to be used with the PCI EHCI/OHCI drivers and the xHCI platform driver.
Signed-off-by Sergei Shtylyov <[email protected]>Signed-off-by Yoshihiro Shimoda <[email protected]>---
This patch is against the 'usb-next' branch of Greg KH's 'usb.git' repo. (commit id =70d2f61fc7559df3d5be32a9d01efdb9ee1b11d8)Changes in version 3:
- rebased the current usb-next.
- I tested this patch on my R-Car H2 USB 3.0 driver (not merged yet)drivers/usb/core/hcd.c | 42 ++++++++++++++++++++++++++++++++++++++++-- include/linux/usb/hcd.h | 3 ++- 2 files changed, 42 insertions(+), 3 deletions(-)drivers/usb/core/hcd.c +1
-0@@ -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> drivers/usb/core/hcd.c int usb_add_hcd(struct usb_hcd *hcd, · line 2654
Quoted 5 lines
drivers/usb/core/hcd.c +2
-0@@ -2649,6 +2650,29 @@ int usb_add_hcd(struct usb_hcd *hcd, } } +if (IS_ENABLED (CONFIG_GENERIC_PHY )) { +struct phy *phy =phy_get (hcd->self.controller,"usb" );The xHCI host controller is going to have two controllers (main and shared) USB2 controller and
USB3 controller. So they will have two different PHYs. For example, the DWC3, which has a xHCI controller, has to have 2 different phys -- usb2-phy and usb3-phy.So, how the two 'hcd's' will be able to differentiate and get two separate PHYs. Unfortunately, the xHCI with DWC3 doesn't have a device node too, so it needs to have
a way out to look up the PHYs (in a way suggested by Heikki :
usb: dwc3: host: convey the PHYs to xhci
(https://lkml.org/lkml/2014/6/5/585) and related patch series.
But this also has an issue, since we need to have two separate constant strings to distinguish between the two PHYs,
while creating the lookup table.
Quoted 5 lines
So how do you suggest me to get link the two PHYs in DWC3 with the XHCI host controller, the issue which i am
facing currently while working with the patch:
usb: host: xhci-plat: Add support to get PHYs and the related patch
series, since we need to handle PHY from the hcd.
Can someone please clear my doubt here.
This can help me getting a clear picture of how to align with the xhci's request for PHY to let it handle any sort of phy-calibration, which we are trying in the patch-series:
[PATCH v1 0/4] Fine tune USB 3.0 PHY on exynos5420
https://lkml.org/lkml/2014/6/6/202
I have also posted my doubts in the thread :
[PATCH 2/4] usb: host: xhci-plat: Add support to get PHYs
https://lkml.org/lkml/2014/6/25/150
[snip]
Signature · 4 lines
Best Regards Vivek Gautam Samsung R&D Institute, Bangalore India
Hello.
Quoted 23 lines · Vivek Gautam
Quoted 23 lines
From Sergei Shtylyov <[email protected]>
Add the generic PHY support, analogous to the USB PHY support. Intended it to be used with the PCI EHCI/OHCI drivers and the xHCI platform driver.
Signed-off-by Sergei Shtylyov <[email protected]>Signed-off-by Yoshihiro Shimoda <[email protected]>---
This patch is against the 'usb-next' branch of Greg KH's 'usb.git' repo. (commit id =70d2f61fc7559df3d5be32a9d01efdb9ee1b11d8)Changes in version 3:
- rebased the current usb-next.
- I tested this patch on my R-Car H2 USB 3.0 driver (not merged yet)drivers/usb/core/hcd.c | 42 ++++++++++++++++++++++++++++++++++++++++-- include/linux/usb/hcd.h | 3 ++- 2 files changed, 42 insertions(+), 3 deletions(-)drivers/usb/core/hcd.c +0
-0
[...]
Quoted 10 lines
drivers/usb/core/hcd.c int usb_add_hcd(struct usb_hcd *hcd, · line 2654
Quoted 6 lines
drivers/usb/core/hcd.c +2
-0@@ -2649,6 +2650,29 @@ int usb_add_hcd(struct usb_hcd *hcd, } } +if (IS_ENABLED (CONFIG_GENERIC_PHY )) { +struct phy *phy =phy_get (hcd->self.controller,"usb" );The xHCI host controller is going to have two controllers (main and shared) USB2 controller and
USB3 controller. So they will have two different PHYs.
Not necessarily -- in my case there's going be one PHY, even for xHCI.
Quoted 2 lines
For example, the DWC3, which has a xHCI controller, has to have 2 different phys -- usb2-phy and usb3-phy.
Yes, I understood that.
Quoted 1 line
So, how the two 'hcd's' will be able to differentiate and get two separate PHYs.
Apparently, by name? I don't see any other way...
Quoted 8 lines
Unfortunately, the xHCI with DWC3 doesn't have a device node too, so it needs to have
a way out to look up the PHYs (in a way suggested by Heikki :
usb: dwc3: host: convey the PHYs to xhci
(https://lkml.org/lkml/2014/6/5/585) and related patch series.
But this also has an issue, since we need to have two separate constant strings to distinguish between the two PHYs, while creating the lookup table.
I'm sorry, where's the issue?
Quoted 5 lines
So how do you suggest me to get link the two PHYs in DWC3 with the XHCI host controller, the issue which i am
facing currently while working with the patch:
usb: host: xhci-plat: Add support to get PHYs and the related patch
series, since we need to handle PHY from the hcd.
Well, I've already spoke out in another thread: you'll have to carry on
with your approach, ignoring the patch starting this thread. I'm sorry for side-tracking you...
WBR, Sergei
Hi,
Quoted 51 lines · Sergei Shtylyov
Hello.
Quoted 30 lines · Vivek Gautam
Quoted 30 lines
From Sergei Shtylyov <[email protected]>
Add the generic PHY support, analogous to the USB PHY support. Intended it to be
used with the PCI EHCI/OHCI drivers and the xHCI platform driver.Signed-off-by Sergei Shtylyov <[email protected]>Signed-off-by Yoshihiro Shimoda <[email protected]>---
This patch is against the 'usb-next' branch of Greg KH's 'usb.git' repo. (commit id =70d2f61fc7559df3d5be32a9d01efdb9ee1b11d8)Changes in version 3:
- rebased the current usb-next.
- I tested this patch on my R-Car H2 USB 3.0 driver (not merged yet)drivers/usb/core/hcd.c | 42 ++++++++++++++++++++++++++++++++++++++++-- include/linux/usb/hcd.h | 3 ++- 2 files changed, 42 insertions(+), 3 deletions(-)drivers/usb/core/hcd.c +0
-0[...]
Quoted 11 lines
drivers/usb/core/hcd.c int usb_add_hcd(struct usb_hcd *hcd, · line 2654
Quoted 6 lines
drivers/usb/core/hcd.c +2
-0@@ -2649,6 +2650,29 @@ int usb_add_hcd(struct usb_hcd *hcd, } } +if (IS_ENABLED (CONFIG_GENERIC_PHY )) { +struct phy *phy =phy_get (hcd->self.controller,"usb" );The xHCI host controller is going to have two controllers (main and shared) USB2 controller and
USB3 controller. So they will have two different PHYs.
Quoted 1 line
Not necessarily -- in my case there's going be one PHY, even for xHCI.
ok.
Quoted 6 lines
Quoted 4 lines
For example, the DWC3, which has a xHCI controller, has to have 2 different phys -- usb2-phy and usb3-phy.
Quoted 8 lines
Yes, I understood that.
Quoted 2 lines
So, how the two 'hcd's' will be able to differentiate and get two separate PHYs.
Apparently, by name? I don't see any other way...
true, by name string only.
Quoted 12 lines
Quoted 10 lines
Unfortunately, the xHCI with DWC3 doesn't have a device node too, so it needs to have
a way out to look up the PHYs (in a way suggested by Heikki :
usb: dwc3: host: convey the PHYs to xhci
(https://lkml.org/lkml/2014/6/5/585) and related patch series.
But this also has an issue, since we need to have two separate constant strings to distinguish between the two PHYs, while creating the lookup table.
Quoted 1 line
I'm sorry, where's the issue?
i actually thought of the phy_get() in core/hcd.c, where we would need more than one
name string for different PHYs. But now things are clear after your explanation.
Quoted 9 lines
Quoted 7 lines
So how do you suggest me to get link the two PHYs in DWC3 with the XHCI host controller, the issue which i am
facing currently while working with the patch:
usb: host: xhci-plat: Add support to get PHYs and the related patch
series, since we need to handle PHY from the hcd.
Quoted 3 lines
Well, I've already spoke out in another thread: you'll have to carry on
with your approach, ignoring the patch starting this thread. I'm sorry for side-tracking you...
Thanks Sergei for clearing my doubts and the confusion.
Signature · 4 lines
Best Regards Vivek Gautam Samsung R&D Institute, Bangalore India
Quoted 22 lines · Sergei Shtylyov
Hello.
Quoted 1 line · Yoshihiro Shimoda
From Sergei Shtylyov <[email protected]>
Should be "From:".
Quoted 10 lines
Add the generic PHY support, analogous to the USB PHY support. Intended it to be
used with the PCI EHCI/OHCI drivers and the xHCI platform driver.Signed-off-by Sergei Shtylyov <[email protected]>Signed-off-by Yoshihiro Shimoda <[email protected]>---
This patch is against the 'usb-next' branch of Greg KH's 'usb.git' repo. (commit id =70d2f61fc7559df3d5be32a9d01efdb9ee1b11d8)
Quoted 2 lines
I was pondering on reposting this patch, along with the R8A779x device
tree changes using it as Greg KH requested to see the users of this patch...
Are we planning a repost of this patch, since we definitely have user for this change [1],
apart from Antoine's series [2] which makes changes on top of this patch.
It will be easier for us if this patch gets pulled in for 3.18.
[1] [PATCH v4 2/4] usb: host: xhci-plat: Get PHYs for xhci's hcds
http://lists.infradead.org/pipermail/linux-arm-kernel/2014-July/272833.html
[2] [PATCH v2 0/8] usb: add support for the generic PHY framework
http://www.spinics.net/lists/linux-usb/msg110557.html
Signature · 4 lines
Best Regards Vivek Gautam Samsung R&D Institute, Bangalore India
Hello.
Quoted 14 lines · Vivek Gautam
Quoted 13 lines
Quoted 1 line
From Sergei Shtylyov <[email protected]>
Should be "From:".
Quoted 9 lines
Add the generic PHY support, analogous to the USB PHY support. Intended it to be
used with the PCI EHCI/OHCI drivers and the xHCI platform driver.Signed-off-by Sergei Shtylyov <[email protected]>Signed-off-by Yoshihiro Shimoda <[email protected]>---
This patch is against the 'usb-next' branch of Greg KH's 'usb.git' repo. (commit id =70d2f61fc7559df3d5be32a9d01efdb9ee1b11d8)
Quoted 4 lines
Quoted 2 lines
I was pondering on reposting this patch, along with the R8A779x device
tree changes using it as Greg KH requested to see the users of this patch...Are we planning a repost of this patch,
Yes, I'm planning this since Greg has lost v4.
WBR, Sergei
Hi Sergei,
Quoted 30 lines · Sergei Shtylyov
Hello.
Quoted 23 lines · Vivek Gautam
Quoted 23 lines
Quoted 1 line
From Sergei Shtylyov <[email protected]>
Should be "From:".
Quoted 11 lines
Add the generic PHY support, analogous to the USB PHY support. Intended it
to be
used with the PCI EHCI/OHCI drivers and the xHCI platform driver.Signed-off-by Sergei Shtylyov <[email protected]>Signed-off-by Yoshihiro Shimoda <[email protected]>---
This patch is against the 'usb-next' branch of Greg KH's 'usb.git' repo. (commit id =70d2f61fc7559df3d5be32a9d01efdb9ee1b11d8)I was pondering on reposting this patch, along with the R8A779x
device
tree changes using it as Greg KH requested to see the users of this patch...
Quoted 4 lines
Quoted 1 line
Are we planning a repost of this patch,
Yes, I'm planning this since Greg has lost v4.
Ok, for now i will rebase my series for xhci-plat on this. Thanks :-)
Signature · 4 lines
Best Regards Vivek Gautam Samsung R&D Institute, Bangalore India