summaryrefslogtreecommitdiff
path: root/plat/amlogic
diff options
context:
space:
mode:
authorCarlo Caione <ccaione@baylibre.com>2019-09-16 12:13:49 +0100
committerCarlo Caione <ccaione@baylibre.com>2019-09-17 13:11:50 +0100
commit5cfdfc3c6200e1db3c635341e0a923a1ee9d14d8 (patch)
tree4905610ced207fe471b2599d392af07b9cbe91e6 /plat/amlogic
parent6129e9a643274e658a0e6f5428ad976676c7bb7a (diff)
amlogic: scpi: Add support to retrieve chip ID
Both kernel and U-Boot use a SMC call to the secure monitor to get the chip ID. This call is translated by BL31 to a call to the SCP to retrieve the ID. Add a new SiP call and the backing SCPI command. Signed-off-by: Carlo Caione <ccaione@baylibre.com> Change-Id: Ib128f5645ee92866e7ebbcd550dacd33f573524b
Diffstat (limited to 'plat/amlogic')
-rw-r--r--plat/amlogic/common/aml_scpi.c23
-rw-r--r--plat/amlogic/common/aml_sip_svc.c33
-rw-r--r--plat/amlogic/common/include/aml_private.h1
-rw-r--r--plat/amlogic/gxbb/gxbb_def.h1
-rw-r--r--plat/amlogic/gxl/gxl_def.h1
5 files changed, 59 insertions, 0 deletions
diff --git a/plat/amlogic/common/aml_scpi.c b/plat/amlogic/common/aml_scpi.c
index 728bcd06..c8a6772c 100644
--- a/plat/amlogic/common/aml_scpi.c
+++ b/plat/amlogic/common/aml_scpi.c
@@ -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;
diff --git a/plat/amlogic/common/aml_sip_svc.c b/plat/amlogic/common/aml_sip_svc.c
index 8a9b070d..ab4c0156 100644
--- a/plat/amlogic/common/aml_sip_svc.c
+++ b/plat/amlogic/common/aml_sip_svc.c
@@ -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;
diff --git a/plat/amlogic/common/include/aml_private.h b/plat/amlogic/common/include/aml_private.h
index 49237456..724f382f 100644
--- a/plat/amlogic/common/include/aml_private.h
+++ b/plat/amlogic/common/include/aml_private.h
@@ -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);
diff --git a/plat/amlogic/gxbb/gxbb_def.h b/plat/amlogic/gxbb/gxbb_def.h
index 2f6d1d2a..59d9cc9a 100644
--- a/plat/amlogic/gxbb/gxbb_def.h
+++ b/plat/amlogic/gxbb/gxbb_def.h
@@ -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)
diff --git a/plat/amlogic/gxl/gxl_def.h b/plat/amlogic/gxl/gxl_def.h
index 6f49ed2b..1e1a934d 100644
--- a/plat/amlogic/gxl/gxl_def.h
+++ b/plat/amlogic/gxl/gxl_def.h
@@ -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)