cs: move qdss code under drivers

In preparation to create generic coresight drivers code move
existing qdss code under drivers/cs and include/linux

Change-Id: If7697a9961006fe94818e32d19aea75c56ce225d
Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
diff --git a/arch/arm/mach-msm/Kconfig b/arch/arm/mach-msm/Kconfig
index d1ab4dd..776bf40 100644
--- a/arch/arm/mach-msm/Kconfig
+++ b/arch/arm/mach-msm/Kconfig
@@ -347,12 +347,14 @@
 	select ARCH_MSM_SCORPION
 	select MSM_SMP
 	select HAVE_ARCH_HAS_CURRENT_TIMER
+	select MSM_JTAG if MSM_QDSS
 	bool
 
 config  ARCH_MSM_KRAITMP
 	select ARCH_MSM_KRAIT
 	select MSM_SMP
 	select HAVE_ARCH_HAS_CURRENT_TIMER
+	select MSM_JTAG if MSM_QDSS
 	bool
 	select HAVE_HW_BRKPT_RESERVED_RW_ACCESS
 
@@ -2074,9 +2076,15 @@
 		enabled via another mechanism.
 
 config MSM_JTAG
-        bool "JTAG debug and trace support"
+	bool "JTAG and kernel debug and trace support across power collapse"
 	help
-          Add additional support for JTAG kernel debugging and tracing.
+	  Enables support for kernel debugging (specifically breakpoints) and
+	  processor tracing across power collapse both for JTag and OS hosted
+	  software running on the target. Enabling this will ensure debug
+	  and ETM registers are saved and restored across power collapse.
+
+	  For production builds, you should probably say 'N' here to avoid
+	  potential power, performance and memory penalty.
 
 config MSM_ETM
 	tristate "Enable MSM ETM and ETB"
@@ -2085,30 +2093,6 @@
 	help
 	  Enables embedded trace collection on MSM8660
 
-config MSM_QDSS
-	bool "Qualcomm Debug Subsystem"
-	select MSM_JTAG
-	help
-	  Enables support for Qualcomm Debug Subsystem.
-
-config MSM_QDSS_STM_DEFAULT_ENABLE
-	bool "Turn on QDSS STM Tracing by Default"
-	depends on MSM_QDSS
-	help
-	  Turns on QDSS STM tracing (hardware assisted software
-	  instrumentation based tracing) by default. Otherwise, tracing is
-	  disabled by default but can be enabled via sysfs.
-
-	  For production builds, you should probably say 'N' here to avoid
-	  potential power, performance and memory penalty.
-
-config MSM_QDSS_ETM_DEFAULT_ENABLE
-	bool "Turn on QDSS ETM Tracing by Default"
-	depends on MSM_QDSS
-	help
-	  Turns on QDSS ETM tracing by default. Otherwise, tracing is
-	  disabled by default but can be enabled by other means.
-
 config MSM_SLEEP_STATS
 	bool "Enable exporting of MSM sleep stats to userspace"
 	depends on CPU_IDLE
diff --git a/arch/arm/mach-msm/Makefile b/arch/arm/mach-msm/Makefile
index 8315d70..ec8de9f 100644
--- a/arch/arm/mach-msm/Makefile
+++ b/arch/arm/mach-msm/Makefile
@@ -55,7 +55,6 @@
 
 msm-etm-objs := etm.o
 obj-$(CONFIG_MSM_ETM) += msm-etm.o
-obj-$(CONFIG_MSM_QDSS) += qdss.o qdss-etb.o qdss-tpiu.o qdss-funnel.o qdss-stm.o qdss-etm.o
 
 quiet_cmd_mkrpcsym = MKCAP   $@
       cmd_mkrpcsym = $(PERL) $(srctree)/$(src)/mkrpcsym.pl $< $@
diff --git a/arch/arm/mach-msm/devices-8064.c b/arch/arm/mach-msm/devices-8064.c
index cc3c6db..288d0e3 100644
--- a/arch/arm/mach-msm/devices-8064.c
+++ b/arch/arm/mach-msm/devices-8064.c
@@ -17,6 +17,7 @@
 #include <linux/msm_rotator.h>
 #include <linux/clkdev.h>
 #include <linux/dma-mapping.h>
+#include <linux/qdss.h>
 #include <mach/irqs-8064.h>
 #include <mach/board.h>
 #include <mach/msm_iomap.h>
@@ -32,7 +33,6 @@
 #include <mach/msm_smd.h>
 #include <mach/msm_dcvs.h>
 #include <mach/msm_rtb.h>
-#include <mach/qdss.h>
 #include <linux/ion.h>
 #include "clock.h"
 #include "devices.h"
diff --git a/arch/arm/mach-msm/devices-8960.c b/arch/arm/mach-msm/devices-8960.c
index 550a283..d26a68a 100644
--- a/arch/arm/mach-msm/devices-8960.c
+++ b/arch/arm/mach-msm/devices-8960.c
@@ -17,6 +17,7 @@
 #include <linux/msm_rotator.h>
 #include <linux/ion.h>
 #include <linux/gpio.h>
+#include <linux/qdss.h>
 #include <asm/clkdev.h>
 #include <linux/msm_kgsl.h>
 #include <linux/android_pmem.h>
@@ -37,7 +38,6 @@
 #include <sound/msm-dai-q6.h>
 #include <sound/apr_audio.h>
 #include <mach/msm_tsif.h>
-#include <mach/qdss.h>
 #include <mach/msm_serial_hs_lite.h>
 #include "clock.h"
 #include "devices.h"
diff --git a/arch/arm/mach-msm/hotplug.c b/arch/arm/mach-msm/hotplug.c
index 46e835f..60059e8 100644
--- a/arch/arm/mach-msm/hotplug.c
+++ b/arch/arm/mach-msm/hotplug.c
@@ -11,12 +11,12 @@
 #include <linux/errno.h>
 #include <linux/smp.h>
 #include <linux/cpu.h>
+#include <linux/qdss.h>
 
 #include <asm/cacheflush.h>
 #include <asm/smp_plat.h>
 #include <asm/vfp.h>
 
-#include <mach/qdss.h>
 #include <mach/msm_rtb.h>
 
 #include "pm.h"
diff --git a/arch/arm/mach-msm/jtag.c b/arch/arm/mach-msm/jtag.c
index 8dae9c6..cd4a908 100644
--- a/arch/arm/mach-msm/jtag.c
+++ b/arch/arm/mach-msm/jtag.c
@@ -21,9 +21,20 @@
 #include <linux/ratelimit.h>
 #include <mach/scm.h>
 
-#include "qdss-priv.h"
 #include "cp14.h"
 
+/* DBGv7 with baseline CP14 registers implemented */
+#define ARM_DEBUG_ARCH_V7B	(0x3)
+/* DBGv7 with all CP14 registers implemented */
+#define ARM_DEBUG_ARCH_V7	(0x4)
+#define ARM_DEBUG_ARCH_V7_1	(0x5)
+#define ETM_ARCH_V3_3		(0x23)
+#define PFT_ARCH_V1_1		(0x31)
+
+#define BM(lsb, msb)		((BIT(msb) - BIT(lsb)) + BIT(msb))
+#define BMVAL(val, lsb, msb)	((val & BM(lsb, msb)) >> lsb)
+#define BVAL(val, n)		((val & BIT(n)) >> n)
+
 /* no of dbg regs + 1 (for storing the reg count) */
 #define MAX_DBG_REGS		(90)
 #define MAX_DBG_STATE_SIZE	(MAX_DBG_REGS * num_possible_cpus())
diff --git a/drivers/Kconfig b/drivers/Kconfig
index 286a4d4..7225bdf 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -148,4 +148,6 @@
 
 source "drivers/gud/Kconfig"
 
+source "drivers/cs/Kconfig"
+
 endmenu
diff --git a/drivers/Makefile b/drivers/Makefile
index bea505c..3272e2c 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -140,3 +140,5 @@
 
 #MobiCore
 obj-$(CONFIG_MOBICORE_SUPPORT)  += gud/
