Merge "msm7630: Send kernel tamper info to nonHLOS"
diff --git a/platform/msm7x27a/acpuclock.c b/platform/msm7x27a/acpuclock.c
index 33375ad..ba0b939 100644
--- a/platform/msm7x27a/acpuclock.c
+++ b/platform/msm7x27a/acpuclock.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2008, Google Inc.
  * All rights reserved.
- * Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
+ * Copyright (c) 2009-2012, Code Aurora Forum. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -102,6 +102,14 @@
 #endif
 };
 
+/*
+ * Use PLL4 to run acpu @ 1.2 GHZ
+ */
+uint32_t const clk_cntl_reg_val_8X25[] = {
+	(WAIT_CNT << 16) | (SRC_SEL_PLL4 << 4)  | DIV_2,
+	(WAIT_CNT << 16) | (SRC_SEL_PLL4 << 12) | (DIV_1 << 8),
+};
+
 uint32_t const clk_cntl_reg_val_7625A[] = {
 	(WAIT_CNT << 16) | (SRC_SEL_PLL2 << 4) | DIV_16,
 	(WAIT_CNT << 16) | (SRC_SEL_PLL2 << 12) | (DIV_8 << 8),
@@ -225,6 +233,12 @@
 		pll_request(4, 1);
 #endif
 		break;
+	case MSM8625:
+		/* Fix me: Will move to PLL4 later */
+		clk_cntl_reg_val = clk_cntl_reg_val_7627A;
+		size = ARRAY_SIZE(clk_cntl_reg_val_7627A);
+		pll_request(2, 1);
+		break;
 
 	case MSM7225A:
 	case MSM7625A:
diff --git a/platform/msm7x27a/include/platform/irqs.h b/platform/msm7x27a/include/platform/irqs.h
index 76a41d5..d5dce0f 100644
--- a/platform/msm7x27a/include/platform/irqs.h
+++ b/platform/msm7x27a/include/platform/irqs.h
@@ -2,6 +2,8 @@
  * Copyright (c) 2008, Google Inc.
  * All rights reserved.
  *
+ * Copyright (c) 2012, Code Aurora Forum. All rights reserved.
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -32,6 +34,11 @@
 #ifndef _PLATFORM_MSM7K_IRQS_H_
 #define _PLATFORM_MSM7K_IRQS_H_
 
+extern int debug_timer;
+extern int gpt_timer;
+extern int usb_hs_int;
+
+#define GIC_PPI_START		16
 #define INT_A9_M2A_0		 0
 #define INT_A9_M2A_1		 1
 #define INT_A9_M2A_2		 2
@@ -39,8 +46,8 @@
 #define INT_A9_M2A_4		 4
 #define INT_A9_M2A_5		 5
 #define INT_A9_M2A_6		 6
-#define INT_GP_TIMER_EXP	 7
-#define INT_DEBUG_TIMER_EXP  8
+#define INT_GP_TIMER_EXP	 gpt_timer
+#define INT_DEBUG_TIMER_EXP	 debug_timer
 #define INT_UART1			9
 #define INT_UART2			10
 #define INT_UART3			11
@@ -80,7 +87,9 @@
 #define INT_TSIF_IRQ		 (32 + 12)
 #define INT_UART1DM_IRQ	  (32 + 13)
 #define INT_UART1DM_RX	   (32 + 14)
-#define INT_USB_HS		   (32 + 15)
+#define INT_USB_HS_VIC		(32 + 15)
+#define INT_USB_HS_GIC		(32 + 32 + 15)
+#define INT_USB_HS		usb_hs_int
 #define INT_SDC3_0		   (32 + 16)
 #define INT_SDC3_1		   (32 + 17)
 #define INT_SDC4_0		   (32 + 18)
@@ -90,6 +99,8 @@
 
 #define MSM_IRQ_BIT(irq)	 (1 << ((irq) & 31))
 
-#define NR_IRQS 54
+#define NR_IRQS		NR_IRQS_QGIC
+#define NR_IRQS_VIC	54
+#define NR_IRQS_QGIC	261
 
 #endif
diff --git a/platform/msm7x27a/interrupts.c b/platform/msm7x27a/interrupts.c
index 9f72908..fdc7798 100644
--- a/platform/msm7x27a/interrupts.c
+++ b/platform/msm7x27a/interrupts.c
@@ -2,6 +2,8 @@
  * Copyright (c) 2008, Google Inc.
  * All rights reserved.
  *
+ * Copyright (c) 2012, Code Aurora Forum. All rights reserved.
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -78,7 +80,7 @@
 	void *arg;
 };
 
