Skip to content

Commit 5898244

Browse files
Tao ZhangSuzuki K Poulose
authored andcommitted
coresight-tpdm: Add nodes to configure pattern match output
Add nodes to configure trigger pattern and trigger pattern mask. Each DSB subunit TPDM has maximum of n(n<7) XPR registers to configure trigger pattern match output. Eight 32 bit registers providing DSB interface trigger output pattern match comparison. And each DSB subunit TPDM has maximum of m(m<7) XPMR registers to configure trigger pattern mask match output. Eight 32 bit registers providing DSB interface trigger output pattern match mask. Signed-off-by: Tao Zhang <quic_taozha@quicinc.com> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Link: https://lore.kernel.org/r/1695882586-10306-11-git-send-email-quic_taozha@quicinc.com
1 parent dd60b99 commit 5898244

3 files changed

Lines changed: 126 additions & 2 deletions

File tree

Documentation/ABI/testing/sysfs-bus-coresight-devices-tpdm

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,20 @@ Date: March 2023
107107
KernelVersion 6.7
108108
Contact: Jinlong Mao (QUIC) <quic_jinlmao@quicinc.com>, Tao Zhang (QUIC) <quic_taozha@quicinc.com>
109109
Description:
110-
Read a set of the edge control mask of the DSB in TPDM.
110+
Read a set of the edge control mask of the DSB in TPDM.
111+
112+
What: /sys/bus/coresight/devices/<tpdm-name>/dsb_trig_patt/xpr[0:7]
113+
Date: March 2023
114+
KernelVersion 6.7
115+
Contact: Jinlong Mao (QUIC) <quic_jinlmao@quicinc.com>, Tao Zhang (QUIC) <quic_taozha@quicinc.com>
116+
Description:
117+
(RW) Set/Get the value of the trigger pattern for the DSB
118+
subunit TPDM.
119+
120+
What: /sys/bus/coresight/devices/<tpdm-name>/dsb_trig_patt/xpmr[0:7]
121+
Date: March 2023
122+
KernelVersion 6.7
123+
Contact: Jinlong Mao (QUIC) <quic_jinlmao@quicinc.com>, Tao Zhang (QUIC) <quic_taozha@quicinc.com>
124+
Description:
125+
(RW) Set/Get the mask of the trigger pattern for the DSB
126+
subunit TPDM.

drivers/hwtracing/coresight/coresight-tpdm.c

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,58 @@ static ssize_t tpdm_simple_dataset_show(struct device *dev,
4141
return -EINVAL;
4242
return sysfs_emit(buf, "0x%x\n",
4343
drvdata->dsb->edge_ctrl_mask[tpdm_attr->idx]);
44+
case DSB_TRIG_PATT:
45+
if (tpdm_attr->idx >= TPDM_DSB_MAX_PATT)
46+
return -EINVAL;
47+
return sysfs_emit(buf, "0x%x\n",
48+
drvdata->dsb->trig_patt[tpdm_attr->idx]);
49+
case DSB_TRIG_PATT_MASK:
50+
if (tpdm_attr->idx >= TPDM_DSB_MAX_PATT)
51+
return -EINVAL;
52+
return sysfs_emit(buf, "0x%x\n",
53+
drvdata->dsb->trig_patt_mask[tpdm_attr->idx]);
4454
}
4555
return -EINVAL;
4656
}
4757

