Commit 6a7cbfd5 authored by Sandrine Bailleux's avatar Sandrine Bailleux Committed by TrustedFirmware Code Review
Browse files

Merge "amlogic: scpi: Add support to retrieve chip ID" into integration

parents 3ea2cc00 5cfdfc3c
......@@ -25,6 +25,7 @@
#define SCPI_CMD_JTAG_SET_STATE 0xC0
#define SCPI_CMD_EFUSE_READ 0xC2
#define SCPI_CMD_CHIP_ID 0xC6
#define SCPI_CMD_COPY_FW 0xd4
#define SCPI_CMD_SET_FW_ADDR 0xd3
......@@ -142,6 +143,28 @@ void aml_scpi_unknown_thermal(uint32_t arg0, uint32_t arg1,
aml_mhu_secure_message_end();
}
uint32_t aml_scpi_get_chip_id(uint8_t *obuff, uint32_t osize)
{
uint32_t *response;
size_t resp_size;
if ((osize != 16) && (osize != 12))
return 0;
aml_mhu_secure_message_start();
aml_mhu_secure_message_send(aml_scpi_cmd(SCPI_CMD_CHIP_ID, osize));
aml_scpi_secure_message_receive((void *)&response, &resp_size);
aml_mhu_secure_message_end();
if (!((resp_size == 16) && (osize == 16)) &&
!((resp_size == 0) && (osize == 12)))
return 0;
memcpy((void *)obuff, (const void *)response, osize);
return osize;
}
static inline void aml_scpi_copy_scp_data(uint8_t *data, size_t len)
{
void *dst = (void *)AML_MHU_SECURE_AP_TO_SCP_PAYLOAD;
......
......@@ -9,9 +9,39 @@
#include <lib/mmio.h>
#include <platform_def.h>
#include <stdint.h>
#include <string.h>
#include "aml_private.h"
struct aml_cpu_info {
uint32_t version;
uint8_t chip_id[16];
};
static int aml_sip_get_chip_id(uint64_t version)
{
struct aml_cpu_info *info = (void *)AML_SHARE_MEM_OUTPUT_BASE;
uint32_t size;
if (version > 2)
return -1;
memset(info, 0, sizeof(struct aml_cpu_info));
if (version == 2) {
info->version = 2;
size = 16;
} else {
info->version = 1;
size = 12;
}
if (aml_scpi_get_chip_id(info->chip_id, size) == 0)
return -1;
return 0;
}
/*******************************************************************************
* This function is responsible for handling all SiP calls
******************************************************************************/
......@@ -47,6 +77,9 @@ static uintptr_t aml_sip_handler(uint32_t smc_fid,
aml_scpi_jtag_set_state(AML_JTAG_STATE_OFF, x1);
SMC_RET1(handle, 0);
case AML_SM_GET_CHIP_ID:
SMC_RET1(handle, aml_sip_get_chip_id(x1));
default:
ERROR("BL31: Unhandled SIP SMC: 0x%08x\n", smc_fid);
break;
......
......@@ -31,6 +31,7 @@ uint32_t aml_scpi_efuse_read(void *dst, uint32_t base, uint32_t size);
void aml_scpi_unknown_thermal(uint32_t arg0, uint32_t arg1,
uint32_t arg2, uint32_t arg3);
void aml_scpi_upload_scp_fw(uintptr_t addr, size_t size, int send);
uint32_t aml_scpi_get_chip_id(uint8_t *obuff, uint32_t osize);
/* Peripherals */
void aml_thermal_unknown(void);
......
......@@ -106,6 +106,7 @@
#define AML_SM_JTAG_ON U(0x82000040)
#define AML_SM_JTAG_OFF U(0x82000041)
#define AML_SM_GET_CHIP_ID U(0x82000044)
#define AML_JTAG_STATE_ON U(0)
#define AML_JTAG_STATE_OFF U(1)
......
......@@ -116,6 +116,7 @@
#define AML_SM_JTAG_ON U(0x82000040)
#define AML_SM_JTAG_OFF U(0x82000041)
#define AML_SM_GET_CHIP_ID U(0x82000044)
#define AML_JTAG_STATE_ON U(0)
#define AML_JTAG_STATE_OFF U(1)
......
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