linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] phy: rockchip-inno-usb2: RK356x OTG fix and enhancements
@ 2022-04-14  3:22 Samuel Holland
  2022-04-14  3:22 ` [PATCH 1/6] phy: rockchip-inno-usb2: Fix muxed interrupt support Samuel Holland
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Samuel Holland @ 2022-04-14  3:22 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Vinod Koul, Heiko Stuebner
  Cc: Peter Geis, Samuel Holland, linux-arm-kernel, linux-kernel,
	linux-phy, linux-rockchip

This series gets USB OTG working on the RK356x SoCs, as used in the
PineNote tablet.

 - Patch 1 fixes an interrupt storm issue specific to RK356x.
 - Patches 2 and 3 are a couple of small optimizations.
 - Patches 4 and 5 reduce the delay when unplugging from the OTG port.
 - Patch 6 allows OTG ports to work in host mode without depending on
   another driver to provide an extcon. The specific use case here is
   a Type-C port controller that provides a hardware "ID pin" output.


Samuel Holland (6):
  phy: rockchip-inno-usb2: Fix muxed interrupt support
  phy: rockchip-inno-usb2: Do not check bvalid twice
  phy: rockchip-inno-usb2: Do not lock in bvalid IRQ handler
  phy: rockchip-inno-usb2: Support multi-bit mask properties
  phy: rockchip-inno-usb2: Handle bvalid falling
  phy: rockchip-inno-usb2: Handle ID IRQ

 drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 125 +++++++++++++++---
 1 file changed, 105 insertions(+), 20 deletions(-)

-- 
2.35.1


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

* [PATCH 1/6] phy: rockchip-inno-usb2: Fix muxed interrupt support
  2022-04-14  3:22 [PATCH 0/6] phy: rockchip-inno-usb2: RK356x OTG fix and enhancements Samuel Holland
@ 2022-04-14  3:22 ` Samuel Holland
  2022-04-14  3:22 ` [PATCH 2/6] phy: rockchip-inno-usb2: Do not check bvalid twice Samuel Holland
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Samuel Holland @ 2022-04-14  3:22 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Vinod Koul, Heiko Stuebner
  Cc: Peter Geis, Samuel Holland, linux-arm-kernel, linux-kernel,
	linux-phy, linux-rockchip

This commit fixes two issues with the muxed interrupt handler. First,
the OTG port has the "bvalid" interrupt enabled, not "linestate". Since
only the linestate interrupt was handled, and not the bvalid interrupt,
plugging in a cable to the OTG port caused an interrupt storm.

Second, the return values from the individual port IRQ handlers need to
be OR-ed together. Otherwise, the lack of an interrupt from the last
port would cause the handler to erroneously return IRQ_NONE.

Fixes: ed2b5a8e6b98 ("phy: phy-rockchip-inno-usb2: support muxed interrupts")
Signed-off-by: Samuel Holland <samuel@sholland.org>
---

 drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
index eca77e44a4c1..cba5c32cbaee 100644
--- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
+++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
@@ -940,8 +940,14 @@ static irqreturn_t rockchip_usb2phy_irq(int irq, void *data)
 		if (!rport->phy)
 			continue;
 
-		/* Handle linestate irq for both otg port and host port */
-		ret = rockchip_usb2phy_linestate_irq(irq, rport);
+		switch (rport->port_id) {
+		case USB2PHY_PORT_OTG:
+			ret |= rockchip_usb2phy_otg_mux_irq(irq, rport);
+			break;
+		case USB2PHY_PORT_HOST:
+			ret |= rockchip_usb2phy_linestate_irq(irq, rport);
+			break;
+		}
 	}
 
 	return ret;
-- 
2.35.1


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

* [PATCH 2/6] phy: rockchip-inno-usb2: Do not check bvalid twice
  2022-04-14  3:22 [PATCH 0/6] phy: rockchip-inno-usb2: RK356x OTG fix and enhancements Samuel Holland
  2022-04-14  3:22 ` [PATCH 1/6] phy: rockchip-inno-usb2: Fix muxed interrupt support Samuel Holland
