Skip to content

Commit 03f0ff5

Browse files
Tao ZhangSuzuki K Poulose
authored andcommitted
coresight-tpdm: Initialize DSB subunit configuration
DSB is used for monitoring “events”. Events are something that occurs at some point in time. It could be a state decode, the act of writing/reading a particular address, a FIFO being empty, etc. This decoding of the event desired is done outside TPDM. DSB subunit need to be configured in enablement and disablement. A struct that specifics associated to dsb dataset is needed. It saves the configuration and parameters of the dsb datasets. This change is to add this struct and initialize the configuration of DSB subunit. 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-6-git-send-email-quic_taozha@quicinc.com
1 parent 18e176f commit 03f0ff5

2 files changed

Lines changed: 74 additions & 8 deletions

File tree

drivers/hwtracing/coresight/coresight-tpdm.c

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,57 @@
2020

2121
DEFINE_CORESIGHT_DEVLIST(tpdm_devs, "tpdm");
2222

23+
static bool tpdm_has_dsb_dataset(struct tpdm_drvdata *drvdata)
24+
{
25+
return (drvdata->datasets & TPDM_PIDR0_DS_DSB);
26+
}
27+
28+
static void tpdm_reset_datasets(struct tpdm_drvdata *drvdata)
29+
{
30+
if (tpdm_has_dsb_dataset(drvdata)) {
31+
memset(drvdata->dsb, 0, sizeof(struct dsb_dataset));
32+
33+
drvdata->dsb->trig_ts = true;
34+
drvdata->dsb->trig_type = false;
35+
}
36+
}
37+
2338
static void tpdm_enable_dsb(struct tpdm_drvdata *drvdata)
2439
{
2540
u32 val;
2641

27-
/* Set the enable bit of DSB control register to 1 */
42+
val = readl_relaxed(drvdata->base + TPDM_DSB_TIER);
43+
/* Set trigger timestamp */
44+
if (drvdata->dsb->trig_ts)
45+
val |= TPDM_DSB_TIER_XTRIG_TSENAB;
46+
else
47+
val &= ~TPDM_DSB_TIER_XTRIG_TSENAB;
48+
writel_relaxed(val, drvdata->base + TPDM_DSB_TIER);
49+
2850
val = readl_relaxed(drvdata->base + TPDM_DSB_CR);
51+
/* Set trigger type */
52+
if (drvdata->dsb->trig_type)
53+
val |= TPDM_DSB_CR_TRIG_TYPE;
54+
else
55+
val &= ~TPDM_DSB_CR_TRIG_TYPE;
56+
/* Set the enable bit of DSB control register to 1 */
2957
val |= TPDM_DSB_CR_ENA;
3058
writel_relaxed(val, drvdata->base + TPDM_DSB_CR);
3159
}
3260

