Lines Matching +full:coresight +full:- +full:tpda
1 // SPDX-License-Identifier: GPL-2.0
8 #include <linux/coresight.h>
18 #include "coresight-priv.h"
19 #include "coresight-tpda.h"
20 #include "coresight-trace-id.h"
22 DEFINE_CORESIGHT_DEVLIST(tpda_devs, "tpda");
26 return (csdev->type == CORESIGHT_DEV_TYPE_SOURCE) && in coresight_device_is_tpdm()
27 (csdev->subtype.source_subtype == in coresight_device_is_tpdm()
35 * 0 - Otherwise, with a warning once.
42 rc = fwnode_property_read_u8(dev_fwnode(csdev->dev.parent), in tpdm_read_dsb_element_size()
43 "qcom,dsb-element-size", &size); in tpdm_read_dsb_element_size()
45 dev_warn_once(&csdev->dev, in tpdm_read_dsb_element_size()
53 * the devicetree. Each input port of TPDA is connected to
57 * of TPDA, and it is set to -1 in the recursize call.
62 int dsb_size = -ENOENT; in tpda_get_element_size()
66 for (i = 0; i < csdev->pdata->nr_inconns; i++) { in tpda_get_element_size()
67 in = csdev->pdata->in_conns[i]->src_dev; in tpda_get_element_size()
73 csdev->pdata->in_conns[i]->dest_port != inport) in tpda_get_element_size()
80 size = tpda_get_element_size(in, -1); in tpda_get_element_size()
91 return -EEXIST; in tpda_get_element_size()
103 val = readl_relaxed(drvdata->base + TPDA_CR); in tpda_enable_pre_port()
105 val |= FIELD_PREP(TPDA_CR_ATID, drvdata->atid); in tpda_enable_pre_port()
106 writel_relaxed(val, drvdata->base + TPDA_CR); in tpda_enable_pre_port()
114 val = readl_relaxed(drvdata->base + TPDA_Pn_CR(port)); in tpda_enable_port()
120 size = tpda_get_element_size(drvdata->csdev, port); in tpda_enable_port()
129 return -EEXIST; in tpda_enable_port()
130 case -EEXIST: in tpda_enable_port()
131 dev_warn_once(&drvdata->csdev->dev, in tpda_enable_port()
132 "Detected multiple TPDMs on port %d", -EEXIST); in tpda_enable_port()
133 return -EEXIST; in tpda_enable_port()
135 return -EINVAL; in tpda_enable_port()
140 writel_relaxed(val, drvdata->base + TPDA_Pn_CR(port)); in tpda_enable_port()
149 CS_UNLOCK(drvdata->base); in __tpda_enable()
151 if (!drvdata->csdev->enable) in __tpda_enable()
155 CS_LOCK(drvdata->base); in __tpda_enable()
164 struct tpda_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); in tpda_enable()
167 spin_lock(&drvdata->spinlock); in tpda_enable()
168 if (atomic_read(&in->dest_refcnt) == 0) { in tpda_enable()
169 ret = __tpda_enable(drvdata, in->dest_port); in tpda_enable()
171 atomic_inc(&in->dest_refcnt); in tpda_enable()
172 dev_dbg(drvdata->dev, "TPDA inport %d enabled.\n", in->dest_port); in tpda_enable()
176 spin_unlock(&drvdata->spinlock); in tpda_enable()
184 CS_UNLOCK(drvdata->base); in __tpda_disable()
186 val = readl_relaxed(drvdata->base + TPDA_Pn_CR(port)); in __tpda_disable()
188 writel_relaxed(val, drvdata->base + TPDA_Pn_CR(port)); in __tpda_disable()
190 CS_LOCK(drvdata->base); in __tpda_disable()
197 struct tpda_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); in tpda_disable()
199 spin_lock(&drvdata->spinlock); in tpda_disable()
200 if (atomic_dec_return(&in->dest_refcnt) == 0) in tpda_disable()
201 __tpda_disable(drvdata, in->dest_port); in tpda_disable()
203 spin_unlock(&drvdata->spinlock); in tpda_disable()
205 dev_dbg(drvdata->dev, "TPDA inport %d disabled\n", in->dest_port); in tpda_disable()
221 * TPDA must has a unique atid. This atid can uniquely in tpda_init_default_data()
222 * identify the TPDM trace source connected to the TPDA. in tpda_init_default_data()
223 * The TPDMs which are connected to same TPDA share the in tpda_init_default_data()
224 * same trace-id. When TPDA does packetization, different in tpda_init_default_data()
231 drvdata->atid = atid; in tpda_init_default_data()
238 struct device *dev = &adev->dev; in tpda_probe()
247 adev->dev.platform_data = pdata; in tpda_probe()
251 return -ENOMEM; in tpda_probe()
253 drvdata->dev = &adev->dev; in tpda_probe()
256 base = devm_ioremap_resource(dev, &adev->res); in tpda_probe()
259 drvdata->base = base; in tpda_probe()
261 spin_lock_init(&drvdata->spinlock); in tpda_probe()
269 return -ENOMEM; in tpda_probe()
273 desc.pdata = adev->dev.platform_data; in tpda_probe()
274 desc.dev = &adev->dev; in tpda_probe()
276 drvdata->csdev = coresight_register(&desc); in tpda_probe()
277 if (IS_ERR(drvdata->csdev)) in tpda_probe()
278 return PTR_ERR(drvdata->csdev); in tpda_probe()
280 pm_runtime_put(&adev->dev); in tpda_probe()
282 dev_dbg(drvdata->dev, "TPDA initialized\n"); in tpda_probe()
288 struct tpda_drvdata *drvdata = dev_get_drvdata(&adev->dev); in tpda_remove()
290 coresight_trace_id_put_system_id(drvdata->atid); in tpda_remove()
291 coresight_unregister(drvdata->csdev); in tpda_remove()
295 * Different TPDA has different periph id.
296 * The difference is 0-7 bits' value. So ignore 0-7 bits.
308 .name = "coresight-tpda",