Lines Matching refs:drvdata

19 static int __tmc_etb_enable_hw(struct tmc_drvdata *drvdata)  in __tmc_etb_enable_hw()  argument
23 CS_UNLOCK(drvdata->base); in __tmc_etb_enable_hw()
26 rc = tmc_wait_for_tmcready(drvdata); in __tmc_etb_enable_hw()
28 dev_err(&drvdata->csdev->dev, in __tmc_etb_enable_hw()
30 CS_LOCK(drvdata->base); in __tmc_etb_enable_hw()
34 writel_relaxed(TMC_MODE_CIRCULAR_BUFFER, drvdata->base + TMC_MODE); in __tmc_etb_enable_hw()
38 drvdata->base + TMC_FFCR); in __tmc_etb_enable_hw()
40 writel_relaxed(drvdata->trigger_cntr, drvdata->base + TMC_TRG); in __tmc_etb_enable_hw()
41 tmc_enable_hw(drvdata); in __tmc_etb_enable_hw()
43 CS_LOCK(drvdata->base); in __tmc_etb_enable_hw()
47 static int tmc_etb_enable_hw(struct tmc_drvdata *drvdata) in tmc_etb_enable_hw() argument
49 int rc = coresight_claim_device(drvdata->csdev); in tmc_etb_enable_hw()
54 rc = __tmc_etb_enable_hw(drvdata); in tmc_etb_enable_hw()
56 coresight_disclaim_device(drvdata->csdev); in tmc_etb_enable_hw()
60 static void tmc_etb_dump_hw(struct tmc_drvdata *drvdata) in tmc_etb_dump_hw() argument
66 lost = readl_relaxed(drvdata->base + TMC_STS) & TMC_STS_FULL; in tmc_etb_dump_hw()
67 bufp = drvdata->buf; in tmc_etb_dump_hw()
68 drvdata->len = 0; in tmc_etb_dump_hw()
70 read_data = readl_relaxed(drvdata->base + TMC_RRD); in tmc_etb_dump_hw()
75 drvdata->len += 4; in tmc_etb_dump_hw()
79 coresight_insert_barrier_packet(drvdata->buf); in tmc_etb_dump_hw()
83 static void __tmc_etb_disable_hw(struct tmc_drvdata *drvdata) in __tmc_etb_disable_hw() argument
85 CS_UNLOCK(drvdata->base); in __tmc_etb_disable_hw()
87 tmc_flush_and_stop(drvdata); in __tmc_etb_disable_hw()
92 if (drvdata->mode == CS_MODE_SYSFS) in __tmc_etb_disable_hw()
93 tmc_etb_dump_hw(drvdata); in __tmc_etb_disable_hw()
94 tmc_disable_hw(drvdata); in __tmc_etb_disable_hw()
96 CS_LOCK(drvdata->base); in __tmc_etb_disable_hw()
99 static void tmc_etb_disable_hw(struct tmc_drvdata *drvdata) in tmc_etb_disable_hw() argument
101 __tmc_etb_disable_hw(drvdata); in tmc_etb_disable_hw()
102 coresight_disclaim_device(drvdata->csdev); in tmc_etb_disable_hw()
105 static int __tmc_etf_enable_hw(struct tmc_drvdata *drvdata) in __tmc_etf_enable_hw() argument
109 CS_UNLOCK(drvdata->base); in __tmc_etf_enable_hw()
112 rc = tmc_wait_for_tmcready(drvdata); in __tmc_etf_enable_hw()
114 dev_err(&drvdata->csdev->dev, in __tmc_etf_enable_hw()
116 CS_LOCK(drvdata->base); in __tmc_etf_enable_hw()
120 writel_relaxed(TMC_MODE_HARDWARE_FIFO, drvdata->base + TMC_MODE); in __tmc_etf_enable_hw()
122 drvdata->base + TMC_FFCR); in __tmc_etf_enable_hw()
123 writel_relaxed(0x0, drvdata->base + TMC_BUFWM); in __tmc_etf_enable_hw()
124 tmc_enable_hw(drvdata); in __tmc_etf_enable_hw()
126 CS_LOCK(drvdata->base); in __tmc_etf_enable_hw()
130 static int tmc_etf_enable_hw(struct tmc_drvdata *drvdata) in tmc_etf_enable_hw() argument
132 int rc = coresight_claim_device(drvdata->csdev); in tmc_etf_enable_hw()
137 rc = __tmc_etf_enable_hw(drvdata); in tmc_etf_enable_hw()
139 coresight_disclaim_device(drvdata->csdev); in tmc_etf_enable_hw()
143 static void tmc_etf_disable_hw(struct tmc_drvdata *drvdata) in tmc_etf_disable_hw() argument
145 struct coresight_device *csdev = drvdata->csdev; in tmc_etf_disable_hw()
147 CS_UNLOCK(drvdata->base); in tmc_etf_disable_hw()
149 tmc_flush_and_stop(drvdata); in tmc_etf_disable_hw()
150 tmc_disable_hw(drvdata); in tmc_etf_disable_hw()
152 CS_LOCK(drvdata->base); in tmc_etf_disable_hw()
160 ssize_t tmc_etb_get_sysfs_trace(struct tmc_drvdata *drvdata, in tmc_etb_get_sysfs_trace() argument
166 if (pos + actual > drvdata->len) in tmc_etb_get_sysfs_trace()
167 actual = drvdata->len - pos; in tmc_etb_get_sysfs_trace()
169 *bufpp = drvdata->buf + pos; in tmc_etb_get_sysfs_trace()
179 struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); in tmc_enable_etf_sink_sysfs() local
185 spin_lock_irqsave(&drvdata->spinlock, flags); in tmc_enable_etf_sink_sysfs()
186 if (!drvdata->buf) { in tmc_enable_etf_sink_sysfs()
187 spin_unlock_irqrestore(&drvdata->spinlock, flags); in tmc_enable_etf_sink_sysfs()
190 buf = kzalloc(drvdata->size, GFP_KERNEL); in tmc_enable_etf_sink_sysfs()
195 spin_lock_irqsave(&drvdata->spinlock, flags); in tmc_enable_etf_sink_sysfs()
198 if (drvdata->reading) { in tmc_enable_etf_sink_sysfs()
208 if (drvdata->mode == CS_MODE_SYSFS) { in tmc_enable_etf_sink_sysfs()
222 if (drvdata->buf) { in tmc_enable_etf_sink_sysfs()
223 memset(drvdata->buf, 0, drvdata->size); in tmc_enable_etf_sink_sysfs()
226 drvdata->buf = buf; in tmc_enable_etf_sink_sysfs()
229 ret = tmc_etb_enable_hw(drvdata); in tmc_enable_etf_sink_sysfs()
231 drvdata->mode = CS_MODE_SYSFS; in tmc_enable_etf_sink_sysfs()
238 spin_unlock_irqrestore(&drvdata->spinlock, flags); in tmc_enable_etf_sink_sysfs()
252 struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); in tmc_enable_etf_sink_perf() local
256 spin_lock_irqsave(&drvdata->spinlock, flags); in tmc_enable_etf_sink_perf()
259 if (drvdata->reading) in tmc_enable_etf_sink_perf()
265 if (drvdata->mode == CS_MODE_SYSFS) { in tmc_enable_etf_sink_perf()
273 if (drvdata->pid != -1 && drvdata->pid != pid) { in tmc_enable_etf_sink_perf()
286 if (drvdata->pid == pid) { in tmc_enable_etf_sink_perf()
291 ret = tmc_etb_enable_hw(drvdata); in tmc_enable_etf_sink_perf()
294 drvdata->pid = pid; in tmc_enable_etf_sink_perf()
295 drvdata->mode = CS_MODE_PERF; in tmc_enable_etf_sink_perf()
299 spin_unlock_irqrestore(&drvdata->spinlock, flags); in tmc_enable_etf_sink_perf()
332 struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); in tmc_disable_etf_sink() local
334 spin_lock_irqsave(&drvdata->spinlock, flags); in tmc_disable_etf_sink()
336 if (drvdata->reading) { in tmc_disable_etf_sink()
337 spin_unlock_irqrestore(&drvdata->spinlock, flags); in tmc_disable_etf_sink()
342 spin_unlock_irqrestore(&drvdata->spinlock, flags); in tmc_disable_etf_sink()
347 WARN_ON_ONCE(drvdata->mode == CS_MODE_DISABLED); in tmc_disable_etf_sink()
348 tmc_etb_disable_hw(drvdata); in tmc_disable_etf_sink()
350 drvdata->pid = -1; in tmc_disable_etf_sink()
351 drvdata->mode = CS_MODE_DISABLED; in tmc_disable_etf_sink()
353 spin_unlock_irqrestore(&drvdata->spinlock, flags); in tmc_disable_etf_sink()
365 struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); in tmc_enable_etf_link() local
368 spin_lock_irqsave(&drvdata->spinlock, flags); in tmc_enable_etf_link()
369 if (drvdata->reading) { in tmc_enable_etf_link()
370 spin_unlock_irqrestore(&drvdata->spinlock, flags); in tmc_enable_etf_link()
375 ret = tmc_etf_enable_hw(drvdata); in tmc_enable_etf_link()
377 drvdata->mode = CS_MODE_SYSFS; in tmc_enable_etf_link()
383 spin_unlock_irqrestore(&drvdata->spinlock, flags); in tmc_enable_etf_link()
395 struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); in tmc_disable_etf_link() local
398 spin_lock_irqsave(&drvdata->spinlock, flags); in tmc_disable_etf_link()
399 if (drvdata->reading) { in tmc_disable_etf_link()
400 spin_unlock_irqrestore(&drvdata->spinlock, flags); in tmc_disable_etf_link()
405 tmc_etf_disable_hw(drvdata); in tmc_disable_etf_link()
406 drvdata->mode = CS_MODE_DISABLED; in tmc_disable_etf_link()
409 spin_unlock_irqrestore(&drvdata->spinlock, flags); in tmc_disable_etf_link()
480 struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); in tmc_update_etf_buffer() local
486 if (WARN_ON_ONCE(drvdata->mode != CS_MODE_PERF)) in tmc_update_etf_buffer()
489 spin_lock_irqsave(&drvdata->spinlock, flags); in tmc_update_etf_buffer()
495 CS_UNLOCK(drvdata->base); in tmc_update_etf_buffer()
497 tmc_flush_and_stop(drvdata); in tmc_update_etf_buffer()
499 read_ptr = tmc_read_rrp(drvdata); in tmc_update_etf_buffer()
500 write_ptr = tmc_read_rwp(drvdata); in tmc_update_etf_buffer()
506 status = readl_relaxed(drvdata->base + TMC_STS); in tmc_update_etf_buffer()
509 to_read = drvdata->size; in tmc_update_etf_buffer()
511 to_read = CIRC_CNT(write_ptr, read_ptr, drvdata->size); in tmc_update_etf_buffer()
522 u32 mask = tmc_get_memwidth_mask(drvdata); in tmc_update_etf_buffer()
530 read_ptr = (write_ptr + drvdata->size) - to_read; in tmc_update_etf_buffer()
532 if (read_ptr > (drvdata->size - 1)) in tmc_update_etf_buffer()
533 read_ptr -= drvdata->size; in tmc_update_etf_buffer()
535 tmc_write_rrp(drvdata, read_ptr); in tmc_update_etf_buffer()
555 *buf_ptr = readl_relaxed(drvdata->base + TMC_RRD); in tmc_update_etf_buffer()
584 CS_LOCK(drvdata->base); in tmc_update_etf_buffer()
586 spin_unlock_irqrestore(&drvdata->spinlock, flags); in tmc_update_etf_buffer()
613 int tmc_read_prepare_etb(struct tmc_drvdata *drvdata) in tmc_read_prepare_etb() argument
620 if (WARN_ON_ONCE(drvdata->config_type != TMC_CONFIG_TYPE_ETB && in tmc_read_prepare_etb()
621 drvdata->config_type != TMC_CONFIG_TYPE_ETF)) in tmc_read_prepare_etb()
624 spin_lock_irqsave(&drvdata->spinlock, flags); in tmc_read_prepare_etb()
626 if (drvdata->reading) { in tmc_read_prepare_etb()
632 if (drvdata->mode == CS_MODE_PERF) { in tmc_read_prepare_etb()
638 if (drvdata->buf == NULL) { in tmc_read_prepare_etb()
644 if (drvdata->mode == CS_MODE_SYSFS) { in tmc_read_prepare_etb()
646 mode = readl_relaxed(drvdata->base + TMC_MODE); in tmc_read_prepare_etb()
651 __tmc_etb_disable_hw(drvdata); in tmc_read_prepare_etb()
654 drvdata->reading = true; in tmc_read_prepare_etb()
656 spin_unlock_irqrestore(&drvdata->spinlock, flags); in tmc_read_prepare_etb()
661 int tmc_read_unprepare_etb(struct tmc_drvdata *drvdata) in tmc_read_unprepare_etb() argument
669 if (WARN_ON_ONCE(drvdata->config_type != TMC_CONFIG_TYPE_ETB && in tmc_read_unprepare_etb()
670 drvdata->config_type != TMC_CONFIG_TYPE_ETF)) in tmc_read_unprepare_etb()
673 spin_lock_irqsave(&drvdata->spinlock, flags); in tmc_read_unprepare_etb()
676 if (drvdata->mode == CS_MODE_SYSFS) { in tmc_read_unprepare_etb()
678 mode = readl_relaxed(drvdata->base + TMC_MODE); in tmc_read_unprepare_etb()
680 spin_unlock_irqrestore(&drvdata->spinlock, flags); in tmc_read_unprepare_etb()
691 memset(drvdata->buf, 0, drvdata->size); in tmc_read_unprepare_etb()
692 rc = __tmc_etb_enable_hw(drvdata); in tmc_read_unprepare_etb()
694 spin_unlock_irqrestore(&drvdata->spinlock, flags); in tmc_read_unprepare_etb()
702 buf = drvdata->buf; in tmc_read_unprepare_etb()
703 drvdata->buf = NULL; in tmc_read_unprepare_etb()
706 drvdata->reading = false; in tmc_read_unprepare_etb()
707 spin_unlock_irqrestore(&drvdata->spinlock, flags); in tmc_read_unprepare_etb()