linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH 2/2] extcon: usbc-tusb320: Add USB TYPE-C support
@ 2022-11-13 16:59 Peter Rosin
  2022-11-13 17:38 ` [PATCH 2/2] extcon: usbc-tusb320: Add USB TYPE-C support #forregzbot Thorsten Leemhuis
  2022-11-13 18:48 ` [PATCH 2/2] extcon: usbc-tusb320: Add USB TYPE-C support Marek Vasut
  0 siblings, 2 replies; 16+ messages in thread
From: Peter Rosin @ 2022-11-13 16:59 UTC (permalink / raw)
  To: linux-usb
  Cc: Marek Vasut, Chanwoo Choi, Greg Kroah-Hartman, Heikki Krogerus,
	Yassine Oudjana, Alvin Šipraga, regressions

On Sat, Jul 30, 2022 at 08:05:00PM +0200, Marek Vasut wrote:
> The TI TUSB320 seems like a better fit for USB TYPE-C subsystem,
> which can expose details collected by the TUSB320 in a far more
> precise way than extcon. Since there are existing users in the
> kernel and in DT which depend on the extcon interface, keep it
> for now.
> 
> Add TYPE-C interface and expose the supported supply current,
> direction and connector polarity via the TYPE-C interface.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>

Hi!

I'm very sad to report that this patch has caused a severe
regression for our devices. They can no longer be powered by simply
sticking a USB cable into their USB ports (they keep resetting
when the tusb320 driver probes), and they reset (and keep resetting)
if a USB cable is connected while the device is powered by other
means.

We have no connector node nor any typec-power-opmode property
in the device tree, so the mere touching of the new registers
happening in this patch is enough to cause the resets.

The devices were fine before this patch, and reverting on top
of a recent linus master (4bbf3422df78, from 11/11) makes the
problem go away.

Any suggestions?

Cheers,
Peter

regzbot: introduced bf7571c00dca

