feat(ti): add enter sleep method
This TISCI API must be used to trigger entry into system suspend, and this is done through the use of TI_SCI_MSG_ENTER_SLEEP. Introduce a method to send this message. Change-Id: Id7af5fb2a34623ad69e76764f389ff4d8d259fba Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
This commit is contained in:
parent
19a9cc3a1b
commit
cf5868b8cd
|
@ -2,7 +2,7 @@
|
||||||
* Texas Instruments System Control Interface Driver
|
* Texas Instruments System Control Interface Driver
|
||||||
* Based on Linux and U-Boot implementation
|
* Based on Linux and U-Boot implementation
|
||||||
*
|
*
|
||||||
* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
|
* Copyright (C) 2018-2022 Texas Instruments Incorporated - https://www.ti.com/
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -1663,6 +1663,57 @@ int ti_sci_proc_wait_boot_status_no_wait(uint8_t proc_id,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ti_sci_enter_sleep - Command to initiate system transition into suspend.
|
||||||
|
*
|
||||||
|
* @proc_id: Processor ID.
|
||||||
|
* @mode: Low power mode to enter.
|
||||||
|
* @core_resume_addr: Address that core should be
|
||||||
|
* resumed from after low power transition.
|
||||||
|
*
|
||||||
|
* Return: 0 if all goes well, else appropriate error message
|
||||||
|
*/
|
||||||
|
int ti_sci_enter_sleep(uint8_t proc_id,
|
||||||
|
uint8_t mode,
|
||||||
|
uint64_t core_resume_addr)
|
||||||
|
{
|
||||||
|
struct ti_sci_msg_req_enter_sleep req;
|
||||||
|
struct ti_sci_msg_hdr *hdr;
|
||||||
|
struct k3_sec_proxy_msg tx_message;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/* Ensure we have sane transfer size */
|
||||||
|
if (sizeof(req) > TI_SCI_MAX_MESSAGE_SIZE) {
|
||||||
|
return -ERANGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
hdr = (struct ti_sci_msg_hdr *)&req;
|
||||||
|
hdr->seq = ++message_sequence;
|
||||||
|
hdr->type = TI_SCI_MSG_ENTER_SLEEP;
|
||||||
|
hdr->host = TI_SCI_HOST_ID;
|
||||||
|
/* Setup with NORESPONSE flag to keep response queue clean */
|
||||||
|
hdr->flags = TI_SCI_FLAG_REQ_GENERIC_NORESPONSE;
|
||||||
|
|
||||||
|
req.processor_id = proc_id;
|
||||||
|
req.mode = mode;
|
||||||
|
req.core_resume_lo = core_resume_addr & TISCI_ADDR_LOW_MASK;
|
||||||
|
req.core_resume_hi = (core_resume_addr & TISCI_ADDR_HIGH_MASK) >>
|
||||||
|
TISCI_ADDR_HIGH_SHIFT;
|
||||||
|
|
||||||
|
tx_message.buf = (uint8_t *)&req;
|
||||||
|
tx_message.len = sizeof(req);
|
||||||
|
|
||||||
|
/* Send message */
|
||||||
|
ret = k3_sec_proxy_send(SP_HIGH_PRIORITY, &tx_message);
|
||||||
|
if (ret != 0) {
|
||||||
|
ERROR("Message sending failed (%d)\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return without waiting for response */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ti_sci_init() - Basic initialization
|
* ti_sci_init() - Basic initialization
|
||||||
*
|
*
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* Texas Instruments System Control Interface API
|
* Texas Instruments System Control Interface API
|
||||||
* Based on Linux and U-Boot implementation
|
* Based on Linux and U-Boot implementation
|
||||||
*
|
*
|
||||||
* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
|
* Copyright (C) 2018-2022 Texas Instruments Incorporated - https://www.ti.com/
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -206,6 +206,22 @@ int ti_sci_proc_wait_boot_status_no_wait(uint8_t proc_id,
|
||||||
uint32_t status_flags_1_clr_all_wait,
|
uint32_t status_flags_1_clr_all_wait,
|
||||||
uint32_t status_flags_1_clr_any_wait);
|
uint32_t status_flags_1_clr_any_wait);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* System Low Power Operations
|
||||||
|
*
|
||||||
|
* - ti_sci_enter_sleep - Command to initiate system transition into suspend.
|
||||||
|
* @proc_id: Processor ID.
|
||||||
|
* @mode: Low power mode to enter.
|
||||||
|
* @core_resume_addr: Address that core should be resumed from
|
||||||
|
* after low power transition.
|
||||||
|
*
|
||||||
|
* NOTE: for all these functions, the following are generic in nature:
|
||||||
|
* Returns 0 for successful request, else returns corresponding error message.
|
||||||
|
*/
|
||||||
|
int ti_sci_enter_sleep(uint8_t proc_id,
|
||||||
|
uint8_t mode,
|
||||||
|
uint64_t core_resume_addr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ti_sci_init() - Basic initialization
|
* ti_sci_init() - Basic initialization
|
||||||
*
|
*
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* The system works in a message response protocol
|
* The system works in a message response protocol
|
||||||
* See: http://processors.wiki.ti.com/index.php/TISCI for details
|
* See: http://processors.wiki.ti.com/index.php/TISCI for details
|
||||||
*
|
*
|
||||||
* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
|
* Copyright (C) 2018-2022 Texas Instruments Incorporated - https://www.ti.com/
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -28,6 +28,9 @@
|
||||||
#define TI_SCI_MSG_GET_DEVICE_STATE 0x0201
|
#define TI_SCI_MSG_GET_DEVICE_STATE 0x0201
|
||||||
#define TI_SCI_MSG_SET_DEVICE_RESETS 0x0202
|
#define TI_SCI_MSG_SET_DEVICE_RESETS 0x0202
|
||||||
|
|
||||||
|
/* Low Power Mode Requests */
|
||||||
|
#define TI_SCI_MSG_ENTER_SLEEP 0x0301
|
||||||
|
|
||||||
/* Clock requests */
|
/* Clock requests */
|
||||||
#define TI_SCI_MSG_SET_CLOCK_STATE 0x0100
|
#define TI_SCI_MSG_SET_CLOCK_STATE 0x0100
|
||||||
#define TI_SCI_MSG_GET_CLOCK_STATE 0x0101
|
#define TI_SCI_MSG_GET_CLOCK_STATE 0x0101
|
||||||
|
@ -706,4 +709,26 @@ struct ti_sci_msg_req_wait_proc_boot_status {
|
||||||
uint32_t status_flags_1_clr_any_wait;
|
uint32_t status_flags_1_clr_any_wait;
|
||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* struct ti_sci_msg_req_enter_sleep - Request for TI_SCI_MSG_ENTER_SLEEP.
|
||||||
|
*
|
||||||
|
* @hdr Generic Header
|
||||||
|
* @mode Low power mode to enter.
|
||||||
|
* @proc_id Processor id to be restored.
|
||||||
|
* @core_resume_lo Low 32-bits of physical pointer to address for core
|
||||||
|
* to begin execution upon resume.
|
||||||
|
* @core_resume_hi High 32-bits of physical pointer to address for core
|
||||||
|
* to begin execution upon resume.
|
||||||
|
*
|
||||||
|
* This message is to be sent after TI_SCI_MSG_PREPARE_SLEEP is sent from OS
|
||||||
|
* and is what actually triggers entry into the specified low power mode.
|
||||||
|
*/
|
||||||
|
struct ti_sci_msg_req_enter_sleep {
|
||||||
|
struct ti_sci_msg_hdr hdr;
|
||||||
|
uint8_t mode;
|
||||||
|
uint8_t processor_id;
|
||||||
|
uint32_t core_resume_lo;
|
||||||
|
uint32_t core_resume_hi;
|
||||||
|
} __packed;
|
||||||
|
|
||||||
#endif /* TI_SCI_PROTOCOL_H */
|
#endif /* TI_SCI_PROTOCOL_H */
|
||||||
|
|
Loading…
Reference in New Issue