devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] phy: renesas: rcar-gen3-usb2: add gpio handling for R-Car D3
@ 2017-12-13  6:27 Yoshihiro Shimoda
  2017-12-13  6:27 ` [PATCH 1/5] phy: renesas: rcar-gen3-usb2: call INIT_WORK() anyway Yoshihiro Shimoda
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Yoshihiro Shimoda @ 2017-12-13  6:27 UTC (permalink / raw)
  To: kishon-l0cyMroinI0, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	mark.rutland-5wv7dgnIgG8
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-renesas-soc-u79uwXL29TY76Z2rM5mHXA, 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.

Yoshihiro Shimoda (5):
  phy: renesas: rcar-gen3-usb2: call INIT_WORK() anyway
  phy: renesas: rcar-gen3-usb2: unify OBINTEN handling
  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 handlings

 .../devicetree/bindings/phy/rcar-gen3-phy-usb2.txt |   2 +
 drivers/phy/renesas/phy-rcar-gen3-usb2.c           | 262 ++++++++++++++++-----
 2 files changed, 206 insertions(+), 58 deletions(-)

-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 1/5] phy: renesas: rcar-gen3-usb2: call INIT_WORK() anyway
  2017-12-13  6:27 [PATCH 0/5] phy: renesas: rcar-gen3-usb2: add gpio handling for R-Car D3 Yoshihiro Shimoda
@ 2017-12-13  6:27 ` Yoshihiro Shimoda
  2017-12-13  6:27 ` [PATCH 2/5] phy: renesas: rcar-gen3-usb2: unify OBINTEN handling Yoshihiro Shimoda
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Yoshihiro Shimoda @ 2017-12-13  6:27 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] 10+ messages in thread

* [PATCH 2/5] phy: renesas: rcar-gen3-usb2: unify OBINTEN handling
  2017-12-13  6:27 [PATCH 0/5] phy: renesas: rcar-gen3-usb2: add gpio handling for R-Car D3 Yoshihiro Shimoda
  2017-12-13  6:27 ` [PATCH 1/5] phy: renesas: rcar-gen3-usb2: call INIT_WORK() anyway Yoshihiro Shimoda
@ 2017-12-13  6:27 ` Yoshihiro Shimoda
       [not found]   ` <1513146460-20326-3-git-send-email-yoshihiro.shimoda.uh-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
  2017-12-13  6:27 ` [PATCH 3/5] phy: renesas: rcar-gen3-usb2: use prefix "has_otg_pins_" for dedicated pins handling Yoshihiro Shimoda
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Yoshihiro Shimoda @ 2017-12-13  6:27 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..beeaa30 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_enable_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_enable_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_enable_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_enable_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] 10+ messages in thread

* [PATCH 3/5] phy: renesas: rcar-gen3-usb2: use prefix "has_otg_pins_" for dedicated pins handling
  2017-12-13  6:27 [PATCH 0/5] phy: renesas: rcar-gen3-usb2: add gpio handling for R-Car D3 Yoshihiro Shimoda
  2017-12-13  6:27 ` [PATCH 1/5] phy: renesas: rcar-gen3-usb2: call INIT_WORK() anyway Yoshihiro Shimoda
  2017-12-13  6:27 ` [PATCH 2/5] phy: renesas: rcar-gen3-usb2: unify OBINTEN handling Yoshihiro Shimoda
@ 2017-12-13  6:27 ` Yoshihiro Shimoda
       [not found] ` <1513146460-20326-1-git-send-email-yoshihiro.shimoda.uh-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
  2017-12-13  6:27 ` [PATCH 5/5] phy: renesas: rcar-gen3-usb2: add gpio handling Yoshihiro Shimoda
  4 siblings, 0 replies; 10+ messages in thread
From: Yoshihiro Shimoda @ 2017-12-13  6:27 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 beeaa30..6d6f3eb 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_enable_vbus_ctrl(struct rcar_gen3_chan *ch, int vbus)
+static void has_otg_pins_enable_vbus(struct rcar_gen3_chan *ch, int vbus)
 {
 	void __iomem *usb2_base = ch->base;
 	u32 val = readl(usb2_base + USB2_ADPCTRL);
@@ -147,7 +153,7 @@ static void rcar_gen3_enable_vbus_ctrl(struct rcar_gen3_chan *ch, int vbus)
 	writel(val, usb2_base + USB2_ADPCTRL);
 }
 
-static void rcar_gen3_enable_otg_irq(struct rcar_gen3_chan *ch, int enable)
+static void has_otg_pins_enable_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_enable_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_enable_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_enable_vbus_ctrl(struct rcar_gen3_chan *ch, int vbus)
+{
+	has_otg_pins_enable_vbus(ch, vbus);
+}
+
+static void rcar_gen3_enable_otg_irq(struct rcar_gen3_chan *ch, int enable)
+{
+	has_otg_pins_enable_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_enable_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] 10+ messages in thread

