linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] usb: typec: couple of fixes for stusb160x
@ 2021-07-16 12:07 Amelie Delaunay
  2021-07-16 12:07 ` [PATCH 1/2] usb: typec: stusb160x: register role switch before interrupt registration Amelie Delaunay
  2021-07-16 12:07 ` [PATCH 2/2] usb: typec: stusb160x: Don't block probing of consumer of "connector" nodes Amelie Delaunay
  0 siblings, 2 replies; 3+ messages in thread
From: Amelie Delaunay @ 2021-07-16 12:07 UTC (permalink / raw)
  To: Heikki Krogerus, Greg Kroah-Hartman, Saravana Kannan
  Cc: linux-usb, linux-kernel, linux-stm32, Amelie Delaunay, Fabrice Gasnier

First patch fixes role switch when attached before probe.
Second patch follows Martin's patch [1] as it is also applicable for
stusb160x typec driver, in order to avoid the WARNING seen on
stm32mp15xx-dkx boot:
[    8.598414] typec port0: Fixing up cyclic dependency with 49000000.usb-otg
[    8.604493] dwc2 49000000.usb-otg: supply vusb_d not found, using dummy regulator
[    8.630642] ------------[ cut here ]------------
[    8.649193] WARNING: CPU: 0 PID: 157 at drivers/base/core.c:1532 device_del+0x328/0x3ec

[1] https://lkml.org/lkml/2021/7/14/47

Amelie Delaunay (2):
  usb: typec: stusb160x: register role switch before interrupt
    registration
  usb: typec: stusb160x: Don't block probing of consumer of "connector"
    nodes

 drivers/usb/typec/stusb160x.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

-- 
2.25.1


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

* [PATCH 1/2] usb: typec: stusb160x: register role switch before interrupt registration
  2021-07-16 12:07 [PATCH 0/2] usb: typec: couple of fixes for stusb160x Amelie Delaunay
@ 2021-07-16 12:07 ` Amelie Delaunay
  2021-07-16 12:07 ` [PATCH 2/2] usb: typec: stusb160x: Don't block probing of consumer of "connector" nodes Amelie Delaunay
  1 sibling, 0 replies; 3+ messages in thread
From: Amelie Delaunay @ 2021-07-16 12:07 UTC (permalink / raw)
  To: Heikki Krogerus, Greg Kroah-Hartman, Saravana Kannan
  Cc: linux-usb, linux-kernel, linux-stm32, Amelie Delaunay, Fabrice Gasnier

During interrupt registration, attach state is checked. If attached, then
the Type-C state is updated with typec_set_xxx functions and role switch is
set with usb_role_switch_set_role().
If the usb_role_switch parameter is error or null, the function simply
returns 0.
So, to update usb_role_switch role if a device is attached before the irq
is registered, usb_role_switch must be registered before irq registration.

Fixes: da0cb6310094 ("usb: typec: add support for STUSB160x Type-C controller family")
Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
---
 drivers/usb/typec/stusb160x.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/typec/stusb160x.c b/drivers/usb/typec/stusb160x.c
index 6eaeba9b096e..3d3848e7c2c2 100644
--- a/drivers/usb/typec/stusb160x.c
+++ b/drivers/usb/typec/stusb160x.c
@@ -739,10 +739,6 @@ static int stusb160x_probe(struct i2c_client *client)
 	typec_set_pwr_opmode(chip->port, chip->pwr_opmode);
 
 	if (client->irq) {
-		ret = stusb160x_irq_init(chip, client->irq);
-		if (ret)
-			goto port_unregister;
-
 		chip->role_sw = fwnode_usb_role_switch_get(fwnode);
 		if (IS_ERR(chip->role_sw)) {
 			ret = PTR_ERR(chip->role_sw);
@@ -752,6 +748,10 @@ static int stusb160x_probe(struct i2c_client *client)
 					ret);
 			goto port_unregister;
 		}
+
+		ret = stusb160x_irq_init(chip, client->irq);
+		if (ret)
+			goto role_sw_put;
 	} else {
 		/*
 		 * If Source or Dual power role, need to enable VDD supply
@@ -775,6 +775,9 @@ static int stusb160x_probe(struct i2c_client *client)
 
 	return 0;
 
+role_sw_put:
+	if (chip->role_sw)
+		usb_role_switch_put(chip->role_sw);
 port_unregister:
 	typec_unregister_port(chip->port);
 all_reg_disable:
-- 
2.25.1


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

* [PATCH 2/2] usb: typec: stusb160x: Don't block probing of consumer of "connector" nodes
  2021-07-16 12:07 [PATCH 0/2] usb: typec: couple of fixes for stusb160x Amelie Delaunay
  2021-07-16 12:07 ` [PATCH 1/2] usb: typec: stusb160x: register role switch before interrupt registration Amelie Delaunay
@ 2021-07-16 12:07 ` Amelie Delaunay
  1 sibling, 0 replies; 3+ messages in thread
From: Amelie Delaunay @ 2021-07-16 12:07 UTC (permalink / raw)
  To: Heikki Krogerus, Greg Kroah-Hartman, Saravana Kannan
  Cc: linux-usb, linux-kernel, linux-stm32, Amelie Delaunay, Fabrice Gasnier

Similar as with tcpm this patch lets fw_devlink know not to wait on the
fwnode to be populated as a struct device.

Without this patch, USB functionality can be broken on some previously
supported boards.

Fixes: 28ec344bb891 ("usb: typec: tcpm: Don't block probing of consumers of "connector" nodes")
Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
---
 drivers/usb/typec/stusb160x.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/usb/typec/stusb160x.c b/drivers/usb/typec/stusb160x.c
index 3d3848e7c2c2..e7745d1c2a5c 100644
--- a/drivers/usb/typec/stusb160x.c
+++ b/drivers/usb/typec/stusb160x.c
@@ -685,6 +685,15 @@ static int stusb160x_probe(struct i2c_client *client)
 	if (!fwnode)
 		return -ENODEV;
 
+	/*
+	 * This fwnode has a "compatible" property, but is never populated as a
+	 * struct device. Instead we simply parse it to read the properties.
+	 * This it breaks fw_devlink=on. To maintain backward compatibility
+	 * with existing DT files, we work around this by deleting any
+	 * fwnode_links to/from this fwnode.
+	 */
+	fw_devlink_purge_absent_suppliers(fwnode);
+
 	/*
 	 * When both VDD and VSYS power supplies are present, the low power
 	 * supply VSYS is selected when VSYS voltage is above 3.1 V.
-- 
2.25.1


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

end of thread, other threads:[~2021-07-16 12:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-16 12:07 [PATCH 0/2] usb: typec: couple of fixes for stusb160x Amelie Delaunay
2021-07-16 12:07 ` [PATCH 1/2] usb: typec: stusb160x: register role switch before interrupt registration Amelie Delaunay
2021-07-16 12:07 ` [PATCH 2/2] usb: typec: stusb160x: Don't block probing of consumer of "connector" nodes Amelie Delaunay

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