Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9a9731d6 authored by Rama Aparna Mallavarapu's avatar Rama Aparna Mallavarapu
Browse files

coresight-tmc: add support to configure flush and reset CTIs



Add support to map/unmap TMC flush and reset CTIs as part of
TMC enable/disable.

Change-Id: Icfb55f4cfaa944de396514e4792f88bcfb7eb7b6
Signed-off-by: default avatarSatyajit Desai <sadesai@codeaurora.org>
Signed-off-by: default avatarRama Aparna Mallavarapu <aparnam@codeaurora.org>
parent 5e6427f5
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -183,6 +183,12 @@ static int tmc_enable_etf_sink_sysfs(struct coresight_device *csdev)
	if (!used)
		kfree(buf);

	if (!ret) {
		coresight_cti_map_trigin(drvdata->cti_reset, 2, 0);
		coresight_cti_map_trigout(drvdata->cti_flush, 1, 0);
		dev_info(drvdata->dev, "TMC-ETB/ETF enabled\n");
	}

	return ret;
}

@@ -260,6 +266,9 @@ static void tmc_disable_etf_sink(struct coresight_device *csdev)

	spin_unlock_irqrestore(&drvdata->spinlock, flags);

	coresight_cti_unmap_trigin(drvdata->cti_reset, 2, 0);
	coresight_cti_unmap_trigout(drvdata->cti_flush, 1, 0);

	dev_info(drvdata->dev, "TMC-ETB/ETF disabled\n");
}

+8 −0
Original line number Diff line number Diff line
@@ -402,6 +402,8 @@ static int tmc_enable_etr_sink_sysfs(struct coresight_device *csdev, u32 mode)
				mutex_unlock(&drvdata->mem_lock);
				return ret;
			}
			coresight_cti_map_trigout(drvdata->cti_flush, 3, 0);
			coresight_cti_map_trigin(drvdata->cti_reset, 2, 0);
		} else {
			drvdata->usbch = usb_qdss_open("qdss", drvdata,
								usb_notifier);
@@ -512,6 +514,7 @@ static void tmc_disable_etr_sink(struct coresight_device *csdev)
	unsigned long flags;
	struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);

	mutex_lock(&drvdata->mem_lock);
	spin_lock_irqsave(&drvdata->spinlock, flags);
	if (drvdata->reading) {
		spin_unlock_irqrestore(&drvdata->spinlock, flags);
@@ -532,6 +535,11 @@ static void tmc_disable_etr_sink(struct coresight_device *csdev)

	spin_unlock_irqrestore(&drvdata->spinlock, flags);

	if (drvdata->out_mode == TMC_ETR_OUT_MODE_MEM) {
		coresight_cti_unmap_trigin(drvdata->cti_reset, 2, 0);
		coresight_cti_unmap_trigout(drvdata->cti_flush, 3, 0);
	}
	mutex_unlock(&drvdata->mem_lock);
	dev_info(drvdata->dev, "TMC-ETR disabled\n");
}

+20 −0
Original line number Diff line number Diff line
@@ -360,6 +360,9 @@ static ssize_t out_mode_store(struct device *dev,
		drvdata->out_mode = TMC_ETR_OUT_MODE_MEM;
		spin_unlock_irqrestore(&drvdata->spinlock, flags);

		coresight_cti_map_trigout(drvdata->cti_flush, 3, 0);
		coresight_cti_map_trigin(drvdata->cti_reset, 2, 0);

		tmc_etr_bam_disable(drvdata);
		usb_qdss_close(drvdata->usbch);
	} else if (!strcmp(str, str_tmc_etr_out_mode[TMC_ETR_OUT_MODE_USB])) {
@@ -380,6 +383,9 @@ static ssize_t out_mode_store(struct device *dev,
		drvdata->out_mode = TMC_ETR_OUT_MODE_USB;
		spin_unlock_irqrestore(&drvdata->spinlock, flags);

		coresight_cti_unmap_trigout(drvdata->cti_flush, 3, 0);
		coresight_cti_unmap_trigin(drvdata->cti_reset, 2, 0);

		drvdata->usbch = usb_qdss_open("qdss", drvdata,
					       usb_notifier);
		if (IS_ERR(drvdata->usbch)) {
@@ -537,6 +543,7 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id)
	struct resource *res = &adev->res;
	struct coresight_desc desc = { 0 };
	struct device_node *np = adev->dev.of_node;
	struct coresight_cti_data *ctidata;

	pdata = of_get_coresight_platform_data(dev, np);
	if (IS_ERR(pdata)) {
@@ -583,6 +590,19 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id)

	pm_runtime_put(&adev->dev);

	ctidata = of_get_coresight_cti_data(dev, adev->dev.of_node);
	if (IS_ERR(ctidata)) {
		dev_err(dev, "invalid cti data\n");
	} else if (ctidata && ctidata->nr_ctis == 2) {
		drvdata->cti_flush = coresight_cti_get(ctidata->names[0]);
		if (IS_ERR(drvdata->cti_flush))
			dev_err(dev, "failed to get flush cti\n");

		drvdata->cti_reset = coresight_cti_get(ctidata->names[1]);
		if (IS_ERR(drvdata->cti_reset))
			dev_err(dev, "failed to get reset cti\n");
	}

	desc.pdata = pdata;
	desc.dev = dev;

+3 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#include <linux/amba/bus.h>
#include <linux/usb_bam.h>
#include <linux/usb/usb_qdss.h>
#include <linux/coresight-cti.h>

#define TMC_RSZ			0x004
#define TMC_STS			0x00c
@@ -215,6 +216,8 @@ struct tmc_drvdata {
	struct usb_qdss_ch	*usbch;
	struct tmc_etr_bam_data	*bamdata;
	bool			sticky_enable;
	struct coresight_cti	*cti_flush;
	struct coresight_cti	*cti_reset;
};

/* Generic functions */