[PATCH 12/13] extcon: intel-cht-wc: Check new "intel,cht-wc-setup" device-property

From: Hans de Goede
Date: Sat Oct 30 2021 - 14:29:23 EST


The CHT_WC_VBUS_GPIO_CTLO GPIO actually driving an external 5V Vboost
converter for Vbus depends on the board on which the Cherry Trail -
Whiskey Cove PMIC is actually used.

Since the information about the exact PMIC setup is necessary in other
places too, the kernel now adds a "intel,cht-wc-setup" string property
to the Whiskey Cove PMIC i2c-client based on DMI matching.

Only poke the CHT_WC_VBUS_GPIO_CTLO GPIO if this new property has the
"bq24292i,max17047,fusb302,pi3usb30532" value which indicates the Type-C
(with PD and DP-altmode) setup used on the GPD pocket and GPD win; and
on which this GPIO actually controls an external 5V Vboost converter.

Signed-off-by: Hans de Goede <hdegoede@xxxxxxxxxx>
---
drivers/extcon/extcon-intel-cht-wc.c | 38 ++++++++++++++++------------
1 file changed, 22 insertions(+), 16 deletions(-)

diff --git a/drivers/extcon/extcon-intel-cht-wc.c b/drivers/extcon/extcon-intel-cht-wc.c
index 771f6f4cf92e..a7a6b43d699b 100644
--- a/drivers/extcon/extcon-intel-cht-wc.c
+++ b/drivers/extcon/extcon-intel-cht-wc.c
@@ -14,6 +14,7 @@
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/platform_device.h>
+#include <linux/property.h>
#include <linux/regmap.h>
#include <linux/slab.h>

@@ -338,8 +339,8 @@ static int cht_wc_extcon_probe(struct platform_device *pdev)
struct intel_soc_pmic *pmic = dev_get_drvdata(pdev->dev.parent);
struct cht_wc_extcon_data *ext;
unsigned long mask = ~(CHT_WC_PWRSRC_VBUS | CHT_WC_PWRSRC_USBID_MASK);
- int pwrsrc_sts, id;
- int irq, ret;
+ int id, irq, pwrsrc_sts, ret;
+ const char *setup;

irq = platform_get_irq(pdev, 0);
if (irq < 0)
@@ -358,20 +359,25 @@ static int cht_wc_extcon_probe(struct platform_device *pdev)
if (IS_ERR(ext->edev))
return PTR_ERR(ext->edev);

- /*
- * When a host-cable is detected the BIOS enables an external 5v boost
- * converter to power connected devices there are 2 problems with this:
- * 1) This gets seen by the external battery charger as a valid Vbus
- * supply and it then tries to feed Vsys from this creating a
- * feedback loop which causes aprox. 300 mA extra battery drain
- * (and unless we drive the external-charger-disable pin high it
- * also tries to charge the battery causing even more feedback).
- * 2) This gets seen by the pwrsrc block as a SDP USB Vbus supply
- * Since the external battery charger has its own 5v boost converter
- * which does not have these issues, we simply turn the separate
- * external 5v boost converter off and leave it off entirely.
- */
- cht_wc_extcon_set_5v_boost(ext, false);
+ ret = device_property_read_string(ext->dev->parent, "intel,cht-wc-setup", &setup);
+ if (ret) {
+ dev_warn(ext->dev, "intel,cht-wc-setup not set\n");
+ } else if (!strcmp(setup, "bq24292i,max17047,fusb302,pi3usb30532")) {
+ /*
+ * When a host-cable is detected the BIOS enables an external 5v boost
+ * converter to power connected devices there are 2 problems with this:
+ * 1) This gets seen by the external battery charger as a valid Vbus
+ * supply and it then tries to feed Vsys from this creating a
+ * feedback loop which causes aprox. 300 mA extra battery drain
+ * (and unless we drive the external-charger-disable pin high it
+ * also tries to charge the battery causing even more feedback).
+ * 2) This gets seen by the pwrsrc block as a SDP USB Vbus supply
+ * Since the external battery charger has its own 5v boost converter
+ * which does not have these issues, we simply turn the separate
+ * external 5v boost converter off and leave it off entirely.
+ */
+ cht_wc_extcon_set_5v_boost(ext, false);
+ }

/* Enable sw control */
ret = cht_wc_extcon_sw_control(ext, true);
--
2.31.1