[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aTrM-1HiOtnLtLyc@kuha>
Date: Thu, 11 Dec 2025 15:54:03 +0200
From: Heikki Krogerus <heikki.krogerus@...ux.intel.com>
To: Benson Leung <bleung@...omium.org>
Cc: sebastian.reichel@...labora.com, gregkh@...uxfoundation.org,
jthies@...gle.com, bleung@...gle.com, linux-usb@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] usb: typec: ucsi: psy: Fix ucsi_psy_get_current_now
in non-PD cases
Mon, Dec 08, 2025 at 05:48:47PM +0000, Benson Leung kirjoitti:
> current_now would always return 0 in for non-PD power sources, and the
> negotiated current based on the Request RDO in PD mode.
>
> For USB Type-C current or legacy Default USB cases current_now will present
> the max value of those modes, as that is the equivalent of the Request RDO
> in PD.
>
> Also, current_now will now return 0 when the port is disconnected to match
> the same behavior of current_max.
>
> Signed-off-by: Benson Leung <bleung@...omium.org>
Looks good to me. Shouldn't this be applied also to the stable trees?
Reviewed-by: Heikki Krogerus <heikki.krogerus@...ux.intel.com>
> ---
> drivers/usb/typec/ucsi/psy.c | 24 +++++++++++++++++++++---
> 1 file changed, 21 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/typec/ucsi/psy.c b/drivers/usb/typec/ucsi/psy.c
> index 3abe9370ffaa..b828719e33df 100644
> --- a/drivers/usb/typec/ucsi/psy.c
> +++ b/drivers/usb/typec/ucsi/psy.c
> @@ -202,10 +202,28 @@ static int ucsi_psy_get_current_max(struct ucsi_connector *con,
> static int ucsi_psy_get_current_now(struct ucsi_connector *con,
> union power_supply_propval *val)
> {
> - if (UCSI_CONSTAT(con, PWR_OPMODE) == UCSI_CONSTAT_PWR_OPMODE_PD)
> - val->intval = rdo_op_current(con->rdo) * 1000;
> - else
> + if (!UCSI_CONSTAT(con, CONNECTED)) {
> val->intval = 0;
> + return 0;
> + }
> +
> + switch (UCSI_CONSTAT(con, PWR_OPMODE)) {
> + case UCSI_CONSTAT_PWR_OPMODE_PD:
> + val->intval = rdo_op_current(con->rdo) * 1000;
> + break;
> + case UCSI_CONSTAT_PWR_OPMODE_TYPEC1_5:
> + val->intval = UCSI_TYPEC_1_5_CURRENT * 1000;
> + break;
> + case UCSI_CONSTAT_PWR_OPMODE_TYPEC3_0:
> + val->intval = UCSI_TYPEC_3_0_CURRENT * 1000;
> + break;
> + case UCSI_CONSTAT_PWR_OPMODE_BC:
> + case UCSI_CONSTAT_PWR_OPMODE_DEFAULT:
> + /* UCSI can't tell b/w DCP/CDP or USB2/3x1/3x2 SDP chargers */
> + default:
> + val->intval = UCSI_TYPEC_DEFAULT_CURRENT * 1000;
> + break;
> + }
> return 0;
> }
>
> --
> 2.52.0.223.gf5cc29aaa4-goog
--
heikki
Powered by blists - more mailing lists