1 /* Copyright (c) 2012, The Linux Foundation. All rights reserved.
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
13 #include <linux/kernel.h>
14 #include <linux/module.h>
15 #include <linux/init.h>
16 #include <linux/types.h>
17 #include <linux/device.h>
19 #include <linux/err.h>
21 #include <linux/miscdevice.h>
22 #include <linux/uaccess.h>
23 #include <linux/slab.h>
24 #include <linux/dma-mapping.h>
25 #include <linux/spinlock.h>
26 #include <linux/pm_runtime.h>
28 #include <linux/coresight.h>
29 #include <linux/amba/bus.h>
31 #include "coresight-priv.h"
41 #define TMC_MODE 0x028
42 #define TMC_LBUFLEVEL 0x02c
43 #define TMC_CBUFLEVEL 0x030
44 #define TMC_BUFWM 0x034
45 #define TMC_RRPHI 0x038
46 #define TMC_RWPHI 0x03c
47 #define TMC_AXICTL 0x110
48 #define TMC_DBALO 0x118
49 #define TMC_DBAHI 0x11c
50 #define TMC_FFSR 0x300
51 #define TMC_FFCR 0x304
52 #define TMC_PSCR 0x308
53 #define TMC_ITMISCOP0 0xee0
54 #define TMC_ITTRFLIN 0xee8
55 #define TMC_ITATBDATA0 0xeec
56 #define TMC_ITATBCTR2 0xef0
57 #define TMC_ITATBCTR1 0xef4
58 #define TMC_ITATBCTR0 0xef8
60 /* register description */
62 #define TMC_CTL_CAPT_EN BIT(0)
64 #define TMC_STS_TRIGGERED BIT(1)
65 /* TMC_AXICTL - 0x110 */
66 #define TMC_AXICTL_PROT_CTL_B0 BIT(0)
67 #define TMC_AXICTL_PROT_CTL_B1 BIT(1)
68 #define TMC_AXICTL_SCT_GAT_MODE BIT(7)
69 #define TMC_AXICTL_WR_BURST_LEN 0xF00
70 /* TMC_FFCR - 0x304 */
71 #define TMC_FFCR_EN_FMT BIT(0)
72 #define TMC_FFCR_EN_TI BIT(1)
73 #define TMC_FFCR_FON_FLIN BIT(4)
74 #define TMC_FFCR_FON_TRIG_EVT BIT(5)
75 #define TMC_FFCR_FLUSHMAN BIT(6)
76 #define TMC_FFCR_TRIGON_TRIGIN BIT(8)
77 #define TMC_FFCR_STOP_ON_FLUSH BIT(12)
79 #define TMC_STS_TRIGGERED_BIT 2
80 #define TMC_FFCR_FLUSHMAN_BIT 6
82 enum tmc_config_type {
89 TMC_MODE_CIRCULAR_BUFFER,
90 TMC_MODE_SOFTWARE_FIFO,
91 TMC_MODE_HARDWARE_FIFO,
94 enum tmc_mem_intf_width {
95 TMC_MEM_INTF_WIDTH_32BITS = 0x2,
96 TMC_MEM_INTF_WIDTH_64BITS = 0x3,
97 TMC_MEM_INTF_WIDTH_128BITS = 0x4,
98 TMC_MEM_INTF_WIDTH_256BITS = 0x5,
102 * struct tmc_drvdata - specifics associated to an TMC component
103 * @base: memory mapped base address for this component.
104 * @dev: the device entity associated to this component.
105 * @csdev: component vitals needed by the framework.
106 * @miscdev: specifics to handle "/dev/xyz.tmc" entry.
107 * @spinlock: only one at a time pls.
108 * @read_count: manages preparation of buffer for reading.
109 * @buf: area of memory where trace data get sent.
110 * @paddr: DMA start location in RAM.
111 * @vaddr: virtual representation of @paddr.
113 * @enable: this TMC is being used.
114 * @config_type: TMC variant, must be of type @tmc_config_type.
115 * @trigger_cntr: amount of words to store after a trigger.
120 struct coresight_device *csdev;
121 struct miscdevice miscdev;
130 enum tmc_config_type config_type;
134 static void tmc_wait_for_ready(struct tmc_drvdata *drvdata)
136 /* Ensure formatter, unformatter and hardware fifo are empty */
137 if (coresight_timeout(drvdata->base,
138 TMC_STS, TMC_STS_TRIGGERED_BIT, 1)) {
139 dev_err(drvdata->dev,
140 "timeout observed when probing at offset %#x\n",
145 static void tmc_flush_and_stop(struct tmc_drvdata *drvdata)
149 ffcr = readl_relaxed(drvdata->base + TMC_FFCR);
150 ffcr |= TMC_FFCR_STOP_ON_FLUSH;
151 writel_relaxed(ffcr, drvdata->base + TMC_FFCR);
152 ffcr |= TMC_FFCR_FLUSHMAN;
153 writel_relaxed(ffcr, drvdata->base + TMC_FFCR);
154 /* Ensure flush completes */
155 if (coresight_timeout(drvdata->base,
156 TMC_FFCR, TMC_FFCR_FLUSHMAN_BIT, 0)) {
157 dev_err(drvdata->dev,
158 "timeout observed when probing at offset %#x\n",
162 tmc_wait_for_ready(drvdata);
165 static void tmc_enable_hw(struct tmc_drvdata *drvdata)
167 writel_relaxed(TMC_CTL_CAPT_EN, drvdata->base + TMC_CTL);
170 static void tmc_disable_hw(struct tmc_drvdata *drvdata)
172 writel_relaxed(0x0, drvdata->base + TMC_CTL);
175 static void tmc_etb_enable_hw(struct tmc_drvdata *drvdata)
177 /* Zero out the memory to help with debug */
178 memset(drvdata->buf, 0, drvdata->size);
180 CS_UNLOCK(drvdata->base);
182 writel_relaxed(TMC_MODE_CIRCULAR_BUFFER, drvdata->base + TMC_MODE);
183 writel_relaxed(TMC_FFCR_EN_FMT | TMC_FFCR_EN_TI |
184 TMC_FFCR_FON_FLIN | TMC_FFCR_FON_TRIG_EVT |
185 TMC_FFCR_TRIGON_TRIGIN,
186 drvdata->base + TMC_FFCR);
188 writel_relaxed(drvdata->trigger_cntr, drvdata->base + TMC_TRG);
189 tmc_enable_hw(drvdata);
191 CS_LOCK(drvdata->base);
194 static void tmc_etr_enable_hw(struct tmc_drvdata *drvdata)
198 /* Zero out the memory to help with debug */
199 memset(drvdata->vaddr, 0, drvdata->size);
201 CS_UNLOCK(drvdata->base);
203 writel_relaxed(drvdata->size / 4, drvdata->base + TMC_RSZ);
204 writel_relaxed(TMC_MODE_CIRCULAR_BUFFER, drvdata->base + TMC_MODE);
206 axictl = readl_relaxed(drvdata->base + TMC_AXICTL);
207 axictl |= TMC_AXICTL_WR_BURST_LEN;
208 writel_relaxed(axictl, drvdata->base + TMC_AXICTL);
209 axictl &= ~TMC_AXICTL_SCT_GAT_MODE;
210 writel_relaxed(axictl, drvdata->base + TMC_AXICTL);
212 ~(TMC_AXICTL_PROT_CTL_B0 | TMC_AXICTL_PROT_CTL_B1)) |
213 TMC_AXICTL_PROT_CTL_B1;
214 writel_relaxed(axictl, drvdata->base + TMC_AXICTL);
216 writel_relaxed(drvdata->paddr, drvdata->base + TMC_DBALO);
217 writel_relaxed(0x0, drvdata->base + TMC_DBAHI);
218 writel_relaxed(TMC_FFCR_EN_FMT | TMC_FFCR_EN_TI |
219 TMC_FFCR_FON_FLIN | TMC_FFCR_FON_TRIG_EVT |
220 TMC_FFCR_TRIGON_TRIGIN,
221 drvdata->base + TMC_FFCR);
222 writel_relaxed(drvdata->trigger_cntr, drvdata->base + TMC_TRG);
223 tmc_enable_hw(drvdata);
225 CS_LOCK(drvdata->base);
228 static void tmc_etf_enable_hw(struct tmc_drvdata *drvdata)
230 CS_UNLOCK(drvdata->base);
232 writel_relaxed(TMC_MODE_HARDWARE_FIFO, drvdata->base + TMC_MODE);
233 writel_relaxed(TMC_FFCR_EN_FMT | TMC_FFCR_EN_TI,
234 drvdata->base + TMC_FFCR);
235 writel_relaxed(0x0, drvdata->base + TMC_BUFWM);
236 tmc_enable_hw(drvdata);
238 CS_LOCK(drvdata->base);
241 static int tmc_enable(struct tmc_drvdata *drvdata, enum tmc_mode mode)
245 spin_lock_irqsave(&drvdata->spinlock, flags);
246 if (drvdata->reading) {
247 spin_unlock_irqrestore(&drvdata->spinlock, flags);
251 if (drvdata->config_type == TMC_CONFIG_TYPE_ETB) {
252 tmc_etb_enable_hw(drvdata);
253 } else if (drvdata->config_type == TMC_CONFIG_TYPE_ETR) {
254 tmc_etr_enable_hw(drvdata);
256 if (mode == TMC_MODE_CIRCULAR_BUFFER)
257 tmc_etb_enable_hw(drvdata);
259 tmc_etf_enable_hw(drvdata);
261 drvdata->enable = true;
262 spin_unlock_irqrestore(&drvdata->spinlock, flags);
264 dev_info(drvdata->dev, "TMC enabled\n");
268 static int tmc_enable_sink(struct coresight_device *csdev)
270 struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
272 return tmc_enable(drvdata, TMC_MODE_CIRCULAR_BUFFER);
275 static int tmc_enable_link(struct coresight_device *csdev, int inport,
278 struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
280 return tmc_enable(drvdata, TMC_MODE_HARDWARE_FIFO);
283 static void tmc_etb_dump_hw(struct tmc_drvdata *drvdata)
285 enum tmc_mem_intf_width memwidth;
291 memwidth = BMVAL(readl_relaxed(drvdata->base + CORESIGHT_DEVID), 8, 10);
292 if (memwidth == TMC_MEM_INTF_WIDTH_32BITS)
294 else if (memwidth == TMC_MEM_INTF_WIDTH_64BITS)
296 else if (memwidth == TMC_MEM_INTF_WIDTH_128BITS)
303 for (i = 0; i < memwords; i++) {
304 read_data = readl_relaxed(drvdata->base + TMC_RRD);
305 if (read_data == 0xFFFFFFFF)
307 memcpy(bufp, &read_data, 4);
313 static void tmc_etb_disable_hw(struct tmc_drvdata *drvdata)
315 CS_UNLOCK(drvdata->base);
317 tmc_flush_and_stop(drvdata);
318 tmc_etb_dump_hw(drvdata);
319 tmc_disable_hw(drvdata);
321 CS_LOCK(drvdata->base);
324 static void tmc_etr_dump_hw(struct tmc_drvdata *drvdata)
328 rwp = readl_relaxed(drvdata->base + TMC_RWP);
329 val = readl_relaxed(drvdata->base + TMC_STS);
331 /* How much memory do we still have */
333 drvdata->buf = drvdata->vaddr + rwp - drvdata->paddr;
335 drvdata->buf = drvdata->vaddr;
338 static void tmc_etr_disable_hw(struct tmc_drvdata *drvdata)
340 CS_UNLOCK(drvdata->base);
342 tmc_flush_and_stop(drvdata);
343 tmc_etr_dump_hw(drvdata);
344 tmc_disable_hw(drvdata);
346 CS_LOCK(drvdata->base);
349 static void tmc_etf_disable_hw(struct tmc_drvdata *drvdata)
351 CS_UNLOCK(drvdata->base);
353 tmc_flush_and_stop(drvdata);
354 tmc_disable_hw(drvdata);
356 CS_LOCK(drvdata->base);
359 static void tmc_disable(struct tmc_drvdata *drvdata, enum tmc_mode mode)
363 spin_lock_irqsave(&drvdata->spinlock, flags);
364 if (drvdata->reading)
367 if (drvdata->config_type == TMC_CONFIG_TYPE_ETB) {
368 tmc_etb_disable_hw(drvdata);
369 } else if (drvdata->config_type == TMC_CONFIG_TYPE_ETR) {
370 tmc_etr_disable_hw(drvdata);
372 if (mode == TMC_MODE_CIRCULAR_BUFFER)
373 tmc_etb_disable_hw(drvdata);
375 tmc_etf_disable_hw(drvdata);
378 drvdata->enable = false;
379 spin_unlock_irqrestore(&drvdata->spinlock, flags);
381 dev_info(drvdata->dev, "TMC disabled\n");
384 static void tmc_disable_sink(struct coresight_device *csdev)
386 struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
388 tmc_disable(drvdata, TMC_MODE_CIRCULAR_BUFFER);
391 static void tmc_disable_link(struct coresight_device *csdev, int inport,
394 struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
396 tmc_disable(drvdata, TMC_MODE_HARDWARE_FIFO);
399 static const struct coresight_ops_sink tmc_sink_ops = {
400 .enable = tmc_enable_sink,
401 .disable = tmc_disable_sink,
404 static const struct coresight_ops_link tmc_link_ops = {
405 .enable = tmc_enable_link,
406 .disable = tmc_disable_link,
409 static const struct coresight_ops tmc_etb_cs_ops = {
410 .sink_ops = &tmc_sink_ops,
413 static const struct coresight_ops tmc_etr_cs_ops = {
414 .sink_ops = &tmc_sink_ops,
417 static const struct coresight_ops tmc_etf_cs_ops = {
418 .sink_ops = &tmc_sink_ops,
419 .link_ops = &tmc_link_ops,
422 static int tmc_read_prepare(struct tmc_drvdata *drvdata)
428 spin_lock_irqsave(&drvdata->spinlock, flags);
429 if (!drvdata->enable)
432 if (drvdata->config_type == TMC_CONFIG_TYPE_ETB) {
433 tmc_etb_disable_hw(drvdata);
434 } else if (drvdata->config_type == TMC_CONFIG_TYPE_ETR) {
435 tmc_etr_disable_hw(drvdata);
437 mode = readl_relaxed(drvdata->base + TMC_MODE);
438 if (mode == TMC_MODE_CIRCULAR_BUFFER) {
439 tmc_etb_disable_hw(drvdata);
446 drvdata->reading = true;
447 spin_unlock_irqrestore(&drvdata->spinlock, flags);
449 dev_info(drvdata->dev, "TMC read start\n");
452 spin_unlock_irqrestore(&drvdata->spinlock, flags);
456 static void tmc_read_unprepare(struct tmc_drvdata *drvdata)
461 spin_lock_irqsave(&drvdata->spinlock, flags);
462 if (!drvdata->enable)
465 if (drvdata->config_type == TMC_CONFIG_TYPE_ETB) {
466 tmc_etb_enable_hw(drvdata);
467 } else if (drvdata->config_type == TMC_CONFIG_TYPE_ETR) {
468 tmc_etr_enable_hw(drvdata);
470 mode = readl_relaxed(drvdata->base + TMC_MODE);
471 if (mode == TMC_MODE_CIRCULAR_BUFFER)
472 tmc_etb_enable_hw(drvdata);
475 drvdata->reading = false;
476 spin_unlock_irqrestore(&drvdata->spinlock, flags);
478 dev_info(drvdata->dev, "TMC read end\n");
481 static int tmc_open(struct inode *inode, struct file *file)
483 struct tmc_drvdata *drvdata = container_of(file->private_data,
484 struct tmc_drvdata, miscdev);
487 if (drvdata->read_count++)
490 ret = tmc_read_prepare(drvdata);
494 nonseekable_open(inode, file);
496 dev_dbg(drvdata->dev, "%s: successfully opened\n", __func__);
500 static ssize_t tmc_read(struct file *file, char __user *data, size_t len,
503 struct tmc_drvdata *drvdata = container_of(file->private_data,
504 struct tmc_drvdata, miscdev);
505 char *bufp = drvdata->buf + *ppos;
507 if (*ppos + len > drvdata->size)
508 len = drvdata->size - *ppos;
510 if (drvdata->config_type == TMC_CONFIG_TYPE_ETR) {
511 if (bufp == (char *)(drvdata->vaddr + drvdata->size))
512 bufp = drvdata->vaddr;
513 else if (bufp > (char *)(drvdata->vaddr + drvdata->size))
514 bufp -= drvdata->size;
515 if ((bufp + len) > (char *)(drvdata->vaddr + drvdata->size))
516 len = (char *)(drvdata->vaddr + drvdata->size) - bufp;
519 if (copy_to_user(data, bufp, len)) {
520 dev_dbg(drvdata->dev, "%s: copy_to_user failed\n", __func__);
526 dev_dbg(drvdata->dev, "%s: %zu bytes copied, %d bytes left\n",
527 __func__, len, (int)(drvdata->size - *ppos));
531 static int tmc_release(struct inode *inode, struct file *file)
533 struct tmc_drvdata *drvdata = container_of(file->private_data,
534 struct tmc_drvdata, miscdev);
536 if (--drvdata->read_count) {
537 if (drvdata->read_count < 0) {
538 dev_err(drvdata->dev, "mismatched close\n");
539 drvdata->read_count = 0;
544 tmc_read_unprepare(drvdata);
546 dev_dbg(drvdata->dev, "%s: released\n", __func__);
550 static const struct file_operations tmc_fops = {
551 .owner = THIS_MODULE,
554 .release = tmc_release,
558 static ssize_t status_show(struct device *dev,
559 struct device_attribute *attr, char *buf)
562 u32 tmc_rsz, tmc_sts, tmc_rrp, tmc_rwp, tmc_trg;
563 u32 tmc_ctl, tmc_ffsr, tmc_ffcr, tmc_mode, tmc_pscr;
565 struct tmc_drvdata *drvdata = dev_get_drvdata(dev->parent);
567 pm_runtime_get_sync(drvdata->dev);
568 spin_lock_irqsave(&drvdata->spinlock, flags);
569 CS_UNLOCK(drvdata->base);
571 tmc_rsz = readl_relaxed(drvdata->base + TMC_RSZ);
572 tmc_sts = readl_relaxed(drvdata->base + TMC_STS);
573 tmc_rrp = readl_relaxed(drvdata->base + TMC_RRP);
574 tmc_rwp = readl_relaxed(drvdata->base + TMC_RWP);
575 tmc_trg = readl_relaxed(drvdata->base + TMC_TRG);
576 tmc_ctl = readl_relaxed(drvdata->base + TMC_CTL);
577 tmc_ffsr = readl_relaxed(drvdata->base + TMC_FFSR);
578 tmc_ffcr = readl_relaxed(drvdata->base + TMC_FFCR);
579 tmc_mode = readl_relaxed(drvdata->base + TMC_MODE);
580 tmc_pscr = readl_relaxed(drvdata->base + TMC_PSCR);
581 devid = readl_relaxed(drvdata->base + CORESIGHT_DEVID);
583 CS_LOCK(drvdata->base);
584 spin_unlock_irqrestore(&drvdata->spinlock, flags);
585 pm_runtime_put(drvdata->dev);
590 "RAM read ptr:\t0x%x\n"
591 "RAM wrt ptr:\t0x%x\n"
592 "Trigger cnt:\t0x%x\n"
594 "Flush status:\t0x%x\n"
595 "Flush ctrl:\t0x%x\n"
599 tmc_rsz, tmc_sts, tmc_rrp, tmc_rwp, tmc_trg,
600 tmc_ctl, tmc_ffsr, tmc_ffcr, tmc_mode, tmc_pscr, devid);
604 static DEVICE_ATTR_RO(status);
606 static ssize_t trigger_cntr_show(struct device *dev,
607 struct device_attribute *attr, char *buf)
609 struct tmc_drvdata *drvdata = dev_get_drvdata(dev->parent);
610 unsigned long val = drvdata->trigger_cntr;
612 return sprintf(buf, "%#lx\n", val);
615 static ssize_t trigger_cntr_store(struct device *dev,
616 struct device_attribute *attr,
617 const char *buf, size_t size)
621 struct tmc_drvdata *drvdata = dev_get_drvdata(dev->parent);
623 ret = kstrtoul(buf, 16, &val);
627 drvdata->trigger_cntr = val;
630 static DEVICE_ATTR_RW(trigger_cntr);
632 static struct attribute *coresight_etb_attrs[] = {
633 &dev_attr_trigger_cntr.attr,
634 &dev_attr_status.attr,
637 ATTRIBUTE_GROUPS(coresight_etb);
639 static struct attribute *coresight_etr_attrs[] = {
640 &dev_attr_trigger_cntr.attr,
641 &dev_attr_status.attr,
644 ATTRIBUTE_GROUPS(coresight_etr);
646 static struct attribute *coresight_etf_attrs[] = {
647 &dev_attr_trigger_cntr.attr,
648 &dev_attr_status.attr,
651 ATTRIBUTE_GROUPS(coresight_etf);
653 static int tmc_probe(struct amba_device *adev, const struct amba_id *id)
658 struct device *dev = &adev->dev;
659 struct coresight_platform_data *pdata = NULL;
660 struct tmc_drvdata *drvdata;
661 struct resource *res = &adev->res;
662 struct coresight_desc *desc;
663 struct device_node *np = adev->dev.of_node;
666 pdata = of_get_coresight_platform_data(dev, np);
668 return PTR_ERR(pdata);
669 adev->dev.platform_data = pdata;
672 drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
676 drvdata->dev = &adev->dev;
677 dev_set_drvdata(dev, drvdata);
679 /* Validity for the resource is already checked by the AMBA core */
680 base = devm_ioremap_resource(dev, res);
682 return PTR_ERR(base);
684 drvdata->base = base;
686 spin_lock_init(&drvdata->spinlock);
688 devid = readl_relaxed(drvdata->base + CORESIGHT_DEVID);
689 drvdata->config_type = BMVAL(devid, 6, 7);
691 if (drvdata->config_type == TMC_CONFIG_TYPE_ETR) {
693 ret = of_property_read_u32(np,
697 drvdata->size = SZ_1M;
699 drvdata->size = readl_relaxed(drvdata->base + TMC_RSZ) * 4;
702 pm_runtime_put(&adev->dev);
704 if (drvdata->config_type == TMC_CONFIG_TYPE_ETR) {
705 drvdata->vaddr = dma_alloc_coherent(dev, drvdata->size,
706 &drvdata->paddr, GFP_KERNEL);
710 memset(drvdata->vaddr, 0, drvdata->size);
711 drvdata->buf = drvdata->vaddr;
713 drvdata->buf = devm_kzalloc(dev, drvdata->size, GFP_KERNEL);
718 desc = devm_kzalloc(dev, sizeof(*desc), GFP_KERNEL);
721 goto err_devm_kzalloc;
726 desc->subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_BUFFER;
728 if (drvdata->config_type == TMC_CONFIG_TYPE_ETB) {
729 desc->type = CORESIGHT_DEV_TYPE_SINK;
730 desc->ops = &tmc_etb_cs_ops;
731 desc->groups = coresight_etb_groups;
732 } else if (drvdata->config_type == TMC_CONFIG_TYPE_ETR) {
733 desc->type = CORESIGHT_DEV_TYPE_SINK;
734 desc->ops = &tmc_etr_cs_ops;
735 desc->groups = coresight_etr_groups;
737 desc->type = CORESIGHT_DEV_TYPE_LINKSINK;
738 desc->subtype.link_subtype = CORESIGHT_DEV_SUBTYPE_LINK_FIFO;
739 desc->ops = &tmc_etf_cs_ops;
740 desc->groups = coresight_etf_groups;
743 drvdata->csdev = coresight_register(desc);
744 if (IS_ERR(drvdata->csdev)) {
745 ret = PTR_ERR(drvdata->csdev);
746 goto err_devm_kzalloc;
749 drvdata->miscdev.name = pdata->name;
750 drvdata->miscdev.minor = MISC_DYNAMIC_MINOR;
751 drvdata->miscdev.fops = &tmc_fops;
752 ret = misc_register(&drvdata->miscdev);
754 goto err_misc_register;
756 dev_info(dev, "TMC initialized\n");
760 coresight_unregister(drvdata->csdev);
762 if (drvdata->config_type == TMC_CONFIG_TYPE_ETR)
763 dma_free_coherent(dev, drvdata->size,
764 drvdata->vaddr, drvdata->paddr);
768 static struct amba_id tmc_ids[] = {
776 static struct amba_driver tmc_driver = {
778 .name = "coresight-tmc",
779 .owner = THIS_MODULE,
780 .suppress_bind_attrs = true,
786 module_amba_driver(tmc_driver);
788 MODULE_LICENSE("GPL v2");
789 MODULE_DESCRIPTION("CoreSight Trace Memory Controller driver");