Re: [PATCH v2 3/5] usb: typec: tcpm: Add support for Battery Status response message
From: Sebastian Reichel
Date: Mon Jun 23 2025 - 17:28:21 EST
Hi,
On Wed, May 07, 2025 at 06:00:24PM -0700, Amit Sunil Dhamne via B4 Relay wrote:
> From: Amit Sunil Dhamne <amitsd@xxxxxxxxxx>
>
> Add support for responding to Get_Battery_Status (extended) request with
> a Battery_Status (data) msg. The requester shall request the status of
> an individual battery by providing an index in Get_Battery_Status. In
> case of failure to identify battery, the responder shall reply with an
> appropriate message indicating so.
>
> Battery status support is only provided for fixed batteries indexed from
> 0 - 3.
>
> Support for Battery_Status message is required for sinks that contain
> battery as specified in USB PD Rev3.1 v1.8
> ("Applicability of Data Messages" section).
>
> Signed-off-by: Amit Sunil Dhamne <amitsd@xxxxxxxxxx>
> Reviewed-by: Badhri Jagan Sridharan <badhri@xxxxxxxxxx>
> Reviewed-by: Kyle Tso <kyletso@xxxxxxxxxx>
> ---
(partial review)
> +static int tcpm_pd_send_batt_status(struct tcpm_port *port)
> +{
> + struct pd_message msg;
> + struct power_supply *batt;
> + u32 bsdo;
> + u32 batt_id = port->batt_request;
> + union power_supply_propval val;
> + int ret;
> + bool batt_present = false;
> + u8 charging_status = BSDO_BATTERY_INFO_RSVD;
> + u16 present_charge = BATTERY_PROPERTY_UNKNOWN;
> +
> + memset(&msg, 0, sizeof(msg));
> + if (batt_id < MAX_NUM_FIXED_BATT && port->fixed_batt[batt_id]) {
> + batt_present = true;
power_supply_get_property(batt, POWER_SUPPLY_PROP_PRESENT, &batt_present);
> ...
Greetings,
-- Sebastian
Attachment:
signature.asc
Description: PGP signature