From patchwork Fri Apr 12 10:27:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 162108 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp449634jan; Fri, 12 Apr 2019 03:28:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqwod3kSOQku8nn/Z4b9CYZnoLRNul5xge4EodXwua9paaR8BIVMyZZC7znionDrrNMBLZOJ X-Received: by 2002:a17:902:2c01:: with SMTP id m1mr46311645plb.186.1555064891738; Fri, 12 Apr 2019 03:28:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555064891; cv=none; d=google.com; s=arc-20160816; b=F1zAaXR+3d3T8826GFYWeW5EgqbJqx0uRFjVUid4QLMORSOPtzyxGs7O5KcLKFuBoC DIsGz3UyrLl0UKM75KY74+2T4I+/Js/XD6HTKbkn/zGkxHsJhcbsWpSqMDPfMSNq+T8L 1xhhldPzlsOpObhV8cIX9nO0EYGWb+Gfs7R9KDbqSCLv5UtLIRz25d6rSUSJQ5o8e3wj xmVHCycVYvf+TVuBv1Vi1yi2swdH2O02igE8hCGCZR+Cbxus2e1FWiAjZOYnVbEjHqpA I8cLo+K88zchaybJnfd+yNFCHwsUVF+63QzKxygrAsIbxfSslGA/s/bTLDbH3HPp+h0S UwSQ== 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=TVn8dSjjHAjnUPi8i4DcVyaJDVuLc6w06N90aexbdd8=; b=VhShlXGJkuY2CxwAeIUYJERsvYtMi5nTnaNo80nyzQT6a4qP5jDK1cbhkPP5PJS9uS daSteU7AJlnYiU4VVj0IE+1a2KUmx2M6qLkYccHZTxJPchf9jfjDCV2tNLowjKjlk45C m4FiZ6sb0Nn3JQWZPg6eUd6zdGj760TgvSg8POMX9mx3Rxqag2a37AvEYBOdyoc9hwDt ci3KvbJJGpkoOzT1BmuzrapC/erpseYdFaoLRT+LKIVrypa52w+NSg+4b90AVUqwJG7y PzmIVGPyF6perw0Sw2mV8ZE/up9huNBmTgwHKQmMreVgkpZqmVemiWTm898mQDxFiQEK Ez4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yPKfCE75; 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 u37si36506905pga.301.2019.04.12.03.28.11; Fri, 12 Apr 2019 03:28:11 -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=yPKfCE75; 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 S1727600AbfDLK2K (ORCPT + 7 others); Fri, 12 Apr 2019 06:28:10 -0400 Received: from mail-oi1-f194.google.com ([209.85.167.194]:39023 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727561AbfDLK2K (ORCPT ); Fri, 12 Apr 2019 06:28:10 -0400 Received: by mail-oi1-f194.google.com with SMTP id n187so7517749oih.6 for ; Fri, 12 Apr 2019 03:28:09 -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=TVn8dSjjHAjnUPi8i4DcVyaJDVuLc6w06N90aexbdd8=; b=yPKfCE75VVrUcD6JiDsUWrln5V+ZYLYS+8l0jP5LCqSGqu1DYXF7Q8WELVIg7jB5M6 ywFTk3ftdjVjq7Bft/uzTliVctphixGmZx+fH76nVFz31EApMrGmSxucTWSD4vmWglqx YPxWfq3DpNIVyoqFmAx4ZrpBUVkNjDy1BRl8Cxfs3jdi54Uo0TeK7wH+y4PEpuhJSHwt dVJ9DT88yG1eCR00/j/RFMesIA7CYN/vA16svo34m0mbdgdmdVmC9qVV85lPjFmtsYIw gY1sPo9YlKs+A7NIozanwu/fGuY1MDffOZT8+FNK5nu21Hc8RMCOZi92C3gykJffuH8q MQ8Q== 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=TVn8dSjjHAjnUPi8i4DcVyaJDVuLc6w06N90aexbdd8=; b=n9H0y6/Vapj5qXn1JQ/+q3gi7AbEDS8qzoJZxNIJ8I2gW0yAU//lHpA6f0f/LetF3Y stUD/C8CccBJ2NTk+GYp0VgX/QcEfbINLAncjA0Jeo4O/RwQotoArtKJqehdpOy857ik a4IuFzrSlc+dbw/c5dMU/yeTc4XJYGcZ0NL7oXmOTUG0oylcusj64ntBL50F603oi55J BZzpLBeRPrWLJbKuXL3l2QHsMnTwsjRJYSlvVXvurh/gniUmnH6EsZWbKgLBNcRdItt9 +BbXqlBqURCtYzakkCzHy4mfrU8LtMJs83g58dGnkXOE9Zqauda6cYpAqDVXafkbrukA /yhQ== X-Gm-Message-State: APjAAAUxwkg0G0hx1Zx5bqcy72qWQT9xWo2EslOtWII2Q+ceavFqGukX XT+UXyNMHQRQCWD1YSE+B9Ivxw== X-Received: by 2002:aca:5a89:: with SMTP id o131mr10258811oib.17.1555064889350; Fri, 12 Apr 2019 03:28:09 -0700 (PDT) Received: from localhost.localdomain (li808-42.members.linode.com. [104.237.132.42]) by smtp.gmail.com with ESMTPSA id 88sm17530692otj.3.2019.04.12.03.28.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Apr 2019 03:28:08 -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 Cc: Leo Yan , Wanglai Shi Subject: [PATCH v5 3/4] dt-bindings: arm: coresight: Unify funnel DT binding Date: Fri, 12 Apr 2019 18:27:37 +0800 Message-Id: <20190412102738.12679-4-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190412102738.12679-1-leo.yan@linaro.org> References: <20190412102738.12679-1-leo.yan@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Following the same fashion with replicator DT binding, this patch is to unify the DT binding for funnel to support static and dynamic modes; finally we get the funnel DT binding as below: Before patch: Static funnel, aka. non-configurable funnel: Not supported; Dynamic funnel, aka. configurable funnel: "arm,coresight-funnel", "arm,primecell"; After patch: Static funnel: "arm,coresight-static-funnel"; Dynamic funnel: "arm,coresight-dynamic-funnel", "arm,primecell"; "arm,coresight-funnel", "arm,primecell"; (obsolete) At the end of this patch, it gives an example for static funnel DT binding, and updates the dynamic funnel example. Cc: Mathieu Poirier Cc: Suzuki K Poulose Cc: Wanglai Shi Signed-off-by: Leo Yan --- .../devicetree/bindings/arm/coresight.txt | 53 +++++++++++++++++-- 1 file changed, 48 insertions(+), 5 deletions(-) -- 2.17.1 Reviewed-by: Suzuki K Poulose Reviewed-by: Rob Herring diff --git a/Documentation/devicetree/bindings/arm/coresight.txt b/Documentation/devicetree/bindings/arm/coresight.txt index d02d160fa8ac..8a88ddebc1a2 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,8 +25,10 @@ its hardware characteristcs. discovered at boot time when the device is probed. "arm,coresight-tmc", "arm,primecell"; - - Trace Funnel: - "arm,coresight-funnel", "arm,primecell"; + - Trace Programmable Funnel: + "arm,coresight-dynamic-funnel", "arm,primecell"; + "arm,coresight-funnel", "arm,primecell"; (OBSOLETE. For + backward compatibility and will be removed) - Embedded Trace Macrocell (version 3.x) and Program Flow Trace Macrocell: @@ -65,7 +68,7 @@ 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): @@ -74,6 +77,9 @@ its hardware characteristcs. "arm,coresight-replicator"; (OBSOLETE. For backward compatibility and will be removed) + - Coresight Non-configurable Funnel: + "arm,coresight-static-funnel"; + * port or ports: see "Graph bindings for Coresight" below. * Optional properties for ETM/PTMs: @@ -203,8 +209,45 @@ 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"; + compatible = "arm,coresight-dynamic-funnel", "arm,primecell"; reg = <0 0x20040000 0 0x1000>; clocks = <&oscclk6a>; From patchwork Fri Apr 12 10:27:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 162109 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp449753jan; Fri, 12 Apr 2019 03:28:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqyhriskAbBcioTJVJILOUF/0xjhThhBfH3UbiJ4wJ6zQ9CVi61U/2Blf5TpA1en23xeuGT9 X-Received: by 2002:a62:565c:: with SMTP id k89mr55079186pfb.175.1555064897402; Fri, 12 Apr 2019 03:28:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555064897; cv=none; d=google.com; s=arc-20160816; b=zbjwwHPqrmVZwEEtofceZ8xtGBQ9nXxuLnpYE8LuZvViqe2NYdySbMCVV5SlCr4hBT brb/Sjpv02DtztXcgh3msfkLP6ZOHnLhGvjXde2KF1CBt42PuyFRubhviqJfC9rjH2Ni moyO1nSGr3QWn3NMk/USkBmfuhI8+AJ30Kxocy5719LbU+sKkEX8DpUMFbrimmRtNelT Y6U9IfG+k7lD1ZqaBo4opWU/2pgmXhvR4Ce45gvmIsyWAK+iVy2AydkT75dFKcj4hXL5 aU2oUlZm7bS68vxU1ugcGDrlHnm5hNNJgpFGW/pwv8nno2xGYUWnEE5r/fsdc0mOzNdU b3eA== 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=hR3TUnL81mAK4TjBbDbJHygDbgagwUd1k/T2re2bRoo=; b=a07osyczGZYhcV+mQkXxwPBptefr4ObQoZGaYJSN+BgN5PhmlA1H2UsjVbsA46P0cB giJV6JhVv2uk1+WFXFMXJpa6TTW72jIJpo0NururEfqExDYvSvQmhGJYV9TNPbeEaMCA XkUnVUx7w4zWO/k5MlZLQRCkygEZvRHNSRBUN3HwlyCaDNO27yiSzE8mhTXkdyBlzSpU vtDBcEOKXuwHilSyBjwaQhGbNcuRlLELWsDLcTVl0x/qMzoK6e3l8N9HAXBVE3Yeydye ddDFjlUKJdYKbGJ0rVJbjh37c9/nyyEkmSFO//32Mx4Sf0Qra4QrzrKJ22aC5G87Jdef Rimw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CmWLhvar; 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 g11si26669367plp.278.2019.04.12.03.28.17; Fri, 12 Apr 2019 03:28:17 -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=CmWLhvar; 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 S1727939AbfDLK2P (ORCPT + 7 others); Fri, 12 Apr 2019 06:28:15 -0400 Received: from mail-oi1-f195.google.com ([209.85.167.195]:33244 "EHLO mail-oi1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726697AbfDLK2P (ORCPT ); Fri, 12 Apr 2019 06:28:15 -0400 Received: by mail-oi1-f195.google.com with SMTP id e5so7545591oii.0 for ; Fri, 12 Apr 2019 03:28:14 -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=hR3TUnL81mAK4TjBbDbJHygDbgagwUd1k/T2re2bRoo=; b=CmWLhvarY9SHixmdYGQl2Gyeb1L2STJrd3Z6Gr8Fvt8MTyedN7RS3IKluCbjxX3/gC WQvcHtObjIH/qHQU1pY4hRPdaiQrxf43MAp2AXTiSambkMRjX18G/+AE+g9gFxXRGpf2 fYgVBiqNENKmjSNE67fbCod2RwiPOKIDTGOoSvsld6atkS0UDunyG3oOhxv0Q0X1er2v QrkcRprks8kzY8gjGsoS+3nUc1SYUfG9Sck4oGFK0jFOW4p/zd5gSvubnTjcApyTGfOO J+6YL8L1QvCqjSaLRUQezerJ8OChOnq6zFv/s2aNAGo6sUEMgb7HijlRrbrnRExiCyxq 2fQw== 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=hR3TUnL81mAK4TjBbDbJHygDbgagwUd1k/T2re2bRoo=; b=E1Rg5DmpfbBEQco5deH+4QCQtmvhxz8wuc+/9BJuCMSWY/bZM3X14hu1/qe4/FUBf4 uDQhk2NKhiGx+w/IqReojhDqY1Gto+1WHo3Sn4V6UjS9Bb3R8hPvwFPEhrCytGnTTW8t K2EqklIofqD43NaGNvBUKvuwdgMyARfrMSmEEOBnkvnq8sPe9817Bpcnq+xiqOI1eYq5 Ga+msD8rad5yzyoOs1S4hA8KccL1ZKGoyWPUC/dmEE7aZ5TGJThgiQ3ShH3qLUFeUhUd ULx45+U8MZdjgaZ4QaLYdnUTXGdNTE+MHb+kJzD6l/LYfFNOhWHA9ULK6QddrDHTNrhM hVxA== X-Gm-Message-State: APjAAAV4ZnMZeJXGT9+oAnjV0lHaWXGIpoKtmehYioCqj1B5jNrWTtLx tYovqmp1tRZQi6eIGYn0N6jgf+g6kI124g== X-Received: by 2002:aca:304e:: with SMTP id w75mr10038613oiw.176.1555064894407; Fri, 12 Apr 2019 03:28:14 -0700 (PDT) Received: from localhost.localdomain (li808-42.members.linode.com. [104.237.132.42]) by smtp.gmail.com with ESMTPSA id 88sm17530692otj.3.2019.04.12.03.28.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Apr 2019 03:28:13 -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 Cc: Leo Yan , Wanglai Shi Subject: [PATCH v5 4/4] coresight: funnel: Support static funnel Date: Fri, 12 Apr 2019 18:27:38 +0800 Message-Id: <20190412102738.12679-5-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190412102738.12679-1-leo.yan@linaro.org> References: <20190412102738.12679-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 Reviewed-by: Suzuki K Poulose --- .../hwtracing/coresight/coresight-funnel.c | 116 ++++++++++++++---- 1 file changed, 89 insertions(+), 27 deletions(-) -- 2.17.1 diff --git a/drivers/hwtracing/coresight/coresight-funnel.c b/drivers/hwtracing/coresight/coresight-funnel.c index 927925151509..16b0c0e1e43a 100644 --- a/drivers/hwtracing/coresight/coresight-funnel.c +++ b/drivers/hwtracing/coresight/coresight-funnel.c @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include #include #include @@ -43,7 +45,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 +73,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 +107,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 +182,70 @@ 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; } + if (of_device_is_compatible(np, "arm,coresight-funnel")) + pr_warn_once("Uses OBSOLETE CoreSight funnel binding\n"); + 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 +274,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 +328,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);