Linux Audio

Check our new training course

Linux BSP upgrade and security maintenance

Need help to get security updates for your Linux BSP?
Loading...
v4.6
  1/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
 
 
  2 *
  3 * Description: CoreSight Funnel driver
  4 *
  5 * This program is free software; you can redistribute it and/or modify
  6 * it under the terms of the GNU General Public License version 2 and
  7 * only version 2 as published by the Free Software Foundation.
  8 *
  9 * This program is distributed in the hope that it will be useful,
 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 12 * GNU General Public License for more details.
 13 */
 14
 
 15#include <linux/kernel.h>
 16#include <linux/init.h>
 17#include <linux/types.h>
 18#include <linux/device.h>
 19#include <linux/err.h>
 20#include <linux/fs.h>
 21#include <linux/slab.h>
 
 
 22#include <linux/pm_runtime.h>
 23#include <linux/coresight.h>
 24#include <linux/amba/bus.h>
 25#include <linux/clk.h>
 26
 27#include "coresight-priv.h"
 28
 29#define FUNNEL_FUNCTL		0x000
 30#define FUNNEL_PRICTL		0x004
 31
 32#define FUNNEL_HOLDTIME_MASK	0xf00
 33#define FUNNEL_HOLDTIME_SHFT	0x8
 34#define FUNNEL_HOLDTIME		(0x7 << FUNNEL_HOLDTIME_SHFT)
 
 
 
 35
 36/**
 37 * struct funnel_drvdata - specifics associated to a funnel component
 38 * @base:	memory mapped base address for this component.
 39 * @dev:	the device entity associated to this component.
 40 * @atclk:	optional clock for the core parts of the funnel.
 
 41 * @csdev:	component vitals needed by the framework.
 42 * @priority:	port selection order.
 
 43 */
 44struct funnel_drvdata {
 45	void __iomem		*base;
 46	struct device		*dev;
 47	struct clk		*atclk;
 
 48	struct coresight_device	*csdev;
 49	unsigned long		priority;
 
 50};
 51
 52static void funnel_enable_hw(struct funnel_drvdata *drvdata, int port)
 53{
 54	u32 functl;
 
 
 55
 56	CS_UNLOCK(drvdata->base);
 57
 58	functl = readl_relaxed(drvdata->base + FUNNEL_FUNCTL);
 
 
 
 
 
 
 
 59	functl &= ~FUNNEL_HOLDTIME_MASK;
 60	functl |= FUNNEL_HOLDTIME;
 61	functl |= (1 << port);
 62	writel_relaxed(functl, drvdata->base + FUNNEL_FUNCTL);
 63	writel_relaxed(drvdata->priority, drvdata->base + FUNNEL_PRICTL);
 64
 65	CS_LOCK(drvdata->base);
 
 66}
 67
 68static int funnel_enable(struct coresight_device *csdev, int inport,
 69			 int outport)
 
 70{
 
 71	struct funnel_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
 
 
 72
 73	funnel_enable_hw(drvdata, inport);
 74
 75	dev_info(drvdata->dev, "FUNNEL inport %d enabled\n", inport);
 76	return 0;
 
 
 
 
 
 
 
 
 
 
 
 77}
 78
 79static void funnel_disable_hw(struct funnel_drvdata *drvdata, int inport)
 
 80{
 81	u32 functl;
 
 82
 83	CS_UNLOCK(drvdata->base);
 84
 85	functl = readl_relaxed(drvdata->base + FUNNEL_FUNCTL);
 86	functl &= ~(1 << inport);
 87	writel_relaxed(functl, drvdata->base + FUNNEL_FUNCTL);
 88
 
 
 
 
 89	CS_LOCK(drvdata->base);
 90}
 91
 92static void funnel_disable(struct coresight_device *csdev, int inport,
 93			   int outport)
 
 94{
 95	struct funnel_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
 
 
 96
 97	funnel_disable_hw(drvdata, inport);
 
 
 
 
 
 
 98
 99	dev_info(drvdata->dev, "FUNNEL inport %d disabled\n", inport);
 
 
100}
101
102static const struct coresight_ops_link funnel_link_ops = {
103	.enable		= funnel_enable,
104	.disable	= funnel_disable,
105};
106
107static const struct coresight_ops funnel_cs_ops = {
108	.link_ops	= &funnel_link_ops,
109};
110
111static ssize_t priority_show(struct device *dev,
112			     struct device_attribute *attr, char *buf)
113{
114	struct funnel_drvdata *drvdata = dev_get_drvdata(dev->parent);
115	unsigned long val = drvdata->priority;
116
117	return sprintf(buf, "%#lx\n", val);
118}
119
120static ssize_t priority_store(struct device *dev,
121			      struct device_attribute *attr,
122			      const char *buf, size_t size)
123{
124	int ret;
125	unsigned long val;
126	struct funnel_drvdata *drvdata = dev_get_drvdata(dev->parent);
127
128	ret = kstrtoul(buf, 16, &val);
129	if (ret)
130		return ret;
131
132	drvdata->priority = val;
133	return size;
134}
135static DEVICE_ATTR_RW(priority);
136
137static u32 get_funnel_ctrl_hw(struct funnel_drvdata *drvdata)
138{
139	u32 functl;
140
141	CS_UNLOCK(drvdata->base);
142	functl = readl_relaxed(drvdata->base + FUNNEL_FUNCTL);
143	CS_LOCK(drvdata->base);
144
145	return functl;
146}
147
148static ssize_t funnel_ctrl_show(struct device *dev,
149			     struct device_attribute *attr, char *buf)
150{
151	u32 val;
152	struct funnel_drvdata *drvdata = dev_get_drvdata(dev->parent);
153
154	pm_runtime_get_sync(drvdata->dev);
155
156	val = get_funnel_ctrl_hw(drvdata);
157
158	pm_runtime_put(drvdata->dev);
159
160	return sprintf(buf, "%#x\n", val);
161}
162static DEVICE_ATTR_RO(funnel_ctrl);
163
164static struct attribute *coresight_funnel_attrs[] = {
165	&dev_attr_funnel_ctrl.attr,
166	&dev_attr_priority.attr,
167	NULL,
168};
169ATTRIBUTE_GROUPS(coresight_funnel);
170
171static int funnel_probe(struct amba_device *adev, const struct amba_id *id)
172{
173	int ret;
174	void __iomem *base;
175	struct device *dev = &adev->dev;
176	struct coresight_platform_data *pdata = NULL;
177	struct funnel_drvdata *drvdata;
178	struct resource *res = &adev->res;
179	struct coresight_desc *desc;
180	struct device_node *np = adev->dev.of_node;
181
182	if (np) {
183		pdata = of_get_coresight_platform_data(dev, np);
184		if (IS_ERR(pdata))
185			return PTR_ERR(pdata);
186		adev->dev.platform_data = pdata;
187	}
188
189	drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
190	if (!drvdata)
191		return -ENOMEM;
192
193	drvdata->dev = &adev->dev;
194	drvdata->atclk = devm_clk_get(&adev->dev, "atclk"); /* optional */
195	if (!IS_ERR(drvdata->atclk)) {
196		ret = clk_prepare_enable(drvdata->atclk);
197		if (ret)
198			return ret;
199	}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200	dev_set_drvdata(dev, drvdata);
201
202	/* Validity for the resource is already checked by the AMBA core */
203	base = devm_ioremap_resource(dev, res);
204	if (IS_ERR(base))
205		return PTR_ERR(base);
 
 
206
207	drvdata->base = base;
208	pm_runtime_put(&adev->dev);
 
 
 
 
 
 
 
 
 
209
210	desc = devm_kzalloc(dev, sizeof(*desc), GFP_KERNEL);
211	if (!desc)
212		return -ENOMEM;
213
214	desc->type = CORESIGHT_DEV_TYPE_LINK;
215	desc->subtype.link_subtype = CORESIGHT_DEV_SUBTYPE_LINK_MERG;
216	desc->ops = &funnel_cs_ops;
217	desc->pdata = pdata;
218	desc->dev = dev;
219	desc->groups = coresight_funnel_groups;
220	drvdata->csdev = coresight_register(desc);
221	if (IS_ERR(drvdata->csdev))
222		return PTR_ERR(drvdata->csdev);
 
 
 
 
223
224	dev_info(dev, "FUNNEL initialized\n");
225	return 0;
226}
227
228#ifdef CONFIG_PM
229static int funnel_runtime_suspend(struct device *dev)
230{
231	struct funnel_drvdata *drvdata = dev_get_drvdata(dev);
232
233	if (drvdata && !IS_ERR(drvdata->atclk))
234		clk_disable_unprepare(drvdata->atclk);
235
 
 
 
236	return 0;
237}
238
239static int funnel_runtime_resume(struct device *dev)
240{
241	struct funnel_drvdata *drvdata = dev_get_drvdata(dev);
242
243	if (drvdata && !IS_ERR(drvdata->atclk))
244		clk_prepare_enable(drvdata->atclk);
245
 
 
246	return 0;
247}
248#endif
249
250static const struct dev_pm_ops funnel_dev_pm_ops = {
251	SET_RUNTIME_PM_OPS(funnel_runtime_suspend, funnel_runtime_resume, NULL)
252};
253
254static struct amba_id funnel_ids[] = {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
255	{
256		.id     = 0x0003b908,
257		.mask   = 0x0003ffff,
 
258	},
259	{ 0, 0},
260};
261
262static struct amba_driver funnel_driver = {
 
 
263	.drv = {
264		.name	= "coresight-funnel",
265		.owner	= THIS_MODULE,
266		.pm	= &funnel_dev_pm_ops,
267		.suppress_bind_attrs = true,
268	},
269	.probe		= funnel_probe,
270	.id_table	= funnel_ids,
 
271};
272builtin_amba_driver(funnel_driver);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
v6.13.7
  1// SPDX-License-Identifier: GPL-2.0
  2/*
  3 * Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
  4 *
  5 * Description: CoreSight Funnel driver
 
 
 
 
 
 
 
 
 
  6 */
  7
  8#include <linux/acpi.h>
  9#include <linux/kernel.h>
 10#include <linux/init.h>
 11#include <linux/types.h>
 12#include <linux/device.h>
 13#include <linux/err.h>
 14#include <linux/fs.h>
 15#include <linux/slab.h>
 16#include <linux/of.h>
 17#include <linux/platform_device.h>
 18#include <linux/pm_runtime.h>
 19#include <linux/coresight.h>
 20#include <linux/amba/bus.h>
 21#include <linux/clk.h>
 22
 23#include "coresight-priv.h"
 24
 25#define FUNNEL_FUNCTL		0x000
 26#define FUNNEL_PRICTL		0x004
 27
 28#define FUNNEL_HOLDTIME_MASK	0xf00
 29#define FUNNEL_HOLDTIME_SHFT	0x8
 30#define FUNNEL_HOLDTIME		(0x7 << FUNNEL_HOLDTIME_SHFT)
 31#define FUNNEL_ENSx_MASK	0xff
 32
 33DEFINE_CORESIGHT_DEVLIST(funnel_devs, "funnel");
 34
 35/**
 36 * struct funnel_drvdata - specifics associated to a funnel component
 37 * @base:	memory mapped base address for this component.
 
 38 * @atclk:	optional clock for the core parts of the funnel.
 39 * @pclk:	APB clock if present, otherwise NULL
 40 * @csdev:	component vitals needed by the framework.
 41 * @priority:	port selection order.
 42 * @spinlock:	serialize enable/disable operations.
 43 */
 44struct funnel_drvdata {
 45	void __iomem		*base;
 
 46	struct clk		*atclk;
 47	struct clk		*pclk;
 48	struct coresight_device	*csdev;
 49	unsigned long		priority;
 50	spinlock_t		spinlock;
 51};
 52
 53static int dynamic_funnel_enable_hw(struct funnel_drvdata *drvdata, int port)
 54{
 55	u32 functl;
 56	int rc = 0;
 57	struct coresight_device *csdev = drvdata->csdev;
 58
 59	CS_UNLOCK(drvdata->base);
 60
 61	functl = readl_relaxed(drvdata->base + FUNNEL_FUNCTL);
 62	/* Claim the device only when we enable the first slave */
 63	if (!(functl & FUNNEL_ENSx_MASK)) {
 64		rc = coresight_claim_device_unlocked(csdev);
 65		if (rc)
 66			goto done;
 67	}
 68
 69	functl &= ~FUNNEL_HOLDTIME_MASK;
 70	functl |= FUNNEL_HOLDTIME;
 71	functl |= (1 << port);
 72	writel_relaxed(functl, drvdata->base + FUNNEL_FUNCTL);
 73	writel_relaxed(drvdata->priority, drvdata->base + FUNNEL_PRICTL);
 74done:
 75	CS_LOCK(drvdata->base);
 76	return rc;
 77}
 78
 79static int funnel_enable(struct coresight_device *csdev,
 80			 struct coresight_connection *in,
 81			 struct coresight_connection *out)
 82{
 83	int rc = 0;
 84	struct funnel_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
 85	unsigned long flags;
 86	bool first_enable = false;
 87
 88	spin_lock_irqsave(&drvdata->spinlock, flags);
 89	if (atomic_read(&in->dest_refcnt) == 0) {
 90		if (drvdata->base)
 91			rc = dynamic_funnel_enable_hw(drvdata, in->dest_port);
 92		if (!rc)
 93			first_enable = true;
 94	}
 95	if (!rc)
 96		atomic_inc(&in->dest_refcnt);
 97	spin_unlock_irqrestore(&drvdata->spinlock, flags);
 98
 99	if (first_enable)
100		dev_dbg(&csdev->dev, "FUNNEL inport %d enabled\n",
101			in->dest_port);
102	return rc;
103}
104
105static void dynamic_funnel_disable_hw(struct funnel_drvdata *drvdata,
106				      int inport)
107{
108	u32 functl;
109	struct coresight_device *csdev = drvdata->csdev;
110
111	CS_UNLOCK(drvdata->base);
112
113	functl = readl_relaxed(drvdata->base + FUNNEL_FUNCTL);
114	functl &= ~(1 << inport);
115	writel_relaxed(functl, drvdata->base + FUNNEL_FUNCTL);
116
117	/* Disclaim the device if none of the slaves are now active */
118	if (!(functl & FUNNEL_ENSx_MASK))
119		coresight_disclaim_device_unlocked(csdev);
120
121	CS_LOCK(drvdata->base);
122}
123
124static void funnel_disable(struct coresight_device *csdev,
125			   struct coresight_connection *in,
126			   struct coresight_connection *out)
127{
128	struct funnel_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
129	unsigned long flags;
130	bool last_disable = false;
131
132	spin_lock_irqsave(&drvdata->spinlock, flags);
133	if (atomic_dec_return(&in->dest_refcnt) == 0) {
134		if (drvdata->base)
135			dynamic_funnel_disable_hw(drvdata, in->dest_port);
136		last_disable = true;
137	}
138	spin_unlock_irqrestore(&drvdata->spinlock, flags);
139
140	if (last_disable)
141		dev_dbg(&csdev->dev, "FUNNEL inport %d disabled\n",
142			in->dest_port);
143}
144
145static const struct coresight_ops_link funnel_link_ops = {
146	.enable		= funnel_enable,
147	.disable	= funnel_disable,
148};
149
150static const struct coresight_ops funnel_cs_ops = {
151	.link_ops	= &funnel_link_ops,
152};
153
154static ssize_t priority_show(struct device *dev,
155			     struct device_attribute *attr, char *buf)
156{
157	struct funnel_drvdata *drvdata = dev_get_drvdata(dev->parent);
158	unsigned long val = drvdata->priority;
159
160	return sprintf(buf, "%#lx\n", val);
161}
162
163static ssize_t priority_store(struct device *dev,
164			      struct device_attribute *attr,
165			      const char *buf, size_t size)
166{
167	int ret;
168	unsigned long val;
169	struct funnel_drvdata *drvdata = dev_get_drvdata(dev->parent);
170
171	ret = kstrtoul(buf, 16, &val);
172	if (ret)
173		return ret;
174
175	drvdata->priority = val;
176	return size;
177}
178static DEVICE_ATTR_RW(priority);
179
180static u32 get_funnel_ctrl_hw(struct funnel_drvdata *drvdata)
181{
182	u32 functl;
183
184	CS_UNLOCK(drvdata->base);
185	functl = readl_relaxed(drvdata->base + FUNNEL_FUNCTL);
186	CS_LOCK(drvdata->base);
187
188	return functl;
189}
190
191static ssize_t funnel_ctrl_show(struct device *dev,
192			     struct device_attribute *attr, char *buf)
193{
194	u32 val;
195	struct funnel_drvdata *drvdata = dev_get_drvdata(dev->parent);
196
197	pm_runtime_get_sync(dev->parent);
198
199	val = get_funnel_ctrl_hw(drvdata);
200
201	pm_runtime_put(dev->parent);
202
203	return sprintf(buf, "%#x\n", val);
204}
205static DEVICE_ATTR_RO(funnel_ctrl);
206
207static struct attribute *coresight_funnel_attrs[] = {
208	&dev_attr_funnel_ctrl.attr,
209	&dev_attr_priority.attr,
210	NULL,
211};
212ATTRIBUTE_GROUPS(coresight_funnel);
213
214static int funnel_probe(struct device *dev, struct resource *res)
215{
216	int ret;
217	void __iomem *base;
 
218	struct coresight_platform_data *pdata = NULL;
219	struct funnel_drvdata *drvdata;
220	struct coresight_desc desc = { 0 };
221
222	if (is_of_node(dev_fwnode(dev)) &&
223	    of_device_is_compatible(dev->of_node, "arm,coresight-funnel"))
224		dev_warn_once(dev, "Uses OBSOLETE CoreSight funnel binding\n");
225
226	desc.name = coresight_alloc_device_name(&funnel_devs, dev);
227	if (!desc.name)
228		return -ENOMEM;
 
229
230	drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
231	if (!drvdata)
232		return -ENOMEM;
233
234	drvdata->atclk = devm_clk_get(dev, "atclk"); /* optional */
 
235	if (!IS_ERR(drvdata->atclk)) {
236		ret = clk_prepare_enable(drvdata->atclk);
237		if (ret)
238			return ret;
239	}
240
241	drvdata->pclk = coresight_get_enable_apb_pclk(dev);
242	if (IS_ERR(drvdata->pclk))
243		return -ENODEV;
244
245	/*
246	 * Map the device base for dynamic-funnel, which has been
247	 * validated by AMBA core.
248	 */
249	if (res) {
250		base = devm_ioremap_resource(dev, res);
251		if (IS_ERR(base)) {
252			ret = PTR_ERR(base);
253			goto out_disable_clk;
254		}
255		drvdata->base = base;
256		desc.groups = coresight_funnel_groups;
257		desc.access = CSDEV_ACCESS_IOMEM(base);
258	}
259
260	dev_set_drvdata(dev, drvdata);
261
262	pdata = coresight_get_platform_data(dev);
263	if (IS_ERR(pdata)) {
264		ret = PTR_ERR(pdata);
265		goto out_disable_clk;
266	}
267	dev->platform_data = pdata;
268
269	spin_lock_init(&drvdata->spinlock);
270	desc.type = CORESIGHT_DEV_TYPE_LINK;
271	desc.subtype.link_subtype = CORESIGHT_DEV_SUBTYPE_LINK_MERG;
272	desc.ops = &funnel_cs_ops;
273	desc.pdata = pdata;
274	desc.dev = dev;
275	drvdata->csdev = coresight_register(&desc);
276	if (IS_ERR(drvdata->csdev)) {
277		ret = PTR_ERR(drvdata->csdev);
278		goto out_disable_clk;
279	}
280
281	ret = 0;
 
 
282
283out_disable_clk:
284	if (ret && !IS_ERR_OR_NULL(drvdata->atclk))
285		clk_disable_unprepare(drvdata->atclk);
286	if (ret && !IS_ERR_OR_NULL(drvdata->pclk))
287		clk_disable_unprepare(drvdata->pclk);
288	return ret;
289}
290
291static int funnel_remove(struct device *dev)
292{
293	struct funnel_drvdata *drvdata = dev_get_drvdata(dev);
294
295	coresight_unregister(drvdata->csdev);
296
 
297	return 0;
298}
299
300#ifdef CONFIG_PM
301static int funnel_runtime_suspend(struct device *dev)
302{
303	struct funnel_drvdata *drvdata = dev_get_drvdata(dev);
304
305	if (drvdata && !IS_ERR(drvdata->atclk))
306		clk_disable_unprepare(drvdata->atclk);
307
308	if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk))
309		clk_disable_unprepare(drvdata->pclk);
310
311	return 0;
312}
313
314static int funnel_runtime_resume(struct device *dev)
315{
316	struct funnel_drvdata *drvdata = dev_get_drvdata(dev);
317
318	if (drvdata && !IS_ERR(drvdata->atclk))
319		clk_prepare_enable(drvdata->atclk);
320
321	if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk))
322		clk_prepare_enable(drvdata->pclk);
323	return 0;
324}
325#endif
326
327static const struct dev_pm_ops funnel_dev_pm_ops = {
328	SET_RUNTIME_PM_OPS(funnel_runtime_suspend, funnel_runtime_resume, NULL)
329};
330
331static int funnel_platform_probe(struct platform_device *pdev)
332{
333	struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
334	int ret;
335
336	pm_runtime_get_noresume(&pdev->dev);
337	pm_runtime_set_active(&pdev->dev);
338	pm_runtime_enable(&pdev->dev);
339
340	ret = funnel_probe(&pdev->dev, res);
341	pm_runtime_put(&pdev->dev);
342	if (ret)
343		pm_runtime_disable(&pdev->dev);
344
345	return ret;
346}
347
348static void funnel_platform_remove(struct platform_device *pdev)
349{
350	struct funnel_drvdata *drvdata = dev_get_drvdata(&pdev->dev);
351
352	if (WARN_ON(!drvdata))
353		return;
354
355	funnel_remove(&pdev->dev);
356	pm_runtime_disable(&pdev->dev);
357	if (!IS_ERR_OR_NULL(drvdata->pclk))
358		clk_put(drvdata->pclk);
359}
360
361static const struct of_device_id funnel_match[] = {
362	{.compatible = "arm,coresight-static-funnel"},
363	{}
364};
365
366MODULE_DEVICE_TABLE(of, funnel_match);
367
368#ifdef CONFIG_ACPI
369static const struct acpi_device_id funnel_acpi_ids[] = {
370	{"ARMHC9FE", 0, 0, 0}, /* ARM Coresight Static Funnel */
371	{"ARMHC9FF", 0, 0, 0}, /* ARM CoreSight Dynamic Funnel */
372	{},
373};
374
375MODULE_DEVICE_TABLE(acpi, funnel_acpi_ids);
376#endif
377
378static struct platform_driver funnel_driver = {
379	.probe		= funnel_platform_probe,
380	.remove		= funnel_platform_remove,
381	.driver		= {
382		.name   = "coresight-funnel",
383		/* THIS_MODULE is taken care of by platform_driver_register() */
384		.of_match_table = funnel_match,
385		.acpi_match_table = ACPI_PTR(funnel_acpi_ids),
386		.pm	= &funnel_dev_pm_ops,
387		.suppress_bind_attrs = true,
388	},
389};
390
391static int dynamic_funnel_probe(struct amba_device *adev,
392				const struct amba_id *id)
393{
394	int ret;
395
396	ret = funnel_probe(&adev->dev, &adev->res);
397	if (!ret)
398		pm_runtime_put(&adev->dev);
399
400	return ret;
401}
402
403static void dynamic_funnel_remove(struct amba_device *adev)
404{
405	funnel_remove(&adev->dev);
406}
407
408static const struct amba_id dynamic_funnel_ids[] = {
409	{
410		.id     = 0x000bb908,
411		.mask   = 0x000fffff,
412	},
413	{
414		/* Coresight SoC-600 */
415		.id     = 0x000bb9eb,
416		.mask   = 0x000fffff,
417	},
418	{ 0, 0, NULL },
419};
420
421MODULE_DEVICE_TABLE(amba, dynamic_funnel_ids);
422
423static struct amba_driver dynamic_funnel_driver = {
424	.drv = {
425		.name	= "coresight-dynamic-funnel",
 
426		.pm	= &funnel_dev_pm_ops,
427		.suppress_bind_attrs = true,
428	},
429	.probe		= dynamic_funnel_probe,
430	.remove		= dynamic_funnel_remove,
431	.id_table	= dynamic_funnel_ids,
432};
433
434static int __init funnel_init(void)
435{
436	return coresight_init_driver("funnel", &dynamic_funnel_driver, &funnel_driver);
437}
438
439static void __exit funnel_exit(void)
440{
441	coresight_remove_driver(&dynamic_funnel_driver, &funnel_driver);
442}
443
444module_init(funnel_init);
445module_exit(funnel_exit);
446
447MODULE_AUTHOR("Pratik Patel <pratikp@codeaurora.org>");
448MODULE_AUTHOR("Mathieu Poirier <mathieu.poirier@linaro.org>");
449MODULE_DESCRIPTION("Arm CoreSight Funnel Driver");
450MODULE_LICENSE("GPL v2");