Skip to content

Commit ee39dbe

Browse files
Mao JinlongSuzuki K Poulose
authored andcommitted
coresight-tpdm: Add MCMB dataset support
MCMB (Multi-lane CMB) is a special form of CMB dataset type. MCMB subunit TPDM has the same number and usage of registers as CMB subunit TPDM. MCMB subunit can be enabled for data collection by writing 1 to the first bit of CMB_CR register. The difference is that MCMB subunit TPDM needs to select the lane and enable it in using it. Signed-off-by: Tao Zhang <[email protected]> Signed-off-by: Mao Jinlong <[email protected]> Signed-off-by: Suzuki K Poulose <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 4ff6039 commit ee39dbe

File tree

3 files changed

+54
-20
lines changed

3 files changed

+54
-20
lines changed

drivers/hwtracing/coresight/coresight-tpda.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0
22
/*
3-
* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
3+
* Copyright (c) 2023-2025 Qualcomm Innovation Center, Inc. All rights reserved.
44
*/
55

66
#include <linux/amba/bus.h>
@@ -68,11 +68,12 @@ static int tpdm_read_element_size(struct tpda_drvdata *drvdata,
6868
int rc = -EINVAL;
6969
struct tpdm_drvdata *tpdm_data = dev_get_drvdata(csdev->dev.parent);
7070

71-
if (tpdm_has_dsb_dataset(tpdm_data)) {
71+
if (tpdm_data->dsb) {
7272
rc = fwnode_property_read_u32(dev_fwnode(csdev->dev.parent),
7373
"qcom,dsb-element-bits", &drvdata->dsb_esize);
7474
}
75-
if (tpdm_has_cmb_dataset(tpdm_data)) {
75+
76+
if (tpdm_data->cmb) {
7677
rc = fwnode_property_read_u32(dev_fwnode(csdev->dev.parent),
7778
"qcom,cmb-element-bits", &drvdata->cmb_esize);
7879
}

drivers/hwtracing/coresight/coresight-tpdm.c

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0
22
/*
3-
* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
3+
* Copyright (c) 2023-2025 Qualcomm Innovation Center, Inc. All rights reserved.
44
*/
55

66
#include <linux/amba/bus.h>
@@ -21,6 +21,21 @@
2121

2222
DEFINE_CORESIGHT_DEVLIST(tpdm_devs, "tpdm");
2323

24+
static bool tpdm_has_dsb_dataset(struct tpdm_drvdata *drvdata)
25+
{
26+
return (drvdata->datasets & TPDM_PIDR0_DS_DSB);
27+
}
28+
29+
static bool tpdm_has_cmb_dataset(struct tpdm_drvdata *drvdata)
30+
{
31+
return (drvdata->datasets & TPDM_PIDR0_DS_CMB);
32+
}
33+
34+
static bool tpdm_has_mcmb_dataset(struct tpdm_drvdata *drvdata)
35+
{
36+
return (drvdata->datasets & TPDM_PIDR0_DS_MCMB);
37+
}
38+
2439
/* Read dataset array member with the index number */
2540
static ssize_t tpdm_simple_dataset_show(struct device *dev,
2641
struct device_attribute *attr,
@@ -198,7 +213,7 @@ static umode_t tpdm_cmb_is_visible(struct kobject *kobj,
198213
struct device *dev = kobj_to_dev(kobj);
199214
struct tpdm_drvdata *drvdata = dev_get_drvdata(dev->parent);
200215

201-
if (drvdata && tpdm_has_cmb_dataset(drvdata))
216+
if (drvdata && drvdata->cmb)
202217
return attr->mode;
203218

204219
return 0;
@@ -388,7 +403,7 @@ static void tpdm_enable_cmb(struct tpdm_drvdata *drvdata)
388403
{
389404
u32 val, i;
390405

391-
if (!tpdm_has_cmb_dataset(drvdata))
406+
if (!drvdata->cmb)
392407
return;
393408

394409
/* Configure pattern registers */
@@ -415,6 +430,19 @@ static void tpdm_enable_cmb(struct tpdm_drvdata *drvdata)
415430
val |= TPDM_CMB_CR_MODE;
416431
else
417432
val &= ~TPDM_CMB_CR_MODE;
433+
434+
if (tpdm_has_mcmb_dataset(drvdata)) {
435+
val &= ~TPDM_CMB_CR_XTRIG_LNSEL;
436+
/* Set the lane participates in the output pattern */
437+
val |= FIELD_PREP(TPDM_CMB_CR_XTRIG_LNSEL,
438+
drvdata->cmb->mcmb.trig_lane);
439+
440+
/* Set the enablement of the lane */
441+
val &= ~TPDM_CMB_CR_E_LN;
442+
val |= FIELD_PREP(TPDM_CMB_CR_E_LN,
443+
drvdata->cmb->mcmb.lane_select);
444+
}
445+
418446
/* Set the enable bit of CMB control register to 1 */
419447
val |= TPDM_CMB_CR_ENA;
420448
writel_relaxed(val, drvdata->base + TPDM_CMB_CR);
@@ -480,7 +508,7 @@ static void tpdm_disable_cmb(struct tpdm_drvdata *drvdata)
480508
{
481509
u32 val;
482510

483-
if (!tpdm_has_cmb_dataset(drvdata))
511+
if (!drvdata->cmb)
484512
return;
485513

486514
val = readl_relaxed(drvdata->base + TPDM_CMB_CR);
@@ -542,12 +570,14 @@ static int tpdm_datasets_setup(struct tpdm_drvdata *drvdata)
542570
if (!drvdata->dsb)
543571
return -ENOMEM;
544572
}
545-
if (tpdm_has_cmb_dataset(drvdata) && (!drvdata->cmb)) {
573+
if ((tpdm_has_cmb_dataset(drvdata) || tpdm_has_mcmb_dataset(drvdata))
574+
&& (!drvdata->cmb)) {
546575
drvdata->cmb = devm_kzalloc(drvdata->dev,
547576
sizeof(*drvdata->cmb), GFP_KERNEL);
548577
if (!drvdata->cmb)
549578
return -ENOMEM;
550579
}
580+
551581
tpdm_reset_datasets(drvdata);
552582

553583
return 0;

drivers/hwtracing/coresight/coresight-tpdm.h

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
22
/*
3-
* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
3+
* Copyright (c) 2023-2025 Qualcomm Innovation Center, Inc. All rights reserved.
44
*/
55

66
#ifndef _CORESIGHT_CORESIGHT_TPDM_H
@@ -9,7 +9,7 @@
99
/* The max number of the datasets that TPDM supports */
1010
#define TPDM_DATASETS 7
1111

12-
/* CMB Subunit Registers */
12+
/* CMB/MCMB Subunit Registers */
1313
#define TPDM_CMB_CR (0xA00)
1414
/* CMB subunit timestamp insertion enable register */
1515
#define TPDM_CMB_TIER (0xA04)
@@ -28,6 +28,10 @@
2828
#define TPDM_CMB_CR_ENA BIT(0)
2929
/* Trace collection mode for CMB subunit */
3030
#define TPDM_CMB_CR_MODE BIT(1)
31+
/* MCMB trigger lane select */
32+
#define TPDM_CMB_CR_XTRIG_LNSEL GENMASK(20, 18)
33+
/* MCMB lane enablement */
34+
#define TPDM_CMB_CR_E_LN GENMASK(17, 10)
3135
/* Timestamp control for pattern match */
3236
#define TPDM_CMB_TIER_PATT_TSENAB BIT(0)
3337
/* CMB CTI timestamp request */
@@ -112,11 +116,13 @@
112116
* PERIPHIDR0[0] : Fix to 1 if ImplDef subunit present, else 0
113117
* PERIPHIDR0[1] : Fix to 1 if DSB subunit present, else 0
114118
* PERIPHIDR0[2] : Fix to 1 if CMB subunit present, else 0
119+
* PERIPHIDR0[6] : Fix to 1 if MCMB subunit present, else 0
115120
*/
116121

117122
#define TPDM_PIDR0_DS_IMPDEF BIT(0)
118123
#define TPDM_PIDR0_DS_DSB BIT(1)
119124
#define TPDM_PIDR0_DS_CMB BIT(2)
125+
#define TPDM_PIDR0_DS_MCMB BIT(6)
120126

121127
#define TPDM_DSB_MAX_LINES 256
122128
/* MAX number of EDCR registers */
@@ -256,6 +262,9 @@ struct dsb_dataset {
256262
* @patt_ts: Indicates if pattern match for timestamp is enabled.
257263
* @trig_ts: Indicates if CTI trigger for timestamp is enabled.
258264
* @ts_all: Indicates if timestamp is enabled for all packets.
265+
* struct mcmb_dataset
266+
* @mcmb_trig_lane: Save data for trigger lane
267+
* @mcmb_lane_select: Save data for lane enablement
259268
*/
260269
struct cmb_dataset {
261270
u32 trace_mode;
@@ -267,6 +276,10 @@ struct cmb_dataset {
267276
bool patt_ts;
268277
bool trig_ts;
269278
bool ts_all;
279+
struct {
280+
u8 trig_lane;
281+
u8 lane_select;
282+
} mcmb;
270283
};
271284

272285
/**
@@ -324,14 +337,4 @@ struct tpdm_dataset_attribute {
324337
enum dataset_mem mem;
325338
u32 idx;
326339
};
327-
328-
static bool tpdm_has_dsb_dataset(struct tpdm_drvdata *drvdata)
329-
{
330-
return (drvdata->datasets & TPDM_PIDR0_DS_DSB);
331-
}
332-
333-
static bool tpdm_has_cmb_dataset(struct tpdm_drvdata *drvdata)
334-
{
335-
return (drvdata->datasets & TPDM_PIDR0_DS_CMB);
336-
}
337340
#endif /* _CORESIGHT_CORESIGHT_TPDM_H */

0 commit comments

Comments
 (0)