plat/arm/sgi: add support for SGI-Clark platform
authorChandni Cherukuri <chandni.cherukuri@arm.com>
Thu, 4 Oct 2018 11:02:03 +0000 (16:32 +0530)
committerChandni Cherukuri <chandni.cherukuri@arm.com>
Fri, 26 Oct 2018 06:46:17 +0000 (12:16 +0530)
SGI-Clark platform is the next version in the Arm's SGI platform
series. One of the primary difference between the SGI-575 platform and
the SGI-Clark platform is the MHU version (MHUv2 in case of SGI-Clark).
Add the required base support for SGI-Clark platform.

Change-Id: If396e5279fdf801d586662dad0b55195e81371e4
Signed-off-by: Chandni Cherukuri <chandni.cherukuri@arm.com>
plat/arm/css/sgi/include/sgi_variant.h
plat/arm/css/sgi/sgi_bl31_setup.c
plat/arm/css/sgi/sgi_image_load.c

index 5698d0abd90376fcff6db13c55229bb4088c3e17..dea580be27dd1768f7cb77af56f112e73f0776a0 100644 (file)
@@ -4,10 +4,21 @@
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
-#ifndef __SGI_VARIANT_H__
-#define __SGI_VARIANT_H__
+#ifndef SGI_VARIANT_H
+#define SGI_VARIANT_H
 
 /* SSC_VERSION values for SGI575 */
 #define SGI575_SSC_VER_PART_NUM                0x0783
 
-#endif /* __SGI_VARIANT_H__ */
+/* SID Version values for SGI-Clark */
+#define SGI_CLARK_SID_VER_PART_NUM             0x0786
+
+/* Structure containing SGI platform variant information */
+typedef struct sgi_platform_info {
+       unsigned int platform_id;       /* Part Number of the platform */
+       unsigned int config_id;         /* Config Id of the platform */
+} sgi_platform_info_t;
+
+extern sgi_platform_info_t sgi_plat_info;
+
+#endif /* SGI_VARIANT_H */
index a16343cf0b653319a95eb5ed85409e89ca420212..ce850269952bf74240b4b87660d4a283049b8268 100644 (file)
@@ -4,13 +4,18 @@
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
+#include <assert.h>
 #include <bl_common.h>
 #include <debug.h>
+#include <libfdt.h>
 #include <plat_arm.h>
 #include <sgi_ras.h>
+#include <sgi_variant.h>
 #include "../../css/drivers/scmi/scmi.h"
 #include "../../css/drivers/mhu/css_mhu_doorbell.h"
 
+sgi_platform_info_t sgi_plat_info;
+
 static scmi_channel_plat_info_t sgi575_scmi_plat_info = {
                .scmi_mbx_mem = CSS_SCMI_PAYLOAD_BASE,
                .db_reg_addr = PLAT_CSS_MHU_BASE + CSS_SCMI_MHU_DB_REG_OFF,
@@ -19,14 +24,72 @@ static scmi_channel_plat_info_t sgi575_scmi_plat_info = {
                .ring_doorbell = &mhu_ring_doorbell,
 };
 
+static scmi_channel_plat_info_t sgi_clark_scmi_plat_info = {
+               .scmi_mbx_mem = CSS_SCMI_PAYLOAD_BASE,
+               .db_reg_addr = PLAT_CSS_MHU_BASE + SENDER_REG_SET(0),
+               .db_preserve_mask = 0xfffffffe,
+               .db_modify_mask = 0x1,
+               .ring_doorbell = &mhuv2_ring_doorbell,
+};
+
 scmi_channel_plat_info_t *plat_css_get_scmi_info()
 {
-       return &sgi575_scmi_plat_info;
+       if (sgi_plat_info.platform_id == SGI_CLARK_SID_VER_PART_NUM)
+               return &sgi_clark_scmi_plat_info;
+       else if (sgi_plat_info.platform_id == SGI575_SSC_VER_PART_NUM)
+               return &sgi575_scmi_plat_info;
+       else
+               panic();
+};
+
+/*******************************************************************************
+ * This function sets the sgi_platform_id and sgi_config_id
+ ******************************************************************************/
+int sgi_identify_platform(unsigned long hw_config)
+{
+       void *fdt;
+       int nodeoffset;
+       const unsigned int *property;
+
+       fdt = (void *)hw_config;
+
+       /* Check the validity of the fdt */
+       assert(fdt_check_header(fdt) == 0);
+
+       nodeoffset = fdt_subnode_offset(fdt, 0, "system-id");
+       if (nodeoffset < 0) {
+               ERROR("Failed to get system-id node offset\n");
+               return -1;
+       }
+
+       property = fdt_getprop(fdt, nodeoffset, "platform-id", NULL);
+       if (property == NULL) {
+               ERROR("Failed to get platform-id property\n");
+               return -1;
+       }
+
+       sgi_plat_info.platform_id = fdt32_to_cpu(*property);
+
+       property = fdt_getprop(fdt, nodeoffset, "config-id", NULL);
+       if (property == NULL) {
+               ERROR("Failed to get config-id property\n");
+               return -1;
+       }
+
+       sgi_plat_info.config_id = fdt32_to_cpu(*property);
+
+       return 0;
 }
 
 void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
                                u_register_t arg2, u_register_t arg3)
 {
+       int ret;
+
+       ret = sgi_identify_platform(arg2);
+       if (ret == -1)
+               panic();
+
        arm_bl31_early_platform_setup((void *)arg0, arg1, arg2, (void *)arg3);
 }
 
index 52dcf889e07607a79baf1227567c69cbf9ad2cc2..d97583ef9fa7e3a01aeb39090f0631985e0395db 100644 (file)
@@ -50,6 +50,10 @@ static int plat_sgi_append_config_node(void)
                platid = mmio_read_32(SSC_VERSION) & SSC_VERSION_PART_NUM_MASK;
                platcfg = (mmio_read_32(SSC_VERSION) >> SSC_VERSION_CONFIG_SHIFT)
                                & SSC_VERSION_CONFIG_MASK;
+       } else if (strcmp(platform_name, "arm,sgi-clark") == 0) {
+               platid = mmio_read_32(SID_REG_BASE + SID_SYSTEM_ID_OFFSET)
+                               & SID_SYSTEM_ID_PART_NUM_MASK;
+               platcfg = mmio_read_32(SID_REG_BASE + SID_SYSTEM_CFG_OFFSET);
        } else {
                WARN("Invalid platform\n");
                return -1;