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

Commit ba8c30de authored by Mulu He's avatar Mulu He Committed by Gerrit - the friendly Code Review server
Browse files

coresight: csr: Add multiple CSR devices support



Add a CSR device list in CSR driver to support multiple CSR devices. CSR
device structure is initialized in probe and added to the list. Add CSR
device structure as parameter of CSR function. Change the caller of CSR
functions to align with this change.

Change-Id: Id904633510a82fe5fcc574d12e9b15ec5ecdfa05
Signed-off-by: default avatarMulu He <muluhe@codeaurora.org>
parent e9b98347
Loading
Loading
Loading
Loading
+44 −21
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012,2017, The Linux Foundation. All rights reserved.
 *
 * Description: CoreSight Trace Memory Controller driver
 */
@@ -372,6 +372,34 @@ static int tmc_etr_setup_caps(struct tmc_drvdata *drvdata,
	return dma_set_mask_and_coherent(drvdata->dev, DMA_BIT_MASK(dma_mask));
}

static int tmc_config_desc(struct tmc_drvdata *drvdata,
				struct coresight_desc *desc)
{
	int ret = 0;

	switch (drvdata->config_type) {
	case TMC_CONFIG_TYPE_ETB:
		desc->type = CORESIGHT_DEV_TYPE_SINK;
		desc->subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_BUFFER;
		desc->ops = &tmc_etb_cs_ops;
		break;
	case TMC_CONFIG_TYPE_ETR:
		desc->type = CORESIGHT_DEV_TYPE_SINK;
		desc->subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_BUFFER;
		desc->ops = &tmc_etr_cs_ops;
		break;
	case TMC_CONFIG_TYPE_ETF:
		desc->type = CORESIGHT_DEV_TYPE_LINKSINK;
		desc->subtype.link_subtype = CORESIGHT_DEV_SUBTYPE_LINK_FIFO;
		desc->ops = &tmc_etf_cs_ops;
		break;
	default:
		ret = -EINVAL;
	}

	return ret;
}

static int tmc_probe(struct amba_device *adev, const struct amba_id *id)
{
	int ret = 0;
@@ -429,33 +457,28 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id)

	pm_runtime_put(&adev->dev);

	ret = of_get_coresight_csr_name(adev->dev.of_node, &drvdata->csr_name);
	if (ret)
		dev_err(dev, "No csr data\n");
	else {
		drvdata->csr = coresight_csr_get(drvdata->csr_name);
		if (IS_ERR(drvdata->csr)) {
			dev_dbg(dev, "failed to get csr, defer probe\n");
			return -EPROBE_DEFER;
		}
	}

	desc.pdata = pdata;
	desc.dev = dev;
	desc.groups = coresight_tmc_groups;
	ret = tmc_config_desc(drvdata, &desc);
	if (ret)
		goto out;

	switch (drvdata->config_type) {
	case TMC_CONFIG_TYPE_ETB:
		desc.type = CORESIGHT_DEV_TYPE_SINK;
		desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_BUFFER;
		desc.ops = &tmc_etb_cs_ops;
		break;
	case TMC_CONFIG_TYPE_ETR:
		desc.type = CORESIGHT_DEV_TYPE_SINK;
		desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_BUFFER;
		desc.ops = &tmc_etr_cs_ops;
	if (drvdata->config_type == TMC_CONFIG_TYPE_ETR) {
		ret = tmc_etr_setup_caps(drvdata, devid, id->data);
		if (ret)
			goto out;
		break;
	case TMC_CONFIG_TYPE_ETF:
		desc.type = CORESIGHT_DEV_TYPE_LINKSINK;
		desc.subtype.link_subtype = CORESIGHT_DEV_SUBTYPE_LINK_FIFO;
		desc.ops = &tmc_etf_cs_ops;
		break;
	default:
		pr_err("%s: Unsupported TMC config\n", pdata->name);
		ret = -EINVAL;
		goto out;
	}

	drvdata->csdev = coresight_register(&desc);
+2 −0
Original line number Diff line number Diff line
@@ -189,6 +189,8 @@ struct tmc_drvdata {
	enum tmc_mem_intf_width	memwidth;
	u32			trigger_cntr;
	u32			etr_caps;
	struct coresight_csr	*csr;
	const char		*csr_name;
};

struct etr_buf_operations {
+19 −1
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
 * Copyright (c) 2012,2017, The Linux Foundation. All rights reserved.
 */

#include <linux/types.h>
@@ -193,3 +193,21 @@ of_get_coresight_platform_data(struct device *dev,
	return pdata;
}
EXPORT_SYMBOL_GPL(of_get_coresight_platform_data);

int of_get_coresight_csr_name(struct device_node *node, const char **csr_name)
{
	int  ret;
	struct device_node *csr_node;

	csr_node = of_parse_phandle(node, "coresight-csr", 0);
	if (!csr_node)
		return -EINVAL;

	ret = of_property_read_string(csr_node, "coresight-name", csr_name);
	of_node_put(csr_node);
	if (ret)
		return ret;

	return 0;
}
EXPORT_SYMBOL(of_get_coresight_csr_name);
+6 −1
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
 * Copyright (c) 2012,2017, The Linux Foundation. All rights reserved.
 */

#ifndef _LINUX_CORESIGHT_H
@@ -286,11 +286,16 @@ extern int of_coresight_get_cpu(const struct device_node *node);
extern struct coresight_platform_data *
of_get_coresight_platform_data(struct device *dev,
			       const struct device_node *node);
extern int of_get_coresight_csr_name(struct device_node *node,
				const char **csr_name);

#else
static inline int of_coresight_get_cpu(const struct device_node *node)
{ return 0; }
static inline struct coresight_platform_data *of_get_coresight_platform_data(
	struct device *dev, const struct device_node *node) { return NULL; }
static inline int of_get_coresight_csr_name(struct device_node *node,
		const char **csr_name){ return -EINVAL; }
#endif

#endif