mosys: use model name as customization id

With unibuild, use model name as the customization_id regardless if
that has been set in VPD or not, with the exception of reef.

BRANCH=none
BUG=b:72651867
TEST=build and verify

Change-Id: I0b8101c48bf8442110e5eef7e06dea738c32cf7c
Signed-off-by: YH Lin <yueherngl@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/899773
Reviewed-by: Jason Clinton <jclinton@chromium.org>
diff --git a/include/lib/sku.h b/include/lib/sku.h
index e817ca2..1858cab 100644
--- a/include/lib/sku.h
+++ b/include/lib/sku.h
@@ -85,7 +85,15 @@
 extern char *sku_get_chassis(struct platform_intf *intf);
 
 /**
- * sku_get_customization - get customization ID
+ * sku_get_vpd_customization - get customization ID from VPD then model
+ *
+ * returns allocated string containing value if found
+ * returns NULL to indicate value not found or error
+ */
+extern char *sku_get_vpd_customization(struct platform_intf *intf);
+
+/**
+ * sku_get_customization - get customization ID from model then VPD
  *
  * returns allocated string containing value if found
  * returns NULL to indicate value not found or error
diff --git a/lib/misc/sku.c b/lib/misc/sku.c
index 1dcecac..9128b24 100644
--- a/lib/misc/sku.c
+++ b/lib/misc/sku.c
@@ -204,22 +204,36 @@
 	return result;
 }
 
-char *sku_get_customization(struct platform_intf *intf)
+char *sku_get_vpd_customization(struct platform_intf *intf)
 {
 	const struct sku_info *info = intf->sku_info;
-	char *result = _get_vpd_value("customization_id");
+	char *customization_id;
 
-	/* Unlike other SKU values, we trust VPD than mosys table. */
-	if (result)
-		return result;
+	/* Look for VPD first before looking into model */
+	customization_id = _get_vpd_value("customization_id");
+	if (customization_id)
+		return customization_id;
 
 	if (info && info->customization)
 		return mosys_strdup(info->customization);
 
-	result = sku_get_model(intf);
-	if (result)
-		strupper(result);
-	return result;
+	return NULL;
+}
+
+char *sku_get_customization(struct platform_intf *intf)
+{
+	const struct sku_info *info = intf->sku_info;
+	char *customization_id;
+
+	/* Look for model first before looking into VPD */
+	if (info && info->customization)
+		return mosys_strdup(info->customization);
+
+	customization_id = _get_vpd_value("customization_id");
+	if (customization_id)
+		return customization_id;
+
+	return NULL;
 }
 
 /*
diff --git a/platform/platform_list.c b/platform/platform_list.c
index b911d46..2468593 100644
--- a/platform/platform_list.c
+++ b/platform/platform_list.c
@@ -41,6 +41,7 @@
 extern struct platform_intf platform_auron;
 extern struct platform_intf platform_beltino;
 extern struct platform_intf platform_butterfly;
+extern struct platform_intf platform_coral;
 extern struct platform_intf platform_cyan;
 extern struct platform_intf platform_cyclone;
 extern struct platform_intf platform_daisy;
@@ -133,6 +134,7 @@
 #endif
 #ifdef CONFIG_PLATFORM_REEF
 	&platform_reef,
+	&platform_coral,
 #endif
 #ifdef CONFIG_PLATFORM_SAMUS
 	&platform_samus,
diff --git a/platform/reef/reef.c b/platform/reef/reef.c
index 6d13c45..8b7feec 100644
--- a/platform/reef/reef.c
+++ b/platform/reef/reef.c
@@ -119,7 +119,7 @@
 	static struct sku_info sku_info;
 	int ret;
 
-	ret = cros_config_read_sku_info(intf, "Reef,Pyro,Sand,Snappy,Coral",
+	ret = cros_config_read_sku_info(intf, "Reef,Pyro,Sand,Snappy",
 					&sku_info);
 
 	/* If there was no error, indicate that we found a match */
@@ -165,6 +165,26 @@
 #endif /* CONFIG_CROS_CONFIG */
 }
 
+int coral_probe(struct platform_intf *intf)
+{
+#ifdef CONFIG_CROS_CONFIG
+	static struct sku_info sku_info;
+	int ret;
+
+	ret = cros_config_read_sku_info(intf, "Coral", &sku_info);
+
+	/* If there was no error, indicate that we found a match */
+	if (!ret) {
+		intf->sku_info = &sku_info;
+		return 1;
+	}
+
+	return ret;
+#else
+	return -1;
+#endif
+}
+
 /* late setup routine; not critical to core functionality */
 static int reef_setup_post(struct platform_intf *intf)
 {
@@ -197,6 +217,16 @@
 	.eventlog	= &reef_eventlog_cb,
 };
 
+struct platform_cb coral_cb = {
+	.ec		= &cros_ec_cb,
+	.eeprom		= &reef_eeprom_cb,
+	.memory		= &reef_memory_cb,
+	.nvram		= &reef_nvram_cb,
+	.smbios		= &smbios_sysinfo_cb,
+	.sys 		= &coral_sys_cb,
+	.eventlog	= &reef_eventlog_cb,
+};
+
 struct platform_intf platform_reef = {
 	.type		= PLATFORM_X86_64,
 	.name		= "Reef",
@@ -206,3 +236,13 @@
 	.setup_post	= &reef_setup_post,
 	.destroy	= &reef_destroy,
 };
+
+struct platform_intf platform_coral = {
+	.type		= PLATFORM_X86_64,
+	.name		= "Coral",
+	.sub		= reef_sub,
+	.cb		= &coral_cb,
+	.probe		= &coral_probe,
+	.setup_post	= &reef_setup_post,
+	.destroy	= &reef_destroy,
+};
diff --git a/platform/reef/reef.h b/platform/reef/reef.h
index dbe89f5..03d1798 100644
--- a/platform/reef/reef.h
+++ b/platform/reef/reef.h
@@ -43,6 +43,7 @@
 extern struct memory_cb reef_memory_cb;	/* memory.c */
 extern struct nvram_cb reef_nvram_cb;		/* nvram.c */
 extern struct sys_cb reef_sys_cb;		/* sys.c */
+extern struct sys_cb coral_sys_cb;		/* sys.c */
 
 /* functions called by setup routines */
 extern int reef_ec_setup(struct platform_intf *intf);
diff --git a/platform/reef/sys.c b/platform/reef/sys.c
index 82293d8..8d26df4 100644
--- a/platform/reef/sys.c
+++ b/platform/reef/sys.c
@@ -49,6 +49,20 @@
 	.family			= &smbios_sysinfo_get_family,
 	.firmware_vendor	= &smbios_bios_get_vendor,
 	.sku_number		= &smbios_sysinfo_get_sku_number,
+	.customization		= sku_get_vpd_customization,
+#ifdef CONFIG_CROS_CONFIG
+	/* Only unibuild has the concept of a signature ID */
+	.signature_id           = sku_get_signature_id,
+#endif
+};
+
+struct sys_cb coral_sys_cb = {
+	.version		= &smbios_sysinfo_get_version,
+	.vendor			= &smbios_sysinfo_get_vendor,
+	.name			= &reef_get_name,
+	.family			= &smbios_sysinfo_get_family,
+	.firmware_vendor	= &smbios_bios_get_vendor,
+	.sku_number		= &smbios_sysinfo_get_sku_number,
 #ifdef CONFIG_CROS_CONFIG
 	/* Only unibuild has the concept of a signature ID */
 	.signature_id           = sku_get_signature_id,