public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Mario Limonciello <mario.limonciello@amd.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Sebastian Reichel <sebastian.reichel@collabora.com>,
	linux-usb@vger.kernel.org
Subject: Re: [PATCH v2] usb: typec: ucsi: psy: Add support for the charge type property
Date: Wed, 19 Jun 2024 14:14:28 +0300	[thread overview]
Message-ID: <ZnK9lA16RRnB0qAL@kuha.fi.intel.com> (raw)
In-Reply-To: <bd44a37e-ca64-4ab0-81e9-b25d7185fe42@amd.com>

On Tue, Jun 18, 2024 at 10:01:21AM -0500, Mario Limonciello wrote:
> On 6/18/2024 03:15, Heikki Krogerus wrote:
> > Adding support for the charge type Linux power supply class
> > property (POWER_SUPPLY_PROP_CHARGE_TYPE) to the UCSI driver.
> > That will make the charge type visible in the charge_type
> > power supply class sysfs attribute file.
> > 
> > UCSI has the charge type specified in the Battery Charging
> > Status field of the response to the GET_CONNECTOR_STATUS
> > command.
> > 
> > Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> > Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> > ---
> > Changed since the last version:
> > The commit message is completely rewritten. The subject line was also changed.
> > 
> > The original patch:
> > https://lore.kernel.org/linux-usb/20240617105554.1677285-1-heikki.krogerus@linux.intel.com/
> > 
> > ---
> >   drivers/usb/typec/ucsi/psy.c  | 27 +++++++++++++++++++++++++++
> >   drivers/usb/typec/ucsi/ucsi.c |  3 +++
> >   2 files changed, 30 insertions(+)
> > 
> > diff --git a/drivers/usb/typec/ucsi/psy.c b/drivers/usb/typec/ucsi/psy.c
> > index b35c6e07911e..b3910f37e171 100644
> > --- a/drivers/usb/typec/ucsi/psy.c
> > +++ b/drivers/usb/typec/ucsi/psy.c
> > @@ -20,6 +20,7 @@ enum ucsi_psy_online_states {
> >   };
> >   static enum power_supply_property ucsi_psy_props[] = {
> > +	POWER_SUPPLY_PROP_CHARGE_TYPE,
> >   	POWER_SUPPLY_PROP_USB_TYPE,
> >   	POWER_SUPPLY_PROP_ONLINE,
> >   	POWER_SUPPLY_PROP_VOLTAGE_MIN,
> > @@ -194,6 +195,30 @@ static int ucsi_psy_get_usb_type(struct ucsi_connector *con,
> >   	return 0;
> >   }
> > +static int ucsi_psy_get_charge_type(struct ucsi_connector *con, union power_supply_propval *val)
> > +{
> > +	if (!(con->status.flags & UCSI_CONSTAT_CONNECTED) ||
> > +	    (con->status.flags & UCSI_CONSTAT_PWR_DIR) != TYPEC_SINK) {
> > +		val->intval = POWER_SUPPLY_CHARGE_TYPE_NONE;
> 
> The not connected state obviously makes sense for
> POWER_SUPPLY_CHARGE_TYPE_NONE, but what exactly is the other situation? A
> UCSI state machine failure?
> 
> I'm mostly wondering if POWER_SUPPLY_CHARGE_TYPE_UNKNOWN makes sense for
> that or not.

That works for me. I'll change it to POWER_SUPPLY_CHARGE_TYPE_UNKNOWN
in that case.

> Besides this question the patch looks fine to me and you can add my tag with
> your decision.
> 
> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>

thanks,

-- 
heikki

      reply	other threads:[~2024-06-19 11:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-18  8:15 [PATCH v2] usb: typec: ucsi: psy: Add support for the charge type property Heikki Krogerus
2024-06-18 15:01 ` Mario Limonciello
2024-06-19 11:14   ` Heikki Krogerus [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZnK9lA16RRnB0qAL@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mario.limonciello@amd.com \
    --cc=sebastian.reichel@collabora.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox