mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] usb: typec: ucsi: psy: Set current max to 100mA for BC 1.2 and Default
@ 2025-07-17 20:08 Benson Leung
  2025-07-17 20:48 ` Jameson Thies
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Benson Leung @ 2025-07-17 20:08 UTC (permalink / raw)
  To: heikki.krogerus, jthies, gregkh, hansg, sebastian.reichel,
	dmitry.baryshkov, madhu.m, linux-usb, linux-kernel
  Cc: bleung, Benson Leung

ucsi_psy_get_current_max would return 0mA as the maximum current if
UCSI detected a BC or a Default USB Power sporce.

The comment in this function is true that we can't tell the difference
between DCP/CDP or SDP chargers, but we can guarantee that at least 1-unit
of USB 1.1/2.0 power is available, which is 100mA, which is a better
fallback value than 0, which causes some userspaces, including the ChromeOS
power manager, to regard this as a power source that is not providing
any power.

In reality, 100mA is guaranteed from all sources in these classes.

Signed-off-by: Benson Leung <bleung@chromium.org>
---
 drivers/usb/typec/ucsi/psy.c  | 2 +-
 drivers/usb/typec/ucsi/ucsi.h | 7 ++++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/typec/ucsi/psy.c b/drivers/usb/typec/ucsi/psy.c
index 62ac69730405..62a9d68bb66d 100644
--- a/drivers/usb/typec/ucsi/psy.c
+++ b/drivers/usb/typec/ucsi/psy.c
@@ -164,7 +164,7 @@ static int ucsi_psy_get_current_max(struct ucsi_connector *con,
 	case UCSI_CONSTAT_PWR_OPMODE_DEFAULT:
 	/* UCSI can't tell b/w DCP/CDP or USB2/3x1/3x2 SDP chargers */
 	default:
-		val->intval = 0;
+		val->intval = UCSI_TYPEC_DEFAULT_CURRENT * 1000;
 		break;
 	}
 	return 0;
diff --git a/drivers/usb/typec/ucsi/ucsi.h b/drivers/usb/typec/ucsi/ucsi.h
index b711e1ecc378..ebd7c27c2cc7 100644
--- a/drivers/usb/typec/ucsi/ucsi.h
+++ b/drivers/usb/typec/ucsi/ucsi.h
@@ -483,9 +483,10 @@ struct ucsi {
 #define UCSI_MAX_SVID		5
 #define UCSI_MAX_ALTMODES	(UCSI_MAX_SVID * 6)
 
-#define UCSI_TYPEC_VSAFE5V	5000
-#define UCSI_TYPEC_1_5_CURRENT	1500
-#define UCSI_TYPEC_3_0_CURRENT	3000
+#define UCSI_TYPEC_VSAFE5V		5000
+#define UCSI_TYPEC_DEFAULT_CURRENT	 100
+#define UCSI_TYPEC_1_5_CURRENT		1500
+#define UCSI_TYPEC_3_0_CURRENT		3000
 
 struct ucsi_connector {
 	int num;
-- 
2.50.0.727.gbf7dc18ff4-goog


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

* Re: [PATCH] usb: typec: ucsi: psy: Set current max to 100mA for BC 1.2 and Default
  2025-07-17 20:08 [PATCH] usb: typec: ucsi: psy: Set current max to 100mA for BC 1.2 and Default Benson Leung
@ 2025-07-17 20:48 ` Jameson Thies
  2025-07-17 22:40 ` Sebastian Reichel
  2025-07-21  9:46 ` Heikki Krogerus
  2 siblings, 0 replies; 4+ messages in thread
From: Jameson Thies @ 2025-07-17 20:48 UTC (permalink / raw)
  To: Benson Leung
  Cc: heikki.krogerus, gregkh, hansg, sebastian.reichel,
	dmitry.baryshkov, madhu.m, linux-usb, linux-kernel, bleung

