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

Commit f566957c authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "coresight: add support for fuse v2 layout"

parents a82af7f3 1e6812aa
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -22,7 +22,8 @@ Required properties:
	"qcom,coresight-csr" for coresight csr device,
	"arm,coresight-cti" for coresight cti devices,
	"qcom,coresight-hwevent" for coresight hardware event devices
	"arm,coresight-fuse" for coresight fuse device,
	"arm,coresight-fuse" for coresight fuse v1 device,
	"arm,coresight-fuse-v2" for coresight fuse v2 device,
	"qcom,coresight-audio-etm" for coresight audio etm trace device,
	"qcom,coresight-modem-etm" for coresight modem etm trace device,
	"qcom,coresight-wcn-etm" for coresight wireless etm trace device,
+89 −36
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include <linux/slab.h>
#include <linux/of.h>
#include <linux/of_coresight.h>
#include <linux/of_device.h>
#include <linux/coresight.h>

#include "coresight-priv.h"
@@ -31,6 +32,10 @@
#define OEM_CONFIG1		(0x004)
#define FEATURE_CONFIG2		(0x000)

#define CORESIGHT_FUSE_VERSION_V1		"arm,coresight-fuse"
#define CORESIGHT_FUSE_VERSION_V2		"arm,coresight-fuse-v2"

/* CoreSight FUSE V1 */
#define ALL_DEBUG_DISABLE	BIT(21)
#define APPS_DBGEN_DISABLE	BIT(0)
#define APPS_NIDEN_DISABLE	BIT(1)
@@ -41,8 +46,20 @@
#define DAP_SPIDEN_DISABLE	BIT(6)
#define DAP_SPNIDEN_DISABLE	BIT(7)
#define DAP_DEVICEEN_DISABLE	BIT(8)
#define QPDI_SPMI_DISABLE	BIT(2)

/* CoreSight FUSE V2 */
#define ALL_DEBUG_DISABLE_V2		BIT(0)
#define APPS_DBGEN_DISABLE_V2		BIT(10)
#define APPS_NIDEN_DISABLE_V2		BIT(11)
#define APPS_SPIDEN_DISABLE_V2		BIT(12)
#define APPS_SPNIDEN_DISABLE_V2	BIT(13)
#define DAP_DBGEN_DISABLE_V2		BIT(14)
#define DAP_NIDEN_DISABLE_V2		BIT(15)
#define DAP_SPIDEN_DISABLE_V2		BIT(16)
#define DAP_SPNIDEN_DISABLE_V2		BIT(17)
#define DAP_DEVICEEN_DISABLE_V2	BIT(18)

#define QPDI_SPMI_DISABLE	BIT(2)
#define NIDNT_DISABLE	BIT(27)

