* [PATCH v3 0/4] phy: rcar-gen3-usb2: add support for r8a77995
@ 2017-09-01 2:41 Yoshihiro Shimoda
2017-09-01 2:41 ` [PATCH v3 1/4] phy: rcar-gen3-usb2: check dr_mode for otg mode Yoshihiro Shimoda
` (4 more replies)
0 siblings, 5 replies; 12+ messages in thread
From: Yoshihiro Shimoda @ 2017-09-01 2:41 UTC (permalink / raw)
To: kishon; +Cc: linux-kernel, linux-renesas-soc, Yoshihiro Shimoda
This patch set is based on the latest phy.git / next branch
(the commit id = d9c51f4c53ae2af03aa8bd001d46f21b0adcdab8).
After this patch set is applied, a usb 2.0 host node that is combined
with usb 2.0 peripheral needs 'dr_mode = "otg";' property.
Changes from v2:
- Revise the commit log ("SoCs" is not third-person singular present).
Changes from v1:
- Revise typo "wronly" to "wrongly".
- Remove RCAR_GEN3_PHY_HAS_DEDICATED_PINS from generic gen3 entry in
patch 3/4
- Remove the driver change from patch 4/4.
- Revise the commit log of patch 4/4.
Yoshihiro Shimoda (4):
phy: rcar-gen3-usb2: check dr_mode for otg mode
phy: rcar-gen3-usb2: split the two meaning of "has_otg"
phy: rcar-gen3-usb2: add SoC-specific parameter for dedicated pins
phy: rcar-gen3-usb2: add binding for r8a77995
.../devicetree/bindings/phy/rcar-gen3-phy-usb2.txt | 2 +
drivers/phy/renesas/phy-rcar-gen3-usb2.c | 93 ++++++++++++++++------
2 files changed, 69 insertions(+), 26 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v3 1/4] phy: rcar-gen3-usb2: check dr_mode for otg mode
2017-09-01 2:41 [PATCH v3 0/4] phy: rcar-gen3-usb2: add support for r8a77995 Yoshihiro Shimoda
@ 2017-09-01 2:41 ` Yoshihiro Shimoda
2017-10-06 9:15 ` Simon Horman
2017-09-01 2:41 ` [PATCH v3 2/4] phy: rcar-gen3-usb2: split the two meaning of "has_otg" Yoshihiro Shimoda
` (3 subsequent siblings)
4 siblings, 1 reply; 12+ messages in thread
From: Yoshihiro Shimoda @ 2017-09-01 2:41 UTC (permalink / raw)
To: kishon; +Cc: linux-kernel, linux-renesas-soc, Yoshihiro Shimoda
The previous code assumed a channel has otg capability if a channel
has interrupt property. But, it is not good because:
- Battery charging feature also needs interrupt property.
- Some R-Car Gen3 SoCs (e.g. R-Car D3) don't have OTG capability.
So, this patch checks whether usb 2.0 host node has dr_mode property or
not. If it has 'dr_mode = "otg";', this driver enables otg capability.
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
drivers/phy/renesas/phy-rcar-gen3-usb2.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
index 54c3429..e00e99a 100644
--- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
+++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
@@ -1,7 +1,7 @@
/*
* Renesas R-Car Gen3 for USB2.0 PHY driver
*
- * Copyright (C) 2015 Renesas Electronics Corporation
+ * Copyright (C) 2015-2017 Renesas Electronics Corporation
*
* This is based on the phy-rcar-gen2 driver:
* Copyright (C) 2014 Renesas Solutions Corp.
@@ -22,6 +22,7 @@
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/regulator/consumer.h>
+#include <linux/usb/of.h>
#include <linux/workqueue.h>
/******* USB2.0 Host registers (original offset is +0x200) *******/
@@ -415,13 +416,16 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
/* call request_irq for OTG */
irq = platform_get_irq(pdev, 0);
if (irq >= 0) {
- int ret;
-
INIT_WORK(&channel->work, rcar_gen3_phy_usb2_work);
irq = devm_request_irq(dev, irq, rcar_gen3_phy_usb2_irq,
IRQF_SHARED, dev_name(dev), channel);
if (irq < 0)
dev_err(dev, "No irq handler (%d)\n", irq);
+ }
+
+ if (of_usb_get_dr_mode_by_phy(dev->of_node, 0) == USB_DR_MODE_OTG) {
+ int ret;
+
channel->has_otg = true;
channel->extcon = devm_extcon_dev_allocate(dev,
rcar_gen3_phy_cable);
--
1.9.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v3 2/4] phy: rcar-gen3-usb2: split the two meaning of "has_otg"
2017-09-01 2:41 [PATCH v3 0/4] phy: rcar-gen3-usb2: add support for r8a77995 Yoshihiro Shimoda
2017-09-01 2:41 ` [PATCH v3 1/4] phy: rcar-gen3-usb2: check dr_mode for otg mode Yoshihiro Shimoda
@ 2017-09-01 2:41 ` Yoshihiro Shimoda
2017-10-06 9:15 ` Simon Horman
2017-10-09 10:06 ` Kishon Vijay Abraham I
2017-09-01 2:41 ` [PATCH v3 3/4] phy: rcar-gen3-usb2: add SoC-specific parameter for dedicated pins Yoshihiro Shimoda
` (2 subsequent siblings)
4 siblings, 2 replies; 12+ messages in thread
From: Yoshihiro Shimoda @ 2017-09-01 2:41 UTC (permalink / raw)
To: kishon; +Cc: linux-kernel, linux-renesas-soc, Yoshihiro Shimoda
The has_otg on previous code has the two meaning:
- The channel has dedicated otg pins (ID, VBUS).
- The channel can swap the role via sysfs.
However, some SoCs (e.g. R-Car D3) doesn't have such dedicated pins,
but the SoCs can swap the role. So, this patch split the two meaning
of has_otg as "has dedicated otg pins" and adds a new value
"can_role_swap". For now, the behavior is the same as before.
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
drivers/phy/renesas/phy-rcar-gen3-usb2.c | 61 ++++++++++++++++++++++----------
1 file changed, 42 insertions(+), 19 deletions(-)
diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
index e00e99a..4ea9902 100644
--- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
+++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
@@ -87,7 +87,8 @@ struct rcar_gen3_chan {
struct regulator *vbus;
struct work_struct work;
bool extcon_host;
- bool has_otg;
+ bool has_otg; /* has dedicated pins (ID, VBUS) */
+ bool can_role_swap;
};
static void rcar_gen3_phy_usb2_work(struct work_struct *work)
@@ -219,14 +220,10 @@ static bool rcar_gen3_is_host(struct rcar_gen3_chan *ch)
return !(readl(ch->base + USB2_COMMCTRL) & USB2_COMMCTRL_OTG_PERI);
}
-static ssize_t role_store(struct device *dev, struct device_attribute *attr,
- const char *buf, size_t count)
+static ssize_t rcar_gen3_otg_change_role(struct rcar_gen3_chan *ch,
+ bool new_mode_is_host)
{
- struct rcar_gen3_chan *ch = dev_get_drvdata(dev);
- bool is_b_device, is_host, new_mode_is_host;
-
- if (!ch->has_otg || !ch->phy->init_count)
- return -EIO;
+ bool is_b_device, is_host;
/*
* is_b_device: true is B-Device. false is A-Device.
@@ -234,12 +231,6 @@ static ssize_t role_store(struct device *dev, struct device_attribute *attr,
*/
is_b_device = rcar_gen3_check_id(ch);
is_host = rcar_gen3_is_host(ch);
- if (!strncmp(buf, "host", strlen("host")))
- new_mode_is_host = true;
- else if (!strncmp(buf, "peripheral", strlen("peripheral")))
- new_mode_is_host = false;
- else
- return -EINVAL;
/* If current and new mode is the same, this returns the error */
if (is_host == new_mode_is_host)
@@ -257,6 +248,32 @@ static ssize_t role_store(struct device *dev, struct device_attribute *attr,
rcar_gen3_init_for_peri(ch);
}
+ return 0;
+}
+
+static ssize_t role_store(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct rcar_gen3_chan *ch = dev_get_drvdata(dev);
+ bool new_mode_is_host;
+ ssize_t ret = -EIO;
+
+ if (!ch->phy->init_count)
+ return -EIO;
+
+ if (!strncmp(buf, "host", strlen("host")))
+ new_mode_is_host = true;
+ else if (!strncmp(buf, "peripheral", strlen("peripheral")))
+ new_mode_is_host = false;
+ else
+ return -EINVAL;
+
+ if (ch->has_otg)
+ ret = rcar_gen3_otg_change_role(ch, new_mode_is_host);
+
+ if (ret < 0)
+ return ret;
+
return count;
}
@@ -264,12 +281,17 @@ static ssize_t role_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct rcar_gen3_chan *ch = dev_get_drvdata(dev);
+ bool is_host;
- if (!ch->has_otg || !ch->phy->init_count)
+ if (!ch->phy->init_count)
return -EIO;
- return sprintf(buf, "%s\n", rcar_gen3_is_host(ch) ? "host" :
- "peripheral");
+ if (ch->has_otg)
+ is_host = rcar_gen3_is_host(ch);
+ else
+ return -EIO;
+
+ return sprintf(buf, "%s\n", is_host ? "host" : "peripheral");
}
static DEVICE_ATTR_RW(role);
@@ -427,6 +449,7 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
int ret;
channel->has_otg = true;
+ channel->can_role_swap = true;
channel->extcon = devm_extcon_dev_allocate(dev,
rcar_gen3_phy_cable);
if (IS_ERR(channel->extcon))
@@ -468,7 +491,7 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
dev_err(dev, "Failed to register PHY provider\n");
ret = PTR_ERR(provider);
goto error;
- } else if (channel->has_otg) {
+ } else if (channel->can_role_swap) {
int ret;
ret = device_create_file(dev, &dev_attr_role);
@@ -488,7 +511,7 @@ static int rcar_gen3_phy_usb2_remove(struct platform_device *pdev)
{
struct rcar_gen3_chan *channel = platform_get_drvdata(pdev);
- if (channel->has_otg)
+ if (channel->can_role_swap)
device_remove_file(&pdev->dev, &dev_attr_role);
pm_runtime_disable(&pdev->dev);
--
1.9.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v3 3/4] phy: rcar-gen3-usb2: add SoC-specific parameter for dedicated pins
2017-09-01 2:41 [PATCH v3 0/4] phy: rcar-gen3-usb2: add support for r8a77995 Yoshihiro Shimoda
2017-09-01 2:41 ` [PATCH v3 1/4] phy: rcar-gen3-usb2: check dr_mode for otg mode Yoshihiro Shimoda
2017-09-01 2:41 ` [PATCH v3 2/4] phy: rcar-gen3-usb2: split the two meaning of "has_otg" Yoshihiro Shimoda
@ 2017-09-01 2:41 ` Yoshihiro Shimoda
2017-10-06 9:14 ` Simon Horman
2017-09-01 2:41 ` [PATCH v3 4/4] phy: rcar-gen3-usb2: add binding for r8a77995 Yoshihiro Shimoda
2017-10-06 2:13 ` [PATCH v3 0/4] phy: rcar-gen3-usb2: add support " Yoshihiro Shimoda
4 siblings, 1 reply; 12+ messages in thread
From: Yoshihiro Shimoda @ 2017-09-01 2:41 UTC (permalink / raw)
To: kishon; +Cc: linux-kernel, linux-renesas-soc, Yoshihiro Shimoda
This patch adds SoC-specific parameter to avoid reading/writing
specific registers wrongly if this driver runs on a SoC which doesn't
have dedicated pins (e.g. R-Car D3).
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
drivers/phy/renesas/phy-rcar-gen3-usb2.c | 24 +++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
index 4ea9902..15e095e 100644
--- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
+++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
@@ -18,6 +18,7 @@
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_address.h>
+#include <linux/of_device.h>
#include <linux/phy/phy.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
@@ -80,6 +81,8 @@
#define USB2_ADPCTRL_IDPULLUP BIT(5) /* 1 = ID sampling is enabled */
#define USB2_ADPCTRL_DRVVBUS BIT(4)
+#define RCAR_GEN3_PHY_HAS_DEDICATED_PINS 1
+
struct rcar_gen3_chan {
void __iomem *base;
struct extcon_dev *extcon;
@@ -400,9 +403,17 @@ static irqreturn_t rcar_gen3_phy_usb2_irq(int irq, void *_ch)
}
static const struct of_device_id rcar_gen3_phy_usb2_match_table[] = {
- { .compatible = "renesas,usb2-phy-r8a7795" },
- { .compatible = "renesas,usb2-phy-r8a7796" },
- { .compatible = "renesas,rcar-gen3-usb2-phy" },
+ {
+ .compatible = "renesas,usb2-phy-r8a7795",
+ .data = (void *)RCAR_GEN3_PHY_HAS_DEDICATED_PINS,
+ },
+ {
+ .compatible = "renesas,usb2-phy-r8a7796",
+ .data = (void *)RCAR_GEN3_PHY_HAS_DEDICATED_PINS,
+ },
+ {
+ .compatible = "renesas,rcar-gen3-usb2-phy",
+ },
{ }
};
MODULE_DEVICE_TABLE(of, rcar_gen3_phy_usb2_match_table);
@@ -446,9 +457,12 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
}
if (of_usb_get_dr_mode_by_phy(dev->of_node, 0) == USB_DR_MODE_OTG) {
- int ret;
+ int ret, dedicated_pins;
+ const struct of_device_id *of_id =
+ of_match_device(rcar_gen3_phy_usb2_match_table, dev);
- channel->has_otg = true;
+ dedicated_pins = of_id ? (uintptr_t)of_id->data : 0;
+ channel->has_otg = !!dedicated_pins;
channel->can_role_swap = true;
channel->extcon = devm_extcon_dev_allocate(dev,
rcar_gen3_phy_cable);
--
1.9.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v3 4/4] phy: rcar-gen3-usb2: add binding for r8a77995
2017-09-01 2:41 [PATCH v3 0/4] phy: rcar-gen3-usb2: add support for r8a77995 Yoshihiro Shimoda
` (2 preceding siblings ...)
2017-09-01 2:41 ` [PATCH v3 3/4] phy: rcar-gen3-usb2: add SoC-specific parameter for dedicated pins Yoshihiro Shimoda
@ 2017-09-01 2:41 ` Yoshihiro Shimoda
2017-10-06 9:14 ` Simon Horman
2017-10-06 2:13 ` [PATCH v3 0/4] phy: rcar-gen3-usb2: add support " Yoshihiro Shimoda
4 siblings, 1 reply; 12+ messages in thread
From: Yoshihiro Shimoda @ 2017-09-01 2:41 UTC (permalink / raw)
To: kishon; +Cc: linux-kernel, linux-renesas-soc, Yoshihiro Shimoda
This patch adds binding for r8a77995 (R-Car D3). Since r8a77995 doesn't
have dedicated pins (ID, VBUS), this will match against the generic
fallback on R-Car D3.
For now, this driver doesn't support usb role swap for r8a77995.
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
index ace9cce..99b651b 100644
--- a/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
+++ b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
@@ -8,6 +8,8 @@ Required properties:
SoC.
"renesas,usb2-phy-r8a7796" if the device is a part of an R8A7796
SoC.
+ "renesas,usb2-phy-r8a77995" if the device is a part of an
+ R8A77995 SoC.
"renesas,rcar-gen3-usb2-phy" for a generic R-Car Gen3 compatible device.
When compatible with the generic version, nodes must list the
--
1.9.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* RE: [PATCH v3 0/4] phy: rcar-gen3-usb2: add support for r8a77995
2017-09-01 2:41 [PATCH v3 0/4] phy: rcar-gen3-usb2: add support for r8a77995 Yoshihiro Shimoda
` (3 preceding siblings ...)
2017-09-01 2:41 ` [PATCH v3 4/4] phy: rcar-gen3-usb2: add binding for r8a77995 Yoshihiro Shimoda
@ 2017-10-06 2:13 ` Yoshihiro Shimoda
4 siblings, 0 replies; 12+ messages in thread
From: Yoshihiro Shimoda @ 2017-10-06 2:13 UTC (permalink / raw)
To: kishon@ti.com
Cc: linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org
Hi Kishon,
Would you review this patch set?
I checked this can apply your latest linux-phy.git / next branch (the commit id = 415060b21f31).
Best regards,
Yoshihiro Shimoda
> -----Original Message-----
> From: Yoshihiro Shimoda
> Sent: Friday, September 1, 2017 11:41 AM
> To: kishon@ti.com
> Cc: linux-kernel@vger.kernel.org; linux-renesas-soc@vger.kernel.org; Yoshihiro Shimoda
> <yoshihiro.shimoda.uh@renesas.com>
> Subject: [PATCH v3 0/4] phy: rcar-gen3-usb2: add support for r8a77995
>
> This patch set is based on the latest phy.git / next branch
> (the commit id = d9c51f4c53ae2af03aa8bd001d46f21b0adcdab8).
>
> After this patch set is applied, a usb 2.0 host node that is combined
> with usb 2.0 peripheral needs 'dr_mode = "otg";' property.
>
> Changes from v2:
> - Revise the commit log ("SoCs" is not third-person singular present).
>
> Changes from v1:
> - Revise typo "wronly" to "wrongly".
> - Remove RCAR_GEN3_PHY_HAS_DEDICATED_PINS from generic gen3 entry in
> patch 3/4
> - Remove the driver change from patch 4/4.
> - Revise the commit log of patch 4/4.
>
> Yoshihiro Shimoda (4):
> phy: rcar-gen3-usb2: check dr_mode for otg mode
> phy: rcar-gen3-usb2: split the two meaning of "has_otg"
> phy: rcar-gen3-usb2: add SoC-specific parameter for dedicated pins
> phy: rcar-gen3-usb2: add binding for r8a77995
>
> .../devicetree/bindings/phy/rcar-gen3-phy-usb2.txt | 2 +
> drivers/phy/renesas/phy-rcar-gen3-usb2.c | 93 ++++++++++++++++------
> 2 files changed, 69 insertions(+), 26 deletions(-)
>
> --
> 1.9.1
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 3/4] phy: rcar-gen3-usb2: add SoC-specific parameter for dedicated pins
2017-09-01 2:41 ` [PATCH v3 3/4] phy: rcar-gen3-usb2: add SoC-specific parameter for dedicated pins Yoshihiro Shimoda
@ 2017-10-06 9:14 ` Simon Horman
0 siblings, 0 replies; 12+ messages in thread
From: Simon Horman @ 2017-10-06 9:14 UTC (permalink / raw)
To: Yoshihiro Shimoda; +Cc: kishon, linux-kernel, linux-renesas-soc
On Fri, Sep 01, 2017 at 11:41:24AM +0900, Yoshihiro Shimoda wrote:
> This patch adds SoC-specific parameter to avoid reading/writing
> specific registers wrongly if this driver runs on a SoC which doesn't
> have dedicated pins (e.g. R-Car D3).
>
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
> ---
> drivers/phy/renesas/phy-rcar-gen3-usb2.c | 24 +++++++++++++++++++-----
> 1 file changed, 19 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> index 4ea9902..15e095e 100644
> --- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> +++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> @@ -18,6 +18,7 @@
> #include <linux/module.h>
> #include <linux/of.h>
> #include <linux/of_address.h>
> +#include <linux/of_device.h>
> #include <linux/phy/phy.h>
> #include <linux/platform_device.h>
> #include <linux/pm_runtime.h>
> @@ -80,6 +81,8 @@
> #define USB2_ADPCTRL_IDPULLUP BIT(5) /* 1 = ID sampling is enabled */
> #define USB2_ADPCTRL_DRVVBUS BIT(4)
>
> +#define RCAR_GEN3_PHY_HAS_DEDICATED_PINS 1
> +
> struct rcar_gen3_chan {
> void __iomem *base;
> struct extcon_dev *extcon;
> @@ -400,9 +403,17 @@ static irqreturn_t rcar_gen3_phy_usb2_irq(int irq, void *_ch)
> }
>
> static const struct of_device_id rcar_gen3_phy_usb2_match_table[] = {
> - { .compatible = "renesas,usb2-phy-r8a7795" },
> - { .compatible = "renesas,usb2-phy-r8a7796" },
> - { .compatible = "renesas,rcar-gen3-usb2-phy" },
> + {
> + .compatible = "renesas,usb2-phy-r8a7795",
> + .data = (void *)RCAR_GEN3_PHY_HAS_DEDICATED_PINS,
> + },
> + {
> + .compatible = "renesas,usb2-phy-r8a7796",
> + .data = (void *)RCAR_GEN3_PHY_HAS_DEDICATED_PINS,
> + },
> + {
> + .compatible = "renesas,rcar-gen3-usb2-phy",
> + },
> { }
> };
> MODULE_DEVICE_TABLE(of, rcar_gen3_phy_usb2_match_table);
> @@ -446,9 +457,12 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
> }
>
> if (of_usb_get_dr_mode_by_phy(dev->of_node, 0) == USB_DR_MODE_OTG) {
> - int ret;
> + int ret, dedicated_pins;
> + const struct of_device_id *of_id =
> + of_match_device(rcar_gen3_phy_usb2_match_table, dev);
>
> - channel->has_otg = true;
> + dedicated_pins = of_id ? (uintptr_t)of_id->data : 0;
Nit: I think you could use of_device_get_match_data() here.
> + channel->has_otg = !!dedicated_pins;
> channel->can_role_swap = true;
> channel->extcon = devm_extcon_dev_allocate(dev,
> rcar_gen3_phy_cable);
> --
> 1.9.1
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 4/4] phy: rcar-gen3-usb2: add binding for r8a77995
2017-09-01 2:41 ` [PATCH v3 4/4] phy: rcar-gen3-usb2: add binding for r8a77995 Yoshihiro Shimoda
@ 2017-10-06 9:14 ` Simon Horman
0 siblings, 0 replies; 12+ messages in thread
From: Simon Horman @ 2017-10-06 9:14 UTC (permalink / raw)
To: Yoshihiro Shimoda; +Cc: kishon, linux-kernel, linux-renesas-soc
On Fri, Sep 01, 2017 at 11:41:25AM +0900, Yoshihiro Shimoda wrote:
> This patch adds binding for r8a77995 (R-Car D3). Since r8a77995 doesn't
> have dedicated pins (ID, VBUS), this will match against the generic
> fallback on R-Car D3.
>
> For now, this driver doesn't support usb role swap for r8a77995.
>
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
> ---
> Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
> index ace9cce..99b651b 100644
> --- a/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
> +++ b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
> @@ -8,6 +8,8 @@ Required properties:
> SoC.
> "renesas,usb2-phy-r8a7796" if the device is a part of an R8A7796
> SoC.
> + "renesas,usb2-phy-r8a77995" if the device is a part of an
> + R8A77995 SoC.
> "renesas,rcar-gen3-usb2-phy" for a generic R-Car Gen3 compatible device.
>
> When compatible with the generic version, nodes must list the
> --
> 1.9.1
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 2/4] phy: rcar-gen3-usb2: split the two meaning of "has_otg"
2017-09-01 2:41 ` [PATCH v3 2/4] phy: rcar-gen3-usb2: split the two meaning of "has_otg" Yoshihiro Shimoda
@ 2017-10-06 9:15 ` Simon Horman
2017-10-09 10:06 ` Kishon Vijay Abraham I
1 sibling, 0 replies; 12+ messages in thread
From: Simon Horman @ 2017-10-06 9:15 UTC (permalink / raw)
To: Yoshihiro Shimoda; +Cc: kishon, linux-kernel, linux-renesas-soc
On Fri, Sep 01, 2017 at 11:41:23AM +0900, Yoshihiro Shimoda wrote:
> The has_otg on previous code has the two meaning:
> - The channel has dedicated otg pins (ID, VBUS).
> - The channel can swap the role via sysfs.
>
> However, some SoCs (e.g. R-Car D3) doesn't have such dedicated pins,
> but the SoCs can swap the role. So, this patch split the two meaning
> of has_otg as "has dedicated otg pins" and adds a new value
> "can_role_swap". For now, the behavior is the same as before.
>
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
> ---
> drivers/phy/renesas/phy-rcar-gen3-usb2.c | 61 ++++++++++++++++++++++----------
> 1 file changed, 42 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> index e00e99a..4ea9902 100644
> --- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> +++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> @@ -87,7 +87,8 @@ struct rcar_gen3_chan {
> struct regulator *vbus;
> struct work_struct work;
> bool extcon_host;
> - bool has_otg;
> + bool has_otg; /* has dedicated pins (ID, VBUS) */
Not: has_otg_pins might make for slightly easier reading of the code.
> + bool can_role_swap;
> };
...
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 1/4] phy: rcar-gen3-usb2: check dr_mode for otg mode
2017-09-01 2:41 ` [PATCH v3 1/4] phy: rcar-gen3-usb2: check dr_mode for otg mode Yoshihiro Shimoda
@ 2017-10-06 9:15 ` Simon Horman
0 siblings, 0 replies; 12+ messages in thread
From: Simon Horman @ 2017-10-06 9:15 UTC (permalink / raw)
To: Yoshihiro Shimoda; +Cc: kishon, linux-kernel, linux-renesas-soc
On Fri, Sep 01, 2017 at 11:41:22AM +0900, Yoshihiro Shimoda wrote:
> The previous code assumed a channel has otg capability if a channel
> has interrupt property. But, it is not good because:
> - Battery charging feature also needs interrupt property.
> - Some R-Car Gen3 SoCs (e.g. R-Car D3) don't have OTG capability.
>
> So, this patch checks whether usb 2.0 host node has dr_mode property or
> not. If it has 'dr_mode = "otg";', this driver enables otg capability.
>
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 2/4] phy: rcar-gen3-usb2: split the two meaning of "has_otg"
2017-09-01 2:41 ` [PATCH v3 2/4] phy: rcar-gen3-usb2: split the two meaning of "has_otg" Yoshihiro Shimoda
2017-10-06 9:15 ` Simon Horman
@ 2017-10-09 10:06 ` Kishon Vijay Abraham I
2017-10-10 5:59 ` Yoshihiro Shimoda
1 sibling, 1 reply; 12+ messages in thread
From: Kishon Vijay Abraham I @ 2017-10-09 10:06 UTC (permalink / raw)
To: Yoshihiro Shimoda; +Cc: linux-kernel, linux-renesas-soc
Hi,
On Friday 01 September 2017 08:11 AM, Yoshihiro Shimoda wrote:
> The has_otg on previous code has the two meaning:
> - The channel has dedicated otg pins (ID, VBUS).
> - The channel can swap the role via sysfs.
>
> However, some SoCs (e.g. R-Car D3) doesn't have such dedicated pins,
> but the SoCs can swap the role. So, this patch split the two meaning
> of has_otg as "has dedicated otg pins" and adds a new value
> "can_role_swap". For now, the behavior is the same as before.
Might not be directly related to $patch, but in general certain cleanups can be
done..
>
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> ---
> drivers/phy/renesas/phy-rcar-gen3-usb2.c | 61 ++++++++++++++++++++++----------
> 1 file changed, 42 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> index e00e99a..4ea9902 100644
> --- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> +++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> @@ -87,7 +87,8 @@ struct rcar_gen3_chan {
> struct regulator *vbus;
> struct work_struct work;
> bool extcon_host;
> - bool has_otg;
> + bool has_otg; /* has dedicated pins (ID, VBUS) */
> + bool can_role_swap;
> };
>
> static void rcar_gen3_phy_usb2_work(struct work_struct *work)
> @@ -219,14 +220,10 @@ static bool rcar_gen3_is_host(struct rcar_gen3_chan *ch)
> return !(readl(ch->base + USB2_COMMCTRL) & USB2_COMMCTRL_OTG_PERI);
> }
>
> -static ssize_t role_store(struct device *dev, struct device_attribute *attr,
> - const char *buf, size_t count)
> +static ssize_t rcar_gen3_otg_change_role(struct rcar_gen3_chan *ch,
> + bool new_mode_is_host)
replace new_mode_is_host with enum mode.
> {
> - struct rcar_gen3_chan *ch = dev_get_drvdata(dev);
> - bool is_b_device, is_host, new_mode_is_host;
> -
> - if (!ch->has_otg || !ch->phy->init_count)
> - return -EIO;
> + bool is_b_device, is_host;
>
> /*
> * is_b_device: true is B-Device. false is A-Device.
> @@ -234,12 +231,6 @@ static ssize_t role_store(struct device *dev, struct device_attribute *attr,
> */
> is_b_device = rcar_gen3_check_id(ch);
> is_host = rcar_gen3_is_host(ch);
> - if (!strncmp(buf, "host", strlen("host")))
> - new_mode_is_host = true;
> - else if (!strncmp(buf, "peripheral", strlen("peripheral")))
> - new_mode_is_host = false;
> - else
> - return -EINVAL;
>
> /* If current and new mode is the same, this returns the error */
> if (is_host == new_mode_is_host)
> @@ -257,6 +248,32 @@ static ssize_t role_store(struct device *dev, struct device_attribute *attr,
> rcar_gen3_init_for_peri(ch);
> }
>
> + return 0;
> +}
> +
> +static ssize_t role_store(struct device *dev, struct device_attribute *attr,
> + const char *buf, size_t count)
> +{
> + struct rcar_gen3_chan *ch = dev_get_drvdata(dev);
> + bool new_mode_is_host;
> + ssize_t ret = -EIO;
> +
> + if (!ch->phy->init_count)
> + return -EIO;
> +
> + if (!strncmp(buf, "host", strlen("host")))
> + new_mode_is_host = true;
> + else if (!strncmp(buf, "peripheral", strlen("peripheral")))
> + new_mode_is_host = false;
set the enum mode here.
> + else
> + return -EINVAL;
> +
> + if (ch->has_otg)
> + ret = rcar_gen3_otg_change_role(ch, new_mode_is_host);
Aren't you using sysfs to change the role here?
> +
> + if (ret < 0)
> + return ret;
> +
> return count;
> }
>
> @@ -264,12 +281,17 @@ static ssize_t role_show(struct device *dev, struct device_attribute *attr,
> char *buf)
> {
> struct rcar_gen3_chan *ch = dev_get_drvdata(dev);
> + bool is_host;
>
> - if (!ch->has_otg || !ch->phy->init_count)
> + if (!ch->phy->init_count)
> return -EIO;
>
> - return sprintf(buf, "%s\n", rcar_gen3_is_host(ch) ? "host" :
> - "peripheral");
> + if (ch->has_otg)
> + is_host = rcar_gen3_is_host(ch);
> + else
> + return -EIO;
> +
> + return sprintf(buf, "%s\n", is_host ? "host" : "peripheral");
> }
> static DEVICE_ATTR_RW(role);
>
> @@ -427,6 +449,7 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
> int ret;
>
> channel->has_otg = true;
> + channel->can_role_swap = true;
Can both has_otg and can_role_swap be true?
Thanks
Kishon
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH v3 2/4] phy: rcar-gen3-usb2: split the two meaning of "has_otg"
2017-10-09 10:06 ` Kishon Vijay Abraham I
@ 2017-10-10 5:59 ` Yoshihiro Shimoda
0 siblings, 0 replies; 12+ messages in thread
From: Yoshihiro Shimoda @ 2017-10-10 5:59 UTC (permalink / raw)
To: Kishon Vijay Abraham I
Cc: linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org
Hi,
Thank you for the comment!
I will submit v4 patch soon. But, I wrote some comments below.
> From: Kishon Vijay Abraham I, Sent: Monday, October 9, 2017 7:07 PM
>
> Hi,
>
> On Friday 01 September 2017 08:11 AM, Yoshihiro Shimoda wrote:
> > The has_otg on previous code has the two meaning:
> > - The channel has dedicated otg pins (ID, VBUS).
> > - The channel can swap the role via sysfs.
> >
> > However, some SoCs (e.g. R-Car D3) doesn't have such dedicated pins,
> > but the SoCs can swap the role. So, this patch split the two meaning
> > of has_otg as "has dedicated otg pins" and adds a new value
> > "can_role_swap". For now, the behavior is the same as before.
>
> Might not be directly related to $patch, but in general certain cleanups can be
> done..
> >
> > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> > ---
> > drivers/phy/renesas/phy-rcar-gen3-usb2.c | 61 ++++++++++++++++++++++----------
> > 1 file changed, 42 insertions(+), 19 deletions(-)
> >
> > diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> > index e00e99a..4ea9902 100644
> > --- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> > +++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> > @@ -87,7 +87,8 @@ struct rcar_gen3_chan {
> > struct regulator *vbus;
> > struct work_struct work;
> > bool extcon_host;
> > - bool has_otg;
> > + bool has_otg; /* has dedicated pins (ID, VBUS) */
> > + bool can_role_swap;
> > };
> >
> > static void rcar_gen3_phy_usb2_work(struct work_struct *work)
> > @@ -219,14 +220,10 @@ static bool rcar_gen3_is_host(struct rcar_gen3_chan *ch)
> > return !(readl(ch->base + USB2_COMMCTRL) & USB2_COMMCTRL_OTG_PERI);
> > }
> >
> > -static ssize_t role_store(struct device *dev, struct device_attribute *attr,
> > - const char *buf, size_t count)
> > +static ssize_t rcar_gen3_otg_change_role(struct rcar_gen3_chan *ch,
> > + bool new_mode_is_host)
>
> replace new_mode_is_host with enum mode.
I got it. I will replace it in v4 patch.
> > {
> > - struct rcar_gen3_chan *ch = dev_get_drvdata(dev);
> > - bool is_b_device, is_host, new_mode_is_host;
> > -
> > - if (!ch->has_otg || !ch->phy->init_count)
> > - return -EIO;
> > + bool is_b_device, is_host;
> >
> > /*
> > * is_b_device: true is B-Device. false is A-Device.
> > @@ -234,12 +231,6 @@ static ssize_t role_store(struct device *dev, struct device_attribute *attr,
> > */
> > is_b_device = rcar_gen3_check_id(ch);
> > is_host = rcar_gen3_is_host(ch);
> > - if (!strncmp(buf, "host", strlen("host")))
> > - new_mode_is_host = true;
> > - else if (!strncmp(buf, "peripheral", strlen("peripheral")))
> > - new_mode_is_host = false;
> > - else
> > - return -EINVAL;
> >
> > /* If current and new mode is the same, this returns the error */
> > if (is_host == new_mode_is_host)
> > @@ -257,6 +248,32 @@ static ssize_t role_store(struct device *dev, struct device_attribute *attr,
> > rcar_gen3_init_for_peri(ch);
> > }
> >
> > + return 0;
> > +}
> > +
> > +static ssize_t role_store(struct device *dev, struct device_attribute *attr,
> > + const char *buf, size_t count)
> > +{
> > + struct rcar_gen3_chan *ch = dev_get_drvdata(dev);
> > + bool new_mode_is_host;
> > + ssize_t ret = -EIO;
> > +
> > + if (!ch->phy->init_count)
> > + return -EIO;
> > +
> > + if (!strncmp(buf, "host", strlen("host")))
> > + new_mode_is_host = true;
> > + else if (!strncmp(buf, "peripheral", strlen("peripheral")))
> > + new_mode_is_host = false;
>
> set the enum mode here.
I will set it in v4 patch.
> > + else
> > + return -EINVAL;
> > +
> > + if (ch->has_otg)
> > + ret = rcar_gen3_otg_change_role(ch, new_mode_is_host);
>
> Aren't you using sysfs to change the role here?
Oops! The patch set doesn't take care about a case of "can_role_swap = true" and "has_otg = false".
So, I will remove the "can_role_swap" parameter in v4 patch.
> > +
> > + if (ret < 0)
> > + return ret;
> > +
> > return count;
> > }
> >
> > @@ -264,12 +281,17 @@ static ssize_t role_show(struct device *dev, struct device_attribute *attr,
> > char *buf)
> > {
> > struct rcar_gen3_chan *ch = dev_get_drvdata(dev);
> > + bool is_host;
> >
> > - if (!ch->has_otg || !ch->phy->init_count)
> > + if (!ch->phy->init_count)
> > return -EIO;
> >
> > - return sprintf(buf, "%s\n", rcar_gen3_is_host(ch) ? "host" :
> > - "peripheral");
> > + if (ch->has_otg)
> > + is_host = rcar_gen3_is_host(ch);
> > + else
> > + return -EIO;
> > +
> > + return sprintf(buf, "%s\n", is_host ? "host" : "peripheral");
> > }
> > static DEVICE_ATTR_RW(role);
> >
> > @@ -427,6 +449,7 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
> > int ret;
> >
> > channel->has_otg = true;
> > + channel->can_role_swap = true;
>
> Can both has_otg and can_role_swap be true?
Yes. But, in v4 patch will not have the "can_role_swap".
Best regards,
Yoshihiro Shimoda
> Thanks
> Kishon
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2017-10-10 5:59 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-01 2:41 [PATCH v3 0/4] phy: rcar-gen3-usb2: add support for r8a77995 Yoshihiro Shimoda
2017-09-01 2:41 ` [PATCH v3 1/4] phy: rcar-gen3-usb2: check dr_mode for otg mode Yoshihiro Shimoda
2017-10-06 9:15 ` Simon Horman
2017-09-01 2:41 ` [PATCH v3 2/4] phy: rcar-gen3-usb2: split the two meaning of "has_otg" Yoshihiro Shimoda
2017-10-06 9:15 ` Simon Horman
2017-10-09 10:06 ` Kishon Vijay Abraham I
2017-10-10 5:59 ` Yoshihiro Shimoda
2017-09-01 2:41 ` [PATCH v3 3/4] phy: rcar-gen3-usb2: add SoC-specific parameter for dedicated pins Yoshihiro Shimoda
2017-10-06 9:14 ` Simon Horman
2017-09-01 2:41 ` [PATCH v3 4/4] phy: rcar-gen3-usb2: add binding for r8a77995 Yoshihiro Shimoda
2017-10-06 9:14 ` Simon Horman
2017-10-06 2:13 ` [PATCH v3 0/4] phy: rcar-gen3-usb2: add support " Yoshihiro Shimoda
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox