Commit cefb37eb authored by Tien Hock, Loh's avatar Tien Hock, Loh Committed by Hadi Asyrafi
Browse files

plat: intel: Fix FPGA manager on reconfiguration


Fixes the SiP Service driver that is responsible for FPGA
reconfiguration. Also change the base address of FPGA reconfiguration
to 0x400000.
Signed-off-by: default avatarTien Hock, Loh <tien.hock.loh@intel.com>
Change-Id: I2b84c12c85cd5fc235247131fec4916ed2fb56c8
Showing with 32 additions and 20 deletions
+32 -20
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#define INTEL_SIP_SMC_RSU_RETRY_COUNTER 0xC200000F #define INTEL_SIP_SMC_RSU_RETRY_COUNTER 0xC200000F
/* FPGA config helpers */ /* FPGA config helpers */
#define INTEL_SIP_SMC_FPGA_CONFIG_ADDR 0x1000 #define INTEL_SIP_SMC_FPGA_CONFIG_ADDR 0x400000
#define INTEL_SIP_SMC_FPGA_CONFIG_SIZE 16777216 #define INTEL_SIP_SMC_FPGA_CONFIG_SIZE 16777216
/* SMC function IDs for SiP Service queries */ /* SMC function IDs for SiP Service queries */
......
...@@ -18,13 +18,14 @@ ...@@ -18,13 +18,14 @@
/* Total buffer the driver can hold */ /* Total buffer the driver can hold */
#define FPGA_CONFIG_BUFFER_SIZE 4 #define FPGA_CONFIG_BUFFER_SIZE 4
int current_block; static int current_block;
int current_buffer; static int read_block;
int current_id = 1; static int current_buffer;
int max_blocks; static int send_id;
uint32_t bytes_per_block; static int rcv_id;
uint32_t blocks_submitted; static int max_blocks;
uint32_t blocks_completed; static uint32_t bytes_per_block;
static uint32_t blocks_submitted;
struct fpga_config_info { struct fpga_config_info {
uint32_t addr; uint32_t addr;
...@@ -68,7 +69,8 @@ static void intel_fpga_sdm_write_buffer(struct fpga_config_info *buffer) ...@@ -68,7 +69,8 @@ static void intel_fpga_sdm_write_buffer(struct fpga_config_info *buffer)
buffer->size_written += buffer->size_written +=
buffer->size - buffer->size_written; buffer->size - buffer->size_written;
buffer->subblocks_sent++; buffer->subblocks_sent++;
mailbox_send_cmd_async(0x4, mailbox_send_cmd_async(
send_id++ % MBOX_MAX_JOB_ID,
MBOX_RECONFIG_DATA, MBOX_RECONFIG_DATA,
args, 3, 0); args, 3, 0);
current_buffer++; current_buffer++;
...@@ -78,7 +80,8 @@ static void intel_fpga_sdm_write_buffer(struct fpga_config_info *buffer) ...@@ -78,7 +80,8 @@ static void intel_fpga_sdm_write_buffer(struct fpga_config_info *buffer)
args[1] = buffer->addr + buffer->size_written; args[1] = buffer->addr + buffer->size_written;
args[2] = bytes_per_block; args[2] = bytes_per_block;
buffer->size_written += bytes_per_block; buffer->size_written += bytes_per_block;
mailbox_send_cmd_async(0x4, mailbox_send_cmd_async(
send_id++ % MBOX_MAX_JOB_ID,
MBOX_RECONFIG_DATA, MBOX_RECONFIG_DATA,
args, 3, 0); args, 3, 0);
buffer->subblocks_sent++; buffer->subblocks_sent++;
...@@ -134,6 +137,8 @@ unsigned int address_in_ddr(uint32_t *addr) ...@@ -134,6 +137,8 @@ unsigned int address_in_ddr(uint32_t *addr)
return -1; return -1;
} }
int mailbox_poll_response(int job_id, int urgent, uint32_t *response);
int intel_fpga_config_completed_write(uint32_t *completed_addr, int intel_fpga_config_completed_write(uint32_t *completed_addr,
uint32_t *count) uint32_t *count)
{ {
...@@ -142,30 +147,29 @@ int intel_fpga_config_completed_write(uint32_t *completed_addr, ...@@ -142,30 +147,29 @@ int intel_fpga_config_completed_write(uint32_t *completed_addr,
int resp_len = 0; int resp_len = 0;
uint32_t resp[5]; uint32_t resp[5];
int all_completed = 1; int all_completed = 1;
int count_check = 0;
if (address_in_ddr(completed_addr) != 0 || address_in_ddr(count) != 0) while (*count < 3) {
return INTEL_SIP_SMC_STATUS_ERROR;
for (count_check = 0; count_check < 3; count_check++) resp_len = mailbox_read_response(
if (address_in_ddr(&completed_addr[*count + count_check]) != 0) rcv_id % MBOX_MAX_JOB_ID, resp);
return INTEL_SIP_SMC_STATUS_ERROR;
resp_len = mailbox_read_response(0x4, resp); if (resp_len < 0)
break;
while (resp_len >= 0 && *count < 3) {
max_blocks++; max_blocks++;
rcv_id++;
if (mark_last_buffer_xfer_completed( if (mark_last_buffer_xfer_completed(
&completed_addr[*count]) == 0) &completed_addr[*count]) == 0)
*count = *count + 1; *count = *count + 1;
else else
break; break;
resp_len = mailbox_read_response(0x4, resp);
} }
if (*count <= 0) { if (*count <= 0) {
if (resp_len != MBOX_NO_RESPONSE && if (resp_len != MBOX_NO_RESPONSE &&
resp_len != MBOX_TIMEOUT && resp_len != 0) { resp_len != MBOX_TIMEOUT && resp_len != 0) {
mailbox_clear_response();
return INTEL_SIP_SMC_STATUS_ERROR; return INTEL_SIP_SMC_STATUS_ERROR;
} }
...@@ -197,7 +201,11 @@ int intel_fpga_config_start(uint32_t config_type) ...@@ -197,7 +201,11 @@ int intel_fpga_config_start(uint32_t config_type)
uint32_t response[3]; uint32_t response[3];
int status = 0; int status = 0;
status = mailbox_send_cmd(2, MBOX_RECONFIG, 0, 0, 0, mailbox_clear_response();
mailbox_send_cmd(1, MBOX_CMD_CANCEL, 0, 0, 0, response);
status = mailbox_send_cmd(1, MBOX_RECONFIG, 0, 0, 0,
response); response);
if (status < 0) if (status < 0)
...@@ -217,7 +225,10 @@ int intel_fpga_config_start(uint32_t config_type) ...@@ -217,7 +225,10 @@ int intel_fpga_config_start(uint32_t config_type)
blocks_submitted = 0; blocks_submitted = 0;
current_block = 0; current_block = 0;
read_block = 0;
current_buffer = 0; current_buffer = 0;
send_id = 0;
rcv_id = 0;
return 0; return 0;
} }
...@@ -323,6 +334,7 @@ uintptr_t sip_smc_handler(uint32_t smc_fid, ...@@ -323,6 +334,7 @@ uintptr_t sip_smc_handler(uint32_t smc_fid,
SMC_RET4(handle, status, 0, 0, 0); SMC_RET4(handle, status, 0, 0, 0);
break; break;
default: default:
mailbox_clear_response();
SMC_RET1(handle, INTEL_SIP_SMC_STATUS_ERROR); SMC_RET1(handle, INTEL_SIP_SMC_STATUS_ERROR);
} }
break; break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment