Skip to content

Commit 535d80d

Browse files
Tao ZhangSuzuki K Poulose
authored andcommitted
coresight-tpdm: Add node to set dsb programming mode
Add node to set and show programming mode for TPDM DSB subunit. Once the DSB programming mode is set, it will be written to the register DSB_CR. 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-9-git-send-email-quic_taozha@quicinc.com
1 parent c821b93 commit 535d80d

3 files changed

Lines changed: 86 additions & 0 deletions

File tree

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,17 @@ Description:
4343
Accepts only one of the 2 values - 0 or 1.
4444
0 : Set the DSB trigger type to false
4545
1 : Set the DSB trigger type to true
46+
47+
What: /sys/bus/coresight/devices/<tpdm-name>/dsb_mode
48+
Date: March 2023
49+
KernelVersion 6.7
50+
Contact: Jinlong Mao (QUIC) <quic_jinlmao@quicinc.com>, Tao Zhang (QUIC) <quic_taozha@quicinc.com>
51+
Description:
52+
(RW) Set/Get the programming mode of the DSB for tpdm.
53+
54+
Accepts the value needs to be greater than 0. What data
55+
bits do is listed below.
56+
Bit[0:1] : Test mode control bit for choosing the inputs.
57+
Bit[3] : Set to 0 for low performance mode.
58+
Set to 1 for high performance mode.
59+
Bit[4:8] : Select byte lane for high performance mode.

drivers/hwtracing/coresight/coresight-tpdm.c

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
#include <linux/amba/bus.h>
7+
#include <linux/bitfield.h>
78
#include <linux/bitmap.h>
89
#include <linux/coresight.h>
910
#include <linux/coresight-pmu.h>
@@ -47,6 +48,27 @@ static void tpdm_reset_datasets(struct tpdm_drvdata *drvdata)
4748
}
4849
}
4950

51+
static void set_dsb_mode(struct tpdm_drvdata *drvdata, u32 *val)
52+
{
53+
u32 mode;
54+
55+
/* Set the test accurate mode */
56+
mode = TPDM_DSB_MODE_TEST(drvdata->dsb->mode);
57+
*val &= ~TPDM_DSB_CR_TEST_MODE;
58+
*val |= FIELD_PREP(TPDM_DSB_CR_TEST_MODE, mode);
59+
60+
/* Set the byte lane for high-performance mode */
61+
mode = TPDM_DSB_MODE_HPBYTESEL(drvdata->dsb->mode);
62+
*val &= ~TPDM_DSB_CR_HPSEL;
63+
*val |= FIELD_PREP(TPDM_DSB_CR_HPSEL, mode);
64+
65+
/* Set the performance mode */
66+
if (drvdata->dsb->mode & TPDM_DSB_MODE_PERF)
67+
*val |= TPDM_DSB_CR_MODE;
68+
else
69+
*val &= ~TPDM_DSB_CR_MODE;
70+
}
71+
5072
static void tpdm_enable_dsb(struct tpdm_drvdata *drvdata)
5173
{
5274
u32 val;
@@ -60,6 +82,8 @@ static void tpdm_enable_dsb(struct tpdm_drvdata *drvdata)
6082
writel_relaxed(val, drvdata->base + TPDM_DSB_TIER);
6183

6284
val = readl_relaxed(drvdata->base + TPDM_DSB_CR);
85+
/* Set the mode of DSB dataset */
86+
set_dsb_mode(drvdata, &val);
6387
/* Set trigger type */
6488
if (drvdata->dsb->trig_type)
6589
val |= TPDM_DSB_CR_TRIG_TYPE;
@@ -244,6 +268,34 @@ static struct attribute_group tpdm_attr_grp = {
244268
.attrs = tpdm_attrs,
245269
};
246270

271+
static ssize_t dsb_mode_show(struct device *dev,
272+
struct device_attribute *attr,
273+
char *buf)
274+
{
275+
struct tpdm_drvdata *drvdata = dev_get_drvdata(dev->parent);
276+
277+
return sysfs_emit(buf, "%x\n", drvdata->dsb->mode);
278+
}
279+
280+
static ssize_t dsb_mode_store(struct device *dev,
281+
struct device_attribute *attr,
282+
const char *buf,
283+
size_t size)
284+
{
285+
struct tpdm_drvdata *drvdata = dev_get_drvdata(dev->parent);
286+
unsigned long val;
287+
288+
if ((kstrtoul(buf, 0, &val)) || (val < 0) ||
289+
(val & ~TPDM_DSB_MODE_MASK))
290+
return -EINVAL;
291+
292+
spin_lock(&drvdata->spinlock);
293+
drvdata->dsb->mode = val & TPDM_DSB_MODE_MASK;
294+
spin_unlock(&drvdata->spinlock);
295+
return size;
296+
}
297+
static DEVICE_ATTR_RW(dsb_mode);
298+
247299
static ssize_t dsb_trig_type_show(struct device *dev,
248300
struct device_attribute *attr, char *buf)
249301
{
@@ -316,6 +368,7 @@ static ssize_t dsb_trig_ts_store(struct device *dev,
316368
static DEVICE_ATTR_RW(dsb_trig_ts);
317369

318370
static struct attribute *tpdm_dsb_attrs[] = {
371+
&dev_attr_dsb_mode.attr,
319372
&dev_attr_dsb_trig_ts.attr,
320373
&dev_attr_dsb_trig_type.attr,
321374
NULL,

drivers/hwtracing/coresight/coresight-tpdm.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,28 @@
1515

1616
/* Enable bit for DSB subunit */
1717
#define TPDM_DSB_CR_ENA BIT(0)
18+
/* Enable bit for DSB subunit perfmance mode */
19+
#define TPDM_DSB_CR_MODE BIT(1)
1820
/* Enable bit for DSB subunit trigger type */
1921
#define TPDM_DSB_CR_TRIG_TYPE BIT(12)
22+
/* Data bits for DSB high performace mode */
23+
#define TPDM_DSB_CR_HPSEL GENMASK(6, 2)
24+
/* Data bits for DSB test mode */
25+
#define TPDM_DSB_CR_TEST_MODE GENMASK(10, 9)
26+
2027
/* Enable bit for DSB subunit trigger timestamp */
2128
#define TPDM_DSB_TIER_XTRIG_TSENAB BIT(1)
2229

30+
/* DSB programming modes */
31+
/* DSB mode bits mask */
32+
#define TPDM_DSB_MODE_MASK GENMASK(8, 0)
33+
/* Test mode control bit*/
34+
#define TPDM_DSB_MODE_TEST(val) (val & GENMASK(1, 0))
35+
/* Performance mode */
36+
#define TPDM_DSB_MODE_PERF BIT(3)
37+
/* High performance mode */
38+
#define TPDM_DSB_MODE_HPBYTESEL(val) (val & GENMASK(8, 4))
39+
2340
/* TPDM integration test registers */
2441
#define TPDM_ITATBCNTRL (0xEF0)
2542
#define TPDM_ITCNTRL (0xF00)
@@ -48,10 +65,12 @@
4865

4966
/**
5067
* struct dsb_dataset - specifics associated to dsb dataset
68+
* @mode: DSB programming mode
5169
* @trig_ts: Enable/Disable trigger timestamp.
5270
* @trig_type: Enable/Disable trigger type.
5371
*/
5472
struct dsb_dataset {
73+
u32 mode;
5574
bool trig_ts;
5675
bool trig_type;
5776
};

0 commit comments

Comments
 (0)