Re: [PATCH v9 3/4] firmware: ti_sci: Introduce Power Management Ops

Kevin Hilman
2024-08-12T21:16:47Z

Dhruva Gole <d-gole@ti.com> writes:

> On Aug 09, 2024 at 15:53:46 +0200, Markus Schneider-Pargmann wrote:
>> From: Dave Gerlach <d-gerlach@ti.com>
>>
>> Introduce power management ops supported by the TISCI
>> Low Power Mode API [1].
>>
>> 1) TISCI_MSG_LPM_WAKE_REASON
>> Get which wake up source woke the SoC from Low Power Mode.
>> The wake up source IDs will be common for all K3 platforms.
>>
>> 2) TISCI_MSG_LPM_SET_DEVICE_CONSTRAINT
>> Set LPM constraint on behalf of a device. By setting a constraint, the
>> device ensures that it will not be powered off or reset in the selected
>> mode.
>>
>> 3) TISCI_MSG_LPM_SET_LATENCY_CONSTRAINT
>> Set LPM resume latency constraint. By setting a constraint, the host
>> ensures that the resume time from selected mode will be less than the
>> constraint value.
>>
>> [1] https://software-dl.ti.com/tisci/esd/latest/2_tisci_msgs/pm/lpm.html
>>
>> Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
>> [g-vlaev@ti.com: LPM_WAKE_REASON and IO_ISOLATION support]
>> Signed-off-by: Georgi Vlaev <g-vlaev@ti.com>
>> [a-kaur@ti.com: SET_DEVICE_CONSTRAINT support]
>> Signed-off-by: Akashdeep Kaur <a-kaur@ti.com>
>> [vibhore@ti.com: SET_LATENCY_CONSTRAINT support]
>> Signed-off-by: Vibhore Vardhan <vibhore@ti.com>
>> Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
>> ---
> [...]
>> diff --git a/drivers/firmware/ti_sci.h b/drivers/firmware/ti_sci.h
>> index 8efe4d0e61fb..9dd40b6711d4 100644
>> --- a/drivers/firmware/ti_sci.h
>> +++ b/drivers/firmware/ti_sci.h
>> @@ -38,7 +38,10 @@
>>
>> /* Low Power Mode Requests */
>> #define TI_SCI_MSG_PREPARE_SLEEP 0x0300
>> +#define TI_SCI_MSG_LPM_WAKE_REASON 0x0306
>> #define TI_SCI_MSG_SET_IO_ISOLATION 0x0307
>> +#define TI_SCI_MSG_LPM_SET_DEVICE_CONSTRAINT 0x0309
>> +#define TI_SCI_MSG_LPM_SET_LATENCY_CONSTRAINT 0x030A
>>
>> /* Resource Management Requests */
>> #define TI_SCI_MSG_GET_RESOURCE_RANGE 0x1500
>> @@ -610,6 +613,73 @@ struct ti_sci_msg_req_set_io_isolation {
>> u8 state;
>> } __packed;
>>
>> +/**
>> + * struct ti_sci_msg_resp_lpm_wake_reason - Response for TI_SCI_MSG_LPM_WAKE_REASON.
>> + *
>> + * @hdr: Generic header.
>> + * @wake_source: The wake up source that woke soc from LPM.
>> + * @wake_timestamp: Timestamp at which soc woke.
>> + *
>> + * Response to a generic message with message type TI_SCI_MSG_LPM_WAKE_REASON,
>> + * used to query the wake up source from low power mode.
>> + */
>> +struct ti_sci_msg_resp_lpm_wake_reason {
>> + struct ti_sci_msg_hdr hdr;
>> + u32 wake_source;
>> + u64 wake_timestamp;
>> +} __packed;
>> +
>
> It looks like we forgot to update the parameters in this API.
> See [1]:
>
> struct tisci_msg_lpm_wake_reason_req
>
> We're missing here the wake_pin, mode and 2 rsvd fields as well.
>
> [1] https://software-dl.ti.com/tisci/esd/latest/2_tisci_msgs/pm/lpm.html#tisci-msg-lpm-wake-reason
>

The docs mention how to interpret the pin, but not the mode. This
driver should translate this mode number to some human-readable state
for better debug messages.

Kevin