On Thu, Jul 17, 2025 at 1:08 PM Benson Leung <bleung@chromium.org> wrote:
>
> ucsi_psy_get_current_max would return 0mA as the maximum current if
> UCSI detected a BC or a Default USB Power sporce.
>
> The comment in this function is true that we can't tell the difference
> between DCP/CDP or SDP chargers, but we can guarantee that at least 1-unit
> of USB 1.1/2.0 power is available, which is 100mA, which is a better
> fallback value than 0, which causes some userspaces, including the ChromeOS
> power manager, to regard this as a power source that is not providing
> any power.
>
> In reality, 100mA is guaranteed from all sources in these classes.
>
> Signed-off-by: Benson Leung <bleung@chromium.org>

Reviewed-by: Jameson Thies <jthies@google.com>

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

* Re: [PATCH] usb: typec: ucsi: psy: Set current max to 100mA for BC 1.2 and Default
  2025-07-17 20:08 [PATCH] usb: typec: ucsi: psy: Set current max to 100mA for BC 1.2 and Default Benson Leung
  2025-07-17 20:48 ` Jameson Thies
@ 2025-07-17 22:40 ` Sebastian Reichel
  2025-07-21  9:46 ` Heikki Krogerus
  2 siblings, 0 replies; 4+ messages in thread
From: Sebastian Reichel @ 2025-07-17 22:40 UTC (permalink / raw)
  To: Benson Leung
  Cc: heikki.krogerus, jthies, gregkh, hansg, dmitry.baryshkov,
	madhu.m, linux-usb, linux-kernel, bleung

[-- Attachment #1: Type: text/plain, Size: 2199 bytes --]

Hi,

On Thu, Jul 17, 2025 at 08:08:05PM +0000, Benson Leung wrote:
> ucsi_psy_get_current_max would return 0mA as the maximum current if
> UCSI detected a BC or a Default USB Power sporce.

sporce?

> The comment in this function is true that we can't tell the difference
> between DCP/CDP or SDP chargers, but we can guarantee that at least 1-unit
> of USB 1.1/2.0 power is available, which is 100mA, which is a better
> fallback value than 0, which causes some userspaces, including the ChromeOS
> power manager, to regard this as a power source that is not providing
> any power.
> 
> In reality, 100mA is guaranteed from all sources in these classes.
> 
> Signed-off-by: Benson Leung <bleung@chromium.org>
> ---

Otherwise patch LGTM.

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>

-- Sebastian

>  drivers/usb/typec/ucsi/psy.c  | 2 +-
>  drivers/usb/typec/ucsi/ucsi.h | 7 ++++---
>  2 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/typec/ucsi/psy.c b/drivers/usb/typec/ucsi/psy.c
> index 62ac69730405..62a9d68bb66d 100644
> --- a/drivers/usb/typec/ucsi/psy.c
> +++ b/drivers/usb/typec/ucsi/psy.c
> @@ -164,7 +164,7 @@ static int ucsi_psy_get_current_max(struct ucsi_connector *con,
>  	case UCSI_CONSTAT_PWR_OPMODE_DEFAULT:
>  	/* UCSI can't tell b/w DCP/CDP or USB2/3x1/3x2 SDP chargers */
>  	default:
> -		val->intval = 0;
> +		val->intval = UCSI_TYPEC_DEFAULT_CURRENT * 1000;
>  		break;
>  	}
>  	return 0;
> diff --git a/drivers/usb/typec/ucsi/ucsi.h b/drivers/usb/typec/ucsi/ucsi.h
> index b711e1ecc378..ebd7c27c2cc7 100644
> --- a/drivers/usb/typec/ucsi/ucsi.h
> +++ b/drivers/usb/typec/ucsi/ucsi.h
> @@ -483,9 +483,10 @@ struct ucsi {
>  #define UCSI_MAX_SVID		5
>  #define UCSI_MAX_ALTMODES	(UCSI_MAX_SVID * 6)
>  
> -#define UCSI_TYPEC_VSAFE5V	5000
> -#define UCSI_TYPEC_1_5_CURRENT	1500
> -#define UCSI_TYPEC_3_0_CURRENT	3000
> +#define UCSI_TYPEC_VSAFE5V		5000
> +#define UCSI_TYPEC_DEFAULT_CURRENT	 100
> +#define UCSI_TYPEC_1_5_CURRENT		1500
> +#define UCSI_TYPEC_3_0_CURRENT		3000
>  
>  struct ucsi_connector {
>  	int num;
> -- 
> 2.50.0.727.gbf7dc18ff4-goog
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] usb: typec: ucsi: psy: Set current max to 100mA for BC 1.2 and Default
  2025-07-17 20:08 [PATCH] usb: typec: ucsi: psy: Set current max to 100mA for BC 1.2 and Default Benson Leung
  2025-07-17 20:48 ` Jameson Thies
  2025-07-17 22:40 ` Sebastian Reichel
@ 2025-07-21  9:46 ` Heikki Krogerus
  2 siblings, 0 replies; 4+ messages in thread
From: Heikki Krogerus @ 2025-07-21  9:46 UTC (permalink / raw)
  To: Benson Leung
  Cc: jthies, gregkh, hansg, sebastian.reichel, dmitry.baryshkov,
	madhu.m, linux-usb, linux-kernel, bleung

On Thu, Jul 17, 2025 at 08:08:05PM +0000, Benson Leung wrote:
> ucsi_psy_get_current_max would return 0mA as the maximum current if
> UCSI detected a BC or a Default USB Power sporce.
> 
> The comment in this function is true that we can't tell the difference
> between DCP/CDP or SDP chargers, but we can guarantee that at least 1-unit
> of USB 1.1/2.0 power is available, which is 100mA, which is a better
> fallback value than 0, which causes some userspaces, including the ChromeOS
> power manager, to regard this as a power source that is not providing
> any power.
> 
> In reality, 100mA is guaranteed from all sources in these classes.
> 
> Signed-off-by: Benson Leung <bleung@chromium.org>

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/ucsi/psy.c  | 2 +-
>  drivers/usb/typec/ucsi/ucsi.h | 7 ++++---
>  2 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/typec/ucsi/psy.c b/drivers/usb/typec/ucsi/psy.c
> index 62ac69730405..62a9d68bb66d 100644
> --- a/drivers/usb/typec/ucsi/psy.c
> +++ b/drivers/usb/typec/ucsi/psy.c
> @@ -164,7 +164,7 @@ static int ucsi_psy_get_current_max(struct ucsi_connector *con,
>  	case UCSI_CONSTAT_PWR_OPMODE_DEFAULT:
>  	/* UCSI can't tell b/w DCP/CDP or USB2/3x1/3x2 SDP chargers */
>  	default:
> -		val->intval = 0;
> +		val->intval = UCSI_TYPEC_DEFAULT_CURRENT * 1000;
>  		break;
>  	}
>  	return 0;
> diff --git a/drivers/usb/typec/ucsi/ucsi.h b/drivers/usb/typec/ucsi/ucsi.h
> index b711e1ecc378..ebd7c27c2cc7 100644
> --- a/drivers/usb/typec/ucsi/ucsi.h
> +++ b/drivers/usb/typec/ucsi/ucsi.h
> @@ -483,9 +483,10 @@ struct ucsi {
>  #define UCSI_MAX_SVID		5
>  #define UCSI_MAX_ALTMODES	(UCSI_MAX_SVID * 6)
>  
> -#define UCSI_TYPEC_VSAFE5V	5000
> -#define UCSI_TYPEC_1_5_CURRENT	1500
> -#define UCSI_TYPEC_3_0_CURRENT	3000
> +#define UCSI_TYPEC_VSAFE5V		5000
> +#define UCSI_TYPEC_DEFAULT_CURRENT	 100
> +#define UCSI_TYPEC_1_5_CURRENT		1500
> +#define UCSI_TYPEC_3_0_CURRENT		3000
>  
>  struct ucsi_connector {
>  	int num;
> -- 
> 2.50.0.727.gbf7dc18ff4-goog

-- 
heikki

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

end of thread, other threads:[~2025-07-21  9:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-17 20:08 [PATCH] usb: typec: ucsi: psy: Set current max to 100mA for BC 1.2 and Default Benson Leung
2025-07-17 20:48 ` Jameson Thies
2025-07-17 22:40 ` Sebastian Reichel
2025-07-21  9:46 ` Heikki Krogerus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®