+
+obj-$(CONFIG_MSM_QDSS)		+= cs/
diff --git a/drivers/cs/Kconfig b/drivers/cs/Kconfig
new file mode 100644
index 0000000..1219af1
--- /dev/null
+++ b/drivers/cs/Kconfig
@@ -0,0 +1,32 @@
+config MSM_QDSS
+	bool "CoreSight tracing"
+	help
+	  Enables support for CoreSight tracing. This uses CoreSight trace
+	  components and buses to support both hardware (eg. processor ETM)
+	  and hardware assisted software instrumentation based (eg. STM)
+	  tracing.
+
+	  For production builds, you should probably say 'N' here to avoid
+	  potential power, performance and memory penalty.
+
+config MSM_QDSS_STM_DEFAULT_ENABLE
+	bool "Turn on CoreSight STM tracing by default"
+	depends on MSM_QDSS
+	help
+	  Turns on CoreSight STM tracing (hardware assisted software
+	  instrumentation based tracing) by default. Otherwise, tracing is
+	  disabled by default but can be enabled via sysfs.
+
+	  For production builds, you should probably say 'N' here to avoid
+	  potential power, performance and memory penalty.
+
+config MSM_QDSS_ETM_DEFAULT_ENABLE
+	bool "Turn on CoreSight ETM tracing by default"
+	depends on MSM_QDSS
+	help
+	  Turns on CoreSight ETM tracing (processor tracing) by default.
+	  Otherwise, tracing is disabled by default but can be enabled via
+	  sysfs.
+
+	  For production builds, you should probably say 'N' here to avoid
+	  potential power, performance and memory penalty.
diff --git a/drivers/cs/Makefile b/drivers/cs/Makefile
new file mode 100644
index 0000000..9a634a1
--- /dev/null
+++ b/drivers/cs/Makefile
@@ -0,0 +1,2 @@
+
+obj-$(CONFIG_MSM_QDSS) += qdss.o qdss-etb.o qdss-tpiu.o qdss-funnel.o qdss-stm.o qdss-etm.o
diff --git a/arch/arm/mach-msm/qdss-etb.c b/drivers/cs/qdss-etb.c
similarity index 100%
rename from arch/arm/mach-msm/qdss-etb.c
rename to drivers/cs/qdss-etb.c
diff --git a/arch/arm/mach-msm/qdss-etm.c b/drivers/cs/qdss-etm.c
similarity index 100%
rename from arch/arm/mach-msm/qdss-etm.c
rename to drivers/cs/qdss-etm.c
diff --git a/arch/arm/mach-msm/qdss-funnel.c b/drivers/cs/qdss-funnel.c
similarity index 100%
rename from arch/arm/mach-msm/qdss-funnel.c
rename to drivers/cs/qdss-funnel.c
diff --git a/arch/arm/mach-msm/qdss-priv.h b/drivers/cs/qdss-priv.h
similarity index 98%
rename from arch/arm/mach-msm/qdss-priv.h
rename to drivers/cs/qdss-priv.h
index f39bc52..868514c 100644
--- a/arch/arm/mach-msm/qdss-priv.h
+++ b/drivers/cs/qdss-priv.h
@@ -14,7 +14,7 @@
 #define _ARCH_ARM_MACH_MSM_QDSS_H_
 
 #include <linux/bitops.h>
-#include <mach/qdss.h>
+#include <linux/qdss.h>
 
 /* Coresight management registers (0xF00-0xFCC)
  * 0xFA0 - 0xFA4: Management	registers in PFTv1.0
diff --git a/arch/arm/mach-msm/qdss-stm.c b/drivers/cs/qdss-stm.c
similarity index 100%
rename from arch/arm/mach-msm/qdss-stm.c
rename to drivers/cs/qdss-stm.c
diff --git a/arch/arm/mach-msm/qdss-tpiu.c b/drivers/cs/qdss-tpiu.c
similarity index 100%
rename from arch/arm/mach-msm/qdss-tpiu.c
rename to drivers/cs/qdss-tpiu.c
diff --git a/arch/arm/mach-msm/qdss.c b/drivers/cs/qdss.c
similarity index 100%
rename from arch/arm/mach-msm/qdss.c
rename to drivers/cs/qdss.c
diff --git a/arch/arm/mach-msm/include/mach/qdss.h b/include/linux/qdss.h
similarity index 100%
rename from arch/arm/mach-msm/include/mach/qdss.h
rename to include/linux/qdss.h