struct fuse_nidnt {
@@ -59,6 +76,7 @@ struct fuse_drvdata {
	struct fuse_qpdi	*qpdi;
	struct device		*dev;
	struct coresight_device	*csdev;
	bool			fuse_v2;
};

static struct fuse_drvdata *fusedrvdata;
@@ -92,7 +110,7 @@ bool coresight_fuse_access_disabled(void)
{
	struct fuse_drvdata *drvdata = fusedrvdata;
	uint32_t config0, config1;
	bool ret;
	bool ret = false;

	config0 = fuse_readl(drvdata, OEM_CONFIG0);
	config1 = fuse_readl(drvdata, OEM_CONFIG1);
@@ -100,6 +118,20 @@ bool coresight_fuse_access_disabled(void)
	dev_dbg(drvdata->dev, "config0: %lx\n", (unsigned long)config0);
	dev_dbg(drvdata->dev, "config1: %lx\n", (unsigned long)config1);

	if (drvdata->fuse_v2) {
		if (config1 & ALL_DEBUG_DISABLE_V2)
			ret = true;
		else if (config1 & DAP_DBGEN_DISABLE_V2)
			ret = true;
		else if (config1 & DAP_NIDEN_DISABLE_V2)
			ret = true;
		else if (config1 & DAP_SPIDEN_DISABLE_V2)
			ret = true;
		else if (config1 & DAP_SPNIDEN_DISABLE_V2)
			ret = true;
		else if (config1 & DAP_DEVICEEN_DISABLE_V2)
			ret = true;
	} else {
		if (config0 & ALL_DEBUG_DISABLE)
			ret = true;
		else if (config1 & DAP_DBGEN_DISABLE)
@@ -112,8 +144,7 @@ bool coresight_fuse_access_disabled(void)
			ret = true;
		else if (config1 & DAP_DEVICEEN_DISABLE)
			ret = true;
	else
		ret = false;
	}

	if (ret)
		dev_dbg(drvdata->dev, "coresight fuse disabled\n");
@@ -126,7 +157,7 @@ bool coresight_fuse_apps_access_disabled(void)
{
	struct fuse_drvdata *drvdata = fusedrvdata;
	uint32_t config0, config1;
	bool ret;
	bool ret = false;

	config0 = fuse_readl(drvdata, OEM_CONFIG0);
	config1 = fuse_readl(drvdata, OEM_CONFIG1);
@@ -134,6 +165,20 @@ bool coresight_fuse_apps_access_disabled(void)
	dev_dbg(drvdata->dev, "apps config0: %lx\n", (unsigned long)config0);
	dev_dbg(drvdata->dev, "apps config1: %lx\n", (unsigned long)config1);

	if (drvdata->fuse_v2) {
		if (config1 & ALL_DEBUG_DISABLE_V2)
			ret = true;
		else if (config1 & APPS_DBGEN_DISABLE_V2)
			ret = true;
		else if (config1 & APPS_NIDEN_DISABLE_V2)
			ret = true;
		else if (config1 & APPS_SPIDEN_DISABLE_V2)
			ret = true;
		else if (config1 & APPS_SPNIDEN_DISABLE_V2)
			ret = true;
		else if (config1 & DAP_DEVICEEN_DISABLE_V2)
			ret = true;
	} else {
		if (config0 & ALL_DEBUG_DISABLE)
			ret = true;
		else if (config1 & APPS_DBGEN_DISABLE)
@@ -146,8 +191,7 @@ bool coresight_fuse_apps_access_disabled(void)
			ret = true;
		else if (config1 & DAP_DEVICEEN_DISABLE)
			ret = true;
	else
		ret = false;
	}

	if (ret)
		dev_dbg(drvdata->dev, "apps fuse disabled\n");
@@ -177,6 +221,12 @@ bool coresight_fuse_qpdi_access_disabled(void)
}
EXPORT_SYMBOL(coresight_fuse_qpdi_access_disabled);

static struct of_device_id fuse_match[] = {
	{.compatible = CORESIGHT_FUSE_VERSION_V1 },
	{.compatible = CORESIGHT_FUSE_VERSION_V2 },
	{}
};

static int fuse_probe(struct platform_device *pdev)
{
	struct device *dev = &pdev->dev;
@@ -184,6 +234,7 @@ static int fuse_probe(struct platform_device *pdev)
	struct fuse_drvdata *drvdata;
	struct resource *res;
	struct coresight_desc *desc;
	const struct of_device_id *match;

	if (pdev->dev.of_node) {
		pdata = of_get_coresight_platform_data(dev, pdev->dev.of_node);
@@ -200,6 +251,13 @@ static int fuse_probe(struct platform_device *pdev)
	drvdata->dev = &pdev->dev;
	platform_set_drvdata(pdev, drvdata);

	match = of_match_device(fuse_match, dev);
	if (!match)
		return -EINVAL;

	if (!strcmp(match->compatible, CORESIGHT_FUSE_VERSION_V2))
		drvdata->fuse_v2 = true;

	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "fuse-base");
	if (!res)
		return -ENODEV;
@@ -263,11 +321,6 @@ static int fuse_remove(struct platform_device *pdev)
	return 0;
}

static struct of_device_id fuse_match[] = {
	{.compatible = "arm,coresight-fuse"},
	{}
};

static struct platform_driver fuse_driver = {
	.probe          = fuse_probe,
	.remove         = fuse_remove,