linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/6] phy: renesas: rcar-gen3-usb2: add gpio handling for R-Car D3
@ 2017-12-15  5:45 Yoshihiro Shimoda
  2017-12-15  5:45 ` [PATCH v2 1/6] phy: renesas: rcar-gen3-usb2: call INIT_WORK() anyway Yoshihiro Shimoda
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Yoshihiro Shimoda @ 2017-12-15  5:45 UTC (permalink / raw)
  To: kishon, robh+dt, mark.rutland
  Cc: linux-kernel, devicetree, linux-renesas-soc, Yoshihiro Shimoda

This patch set is based on the latest linux-phy / next branch
(commit id = 4fbd8d194f06c8a3fd2af1ce560ddb31f7ec8323).

This new feature will be used by the renesas_usbhs driver on R-Car D3.

Changes from v1:
 - Drop "renesas," from the names of gpio property.
 - Change function names of "enable_" to "control_" or "set_" that
   will enable/disable irq or vbus.

Yoshihiro Shimoda (6):
  phy: renesas: rcar-gen3-usb2: call INIT_WORK() anyway
  phy: renesas: rcar-gen3-usb2: unify OBINTEN handling
  phy: renesas: rcar-gen3-usb2: change the function name to
    set_vbus_ctrl()
  phy: renesas: rcar-gen3-usb2: use prefix "has_otg_pins_" for dedicated
    pins handling
  phy: renesas: rcar-gen3-usb2: add rcar_gen3_role_swap_ops
  phy: renesas: rcar-gen3-usb2: add gpio handling

 .../devicetree/bindings/phy/rcar-gen3-phy-usb2.txt |   2 +
 drivers/phy/renesas/phy-rcar-gen3-usb2.c           | 276 ++++++++++++++++-----
 2 files changed, 213 insertions(+), 65 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2 1/6] phy: renesas: rcar-gen3-usb2: call INIT_WORK() anyway
  2017-12-15  5:45 [PATCH v2 0/6] phy: renesas: rcar-gen3-usb2: add gpio handling for R-Car D3 Yoshihiro Shimoda
@ 2017-12-15  5:45 ` Yoshihiro Shimoda
  2017-12-15  5:45 ` [PATCH v2 2/6] phy: renesas: rcar-gen3-usb2: unify OBINTEN handling Yoshihiro Shimoda
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Yoshihiro Shimoda @ 2017-12-15  5:45 UTC (permalink / raw)
  To: kishon, robh+dt, mark.rutland
  Cc: linux-kernel, devicetree, linux-renesas-soc, Yoshihiro Shimoda

In the future, the work struct will be used by non-irq related code.
So, this patch moves the INIT_WORK() timing.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/phy/renesas/phy-rcar-gen3-usb2.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
index 9c90e7d..c22d65a 100644
--- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
+++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
@@ -431,10 +431,11 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
 	if (IS_ERR(channel->base))
 		return PTR_ERR(channel->base);
 
+	INIT_WORK(&channel->work, rcar_gen3_phy_usb2_work);
+
 	/* call request_irq for OTG */
 	irq = platform_get_irq(pdev, 0);
 	if (irq >= 0) {
-		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)
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2 2/6] phy: renesas: rcar-gen3-usb2: unify OBINTEN handling
  2017-12-15  5:45 [PATCH v2 0/6] phy: renesas: rcar-gen3-usb2: add gpio handling for R-Car D3 Yoshihiro Shimoda
  2017-12-15  5:45 ` [PATCH v2 1/6] phy: renesas: rcar-gen3-usb2: call INIT_WORK() anyway Yoshihiro Shimoda
@ 2017-12-15  5:45 ` Yoshihiro Shimoda
  2017-12-15  5:45 ` [PATCH v2 3/6] phy: renesas: rcar-gen3-usb2: change the function name to set_vbus_ctrl() Yoshihiro Shimoda
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Yoshihiro Shimoda @ 2017-12-15  5:45 UTC (permalink / raw)
  To: kishon, robh+dt, mark.rutland
  Cc: linux-kernel, devicetree, linux-renesas-soc, Yoshihiro Shimoda

This patch unifies the OBINTEN handling to clean-up the code.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/phy/renesas/phy-rcar-gen3-usb2.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
index c22d65a..480f912 100644
--- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
+++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
@@ -147,6 +147,18 @@ static void rcar_gen3_enable_vbus_ctrl(struct rcar_gen3_chan *ch, int vbus)
 	writel(val, usb2_base + USB2_ADPCTRL);
 }
 
+static void rcar_gen3_control_otg_irq(struct rcar_gen3_chan *ch, int enable)
+{
+	void __iomem *usb2_base = ch->base;
+	u32 val = readl(usb2_base + USB2_OBINTEN);
+
+	if (enable)
+		val |= USB2_OBINT_BITS;
+	else
+		val &= ~USB2_OBINT_BITS;
+	writel(val, usb2_base + USB2_OBINTEN);
+}
+
 static void rcar_gen3_init_for_host(struct rcar_gen3_chan *ch)
 {
 	rcar_gen3_set_linectrl(ch, 1, 1);
@@ -192,16 +204,12 @@ static void rcar_gen3_init_for_a_peri(struct rcar_gen3_chan *ch)
 
 static void rcar_gen3_init_from_a_peri_to_a_host(struct rcar_gen3_chan *ch)
 {
-	void __iomem *usb2_base = ch->base;
-	u32 val;
-
-	val = readl(usb2_base + USB2_OBINTEN);
-	writel(val & ~USB2_OBINT_BITS, usb2_base + USB2_OBINTEN);
+	rcar_gen3_control_otg_irq(ch, 0);
 
 	rcar_gen3_enable_vbus_ctrl(ch, 0);
 	rcar_gen3_init_for_host(ch);
 
-	writel(val | USB2_OBINT_BITS, usb2_base + USB2_OBINTEN);
+	rcar_gen3_control_otg_irq(ch, 1);
 }
 
 static bool rcar_gen3_check_id(struct rcar_gen3_chan *ch)
@@ -291,8 +299,7 @@ static void rcar_gen3_init_otg(struct rcar_gen3_chan *ch)
 	val = readl(usb2_base + USB2_VBCTRL);
 	writel(val | USB2_VBCTRL_DRVVBUSSEL, usb2_base + USB2_VBCTRL);
 	writel(USB2_OBINT_BITS, usb2_base + USB2_OBINTSTA);
-	val = readl(usb2_base + USB2_OBINTEN);
-	writel(val | USB2_OBINT_BITS, usb2_base + USB2_OBINTEN);
+	rcar_gen3_control_otg_irq(ch, 1);
 	val = readl(usb2_base + USB2_ADPCTRL);
 	writel(val | USB2_ADPCTRL_IDPULLUP, usb2_base + USB2_ADPCTRL);
 	val = readl(usb2_base + USB2_LINECTRL1);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2 3/6] phy: renesas: rcar-gen3-usb2: change the function name to set_vbus_ctrl()
  2017-12-15  5:45 [PATCH v2 0/6] phy: renesas: rcar-gen3-usb2: add gpio handling for R-Car D3 Yoshihiro Shimoda
  2017-12-15  5:45 ` [PATCH v2 1/6] phy: renesas: rcar-gen3-usb2: call INIT_WORK() anyway Yoshihiro Shimoda
  2017-12-15  5:45 ` [PATCH v2 2/6] phy: renesas: rcar-gen3-usb2: unify OBINTEN handling Yoshihiro Shimoda
