LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCHv3 0/2] Added Multiple Phy support for ehci and ohci drivers
@ 2015-01-20 0:05 arun.ramamurthy
2015-01-20 0:05 ` [PATCHv3 1/2] usb: ehci-platform: add support for multiple phys per controller arun.ramamurthy
2015-01-20 0:05 ` [PATCHv3 2/2] usb: ohci-platform: " arun.ramamurthy
0 siblings, 2 replies; 6+ messages in thread
From: arun.ramamurthy @ 2015-01-20 0:05 UTC (permalink / raw)
To: stern, linux, gregkh
Cc: linux-usb, linux-arm-kernel, linux-kernel, sbranden, rjui,
Arun Ramamurthy
From: Arun Ramamurthy <arun.ramamurthy@broadcom.com>
Broadcom has a chip where one ehci and ohci controller are connected
to three separate phys. This patch allows each phy to be controlled
separately.
Changes in v2:
- removed x character mistakenly introduced by manual edit of diff file
Changes in v3:
- Addressed Alan Stern's commnents on support for non-dt cases
Arun Ramamurthy (1):
usb: ehci-platform: add support for multiple phys per controller
drivers/usb/host/ehci-platform.c | 82 +++++++++++++++++++++++++++++-----------
1 file changed, 60 insertions(+), 22 deletions(-)
--
2.2.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCHv3 1/2] usb: ehci-platform: add support for multiple phys per controller
2015-01-20 0:05 [PATCHv3 0/2] Added Multiple Phy support for ehci and ohci drivers arun.ramamurthy
@ 2015-01-20 0:05 ` arun.ramamurthy
2015-01-21 15:03 ` Alan Stern
2015-01-20 0:05 ` [PATCHv3 2/2] usb: ohci-platform: " arun.ramamurthy
1 sibling, 1 reply; 6+ messages in thread
From: arun.ramamurthy @ 2015-01-20 0:05 UTC (permalink / raw)
To: stern, linux, gregkh
Cc: linux-usb, linux-arm-kernel, linux-kernel, sbranden, rjui,
Arun Ramamurthy
From: Arun Ramamurthy <arunrama@broadcom.com>
Added support for cases where one controller is connected
to multiple phys.
Signed-off-by: Arun Ramamurthy <arunrama@broadcom.com>
Reviewed-by: Ray Jui <rjui@broadcom.com>
Reviewed-by: Scott Branden <sbranden@broadcom.com>
Tested-by: Scott Branden <sbranden@broadcom.com>
---
drivers/usb/host/ehci-platform.c | 82 +++++++++++++++++++++++++++++-----------
1 file changed, 60 insertions(+), 22 deletions(-)
diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c
index 8557803..6b4978a 100644
--- a/drivers/usb/host/ehci-platform.c
+++ b/drivers/usb/host/ehci-platform.c
@@ -43,7 +43,8 @@
struct ehci_platform_priv {
struct clk *clks[EHCI_MAX_CLKS];
struct reset_control *rst;
- struct phy *phy;
+ struct phy **phys;
+ int num_phys;
};
static const char hcd_name[] = "ehci-platform";
@@ -78,7 +79,7 @@ static int ehci_platform_power_on(struct platform_device *dev)
{
struct usb_hcd *hcd = platform_get_drvdata(dev);
struct ehci_platform_priv *priv = hcd_to_ehci_priv(hcd);
- int clk, ret;
+ int clk, ret, phy_num;
for (clk = 0; clk < EHCI_MAX_CLKS && priv->clks[clk]; clk++) {
ret = clk_prepare_enable(priv->clks[clk]);
@@ -86,20 +87,28 @@ static int ehci_platform_power_on(struct platform_device *dev)
goto err_disable_clks;
}
- if (priv->phy) {
- ret = phy_init(priv->phy);
- if (ret)
- goto err_disable_clks;
-
- ret = phy_power_on(priv->phy);
- if (ret)
- goto err_exit_phy;
+ for (phy_num = 0; phy_num < priv->num_phys; phy_num++) {
+ if (priv->phys[phy_num]) {
+ ret = phy_init(priv->phys[phy_num]);
+ if (ret)
+ goto err_exit_phy;
+ ret = phy_power_on(priv->phys[phy_num]);
+ if (ret) {
+ phy_exit(priv->phys[phy_num]);
+ goto err_exit_phy;
+ }
+ }
}
return 0;
err_exit_phy:
- phy_exit(priv->phy);
+ while (--phy_num >= 0) {
+ if (priv->phys[phy_num]) {
+ phy_power_off(priv->phys[phy_num]);
+ phy_exit(priv->phys[phy_num]);
+ }
+ }
err_disable_clks:
while (--clk >= 0)
clk_disable_unprepare(priv->clks[clk]);
@@ -111,11 +120,13 @@ static void ehci_platform_power_off(struct platform_device *dev)
{
struct usb_hcd *hcd = platform_get_drvdata(dev);
struct ehci_platform_priv *priv = hcd_to_ehci_priv(hcd);
- int clk;
+ int clk, phy_num;
- if (priv->phy) {
- phy_power_off(priv->phy);
- phy_exit(priv->phy);
+ for (phy_num = 0; phy_num < priv->num_phys; phy_num++) {
+ if (priv->phys[phy_num]) {
+ phy_power_off(priv->phys[phy_num]);
+ phy_exit(priv->phys[phy_num]);
+ }
}
for (clk = EHCI_MAX_CLKS - 1; clk >= 0; clk--)
@@ -143,7 +154,8 @@ static int ehci_platform_probe(struct platform_device *dev)
struct usb_ehci_pdata *pdata = dev_get_platdata(&dev->dev);
struct ehci_platform_priv *priv;
struct ehci_hcd *ehci;
- int err, irq, clk = 0;
+ const char *phy_name;
+ int err, irq, phy_num, clk = 0;
if (usb_disabled())
return -ENODEV;
@@ -185,12 +197,38 @@ static int ehci_platform_probe(struct platform_device *dev)
if (of_property_read_bool(dev->dev.of_node, "big-endian"))
ehci->big_endian_mmio = ehci->big_endian_desc = 1;
- priv->phy = devm_phy_get(&dev->dev, "usb");
- if (IS_ERR(priv->phy)) {
- err = PTR_ERR(priv->phy);
- if (err == -EPROBE_DEFER)
- goto err_put_hcd;
- priv->phy = NULL;
+ priv->num_phys = of_count_phandle_with_args(dev->dev.of_node,
+ "phys", "#phy-cells");
+ priv->num_phys = priv->num_phys > 0 ? priv->num_phys : 1;
+
+ priv->phys = devm_kcalloc(&dev->dev, priv->num_phys,
+ sizeof(struct phy *), GFP_KERNEL);
+ if (!priv->phys)
+ return -ENOMEM;
+
+ for (phy_num = 0; phy_num < priv->num_phys; phy_num++) {
+ err = of_property_read_string_index(
+ dev->dev.of_node,
+ "phy-names", phy_num,
+ &phy_name);
+
+ if (err < 0) {
+ if (priv->num_phys > 1) {
+ dev_err(&dev->dev, "phy-names not provided");
+ goto err_put_hcd;
+ } else
+ phy_name = "usb";
+ }
+
+ priv->phys[phy_num] = devm_phy_get(&dev->dev,
+ phy_name);
+ if (IS_ERR(priv->phys[phy_num])) {
+ err = PTR_ERR(priv->phys[phy_num]);
+ if ((priv->num_phys > 1) ||
+ (err == -EPROBE_DEFER))
+ goto err_put_hcd;
+ priv->phys[phy_num] = NULL;
+ }
}
for (clk = 0; clk < EHCI_MAX_CLKS; clk++) {
--
2.2.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCHv3 2/2] usb: ohci-platform: add support for multiple phys per controller
2015-01-20 0:05 [PATCHv3 0/2] Added Multiple Phy support for ehci and ohci drivers arun.ramamurthy
2015-01-20 0:05 ` [PATCHv3 1/2] usb: ehci-platform: add support for multiple phys per controller arun.ramamurthy
@ 2015-01-20 0:05 ` arun.ramamurthy
1 sibling, 0 replies; 6+ messages in thread
From: arun.ramamurthy @ 2015-01-20 0:05 UTC (permalink / raw)
To: stern, linux, gregkh
Cc: linux-usb, linux-arm-kernel, linux-kernel, sbranden, rjui,
Arun Ramamurthy
From: Arun Ramamurthy <arunrama@broadcom.com>
Added support for cases where one controller is connected
to multiple phys
Signed-off-by: Arun Ramamurthy <arunrama@broadcom.com>
Reviewed-by: Ray Jui <rjui@broadcom.com>
Reviewed-by: Scott Branden <sbranden@broadcom.com>
Tested-by: Scott Branden <sbranden@broadcom.com>
---
drivers/usb/host/ohci-platform.c | 82 +++++++++++++++++++++++++++++-----------
1 file changed, 60 insertions(+), 22 deletions(-)
diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c
index b81d202..613d54e 100644
--- a/drivers/usb/host/ohci-platform.c
+++ b/drivers/usb/host/ohci-platform.c
@@ -38,7 +38,8 @@
struct ohci_platform_priv {
struct clk *clks[OHCI_MAX_CLKS];
struct reset_control *rst;
- struct phy *phy;
+ struct phy **phys;
+ int num_phys;
};
static const char hcd_name[] = "ohci-platform";
@@ -47,7 +48,7 @@ static int ohci_platform_power_on(struct platform_device *dev)
{
struct usb_hcd *hcd = platform_get_drvdata(dev);
struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd);
- int clk, ret;
+ int clk, ret, phy_num;
for (clk = 0; clk < OHCI_MAX_CLKS && priv->clks[clk]; clk++) {
ret = clk_prepare_enable(priv->clks[clk]);
@@ -55,20 +56,28 @@ static int ohci_platform_power_on(struct platform_device *dev)
goto err_disable_clks;
}
- if (priv->phy) {
- ret = phy_init(priv->phy);
- if (ret)
- goto err_disable_clks;
-
- ret = phy_power_on(priv->phy);
- if (ret)
- goto err_exit_phy;
+ for (phy_num = 0; phy_num < priv->num_phys; phy_num++) {
+ if (priv->phys[phy_num]) {
+ ret = phy_init(priv->phys[phy_num]);
+ if (ret)
+ goto err_exit_phy;
+ ret = phy_power_on(priv->phys[phy_num]);
+ if (ret) {
+ phy_exit(priv->phys[phy_num]);
+ goto err_exit_phy;
+ }
+ }
}
return 0;
err_exit_phy:
- phy_exit(priv->phy);
+ while (--phy_num >= 0) {
+ if (priv->phys[phy_num]) {
+ phy_power_off(priv->phys[phy_num]);
+ phy_exit(priv->phys[phy_num]);
+ }
+ }
err_disable_clks:
while (--clk >= 0)
clk_disable_unprepare(priv->clks[clk]);
@@ -80,11 +89,13 @@ static void ohci_platform_power_off(struct platform_device *dev)
{
struct usb_hcd *hcd = platform_get_drvdata(dev);
struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd);
- int clk;
+ int clk, phy_num;
- if (priv->phy) {
- phy_power_off(priv->phy);
- phy_exit(priv->phy);
+ for (phy_num = 0; phy_num < priv->num_phys; phy_num++) {
+ if (priv->phys[phy_num]) {
+ phy_power_off(priv->phys[phy_num]);
+ phy_exit(priv->phys[phy_num]);
+ }
}
for (clk = OHCI_MAX_CLKS - 1; clk >= 0; clk--)
@@ -112,7 +123,8 @@ static int ohci_platform_probe(struct platform_device *dev)
struct usb_ohci_pdata *pdata = dev_get_platdata(&dev->dev);
struct ohci_platform_priv *priv;
struct ohci_hcd *ohci;
- int err, irq, clk = 0;
+ const char *phy_name;
+ int err, irq, phy_num, clk = 0;
if (usb_disabled())
return -ENODEV;
@@ -160,12 +172,38 @@ static int ohci_platform_probe(struct platform_device *dev)
of_property_read_u32(dev->dev.of_node, "num-ports",
&ohci->num_ports);
- priv->phy = devm_phy_get(&dev->dev, "usb");
- if (IS_ERR(priv->phy)) {
- err = PTR_ERR(priv->phy);
- if (err == -EPROBE_DEFER)
- goto err_put_hcd;
- priv->phy = NULL;
+ priv->num_phys = of_count_phandle_with_args(dev->dev.of_node,
+ "phys", "#phy-cells");
+ priv->num_phys = priv->num_phys > 0 ? priv->num_phys : 1;
+
+ priv->phys = devm_kcalloc(&dev->dev, priv->num_phys,
+ sizeof(struct phy *), GFP_KERNEL);
+ if (!priv->phys)
+ return -ENOMEM;
+
+ for (phy_num = 0; phy_num < priv->num_phys; phy_num++) {
+ err = of_property_read_string_index(
+ dev->dev.of_node,
+ "phy-names", phy_num,
+ &phy_name);
+
+ if (err < 0) {
+ if (priv->num_phys > 1) {
+ dev_err(&dev->dev, "phy-names not provided");
+ goto err_put_hcd;
+ } else
+ phy_name = "usb";
+ }
+
+ priv->phys[phy_num] = devm_phy_get(&dev->dev,
+ phy_name);
+ if (IS_ERR(priv->phys[phy_num])) {
+ err = PTR_ERR(priv->phys[phy_num]);
+ if ((priv->num_phys > 1) ||
+ (err == -EPROBE_DEFER))
+ goto err_put_hcd;
+ priv->phys[phy_num] = NULL;
+ }
}
for (clk = 0; clk < OHCI_MAX_CLKS; clk++) {
--
2.2.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCHv3 1/2] usb: ehci-platform: add support for multiple phys per controller
2015-01-20 0:05 ` [PATCHv3 1/2] usb: ehci-platform: add support for multiple phys per controller arun.ramamurthy
@ 2015-01-21 15:03 ` Alan Stern
2015-01-21 19:13 ` Arun Ramamurthy
0 siblings, 1 reply; 6+ messages in thread
From: Alan Stern @ 2015-01-21 15:03 UTC (permalink / raw)
To: arun.ramamurthy
Cc: linux, gregkh, linux-usb, linux-arm-kernel, linux-kernel,
sbranden, rjui, Arun Ramamurthy
On Mon, 19 Jan 2015 arun.ramamurthy@broadcom.com wrote:
> From: Arun Ramamurthy <arunrama@broadcom.com>
>
> Added support for cases where one controller is connected
> to multiple phys.
>
> Signed-off-by: Arun Ramamurthy <arunrama@broadcom.com>
> Reviewed-by: Ray Jui <rjui@broadcom.com>
> Reviewed-by: Scott Branden <sbranden@broadcom.com>
> Tested-by: Scott Branden <sbranden@broadcom.com>
> ---
Right here is where you should explain how v3 of this patch is
different from v2.
Anyway, it looks good.
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Did you run it through checkpatch.pl?
Alan Stern
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCHv3 1/2] usb: ehci-platform: add support for multiple phys per controller
2015-01-21 15:03 ` Alan Stern
@ 2015-01-21 19:13 ` Arun Ramamurthy
2015-01-21 20:40 ` Alan Stern
0 siblings, 1 reply; 6+ messages in thread
From: Arun Ramamurthy @ 2015-01-21 19:13 UTC (permalink / raw)
To: Alan Stern
Cc: linux, gregkh, linux-usb, linux-arm-kernel, linux-kernel,
sbranden, rjui, Arun Ramamurthy
Thanks Alan. I did run check patch and I had no errors or warnings.
I explained my changes in v3 in the cover patch, did that not come
through or is it convention to do it in the individual patch?
Is the ack for the ohci patch as well? Thanks
Arun Ramamurthy
On 15-01-21 07:03 AM, Alan Stern wrote:
> On Mon, 19 Jan 2015 arun.ramamurthy@broadcom.com wrote:
>
>> From: Arun Ramamurthy <arunrama@broadcom.com>
>>
>> Added support for cases where one controller is connected
>> to multiple phys.
>>
>> Signed-off-by: Arun Ramamurthy <arunrama@broadcom.com>
>> Reviewed-by: Ray Jui <rjui@broadcom.com>
>> Reviewed-by: Scott Branden <sbranden@broadcom.com>
>> Tested-by: Scott Branden <sbranden@broadcom.com>
>> ---
>
> Right here is where you should explain how v3 of this patch is
> different from v2.
>
> Anyway, it looks good.
>
> Acked-by: Alan Stern <stern@rowland.harvard.edu>
>
> Did you run it through checkpatch.pl?
>
> Alan Stern
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCHv3 1/2] usb: ehci-platform: add support for multiple phys per controller
2015-01-21 19:13 ` Arun Ramamurthy
@ 2015-01-21 20:40 ` Alan Stern
0 siblings, 0 replies; 6+ messages in thread
From: Alan Stern @ 2015-01-21 20:40 UTC (permalink / raw)
To: Arun Ramamurthy
Cc: linux, gregkh, linux-usb, linux-arm-kernel, linux-kernel,
sbranden, rjui, Arun Ramamurthy
On Wed, 21 Jan 2015, Arun Ramamurthy wrote:
> Thanks Alan. I did run check patch and I had no errors or warnings.
>
> I explained my changes in v3 in the cover patch, did that not come
> through or is it convention to do it in the individual patch?
Oh, sorry, I missed it. Must have deleted that email by mistake.
> Is the ack for the ohci patch as well? Thanks
Yes.
Alan Stern
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-01-21 20:40 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-20 0:05 [PATCHv3 0/2] Added Multiple Phy support for ehci and ohci drivers arun.ramamurthy
2015-01-20 0:05 ` [PATCHv3 1/2] usb: ehci-platform: add support for multiple phys per controller arun.ramamurthy
2015-01-21 15:03 ` Alan Stern
2015-01-21 19:13 ` Arun Ramamurthy
2015-01-21 20:40 ` Alan Stern
2015-01-20 0:05 ` [PATCHv3 2/2] usb: ohci-platform: " arun.ramamurthy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).