From patchwork Thu Mar 28 02:35:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 161284 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp164051jan; Wed, 27 Mar 2019 19:36:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqwUM8YbTdBO2j3TvTP8pUxo+i6eFJ2sigyFZgLHyT/L4mrKtCbY1RUV5gnUmtodrBnBfZfV X-Received: by 2002:a63:530e:: with SMTP id h14mr13464832pgb.136.1553740579615; Wed, 27 Mar 2019 19:36:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553740579; cv=none; d=google.com; s=arc-20160816; b=tus3aRxfWoDAFVxVny3YoUq7TjrvZe3D9YuiPIRlzBM9p4vinFtvdR6EX8j54klNUY dMSS5P/hDyU9BEmPcQR0OXr3eVbMWZHmfqOj1WAicUgWZmfw63bL45EzD6zujd7MvmPI PomMoLb6utdN7qO4c+uHBGgBuR3CEb2PBZ4ZWmW8gqqR4pGwEQMtPq1h+ia/dQHGQyqA +0RwVojg924++4FnQVMORfdpmnTG7XlbHhxmwW+afiV20yu8suR7/WND+RdjcGY15bnY YQfX1ftKcnQiMKKLubcF/XcB9FBsgg5AAQylaehiFCI2TnkmThriG9uo3y6gKi3Q70cg Wrwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=izMEmenMwBdlubPiof5Ev5xU+2SW+3nUdBrCi2sga88=; b=SBJAqrKtWBKv5YJoPuvmGUzOkNwiV8OM4AD41+109ExSoovngYNjsPAEKROQXM5ib2 unx5PjUPZi6ukdhYxAQSBe6txDJdguMI51kc/cUutBVeKpkzSuVhNt2jZvdAltgV1sP7 nEkVLmI3ao9K3yKPP0V+LY1VXBgy5lAuNRdAfGVRA6Om2PeyoSfNpqrfrhCKXfnykwBC pulZ+LJTV4Zwt5DJXEYH5Ec22eVKQbGG4EpDY/NP849VFK59PlifIaxJYs+ULP8G7EVj qdROAUb/+isPh3c1Osrz5q1d92LN27A8ierJ+X8rH+rO5z6zi+8vX90tCT9oJ6OwmxJq x+qA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zAfkv3nl; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h24si19553951pgv.67.2019.03.27.19.36.19; Wed, 27 Mar 2019 19:36:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zAfkv3nl; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728236AbfC1CgS (ORCPT + 7 others); Wed, 27 Mar 2019 22:36:18 -0400 Received: from mail-yw1-f65.google.com ([209.85.161.65]:45871 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727246AbfC1CgS (ORCPT ); Wed, 27 Mar 2019 22:36:18 -0400 Received: by mail-yw1-f65.google.com with SMTP id j128so14084186ywg.12 for ; Wed, 27 Mar 2019 19:36:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=izMEmenMwBdlubPiof5Ev5xU+2SW+3nUdBrCi2sga88=; b=zAfkv3nlCpcu6TSOQFT/3Fyd0KL9msGTLGDNLLdL4jyUY8HHZM7r1qIMIET5tQpfiw TjC8X6n3xhPLWHBo8UPhTiCo6hS3QrZUScBJ2e6WDGj0afXx5Kva5v8NhIBkpMkBjefV P6Ek2BuEzRCJAZjUGxK8xGWEYMj1XgAGSJ/t2nQJvZNldaplak/ZPmeP4xn+2mR/WA1N 8UbesXQ57KGQF6q1oG9HtoPv6YYmnaiAwSn0kBGv999xFlgxHdJtaR9xf10rKBjwxny7 LdGLJ7ra65NijJWIgompQrHWOZnRBmArejxpWVGJOpgPVX7LDRClEU4vh+A3A/QB0783 Ms+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=izMEmenMwBdlubPiof5Ev5xU+2SW+3nUdBrCi2sga88=; b=p7g2MkOaZKPxISRwYWxaHzFLKlbZpTk2GpIz6AtisAW87JgvCVH0IpcNOLG6FvYRIT 3jKo5I8bh/VsgeYTTd3fvhTaNV4Xk6Q/EcqTwE1yToHMoaAjvxwL5ZgZ9SK0z7sKrqQs w769V9UJi3m0atywocgLIM3r/pRaqAPyatJZ97nto3DtyVVmmyapR1VXhb8e1oaO3+u9 rZpirJs1EmAI2SiEskvufvLMPqgUEEGEfrPi0zhJxuo+iiii4wsmGQsJwX6M6/YpsUSL icM+hcQc94U/w71OpqIzYNIBEdF7ZyW3EiDrfg6iyaIBDerCK/g1EJd/qHZIK2a7agRd BGhw== X-Gm-Message-State: APjAAAVRxjVOKnXdyo1ljdLueptr4AfdblYRE1hnj7HhtIe7/xxi3v+P Q1I1RRtWhy61sG6+0XR2XiS5jQ== X-Received: by 2002:a81:ad61:: with SMTP id l33mr31841567ywk.506.1553740577793; Wed, 27 Mar 2019 19:36:17 -0700 (PDT) Received: from localhost.localdomain (li931-65.members.linode.com. [45.56.113.65]) by smtp.gmail.com with ESMTPSA id t71sm16272787ywc.4.2019.03.27.19.36.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Mar 2019 19:36:16 -0700 (PDT) From: Leo Yan To: Mathieu Poirier , Suzuki K Poulose , Rob Herring , Mark Rutland , Alexander Shishkin , linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, Wanglai Shi Cc: Leo Yan Subject: [PATCH v3 1/2] dt-bindings: arm: coresight: Support static funnel Date: Thu, 28 Mar 2019 10:35:08 +0800 Message-Id: <20190328023509.22242-2-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190328023509.22242-1-leo.yan@linaro.org> References: <20190328023509.22242-1-leo.yan@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Document DT binding for static (non-configurable) funnel and give an example for it. Cc: Mathieu Poirier Cc: Suzuki K Poulose Cc: Wanglai Shi Signed-off-by: Leo Yan --- .../devicetree/bindings/arm/coresight.txt | 45 +++++++++++++++++-- 1 file changed, 42 insertions(+), 3 deletions(-) -- 2.17.1 Reviewed-by: Rob Herring diff --git a/Documentation/devicetree/bindings/arm/coresight.txt b/Documentation/devicetree/bindings/arm/coresight.txt index f8aff65ab921..42935c6ca9d6 100644 --- a/Documentation/devicetree/bindings/arm/coresight.txt +++ b/Documentation/devicetree/bindings/arm/coresight.txt @@ -8,7 +8,8 @@ through the intermediate links connecting the source to the currently selected sink. Each CoreSight component device should use these properties to describe its hardware characteristcs. -* Required properties for all components *except* non-configurable replicators: +* Required properties for all components *except* non-configurable replicators + and non-configurable funnels: * compatible: These have to be supplemented with "arm,primecell" as drivers are using the AMBA bus interface. Possible values include: @@ -24,7 +25,7 @@ its hardware characteristcs. discovered at boot time when the device is probed. "arm,coresight-tmc", "arm,primecell"; - - Trace Funnel: + - Trace Programmable Funnel: "arm,coresight-funnel", "arm,primecell"; - Embedded Trace Macrocell (version 3.x) and @@ -65,11 +66,12 @@ its hardware characteristcs. "stm-stimulus-base", each corresponding to the areas defined in "reg". * Required properties for devices that don't show up on the AMBA bus, such as - non-configurable replicators: + non-configurable replicators and non-configurable funnels: * compatible: Currently supported value is (note the absence of the AMBA markee): - "arm,coresight-replicator" + - "arm,coresight-static-funnel" * port or ports: see "Graph bindings for Coresight" below. @@ -200,6 +202,43 @@ Example: }; }; + funnel { + /* + * non-configurable funnel don't show up on the AMBA + * bus. As such no need to add "arm,primecell". + */ + compatible = "arm,coresight-static-funnel"; + clocks = <&crg_ctrl HI3660_PCLK>; + clock-names = "apb_pclk"; + + out-ports { + port { + combo_funnel_out: endpoint { + remote-endpoint = <&top_funnel_in>; + }; + }; + }; + + in-ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + combo_funnel_in0: endpoint { + remote-endpoint = <&cluster0_etf_out>; + }; + }; + + port@1 { + reg = <1>; + combo_funnel_in1: endpoint { + remote-endpoint = <&cluster1_etf_out>; + }; + }; + }; + }; + funnel@20040000 { compatible = "arm,coresight-funnel", "arm,primecell"; reg = <0 0x20040000 0 0x1000>; From patchwork Thu Mar 28 02:35:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 161285 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp164094jan; Wed, 27 Mar 2019 19:36:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqyK0a+G0m1OX/iav27+eBbcjeEYB6VkX8Clp/8HtzGCYAI+JSzXrOJc5OJqcFHB7dstGnFZ X-Received: by 2002:a62:6086:: with SMTP id u128mr13225708pfb.148.1553740585191; Wed, 27 Mar 2019 19:36:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553740585; cv=none; d=google.com; s=arc-20160816; b=YAuBxDyOOqZWdBtRlFga/guHoOqIk/RzQy2RX4A5aSBw8uOO4i44v+9rB1TUOf5dPf LGfifTMV3Ukiip5QdohLugnydddzUSP14G6N8/xMcF1GoXVGQ9gH+mhsC8RqgLpV9L6q vUG0JAPEV2FnHq/GSMDJoF6MCcPLCZY52kSaSffjNiOXK0b518bt99DaspcTOrunpMkq 8DkgwSzUc3CKWbEbAXoGnbaDLYy6aFIU7AJaIAA8rvb4yLa5tZQ8/452nLhEwAYY6Jrh uHD+7LeKZz0fnYmVGkMfkLNpFYBkTWeEYtKlgYnFpkHRxIK9OBkow/akfBzSuAu7hGXr xDzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=ifdzwTxGteEEao9dZvMWL/DO9hxA9H+vArMJZ+eWCgg=; b=PjZMV6fo9tb1OJ/ux0pQ1z4lzahCJ/7P8mrbwvNyERKtsduBs4B+AkfY4BNAL3PsXp qg3tD9C0o22WT3+Xc6+Gkd2/HkWJtWyg5WGhkzLrL5xmEzULJGsWz6sCBcOtejPWOZax rn9jaqXHCNAFnAdKGF8pd0tVPkblPtOj7e271ghcSNAPix3+ZjZvk7pQx6MCdAuoIS83 HOKtF6O3kQ+rUP5j4wKWIHP5gN1vTsNpGn7I4bbOe6p0eaIghsfUH3KtPTraDCNc82YG E1ww5JQ6KjuvHShLMFyA1G2pTjh5asGNdeISGKq6jWAgxBe7j8krSAROVkA7WdIuH7uE 3qdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d4AKsUOn; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m7si18247272pgg.78.2019.03.27.19.36.24; Wed, 27 Mar 2019 19:36:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d4AKsUOn; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728397AbfC1CgY (ORCPT + 7 others); Wed, 27 Mar 2019 22:36:24 -0400 Received: from mail-yw1-f68.google.com ([209.85.161.68]:46300 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728214AbfC1CgY (ORCPT ); Wed, 27 Mar 2019 22:36:24 -0400 Received: by mail-yw1-f68.google.com with SMTP id v127so14081912ywe.13 for ; Wed, 27 Mar 2019 19:36:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ifdzwTxGteEEao9dZvMWL/DO9hxA9H+vArMJZ+eWCgg=; b=d4AKsUOnzAZqhFXfuz4Z1YoetDtQIw/6wL2E9QNq6+vlOoMEm5l6CZnQBTkytLn43Z bJ5ByTewTet2zBa2xiia2X+LAFqlzgYL4uhY3ep064ej6r3xfWMd9c+Un0jmJRZT7Lrj sJAob9HblZ41kyu2cRUCcAsu/+0vBaJwGJ3csEGw4aj20cs0fWmBzoJFfOwzfD9j0unV vhIF6LmOBW3s0HAx4KiZ46IersVgiEqGQoMJh4qttCVfw6733Qxeiei3lK1CbOOBQWyW UI16o7jlWVQLhqLPLK2uziGEFa+Q+iDlwRvqvQ4hXgTAoLs+Lz+tELfx4tz09OylIrnf mcBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ifdzwTxGteEEao9dZvMWL/DO9hxA9H+vArMJZ+eWCgg=; b=lbHfylKFAPqppaiQr8B81UtngrZmzGwHc9jfnfzlUb2tZgx/Qj4xegCy7QSXbYyyB4 NVTstchKhSaxXtXDSFT5kELFYo+vmuj9pNQKWeY6H+/rvHcRcf3XBZtHspU3KN9+11JM Es3wJrxkK/Kck9hZF8lcuv/oL+WDRhrbOIGe6vkQQ/R3l8jc/AGd7KuNLes+6woAipSc ABhMGaYVxr+omI3KUxvUOohv1G3Wh0MQjMh9QUoZD3Rh6eO/boCfMXAxZsAgESuJzyB1 Opbi6sgcj0QYXtiQudrBZP6sPzhwG+xu4/EcsmqttJWZ89P606acmno53/+Ztz/HMIDd HbqA== X-Gm-Message-State: APjAAAWS0dvwluAM4zoWBvVgWLoJFP1IVm/FcUZ48vZl+S7pBZm98P2M QOZ5AjLAb2bWF4KmuQ2xjfUM9g== X-Received: by 2002:a25:4211:: with SMTP id p17mr32945290yba.96.1553740583042; Wed, 27 Mar 2019 19:36:23 -0700 (PDT) Received: from localhost.localdomain (li931-65.members.linode.com. [45.56.113.65]) by smtp.gmail.com with ESMTPSA id t71sm16272787ywc.4.2019.03.27.19.36.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Mar 2019 19:36:22 -0700 (PDT) From: Leo Yan To: Mathieu Poirier , Suzuki K Poulose , Rob Herring , Mark Rutland , Alexander Shishkin , linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, Wanglai Shi Cc: Leo Yan Subject: [PATCH v3 2/2] coresight: funnel: Support static funnel Date: Thu, 28 Mar 2019 10:35:09 +0800 Message-Id: <20190328023509.22242-3-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190328023509.22242-1-leo.yan@linaro.org> References: <20190328023509.22242-1-leo.yan@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Since CoreSight hardware topology can use a 'hidden' funnel in the trace data path, this kind funnel doesn't have register for accessing and is used by default from hardware design perspective. Below is an example for related hardware topology: +------+ +------+ | cpu0 |->| ETM |-\ +------+ +------+ \-> +--------+ +-----+ ...... | Funnel |->| ETF |-\ Hidden funnel +------+ +------+ /-> +--------+ +-----+ \ | | cpu3 |->| ETM |-/ \ V +------+ +------+ \-> +--------+ | Funnel |-> ... +------+ +------+ /-> +--------+ | cpu4 |->| ETM |-\ / +------+ +------+ \-> +--------+ +-----+ / ...... | Funnel |->| ETF |-/ +------+ +------+ /-> +--------+ +-----+ | cpu7 |->| ETM |-/ +------+ +------+ The CoreSight funnel driver only supports dynamic funnel with registration register resource, thus it cannot support for the static funnel case and it's impossible to create trace data path for this case. This patch is to extend CoreSight funnel driver to support both for static funnel and dynamic funnel. For the dynamic funnel it reuses the code existed in the driver, for static funnel the driver will support device probe if without providing register resource and the driver skips registers accessing when detect the register base is NULL. Cc: Mathieu Poirier Cc: Suzuki K Poulose Cc: Wanglai Shi Suggested-by: Suzuki K Poulose Signed-off-by: Leo Yan --- .../hwtracing/coresight/coresight-funnel.c | 112 +++++++++++++----- 1 file changed, 85 insertions(+), 27 deletions(-) -- 2.17.1 diff --git a/drivers/hwtracing/coresight/coresight-funnel.c b/drivers/hwtracing/coresight/coresight-funnel.c index 927925151509..2030d2596d90 100644 --- a/drivers/hwtracing/coresight/coresight-funnel.c +++ b/drivers/hwtracing/coresight/coresight-funnel.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -43,7 +44,7 @@ struct funnel_drvdata { unsigned long priority; }; -static int funnel_enable_hw(struct funnel_drvdata *drvdata, int port) +static int dynamic_funnel_enable_hw(struct funnel_drvdata *drvdata, int port) { u32 functl; int rc = 0; @@ -71,17 +72,19 @@ static int funnel_enable_hw(struct funnel_drvdata *drvdata, int port) static int funnel_enable(struct coresight_device *csdev, int inport, int outport) { - int rc; + int rc = 0; struct funnel_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); - rc = funnel_enable_hw(drvdata, inport); + if (drvdata->base) + rc = dynamic_funnel_enable_hw(drvdata, inport); if (!rc) dev_dbg(drvdata->dev, "FUNNEL inport %d enabled\n", inport); return rc; } -static void funnel_disable_hw(struct funnel_drvdata *drvdata, int inport) +static void dynamic_funnel_disable_hw(struct funnel_drvdata *drvdata, + int inport) { u32 functl; @@ -103,7 +106,8 @@ static void funnel_disable(struct coresight_device *csdev, int inport, { struct funnel_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); - funnel_disable_hw(drvdata, inport); + if (drvdata->base) + dynamic_funnel_disable_hw(drvdata, inport); dev_dbg(drvdata->dev, "FUNNEL inport %d disabled\n", inport); } @@ -177,54 +181,67 @@ static struct attribute *coresight_funnel_attrs[] = { }; ATTRIBUTE_GROUPS(coresight_funnel); -static int funnel_probe(struct amba_device *adev, const struct amba_id *id) +static int funnel_probe(struct device *dev, struct resource *res) { int ret; void __iomem *base; - struct device *dev = &adev->dev; struct coresight_platform_data *pdata = NULL; struct funnel_drvdata *drvdata; - struct resource *res = &adev->res; struct coresight_desc desc = { 0 }; - struct device_node *np = adev->dev.of_node; + struct device_node *np = dev->of_node; if (np) { pdata = of_get_coresight_platform_data(dev, np); if (IS_ERR(pdata)) return PTR_ERR(pdata); - adev->dev.platform_data = pdata; + dev->platform_data = pdata; } drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) return -ENOMEM; - drvdata->dev = &adev->dev; - drvdata->atclk = devm_clk_get(&adev->dev, "atclk"); /* optional */ + drvdata->dev = dev; + drvdata->atclk = devm_clk_get(dev, "atclk"); /* optional */ if (!IS_ERR(drvdata->atclk)) { ret = clk_prepare_enable(drvdata->atclk); if (ret) return ret; } - dev_set_drvdata(dev, drvdata); - /* Validity for the resource is already checked by the AMBA core */ - base = devm_ioremap_resource(dev, res); - if (IS_ERR(base)) - return PTR_ERR(base); + /* + * Map the device base for dynamic-funnel, which has been + * validated by AMBA core. + */ + if (res) { + base = devm_ioremap_resource(dev, res); + if (IS_ERR(base)) { + ret = PTR_ERR(base); + goto out_disable_clk; + } + drvdata->base = base; + desc.groups = coresight_funnel_groups; + } - drvdata->base = base; - pm_runtime_put(&adev->dev); + dev_set_drvdata(dev, drvdata); desc.type = CORESIGHT_DEV_TYPE_LINK; desc.subtype.link_subtype = CORESIGHT_DEV_SUBTYPE_LINK_MERG; desc.ops = &funnel_cs_ops; desc.pdata = pdata; desc.dev = dev; - desc.groups = coresight_funnel_groups; drvdata->csdev = coresight_register(&desc); + if (IS_ERR(drvdata->csdev)) { + ret = PTR_ERR(drvdata->csdev); + goto out_disable_clk; + } + + pm_runtime_put(dev); - return PTR_ERR_OR_ZERO(drvdata->csdev); +out_disable_clk: + if (ret && !IS_ERR_OR_NULL(drvdata->atclk)) + clk_disable_unprepare(drvdata->atclk); + return ret; } #ifdef CONFIG_PM @@ -253,7 +270,48 @@ static const struct dev_pm_ops funnel_dev_pm_ops = { SET_RUNTIME_PM_OPS(funnel_runtime_suspend, funnel_runtime_resume, NULL) }; -static const struct amba_id funnel_ids[] = { +static int static_funnel_probe(struct platform_device *pdev) +{ + int ret; + + pm_runtime_get_noresume(&pdev->dev); + pm_runtime_set_active(&pdev->dev); + pm_runtime_enable(&pdev->dev); + + /* Static funnel do not have programming base */ + ret = funnel_probe(&pdev->dev, NULL); + + if (ret) { + pm_runtime_put_noidle(&pdev->dev); + pm_runtime_disable(&pdev->dev); + } + + return ret; +} + +static const struct of_device_id static_funnel_match[] = { + {.compatible = "arm,coresight-static-funnel"}, + {} +}; + +static struct platform_driver static_funnel_driver = { + .probe = static_funnel_probe, + .driver = { + .name = "coresight-static-funnel", + .of_match_table = static_funnel_match, + .pm = &funnel_dev_pm_ops, + .suppress_bind_attrs = true, + }, +}; +builtin_platform_driver(static_funnel_driver); + +static int dynamic_funnel_probe(struct amba_device *adev, + const struct amba_id *id) +{ + return funnel_probe(&adev->dev, &adev->res); +} + +static const struct amba_id dynamic_funnel_ids[] = { { .id = 0x000bb908, .mask = 0x000fffff, @@ -266,14 +324,14 @@ static const struct amba_id funnel_ids[] = { { 0, 0}, }; -static struct amba_driver funnel_driver = { +static struct amba_driver dynamic_funnel_driver = { .drv = { - .name = "coresight-funnel", + .name = "coresight-dynamic-funnel", .owner = THIS_MODULE, .pm = &funnel_dev_pm_ops, .suppress_bind_attrs = true, }, - .probe = funnel_probe, - .id_table = funnel_ids, + .probe = dynamic_funnel_probe, + .id_table = dynamic_funnel_ids, }; -builtin_amba_driver(funnel_driver); +builtin_amba_driver(dynamic_funnel_driver);