@ 2022-04-14  3:22 ` Samuel Holland
  2022-04-14  3:22 ` [PATCH 3/6] phy: rockchip-inno-usb2: Do not lock in bvalid IRQ handler Samuel Holland
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Samuel Holland @ 2022-04-14  3:22 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Vinod Koul, Heiko Stuebner
  Cc: Peter Geis, Samuel Holland, linux-arm-kernel, linux-kernel,
	linux-phy, linux-rockchip

The bvalid interrupt handler already checks bvalid status. The muxed IRQ
handler just needs to call the other handler (plus any other handlers
that will be added).

Signed-off-by: Samuel Holland <samuel@sholland.org>
---

 drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
index cba5c32cbaee..29407b36f5fa 100644
--- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
+++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
@@ -919,13 +919,11 @@ static irqreturn_t rockchip_usb2phy_bvalid_irq(int irq, void *data)
 
 static irqreturn_t rockchip_usb2phy_otg_mux_irq(int irq, void *data)
 {
-	struct rockchip_usb2phy_port *rport = data;
-	struct rockchip_usb2phy *rphy = dev_get_drvdata(rport->phy->dev.parent);
+	irqreturn_t ret = IRQ_NONE;
 
-	if (property_enabled(rphy->grf, &rport->port_cfg->bvalid_det_st))
-		return rockchip_usb2phy_bvalid_irq(irq, data);
-	else
-		return IRQ_NONE;
+	ret |= rockchip_usb2phy_bvalid_irq(irq, data);
+
+	return ret;
 }
 
 static irqreturn_t rockchip_usb2phy_irq(int irq, void *data)
-- 
2.35.1


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

* [PATCH 3/6] phy: rockchip-inno-usb2: Do not lock in bvalid IRQ handler
  2022-04-14  3:22 [PATCH 0/6] phy: rockchip-inno-usb2: RK356x OTG fix and enhancements Samuel Holland
  2022-04-14  3:22 ` [PATCH 1/6] phy: rockchip-inno-usb2: Fix muxed interrupt support Samuel Holland
  2022-04-14  3:22 ` [PATCH 2/6] phy: rockchip-inno-usb2: Do not check bvalid twice Samuel Holland
@ 2022-04-14  3:22 ` Samuel Holland
  2022-04-14  3:22 ` [PATCH 4/6] phy: rockchip-inno-usb2: Support multi-bit mask properties Samuel Holland
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Samuel Holland @ 2022-04-14  3:22 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Vinod Koul, Heiko Stuebner
  Cc: Peter Geis, Samuel Holland, linux-arm-kernel, linux-kernel,
	linux-phy, linux-rockchip

Clearing the IRQ is atomic, so there is no need to hold the mutex.

Signed-off-by: Samuel Holland <samuel@sholland.org>
---

 drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
index 29407b36f5fa..3422db56be76 100644
--- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
+++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
@@ -905,13 +905,9 @@ static irqreturn_t rockchip_usb2phy_bvalid_irq(int irq, void *data)
 	if (!property_enabled(rphy->grf, &rport->port_cfg->bvalid_det_st))
 		return IRQ_NONE;
 
-	mutex_lock(&rport->mutex);
-
 	/* clear bvalid detect irq pending status */
 	property_enable(rphy->grf, &rport->port_cfg->bvalid_det_clr, true);
 
-	mutex_unlock(&rport->mutex);
-
 	rockchip_usb2phy_otg_sm_work(&rport->otg_sm_work.work);
 
 	return IRQ_HANDLED;
-- 
2.35.1


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

* [PATCH 4/6] phy: rockchip-inno-usb2: Support multi-bit mask properties
  2022-04-14  3:22 [PATCH 0/6] phy: rockchip-inno-usb2: RK356x OTG fix and enhancements Samuel Holland
                   ` (2 preceding siblings ...)
  2022-04-14  3:22 ` [PATCH 3/6] phy: rockchip-inno-usb2: Do not lock in bvalid IRQ handler Samuel Holland
@ 2022-04-14  3:22 ` Samuel Holland
  2022-04-14  3:22 ` [PATCH 5/6] phy: rockchip-inno-usb2: Handle bvalid falling Samuel Holland
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Samuel Holland @ 2022-04-14  3:22 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Vinod Koul, Heiko Stuebner
  Cc: Peter Geis, Samuel Holland, linux-arm-kernel, linux-kernel,
	linux-phy, linux-rockchip

The "bvalid" and "id" interrupts can trigger on either the rising edge
or the falling edge, so each interrupt has two enable bits and two
status bits. This change allows using a single property for both bits,
checking whether either bit is set.

Signed-off-by: Samuel Holland <samuel@sholland.org>
---

 drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
index 3422db56be76..c694517496f8 100644
--- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
+++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
@@ -253,7 +253,7 @@ static inline bool property_enabled(struct regmap *base,
 		return false;
 
 	tmp = (orig & mask) >> reg->bitstart;
-	return tmp == reg->enable;
+	return tmp != reg->disable;
 }
 
 static int rockchip_usb2phy_clk480m_prepare(struct clk_hw *hw)
-- 
2.35.1


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

* [PATCH 5/6] phy: rockchip-inno-usb2: Handle bvalid falling
  2022-04-14  3:22 [PATCH 0/6] phy: rockchip-inno-usb2: RK356x OTG fix and enhancements Samuel Holland
                   ` (3 preceding siblings ...)
  2022-04-14  3:22 ` [PATCH 4/6] phy: rockchip-inno-usb2: Support multi-bit mask properties Samuel Holland
@ 2022-04-14  3:22 ` Samuel Holland
  2022-04-14  3:22 ` [PATCH 6/6] phy: rockchip-inno-usb2: Handle ID IRQ Samuel Holland
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Samuel Holland @ 2022-04-14  3:22 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Vinod Koul, Heiko Stuebner
  Cc: Peter Geis, Samuel Holland, linux-arm-kernel, linux-kernel,
	linux-phy, linux-rockchip

Some SoCs have a bvalid falling interrupt, in addition to bvalid rising.
This interrupt can detect OTG cable plugout immediately, so it can avoid
the delay until the next scheduled work.

Signed-off-by: Samuel Holland <samuel@sholland.org>
---

 drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
