plat/arm/sgi: Use platform specific functions to get platform ids

Add two new functions 'plat_arm_sgi_get_platform_id' and
'plat_arm_sgi_get_config_id' which will be implemented by all the
SGI platforms. These functions can be used to determine the part
number and configuration id of the SGI platforms.

In BL2, these functions are used to populate the 'system-id' node.
In BL31, these functions are used to populate the 'sgi_plat_info_t'
structure with the part number and configuration id of the platform.

Change-Id: I3bacda933527724a3b4074ad4ed5b53a81ea4689
Signed-off-by: Chandni Cherukuri <chandni.cherukuri@arm.com>
diff --git a/plat/arm/css/sgi/sgi_image_load.c b/plat/arm/css/sgi/sgi_image_load.c
index d97583e..39069ca 100644
--- a/plat/arm/css/sgi/sgi_image_load.c
+++ b/plat/arm/css/sgi/sgi_image_load.c
@@ -9,6 +9,7 @@
 #include <desc_image_load.h>
 #include <libfdt.h>
 #include <platform.h>
+#include <sgi_variant.h>
 
 /*******************************************************************************
  * This function inserts Platform information via device tree nodes as,
@@ -23,7 +24,6 @@
 	void *fdt;
 	int nodeoffset, err;
 	unsigned int platid = 0, platcfg = 0;
-	char *platform_name;
 
 	mem_params = get_bl_mem_params_node(HW_CONFIG_ID);
 	if (mem_params == NULL) {
@@ -39,38 +39,20 @@
 		return -1;
 	}
 
-	platform_name = (char *)fdt_getprop(fdt, 0, "compatible", NULL);
-
-	if (platform_name == NULL) {
-		ERROR("Invalid HW_CONFIG DTB passed\n");
-		return -1;
-	}
-
-	if (strcmp(platform_name, "arm,sgi575") == 0) {
-		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;
-	}
-
 	nodeoffset = fdt_subnode_offset(fdt, 0, "system-id");
 	if (nodeoffset < 0) {
 		ERROR("Failed to get system-id node offset\n");
 		return -1;
 	}
 
+	platid = plat_arm_sgi_get_platform_id();
 	err = fdt_setprop_u32(fdt, nodeoffset, "platform-id", platid);
 	if (err < 0) {
 		ERROR("Failed to set platform-id\n");
 		return -1;
 	}
 
+	platcfg = plat_arm_sgi_get_config_id();
 	err = fdt_setprop_u32(fdt, nodeoffset, "config-id", platcfg);
 	if (err < 0) {
 		ERROR("Failed to set config-id\n");