58+
/* Write dataset array member with the index number */
59+
static ssize_t tpdm_simple_dataset_store(struct device *dev,
60+
struct device_attribute *attr,
61+
const char *buf,
62+
size_t size)
63+
{
64+
unsigned long val;
65+
ssize_t ret = size;
66+
67+
struct tpdm_drvdata *drvdata = dev_get_drvdata(dev->parent);
68+
struct tpdm_dataset_attribute *tpdm_attr =
69+
container_of(attr, struct tpdm_dataset_attribute, attr);
70+
71+
if (kstrtoul(buf, 0, &val))
72+
return -EINVAL;
73+
74+
spin_lock(&drvdata->spinlock);
75+
switch (tpdm_attr->mem) {
76+
case DSB_TRIG_PATT:
77+
if (tpdm_attr->idx < TPDM_DSB_MAX_PATT)
78+
drvdata->dsb->trig_patt[tpdm_attr->idx] = val;
79+
else
80+
ret = -EINVAL;
81+
break;
82+
case DSB_TRIG_PATT_MASK:
83+
if (tpdm_attr->idx < TPDM_DSB_MAX_PATT)
84+
drvdata->dsb->trig_patt_mask[tpdm_attr->idx] = val;
85+
else
86+
ret = -EINVAL;
87+
break;
88+
default:
89+
ret = -EINVAL;
90+
}
91+
spin_unlock(&drvdata->spinlock);
92+
93+
return ret;
94+
}
95+
4896
static bool tpdm_has_dsb_dataset(struct tpdm_drvdata *drvdata)
4997
{
5098
return (drvdata->datasets & TPDM_PIDR0_DS_DSB);
@@ -103,7 +151,12 @@ static void tpdm_enable_dsb(struct tpdm_drvdata *drvdata)
103151
for (i = 0; i < TPDM_DSB_MAX_EDCMR; i++)
104152
writel_relaxed(drvdata->dsb->edge_ctrl_mask[i],
105153
drvdata->base + TPDM_DSB_EDCMR(i));
106-
154+
for (i = 0; i < TPDM_DSB_MAX_PATT; i++) {
155+
writel_relaxed(drvdata->dsb->trig_patt[i],
156+
drvdata->base + TPDM_DSB_XPR(i));
157+
writel_relaxed(drvdata->dsb->trig_patt_mask[i],
158+
drvdata->base + TPDM_DSB_XPMR(i));
159+
}
107160
val = readl_relaxed(drvdata->base + TPDM_DSB_TIER);
108161
/* Set trigger timestamp */
109162
if (drvdata->dsb->trig_ts)
@@ -532,6 +585,26 @@ static struct attribute *tpdm_dsb_edge_attrs[] = {
532585
NULL,
533586
};
534587

588+
static struct attribute *tpdm_dsb_trig_patt_attrs[] = {
589+
DSB_TRIG_PATT_ATTR(0),
590+
DSB_TRIG_PATT_ATTR(1),
591+
DSB_TRIG_PATT_ATTR(2),
592+
DSB_TRIG_PATT_ATTR(3),
593+
DSB_TRIG_PATT_ATTR(4),
594+
DSB_TRIG_PATT_ATTR(5),
595+
DSB_TRIG_PATT_ATTR(6),
596+
DSB_TRIG_PATT_ATTR(7),
597+
DSB_TRIG_PATT_MASK_ATTR(0),
598+
DSB_TRIG_PATT_MASK_ATTR(1),
599+
DSB_TRIG_PATT_MASK_ATTR(2),
600+
DSB_TRIG_PATT_MASK_ATTR(3),
601+
DSB_TRIG_PATT_MASK_ATTR(4),
602+
DSB_TRIG_PATT_MASK_ATTR(5),
603+
DSB_TRIG_PATT_MASK_ATTR(6),
604+
DSB_TRIG_PATT_MASK_ATTR(7),
605+
NULL,
606+
};
607+
535608
static struct attribute *tpdm_dsb_attrs[] = {
536609
&dev_attr_dsb_mode.attr,
537610
&dev_attr_dsb_trig_ts.attr,
@@ -550,10 +623,17 @@ static struct attribute_group tpdm_dsb_edge_grp = {
550623
.name = "dsb_edge",
551624
};
552625

626+
static struct attribute_group tpdm_dsb_trig_patt_grp = {
627+
.attrs = tpdm_dsb_trig_patt_attrs,
628+
.is_visible = tpdm_dsb_is_visible,
629+
.name = "dsb_trig_patt",
630+
};
631+
553632
static const struct attribute_group *tpdm_attr_grps[] = {
554633
&tpdm_attr_grp,
555634
&tpdm_dsb_attr_grp,
556635
&tpdm_dsb_edge_grp,
636+
&tpdm_dsb_trig_patt_grp,
557637
NULL,
558638
};
559639

drivers/hwtracing/coresight/coresight-tpdm.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
/* DSB Subunit Registers */
1313
#define TPDM_DSB_CR (0x780)
1414
#define TPDM_DSB_TIER (0x784)
15+
#define TPDM_DSB_XPR(n) (0x7C8 + (n * 4))
16+
#define TPDM_DSB_XPMR(n) (0x7E8 + (n * 4))
1517
#define TPDM_DSB_EDCR(n) (0x808 + (n * 4))
1618
#define TPDM_DSB_EDCMR(n) (0x848 + (n * 4))
1719

@@ -80,6 +82,8 @@
8082
#define TPDM_DSB_MAX_EDCR 16
8183
/* MAX number of EDCMR registers */
8284
#define TPDM_DSB_MAX_EDCMR 8
85+
/* MAX number of DSB pattern */
86+
#define TPDM_DSB_MAX_PATT 8
8387

8488
#define tpdm_simple_dataset_ro(name, mem, idx) \
8589
(&((struct tpdm_dataset_attribute[]) { \
@@ -90,6 +94,16 @@
9094
} \
9195
})[0].attr.attr)
9296

97+
#define tpdm_simple_dataset_rw(name, mem, idx) \
98+
(&((struct tpdm_dataset_attribute[]) { \
99+
{ \
100+
__ATTR(name, 0644, tpdm_simple_dataset_show, \
101+
tpdm_simple_dataset_store), \
102+
mem, \
103+
idx, \
104+
} \
105+
})[0].attr.attr)
106+
93107
#define DSB_EDGE_CTRL_ATTR(nr) \
94108
tpdm_simple_dataset_ro(edcr##nr, \
95109
DSB_EDGE_CTRL, nr)
@@ -98,12 +112,22 @@
98112
tpdm_simple_dataset_ro(edcmr##nr, \
99113
DSB_EDGE_CTRL_MASK, nr)
100114

115+
#define DSB_TRIG_PATT_ATTR(nr) \
116+
tpdm_simple_dataset_rw(xpr##nr, \
117+
DSB_TRIG_PATT, nr)
118+
119+
#define DSB_TRIG_PATT_MASK_ATTR(nr) \
120+
tpdm_simple_dataset_rw(xpmr##nr, \
121+
DSB_TRIG_PATT_MASK, nr)
122+
101123
/**
102124
* struct dsb_dataset - specifics associated to dsb dataset
103125
* @mode: DSB programming mode
104126
* @edge_ctrl_idx Index number of the edge control
105127
* @edge_ctrl: Save value for edge control
106128
* @edge_ctrl_mask: Save value for edge control mask
129+
* @trig_patt: Save value for trigger pattern
130+
* @trig_patt_mask: Save value for trigger pattern mask
107131
* @trig_ts: Enable/Disable trigger timestamp.
108132
* @trig_type: Enable/Disable trigger type.
109133
*/
@@ -112,6 +136,8 @@ struct dsb_dataset {
112136
u32 edge_ctrl_idx;
113137
u32 edge_ctrl[TPDM_DSB_MAX_EDCR];
114138
u32 edge_ctrl_mask[TPDM_DSB_MAX_EDCMR];
139+
u32 trig_patt[TPDM_DSB_MAX_PATT];
140+
u32 trig_patt_mask[TPDM_DSB_MAX_PATT];
115141
bool trig_ts;
116142
bool trig_type;
117143
};
@@ -141,6 +167,8 @@ struct tpdm_drvdata {
141167
enum dataset_mem {
142168
DSB_EDGE_CTRL,
143169
DSB_EDGE_CTRL_MASK,
170+
DSB_TRIG_PATT,
171+
DSB_TRIG_PATT_MASK,
144172
};
145173

146174
/**

0 commit comments

Comments
 (0)