aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHadi Asyrafi <muhammad.hadi.asyrafi.abdul.halim@intel.com>2019-11-12 14:55:26 +0800
committerHadi Asyrafi <muhammad.hadi.asyrafi.abdul.halim@intel.com>2019-12-17 19:45:26 +0800
commit8014a53ae08ee759fd6283fc2e81034abf1d30d7 (patch)
treea175aba712c087f97b3c30bf2eff57e46f224f2b
parentcefb37eb39f1d077b55cd3f00323c8bb215cfe30 (diff)
downloadtrusted-firmware-a-8014a53ae08ee759fd6283fc2e81034abf1d30d7.tar.gz
intel: Mailbox driver logic fixes
Fix mailbox driver urgent command handling, doorbell routine, and logic optimization. Signed-off-by: Hadi Asyrafi <muhammad.hadi.asyrafi.abdul.halim@intel.com> Change-Id: If536a383f449ca2a68d60274303ec24f92411505
-rw-r--r--plat/intel/soc/common/soc/socfpga_mailbox.c35
1 files changed, 13 insertions, 22 deletions
diff --git a/plat/intel/soc/common/soc/socfpga_mailbox.c b/plat/intel/soc/common/soc/socfpga_mailbox.c
index cb3d08875c..54add7a565 100644
--- a/plat/intel/soc/common/soc/socfpga_mailbox.c
+++ b/plat/intel/soc/common/soc/socfpga_mailbox.c
@@ -6,6 +6,7 @@
#include <lib/mmio.h>
#include <common/debug.h>
+#include <drivers/delay_timer.h>
#include "socfpga_mailbox.h"
#include "socfpga_sip_svc.h"
@@ -41,21 +42,14 @@ int mailbox_read_response(int job_id, uint32_t *response)
int response_length = 0;
int resp = 0;
int total_resp_len = 0;
- int timeout = 100000;
- mmio_write_32(MBOX_OFFSET + MBOX_DOORBELL_TO_SDM, 1);
-
- while (mmio_read_32(MBOX_OFFSET + MBOX_DOORBELL_FROM_SDM) != 1) {
- if (timeout-- < 0)
- return MBOX_NO_RESPONSE;
- }
-
- mmio_write_32(MBOX_OFFSET + MBOX_DOORBELL_FROM_SDM, 0);
+ if (mmio_read_32(MBOX_OFFSET + MBOX_DOORBELL_FROM_SDM))
+ mmio_write_32(MBOX_OFFSET + MBOX_DOORBELL_FROM_SDM, 0);
rin = mmio_read_32(MBOX_OFFSET + MBOX_RIN);
rout = mmio_read_32(MBOX_OFFSET + MBOX_ROUT);
- while (rout != rin) {
+ if (rout != rin) {
resp = mmio_read_32(MBOX_OFFSET +
MBOX_RESP_BUFFER + ((rout++)*4));
@@ -96,22 +90,22 @@ int mailbox_read_response(int job_id, uint32_t *response)
int mailbox_poll_response(int job_id, int urgent, uint32_t *response)
{
- int timeout = 80000;
+ int timeout = 0xFFFFFF;
int rin = 0;
int rout = 0;
int response_length = 0;
int resp = 0;
int total_resp_len = 0;
-
while (1) {
+
while (timeout > 0 &&
- mmio_read_32(MBOX_OFFSET +
- MBOX_DOORBELL_FROM_SDM) != 1) {
+ !(mmio_read_32(MBOX_OFFSET +
+ MBOX_DOORBELL_FROM_SDM) & 1)) {
timeout--;
}
- if (mmio_read_32(MBOX_OFFSET + MBOX_DOORBELL_FROM_SDM) != 1) {
+ if (!timeout) {
INFO("Timed out waiting for SDM");
return MBOX_TIMEOUT;
}
@@ -119,6 +113,7 @@ int mailbox_poll_response(int job_id, int urgent, uint32_t *response)
mmio_write_32(MBOX_OFFSET + MBOX_DOORBELL_FROM_SDM, 0);
if (urgent & 1) {
+ mdelay(5);
if ((mmio_read_32(MBOX_OFFSET + MBOX_STATUS) &
MBOX_STATUS_UA_MASK) ^
(urgent & MBOX_STATUS_UA_MASK)) {
@@ -172,8 +167,6 @@ int mailbox_poll_response(int job_id, int urgent, uint32_t *response)
int mailbox_send_cmd_async(int job_id, unsigned int cmd, uint32_t *args,
int len, int urgent)
{
- int timeout = 100000;
-
if (urgent)
mmio_write_32(MBOX_OFFSET + MBOX_URG, 1);
@@ -185,11 +178,6 @@ int mailbox_send_cmd_async(int job_id, unsigned int cmd, uint32_t *args,
mmio_write_32(MBOX_OFFSET + MBOX_DOORBELL_TO_SDM, 1);
- while (mmio_read_32(MBOX_OFFSET + MBOX_DOORBELL_FROM_SDM) != 1) {
- if (timeout-- < 0)
- return MBOX_NO_RESPONSE;
- }
-
return 0;
}
@@ -281,6 +269,9 @@ int mailbox_init(void)
mailbox_set_int(MBOX_INT_FLAG_COE | MBOX_INT_FLAG_RIE |
MBOX_INT_FLAG_UAE);
+ mmio_write_32(MBOX_OFFSET + MBOX_URG, 0);
+ mmio_write_32(MBOX_OFFSET + MBOX_DOORBELL_FROM_SDM, 0);
+
status = mailbox_send_cmd(0, MBOX_CMD_RESTART, 0, 0, 1, 0);
if (status)