Skip to content

Commit 90a7371

Browse files
Tao ZhangSuzuki K Poulose
authored andcommitted
coresight-tpdm: Add nodes for dsb msr support
Add the nodes for DSB subunit MSR(mux select register) support. The TPDM MSR (mux select register) interface is an optional interface and associated bank of registers per TPDM subunit. The intent of mux select registers is to control muxing structures driving the TPDM’s’ various subunit interfaces. 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-14-git-send-email-quic_taozha@quicinc.com
1 parent 20dab0f commit 90a7371

3 files changed

Lines changed: 105 additions & 0 deletions

File tree

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,11 @@ Description:
162162
Accepts only one of the 2 values - 0 or 1.
163163
0 : Set the DSB pattern type to value.
164164
1 : Set the DSB pattern type to toggle.
165+
166+
What: /sys/bus/coresight/devices/<tpdm-name>/dsb_msr/msr[0:31]
167+
Date: March 2023
168+
KernelVersion 6.7
169+
Contact: Jinlong Mao (QUIC) <quic_jinlmao@quicinc.com>, Tao Zhang (QUIC) <quic_taozha@quicinc.com>
170+
Description:
171+
(RW) Set/Get the MSR(mux select register) for the DSB subunit
172+
TPDM.

drivers/hwtracing/coresight/coresight-tpdm.c

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ static ssize_t tpdm_simple_dataset_show(struct device *dev,
6161
return -EINVAL;
6262
return sysfs_emit(buf, "0x%x\n",
6363
drvdata->dsb->patt_mask[tpdm_attr->idx]);
64+
case DSB_MSR:
65+
if (tpdm_attr->idx >= drvdata->dsb_msr_num)
66+
return -EINVAL;
67+
return sysfs_emit(buf, "0x%x\n",
68+
drvdata->dsb->msr[tpdm_attr->idx]);
6469
}
6570
return -EINVAL;
6671
}
@@ -107,6 +112,12 @@ static ssize_t tpdm_simple_dataset_store(struct device *dev,
107112
else
108113
ret = -EINVAL;
109114
break;
115+
case DSB_MSR:
116+
if (tpdm_attr->idx < drvdata->dsb_msr_num)
117+
drvdata->dsb->msr[tpdm_attr->idx] = val;
118+
else
119+
ret = -EINVAL;
120+
break;
110121
default:
111122
ret = -EINVAL;
112123
}
@@ -132,6 +143,22 @@ static umode_t tpdm_dsb_is_visible(struct kobject *kobj,
132143
return 0;
133144
}
134145

