apq8064: Add support for Crypto Engine 3.

Change-Id: Iaf899719dbb2dee266d77b155ad9d91c8d65805c
diff --git a/platform/msm8960/acpuclock.c b/platform/msm8960/acpuclock.c
index b7a4d3d..0635b81 100644
--- a/platform/msm8960/acpuclock.c
+++ b/platform/msm8960/acpuclock.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
+ * Copyright (c) 2011-2012, 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 met:
@@ -8,7 +8,7 @@
  *   * Redistributions in binary form must reproduce the above copyright
  *     notice, this list of conditions and the following disclaimer in the
  *     documentation and/or other materials provided with the distribution.
- *   * Neither the name of Code Aurora nor
+ *   * Neither the name of The Linux Foundation nor
  *     the names of its contributors may be used to endorse or promote
  *     products derived from this software without specific prior written
  *     permission.
@@ -34,6 +34,8 @@
 #include <gsbi.h>
 #include <mmc.h>
 #include <clock.h>
+#include <board.h>
+#include <smem.h>
 
 /* Set rate and enable the clock */
 static void clock_config(uint32_t ns, uint32_t md, uint32_t ns_addr, uint32_t md_addr)
@@ -236,13 +238,23 @@
 /* Configure crypto engine clock */
 void ce_clock_init(void)
 {
-	/* Enable HCLK for CE */
-	clk_get_set_enable("ce1_pclk", 0, 1);
+	if (board_platform_id() != APQ8064)
+	{
+		/* Enable HCLK for CE1 */
+		clk_get_set_enable("ce1_pclk", 0, 1);
 
-	/* Enable core clk for CE */
-	clk_get_set_enable("ce1_clk", 0, 1);
+		/* Enable core clk for CE1 */
+		clk_get_set_enable("ce1_clk", 0, 1);
+	}
+	else
+	{
+		/* Enable HCLK for CE3 */
+		clk_get_set_enable("ce3_pclk", 0, 1);
+
+		/* Enable core clk for CE3 */
+		clk_get_set_enable("ce3_clk", 0, 1);
+	}
 }
-
 /* Async Reset CE1 */
 void ce_async_reset()
 {
diff --git a/platform/msm8960/include/platform/iomap.h b/platform/msm8960/include/platform/iomap.h
index 2bd50b6..32167f8 100644
--- a/platform/msm8960/include/platform/iomap.h
+++ b/platform/msm8960/include/platform/iomap.h
@@ -1,7 +1,7 @@
 /* Copyright (c) 2008, Google Inc.
  * All rights reserved.
  *
- * Copyright (c) 2009-2012, Code Aurora Forum. All rights reserved.
+ * Copyright (c) 2009-2012, 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
@@ -116,6 +116,6 @@
 #define MMSS_SFPB_GPREG                       (0x05700058)
 
 #define CE1_CRYPTO4_BASE                      (0x18500000)
-#define MSM_CRYPTO_BASE                       CE1_CRYPTO4_BASE
+#define CE3_CRYPTO4_BASE                      (0x11000000)
 #define LCDC_BASE                             (0x000C0000)
 #endif
diff --git a/platform/msm_shared/crypto4_eng.c b/platform/msm_shared/crypto4_eng.c
old mode 100755
new mode 100644
index 62f5666..1a9bc0a
--- a/platform/msm_shared/crypto4_eng.c
+++ b/platform/msm_shared/crypto4_eng.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
+/* Copyright (c) 2012, 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
@@ -9,7 +9,7 @@
  *     copyright notice, this list of conditions and the following
  *     disclaimer in the documentation and/or other materials provided
  *     with the distribution.
- *   * Neither the name of Code Aurora Forum, Inc. nor the names of its
+ *   * Neither the name of The Linux Foundation nor the names of its
  *     contributors may be used to endorse or promote products derived
  *     from this software without specific prior written permission.
  *
@@ -35,10 +35,32 @@
 #include <crypto4_eng.h>
 #include <crypto_hash.h>
 #include <scm.h>
+#include <smem.h>
 
 extern void dsb(void);
 extern void ce_async_reset();
 
+void wr_ce(uint32_t val,uint32_t reg)
+{
+
+	if(board_platform_id() != APQ8064)
+		writel(val,CRYPTO_ENG_REG(CE1_CRYPTO4_BASE, reg));
+	else
+		writel(val,CRYPTO_ENG_REG(CE3_CRYPTO4_BASE, reg));
+}
+uint32_t rd_ce(uint32_t reg)
+{
+
+	uint32_t val;
+
+	if(board_platform_id() != APQ8064)
+		val = readl(CRYPTO_ENG_REG(CE1_CRYPTO4_BASE, reg));
+	else
+        val = readl(CRYPTO_ENG_REG(CE3_CRYPTO4_BASE, reg));
+
+	return val;
+}
+
 /*
  * Function to reset the crypto engine.
  */
@@ -74,13 +96,13 @@
 
 void crypto_eng_init(void)
 {
+
 	unsigned int val;
 
 	enum ap_ce_channel_type chn = AP_CE_REGISTER_USE;
-	/* Make a SMC call to TZ to make CE1 use register interface */
+	/* Make a SMC call to TZ to make CE1 use register interface for HLOS*/
 	val = switch_ce_chn_cmd(chn);
 	dprintf(INFO, "TZ channel swith returned %d\n", val);
-
 }
 
 /*
diff --git a/platform/msm_shared/include/crypto4_eng.h b/platform/msm_shared/include/crypto4_eng.h
index c1597e4..dde7794 100644
--- a/platform/msm_shared/include/crypto4_eng.h
+++ b/platform/msm_shared/include/crypto4_eng.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
+/* Copyright (c) 2012, 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
@@ -9,7 +9,7 @@
  *     copyright notice, this list of conditions and the following
  *     disclaimer in the documentation and/or other materials provided
  *     with the distribution.
- *   * Neither the name of Code Aurora Forum, Inc. nor the names of its
+ *   * Neither the name of The Linux Foundation nor the names of its
  *     contributors may be used to endorse or promote products derived
  *     from this software without specific prior written permission.
  *
@@ -29,10 +29,7 @@
 #ifndef __CRYPTO4_ENG_H__
 #define __CRYPYO4_ENG_H__
 
-#define CRYPTO_ENG_REG(offset)		(MSM_CRYPTO_BASE + offset)
-
-#define wr_ce(val,reg)				writel(val,CRYPTO_ENG_REG(reg))
-#define rd_ce(reg)					readl(CRYPTO_ENG_REG(reg))
+#define CRYPTO_ENG_REG(base, offset)    ((base) + offset)
 
 #define IS_ALIGNED(ptr)				(!(((unsigned int)ptr) & 0x03))
 
diff --git a/target/msm8960/init.c b/target/msm8960/init.c
index 0491a20..fc565c3 100755
--- a/target/msm8960/init.c
+++ b/target/msm8960/init.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2009, Google Inc.
  * All rights reserved.
- * Copyright (c) 2009-2012, Code Aurora Forum. All rights reserved.
+ * Copyright (c) 2009-2012, 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
@@ -140,7 +140,8 @@
 	if ((platform_id == MSM8960) || (platform_id == MSM8960AB) ||
 		(platform_id == APQ8060AB) || (platform_id == MSM8260AB) ||
 		(platform_id == MSM8660AB) || (platform_id == MSM8660A) ||
-		(platform_id == MSM8260A) || (platform_id == APQ8060A))
+		(platform_id == MSM8260A) || (platform_id == APQ8060A) ||
+		(platform_id == APQ8064))
 		/* Enable Hardware CE */
 		platform_ce_type = CRYPTO_ENGINE_TYPE_HW;