From: pratikp@codeaurora.org (pratikp at codeaurora.org)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC 6/8] coresight: add CoreSight Replicator driver
Date: Tue, 18 Dec 2012 11:19:23 -0800 [thread overview]
Message-ID: <1355858365-11849-7-git-send-email-pratikp@codeaurora.org> (raw)
In-Reply-To: <1355858365-11849-1-git-send-email-pratikp@codeaurora.org>
From: Pratik Patel <pratikp@codeaurora.org>
This driver manages CoreSight Replicator that takes single input
trace data stream and replicates it to produce two identical
trace data output streams. Replicators are typically used to
route single interleaved trace data stream to two or more sinks.
Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
---
drivers/coresight/Makefile | 2 +-
drivers/coresight/coresight-replicator.c | 211 ++++++++++++++++++++++++++++++
2 files changed, 212 insertions(+), 1 deletions(-)
create mode 100644 drivers/coresight/coresight-replicator.c
diff --git a/drivers/coresight/Makefile b/drivers/coresight/Makefile
index 9f84ad0..b385e81 100644
--- a/drivers/coresight/Makefile
+++ b/drivers/coresight/Makefile
@@ -3,4 +3,4 @@
#
obj-$(CONFIG_CORESIGHT) += coresight.o
obj-$(CONFIG_OF) += of_coresight.o
-obj-$(CONFIG_CORESIGHT_LINKS_AND_SINKS) += coresight-tmc.o coresight-tpiu.o coresight-etb.o coresight-funnel.o
+obj-$(CONFIG_CORESIGHT_LINKS_AND_SINKS) += coresight-tmc.o coresight-tpiu.o coresight-etb.o coresight-funnel.o coresight-replicator.o
diff --git a/drivers/coresight/coresight-replicator.c b/drivers/coresight/coresight-replicator.c
new file mode 100644
index 0000000..fe37e5e
--- /dev/null
+++ b/drivers/coresight/coresight-replicator.c
@@ -0,0 +1,211 @@
+/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/platform_device.h>
+#include <linux/io.h>
+#include <linux/err.h>
+#include <linux/slab.h>
+#include <linux/clk.h>
+#include <linux/of_coresight.h>
+#include <linux/coresight.h>
+
+#include "coresight-priv.h"
+
+#define replicator_writel(drvdata, val, off) \
+ __raw_writel((val), drvdata->base + off)
+#define replicator_readl(drvdata, off) \
+ __raw_readl(drvdata->base + off)
+
+#define REPLICATOR_LOCK(drvdata) \
+do { \
+ mb(); \
+ replicator_writel(drvdata, 0x0, CORESIGHT_LAR); \
+} while (0)
+#define REPLICATOR_UNLOCK(drvdata) \
+do { \
+ replicator_writel(drvdata, CORESIGHT_UNLOCK, CORESIGHT_LAR); \
+ mb(); \
+} while (0)
+
+#define REPLICATOR_IDFILTER0 (0x000)
+#define REPLICATOR_IDFILTER1 (0x004)
+#define REPLICATOR_ITATBCTR0 (0xEFC)
+#define REPLICATOR_ITATBCTR1 (0xEF8)
+
+struct replicator_drvdata {
+ void __iomem *base;
+ struct device *dev;
+ struct coresight_device *csdev;
+ struct clk *clk;
+};
+
+static void __replicator_enable(struct replicator_drvdata *drvdata, int outport)
+{
+ REPLICATOR_UNLOCK(drvdata);
+
+ if (outport == 0) {
+ replicator_writel(drvdata, 0x0, REPLICATOR_IDFILTER0);
+ replicator_writel(drvdata, 0xFF, REPLICATOR_IDFILTER1);
+ } else {
+ replicator_writel(drvdata, 0x0, REPLICATOR_IDFILTER1);
+ replicator_writel(drvdata, 0xFF, REPLICATOR_IDFILTER0);
+ }
+
+ REPLICATOR_LOCK(drvdata);
+}
+
+static int replicator_enable(struct coresight_device *csdev, int inport,
+ int outport)
+{
+ struct replicator_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
+ int ret;
+
+ ret = clk_prepare_enable(drvdata->clk);
+ if (ret)
+ return ret;
+
+ __replicator_enable(drvdata, outport);
+
+ dev_info(drvdata->dev, "REPLICATOR enabled\n");
+ return 0;
+}
+
+static void __replicator_disable(struct replicator_drvdata *drvdata,
+ int outport)
+{
+ REPLICATOR_UNLOCK(drvdata);
+
+ if (outport == 0)
+ replicator_writel(drvdata, 0xFF, REPLICATOR_IDFILTER0);
+ else
+ replicator_writel(drvdata, 0xFF, REPLICATOR_IDFILTER1);
+
+ REPLICATOR_LOCK(drvdata);
+}
+
+static void replicator_disable(struct coresight_device *csdev, int inport,
+ int outport)
+{
+ struct replicator_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
+
+ __replicator_disable(drvdata, outport);
+
+ clk_disable_unprepare(drvdata->clk);
+
+ dev_info(drvdata->dev, "REPLICATOR disabled\n");
+}
+
+static const struct coresight_ops_link replicator_link_ops = {
+ .enable = replicator_enable,
+ .disable = replicator_disable,
+};
+
+static const struct coresight_ops replicator_cs_ops = {
+ .link_ops = &replicator_link_ops,
+};
+
+static int __devinit replicator_probe(struct platform_device *pdev)
+{
+ int ret;
+ struct device *dev = &pdev->dev;
+ struct coresight_platform_data *pdata;
+ struct replicator_drvdata *drvdata;
+ struct resource *res;
+ struct coresight_desc *desc;
+
+ if (pdev->dev.of_node) {
+ pdata = of_get_coresight_platform_data(dev, pdev->dev.of_node);
+ if (IS_ERR(pdata))
+ return PTR_ERR(pdata);
+ pdev->dev.platform_data = pdata;
+ }
+
+ drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
+ if (!drvdata)
+ return -ENOMEM;
+ drvdata->dev = &pdev->dev;
+ platform_set_drvdata(pdev, drvdata);
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res)
+ return -ENODEV;
+
+ drvdata->base = devm_ioremap(dev, res->start, resource_size(res));
+ if (!drvdata->base)
+ return -ENOMEM;
+
+ drvdata->clk = devm_clk_get(dev, "core_clk");
+ if (IS_ERR(drvdata->clk))
+ return PTR_ERR(drvdata->clk);
+
+ ret = clk_set_rate(drvdata->clk, CORESIGHT_CLK_RATE_TRACE);
+ if (ret)
+ return ret;
+
+ desc = devm_kzalloc(dev, sizeof(*desc), GFP_KERNEL);
+ if (!desc)
+ return -ENOMEM;
+ desc->type = CORESIGHT_DEV_TYPE_LINK;
+ desc->subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_LINK_SPLIT;
+ desc->ops = &replicator_cs_ops;
+ desc->pdata = pdev->dev.platform_data;
+ desc->dev = &pdev->dev;
+ desc->owner = THIS_MODULE;
+ drvdata->csdev = coresight_register(desc);
+ if (IS_ERR(drvdata->csdev))
+ return PTR_ERR(drvdata->csdev);
+
+ dev_info(dev, "REPLICATOR initialized\n");
+ return 0;
+}
+
+static int __devexit replicator_remove(struct platform_device *pdev)
+{
+ struct replicator_drvdata *drvdata = platform_get_drvdata(pdev);
+
+ coresight_unregister(drvdata->csdev);
+ return 0;
+}
+
+static struct of_device_id replicator_match[] = {
+ {.compatible = "qcom,coresight-replicator"},
+ {}
+};
+
+static struct platform_driver replicator_driver = {
+ .probe = replicator_probe,
+ .remove = __devexit_p(replicator_remove),
+ .driver = {
+ .name = "coresight-replicator",
+ .owner = THIS_MODULE,
+ .of_match_table = replicator_match,
+ },
+};
+
+static int __init replicator_init(void)
+{
+ return platform_driver_register(&replicator_driver);
+}
+module_init(replicator_init);
+
+static void __exit replicator_exit(void)
+{
+ platform_driver_unregister(&replicator_driver);
+}
+module_exit(replicator_exit);
+
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("CoreSight Replicator driver");
--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
next prev parent reply other threads:[~2012-12-18 19:19 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-18 19:19 CoreSight framework and drivers pratikp at codeaurora.org
2012-12-18 19:19 ` [RFC 1/8] coresight: add CoreSight core layer framework pratikp at codeaurora.org
2012-12-18 19:19 ` [RFC 2/8] coresight: add CoreSight TMC driver pratikp at codeaurora.org
2013-02-21 14:20 ` Robert MARKLUND
2012-12-18 19:19 ` [RFC 3/8] coresight: add CoreSight TPIU driver pratikp at codeaurora.org
2012-12-18 19:19 ` [RFC 4/8] coresight: add CoreSight ETB driver pratikp at codeaurora.org
2012-12-20 17:49 ` Jon Hunter
2012-12-20 19:54 ` Pratik Patel
2012-12-18 19:19 ` [RFC 5/8] coresight: add CoreSight Funnel driver pratikp at codeaurora.org
2012-12-18 19:19 ` pratikp at codeaurora.org [this message]
2012-12-18 19:19 ` [RFC 7/8] coresight: add CoreSight STM driver pratikp at codeaurora.org
2012-12-18 19:19 ` [RFC 8/8] coresight: add CoreSight ETM driver pratikp at codeaurora.org
2012-12-19 11:23 ` CoreSight framework and drivers Will Deacon
2012-12-19 17:03 ` Jon Hunter
2012-12-19 21:24 ` Pratik Patel
2012-12-20 17:46 ` Jon Hunter
2012-12-20 19:51 ` Pratik Patel
2012-12-20 20:16 ` Jean Pihet
2012-12-21 22:12 ` Pratik Patel
2012-12-20 22:54 ` Jon Hunter
2012-12-20 23:40 ` Russell King - ARM Linux
2012-12-21 22:17 ` Pratik Patel
2012-12-21 22:18 ` Pratik Patel
2012-12-23 11:32 ` Will Deacon
2013-01-03 18:06 ` Pratik Patel
2013-01-07 11:58 ` Will Deacon
2013-01-16 0:14 ` Pratik Patel
2013-01-17 10:55 ` Will Deacon
2013-01-02 20:00 ` Jon Hunter
2013-01-03 19:32 ` Pratik Patel
2012-12-19 21:06 ` Pratik Patel
2013-02-21 14:32 ` Robert MARKLUND
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1355858365-11849-7-git-send-email-pratikp@codeaurora.org \
--to=pratikp@codeaurora.org \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).