index c694517496f8..2b29f5dd8873 100644
--- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
+++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
@@ -1345,9 +1345,9 @@ static const struct rockchip_usb2phy_cfg rk3308_phy_cfgs[] = {
 		.port_cfgs	= {
 			[USB2PHY_PORT_OTG] = {
 				.phy_sus	= { 0x0100, 8, 0, 0, 0x1d1 },
-				.bvalid_det_en	= { 0x3020, 2, 2, 0, 1 },
-				.bvalid_det_st	= { 0x3024, 2, 2, 0, 1 },
-				.bvalid_det_clr = { 0x3028, 2, 2, 0, 1 },
+				.bvalid_det_en	= { 0x3020, 3, 2, 0, 3 },
+				.bvalid_det_st	= { 0x3024, 3, 2, 0, 3 },
+				.bvalid_det_clr = { 0x3028, 3, 2, 0, 3 },
 				.ls_det_en	= { 0x3020, 0, 0, 0, 1 },
 				.ls_det_st	= { 0x3024, 0, 0, 0, 1 },
 				.ls_det_clr	= { 0x3028, 0, 0, 0, 1 },
@@ -1388,9 +1388,9 @@ static const struct rockchip_usb2phy_cfg rk3328_phy_cfgs[] = {
 		.port_cfgs	= {
 			[USB2PHY_PORT_OTG] = {
 				.phy_sus	= { 0x0100, 15, 0, 0, 0x1d1 },
-				.bvalid_det_en	= { 0x0110, 2, 2, 0, 1 },
-				.bvalid_det_st	= { 0x0114, 2, 2, 0, 1 },
-				.bvalid_det_clr = { 0x0118, 2, 2, 0, 1 },
+				.bvalid_det_en	= { 0x0110, 3, 2, 0, 3 },
+				.bvalid_det_st	= { 0x0114, 3, 2, 0, 3 },
+				.bvalid_det_clr = { 0x0118, 3, 2, 0, 3 },
 				.ls_det_en	= { 0x0110, 0, 0, 0, 1 },
 				.ls_det_st	= { 0x0114, 0, 0, 0, 1 },
 				.ls_det_clr	= { 0x0118, 0, 0, 0, 1 },
@@ -1512,9 +1512,9 @@ static const struct rockchip_usb2phy_cfg rk3568_phy_cfgs[] = {
 		.port_cfgs	= {
 			[USB2PHY_PORT_OTG] = {
 				.phy_sus	= { 0x0000, 8, 0, 0, 0x1d1 },
-				.bvalid_det_en	= { 0x0080, 2, 2, 0, 1 },
-				.bvalid_det_st	= { 0x0084, 2, 2, 0, 1 },
-				.bvalid_det_clr = { 0x0088, 2, 2, 0, 1 },
+				.bvalid_det_en	= { 0x0080, 3, 2, 0, 3 },
+				.bvalid_det_st	= { 0x0084, 3, 2, 0, 3 },
+				.bvalid_det_clr = { 0x0088, 3, 2, 0, 3 },
 				.utmi_avalid	= { 0x00c0, 10, 10, 0, 1 },
 				.utmi_bvalid	= { 0x00c0, 9, 9, 0, 1 },
 			},
-- 
2.35.1


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

* [PATCH 6/6] phy: rockchip-inno-usb2: Handle ID IRQ
  2022-04-14  3:22 [PATCH 0/6] phy: rockchip-inno-usb2: RK356x OTG fix and enhancements Samuel Holland
                   ` (4 preceding siblings ...)
  2022-04-14  3:22 ` [PATCH 5/6] phy: rockchip-inno-usb2: Handle bvalid falling Samuel Holland
@ 2022-04-14  3:22 ` Samuel Holland
  2022-04-14 14:00 ` [PATCH 0/6] phy: rockchip-inno-usb2: RK356x OTG fix and enhancements Michael Riesch
  2022-04-20  9:14 ` Vinod Koul
  7 siblings, 0 replies; 9+ messages in thread
From: Samuel Holland @ 2022-04-14  3:22 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Vinod Koul, Heiko Stuebner
  Cc: Peter Geis, Samuel Holland, linux-arm-kernel, linux-kernel,
	linux-phy, linux-rockchip

This supports detecting host mode for the OTG port without an extcon.

The rv1108 properties are not updated due to lack of documentation.

Signed-off-by: Samuel Holland <samuel@sholland.org>
---

 drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 85 +++++++++++++++++++
 1 file changed, 85 insertions(+)

diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
index 2b29f5dd8873..e377b958d9b6 100644
--- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
+++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
@@ -116,11 +116,15 @@ struct rockchip_chg_det_reg {
  * @bvalid_det_en: vbus valid rise detection enable register.
  * @bvalid_det_st: vbus valid rise detection status register.
  * @bvalid_det_clr: vbus valid rise detection clear register.
+ * @id_det_en: id detection enable register.
+ * @id_det_st: id detection state register.
+ * @id_det_clr: id detection clear register.
  * @ls_det_en: linestate detection enable register.
  * @ls_det_st: linestate detection state register.
  * @ls_det_clr: linestate detection clear register.
  * @utmi_avalid: utmi vbus avalid status register.
  * @utmi_bvalid: utmi vbus bvalid status register.
+ * @utmi_id: utmi id state register.
  * @utmi_ls: utmi linestate state register.
  * @utmi_hstdet: utmi host disconnect register.
  */
@@ -129,11 +133,15 @@ struct rockchip_usb2phy_port_cfg {
 	struct usb2phy_reg	bvalid_det_en;
 	struct usb2phy_reg	bvalid_det_st;
 	struct usb2phy_reg	bvalid_det_clr;
+	struct usb2phy_reg	id_det_en;
+	struct usb2phy_reg	id_det_st;
+	struct usb2phy_reg	id_det_clr;
 	struct usb2phy_reg	ls_det_en;
 	struct usb2phy_reg	ls_det_st;
 	struct usb2phy_reg	ls_det_clr;
 	struct usb2phy_reg	utmi_avalid;
 	struct usb2phy_reg	utmi_bvalid;
+	struct usb2phy_reg	utmi_id;
 	struct usb2phy_reg	utmi_ls;
 	struct usb2phy_reg	utmi_hstdet;
 };
@@ -161,6 +169,7 @@ struct rockchip_usb2phy_cfg {
  * @suspended: phy suspended flag.
  * @vbus_attached: otg device vbus status.
  * @bvalid_irq: IRQ number assigned for vbus valid rise detection.
+ * @id_irq: IRQ number assigned for ID pin detection.
  * @ls_irq: IRQ number assigned for linestate detection.
  * @otg_mux_irq: IRQ number which multiplex otg-id/otg-bvalid/linestate
  *		 irqs to one irq in otg-port.
@@ -179,6 +188,7 @@ struct rockchip_usb2phy_port {
 	bool		suspended;
 	bool		vbus_attached;
 	int		bvalid_irq;
+	int		id_irq;
 	int		ls_irq;
 	int		otg_mux_irq;
 	struct mutex	mutex;
@@ -419,6 +429,19 @@ static int rockchip_usb2phy_init(struct phy *phy)
 			if (ret)
 				goto out;
 
+			/* clear id status and enable id detect irq */
+			ret = property_enable(rphy->grf,
+					      &rport->port_cfg->id_det_clr,
+					      true);
+			if (ret)
+				goto out;
+
+			ret = property_enable(rphy->grf,
+					      &rport->port_cfg->id_det_en,
+					      true);
+			if (ret)
+				goto out;
+
 			schedule_delayed_work(&rport->otg_sm_work,
 					      OTG_SCHEDULE_DELAY * 3);
 		} else {
@@ -913,11 +936,30 @@ static irqreturn_t rockchip_usb2phy_bvalid_irq(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
+static irqreturn_t rockchip_usb2phy_id_irq(int irq, void *data)
+{
+	struct rockchip_usb2phy_port *rport = data;
+	struct rockchip_usb2phy *rphy = dev_get_drvdata(rport->phy->dev.parent);
+	bool id;
+
+	if (!property_enabled(rphy->grf, &rport->port_cfg->id_det_st))
+		return IRQ_NONE;
+
+	/* clear id detect irq pending status */
+	property_enable(rphy->grf, &rport->port_cfg->id_det_clr, true);
+
+	id = property_enabled(rphy->grf, &rport->port_cfg->utmi_id);
+	extcon_set_state_sync(rphy->edev, EXTCON_USB_HOST, !id);
+
+	return IRQ_HANDLED;
+}
+
 static irqreturn_t rockchip_usb2phy_otg_mux_irq(int irq, void *data)
 {
 	irqreturn_t ret = IRQ_NONE;
 
 	ret |= rockchip_usb2phy_bvalid_irq(irq, data);
+	ret |= rockchip_usb2phy_id_irq(irq, data);
 
 	return ret;
 }
@@ -1015,6 +1057,25 @@ static int rockchip_usb2phy_port_irq_init(struct rockchip_usb2phy *rphy,
 					"failed to request otg-bvalid irq handle\n");
 				return ret;
 			}
+
+			rport->id_irq = of_irq_get_byname(child_np, "otg-id");
+			if (rport->id_irq < 0) {
+				dev_err(rphy->dev, "no otg-id irq provided\n");
+				ret = rport->id_irq;
+				return ret;
+			}
+
+			ret = devm_request_threaded_irq(rphy->dev, rport->id_irq,
+							NULL,
+							rockchip_usb2phy_id_irq,
+							IRQF_ONESHOT,
+							"rockchip_usb2phy_id",
+							rport);
+			if (ret) {
+				dev_err(rphy->dev,
+					"failed to request otg-id irq handle\n");
+				return ret;
+			}
 		}
 		break;
 	default:
@@ -1289,10 +1350,14 @@ static const struct rockchip_usb2phy_cfg rk3228_phy_cfgs[] = {
 				.bvalid_det_en	= { 0x0680, 3, 3, 0, 1 },
 				.bvalid_det_st	= { 0x0690, 3, 3, 0, 1 },
 				.bvalid_det_clr	= { 0x06a0, 3, 3, 0, 1 },
+				.id_det_en	= { 0x0680, 6, 5, 0, 3 },
+				.id_det_st	= { 0x0690, 6, 5, 0, 3 },
+				.id_det_clr	= { 0x06a0, 6, 5, 0, 3 },
 				.ls_det_en	= { 0x0680, 2, 2, 0, 1 },
 				.ls_det_st	= { 0x0690, 2, 2, 0, 1 },
 				.ls_det_clr	= { 0x06a0, 2, 2, 0, 1 },
 				.utmi_bvalid	= { 0x0480, 4, 4, 0, 1 },
+				.utmi_id	= { 0x0480, 1, 1, 0, 1 },
 				.utmi_ls	= { 0x0480, 3, 2, 0, 1 },
 			},
 			[USB2PHY_PORT_HOST] = {
@@ -1348,11 +1413,15 @@ static const struct rockchip_usb2phy_cfg rk3308_phy_cfgs[] = {
 				.bvalid_det_en	= { 0x3020, 3, 2, 0, 3 },
 				.bvalid_det_st	= { 0x3024, 3, 2, 0, 3 },
 				.bvalid_det_clr = { 0x3028, 3, 2, 0, 3 },
+				.id_det_en	= { 0x3020, 5, 4, 0, 3 },
+				.id_det_st	= { 0x3024, 5, 4, 0, 3 },
+				.id_det_clr	= { 0x3028, 5, 4, 0, 3 },
 				.ls_det_en	= { 0x3020, 0, 0, 0, 1 },
 				.ls_det_st	= { 0x3024, 0, 0, 0, 1 },
 				.ls_det_clr	= { 0x3028, 0, 0, 0, 1 },
 				.utmi_avalid	= { 0x0120, 10, 10, 0, 1 },
 				.utmi_bvalid	= { 0x0120, 9, 9, 0, 1 },
+				.utmi_id	= { 0x0120, 6, 6, 0, 1 },
 				.utmi_ls	= { 0x0120, 5, 4, 0, 1 },
 			},
 			[USB2PHY_PORT_HOST] = {
@@ -1391,11 +1460,15 @@ static const struct rockchip_usb2phy_cfg rk3328_phy_cfgs[] = {
 				.bvalid_det_en	= { 0x0110, 3, 2, 0, 3 },
 				.bvalid_det_st	= { 0x0114, 3, 2, 0, 3 },
 				.bvalid_det_clr = { 0x0118, 3, 2, 0, 3 },
+				.id_det_en	= { 0x0110, 5, 4, 0, 3 },
+				.id_det_st	= { 0x0114, 5, 4, 0, 3 },
+				.id_det_clr	= { 0x0118, 5, 4, 0, 3 },
 				.ls_det_en	= { 0x0110, 0, 0, 0, 1 },
 				.ls_det_st	= { 0x0114, 0, 0, 0, 1 },
 				.ls_det_clr	= { 0x0118, 0, 0, 0, 1 },
 				.utmi_avalid	= { 0x0120, 10, 10, 0, 1 },
 				.utmi_bvalid	= { 0x0120, 9, 9, 0, 1 },
+				.utmi_id	= { 0x0120, 6, 6, 0, 1 },
 				.utmi_ls	= { 0x0120, 5, 4, 0, 1 },
 			},
 			[USB2PHY_PORT_HOST] = {
@@ -1453,8 +1526,12 @@ static const struct rockchip_usb2phy_cfg rk3399_phy_cfgs[] = {
 				.bvalid_det_en	= { 0xe3c0, 3, 3, 0, 1 },
 				.bvalid_det_st	= { 0xe3e0, 3, 3, 0, 1 },
 				.bvalid_det_clr	= { 0xe3d0, 3, 3, 0, 1 },
+				.id_det_en	= { 0xe3c0, 5, 4, 0, 3 },
+				.id_det_st	= { 0xe3e0, 5, 4, 0, 3 },
+				.id_det_clr	= { 0xe3d0, 5, 4, 0, 3 },
 				.utmi_avalid	= { 0xe2ac, 7, 7, 0, 1 },
 				.utmi_bvalid	= { 0xe2ac, 12, 12, 0, 1 },
+				.utmi_id	= { 0xe2ac, 8, 8, 0, 1 },
 			},
 			[USB2PHY_PORT_HOST] = {
 				.phy_sus	= { 0xe458, 1, 0, 0x2, 0x1 },
@@ -1488,8 +1565,12 @@ static const struct rockchip_usb2phy_cfg rk3399_phy_cfgs[] = {
 				.bvalid_det_en  = { 0xe3c0, 8, 8, 0, 1 },
 				.bvalid_det_st  = { 0xe3e0, 8, 8, 0, 1 },
 				.bvalid_det_clr = { 0xe3d0, 8, 8, 0, 1 },
+				.id_det_en	= { 0xe3c0, 10, 9, 0, 3 },
+				.id_det_st	= { 0xe3e0, 10, 9, 0, 3 },
+				.id_det_clr	= { 0xe3d0, 10, 9, 0, 3 },
 				.utmi_avalid	= { 0xe2ac, 10, 10, 0, 1 },
 				.utmi_bvalid    = { 0xe2ac, 16, 16, 0, 1 },
+				.utmi_id	= { 0xe2ac, 11, 11, 0, 1 },
 			},
 			[USB2PHY_PORT_HOST] = {
 				.phy_sus	= { 0xe468, 1, 0, 0x2, 0x1 },
@@ -1515,8 +1596,12 @@ static const struct rockchip_usb2phy_cfg rk3568_phy_cfgs[] = {
 				.bvalid_det_en	= { 0x0080, 3, 2, 0, 3 },
 				.bvalid_det_st	= { 0x0084, 3, 2, 0, 3 },
 				.bvalid_det_clr = { 0x0088, 3, 2, 0, 3 },
+				.id_det_en	= { 0x0080, 5, 4, 0, 3 },
+				.id_det_st	= { 0x0084, 5, 4, 0, 3 },
+				.id_det_clr	= { 0x0088, 5, 4, 0, 3 },
 				.utmi_avalid	= { 0x00c0, 10, 10, 0, 1 },
 				.utmi_bvalid	= { 0x00c0, 9, 9, 0, 1 },
+				.utmi_id	= { 0x00c0, 6, 6, 0, 1 },
 			},
 			[USB2PHY_PORT_HOST] = {
 				/* Select suspend control from controller */
-- 
2.35.1


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

* Re: [PATCH 0/6] phy: rockchip-inno-usb2: RK356x OTG fix and enhancements
  2022-04-14  3:22 [PATCH 0/6] phy: rockchip-inno-usb2: RK356x OTG fix and enhancements Samuel Holland
                   ` (5 preceding siblings ...)
  2022-04-14  3:22 ` [PATCH 6/6] phy: rockchip-inno-usb2: Handle ID IRQ Samuel Holland
@ 2022-04-14 14:00 ` Michael Riesch
  2022-04-20  9:14 ` Vinod Koul
  7 siblings, 0 replies; 9+ messages in thread
From: Michael Riesch @ 2022-04-14 14:00 UTC (permalink / raw)
  To: Samuel Holland, Kishon Vijay Abraham I, Vinod Koul, Heiko Stuebner
  Cc: Peter Geis, linux-arm-kernel, linux-kernel, linux-phy, linux-rockchip

Hello Samuel,

On 4/14/22 05:22, Samuel Holland wrote:
> This series gets USB OTG working on the RK356x SoCs, as used in the
> PineNote tablet.
> 
>  - Patch 1 fixes an interrupt storm issue specific to RK356x.
>  - Patches 2 and 3 are a couple of small optimizations.
>  - Patches 4 and 5 reduce the delay when unplugging from the OTG port.
>  - Patch 6 allows OTG ports to work in host mode without depending on
>    another driver to provide an extcon. The specific use case here is
>    a Type-C port controller that provides a hardware "ID pin" output.
> 
> 
> Samuel Holland (6):
>   phy: rockchip-inno-usb2: Fix muxed interrupt support
>   phy: rockchip-inno-usb2: Do not check bvalid twice
>   phy: rockchip-inno-usb2: Do not lock in bvalid IRQ handler
>   phy: rockchip-inno-usb2: Support multi-bit mask properties
>   phy: rockchip-inno-usb2: Handle bvalid falling
>   phy: rockchip-inno-usb2: Handle ID IRQ
> 
>  drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 125 +++++++++++++++---
>  1 file changed, 105 insertions(+), 20 deletions(-)

Thanks a lot! This series fixes the USB gadget operation of my RK356x
boards.

With suitable DTS changes, the zero gadget module, and usbtest

Tested-by: Michael Riesch <michael.riesch@wolfvision.net>

on a RK3568 EVB1 and a Rock 3 Model A.

Best regards,
Michael

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

* Re: [PATCH 0/6] phy: rockchip-inno-usb2: RK356x OTG fix and enhancements
  2022-04-14  3:22 [PATCH 0/6] phy: rockchip-inno-usb2: RK356x OTG fix and enhancements Samuel Holland
                   ` (6 preceding siblings ...)
  2022-04-14 14:00 ` [PATCH 0/6] phy: rockchip-inno-usb2: RK356x OTG fix and enhancements Michael Riesch
@ 2022-04-20  9:14 ` Vinod Koul
  7 siblings, 0 replies; 9+ messages in thread
From: Vinod Koul @ 2022-04-20  9:14 UTC (permalink / raw)
  To: Samuel Holland
  Cc: Kishon Vijay Abraham I, Heiko Stuebner, Peter Geis,
	linux-arm-kernel, linux-kernel, linux-phy, linux-rockchip

On 13-04-22, 22:22, Samuel Holland wrote:
> This series gets USB OTG working on the RK356x SoCs, as used in the
> PineNote tablet.

Applied, thanks

-- 
~Vinod

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

end of thread, other threads:[~2022-04-20  9:14 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-14  3:22 [PATCH 0/6] phy: rockchip-inno-usb2: RK356x OTG fix and enhancements Samuel Holland
2022-04-14  3:22 ` [PATCH 1/6] phy: rockchip-inno-usb2: Fix muxed interrupt support Samuel Holland
2022-04-14  3:22 ` [PATCH 2/6] phy: rockchip-inno-usb2: Do not check bvalid twice Samuel Holland
2022-04-14  3:22 ` [PATCH 3/6] phy: rockchip-inno-usb2: Do not lock in bvalid IRQ handler Samuel Holland
2022-04-14  3:22 ` [PATCH 4/6] phy: rockchip-inno-usb2: Support multi-bit mask properties Samuel Holland
2022-04-14  3:22 ` [PATCH 5/6] phy: rockchip-inno-usb2: Handle bvalid falling Samuel Holland
2022-04-14  3:22 ` [PATCH 6/6] phy: rockchip-inno-usb2: Handle ID IRQ Samuel Holland
2022-04-14 14:00 ` [PATCH 0/6] phy: rockchip-inno-usb2: RK356x OTG fix and enhancements Michael Riesch
2022-04-20  9:14 ` Vinod Koul

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