From patchwork Wed Aug 20 17:03:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 4752691 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B83749F3B4 for ; Wed, 20 Aug 2014 17:07:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BF2F62015E for ; Wed, 20 Aug 2014 17:07:27 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3EFAF20170 for ; Wed, 20 Aug 2014 17:07:25 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XK9Jl-0006CQ-19; Wed, 20 Aug 2014 17:05:01 +0000 Received: from mail-pd0-f175.google.com ([209.85.192.175]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XK9JP-00064c-Un for linux-arm-kernel@lists.infradead.org; Wed, 20 Aug 2014 17:04:40 +0000 Received: by mail-pd0-f175.google.com with SMTP id r10so11920724pdi.6 for ; Wed, 20 Aug 2014 10:04:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=f1OiP7VViq71+Ks5Gq9Ve1BpnPIH5c0YCJtBnBpukw0=; b=UgjgVOQUKdC3n/P1lfP2rklV3LzAcUqVPMUDP2IaQ535vMrOFz7yrM2Zhw1nBCFkqf y5sE8CYD2NGiGqOXyBwkTzyYYEZo1DBLQiah1BH+QGdrQtiJTIR81Jtu3sRaImHw7QTL CEM/uA2w7GweaEDn/Yt/dqT8EQY8Ru7vBAHAm391D/59QG1qmS/hqihxgr6GBBvmN0fO PWaB2flK70qBOhJ61GKIg9oaJaEpAJGvSaYoUZniWjC6CLX8+T/UypD36xx+aw2fLAb4 3MCbL2SxirNua8SeZnlRMOMbIODU8gK/6Ix4/z001Igm5unT0OotZAqrwzEUZPjALyK0 O4bg== X-Gm-Message-State: ALoCoQneWOkW8T8bvZf3LUvO7F+p03zJADgQTxOaB/HoEdqXpa6pNUkN5XjX7GQdl7sQxY+sLcHA X-Received: by 10.70.35.15 with SMTP id d15mr7537276pdj.48.1408554258639; Wed, 20 Aug 2014 10:04:18 -0700 (PDT) Received: from t430.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [70.73.24.112]) by mx.google.com with ESMTPSA id po10sm41629869pac.9.2014.08.20.10.04.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Aug 2014 10:04:18 -0700 (PDT) From: mathieu.poirier@linaro.org To: linus.walleij@linaro.org, will.deacon@arm.com, linux@arm.linux.org.uk, 00regkh@linuxfoundation.org Subject: [PATCH 06/11 v4] coresight-replicator: add CoreSight Replicator driver Date: Wed, 20 Aug 2014 11:03:46 -0600 Message-Id: <1408554231-24321-7-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1408554231-24321-1-git-send-email-mathieu.poirier@linaro.org> References: <1408554231-24321-1-git-send-email-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140820_100440_056820_0D0F5B83 X-CRM114-Status: GOOD ( 15.48 ) X-Spam-Score: -1.4 (-) Cc: daniel.thompson@linaro.org, robbelibobban@gmail.com, Al.Grant@arm.com, mathieu.poirier@linaro.org, patches@linaro.org, marcin.jabrzyk@gmail.com, linux-kernel@vger.kernel.org, panchaxari.prasannamurthy@linaro.org, r.sengupta@samsung.com, Tony.Armitstead@arm.com, linux-arm-kernel@lists.infradead.org, james.king@linaro.org, pratikp@codeaurora.org, varshney@ti.com, jonas.svennebring@avagotech.com, kaixu.xia@linaro.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Pratik Patel This driver manages non-configurable CoreSight Replicator that takes a 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 Signed-off-by: Panchaxari Prasannamurthy Signed-off-by: Mathieu Poirier --- drivers/coresight/Makefile | 3 +- drivers/coresight/coresight-replicator.c | 153 +++++++++++++++++++++++++++++++ 2 files changed, 155 insertions(+), 1 deletion(-) create mode 100644 drivers/coresight/coresight-replicator.c diff --git a/drivers/coresight/Makefile b/drivers/coresight/Makefile index 26a07e1..3a32c06 100644 --- a/drivers/coresight/Makefile +++ b/drivers/coresight/Makefile @@ -4,4 +4,5 @@ obj-$(CONFIG_CORESIGHT) += coresight.o obj-$(CONFIG_OF) += of_coresight.o obj-$(CONFIG_CORESIGHT_LINKS_AND_SINKS) += coresight-tmc.o coresight-tpiu.o \ - coresight-etb10.o coresight-funnel.o + coresight-etb10.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..24286c6 --- /dev/null +++ b/drivers/coresight/coresight-replicator.c @@ -0,0 +1,153 @@ +/* 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "coresight-priv.h" + +struct replicator_drvdata { + struct device *dev; + struct coresight_device *csdev; +}; + +static int replicator_enable(struct coresight_device *csdev, int inport, + int outport) +{ + struct replicator_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); + + dev_info(drvdata->dev, "REPLICATOR enabled\n"); + return 0; +} + +static void replicator_disable(struct coresight_device *csdev, int inport, + int outport) +{ + struct replicator_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); + + dev_info(drvdata->dev, "REPLICATOR disabled\n"); +} + +static char *replicator_fix_name(struct device *dev, int id) +{ + char *name; + int ret, size; + + size = (sizeof(u64) * 2) + strlen(".replicator") + 1; + name = devm_kzalloc(dev, size, GFP_KERNEL); + if (!name) + return NULL; + + ret = scnprintf(name, size, "%08x.replicator", id); + + return name; +} + +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 replicator_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct coresight_platform_data *pdata = NULL; + struct replicator_drvdata *drvdata; + struct coresight_desc *desc; + struct device_node *np = pdev->dev.of_node; + + if (np) { + pdata = of_get_coresight_platform_data(dev, np); + if (IS_ERR(pdata)) + return PTR_ERR(pdata); + pdev->dev.platform_data = pdata; + + pdata->name = replicator_fix_name(dev, pdata->id); + if (!pdata->name) + return -EINVAL; + } + + drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); + if (!drvdata) + return -ENOMEM; + + drvdata->dev = &pdev->dev; + platform_set_drvdata(pdev, drvdata); + + 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 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 = "arm,coresight-replicator"}, + {} +}; + +static struct platform_driver replicator_driver = { + .probe = replicator_probe, + .remove = 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");