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

Commit 0a34474c authored by Yuanfang Zhang's avatar Yuanfang Zhang Committed by Gerrit - the friendly Code Review server
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>
Signed-off-by: default avatarYuanfang Zhang <zhangyuanfang@codeaurora.org>
parent b7fc809e
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ do { \
#define ITTRIGOUTACK		(0xEF0)
#define ITCHIN			(0xEF4)
#define ITTRIGIN		(0xEF8)
#define DEVID			(0xFC8)

#define CTI_MAX_TRIGGERS	(32)
#define CTI_MAX_CHANNELS	(4)
@@ -93,6 +94,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;
@@ -1360,6 +1363,19 @@ static ssize_t cti_store_disable_gate(struct device *dev,
}
static DEVICE_ATTR(disable_gate, 0200, NULL, cti_store_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,
@@ -1376,6 +1392,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,
};

@@ -1416,6 +1433,7 @@ static int cti_probe(struct amba_device *adev, const struct amba_id *id)
{
	int ret;
	int trig;
	unsigned int ctidevid;
	struct device *dev = &adev->dev;
	struct coresight_platform_data *pdata;
	struct cti_drvdata *drvdata;
@@ -1522,6 +1540,10 @@ static int cti_probe(struct amba_device *adev, const struct amba_id *id)
			cpu_pm_register_notifier(&cti_cpu_pm_notifier);
		registered++;
	}

	ctidevid = cti_readl(drvdata, DEVID);
	drvdata->trig_num_max = (ctidevid & GENMASK(15, 8)) >> 8;
	drvdata->ch_num_max = (ctidevid & GENMASK(21, 16)) >> 16;
	pm_runtime_put(&adev->dev);
	dev_dbg(dev, "CTI initialized\n");
	return 0;