Skip to contentSkip to conversation

extcon: intel-cht-wc: Also set direction and drv flags for V5 boost GPIO

PATCH Superseded Hans de Goede 3 participants 3 messages Feb 15, 2018 – Feb 19, 2018 External connector subsystem (extcon)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 extcon: intel-cht-wc: Also set direction and drv flags for V5 boost GPIO

Sometimes (firmware bug?) the V5 boost GPIO is not configured as output by the BIOS, leading to the 5V boost convertor being permanently on,

Explicitly set the direction and drv flags rather then inheriting them from the firmware to fix this.

---
 drivers/extcon/extcon-intel-cht-wc.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/extcon/extcon-intel-cht-wc.c +7 -4
index 7c4bc8c44c3f..b7e9ea377d70 100644
@@ -66,6 +66,8 @@
 
 #define CHT_WC_VBUS_GPIO_CTLO		0x6e2d
 #define CHT_WC_VBUS_GPIO_CTLO_OUTPUT	BIT(0)
+#define CHT_WC_VBUS_GPIO_CTLO_DRV_OD	BIT(4)
+#define CHT_WC_VBUS_GPIO_CTLO_DIR_OUT	BIT(5)
 
 enum cht_wc_usb_id {
 	USB_ID_OTG,
@@ -183,14 +185,15 @@ static void cht_wc_extcon_set_5v_boost(struct cht_wc_extcon_data *ext,
 {
 	int ret, val;
 
-	val = enable ? CHT_WC_VBUS_GPIO_CTLO_OUTPUT : 0;
-
 	/*
 	 * The 5V boost converter is enabled through a gpio on the PMIC, since
 	 * there currently is no gpio driver we access the gpio reg directly.
 	 */
-	ret = regmap_update_bits(ext->regmap, CHT_WC_VBUS_GPIO_CTLO,
-				 CHT_WC_VBUS_GPIO_CTLO_OUTPUT, val);
+	val = CHT_WC_VBUS_GPIO_CTLO_DRV_OD | CHT_WC_VBUS_GPIO_CTLO_DIR_OUT;
+	if (enable)
+		val |= CHT_WC_VBUS_GPIO_CTLO_OUTPUT;
+
+	ret = regmap_write(ext->regmap, CHT_WC_VBUS_GPIO_CTLO, val);
 	if (ret)
 		dev_err(ext->dev, "Error writing Vbus GPIO CTLO: %d\n", ret);
 }
Signature · 1 line
2.14.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Hans de Goede

Sometimes (firmware bug?) the V5 boost GPIO is not configured as output by the BIOS, leading to the 5V boost convertor being permanently on,

Explicitly set the direction and drv flags rather then inheriting them from the firmware to fix this.

FWIW,

Quoted 41 lines
---
 drivers/extcon/extcon-intel-cht-wc.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/extcon/extcon-intel-cht-wc.c +7 -5
index 7c4bc8c44c3f..b7e9ea377d70 100644
@@ -66,6 +66,8 @@
 
 #define CHT_WC_VBUS_GPIO_CTLO          0x6e2d
 #define CHT_WC_VBUS_GPIO_CTLO_OUTPUT   BIT(0)
+#define CHT_WC_VBUS_GPIO_CTLO_DRV_OD   BIT(4)
+#define CHT_WC_VBUS_GPIO_CTLO_DIR_OUT  BIT(5)
 
 enum cht_wc_usb_id {
        USB_ID_OTG,
@@ -183,14 +185,15 @@ static void cht_wc_extcon_set_5v_boost(struct cht_wc_extcon_data *ext,
 {
        int ret, val;
 
-       val = enable ? CHT_WC_VBUS_GPIO_CTLO_OUTPUT : 0;
-
        /*
         * The 5V boost converter is enabled through a gpio on the PMIC, since
         * there currently is no gpio driver we access the gpio reg directly.
         */
-       ret = regmap_update_bits(ext->regmap, CHT_WC_VBUS_GPIO_CTLO,
-                                CHT_WC_VBUS_GPIO_CTLO_OUTPUT, val);
+       val = CHT_WC_VBUS_GPIO_CTLO_DRV_OD | CHT_WC_VBUS_GPIO_CTLO_DIR_OUT;
+       if (enable)
+               val |= CHT_WC_VBUS_GPIO_CTLO_OUTPUT;
+
+       ret = regmap_write(ext->regmap, CHT_WC_VBUS_GPIO_CTLO, val);
        if (ret)
                dev_err(ext->dev, "Error writing Vbus GPIO CTLO: %d\n", ret);
 }
--

2.14.3

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#2 lore raw
In reply to Hans de Goede

Hi,

Quoted 7 lines · Hans de Goede

Sometimes (firmware bug?) the V5 boost GPIO is not configured as output by the BIOS, leading to the 5V boost convertor being permanently on,

Explicitly set the direction and drv flags rather then inheriting them from the firmware to fix this.

You need to add fixes tag and send stable mailing list.

Quoted 38 lines
---
 drivers/extcon/extcon-intel-cht-wc.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/extcon/extcon-intel-cht-wc.c +7 -4
index 7c4bc8c44c3f..b7e9ea377d70 100644
@@ -66,6 +66,8 @@
 
 #define CHT_WC_VBUS_GPIO_CTLO		0x6e2d
 #define CHT_WC_VBUS_GPIO_CTLO_OUTPUT	BIT(0)
+#define CHT_WC_VBUS_GPIO_CTLO_DRV_OD	BIT(4)
+#define CHT_WC_VBUS_GPIO_CTLO_DIR_OUT	BIT(5)
 
 enum cht_wc_usb_id {
 	USB_ID_OTG,
@@ -183,14 +185,15 @@ static void cht_wc_extcon_set_5v_boost(struct cht_wc_extcon_data *ext,
 {
 	int ret, val;
 
-	val = enable ? CHT_WC_VBUS_GPIO_CTLO_OUTPUT : 0;
-
 	/*
 	 * The 5V boost converter is enabled through a gpio on the PMIC, since
 	 * there currently is no gpio driver we access the gpio reg directly.
 	 */
-	ret = regmap_update_bits(ext->regmap, CHT_WC_VBUS_GPIO_CTLO,
-				 CHT_WC_VBUS_GPIO_CTLO_OUTPUT, val);
+	val = CHT_WC_VBUS_GPIO_CTLO_DRV_OD | CHT_WC_VBUS_GPIO_CTLO_DIR_OUT;
+	if (enable)
+		val |= CHT_WC_VBUS_GPIO_CTLO_OUTPUT;
+
+	ret = regmap_write(ext->regmap, CHT_WC_VBUS_GPIO_CTLO, val);
 	if (ret)
 		dev_err(ext->dev, "Error writing Vbus GPIO CTLO: %d\n", ret);
 }
Signature · 3 lines
Best Regards,
Chanwoo Choi
Samsung Electronics