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"
21 #include "coresight-tpdm.h"
23 DEFINE_CORESIGHT_DEVLIST(tpda_devs, "tpda");
27 return (csdev->type == CORESIGHT_DEV_TYPE_SOURCE) && in coresight_device_is_tpdm()
28 (csdev->subtype.source_subtype == in coresight_device_is_tpdm()
34 struct tpda_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); in tpda_clear_element_size()
36 drvdata->dsb_esize = 0; in tpda_clear_element_size()
37 drvdata->cmb_esize = 0; in tpda_clear_element_size()
45 if (drvdata->dsb_esize == 64) in tpda_set_element_size()
47 else if (drvdata->dsb_esize == 32) in tpda_set_element_size()
50 if (drvdata->cmb_esize == 64) in tpda_set_element_size()
52 else if (drvdata->cmb_esize == 32) in tpda_set_element_size()
54 else if (drvdata->cmb_esize == 8) in tpda_set_element_size()
62 * 0 - The element size property is read
63 * Others - Cannot read the property of the element size
68 int rc = -EINVAL; in tpdm_read_element_size()
69 struct tpdm_drvdata *tpdm_data = dev_get_drvdata(csdev->dev.parent); in tpdm_read_element_size()
72 rc = fwnode_property_read_u32(dev_fwnode(csdev->dev.parent), in tpdm_read_element_size()
73 "qcom,dsb-element-bits", &drvdata->dsb_esize); in tpdm_read_element_size()
76 rc = fwnode_property_read_u32(dev_fwnode(csdev->dev.parent), in tpdm_read_element_size()
77 "qcom,cmb-element-bits", &drvdata->cmb_esize); in tpdm_read_element_size()
81 dev_warn_once(&csdev->dev, in tpdm_read_element_size()
89 * the devicetree. Each input port of TPDA is connected to
93 * of TPDA, and it is set to -1 in the recursize call.
103 for (i = 0; i < csdev->pdata->nr_inconns; i++) { in tpda_get_element_size()
104 in = csdev->pdata->in_conns[i]->src_dev; in tpda_get_element_size()
110 csdev->pdata->in_conns[i]->dest_port != inport) in tpda_get_element_size()
114 if (drvdata->dsb_esize || drvdata->cmb_esize) in tpda_get_element_size()
115 return -EEXIST; in tpda_get_element_size()
121 rc = tpda_get_element_size(drvdata, in, -1); in tpda_get_element_size()
136 val = readl_relaxed(drvdata->base + TPDA_CR); in tpda_enable_pre_port()
138 val |= FIELD_PREP(TPDA_CR_ATID, drvdata->atid); in tpda_enable_pre_port()
139 writel_relaxed(val, drvdata->base + TPDA_CR); in tpda_enable_pre_port()
147 val = readl_relaxed(drvdata->base + TPDA_Pn_CR(port)); in tpda_enable_port()
148 tpda_clear_element_size(drvdata->csdev); in tpda_enable_port()
149 rc = tpda_get_element_size(drvdata, drvdata->csdev, port); in tpda_enable_port()
150 if (!rc && (drvdata->dsb_esize || drvdata->cmb_esize)) { in tpda_enable_port()
154 writel_relaxed(val, drvdata->base + TPDA_Pn_CR(port)); in tpda_enable_port()
155 } else if (rc == -EEXIST) in tpda_enable_port()
156 dev_warn_once(&drvdata->csdev->dev, in tpda_enable_port()
159 dev_warn_once(&drvdata->csdev->dev, in tpda_enable_port()
169 CS_UNLOCK(drvdata->base); in __tpda_enable()
172 * Only do pre-port enable for first port that calls enable when the in __tpda_enable()
175 lockdep_assert_held(&drvdata->spinlock); in __tpda_enable()
176 if (!drvdata->csdev->refcnt) in __tpda_enable()
180 CS_LOCK(drvdata->base); in __tpda_enable()
189 struct tpda_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); in tpda_enable()
192 spin_lock(&drvdata->spinlock); in tpda_enable()
193 if (atomic_read(&in->dest_refcnt) == 0) { in tpda_enable()
194 ret = __tpda_enable(drvdata, in->dest_port); in tpda_enable()
196 atomic_inc(&in->dest_refcnt); in tpda_enable()
197 csdev->refcnt++; in tpda_enable()
198 dev_dbg(drvdata->dev, "TPDA inport %d enabled.\n", in->dest_port); in tpda_enable()
202 spin_unlock(&drvdata->spinlock); in tpda_enable()
210 CS_UNLOCK(drvdata->base); in __tpda_disable()
212 val = readl_relaxed(drvdata->base + TPDA_Pn_CR(port)); in __tpda_disable()
214 writel_relaxed(val, drvdata->base + TPDA_Pn_CR(port)); in __tpda_disable()
216 CS_LOCK(drvdata->base); in __tpda_disable()
223 struct tpda_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); in tpda_disable()
225 spin_lock(&drvdata->spinlock); in tpda_disable()
226 if (atomic_dec_return(&in->dest_refcnt) == 0) { in tpda_disable()
227 __tpda_disable(drvdata, in->dest_port); in tpda_disable()
228 csdev->refcnt--; in tpda_disable()
230 spin_unlock(&drvdata->spinlock); in tpda_disable()
232 dev_dbg(drvdata->dev, "TPDA inport %d disabled\n", in->dest_port); in tpda_disable()
248 * TPDA must has a unique atid. This atid can uniquely in tpda_init_default_data()
249 * identify the TPDM trace source connected to the TPDA. in tpda_init_default_data()
250 * The TPDMs which are connected to same TPDA share the in tpda_init_default_data()
251 * same trace-id. When TPDA does packetization, different in tpda_init_default_data()
258 drvdata->atid = atid; in tpda_init_default_data()
265 struct device *dev = &adev->dev; in tpda_probe()
274 adev->dev.platform_data = pdata; in tpda_probe()
278 return -ENOMEM; in tpda_probe()
280 drvdata->dev = &adev->dev; in tpda_probe()
283 base = devm_ioremap_resource(dev, &adev->res); in tpda_probe()
286 drvdata->base = base; in tpda_probe()
288 spin_lock_init(&drvdata->spinlock); in tpda_probe()
296 return -ENOMEM; in tpda_probe()
300 desc.pdata = adev->dev.platform_data; in tpda_probe()
301 desc.dev = &adev->dev; in tpda_probe()
303 drvdata->csdev = coresight_register(&desc); in tpda_probe()
304 if (IS_ERR(drvdata->csdev)) in tpda_probe()
305 return PTR_ERR(drvdata->csdev); in tpda_probe()
307 pm_runtime_put(&adev->dev); in tpda_probe()
309 dev_dbg(drvdata->dev, "TPDA initialized\n"); in tpda_probe()
315 struct tpda_drvdata *drvdata = dev_get_drvdata(&adev->dev); in tpda_remove()
317 coresight_trace_id_put_system_id(drvdata->atid); in tpda_remove()
318 coresight_unregister(drvdata->csdev); in tpda_remove()
322 * Different TPDA has different periph id.
323 * The difference is 0-7 bits' value. So ignore 0-7 bits.
335 .name = "coresight-tpda",