@ 2017-12-15  5:45 ` Yoshihiro Shimoda
  2017-12-15  5:45 ` [PATCH v2 4/6] phy: renesas: rcar-gen3-usb2: use prefix "has_otg_pins_" for dedicated pins handling Yoshihiro Shimoda
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Yoshihiro Shimoda @ 2017-12-15  5:45 UTC (permalink / raw)
  To: kishon, robh+dt, mark.rutland
  Cc: linux-kernel, devicetree, linux-renesas-soc, Yoshihiro Shimoda

This patch changes the function name from rcar_gen3_enable_vbus_ctrl()
to rcar_gen3_set_vbus_ctrl() because the fucntion both enables and
disables.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/phy/renesas/phy-rcar-gen3-usb2.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
index 480f912..bca6162 100644
--- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
+++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
@@ -134,13 +134,13 @@ static void rcar_gen3_set_linectrl(struct rcar_gen3_chan *ch, int dp, int dm)
 	writel(val, usb2_base + USB2_LINECTRL1);
 }
 
-static void rcar_gen3_enable_vbus_ctrl(struct rcar_gen3_chan *ch, int vbus)
+static void rcar_gen3_set_vbus_ctrl(struct rcar_gen3_chan *ch, int enable)
 {
 	void __iomem *usb2_base = ch->base;
 	u32 val = readl(usb2_base + USB2_ADPCTRL);
 
-	dev_vdbg(&ch->phy->dev, "%s: %08x, %d\n", __func__, val, vbus);
-	if (vbus)
+	dev_vdbg(&ch->phy->dev, "%s: %08x, %d\n", __func__, val, enable);
+	if (enable)
 		val |= USB2_ADPCTRL_DRVVBUS;
 	else
 		val &= ~USB2_ADPCTRL_DRVVBUS;
@@ -163,7 +163,7 @@ static void rcar_gen3_init_for_host(struct rcar_gen3_chan *ch)
 {
 	rcar_gen3_set_linectrl(ch, 1, 1);
 	rcar_gen3_set_host_mode(ch, 1);
-	rcar_gen3_enable_vbus_ctrl(ch, 1);
+	rcar_gen3_set_vbus_ctrl(ch, 1);
 
 	ch->extcon_host = true;
 	schedule_work(&ch->work);
@@ -173,7 +173,7 @@ static void rcar_gen3_init_for_peri(struct rcar_gen3_chan *ch)
 {
 	rcar_gen3_set_linectrl(ch, 0, 1);
 	rcar_gen3_set_host_mode(ch, 0);
-	rcar_gen3_enable_vbus_ctrl(ch, 0);
+	rcar_gen3_set_vbus_ctrl(ch, 0);
 
 	ch->extcon_host = false;
 	schedule_work(&ch->work);
@@ -189,7 +189,7 @@ static void rcar_gen3_init_for_b_host(struct rcar_gen3_chan *ch)
 
 	rcar_gen3_set_linectrl(ch, 1, 1);
 	rcar_gen3_set_host_mode(ch, 1);
-	rcar_gen3_enable_vbus_ctrl(ch, 0);
+	rcar_gen3_set_vbus_ctrl(ch, 0);
 
 	val = readl(usb2_base + USB2_LINECTRL1);
 	writel(val & ~USB2_LINECTRL1_OPMODE_NODRV, usb2_base + USB2_LINECTRL1);
@@ -199,14 +199,14 @@ static void rcar_gen3_init_for_a_peri(struct rcar_gen3_chan *ch)
 {
 	rcar_gen3_set_linectrl(ch, 0, 1);
 	rcar_gen3_set_host_mode(ch, 0);
-	rcar_gen3_enable_vbus_ctrl(ch, 1);
+	rcar_gen3_set_vbus_ctrl(ch, 1);
 }
 
 static void rcar_gen3_init_from_a_peri_to_a_host(struct rcar_gen3_chan *ch)
 {
 	rcar_gen3_control_otg_irq(ch, 0);
 
-	rcar_gen3_enable_vbus_ctrl(ch, 0);
+	rcar_gen3_set_vbus_ctrl(ch, 0);
 	rcar_gen3_init_for_host(ch);
 
 	rcar_gen3_control_otg_irq(ch, 1);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2 4/6] phy: renesas: rcar-gen3-usb2: use prefix "has_otg_pins_" for dedicated pins handling
  2017-12-15  5:45 [PATCH v2 0/6] phy: renesas: rcar-gen3-usb2: add gpio handling for R-Car D3 Yoshihiro Shimoda
                   ` (2 preceding siblings ...)
  2017-12-15  5:45 ` [PATCH v2 3/6] phy: renesas: rcar-gen3-usb2: change the function name to set_vbus_ctrl() Yoshihiro Shimoda
@ 2017-12-15  5:45 ` Yoshihiro Shimoda
  2017-12-15  5:45 ` [PATCH v2 5/6] phy: renesas: rcar-gen3-usb2: add rcar_gen3_role_swap_ops Yoshihiro Shimoda
  2017-12-15  5:45 ` [PATCH v2 6/6] phy: renesas: rcar-gen3-usb2: add gpio handling Yoshihiro Shimoda
  5 siblings, 0 replies; 11+ messages in thread
From: Yoshihiro Shimoda @ 2017-12-15  5:45 UTC (permalink / raw)
  To: kishon, robh+dt, mark.rutland
  Cc: linux-kernel, devicetree, linux-renesas-soc, Yoshihiro Shimoda

To support gpio handling in the future, this patch clean-ups the code
to use prefix "has_otg_pins_" functions.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/phy/renesas/phy-rcar-gen3-usb2.c | 130 ++++++++++++++++++++-----------
 1 file changed, 85 insertions(+), 45 deletions(-)

diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
index bca6162..b121f07 100644
--- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
+++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
@@ -93,21 +93,21 @@ struct rcar_gen3_chan {
 	bool has_otg_pins;
 };
 
-static void rcar_gen3_phy_usb2_work(struct work_struct *work)
+static void rcar_gen3_set_linectrl(struct rcar_gen3_chan *ch, int dp, int dm)
 {
-	struct rcar_gen3_chan *ch = container_of(work, struct rcar_gen3_chan,
-						 work);
+	void __iomem *usb2_base = ch->base;
+	u32 val = readl(usb2_base + USB2_LINECTRL1);
 
-	if (ch->extcon_host) {
-		extcon_set_state_sync(ch->extcon, EXTCON_USB_HOST, true);
-		extcon_set_state_sync(ch->extcon, EXTCON_USB, false);
-	} else {
-		extcon_set_state_sync(ch->extcon, EXTCON_USB_HOST, false);
-		extcon_set_state_sync(ch->extcon, EXTCON_USB, true);
-	}
+	dev_vdbg(&ch->phy->dev, "%s: %08x, %d, %d\n", __func__, val, dp, dm);
+	val &= ~(USB2_LINECTRL1_DP_RPD | USB2_LINECTRL1_DM_RPD);
+	if (dp)
+		val |= USB2_LINECTRL1_DP_RPD;
+	if (dm)
+		val |= USB2_LINECTRL1_DM_RPD;
+	writel(val, usb2_base + USB2_LINECTRL1);
 }
 
-static void rcar_gen3_set_host_mode(struct rcar_gen3_chan *ch, int host)
+static void has_otg_pins_set_host(struct rcar_gen3_chan *ch, int host)
 {
 	void __iomem *usb2_base = ch->base;
 	u32 val = readl(usb2_base + USB2_COMMCTRL);
@@ -120,21 +120,27 @@ static void rcar_gen3_set_host_mode(struct rcar_gen3_chan *ch, int host)
 	writel(val, usb2_base + USB2_COMMCTRL);
 }
 
-static void rcar_gen3_set_linectrl(struct rcar_gen3_chan *ch, int dp, int dm)
+static bool has_otg_pins_is_host(struct rcar_gen3_chan *ch)
+{
+	return !(readl(ch->base + USB2_COMMCTRL) & USB2_COMMCTRL_OTG_PERI);
+}
+
+static irqreturn_t has_otg_pins_irq_handler(struct rcar_gen3_chan *ch)
 {
 	void __iomem *usb2_base = ch->base;
-	u32 val = readl(usb2_base + USB2_LINECTRL1);
+	u32 status = readl(usb2_base + USB2_OBINTSTA);
+	irqreturn_t ret = IRQ_NONE;
 
-	dev_vdbg(&ch->phy->dev, "%s: %08x, %d, %d\n", __func__, val, dp, dm);
-	val &= ~(USB2_LINECTRL1_DP_RPD | USB2_LINECTRL1_DM_RPD);
-	if (dp)
-		val |= USB2_LINECTRL1_DP_RPD;
-	if (dm)
-		val |= USB2_LINECTRL1_DM_RPD;
-	writel(val, usb2_base + USB2_LINECTRL1);
+	if (status & USB2_OBINT_BITS) {
+		dev_vdbg(&ch->phy->dev, "%s: %08x\n", __func__, status);
+		writel(USB2_OBINT_BITS, usb2_base + USB2_OBINTSTA);
+		ret = IRQ_HANDLED;
+	}
+
+	return ret;
 }
 
-static void rcar_gen3_set_vbus_ctrl(struct rcar_gen3_chan *ch, int enable)
+static void has_otg_pins_set_vbus_ctrl(struct rcar_gen3_chan *ch, int enable)
 {
 	void __iomem *usb2_base = ch->base;
 	u32 val = readl(usb2_base + USB2_ADPCTRL);
@@ -147,7 +153,7 @@ static void rcar_gen3_set_vbus_ctrl(struct rcar_gen3_chan *ch, int enable)
 	writel(val, usb2_base + USB2_ADPCTRL);
 }
 
-static void rcar_gen3_control_otg_irq(struct rcar_gen3_chan *ch, int enable)
+static void has_otg_pins_control_irq(struct rcar_gen3_chan *ch, int enable)
 {
 	void __iomem *usb2_base = ch->base;
 	u32 val = readl(usb2_base + USB2_OBINTEN);
@@ -159,6 +165,57 @@ static void rcar_gen3_control_otg_irq(struct rcar_gen3_chan *ch, int enable)
 	writel(val, usb2_base + USB2_OBINTEN);
 }
 
+static bool has_otg_pins_check_id(struct rcar_gen3_chan *ch)
+{
+	return !!(readl(ch->base + USB2_ADPCTRL) & USB2_ADPCTRL_IDDIG);
+}
+
+static void has_otg_pins_init(struct rcar_gen3_chan *ch)
+{
+	void __iomem *usb2_base = ch->base;
+	u32 val;
+
+	val = readl(usb2_base + USB2_VBCTRL);
+	writel(val | USB2_VBCTRL_DRVVBUSSEL, usb2_base + USB2_VBCTRL);
+	writel(USB2_OBINT_BITS, usb2_base + USB2_OBINTSTA);
+	has_otg_pins_control_irq(ch, 1);
+	val = readl(usb2_base + USB2_ADPCTRL);
+	writel(val | USB2_ADPCTRL_IDPULLUP, usb2_base + USB2_ADPCTRL);
+	val = readl(usb2_base + USB2_LINECTRL1);
+	rcar_gen3_set_linectrl(ch, 0, 0);
+	writel(val | USB2_LINECTRL1_DPRPD_EN | USB2_LINECTRL1_DMRPD_EN,
+	       usb2_base + USB2_LINECTRL1);
+}
+
+static void rcar_gen3_phy_usb2_work(struct work_struct *work)
+{
+	struct rcar_gen3_chan *ch = container_of(work, struct rcar_gen3_chan,
+						 work);
+
+	if (ch->extcon_host) {
+		extcon_set_state_sync(ch->extcon, EXTCON_USB_HOST, true);
+		extcon_set_state_sync(ch->extcon, EXTCON_USB, false);
+	} else {
+		extcon_set_state_sync(ch->extcon, EXTCON_USB_HOST, false);
+		extcon_set_state_sync(ch->extcon, EXTCON_USB, true);
+	}
+}
+
+static void rcar_gen3_set_host_mode(struct rcar_gen3_chan *ch, int host)
+{
+	has_otg_pins_set_host(ch, host);
+}
+
+static void rcar_gen3_set_vbus_ctrl(struct rcar_gen3_chan *ch, int enable)
+{
+	has_otg_pins_set_vbus_ctrl(ch, enable);
+}
+
+static void rcar_gen3_control_otg_irq(struct rcar_gen3_chan *ch, int enable)
+{
+	has_otg_pins_control_irq(ch, enable);
+}
+
 static void rcar_gen3_init_for_host(struct rcar_gen3_chan *ch)
 {
 	rcar_gen3_set_linectrl(ch, 1, 1);
@@ -214,7 +271,7 @@ static void rcar_gen3_init_from_a_peri_to_a_host(struct rcar_gen3_chan *ch)
 
 static bool rcar_gen3_check_id(struct rcar_gen3_chan *ch)
 {
-	return !!(readl(ch->base + USB2_ADPCTRL) & USB2_ADPCTRL_IDDIG);
+	return has_otg_pins_check_id(ch);
 }
 
 static void rcar_gen3_device_recognition(struct rcar_gen3_chan *ch)
@@ -227,7 +284,7 @@ static void rcar_gen3_device_recognition(struct rcar_gen3_chan *ch)
 
 static bool rcar_gen3_is_host(struct rcar_gen3_chan *ch)
 {
-	return !(readl(ch->base + USB2_COMMCTRL) & USB2_COMMCTRL_OTG_PERI);
+	return has_otg_pins_is_host(ch);
 }
 
 static enum phy_mode rcar_gen3_get_phy_mode(struct rcar_gen3_chan *ch)
@@ -293,19 +350,7 @@ static ssize_t role_show(struct device *dev, struct device_attribute *attr,
 
 static void rcar_gen3_init_otg(struct rcar_gen3_chan *ch)
 {
-	void __iomem *usb2_base = ch->base;
-	u32 val;
-
-	val = readl(usb2_base + USB2_VBCTRL);
-	writel(val | USB2_VBCTRL_DRVVBUSSEL, usb2_base + USB2_VBCTRL);
-	writel(USB2_OBINT_BITS, usb2_base + USB2_OBINTSTA);
-	rcar_gen3_control_otg_irq(ch, 1);
-	val = readl(usb2_base + USB2_ADPCTRL);
-	writel(val | USB2_ADPCTRL_IDPULLUP, usb2_base + USB2_ADPCTRL);
-	val = readl(usb2_base + USB2_LINECTRL1);
-	rcar_gen3_set_linectrl(ch, 0, 0);
-	writel(val | USB2_LINECTRL1_DPRPD_EN | USB2_LINECTRL1_DMRPD_EN,
-	       usb2_base + USB2_LINECTRL1);
+	has_otg_pins_init(ch);
 
 	rcar_gen3_device_recognition(ch);
 }
@@ -380,16 +425,11 @@ static int rcar_gen3_phy_usb2_power_off(struct phy *p)
 static irqreturn_t rcar_gen3_phy_usb2_irq(int irq, void *_ch)
 {
 	struct rcar_gen3_chan *ch = _ch;
-	void __iomem *usb2_base = ch->base;
-	u32 status = readl(usb2_base + USB2_OBINTSTA);
-	irqreturn_t ret = IRQ_NONE;
+	irqreturn_t ret;
 
-	if (status & USB2_OBINT_BITS) {
-		dev_vdbg(&ch->phy->dev, "%s: %08x\n", __func__, status);
-		writel(USB2_OBINT_BITS, usb2_base + USB2_OBINTSTA);
+	ret = has_otg_pins_irq_handler(ch);
+	if (ret == IRQ_HANDLED)
 		rcar_gen3_device_recognition(ch);
-		ret = IRQ_HANDLED;
-	}
 
 	return ret;
 }
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2 5/6] phy: renesas: rcar-gen3-usb2: add rcar_gen3_role_swap_ops
  2017-12-15  5:45 [PATCH v2 0/6] phy: renesas: rcar-gen3-usb2: add gpio handling for R-Car D3 Yoshihiro Shimoda
                   ` (3 preceding siblings ...)
  2017-12-15  5:45 ` [PATCH v2 4/6] phy: renesas: rcar-gen3-usb2: use prefix "has_otg_pins_" for dedicated pins handling Yoshihiro Shimoda
@ 2017-12-15  5:45 ` Yoshihiro Shimoda
  2017-12-15  5:45 ` [PATCH v2 6/6] phy: renesas: rcar-gen3-usb2: add gpio handling Yoshihiro Shimoda
  5 siblings, 0 replies; 11+ messages in thread
From: Yoshihiro Shimoda @ 2017-12-15  5:45 UTC (permalink / raw)
  To: kishon, robh+dt, mark.rutland
  Cc: linux-kernel, devicetree, linux-renesas-soc, Yoshihiro Shimoda

This patch add rcar_gen3_role_swap_ops to support other feature
(e.g. gpio handling) easily.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/phy/renesas/phy-rcar-gen3-usb2.c | 51 +++++++++++++++++++++++++++-----
 1 file changed, 43 insertions(+), 8 deletions(-)

diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
index b121f07..f470fb3 100644
--- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
+++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
@@ -83,11 +83,23 @@
 
 #define RCAR_GEN3_PHY_HAS_DEDICATED_PINS	1
 
+struct rcar_gen3_chan;
+struct rcar_gen3_role_swap_ops {
+	void (*init)(struct rcar_gen3_chan *ch);
+	void (*set_host)(struct rcar_gen3_chan *ch, int host);
+	bool (*is_host)(struct rcar_gen3_chan *ch);
+	void (*set_vbus_ctrl)(struct rcar_gen3_chan *ch, int enable);
+	bool (*check_id)(struct rcar_gen3_chan *ch);
+	void (*control_irq)(struct rcar_gen3_chan *ch, int enable);
+	irqreturn_t (*irq_handler)(struct rcar_gen3_chan *ch);
+};
+
 struct rcar_gen3_chan {
 	void __iomem *base;
 	struct extcon_dev *extcon;
 	struct phy *phy;
 	struct regulator *vbus;
+	const struct rcar_gen3_role_swap_ops *rs_ops;
 	struct work_struct work;
 	bool extcon_host;
 	bool has_otg_pins;
@@ -203,17 +215,20 @@ static void rcar_gen3_phy_usb2_work(struct work_struct *work)
 
 static void rcar_gen3_set_host_mode(struct rcar_gen3_chan *ch, int host)
 {
-	has_otg_pins_set_host(ch, host);
+	if (ch->rs_ops && ch->rs_ops->set_host)
+		ch->rs_ops->set_host(ch, host);
 }
 
 static void rcar_gen3_set_vbus_ctrl(struct rcar_gen3_chan *ch, int enable)
 {
-	has_otg_pins_set_vbus_ctrl(ch, enable);
+	if (ch->rs_ops && ch->rs_ops->set_vbus_ctrl)
+		ch->rs_ops->set_vbus_ctrl(ch, enable);
 }
 
 static void rcar_gen3_control_otg_irq(struct rcar_gen3_chan *ch, int enable)
 {
-	has_otg_pins_control_irq(ch, enable);
+	if (ch->rs_ops && ch->rs_ops->control_irq)
+		ch->rs_ops->control_irq(ch, enable);
 }
 
 static void rcar_gen3_init_for_host(struct rcar_gen3_chan *ch)
@@ -271,7 +286,10 @@ static void rcar_gen3_init_from_a_peri_to_a_host(struct rcar_gen3_chan *ch)
 
 static bool rcar_gen3_check_id(struct rcar_gen3_chan *ch)
 {
-	return has_otg_pins_check_id(ch);
+	if (ch->rs_ops && ch->rs_ops->check_id)
+		return ch->rs_ops->check_id(ch);
+
+	return false;
 }
 
 static void rcar_gen3_device_recognition(struct rcar_gen3_chan *ch)
@@ -284,7 +302,10 @@ static void rcar_gen3_device_recognition(struct rcar_gen3_chan *ch)
 
 static bool rcar_gen3_is_host(struct rcar_gen3_chan *ch)
 {
-	return has_otg_pins_is_host(ch);
+	if (ch->rs_ops && ch->rs_ops->is_host)
+		return ch->rs_ops->is_host(ch);
+
+	return false;
 }
 
 static enum phy_mode rcar_gen3_get_phy_mode(struct rcar_gen3_chan *ch)
@@ -350,7 +371,8 @@ static ssize_t role_show(struct device *dev, struct device_attribute *attr,
 
 static void rcar_gen3_init_otg(struct rcar_gen3_chan *ch)
 {
-	has_otg_pins_init(ch);
+	if (ch->rs_ops && ch->rs_ops->init)
+		ch->rs_ops->init(ch);
 
 	rcar_gen3_device_recognition(ch);
 }
@@ -425,9 +447,10 @@ static int rcar_gen3_phy_usb2_power_off(struct phy *p)
 static irqreturn_t rcar_gen3_phy_usb2_irq(int irq, void *_ch)
 {
 	struct rcar_gen3_chan *ch = _ch;
-	irqreturn_t ret;
+	irqreturn_t ret = IRQ_NONE;
 
-	ret = has_otg_pins_irq_handler(ch);
+	if (ch->rs_ops && ch->rs_ops->irq_handler)
+		ret = ch->rs_ops->irq_handler(ch);
 	if (ret == IRQ_HANDLED)
 		rcar_gen3_device_recognition(ch);
 
@@ -456,6 +479,16 @@ static irqreturn_t rcar_gen3_phy_usb2_irq(int irq, void *_ch)
 	EXTCON_NONE,
 };
 
+static const struct rcar_gen3_role_swap_ops has_otg_pins_ops = {
+	.init		= has_otg_pins_init,
+	.set_host	= has_otg_pins_set_host,
+	.is_host	= has_otg_pins_is_host,
+	.set_vbus_ctrl	= has_otg_pins_set_vbus_ctrl,
+	.check_id	= has_otg_pins_check_id,
+	.control_irq	= has_otg_pins_control_irq,
+	.irq_handler	= has_otg_pins_irq_handler,
+};
+
 static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -493,6 +526,8 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
 		int ret;
 
 		channel->has_otg_pins = (uintptr_t)of_device_get_match_data(dev);
+		if (channel->has_otg_pins)
+			channel->rs_ops = &has_otg_pins_ops;
 		channel->extcon = devm_extcon_dev_allocate(dev,
 							rcar_gen3_phy_cable);
 		if (IS_ERR(channel->extcon))
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2 6/6] phy: renesas: rcar-gen3-usb2: add gpio handling
  2017-12-15  5:45 [PATCH v2 0/6] phy: renesas: rcar-gen3-usb2: add gpio handling for R-Car D3 Yoshihiro Shimoda
                   ` (4 preceding siblings ...)
  2017-12-15  5:45 ` [PATCH v2 5/6] phy: renesas: rcar-gen3-usb2: add rcar_gen3_role_swap_ops Yoshihiro Shimoda
@ 2017-12-15  5:45 ` Yoshihiro Shimoda
  2017-12-16 18:05   ` Rob Herring
  5 siblings, 1 reply; 11+ messages in thread
From: Yoshihiro Shimoda @ 2017-12-15  5:45 UTC (permalink / raw)
  To: kishon, robh+dt, mark.rutland
  Cc: linux-kernel, devicetree, linux-renesas-soc, Yoshihiro Shimoda

Some R-Car SoCs (e.g. R-Car D3) doesn't have dedicated pins of VBUS
and ID. So, they may be connected to gpio pins. To handle the gpio
pins, this patch adds the handling of VBUS and ID pins instead of
dedicated pins.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 .../devicetree/bindings/phy/rcar-gen3-phy-usb2.txt |  2 +
 drivers/phy/renesas/phy-rcar-gen3-usb2.c           | 77 ++++++++++++++++++++--
 2 files changed, 72 insertions(+), 7 deletions(-)

diff --git a/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
index 99b651b..999a6ef 100644
--- a/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
+++ b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
@@ -27,6 +27,8 @@ channel as USB OTG:
 - interrupts: interrupt specifier for the PHY.
 - vbus-supply: Phandle to a regulator that provides power to the VBUS. This
 	       regulator will be managed during the PHY power on/off sequence.
+- vbus-gpios: use gpio to control vbus instead of dedicated pin.
+- id-gpios: use gpio to detect id instead of dedicated pin.
 
 Example (R-Car H3):
 
diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
index f470fb3..ea76973 100644
--- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
+++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
@@ -13,6 +13,7 @@
  */
 
 #include <linux/extcon-provider.h>
+#include <linux/gpio/consumer.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/module.h>
@@ -100,9 +101,12 @@ struct rcar_gen3_chan {
 	struct phy *phy;
 	struct regulator *vbus;
 	const struct rcar_gen3_role_swap_ops *rs_ops;
+	struct gpio_desc *gpio_vbus;
+	struct gpio_desc *gpio_id;
 	struct work_struct work;
 	bool extcon_host;
 	bool has_otg_pins;
+	bool has_gpio;
 };
 
 static void rcar_gen3_set_linectrl(struct rcar_gen3_chan *ch, int dp, int dm)
@@ -199,6 +203,36 @@ static void has_otg_pins_init(struct rcar_gen3_chan *ch)
 	       usb2_base + USB2_LINECTRL1);
 }
 
+static void gpio_set_vbus_ctrl(struct rcar_gen3_chan *ch, int enable)
+{
+	gpiod_set_value(ch->gpio_vbus, enable);
+}
+
+static bool gpio_check_id(struct rcar_gen3_chan *ch)
+{
+	return gpiod_get_value(ch->gpio_id);
+}
+
+static void gpio_set_host(struct rcar_gen3_chan *ch, int host)
+{
+	/* In gpio ops, this driver will modify the extcon_host by sysfs */
+	if (ch->extcon_host != !!host) {
+		ch->extcon_host = !!host;
+		schedule_work(&ch->work);
+	}
+}
+
+static bool gpio_is_host(struct rcar_gen3_chan *ch)
+{
+	return ch->extcon_host;
+}
+
+static irqreturn_t gpio_irq_handler(struct rcar_gen3_chan *ch)
+{
+	/* Nop because the driver will get gpio value after exited */
+	return IRQ_HANDLED;
+}
+
 static void rcar_gen3_phy_usb2_work(struct work_struct *work)
 {
 	struct rcar_gen3_chan *ch = container_of(work, struct rcar_gen3_chan,
@@ -323,7 +357,7 @@ static ssize_t role_store(struct device *dev, struct device_attribute *attr,
 	bool is_b_device;
 	enum phy_mode cur_mode, new_mode;
 
-	if (!ch->has_otg_pins || !ch->phy->init_count)
+	if (!(ch->has_otg_pins || ch->has_gpio) || !ch->phy->init_count)
 		return -EIO;
 
 	if (!strncmp(buf, "host", strlen("host")))
@@ -361,7 +395,7 @@ static ssize_t role_show(struct device *dev, struct device_attribute *attr,
 {
 	struct rcar_gen3_chan *ch = dev_get_drvdata(dev);
 
-	if (!ch->has_otg_pins || !ch->phy->init_count)
+	if (!(ch->has_otg_pins || ch->has_gpio) || !ch->phy->init_count)
 		return -EIO;
 
 	return sprintf(buf, "%s\n", rcar_gen3_is_host(ch) ? "host" :
@@ -388,7 +422,7 @@ static int rcar_gen3_phy_usb2_init(struct phy *p)
 	writel(USB2_OC_TIMSET_INIT, usb2_base + USB2_OC_TIMSET);
 
 	/* Initialize otg part */
-	if (channel->has_otg_pins)
+	if (channel->has_otg_pins || channel->has_gpio)
 		rcar_gen3_init_otg(channel);
 
 	return 0;
@@ -489,6 +523,14 @@ static irqreturn_t rcar_gen3_phy_usb2_irq(int irq, void *_ch)
 	.irq_handler	= has_otg_pins_irq_handler,
 };
 
+static const struct rcar_gen3_role_swap_ops gpio_ops = {
+	.set_host	= gpio_set_host,
+	.is_host	= gpio_is_host,
+	.set_vbus_ctrl	= gpio_set_vbus_ctrl,
+	.check_id	= gpio_check_id,
+	.irq_handler	= gpio_irq_handler,
+};
+
 static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -513,9 +555,30 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
 
 	INIT_WORK(&channel->work, rcar_gen3_phy_usb2_work);
 
-	/* call request_irq for OTG */
+	channel->gpio_vbus = devm_gpiod_get(dev, "vbus", GPIOD_OUT_LOW);
+	if (IS_ERR(channel->gpio_vbus) &&
+	    PTR_ERR(channel->gpio_vbus) == -EPROBE_DEFER)
+		return PTR_ERR(channel->gpio_vbus);
+
+	channel->gpio_id = devm_gpiod_get(dev, "id", GPIOD_IN);
+	if (!IS_ERR(channel->gpio_vbus) && !IS_ERR(channel->gpio_id)) {
+		irq = gpiod_to_irq(channel->gpio_id);
+		if (irq > 0) {
+			ret = devm_request_irq(dev, irq, rcar_gen3_phy_usb2_irq,
+				IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
+				dev_name(dev), channel);
+			if (ret < 0) {
+				dev_err(dev, "No gpio irq handler (%d)\n", irq);
+			} else {
+				channel->has_gpio = true;
+				channel->rs_ops = &gpio_ops;
+			}
+		}
+	}
+
+	/* call request_irq for OTG if doesn't have gpio */
 	irq = platform_get_irq(pdev, 0);
-	if (irq >= 0) {
+	if (!channel->has_gpio && irq >= 0) {
 		irq = devm_request_irq(dev, irq, rcar_gen3_phy_usb2_irq,
 				       IRQF_SHARED, dev_name(dev), channel);
 		if (irq < 0)
@@ -569,7 +632,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_pins) {
+	} else if (channel->has_otg_pins || channel->has_gpio) {
 		int ret;
 
 		ret = device_create_file(dev, &dev_attr_role);
@@ -589,7 +652,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_pins)
+	if (channel->has_otg_pins || channel->has_gpio)
 		device_remove_file(&pdev->dev, &dev_attr_role);
 
 	pm_runtime_disable(&pdev->dev);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 6/6] phy: renesas: rcar-gen3-usb2: add gpio handling
  2017-12-15  5:45 ` [PATCH v2 6/6] phy: renesas: rcar-gen3-usb2: add gpio handling Yoshihiro Shimoda
@ 2017-12-16 18:05   ` Rob Herring
  2017-12-18  5:16     ` Yoshihiro Shimoda
  0 siblings, 1 reply; 11+ messages in thread
From: Rob Herring @ 2017-12-16 18:05 UTC (permalink / raw)
  To: Yoshihiro Shimoda
  Cc: kishon, mark.rutland, linux-kernel, devicetree, linux-renesas-soc

On Fri, Dec 15, 2017 at 02:45:26PM +0900, Yoshihiro Shimoda wrote:
> Some R-Car SoCs (e.g. R-Car D3) doesn't have dedicated pins of VBUS
> and ID. So, they may be connected to gpio pins. To handle the gpio
> pins, this patch adds the handling of VBUS and ID pins instead of
> dedicated pins.
> 
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> ---
>  .../devicetree/bindings/phy/rcar-gen3-phy-usb2.txt |  2 +
>  drivers/phy/renesas/phy-rcar-gen3-usb2.c           | 77 ++++++++++++++++++++--
>  2 files changed, 72 insertions(+), 7 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
> index 99b651b..999a6ef 100644
> --- a/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
> +++ b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
> @@ -27,6 +27,8 @@ channel as USB OTG:
>  - interrupts: interrupt specifier for the PHY.
>  - vbus-supply: Phandle to a regulator that provides power to the VBUS. This
>  	       regulator will be managed during the PHY power on/off sequence.
> +- vbus-gpios: use gpio to control vbus instead of dedicated pin.

How does this relate to vbus-supply? A gpio-regulator doesn't work here?

> +- id-gpios: use gpio to detect id instead of dedicated pin.

These aren't part of the phy, but really belong in a connector node.

Rob

^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [PATCH v2 6/6] phy: renesas: rcar-gen3-usb2: add gpio handling
  2017-12-16 18:05   ` Rob Herring
@ 2017-12-18  5:16     ` Yoshihiro Shimoda
  2017-12-19  0:09       ` Rob Herring
  0 siblings, 1 reply; 11+ messages in thread
From: Yoshihiro Shimoda @ 2017-12-18  5:16 UTC (permalink / raw)
  To: Rob Herring
  Cc: kishon, mark.rutland, linux-kernel, devicetree, linux-renesas-soc

Hi Rob,

Thank you for your comments!

> -----Original Message-----
> From: Rob Herring, Sent: Sunday, December 17, 2017 3:05 AM
> 
> On Fri, Dec 15, 2017 at 02:45:26PM +0900, Yoshihiro Shimoda wrote:
> > Some R-Car SoCs (e.g. R-Car D3) doesn't have dedicated pins of VBUS
> > and ID. So, they may be connected to gpio pins. To handle the gpio
> > pins, this patch adds the handling of VBUS and ID pins instead of
> > dedicated pins.
> >
> > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> > ---
> >  .../devicetree/bindings/phy/rcar-gen3-phy-usb2.txt |  2 +
> >  drivers/phy/renesas/phy-rcar-gen3-usb2.c           | 77 ++++++++++++++++++++--
> >  2 files changed, 72 insertions(+), 7 deletions(-)
> >
> > diff --git a/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
> b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
> > index 99b651b..999a6ef 100644
> > --- a/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
> > +++ b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
> > @@ -27,6 +27,8 @@ channel as USB OTG:
> >  - interrupts: interrupt specifier for the PHY.
> >  - vbus-supply: Phandle to a regulator that provides power to the VBUS. This
> >  	       regulator will be managed during the PHY power on/off sequence.
> > +- vbus-gpios: use gpio to control vbus instead of dedicated pin.
> 
> How does this relate to vbus-supply? A gpio-regulator doesn't work here?

Thank you for the pointed out. You're correct. A gpio-regulator can work intead of "vbus-gpios".
So, I will drop this.

> > +- id-gpios: use gpio to detect id instead of dedicated pin.
> 
> These aren't part of the phy, but really belong in a connector node.

I'm afraid but I don't understand "a connector node" mean.
Is it an extcon device for instance?
If so, I'll try to use extcon-usb-gpio.c instead of own gpio handling on the driver.

Best regards,
Yoshihiro Shimoda

> Rob

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 6/6] phy: renesas: rcar-gen3-usb2: add gpio handling
  2017-12-18  5:16     ` Yoshihiro Shimoda
@ 2017-12-19  0:09       ` Rob Herring
  2017-12-19 11:43         ` Yoshihiro Shimoda
  0 siblings, 1 reply; 11+ messages in thread
From: Rob Herring @ 2017-12-19  0:09 UTC (permalink / raw)
  To: Yoshihiro Shimoda
  Cc: kishon, mark.rutland, linux-kernel, devicetree, linux-renesas-soc

On Sun, Dec 17, 2017 at 11:16 PM, Yoshihiro Shimoda
<yoshihiro.shimoda.uh@renesas.com> wrote:
> Hi Rob,
>
> Thank you for your comments!
>
>> -----Original Message-----
>> From: Rob Herring, Sent: Sunday, December 17, 2017 3:05 AM
>>
>> On Fri, Dec 15, 2017 at 02:45:26PM +0900, Yoshihiro Shimoda wrote:
>> > Some R-Car SoCs (e.g. R-Car D3) doesn't have dedicated pins of VBUS
>> > and ID. So, they may be connected to gpio pins. To handle the gpio
>> > pins, this patch adds the handling of VBUS and ID pins instead of
>> > dedicated pins.
>> >
>> > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
>> > ---
>> >  .../devicetree/bindings/phy/rcar-gen3-phy-usb2.txt |  2 +
>> >  drivers/phy/renesas/phy-rcar-gen3-usb2.c           | 77 ++++++++++++++++++++--
>> >  2 files changed, 72 insertions(+), 7 deletions(-)
>> >
>> > diff --git a/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
>> b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
>> > index 99b651b..999a6ef 100644
>> > --- a/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
>> > +++ b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
>> > @@ -27,6 +27,8 @@ channel as USB OTG:
>> >  - interrupts: interrupt specifier for the PHY.
>> >  - vbus-supply: Phandle to a regulator that provides power to the VBUS. This
>> >            regulator will be managed during the PHY power on/off sequence.
>> > +- vbus-gpios: use gpio to control vbus instead of dedicated pin.
>>
>> How does this relate to vbus-supply? A gpio-regulator doesn't work here?
>
> Thank you for the pointed out. You're correct. A gpio-regulator can work intead of "vbus-gpios".
> So, I will drop this.
>
>> > +- id-gpios: use gpio to detect id instead of dedicated pin.
>>
>> These aren't part of the phy, but really belong in a connector node.
>
> I'm afraid but I don't understand "a connector node" mean.
> Is it an extcon device for instance?
> If so, I'll try to use extcon-usb-gpio.c instead of own gpio handling on the driver.

No, extcon binding has a lot of Linuxisms in it. I mean something like
hdmi-connector binding. There's been some attempts[1] for USB
connectors, but nothing finalized.

Rob

[1] https://www.spinics.net/lists/linux-usb/msg161104.html

^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [PATCH v2 6/6] phy: renesas: rcar-gen3-usb2: add gpio handling
  2017-12-19  0:09       ` Rob Herring
@ 2017-12-19 11:43         ` Yoshihiro Shimoda
  0 siblings, 0 replies; 11+ messages in thread
From: Yoshihiro Shimoda @ 2017-12-19 11:43 UTC (permalink / raw)
  To: Rob Herring
  Cc: kishon, mark.rutland, linux-kernel, devicetree, linux-renesas-soc

Hi Rob,

> From: Rob Herring, Sent: Tuesday, December 19, 2017 9:10 AM
> 
> On Sun, Dec 17, 2017 at 11:16 PM, Yoshihiro Shimoda
> <yoshihiro.shimoda.uh@renesas.com> wrote:
> > Hi Rob,
> >
> > Thank you for your comments!
> >
> >> From: Rob Herring, Sent: Sunday, December 17, 2017 3:05 AM
> >>
> >> On Fri, Dec 15, 2017 at 02:45:26PM +0900, Yoshihiro Shimoda wrote:
> >> > Some R-Car SoCs (e.g. R-Car D3) doesn't have dedicated pins of VBUS
> >> > and ID. So, they may be connected to gpio pins. To handle the gpio
> >> > pins, this patch adds the handling of VBUS and ID pins instead of
> >> > dedicated pins.
> >> >
> >> > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> >> > ---
> >> >  .../devicetree/bindings/phy/rcar-gen3-phy-usb2.txt |  2 +
> >> >  drivers/phy/renesas/phy-rcar-gen3-usb2.c           | 77 ++++++++++++++++++++--
> >> >  2 files changed, 72 insertions(+), 7 deletions(-)
> >> >
> >> > diff --git a/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
> >> b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
> >> > index 99b651b..999a6ef 100644
> >> > --- a/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
> >> > +++ b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
> >> > @@ -27,6 +27,8 @@ channel as USB OTG:
> >> >  - interrupts: interrupt specifier for the PHY.
> >> >  - vbus-supply: Phandle to a regulator that provides power to the VBUS. This
> >> >            regulator will be managed during the PHY power on/off sequence.
> >> > +- vbus-gpios: use gpio to control vbus instead of dedicated pin.
> >>
> >> How does this relate to vbus-supply? A gpio-regulator doesn't work here?
> >
> > Thank you for the pointed out. You're correct. A gpio-regulator can work intead of "vbus-gpios".
> > So, I will drop this.
> >
> >> > +- id-gpios: use gpio to detect id instead of dedicated pin.
> >>
> >> These aren't part of the phy, but really belong in a connector node.
> >
> > I'm afraid but I don't understand "a connector node" mean.
> > Is it an extcon device for instance?
> > If so, I'll try to use extcon-usb-gpio.c instead of own gpio handling on the driver.
> 
> No, extcon binding has a lot of Linuxisms in it. I mean something like
> hdmi-connector binding.

Thank you for the reply! I understood it. The hdmi-connector binding has "hdp-gpios".
And, this is similar with "id-gpios" of usb.

> There's been some attempts[1] for USB connectors, but nothing finalized.
> 
> Rob
> 
> [1] https://www.spinics.net/lists/linux-usb/msg161104.html

This means I should finalize the USB connectors binding at first?
I checked the email archive, but it seems hard to finalize though...

Best regards,
Yoshihiro Shimoda

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-12-19 11:43 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-15  5:45 [PATCH v2 0/6] phy: renesas: rcar-gen3-usb2: add gpio handling for R-Car D3 Yoshihiro Shimoda
2017-12-15  5:45 ` [PATCH v2 1/6] phy: renesas: rcar-gen3-usb2: call INIT_WORK() anyway Yoshihiro Shimoda
2017-12-15  5:45 ` [PATCH v2 2/6] phy: renesas: rcar-gen3-usb2: unify OBINTEN handling Yoshihiro Shimoda
2017-12-15  5:45 ` [PATCH v2 3/6] phy: renesas: rcar-gen3-usb2: change the function name to set_vbus_ctrl() Yoshihiro Shimoda
2017-12-15  5:45 ` [PATCH v2 4/6] phy: renesas: rcar-gen3-usb2: use prefix "has_otg_pins_" for dedicated pins handling Yoshihiro Shimoda
2017-12-15  5:45 ` [PATCH v2 5/6] phy: renesas: rcar-gen3-usb2: add rcar_gen3_role_swap_ops Yoshihiro Shimoda
2017-12-15  5:45 ` [PATCH v2 6/6] phy: renesas: rcar-gen3-usb2: add gpio handling Yoshihiro Shimoda
2017-12-16 18:05   ` Rob Herring
2017-12-18  5:16     ` Yoshihiro Shimoda
2017-12-19  0:09       ` Rob Herring
2017-12-19 11:43         ` Yoshihiro Shimoda

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).