33-
/* TPDM enable operations */
61+
/*
62+
* TPDM enable operations
63+
* The TPDM or Monitor serves as data collection component for various
64+
* dataset types. It covers Basic Counts(BC), Tenure Counts(TC),
65+
* Continuous Multi-Bit(CMB), Multi-lane CMB(MCMB) and Discrete Single
66+
* Bit(DSB). This function will initialize the configuration according
67+
* to the dataset type supported by the TPDM.
68+
*/
3469
static void __tpdm_enable(struct tpdm_drvdata *drvdata)
3570
{
3671
CS_UNLOCK(drvdata->base);
3772

38-
/* Check if DSB datasets is present for TPDM. */
39-
if (drvdata->datasets & TPDM_PIDR0_DS_DSB)
73+
if (tpdm_has_dsb_dataset(drvdata))
4074
tpdm_enable_dsb(drvdata);
4175

4276
CS_LOCK(drvdata->base);
@@ -76,8 +110,7 @@ static void __tpdm_disable(struct tpdm_drvdata *drvdata)
76110
{
77111
CS_UNLOCK(drvdata->base);
78112

79-
/* Check if DSB datasets is present for TPDM. */
80-
if (drvdata->datasets & TPDM_PIDR0_DS_DSB)
113+
if (tpdm_has_dsb_dataset(drvdata))
81114
tpdm_disable_dsb(drvdata);
82115

83116
CS_LOCK(drvdata->base);
@@ -110,13 +143,23 @@ static const struct coresight_ops tpdm_cs_ops = {
110143
.source_ops = &tpdm_source_ops,
111144
};
112145

113-
static void tpdm_init_default_data(struct tpdm_drvdata *drvdata)
146+
static int tpdm_datasets_setup(struct tpdm_drvdata *drvdata)
114147
{
115148
u32 pidr;
116149

117150
/* Get the datasets present on the TPDM. */
118151
pidr = readl_relaxed(drvdata->base + CORESIGHT_PERIPHIDR0);
119152
drvdata->datasets |= pidr & GENMASK(TPDM_DATASETS - 1, 0);
153+
154+
if (tpdm_has_dsb_dataset(drvdata) && (!drvdata->dsb)) {
155+
drvdata->dsb = devm_kzalloc(drvdata->dev,
156+
sizeof(*drvdata->dsb), GFP_KERNEL);
157+
if (!drvdata->dsb)
158+
return -ENOMEM;
159+
}
160+
tpdm_reset_datasets(drvdata);
161+
162+
return 0;
120163
}
121164

122165
/*
@@ -179,6 +222,7 @@ static int tpdm_probe(struct amba_device *adev, const struct amba_id *id)
179222
struct coresight_platform_data *pdata;
180223
struct tpdm_drvdata *drvdata;
181224
struct coresight_desc desc = { 0 };
225+
int ret;
182226

183227
pdata = coresight_get_platform_data(dev);
184228
if (IS_ERR(pdata))
@@ -198,6 +242,10 @@ static int tpdm_probe(struct amba_device *adev, const struct amba_id *id)
198242

199243
drvdata->base = base;
200244

245+
ret = tpdm_datasets_setup(drvdata);
246+
if (ret)
247+
return ret;
248+
201249
/* Set up coresight component description */
202250
desc.name = coresight_alloc_device_name(&tpdm_devs, dev);
203251
if (!desc.name)
@@ -214,7 +262,7 @@ static int tpdm_probe(struct amba_device *adev, const struct amba_id *id)
214262
return PTR_ERR(drvdata->csdev);
215263

216264
spin_lock_init(&drvdata->spinlock);
217-
tpdm_init_default_data(drvdata);
265+
218266
/* Decrease pm refcount when probe is done.*/
219267
pm_runtime_put(&adev->dev);
220268

drivers/hwtracing/coresight/coresight-tpdm.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,14 @@
1111

1212
/* DSB Subunit Registers */
1313
#define TPDM_DSB_CR (0x780)
14+
#define TPDM_DSB_TIER (0x784)
15+
1416
/* Enable bit for DSB subunit */
1517
#define TPDM_DSB_CR_ENA BIT(0)
18+
/* Enable bit for DSB subunit trigger type */
19+
#define TPDM_DSB_CR_TRIG_TYPE BIT(12)
20+
/* Enable bit for DSB subunit trigger timestamp */
21+
#define TPDM_DSB_TIER_XTRIG_TSENAB BIT(1)
1622

1723
/* TPDM integration test registers */
1824
#define TPDM_ITATBCNTRL (0xEF0)
@@ -40,6 +46,16 @@
4046
#define TPDM_PIDR0_DS_IMPDEF BIT(0)
4147
#define TPDM_PIDR0_DS_DSB BIT(1)
4248

49+
/**
50+
* struct dsb_dataset - specifics associated to dsb dataset
51+
* @trig_ts: Enable/Disable trigger timestamp.
52+
* @trig_type: Enable/Disable trigger type.
53+
*/
54+
struct dsb_dataset {
55+
bool trig_ts;
56+
bool trig_type;
57+
};
58+
4359
/**
4460
* struct tpdm_drvdata - specifics associated to an TPDM component
4561
* @base: memory mapped base address for this component.
@@ -48,6 +64,7 @@
4864
* @spinlock: lock for the drvdata value.
4965
* @enable: enable status of the component.
5066
* @datasets: The datasets types present of the TPDM.
67+
* @dsb Specifics associated to TPDM DSB.
5168
*/
5269

5370
struct tpdm_drvdata {
@@ -57,6 +74,7 @@ struct tpdm_drvdata {
5774
spinlock_t spinlock;
5875
bool enable;
5976
unsigned long datasets;
77+
struct dsb_dataset *dsb;
6078
};
6179

6280
#endif /* _CORESIGHT_CORESIGHT_TPDM_H */

0 commit comments

Comments
 (0)