* [PATCH 4/5] phy: renesas: rcar-gen3-usb2: add rcar_gen3_role_swap_ops
       [not found] ` <1513146460-20326-1-git-send-email-yoshihiro.shimoda.uh-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
@ 2017-12-13  6:27   ` Yoshihiro Shimoda
  0 siblings, 0 replies; 10+ messages in thread
From: Yoshihiro Shimoda @ 2017-12-13  6:27 UTC (permalink / raw)
  To: kishon-l0cyMroinI0, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	mark.rutland-5wv7dgnIgG8
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-renesas-soc-u79uwXL29TY76Z2rM5mHXA, 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-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
---
 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 6d6f3eb..5e509a9 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 (*enable_vbus)(struct rcar_gen3_chan *ch, int vbus);
+	bool (*check_id)(struct rcar_gen3_chan *ch);
+	void (*enable_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_enable_vbus_ctrl(struct rcar_gen3_chan *ch, int vbus)
 {
-	has_otg_pins_enable_vbus(ch, vbus);
+	if (ch->rs_ops && ch->rs_ops->enable_vbus)
+		ch->rs_ops->enable_vbus(ch, vbus);
 }
 
 static void rcar_gen3_enable_otg_irq(struct rcar_gen3_chan *ch, int enable)
 {
-	has_otg_pins_enable_irq(ch, enable);
+	if (ch->rs_ops && ch->rs_ops->enable_irq)
+		ch->rs_ops->enable_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,
+	.enable_vbus	= has_otg_pins_enable_vbus,
+	.check_id	= has_otg_pins_check_id,
+	.enable_irq	= has_otg_pins_enable_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

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 5/5] phy: renesas: rcar-gen3-usb2: add gpio handling
  2017-12-13  6:27 [PATCH 0/5] phy: renesas: rcar-gen3-usb2: add gpio handling for R-Car D3 Yoshihiro Shimoda
                   ` (3 preceding siblings ...)
       [not found] ` <1513146460-20326-1-git-send-email-yoshihiro.shimoda.uh-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
@ 2017-12-13  6:27 ` Yoshihiro Shimoda
       [not found]   ` <1513146460-20326-6-git-send-email-yoshihiro.shimoda.uh-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
  4 siblings, 1 reply; 10+ messages in thread
From: Yoshihiro Shimoda @ 2017-12-13  6:27 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..851582f 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.
+- renesas,vbus-gpios: use gpio to control vbus instead of dedicated pin.
+- renesas,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 5e509a9..0b6333d 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_enable_vbus(struct rcar_gen3_chan *ch, int vbus)
+{
+	gpiod_set_value(ch->gpio_vbus, vbus);
+}
+
+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,
+	.enable_vbus	= gpio_enable_vbus,
+	.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, "renesas,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, "renesas,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] 10+ messages in thread

* Re: [PATCH 5/5] phy: renesas: rcar-gen3-usb2: add gpio handling
       [not found]   ` <1513146460-20326-6-git-send-email-yoshihiro.shimoda.uh-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
@ 2017-12-13  8:55     ` Geert Uytterhoeven
       [not found]       ` <CAMuHMdU2YhLC3VPV8=KDw7U2=eudk35TmW7VfLYBDXrooQbx-g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: Geert Uytterhoeven @ 2017-12-13  8:55 UTC (permalink / raw)
  To: Yoshihiro Shimoda
  Cc: Kishon Vijay Abraham I, Rob Herring, Mark Rutland,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Linux-Renesas

Hi Shimoda-san,

On Wed, Dec 13, 2017 at 7:27 AM, Yoshihiro Shimoda
<yoshihiro.shimoda.uh-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org> 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-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
> ---
>  .../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..851582f 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.
> +- renesas,vbus-gpios: use gpio to control vbus instead of dedicated pin.
> +- renesas,id-gpios: use gpio to detect id instead of dedicated pin.

Documentation/devicetree/bindings/phy/brcm,ns2-drd-phy.txt already uses
"vbus-gpios" and "id-gpios" without vendor-specific prefixes, so perhaps
the "renesas," can be dropped?

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 2/5] phy: renesas: rcar-gen3-usb2: unify OBINTEN handling
       [not found]   ` <1513146460-20326-3-git-send-email-yoshihiro.shimoda.uh-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
@ 2017-12-13  9:09     ` Sergei Shtylyov
  2017-12-14  9:48       ` Yoshihiro Shimoda
  0 siblings, 1 reply; 10+ messages in thread
From: Sergei Shtylyov @ 2017-12-13  9:09 UTC (permalink / raw)
  To: Yoshihiro Shimoda, kishon-l0cyMroinI0,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-renesas-soc-u79uwXL29TY76Z2rM5mHXA

Hello!

On 12/13/2017 9:27 AM, Yoshihiro Shimoda wrote:

