board-8960: Update 8960AB and 8064AB SPM sequences.

8960AB and 8064AB have a new revision of the Krait SPM hardware.
The SPM v1.15x on these targets uses a different bit to control the
apc_pdn signal.
Update the SPM sequences for standalone and power collapse to use the
new sequences.
L2 SPM or Krait WFI/Retention sequences are not affected.

CRs-fixed: 419258
Change-Id: I3bcf335ac50cd1181047fe1ee1d56ecd507ae35c
Signed-off-by: Anji Jonnala <anjir@codeaurora.org>
diff --git a/arch/arm/mach-msm/board-8960.c b/arch/arm/mach-msm/board-8960.c
index ac26bcd..a482c9a 100644
--- a/arch/arm/mach-msm/board-8960.c
+++ b/arch/arm/mach-msm/board-8960.c
@@ -1700,6 +1700,21 @@
 			0x24, 0x30, 0x0f,
 };
 
+/* 8960AB has a different command to assert apc_pdn */
+static uint8_t spm_power_collapse_without_rpm_krait_v3[] __initdata = {
+	0x00, 0x24, 0x84, 0x10,
+	0x09, 0x03, 0x01,
+	0x10, 0x84, 0x30, 0x0C,
+	0x24, 0x30, 0x0f,
+};
+
+static uint8_t spm_power_collapse_with_rpm_krait_v3[] __initdata = {
+	0x00, 0x24, 0x84, 0x10,
+	0x09, 0x07, 0x01, 0x0B,
+	0x10, 0x84, 0x30, 0x0C,
+	0x24, 0x30, 0x0f,
+};
+
 static struct msm_spm_seq_entry msm_spm_boot_cpu_seq_list[] __initdata = {
 	[0] = {
 		.mode = MSM_SPM_MODE_CLOCK_GATING,
@@ -3293,6 +3308,34 @@
 	msm_tsens_early_init(&msm_tsens_pdata);
 }
 
+static void __init msm8960ab_update_krait_spm(void)
+ {
+ 	int i;
+ 
+	/* Reset the AVS registers until we have support for AVS */
+ 	for (i = 0; i < ARRAY_SIZE(msm_spm_data); i++) {
+ 		struct msm_spm_platform_data *pdata = &msm_spm_data[i];
+ 		pdata->reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0;
+ 		pdata->reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0;
+ 	}
+
+	/* Update the SPM sequences for SPC and PC */
+	for (i = 0; i < ARRAY_SIZE(msm_spm_data); i++) {
+		int j;
+		struct msm_spm_platform_data *pdata = &msm_spm_data[i];
+		for (j = 0; j < pdata->num_modes; j++) {
+			if (pdata->modes[j].cmd ==
+					spm_power_collapse_without_rpm)
+				pdata->modes[j].cmd =
+				spm_power_collapse_without_rpm_krait_v3;
+			else if (pdata->modes[j].cmd ==
+					spm_power_collapse_with_rpm)
+				pdata->modes[j].cmd =
+				spm_power_collapse_with_rpm_krait_v3;
+		}
+	}
+}
+
 static void __init msm8960_cdp_init(void)
 {
 	if (meminfo_init(SYS_MEMORY, SZ_256M) < 0)
@@ -3347,6 +3390,8 @@
 		msm_isa1200_board_info[0].platform_data = &isa1200_1_pdata;
 	msm8960_i2c_init();
 	msm8960_gfx_init();
+ 	if (cpu_is_msm8960ab())
+		msm8960ab_update_krait_spm();
 	msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
 	msm_spm_l2_init(msm_spm_l2_data);
 	msm8960_init_buses();