146+
static umode_t tpdm_dsb_msr_is_visible(struct kobject *kobj,
147+
struct attribute *attr, int n)
148+
{
149+
struct device *dev = kobj_to_dev(kobj);
150+
struct tpdm_drvdata *drvdata = dev_get_drvdata(dev->parent);
151+
struct device_attribute *dev_attr =
152+
container_of(attr, struct device_attribute, attr);
153+
struct tpdm_dataset_attribute *tpdm_attr =
154+
container_of(dev_attr, struct tpdm_dataset_attribute, attr);
155+
156+
if (tpdm_attr->idx < drvdata->dsb_msr_num)
157+
return attr->mode;
158+
159+
return 0;
160+
}
161+
135162
static void tpdm_reset_datasets(struct tpdm_drvdata *drvdata)
136163
{
137164
if (tpdm_has_dsb_dataset(drvdata)) {
@@ -193,6 +220,15 @@ static void set_dsb_tier(struct tpdm_drvdata *drvdata)
193220
writel_relaxed(val, drvdata->base + TPDM_DSB_TIER);
194221
}
195222

223+
static void set_dsb_msr(struct tpdm_drvdata *drvdata)
224+
{
225+
int i;
226+
227+
for (i = 0; i < drvdata->dsb_msr_num; i++)
228+
writel_relaxed(drvdata->dsb->msr[i],
229+
drvdata->base + TPDM_DSB_MSR(i));
230+
}
231+
196232
static void tpdm_enable_dsb(struct tpdm_drvdata *drvdata)
197233
{
198234
u32 val, i;
@@ -216,6 +252,8 @@ static void tpdm_enable_dsb(struct tpdm_drvdata *drvdata)
216252

217253
set_dsb_tier(drvdata);
218254

255+
set_dsb_msr(drvdata);
256+
219257
val = readl_relaxed(drvdata->base + TPDM_DSB_CR);
220258
/* Set the mode of DSB dataset */
221259
set_dsb_mode(drvdata, &val);
@@ -739,6 +777,42 @@ static struct attribute *tpdm_dsb_patt_attrs[] = {
739777
NULL,
740778
};
741779

780+
static struct attribute *tpdm_dsb_msr_attrs[] = {
781+
DSB_MSR_ATTR(0),
782+
DSB_MSR_ATTR(1),
783+
DSB_MSR_ATTR(2),
784+
DSB_MSR_ATTR(3),
785+
DSB_MSR_ATTR(4),
786+
DSB_MSR_ATTR(5),
787+
DSB_MSR_ATTR(6),
788+
DSB_MSR_ATTR(7),
789+
DSB_MSR_ATTR(8),
790+
DSB_MSR_ATTR(9),
791+
DSB_MSR_ATTR(10),
792+
DSB_MSR_ATTR(11),
793+
DSB_MSR_ATTR(12),
794+
DSB_MSR_ATTR(13),
795+
DSB_MSR_ATTR(14),
796+
DSB_MSR_ATTR(15),
797+
DSB_MSR_ATTR(16),
798+
DSB_MSR_ATTR(17),
799+
DSB_MSR_ATTR(18),
800+
DSB_MSR_ATTR(19),
801+
DSB_MSR_ATTR(20),
802+
DSB_MSR_ATTR(21),
803+
DSB_MSR_ATTR(22),
804+
DSB_MSR_ATTR(23),
805+
DSB_MSR_ATTR(24),
806+
DSB_MSR_ATTR(25),
807+
DSB_MSR_ATTR(26),
808+
DSB_MSR_ATTR(27),
809+
DSB_MSR_ATTR(28),
810+
DSB_MSR_ATTR(29),
811+
DSB_MSR_ATTR(30),
812+
DSB_MSR_ATTR(31),
813+
NULL,
814+
};
815+
742816
static struct attribute *tpdm_dsb_attrs[] = {
743817
&dev_attr_dsb_mode.attr,
744818
&dev_attr_dsb_trig_ts.attr,
@@ -769,12 +843,19 @@ static struct attribute_group tpdm_dsb_patt_grp = {
769843
.name = "dsb_patt",
770844
};
771845

846+
static struct attribute_group tpdm_dsb_msr_grp = {
847+
.attrs = tpdm_dsb_msr_attrs,
848+
.is_visible = tpdm_dsb_msr_is_visible,
849+
.name = "dsb_msr",
850+
};
851+
772852
static const struct attribute_group *tpdm_attr_grps[] = {
773853
&tpdm_attr_grp,
774854
&tpdm_dsb_attr_grp,
775855
&tpdm_dsb_edge_grp,
776856
&tpdm_dsb_trig_patt_grp,
777857
&tpdm_dsb_patt_grp,
858+
&tpdm_dsb_msr_grp,
778859
NULL,
779860
};
780861

@@ -809,6 +890,10 @@ static int tpdm_probe(struct amba_device *adev, const struct amba_id *id)
809890
if (ret)
810891
return ret;
811892

893+
if (drvdata && tpdm_has_dsb_dataset(drvdata))
894+
of_property_read_u32(drvdata->dev->of_node,
895+
"qcom,dsb_msr_num", &drvdata->dsb_msr_num);
896+
812897
/* Set up coresight component description */
813898
desc.name = coresight_alloc_device_name(&tpdm_devs, dev);
814899
if (!desc.name)

drivers/hwtracing/coresight/coresight-tpdm.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#define TPDM_DSB_XPMR(n) (0x7E8 + (n * 4))
1919
#define TPDM_DSB_EDCR(n) (0x808 + (n * 4))
2020
#define TPDM_DSB_EDCMR(n) (0x848 + (n * 4))
21+
#define TPDM_DSB_MSR(n) (0x980 + (n * 4))
2122

2223
/* Enable bit for DSB subunit */
2324
#define TPDM_DSB_CR_ENA BIT(0)
@@ -90,6 +91,8 @@
9091
#define TPDM_DSB_MAX_EDCMR 8
9192
/* MAX number of DSB pattern */
9293
#define TPDM_DSB_MAX_PATT 8
94+
/* MAX number of DSB MSR */
95+
#define TPDM_DSB_MAX_MSR 32
9396

9497
#define tpdm_simple_dataset_ro(name, mem, idx) \
9598
(&((struct tpdm_dataset_attribute[]) { \
@@ -134,6 +137,10 @@
134137
tpdm_simple_dataset_rw(tpmr##nr, \
135138
DSB_PATT_MASK, nr)
136139

140+
#define DSB_MSR_ATTR(nr) \
141+
tpdm_simple_dataset_rw(msr##nr, \
142+
DSB_MSR, nr)
143+
137144
/**
138145
* struct dsb_dataset - specifics associated to dsb dataset
139146
* @mode: DSB programming mode
@@ -144,6 +151,7 @@
144151
* @patt_mask: Save value for pattern mask
145152
* @trig_patt: Save value for trigger pattern
146153
* @trig_patt_mask: Save value for trigger pattern mask
154+
* @msr Save value for MSR
147155
* @patt_ts: Enable/Disable pattern timestamp
148156
* @patt_type: Set pattern type
149157
* @trig_ts: Enable/Disable trigger timestamp.
@@ -158,6 +166,7 @@ struct dsb_dataset {
158166
u32 patt_mask[TPDM_DSB_MAX_PATT];
159167
u32 trig_patt[TPDM_DSB_MAX_PATT];
160168
u32 trig_patt_mask[TPDM_DSB_MAX_PATT];
169+
u32 msr[TPDM_DSB_MAX_MSR];
161170
bool patt_ts;
162171
bool patt_type;
163172
bool trig_ts;
@@ -173,6 +182,7 @@ struct dsb_dataset {
173182
* @enable: enable status of the component.
174183
* @datasets: The datasets types present of the TPDM.
175184
* @dsb Specifics associated to TPDM DSB.
185+
* @dsb_msr_num Number of MSR supported by DSB TPDM
176186
*/
177187

178188
struct tpdm_drvdata {
@@ -183,6 +193,7 @@ struct tpdm_drvdata {
183193
bool enable;
184194
unsigned long datasets;
185195
struct dsb_dataset *dsb;
196+
u32 dsb_msr_num;
186197
};
187198

188199
/* Enumerate members of various datasets */
@@ -193,6 +204,7 @@ enum dataset_mem {
193204
DSB_TRIG_PATT_MASK,
194205
DSB_PATT,
195206
DSB_PATT_MASK,
207+
DSB_MSR,
196208
};
197209

198210
/**

0 commit comments

Comments
 (0)