aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwtracing/coresight/coresight-etb10.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwtracing/coresight/coresight-etb10.c')
-rw-r--r--drivers/hwtracing/coresight/coresight-etb10.c107
1 files changed, 41 insertions, 66 deletions
diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c
index acbce79934d6..4d20b0be0c0b 100644
--- a/drivers/hwtracing/coresight/coresight-etb10.c
+++ b/drivers/hwtracing/coresight/coresight-etb10.c
@@ -71,26 +71,6 @@
71#define ETB_FRAME_SIZE_WORDS 4 71#define ETB_FRAME_SIZE_WORDS 4
72 72
73/** 73/**
74 * struct cs_buffer - keep track of a recording session' specifics
75 * @cur: index of the current buffer
76 * @nr_pages: max number of pages granted to us
77 * @offset: offset within the current buffer
78 * @data_size: how much we collected in this run
79 * @lost: other than zero if we had a HW buffer wrap around
80 * @snapshot: is this run in snapshot mode
81 * @data_pages: a handle the ring buffer
82 */
83struct cs_buffers {
84 unsigned int cur;
85 unsigned int nr_pages;
86 unsigned long offset;
87 local_t data_size;
88 local_t lost;
89 bool snapshot;
90 void **data_pages;
91};
92
93/**
94 * struct etb_drvdata - specifics associated to an ETB component 74 * struct etb_drvdata - specifics associated to an ETB component
95 * @base: memory mapped base address for this component. 75 * @base: memory mapped base address for this component.
96 * @dev: the device entity associated to this component. 76 * @dev: the device entity associated to this component.
@@ -440,7 +420,7 @@ static void etb_update_buffer(struct coresight_device *csdev,
440 u32 mask = ~(ETB_FRAME_SIZE_WORDS - 1); 420 u32 mask = ~(ETB_FRAME_SIZE_WORDS - 1);
441 421
442 /* The new read pointer must be frame size aligned */ 422 /* The new read pointer must be frame size aligned */
443 to_read -= handle->size & mask; 423 to_read = handle->size & mask;
444 /* 424 /*
445 * Move the RAM read pointer up, keeping in mind that 425 * Move the RAM read pointer up, keeping in mind that
446 * everything is in frame size units. 426 * everything is in frame size units.
@@ -448,7 +428,8 @@ static void etb_update_buffer(struct coresight_device *csdev,
448 read_ptr = (write_ptr + drvdata->buffer_depth) - 428 read_ptr = (write_ptr + drvdata->buffer_depth) -
449 to_read / ETB_FRAME_SIZE_WORDS; 429 to_read / ETB_FRAME_SIZE_WORDS;
450 /* Wrap around if need be*/ 430 /* Wrap around if need be*/
451 read_ptr &= ~(drvdata->buffer_depth - 1); 431 if (read_ptr > (drvdata->buffer_depth - 1))
432 read_ptr -= drvdata->buffer_depth;
452 /* let the decoder know we've skipped ahead */ 433 /* let the decoder know we've skipped ahead */
453 local_inc(&buf->lost); 434 local_inc(&buf->lost);
454 } 435 }
@@ -579,47 +560,29 @@ static const struct file_operations etb_fops = {
579 .llseek = no_llseek, 560 .llseek = no_llseek,
580}; 561};
581 562
582static ssize_t status_show(struct device *dev, 563#define coresight_etb10_simple_func(name, offset) \
583 struct device_attribute *attr, char *buf) 564 coresight_simple_func(struct etb_drvdata, name, offset)
584{ 565
585 unsigned long flags; 566coresight_etb10_simple_func(rdp, ETB_RAM_DEPTH_REG);
586 u32 etb_rdr, etb_sr, etb_rrp, etb_rwp; 567coresight_etb10_simple_func(sts, ETB_STATUS_REG);
587 u32 etb_trg, etb_cr, etb_ffsr, etb_ffcr; 568coresight_etb10_simple_func(rrp, ETB_RAM_READ_POINTER);
588 struct etb_drvdata *drvdata = dev_get_drvdata(dev->parent); 569coresight_etb10_simple_func(rwp, ETB_RAM_WRITE_POINTER);
589 570coresight_etb10_simple_func(trg, ETB_TRG);
590 pm_runtime_get_sync(drvdata->dev); 571coresight_etb10_simple_func(ctl, ETB_CTL_REG);
591 spin_lock_irqsave(&drvdata->spinlock, flags); 572coresight_etb10_simple_func(ffsr, ETB_FFSR);
592 CS_UNLOCK(drvdata->base); 573coresight_etb10_simple_func(ffcr, ETB_FFCR);
593 574
594 etb_rdr = readl_relaxed(drvdata->base + ETB_RAM_DEPTH_REG); 575static struct attribute *coresight_etb_mgmt_attrs[] = {
595 etb_sr = readl_relaxed(drvdata->base + ETB_STATUS_REG); 576 &dev_attr_rdp.attr,
596 etb_rrp = readl_relaxed(drvdata->base + ETB_RAM_READ_POINTER); 577 &dev_attr_sts.attr,
597 etb_rwp = readl_relaxed(drvdata->base + ETB_RAM_WRITE_POINTER); 578 &dev_attr_rrp.attr,
598 etb_trg = readl_relaxed(drvdata->base + ETB_TRG); 579 &dev_attr_rwp.attr,
599 etb_cr = readl_relaxed(drvdata->base + ETB_CTL_REG); 580 &dev_attr_trg.attr,
600 etb_ffsr = readl_relaxed(drvdata->base + ETB_FFSR); 581 &dev_attr_ctl.attr,
601 etb_ffcr = readl_relaxed(drvdata->base + ETB_FFCR); 582 &dev_attr_ffsr.attr,
602 583 &dev_attr_ffcr.attr,
603 CS_LOCK(drvdata->base); 584 NULL,
604 spin_unlock_irqrestore(&drvdata->spinlock, flags); 585};
605
606 pm_runtime_put(drvdata->dev);
607
608 return sprintf(buf,
609 "Depth:\t\t0x%x\n"
610 "Status:\t\t0x%x\n"
611 "RAM read ptr:\t0x%x\n"
612 "RAM wrt ptr:\t0x%x\n"
613 "Trigger cnt:\t0x%x\n"
614 "Control:\t0x%x\n"
615 "Flush status:\t0x%x\n"
616 "Flush ctrl:\t0x%x\n",
617 etb_rdr, etb_sr, etb_rrp, etb_rwp,
618 etb_trg, etb_cr, etb_ffsr, etb_ffcr);
619
620 return -EINVAL;
621}
622static DEVICE_ATTR_RO(status);
623 586
624static ssize_t trigger_cntr_show(struct device *dev, 587static ssize_t trigger_cntr_show(struct device *dev,
625 struct device_attribute *attr, char *buf) 588 struct device_attribute *attr, char *buf)
@@ -649,10 +612,23 @@ static DEVICE_ATTR_RW(trigger_cntr);
649 612
650static struct attribute *coresight_etb_attrs[] = { 613static struct attribute *coresight_etb_attrs[] = {
651 &dev_attr_trigger_cntr.attr, 614 &dev_attr_trigger_cntr.attr,
652 &dev_attr_status.attr,
653 NULL, 615 NULL,
654}; 616};
655ATTRIBUTE_GROUPS(coresight_etb); 617
618static const struct attribute_group coresight_etb_group = {
619 .attrs = coresight_etb_attrs,
620};
621
622static const struct attribute_group coresight_etb_mgmt_group = {
623 .attrs = coresight_etb_mgmt_attrs,
624 .name = "mgmt",
625};
626
627const struct attribute_group *coresight_etb_groups[] = {
628 &coresight_etb_group,
629 &coresight_etb_mgmt_group,
630 NULL,
631};
656 632
657static int etb_probe(struct amba_device *adev, const struct amba_id *id) 633static int etb_probe(struct amba_device *adev, const struct amba_id *id)
658{ 634{
@@ -729,7 +705,6 @@ static int etb_probe(struct amba_device *adev, const struct amba_id *id)
729 if (ret) 705 if (ret)
730 goto err_misc_register; 706 goto err_misc_register;
731 707
732 dev_info(dev, "ETB initialized\n");
733 return 0; 708 return 0;
734 709
735err_misc_register: 710err_misc_register: