msm_shared: Change the delay function for qtimer.

Change-Id: Iea191de9f489e9e5cf7518d5385348c42f87e945
diff --git a/platform/copper/include/platform/iomap.h b/platform/copper/include/platform/iomap.h
index d099e3d..c3ccea2 100644
--- a/platform/copper/include/platform/iomap.h
+++ b/platform/copper/include/platform/iomap.h
@@ -42,6 +42,9 @@
 #define APCS_APC_KPSS_PLL_BASE      (KPSS_BASE + 0x0000A000)
 #define APCS_KPSS_CFG_BASE          (KPSS_BASE + 0x00010000)
 #define APCS_KPSS_WDT_BASE          (KPSS_BASE + 0x00017000)
+#define KPSS_APCS_QTMR_AC_BASE      (KPSS_BASE + 0x00020000)
+#define KPSS_APCS_F0_QTMR_V1_BASE   (KPSS_BASE + 0x00021000)
+#define QTMR_BASE                   KPSS_APCS_F0_QTMR_V1_BASE
 
 #define PERIPH_SS_BASE              0xF9800000
 
@@ -78,7 +81,6 @@
 
 #define MPM2_MPM_CTRL_BASE          0xFC4A1000
 
-/* Clock control registers */
 
 /* GPLL */
 #define GPLL0_STATUS                (CLK_CTL_BASE + 0x001C)
diff --git a/platform/msm_shared/qtimer.c b/platform/msm_shared/qtimer.c
index 2ae2757..81f5b2f 100644
--- a/platform/msm_shared/qtimer.c
+++ b/platform/msm_shared/qtimer.c
@@ -72,8 +72,7 @@
 	/* Calculate timeout = cnt + ticks (mod 2^56)
 	 * to account for timer counter wrapping
 	 */
-	timeout = (cnt + ticks) &
-			(uint64_t)(QTMR_PHY_CNT_MAX_VALUE);
+	timeout = (cnt + ticks) & (uint64_t)(QTMR_PHY_CNT_MAX_VALUE);
 
 	/* Wait out till the counter wrapping occurs
 	 * in cases where there is a wrapping.
diff --git a/platform/msm_shared/qtimer_mmap.c b/platform/msm_shared/qtimer_mmap.c
index 4f0ec4c..a5e732b 100644
--- a/platform/msm_shared/qtimer_mmap.c
+++ b/platform/msm_shared/qtimer_mmap.c
@@ -42,7 +42,6 @@
 static volatile uint32_t current_time;
 static uint32_t tick_count;
 
-extern uint64_t atomic_dw_read(uint32_t, uint32_t *, uint32_t *);
 extern void dsb();
 static void qtimer_enable();
 
@@ -132,8 +131,14 @@
 {
 	uint32_t phy_cnt_lo;
 	uint32_t phy_cnt_hi;
+	uint32_t phy_cnt_hi_1;
+	uint32_t phy_cnt_hi_2;
 
-	atomic_dw_read(QTMR_V1_CNTPCT_LO, &phy_cnt_lo, &phy_cnt_hi);
+	do {
+		phy_cnt_hi_1 = readl(QTMR_V1_CNTPCT_HI);
+		phy_cnt_lo = readl(QTMR_V1_CNTPCT_LO);
+		phy_cnt_hi_2 = readl(QTMR_V1_CNTPCT_HI);
+    } while (phy_cnt_hi_1 != phy_cnt_hi_2);
 
 	return ((uint64_t)phy_cnt_hi << 32) | phy_cnt_lo;
 }
diff --git a/platform/msm_shared/rules.mk b/platform/msm_shared/rules.mk
index 1754547..64545c6 100644
--- a/platform/msm_shared/rules.mk
+++ b/platform/msm_shared/rules.mk
@@ -60,7 +60,7 @@
 ifeq ($(PLATFORM),copper)
 	OBJS += $(LOCAL_DIR)/qgic.o \
 			$(LOCAL_DIR)/qtimer.o \
-			$(LOCAL_DIR)/qtimer_cp15.o \
+			$(LOCAL_DIR)/qtimer_mmap.o \
 			$(LOCAL_DIR)/interrupts.o \
 			$(LOCAL_DIR)/clock.o \
 			$(LOCAL_DIR)/clock_pll.o \