ti: k3: drivers: ti_sci: Use non-blocking TI-SCI messages for power down

Now that we have non-blocking TI-SCI functions we can initiate the shutdown
sequence from the PSCI handler without needing the ti_sci_proc_shutdown
helper function, which is removed. This gives us the greater control and
flexibility that will be needed when cluster power down sequences are added.

Signed-off-by: Andrew F. Davis <afd@ti.com>
This commit is contained in:
Andrew F. Davis 2019-02-11 14:37:58 -06:00
parent e9152c13c5
commit a9ae424ed5
3 changed files with 18 additions and 85 deletions

View File

@ -1680,88 +1680,6 @@ int ti_sci_proc_wait_boot_status_no_wait(uint8_t proc_id,
return 0;
}
/**
* ti_sci_proc_shutdown() - Shutdown Processor without waiting for ACKs
*
* @proc_id: Processor ID this request is for
* @dev_id: Device identifier this request is for
*
* Return: 0 if all goes well, else appropriate error message
*/
int ti_sci_proc_shutdown(uint8_t proc_id, uint32_t dev_id)
{
struct ti_sci_msg_req_wait_proc_boot_status wait_req;
struct ti_sci_msg_req_set_device_state set_req;
/*
* We will not be waiting for this response, but declare one anyway
* to pass to the setup function so the checks will still pass
*/
struct ti_sci_msg_hdr resp;
struct ti_sci_xfer xfer;
int ret;
/* Start by sending wait command */
/* Setup with NORESPONSE flag to keep response queue clean */
ret = ti_sci_setup_one_xfer(TISCI_MSG_WAIT_PROC_BOOT_STATUS,
TI_SCI_FLAG_REQ_GENERIC_NORESPONSE,
&wait_req, sizeof(wait_req),
&resp, sizeof(resp),
&xfer);
if (ret) {
ERROR("Message alloc failed (%d)\n", ret);
return ret;
}
wait_req.processor_id = proc_id;
/*
* Wait maximum time to give us the best chance to get
* to WFI before this command timeouts
*/
wait_req.delay_before_iterations_us = UINT8_MAX;
wait_req.num_wait_iterations = UINT8_MAX;
wait_req.delay_per_iteration_us = UINT8_MAX; /* TODO: optimize time */
wait_req.num_match_iterations = 2;
wait_req.status_flags_1_set_all_wait = 0;
/* Wait for either WFE or WFI */
wait_req.status_flags_1_set_any_wait = PROC_BOOT_STATUS_FLAG_ARMV8_WFE |
PROC_BOOT_STATUS_FLAG_ARMV8_WFI;
wait_req.status_flags_1_clr_all_wait = 0;
wait_req.status_flags_1_clr_any_wait = 0;
/* Send wait message */
ret = k3_sec_proxy_send(SP_HIGH_PRIORITY, &xfer.tx_message);
if (ret) {
ERROR("Message sending failed (%d)\n", ret);
return ret;
}
/* Now queue up the shutdown request */
ret = ti_sci_setup_one_xfer(TI_SCI_MSG_SET_DEVICE_STATE,
TI_SCI_FLAG_REQ_GENERIC_NORESPONSE,
&set_req, sizeof(set_req),
&resp, sizeof(resp),
&xfer);
if (ret) {
ERROR("Message alloc failed (%d)\n", ret);
return ret;
}
set_req.id = dev_id;
set_req.state = MSG_DEVICE_SW_STATE_AUTO_OFF;
/* Send shutdown message */
ret = k3_sec_proxy_send(SP_HIGH_PRIORITY, &xfer.tx_message);
if (ret) {
ERROR("Message sending failed (%d)\n", ret);
return ret;
}
/* Return without waiting for responses */
return 0;
}
/**
* ti_sci_init() - Basic initialization
*

View File

@ -205,7 +205,6 @@ int ti_sci_proc_wait_boot_status_no_wait(uint8_t proc_id,
uint32_t status_flags_1_set_any_wait,
uint32_t status_flags_1_clr_all_wait,
uint32_t status_flags_1_clr_any_wait);
int ti_sci_proc_shutdown(uint8_t proc_id, uint32_t dev_id);
/**
* ti_sci_init() - Basic initialization

View File

@ -13,6 +13,7 @@
#include <lib/psci/psci.h>
#include <plat/common/platform.h>
#include <ti_sci_protocol.h>
#include <k3_gicv3.h>
#include <ti_sci.h>
@ -90,9 +91,24 @@ void k3_pwr_domain_off(const psci_power_state_t *target_state)
proc = PLAT_PROC_START_ID + core_id;
device = PLAT_PROC_DEVICE_START_ID + core_id;
ret = ti_sci_proc_shutdown(proc, device);
/* Start by sending wait for WFI command */
ret = ti_sci_proc_wait_boot_status_no_wait(proc,
/*
* Wait maximum time to give us the best chance to get
* to WFI before this command timeouts
*/
UINT8_MAX, 100, UINT8_MAX, UINT8_MAX,
/* Wait for WFI */
PROC_BOOT_STATUS_FLAG_ARMV8_WFI, 0, 0, 0);
if (ret) {
ERROR("Request to stop core failed: %d\n", ret);
ERROR("Sending wait for WFI failed (%d)\n", ret);
return;
}
/* Now queue up the core shutdown request */
ret = ti_sci_device_put_no_wait(device);
if (ret) {
ERROR("Sending core shutdown message failed (%d)\n", ret);
return;
}
}