dev: gcdb: display: check for msm chip serial number

When an APPS bootloader image is flashed on device and then
subsequently the msm is replaced, the dfps structure stored in
splash partition is not valid. The DSI PLL trim codes need to be
generated again for the new msm part. Save the chip serial number
which is unique for each msm part along with the dfps struct in
splash partition. If the current chip serial number does not match
the chip serial number in the splash partition, recalculate the
DSI PLL trim codes and store it back to splash partition.

Change-Id: I8476d60454c52ee9adbbb6386c6e6bb91c666911
diff --git a/dev/gcdb/display/gcdb_display.c b/dev/gcdb/display/gcdb_display.c
index b144433..945839c 100644
--- a/dev/gcdb/display/gcdb_display.c
+++ b/dev/gcdb/display/gcdb_display.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -240,9 +240,13 @@
 	dprintf(SPEW, "enable=%d cnt=%d\n", dfps->panel_dfps.enabled,
 		dfps->panel_dfps.frame_rate_cnt);
 
-	if (!dfps->panel_dfps.enabled || (dfps->panel_dfps.frame_rate_cnt >
-		DFPS_MAX_FRAME_RATE) || (dfps->dfps_fb_base !=
-		pinfo->dfps.dfps_fb_base)) {
+	dprintf(CRITICAL, "chip serial splash =%d\n", dfps->chip_serial);
+	dprintf(CRITICAL, "chip serial pinfo =%d\n", pinfo->dfps.chip_serial);
+
+	if (!dfps->panel_dfps.enabled ||
+		(dfps->panel_dfps.frame_rate_cnt > DFPS_MAX_FRAME_RATE) ||
+		(dfps->dfps_fb_base != pinfo->dfps.dfps_fb_base) ||
+		(pinfo->dfps.chip_serial != dfps->chip_serial)) {
 		ret = ERROR;
 		free(dfps);
 		goto splash_err;
@@ -295,11 +299,14 @@
 	if (!pinfo->dfps.panel_dfps.enabled)
 		goto dfps_done;
 
+	pinfo->dfps.chip_serial = board_chip_serial();
+
 	if (!mdss_dsi_dfps_get_stored_pll_codes(pinfo)) {
-		dprintf(SPEW, "Found stored PLL codes!\n");
+		dprintf(CRITICAL, "Found stored PLL codes!\n");
 		goto dfps_cal_done;
 	}
 
+	dprintf(CRITICAL, "Calculate PLL codes!\n");
 	ret = mdss_dsi_dfps_get_pll_codes_cal(pinfo);
 	if (ret) {
 		dprintf(CRITICAL, "Cannot cal pll codes!\n");
diff --git a/platform/msm_shared/include/msm_panel.h b/platform/msm_shared/include/msm_panel.h
index 4c44cc4..f458328 100644
--- a/platform/msm_shared/include/msm_panel.h
+++ b/platform/msm_shared/include/msm_panel.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -247,6 +247,7 @@
 	struct dfps_panel_info panel_dfps;
 	struct dfps_codes_info codes_dfps[DFPS_MAX_FRAME_RATE];
 	void *dfps_fb_base;
+	uint32_t chip_serial;
 };
 
 /* intf timing settings */