From 5d79729904818b10fdf28fed75f3b3852842116e Mon Sep 17 00:00:00 2001 From: "Tao,Zhang" Date: Thu, 9 Apr 2020 14:59:20 +0800 Subject: [PATCH] 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: Tao,Zhang --- drivers/hwtracing/coresight/coresight-cti.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-cti.c b/drivers/hwtracing/coresight/coresight-cti.c index 81e8e9c15da4..7f5c159e3809 100644 --- a/drivers/hwtracing/coresight/coresight-cti.c +++ b/drivers/hwtracing/coresight/coresight-cti.c @@ -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; @@ -1354,6 +1357,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, @@ -1370,6 +1386,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, }; @@ -1511,6 +1528,7 @@ EXPORT_SYMBOL(of_get_coresight_cti_data); 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; @@ -1574,6 +1592,9 @@ 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;