-static struct ihandler handler[NR_IRQS];
+static struct ihandler handler[NR_IRQS_VIC];
 
 void platform_init_interrupts(void)
 {
@@ -98,7 +100,7 @@
 	enum handler_return ret;
 	num = readl(VIC_IRQ_VEC_RD);
 	num = readl(VIC_IRQ_VEC_PEND_RD);
-	if (num > NR_IRQS)
+	if (num > NR_IRQS_VIC)
 		return 0;
 	writel(1 << (num & 31), (num > 31) ? VIC_INT_CLEAR1 : VIC_INT_CLEAR0);
 	ret = handler[num].func(handler[num].arg);
@@ -129,7 +131,7 @@
 
 void vic_register_int_handler(unsigned int vector, int_handler func, void *arg)
 {
-	if (vector >= NR_IRQS)
+	if (vector >= NR_IRQS_VIC)
 		return;
 
 	enter_critical_section();
diff --git a/platform/msm7x27a/platform.c b/platform/msm7x27a/platform.c
index 76964f9..c9f39d1 100755
--- a/platform/msm7x27a/platform.c
+++ b/platform/msm7x27a/platform.c
@@ -2,7 +2,7 @@
  * Copyright (c) 2008, Google Inc.
  * All rights reserved.
  *
- * Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
+ * Copyright (c) 2009-2012, Code Aurora Forum. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -36,6 +36,7 @@
 #include <kernel/thread.h>
 #include <platform/debug.h>
 #include <platform/iomap.h>
+#include <platform/irqs.h>
 #include <mddi.h>
 #include <dev/fbcon.h>
 #include <dev/gpio.h>
@@ -59,7 +60,9 @@
 
 unsigned board_msm_id(void);
 
-static int target_uses_qgic = 0;
+static int target_uses_qgic;
+int debug_timer = 0, gpt_timer = 0, usb_hs_int = 0;
+
 void platform_early_init(void)
 {
 #if WITH_DEBUG_UART
@@ -69,8 +72,14 @@
 	if(machine_is_8x25()) {
 		qgic_init();
 		target_uses_qgic = 1;
+		debug_timer = (GIC_PPI_START + 2);
+		gpt_timer = (GIC_PPI_START + 3);
+		usb_hs_int = INT_USB_HS_GIC;
 	} else {
 		platform_init_interrupts();
+		debug_timer = 8;
+		gpt_timer = 7;
+		usb_hs_int = INT_USB_HS_VIC;
 	}
 	platform_init_timer();
 }
@@ -105,7 +114,7 @@
 void display_shutdown(void)
 {
 #if DISPLAY_TYPE_MIPI
-	if (machine_is_7x27a_evb())
+	if (machine_is_evb())
 		return;
 	dprintf(SPEW, "display_shutdown()\n");
 	mipi_dsi_shutdown();
diff --git a/platform/msm_shared/smem.h b/platform/msm_shared/smem.h
index 0813be3..97f01e6 100644
--- a/platform/msm_shared/smem.h
+++ b/platform/msm_shared/smem.h
@@ -2,7 +2,7 @@
  * Copyright (c) 2009, Google Inc.
  * All rights reserved.
  *
- * Copyright (c) 2009, Code Aurora Forum. All rights reserved.
+ * Copyright (c) 2009-2012, Code Aurora Forum. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -185,6 +185,8 @@
 	MSM8660A = 122,
 	MSM8260A = 123,
 	APQ8060A = 124,
+	MSM8225 = 127,
+	MSM8625 = 129
 };
 
 enum platform {
diff --git a/target/msm7627a/init.c b/target/msm7627a/init.c
index b8b91fa..6c8f212 100644
--- a/target/msm7627a/init.c
+++ b/target/msm7627a/init.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2009, Google Inc.
  * All rights reserved.
- * Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
+ * Copyright (c) 2009-2012, Code Aurora Forum. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -52,6 +52,9 @@
 #define MSM7X27A_QRD3	4005
 #define MSM8X25_RUMI3   3871
 
+#define MSM8X25_SURF	4037
+#define MSM8X25_EVB	4042
+
 #define LINUX_MACHTYPE  MSM7X27A_SURF
 
 #define VARIABLE_LENGTH		0x10101010
@@ -75,7 +78,7 @@
  */
 static crypto_engine_type platform_ce_type = CRYPTO_ENGINE_TYPE_SW;
 
-int machine_is_7x27a_evb();
+int machine_is_evb();
 
 /* for these partitions, start will be offset by either what we get from
  * smem, or from the above offset if smem is not useful. Also, we should
@@ -154,7 +157,7 @@
 	 * support for new panel is added disable splash screen
 	 * for EVB
 	 */
-	if (!machine_is_7x27a_evb()) {
+	if (!machine_is_evb()) {
 		display_init();
 		dprintf(SPEW, "Diplay initialized\n");
 		display_image_on_screen();
@@ -253,25 +256,37 @@
 		}
 
 		/* Detect SURF v/s FFA v/s QRD */
-		switch (id) {
-		case 0x1:
-			/* Set the machine type based on msm ID */
-			if (target_msm_id == MSM7225A
-			    || target_msm_id == MSM7625A
-			    || target_msm_id == ESM7225A
-			    || (target_msm_id >= MSM7225AA
-				&& target_msm_id <= ESM7225AA))
-				hw_platform = MSM7X25A_SURF;
+		if (target_msm_id >= MSM8225 && target_msm_id <= MSM8625) {
+			switch (id) {
+			case 0x1:
+				hw_platform = MSM8X25_SURF;
+				break;
+			case 0xC:
+				hw_platform = MSM8X25_EVB;
+				break;
+			default:
+				hw_platform = MSM8X25_SURF;
+			}
+		} else {
+			switch (id) {
+			case 0x1:
+				/* Set the machine type based on msm ID */
+				if (target_msm_id == MSM7225A
+					|| target_msm_id == MSM7625A
+					|| target_msm_id == ESM7225A
+					|| (target_msm_id >= MSM7225AA
+					&& target_msm_id <= ESM7225AA))
+					hw_platform = MSM7X25A_SURF;
 			else
 				hw_platform = MSM7X27A_SURF;
 			break;
-		case 0x2:
-			if (target_msm_id == MSM7225A
-			    || target_msm_id == MSM7625A
-			    || target_msm_id == ESM7225A
-			    || (target_msm_id >= MSM7225AA
-				&& target_msm_id <= ESM7225AA))
-				hw_platform = MSM7X25A_FFA;
+			case 0x2:
+				if (target_msm_id == MSM7225A
+					|| target_msm_id == MSM7625A
+					|| target_msm_id == ESM7225A
+					|| (target_msm_id >= MSM7225AA
+					&& target_msm_id <= ESM7225AA))
+					hw_platform = MSM7X25A_FFA;
 			else
 				hw_platform = MSM7X27A_FFA;
 			break;
@@ -294,7 +309,7 @@
 			else
 				hw_platform = MSM7X27A_SURF;
 		};
-
+	}
 		/* Set msm ID for target variants based on values read from smem */
 		switch (target_msm_id) {
 		case MSM7225A:
@@ -305,6 +320,10 @@
 		case ESM7225AA:
 			target_msm_id = MSM7625A;
 			break;
+		case MSM8225:
+		case MSM8625:
+			target_msm_id = MSM8625;
+			break;
 		default:
 			target_msm_id = MSM7627A;
 		}
@@ -431,12 +450,20 @@
 }
 #endif
 
-int machine_is_7x27a_evb()
+int machine_is_evb()
 {
-	if (board_machtype() == MSM7X27A_EVB)
-		return 1;
-	else
-		return 0;
+	int ret = 0;
+	unsigned mach_type = board_machtype();
+
+	switch(mach_type) {
+		case MSM7X27A_EVB:
+		case MSM8X25_EVB:
+			ret = 1;
+			break;
+		default:
+			ret = 0;
+	}
+	return ret;
 }
 
 int machine_is_7x27a_qrd3()
@@ -456,8 +483,16 @@
 }
 int machine_is_8x25()
 {
-	if (board_machtype() == MSM8X25_RUMI3)
-		return 1;
-	else
-		return 0;
+	int ret = 0;
+	unsigned mach_type = board_machtype();
+
+	switch(mach_type) {
+		case MSM8X25_SURF:
+		case MSM8X25_EVB:
+			ret = 1;
+			break;
+		default:
+			ret = 0;
+	}
+	return ret;
 }
diff --git a/target/msm7627a/keypad.c b/target/msm7627a/keypad.c
index 7244133..28776a6 100644
--- a/target/msm7627a/keypad.c
+++ b/target/msm7627a/keypad.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2009, Google Inc.
  * All rights reserved.
- * Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
+ * Copyright (c) 2009-2012, Code Aurora Forum. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -138,7 +138,7 @@
 {
 	if (machine_is_7x27a_qrd1() || machine_is_7x27a_qrd3())
 		gpio_keypad_init(&halibut_keypad_info_qrd);
-	else if (machine_is_7x27a_evb())
+	else if (machine_is_evb())
 		gpio_keypad_init(&halibut_keypad_info_evb);
 	else
 		gpio_keypad_init(&halibut_keypad_info_surf);