Lines Matching +full:port +full:- +full:base

1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2023-2025 Qualcomm Innovation Center, Inc. All rights reserved.
18 #include "coresight-priv.h"
19 #include "coresight-tpda.h"
20 #include "coresight-trace-id.h"
21 #include "coresight-tpdm.h"
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()
71 if (tpdm_data->dsb) { 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 if (tpdm_data->cmb) { in tpdm_read_element_size()
77 rc = fwnode_property_read_u32(dev_fwnode(csdev->dev.parent), in tpdm_read_element_size()
78 "qcom,cmb-element-bits", &drvdata->cmb_esize); in tpdm_read_element_size()
82 dev_warn_once(&csdev->dev, in tpdm_read_element_size()
90 * the devicetree. Each input port of TPDA is connected to
93 * Parameter "inport" is used to pass in the input port number
94 * of TPDA, and it is set to -1 in the recursize call.
104 for (i = 0; i < csdev->pdata->nr_inconns; i++) { in tpda_get_element_size()
105 in = csdev->pdata->in_conns[i]->src_dev; in tpda_get_element_size()
109 /* Ignore the paths that do not match port */ in tpda_get_element_size()
111 csdev->pdata->in_conns[i]->dest_port != inport) in tpda_get_element_size()
115 * If this port has a hardcoded filter, use the source in tpda_get_element_size()
118 if (csdev->pdata->in_conns[i]->filter_src_fwnode) { in tpda_get_element_size()
119 in = csdev->pdata->in_conns[i]->filter_src_dev; in tpda_get_element_size()
125 if (drvdata->dsb_esize || drvdata->cmb_esize) in tpda_get_element_size()
126 return -EEXIST; in tpda_get_element_size()
132 rc = tpda_get_element_size(drvdata, in, -1); in tpda_get_element_size()
141 /* Settings pre enabling port control register */
146 val = readl_relaxed(drvdata->base + TPDA_CR); in tpda_enable_pre_port()
148 val |= FIELD_PREP(TPDA_CR_ATID, drvdata->atid); in tpda_enable_pre_port()
149 writel_relaxed(val, drvdata->base + TPDA_CR); in tpda_enable_pre_port()
152 static int tpda_enable_port(struct tpda_drvdata *drvdata, int port) in tpda_enable_port() argument
157 val = readl_relaxed(drvdata->base + TPDA_Pn_CR(port)); in tpda_enable_port()
158 tpda_clear_element_size(drvdata->csdev); in tpda_enable_port()
159 rc = tpda_get_element_size(drvdata, drvdata->csdev, port); in tpda_enable_port()
160 if (!rc && (drvdata->dsb_esize || drvdata->cmb_esize)) { in tpda_enable_port()
162 /* Enable the port */ in tpda_enable_port()
164 writel_relaxed(val, drvdata->base + TPDA_Pn_CR(port)); in tpda_enable_port()
165 } else if (rc == -EEXIST) in tpda_enable_port()
166 dev_warn_once(&drvdata->csdev->dev, in tpda_enable_port()
167 "Detected multiple TPDMs on port %d", port); in tpda_enable_port()
169 dev_warn_once(&drvdata->csdev->dev, in tpda_enable_port()
175 static int __tpda_enable(struct tpda_drvdata *drvdata, int port) in __tpda_enable() argument
179 CS_UNLOCK(drvdata->base); in __tpda_enable()
182 * Only do pre-port enable for first port that calls enable when the in __tpda_enable()
185 lockdep_assert_held(&drvdata->spinlock); in __tpda_enable()
186 if (!drvdata->csdev->refcnt) in __tpda_enable()
189 ret = tpda_enable_port(drvdata, port); in __tpda_enable()
190 CS_LOCK(drvdata->base); in __tpda_enable()
199 struct tpda_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); in tpda_enable()
202 spin_lock(&drvdata->spinlock); in tpda_enable()
203 if (in->dest_refcnt == 0) { in tpda_enable()
204 ret = __tpda_enable(drvdata, in->dest_port); in tpda_enable()
206 in->dest_refcnt++; in tpda_enable()
207 csdev->refcnt++; in tpda_enable()
208 dev_dbg(drvdata->dev, "TPDA inport %d enabled.\n", in->dest_port); in tpda_enable()
212 spin_unlock(&drvdata->spinlock); in tpda_enable()
216 static void __tpda_disable(struct tpda_drvdata *drvdata, int port) in __tpda_disable() argument
220 CS_UNLOCK(drvdata->base); in __tpda_disable()
222 val = readl_relaxed(drvdata->base + TPDA_Pn_CR(port)); in __tpda_disable()
224 writel_relaxed(val, drvdata->base + TPDA_Pn_CR(port)); in __tpda_disable()
226 CS_LOCK(drvdata->base); in __tpda_disable()
233 struct tpda_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); in tpda_disable()
235 spin_lock(&drvdata->spinlock); in tpda_disable()
236 if (--in->dest_refcnt == 0) { in tpda_disable()
237 __tpda_disable(drvdata, in->dest_port); in tpda_disable()
238 csdev->refcnt--; in tpda_disable()
240 spin_unlock(&drvdata->spinlock); in tpda_disable()
242 dev_dbg(drvdata->dev, "TPDA inport %d disabled\n", in->dest_port); in tpda_disable()
250 drvdata = dev_get_drvdata(csdev->dev.parent); in tpda_trace_id()
252 return drvdata->atid; in tpda_trace_id()
272 * same trace-id. When TPDA does packetization, different in tpda_init_default_data()
273 * port will have unique channel number for decoding. in tpda_init_default_data()
279 drvdata->atid = atid; in tpda_init_default_data()
286 struct device *dev = &adev->dev; in tpda_probe()
290 void __iomem *base; in tpda_probe() local
295 adev->dev.platform_data = pdata; in tpda_probe()
299 return -ENOMEM; in tpda_probe()
301 drvdata->dev = &adev->dev; in tpda_probe()
304 base = devm_ioremap_resource(dev, &adev->res); in tpda_probe()
305 if (IS_ERR(base)) in tpda_probe()
306 return PTR_ERR(base); in tpda_probe()
307 drvdata->base = base; in tpda_probe()
309 spin_lock_init(&drvdata->spinlock); in tpda_probe()
317 return -ENOMEM; in tpda_probe()
321 desc.pdata = adev->dev.platform_data; in tpda_probe()
322 desc.dev = &adev->dev; in tpda_probe()
323 desc.access = CSDEV_ACCESS_IOMEM(base); in tpda_probe()
324 drvdata->csdev = coresight_register(&desc); in tpda_probe()
325 if (IS_ERR(drvdata->csdev)) in tpda_probe()
326 return PTR_ERR(drvdata->csdev); in tpda_probe()
328 pm_runtime_put(&adev->dev); in tpda_probe()
330 dev_dbg(drvdata->dev, "TPDA initialized\n"); in tpda_probe()
336 struct tpda_drvdata *drvdata = dev_get_drvdata(&adev->dev); in tpda_remove()
338 coresight_trace_id_put_system_id(drvdata->atid); in tpda_remove()
339 coresight_unregister(drvdata->csdev); in tpda_remove()
344 * The difference is 0-7 bits' value. So ignore 0-7 bits.
356 .name = "coresight-tpda",