Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1616407 > unrolled thread

[PATCH v2 2/2] extcon: intel-cht-wc: Ignore failure to detect charger-type on host mode exit

Started byHans de Goede <hdegoede@redhat.com>
First post2017-04-05 00:10 +0200
Last post2017-04-05 03:10 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v2 2/2] extcon: intel-cht-wc: Ignore failure to detect charger-type on host mode exit Hans de Goede <hdegoede@redhat.com> - 2017-04-05 00:10 +0200
    Re: [PATCH v2 2/2] extcon: intel-cht-wc: Ignore failure to detect  charger-type on host mode exit Chanwoo Choi <cw00.choi@samsung.com> - 2017-04-05 03:10 +0200

#1616407 — [PATCH v2 2/2] extcon: intel-cht-wc: Ignore failure to detect charger-type on host mode exit

FromHans de Goede <hdegoede@redhat.com>
Date2017-04-05 00:10 +0200
Subject[PATCH v2 2/2] extcon: intel-cht-wc: Ignore failure to detect charger-type on host mode exit
Message-ID<tsEOe-2oP-15@gated-at.bofh.it>
When we leave host-mode because the id-pin is no longer connected to
ground, the 5v boost converter is normally still on, so we will see
Vbus, but it is not from a charger (normally) so the charger-type
detection will fail.

This commit silences the cht_wc_extcon_get_charger() false-positive
errors when we're leaving host mode.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/extcon/extcon-intel-cht-wc.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/extcon/extcon-intel-cht-wc.c b/drivers/extcon/extcon-intel-cht-wc.c
index e22df5f..5f37112 100644
--- a/drivers/extcon/extcon-intel-cht-wc.c
+++ b/drivers/extcon/extcon-intel-cht-wc.c
@@ -96,6 +96,7 @@ struct cht_wc_extcon_data {
 	struct regmap *regmap;
 	struct extcon_dev *edev;
 	unsigned int previous_cable;
+	bool usb_host;
 };
 
 static int cht_wc_extcon_get_id(struct cht_wc_extcon_data *ext, int pwrsrc_sts)
@@ -112,7 +113,8 @@ static int cht_wc_extcon_get_id(struct cht_wc_extcon_data *ext, int pwrsrc_sts)
 	return USB_ID_FLOAT;
 }
 
-static int cht_wc_extcon_get_charger(struct cht_wc_extcon_data *ext)
+static int cht_wc_extcon_get_charger(struct cht_wc_extcon_data *ext,
+				     bool ignore_errors)
 {
 	int ret, usbsrc, status;
 	unsigned long timeout;
@@ -135,6 +137,9 @@ static int cht_wc_extcon_get_charger(struct cht_wc_extcon_data *ext)
 	} while (time_before(jiffies, timeout));
 
 	if (status != CHT_WC_USBSRC_STS_SUCCESS) {
+		if (ignore_errors)
+			return EXTCON_CHG_USB_SDP; /* Save fallback */
+
 		if (status == CHT_WC_USBSRC_STS_FAIL)
 			dev_warn(ext->dev, "Could not detect charger type\n");
 		else
@@ -203,6 +208,8 @@ static void cht_wc_extcon_pwrsrc_event(struct cht_wc_extcon_data *ext)
 {
 	int ret, pwrsrc_sts, id;
 	unsigned int cable = EXTCON_NONE;
+	/* Ignore errors in host mode, as the 5v boost converter is on then */
+	bool ignore_get_charger_errors = ext->usb_host;
 
 	ret = regmap_read(ext->regmap, CHT_WC_PWRSRC_STS, &pwrsrc_sts);
 	if (ret) {
@@ -223,7 +230,7 @@ static void cht_wc_extcon_pwrsrc_event(struct cht_wc_extcon_data *ext)
 		goto set_state;
 	}
 
-	ret = cht_wc_extcon_get_charger(ext);
+	ret = cht_wc_extcon_get_charger(ext, ignore_get_charger_errors);
 	if (ret >= 0)
 		cable = ret;
 
@@ -238,8 +245,8 @@ static void cht_wc_extcon_pwrsrc_event(struct cht_wc_extcon_data *ext)
 		ext->previous_cable = cable;
 	}
 
-	extcon_set_state_sync(ext->edev, EXTCON_USB_HOST,
-			      id == USB_ID_GND || id == USB_RID_A);
+	ext->usb_host = id == USB_ID_GND || id == USB_RID_A;
+	extcon_set_state_sync(ext->edev, EXTCON_USB_HOST, ext->usb_host);
 }
 
 static irqreturn_t cht_wc_extcon_isr(int irq, void *data)
