gjdwebserver-overlay/sys-kernel/pinephone-pro-sources/files/0021-usb-typec-fusb302-Add-...

35 lines
1.1 KiB
Diff

From: Ondrej Jirman <megous@megous.com>
Date: Sun, 14 Nov 2021 01:14:25 +0100
Subject: [PATCH 32/36] usb: typec: fusb302: Add OF extcon support
It's possible to create a dependency cycle between fusb302 and
other drivers via extcon device, so we retrieve the device on
demand after probe and not during probe.
Signed-off-by: Ondrej Jirman <megous@megous.com>
---
drivers/usb/typec/tcpm/fusb302.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/usb/typec/tcpm/fusb302.c b/drivers/usb/typec/tcpm/fusb302.c
index ae3b930..0c5dd00 100644
--- a/drivers/usb/typec/tcpm/fusb302.c
+++ b/drivers/usb/typec/tcpm/fusb302.c
@@ -518,6 +518,16 @@ static int tcpm_get_current_limit(struct tcpc_dev *dev)
int current_limit = 0;
unsigned long timeout;
+ /*
+ * To avoid cycles in OF dependencies, we get extcon when necessary
+ * outside of probe function.
+ */
+ if (of_property_read_bool(chip->dev->of_node, "extcon") && !chip->extcon) {
+ chip->extcon = extcon_get_edev_by_phandle(chip->dev, 0);
+ if (IS_ERR(chip->extcon))
+ chip->extcon = NULL;
+ }
+
if (!chip->extcon)
return 0;