> This patch unifies the OBINTEN handling to clean-up the code.
> 
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
> ---
>   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..beeaa30 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_enable_otg_irq(struct rcar_gen3_chan *ch, int enable)

    If it both enables and disables, rcar_gen3_control_otg_irq() would seem a 
better name...

> +{
> +	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);
[...]

MBR, Sergei
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* RE: [PATCH 5/5] phy: renesas: rcar-gen3-usb2: add gpio handling
       [not found]       ` <CAMuHMdU2YhLC3VPV8=KDw7U2=eudk35TmW7VfLYBDXrooQbx-g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2017-12-14  9:44         ` Yoshihiro Shimoda
  0 siblings, 0 replies; 10+ messages in thread
From: Yoshihiro Shimoda @ 2017-12-14  9:44 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Kishon Vijay Abraham I, Rob Herring, Mark Rutland,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Linux-Renesas

Hi Geert-san,

> From: Geert Uytterhoeven, Sent: Wednesday, December 13, 2017 5:55 PM
> 
> Hi Shimoda-san,
> 
> On Wed, Dec 13, 2017 at 7:27 AM, Yoshihiro Shimoda
> <yoshihiro.shimoda.uh@renesas.com> 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..851582f 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.
> > +- renesas,vbus-gpios: use gpio to control vbus instead of dedicated pin.
> > +- renesas,id-gpios: use gpio to detect id instead of dedicated pin.
> 
> Documentation/devicetree/bindings/phy/brcm,ns2-drd-phy.txt already uses
> "vbus-gpios" and "id-gpios" without vendor-specific prefixes, so perhaps
> the "renesas," can be dropped?

Thank you for the comments. I agree with you. So, I'll drop "renesas," in v2.

Best regards,
Yoshihiro Shimoda

> Gr{oetje,eeting}s,
> 
>                         Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                 -- Linus Torvalds

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

* RE: [PATCH 2/5] phy: renesas: rcar-gen3-usb2: unify OBINTEN handling
  2017-12-13  9:09     ` Sergei Shtylyov
@ 2017-12-14  9:48       ` Yoshihiro Shimoda
  0 siblings, 0 replies; 10+ messages in thread
From: Yoshihiro Shimoda @ 2017-12-14  9:48 UTC (permalink / raw)
  To: Sergei Shtylyov, kishon, robh+dt, mark.rutland
  Cc: linux-kernel, devicetree, linux-renesas-soc

Hello!

> From: Sergei Shtylyov, Sent: Wednesday, December 13, 2017 6:10 PM
> 
> Hello!
> 
> On 12/13/2017 9:27 AM, Yoshihiro Shimoda wrote:
> 
> > 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..beeaa30 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_enable_otg_irq(struct rcar_gen3_chan *ch, int enable)
> 
>     If it both enables and disables, rcar_gen3_control_otg_irq() would seem a
> better name...

Thank you for the comment! I think so. So, I'll change the name in v2.
I'll also change the names of "enable_vbus_ctrl" and members of
rcar_gen3_role_swap_ops in the patch 4

Best regards,
Yoshihiro Shimoda

> > +{
> > +	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);
> [...]
> 
> MBR, Sergei

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

end of thread, other threads:[~2017-12-14  9:48 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-13  6:27 [PATCH 0/5] phy: renesas: rcar-gen3-usb2: add gpio handling for R-Car D3 Yoshihiro Shimoda
2017-12-13  6:27 ` [PATCH 1/5] phy: renesas: rcar-gen3-usb2: call INIT_WORK() anyway Yoshihiro Shimoda
2017-12-13  6:27 ` [PATCH 2/5] phy: renesas: rcar-gen3-usb2: unify OBINTEN handling Yoshihiro Shimoda
     [not found]   ` <1513146460-20326-3-git-send-email-yoshihiro.shimoda.uh-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2017-12-13  9:09     ` Sergei Shtylyov
2017-12-14  9:48       ` Yoshihiro Shimoda
2017-12-13  6:27 ` [PATCH 3/5] phy: renesas: rcar-gen3-usb2: use prefix "has_otg_pins_" for dedicated pins handling Yoshihiro Shimoda
     [not found] ` <1513146460-20326-1-git-send-email-yoshihiro.shimoda.uh-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2017-12-13  6:27   ` [PATCH 4/5] phy: renesas: rcar-gen3-usb2: add rcar_gen3_role_swap_ops Yoshihiro Shimoda
2017-12-13  6:27 ` [PATCH 5/5] phy: renesas: rcar-gen3-usb2: add gpio handling Yoshihiro Shimoda
     [not found]   ` <1513146460-20326-6-git-send-email-yoshihiro.shimoda.uh-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2017-12-13  8:55     ` Geert Uytterhoeven
     [not found]       ` <CAMuHMdU2YhLC3VPV8=KDw7U2=eudk35TmW7VfLYBDXrooQbx-g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-12-14  9:44         ` 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).