Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 303fe66a authored by Tao,Zhang's avatar Tao,Zhang
Browse files

coresight: cti: Add sys interface to show max trigger number



Read the value of CTI devid register and get the value of max trigger
number and max channel number. Add sys interface to show them.

Change-Id: Ibea77cfd83007f58af1d285f05bbb338141b0dfc
Signed-off-by: default avatarTao,Zhang <taozha@codeaurora.org>
parent dcc90d4a
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ do { \
#define ITTRIGOUTACK		(0xEF0)
#define ITCHIN			(0xEF4)
#define ITTRIGIN		(0xEF8)
#define DEVID			(0xFC8)

#define CTI_MAX_TRIGGERS	(32)
#define CTI_MAX_CHANNELS	(4)
@@ -86,6 +87,8 @@ struct cti_drvdata {
	struct coresight_cti		cti;
	int				refcnt;
	int				cpu;
	unsigned int			trig_num_max;
	unsigned int			ch_num_max;
	bool				cti_save;
	bool				cti_hwclk;
	bool				l2_off;
@@ -1353,6 +1356,19 @@ static ssize_t disable_gate_store(struct device *dev,
}
static DEVICE_ATTR_WO(disable_gate);

static ssize_t show_info_show(struct device *dev, struct device_attribute *attr,
				char *buf)
{
	struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
	ssize_t size = 0;

	size = scnprintf(&buf[size], PAGE_SIZE, "%d %d\n",
			drvdata->trig_num_max, drvdata->ch_num_max);

	return size;
}
static DEVICE_ATTR_RO(show_info);

static struct attribute *cti_attrs[] = {
	&dev_attr_show_trigin.attr,
	&dev_attr_show_trigout.attr,
@@ -1369,6 +1385,7 @@ static struct attribute *cti_attrs[] = {
	&dev_attr_show_gate.attr,
	&dev_attr_enable_gate.attr,
	&dev_attr_disable_gate.attr,
	&dev_attr_show_info.attr,
	NULL,
};

@@ -1468,6 +1485,7 @@ static int cti_init_save(struct cti_drvdata *drvdata,
static int cti_probe(struct amba_device *adev, const struct amba_id *id)
{
	int ret;
	unsigned int ctidevid;
	struct device *dev = &adev->dev;
	struct coresight_platform_data *pdata;
	struct cti_drvdata *drvdata;
@@ -1539,6 +1557,9 @@ static int cti_probe(struct amba_device *adev, const struct amba_id *id)
		registered++;
	}
	pm_runtime_put(&adev->dev);
	ctidevid = cti_readl(drvdata, DEVID);
	drvdata->trig_num_max = (ctidevid & GENMASK(15, 8)) >> 8;
	drvdata->ch_num_max = (ctidevid & GENMASK(21, 16)) >> 16;
	dev_dbg(dev, "CTI initialized\n");
	return 0;
err: