aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathieu Poirier <mathieu.poirier@linaro.org>2016-05-03 13:33:57 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-05-03 17:59:30 -0400
commit4f1ff3de925d741b0b77c59bc1387cb940ad7c73 (patch)
treed3e2d92f460276c89ce5136091baf78d0cbfd44b
parentb217601e9adce4d2dccc95a9e6814bdbf5a4a815 (diff)
coresight: tmc: keep track of memory width
Accessing the HW configuration register each time the memory width is needed simply doesn't make sense. It is much more efficient to read the value once and keep a reference for later use. Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/hwtracing/coresight/coresight-tmc-etf.c14
-rw-r--r--drivers/hwtracing/coresight/coresight-tmc.c34
-rw-r--r--drivers/hwtracing/coresight/coresight-tmc.h10
3 files changed, 41 insertions, 17 deletions
diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c
index b11c52be54a9..ba3384781f71 100644
--- a/drivers/hwtracing/coresight/coresight-tmc-etf.c
+++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c
@@ -41,25 +41,13 @@ void tmc_etb_enable_hw(struct tmc_drvdata *drvdata)
41 41
42static void tmc_etb_dump_hw(struct tmc_drvdata *drvdata) 42static void tmc_etb_dump_hw(struct tmc_drvdata *drvdata)
43{ 43{
44 enum tmc_mem_intf_width memwidth;
45 u8 memwords;
46 char *bufp; 44 char *bufp;
47 u32 read_data; 45 u32 read_data;
48 int i; 46 int i;
49 47
50 memwidth = BMVAL(readl_relaxed(drvdata->base + CORESIGHT_DEVID), 8, 10);
51 if (memwidth == TMC_MEM_INTF_WIDTH_32BITS)
52 memwords = 1;
53 else if (memwidth == TMC_MEM_INTF_WIDTH_64BITS)
54 memwords = 2;
55 else if (memwidth == TMC_MEM_INTF_WIDTH_128BITS)
56 memwords = 4;
57 else
58 memwords = 8;
59
60 bufp = drvdata->buf; 48 bufp = drvdata->buf;
61 while (1) { 49 while (1) {
62 for (i = 0; i < memwords; i++) { 50 for (i = 0; i < drvdata->memwidth; i++) {
63 read_data = readl_relaxed(drvdata->base + TMC_RRD); 51 read_data = readl_relaxed(drvdata->base + TMC_RRD);
64 if (read_data == 0xFFFFFFFF) 52 if (read_data == 0xFFFFFFFF)
65 return; 53 return;
diff --git a/drivers/hwtracing/coresight/coresight-tmc.c b/drivers/hwtracing/coresight/coresight-tmc.c
index ae7525a2b94a..9e02ac963cd0 100644
--- a/drivers/hwtracing/coresight/coresight-tmc.c
+++ b/drivers/hwtracing/coresight/coresight-tmc.c
@@ -186,6 +186,39 @@ static const struct file_operations tmc_fops = {
186 .llseek = no_llseek, 186 .llseek = no_llseek,
187}; 187};
188 188
189static enum tmc_mem_intf_width tmc_get_memwidth(u32 devid)
190{
191 enum tmc_mem_intf_width memwidth;
192
193 /*
194 * Excerpt from the TRM:
195 *
196 * DEVID::MEMWIDTH[10:8]
197 * 0x2 Memory interface databus is 32 bits wide.
198 * 0x3 Memory interface databus is 64 bits wide.
199 * 0x4 Memory interface databus is 128 bits wide.
200 * 0x5 Memory interface databus is 256 bits wide.
201 */
202 switch (BMVAL(devid, 8, 10)) {
203 case 0x2:
204 memwidth = TMC_MEM_INTF_WIDTH_32BITS;
205 break;
206 case 0x3:
207 memwidth = TMC_MEM_INTF_WIDTH_64BITS;
208 break;
209 case 0x4:
210 memwidth = TMC_MEM_INTF_WIDTH_128BITS;
211 break;
212 case 0x5:
213 memwidth = TMC_MEM_INTF_WIDTH_256BITS;
214 break;
215 default:
216 memwidth = 0;
217 }
218
219 return memwidth;
220}
221
189#define coresight_tmc_simple_func(name, offset) \ 222#define coresight_tmc_simple_func(name, offset) \
190 coresight_simple_func(struct tmc_drvdata, name, offset) 223 coresight_simple_func(struct tmc_drvdata, name, offset)
191 224
@@ -299,6 +332,7 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id)
299 332
300 devid = readl_relaxed(drvdata->base + CORESIGHT_DEVID); 333 devid = readl_relaxed(drvdata->base + CORESIGHT_DEVID);
301 drvdata->config_type = BMVAL(devid, 6, 7); 334 drvdata->config_type = BMVAL(devid, 6, 7);
335 drvdata->memwidth = tmc_get_memwidth(devid);
302 336
303 if (drvdata->config_type == TMC_CONFIG_TYPE_ETR) { 337 if (drvdata->config_type == TMC_CONFIG_TYPE_ETR) {
304 if (np) 338 if (np)
diff --git a/drivers/hwtracing/coresight/coresight-tmc.h b/drivers/hwtracing/coresight/coresight-tmc.h
index 94bc034d3b98..c5d06fd57fa8 100644
--- a/drivers/hwtracing/coresight/coresight-tmc.h
+++ b/drivers/hwtracing/coresight/coresight-tmc.h
@@ -81,10 +81,10 @@ enum tmc_mode {
81}; 81};
82 82
83enum tmc_mem_intf_width { 83enum tmc_mem_intf_width {
84 TMC_MEM_INTF_WIDTH_32BITS = 0x2, 84 TMC_MEM_INTF_WIDTH_32BITS = 1,
85 TMC_MEM_INTF_WIDTH_64BITS = 0x3, 85 TMC_MEM_INTF_WIDTH_64BITS = 2,
86 TMC_MEM_INTF_WIDTH_128BITS = 0x4, 86 TMC_MEM_INTF_WIDTH_128BITS = 4,
87 TMC_MEM_INTF_WIDTH_256BITS = 0x5, 87 TMC_MEM_INTF_WIDTH_256BITS = 8,
88}; 88};
89 89
90/** 90/**
@@ -100,6 +100,7 @@ enum tmc_mem_intf_width {
100 * @size: @buf size. 100 * @size: @buf size.
101 * @mode: how this TMC is being used. 101 * @mode: how this TMC is being used.
102 * @config_type: TMC variant, must be of type @tmc_config_type. 102 * @config_type: TMC variant, must be of type @tmc_config_type.
103 * @memwidth: width of the memory interface databus, in bytes.
103 * @trigger_cntr: amount of words to store after a trigger. 104 * @trigger_cntr: amount of words to store after a trigger.
104 */ 105 */
105struct tmc_drvdata { 106struct tmc_drvdata {
@@ -115,6 +116,7 @@ struct tmc_drvdata {
115 u32 size; 116 u32 size;
116 local_t mode; 117 local_t mode;
117 enum tmc_config_type config_type; 118 enum tmc_config_type config_type;
119 enum tmc_mem_intf_width memwidth;
118 u32 trigger_cntr; 120 u32 trigger_cntr;
119}; 121};
120 122