-- 
2.9.3

[toc] | [next] | [standalone]


#1616483 — Re: [PATCH v2 2/2] extcon: intel-cht-wc: Ignore failure to detect charger-type on host mode exit

FromChanwoo Choi <cw00.choi@samsung.com>
Date2017-04-05 03:10 +0200
SubjectRe: [PATCH v2 2/2] extcon: intel-cht-wc: Ignore failure to detect charger-type on host mode exit
Message-ID<tsHCq-4am-9@gated-at.bofh.it>
In reply to#1616407
On 2017년 04월 05일 07:04, Hans de Goede wrote:
> When we leave host-mode because the id-pin is no longer connected to
> ground, the 5v boost converter is normally still on, so we will see
> Vbus, but it is not from a charger (normally) so the charger-type
> detection will fail.
> 
> This commit silences the cht_wc_extcon_get_charger() false-positive
> errors when we're leaving host mode.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  drivers/extcon/extcon-intel-cht-wc.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/extcon/extcon-intel-cht-wc.c b/drivers/extcon/extcon-intel-cht-wc.c
> index e22df5f..5f37112 100644
> --- a/drivers/extcon/extcon-intel-cht-wc.c
> +++ b/drivers/extcon/extcon-intel-cht-wc.c
> @@ -96,6 +96,7 @@ struct cht_wc_extcon_data {
>  	struct regmap *regmap;
>  	struct extcon_dev *edev;
>  	unsigned int previous_cable;
> +	bool usb_host;
>  };
>  
>  static int cht_wc_extcon_get_id(struct cht_wc_extcon_data *ext, int pwrsrc_sts)
> @@ -112,7 +113,8 @@ static int cht_wc_extcon_get_id(struct cht_wc_extcon_data *ext, int pwrsrc_sts)
>  	return USB_ID_FLOAT;
>  }
>  
> -static int cht_wc_extcon_get_charger(struct cht_wc_extcon_data *ext)
> +static int cht_wc_extcon_get_charger(struct cht_wc_extcon_data *ext,
> +				     bool ignore_errors)
>  {
>  	int ret, usbsrc, status;
>  	unsigned long timeout;
> @@ -135,6 +137,9 @@ static int cht_wc_extcon_get_charger(struct cht_wc_extcon_data *ext)
>  	} while (time_before(jiffies, timeout));
>  
>  	if (status != CHT_WC_USBSRC_STS_SUCCESS) {
> +		if (ignore_errors)
> +			return EXTCON_CHG_USB_SDP; /* Save fallback */
> +
>  		if (status == CHT_WC_USBSRC_STS_FAIL)
>  			dev_warn(ext->dev, "Could not detect charger type\n");
>  		else
> @@ -203,6 +208,8 @@ static void cht_wc_extcon_pwrsrc_event(struct cht_wc_extcon_data *ext)
>  {
>  	int ret, pwrsrc_sts, id;
>  	unsigned int cable = EXTCON_NONE;
> +	/* Ignore errors in host mode, as the 5v boost converter is on then */
> +	bool ignore_get_charger_errors = ext->usb_host;
>  
>  	ret = regmap_read(ext->regmap, CHT_WC_PWRSRC_STS, &pwrsrc_sts);
>  	if (ret) {
> @@ -223,7 +230,7 @@ static void cht_wc_extcon_pwrsrc_event(struct cht_wc_extcon_data *ext)
>  		goto set_state;
>  	}
>  
> -	ret = cht_wc_extcon_get_charger(ext);
> +	ret = cht_wc_extcon_get_charger(ext, ignore_get_charger_errors);
>  	if (ret >= 0)
>  		cable = ret;
>  
> @@ -238,8 +245,8 @@ static void cht_wc_extcon_pwrsrc_event(struct cht_wc_extcon_data *ext)
>  		ext->previous_cable = cable;
>  	}
>  
> -	extcon_set_state_sync(ext->edev, EXTCON_USB_HOST,
> -			      id == USB_ID_GND || id == USB_RID_A);
> +	ext->usb_host = id == USB_ID_GND || id == USB_RID_A;

I'll modify it as following to improve the readability:
	ext->usb_host = ((id == USB_ID_GND) || (id == USB_RID_A));

> +	extcon_set_state_sync(ext->edev, EXTCON_USB_HOST, ext->usb_host);
>  }
>  
>  static irqreturn_t cht_wc_extcon_isr(int irq, void *data)
> 


-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web