^ permalink raw reply	[flat|nested] 16+ messages in thread
* [PATCH 1/2] extcon: usbc-tusb320: Factor out extcon into dedicated functions
@ 2022-07-30 18:04 Marek Vasut
  2022-07-30 18:05 ` [PATCH 2/2] extcon: usbc-tusb320: Add USB TYPE-C support Marek Vasut
  0 siblings, 1 reply; 16+ messages in thread
From: Marek Vasut @ 2022-07-30 18:04 UTC (permalink / raw)
  To: linux-usb
  Cc: Marek Vasut, Chanwoo Choi, Greg Kroah-Hartman, Heikki Krogerus,
	Yassine Oudjana

Move extcon code into separate functions in preparation for addition of
USB TYPE-C support. No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: Chanwoo Choi <cw00.choi@samsung.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: Yassine Oudjana <y.oudjana@protonmail.com>
To: linux-usb@vger.kernel.org
---
 drivers/extcon/extcon-usbc-tusb320.c | 75 +++++++++++++++++-----------
 1 file changed, 46 insertions(+), 29 deletions(-)

diff --git a/drivers/extcon/extcon-usbc-tusb320.c b/drivers/extcon/extcon-usbc-tusb320.c
index 6ba3d89b106d0..aced4bbb455dc 100644
--- a/drivers/extcon/extcon-usbc-tusb320.c
+++ b/drivers/extcon/extcon-usbc-tusb320.c
@@ -184,19 +184,9 @@ static struct tusb320_ops tusb320l_ops = {
 	.get_revision = tusb320l_get_revision,
 };
 
-static irqreturn_t tusb320_irq_handler(int irq, void *dev_id)
+static void tusb320_extcon_irq_handler(struct tusb320_priv *priv, u8 reg)
 {
-	struct tusb320_priv *priv = dev_id;
 	int state, polarity;
-	unsigned reg;
-
-	if (regmap_read(priv->regmap, TUSB320_REG9, &reg)) {
-		dev_err(priv->dev, "error during i2c read!\n");
-		return IRQ_NONE;
-	}
-
-	if (!(reg & TUSB320_REG9_INTERRUPT_STATUS))
-		return IRQ_NONE;
 
 	state = (reg >> TUSB320_REG9_ATTACHED_STATE_SHIFT) &
 		TUSB320_REG9_ATTACHED_STATE_MASK;
@@ -219,6 +209,22 @@ static irqreturn_t tusb320_irq_handler(int irq, void *dev_id)
 	extcon_sync(priv->edev, EXTCON_USB_HOST);
 
 	priv->state = state;
+}
+
+static irqreturn_t tusb320_irq_handler(int irq, void *dev_id)
+{
+	struct tusb320_priv *priv = dev_id;
+	unsigned int reg;
+
+	if (regmap_read(priv->regmap, TUSB320_REG9, &reg)) {
+		dev_err(priv->dev, "error during i2c read!\n");
+		return IRQ_NONE;
+	}
+
+	if (!(reg & TUSB320_REG9_INTERRUPT_STATUS))
+		return IRQ_NONE;
+
+	tusb320_extcon_irq_handler(priv, reg);
 
 	regmap_write(priv->regmap, TUSB320_REG9, reg);
 
@@ -230,8 +236,32 @@ static const struct regmap_config tusb320_regmap_config = {
 	.val_bits = 8,
 };
 
-static int tusb320_extcon_probe(struct i2c_client *client,
-				const struct i2c_device_id *id)
+static int tusb320_extcon_probe(struct tusb320_priv *priv)
+{
+	int ret;
+
+	priv->edev = devm_extcon_dev_allocate(priv->dev, tusb320_extcon_cable);
+	if (IS_ERR(priv->edev)) {
+		dev_err(priv->dev, "failed to allocate extcon device\n");
+		return PTR_ERR(priv->edev);
+	}
+
+	ret = devm_extcon_dev_register(priv->dev, priv->edev);
+	if (ret < 0) {
+		dev_err(priv->dev, "failed to register extcon device\n");
+		return ret;
+	}
+
+	extcon_set_property_capability(priv->edev, EXTCON_USB,
+				       EXTCON_PROP_USB_TYPEC_POLARITY);
+	extcon_set_property_capability(priv->edev, EXTCON_USB_HOST,
+				       EXTCON_PROP_USB_TYPEC_POLARITY);
+
+	return 0;
+}
+
+static int tusb320_probe(struct i2c_client *client,
+			 const struct i2c_device_id *id)
 {
 	struct tusb320_priv *priv;
 	const void *match_data;
@@ -257,12 +287,6 @@ static int tusb320_extcon_probe(struct i2c_client *client,
 
 	priv->ops = (struct tusb320_ops*)match_data;
 
-	priv->edev = devm_extcon_dev_allocate(priv->dev, tusb320_extcon_cable);
-	if (IS_ERR(priv->edev)) {
-		dev_err(priv->dev, "failed to allocate extcon device\n");
-		return PTR_ERR(priv->edev);
-	}
-
 	if (priv->ops->get_revision) {
 		ret = priv->ops->get_revision(priv, &revision);
 		if (ret)
@@ -272,16 +296,9 @@ static int tusb320_extcon_probe(struct i2c_client *client,
 			dev_info(priv->dev, "chip revision %d\n", revision);
 	}
 
-	ret = devm_extcon_dev_register(priv->dev, priv->edev);
-	if (ret < 0) {
-		dev_err(priv->dev, "failed to register extcon device\n");
+	ret = tusb320_extcon_probe(priv);
+	if (ret)
 		return ret;
-	}
-
-	extcon_set_property_capability(priv->edev, EXTCON_USB,
-				       EXTCON_PROP_USB_TYPEC_POLARITY);
-	extcon_set_property_capability(priv->edev, EXTCON_USB_HOST,
-				       EXTCON_PROP_USB_TYPEC_POLARITY);
 
 	/* update initial state */
 	tusb320_irq_handler(client->irq, priv);
@@ -313,7 +330,7 @@ static const struct of_device_id tusb320_extcon_dt_match[] = {
 MODULE_DEVICE_TABLE(of, tusb320_extcon_dt_match);
 
 static struct i2c_driver tusb320_extcon_driver = {
-	.probe		= tusb320_extcon_probe,
+	.probe		= tusb320_probe,
 	.driver		= {
 		.name	= "extcon-tusb320",
 		.of_match_table = tusb320_extcon_dt_match,
-- 
2.35.1


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

end of thread, other threads:[~2022-11-14  5:56 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-13 16:59 [PATCH 2/2] extcon: usbc-tusb320: Add USB TYPE-C support Peter Rosin
2022-11-13 17:38 ` [PATCH 2/2] extcon: usbc-tusb320: Add USB TYPE-C support #forregzbot Thorsten Leemhuis
2022-11-14  5:56   ` Thorsten Leemhuis
2022-11-13 18:48 ` [PATCH 2/2] extcon: usbc-tusb320: Add USB TYPE-C support Marek Vasut
2022-11-13 19:41   ` Peter Rosin
2022-11-13 20:47     ` Marek Vasut
  -- strict thread matches above, loose matches on Subject: below --
2022-07-30 18:04 [PATCH 1/2] extcon: usbc-tusb320: Factor out extcon into dedicated functions Marek Vasut
2022-07-30 18:05 ` [PATCH 2/2] extcon: usbc-tusb320: Add USB TYPE-C support Marek Vasut
2022-07-30 20:39   ` kernel test robot
2022-07-30 20:49   ` kernel test robot
2022-08-02  7:40   ` Heikki Krogerus
2022-08-23 10:40     ` Marek Vasut
2022-08-23  9:49   ` Alvin Šipraga
2022-08-23 10:39     ` Marek Vasut
2022-08-23 12:57       ` Alvin Šipraga
2022-08-23 14:07         ` Marek Vasut
2022-08-23 22:36   ` Chanwoo Choi

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