ARM: etm: Check arch version and disable data tracing for ptm
authorArve Hjønnevåg <arve@android.com>
Tue, 3 Apr 2012 03:18:56 +0000 (20:18 -0700)
committerArve Hjønnevåg <arve@android.com>
Mon, 1 Jul 2013 20:40:41 +0000 (13:40 -0700)
Change-Id: If2cb7928d0711f48348443d882a12416be9c5910
Signed-off-by: Arve Hjønnevåg <arve@android.com>
arch/arm/include/asm/hardware/coresight.h
arch/arm/kernel/etm.c

index d75626b2ccbaf95426a06f3bc36d4061a398e54b..684107f444a6d6c3953a55d97f3abd91055e0165 100644 (file)
@@ -60,6 +60,7 @@
 
 /* ETM configuration code register */
 #define ETMR_CONFCODE          (0x04)
+#define ETMCCR_ETMIDR_PRESENT  BIT(31)
 
 /* ETM trace start/stop resource control register */
 #define ETMR_TRACESSCTRL       (0x18)
                                ETMCTRL_BRANCH_OUTPUT | \
                                ETMCTRL_DO_CONTEXTID)
 
+#define ETMR_ID                        0x1e4
+#define ETMIDR_VERSION(x)      (((x) >> 4) & 0xff)
+#define ETMIDR_VERSION_PFT_1_0 0x30
+
 #define ETMR_TRACEIDR          0x200
 
 /* ETM management registers, "ETM Architecture", 3.5.24 */
index 1cb3132bce2ee211880231d378f00da63d355857..fc254563ae054a6e3441d75b0c7de73ce83e44d1 100644 (file)
@@ -724,6 +724,9 @@ static int etm_probe(struct amba_device *dev, const struct amba_id *id)
        int ret = 0;
        void __iomem **new_regs;
        int new_count;
+       u32 etmccr;
+       u32 etmidr;
+       u8 etm_version = 0;
 
        mutex_lock(&t->mutex);
        new_count = t->etm_regs_count + 1;
@@ -758,7 +761,12 @@ static int etm_probe(struct amba_device *dev, const struct amba_id *id)
        /* dummy first read */
        (void)etm_readl(&tracer, t->etm_regs_count, ETMMR_OSSRR);
 
-       t->ncmppairs = etm_readl(t, t->etm_regs_count, ETMR_CONFCODE) & 0xf;
+       etmccr = etm_readl(t, t->etm_regs_count, ETMR_CONFCODE);
+       t->ncmppairs = etmccr & 0xf;
+       if (etmccr & ETMCCR_ETMIDR_PRESENT) {
+               etmidr = etm_readl(t, t->etm_regs_count, ETMR_ID);
+               etm_version = ETMIDR_VERSION(etmidr);
+       }
        etm_writel(t, t->etm_regs_count, 0x441, ETMR_CTRL);
        etm_writel(t, t->etm_regs_count, new_count, ETMR_TRACEIDR);
        etm_lock(t, t->etm_regs_count);
@@ -781,10 +789,15 @@ static int etm_probe(struct amba_device *dev, const struct amba_id *id)
        if (ret)
                dev_dbg(&dev->dev, "Failed to create trace_range in sysfs\n");
 
-       ret = sysfs_create_file(&dev->dev.kobj, &trace_data_range_attr.attr);
-       if (ret)
-               dev_dbg(&dev->dev,
-                       "Failed to create trace_data_range in sysfs\n");
+       if (etm_version < ETMIDR_VERSION_PFT_1_0) {
+               ret = sysfs_create_file(&dev->dev.kobj,
+                                       &trace_data_range_attr.attr);
+               if (ret)
+                       dev_dbg(&dev->dev,
+                               "Failed to create trace_data_range in sysfs\n");
+       } else {
+               tracer.flags &= ~TRACER_TRACE_DATA;
+       }
 
        dev_dbg(&dev->dev, "ETM AMBA driver initialized.\n");