From patchwork Wed Dec 11 23:07:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Leach X-Patchwork-Id: 11286513 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D9EB1112B for ; Wed, 11 Dec 2019 23:08:04 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B640B214AF for ; Wed, 11 Dec 2019 23:08:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="bk0bufxU"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="hMHdSkoz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B640B214AF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=Z5Dl+2KAZ80ztYjiyBA35waJdOu7ExK9+brimZEDWl8=; b=bk0 bufxU3PdfpsPNsEaLTjuMpx5JPFP4J0QwnnUX2/XjgOt5ZXo3Fd8W7HsoVurpIiwQ0KO9/5iHTpYn ysIs0hLiVHhJz4Nd2KVf9GJAVtmuuiP6NAs7X9O1pcCGrQZ3wplJGv1ZJvQ7pBCubLZrD4kLSwwNT A9uSDWFlsLu6iZQRcC3sh8Xl43aQX28rbo8w8teDSyhyl4RNh8nmum0p4RCWqYK3m8csr+Pv+5wb1 MKIy1hXWA16+uER2Wj8z3W1o5a9KPzjVvspRjmvtonTl6FmiYD01T/yrkcsyhwm8KI+X8znituzQd 2vWzMFAwQohtZPUka0xGgGaIJqUQCrw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ifB5P-0007Cw-Km; Wed, 11 Dec 2019 23:08:03 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ifB56-0006sF-Pi for linux-arm-kernel@lists.infradead.org; Wed, 11 Dec 2019 23:07:46 +0000 Received: by mail-wr1-x442.google.com with SMTP id y17so519350wrh.5 for ; Wed, 11 Dec 2019 15:07:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=tDhVs6CVDINJ1HNHUEVGjWNjJ7PiR8LnUgb8ARuG2ic=; b=hMHdSkoz5BDyQw6TwtXyVxNCqua6AMy+cyKJc0JAy9qVqtgz6j9CyRrqxazjYZu1eA rTgNe1t8WcbjnarG27SQGbKFpHC0mjEZ0czht4ajELdmUO6aNzMfMBi8FPR3QwRlax5s GPc1ZHEVJG77stG+XKIcJ7ngDfsNi940u78geK7Z04TSLX+Sxwu9EpbRFPo3cRnV2krM shh5n4GU0D50R+j5s1ho9nc+hr+OFUkqKXcrMRSAfWIfai1tF60y7gcV74kRbVesYSr3 EpdHql/D1HSW/Eb+4/tYGkNCXi7eDH0jm6KYXlufdbowkjaBfLVFS2M9BDiPZSA2Jlxo 7/aw== 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; bh=tDhVs6CVDINJ1HNHUEVGjWNjJ7PiR8LnUgb8ARuG2ic=; b=Umbg1hL3bcdhTvGl6YkFu0gZOB9Yzd1QcdQBpqoRI3JBvOg05C7PLiiPBpn7FbfNgy HDDek8K2YQOWTuv2ohV3OhZ7vnP6ILxR80M50QE3EpSfN6bH2Q8ytixBjMWj0c/pWoar J46Hf5xz8NAqmjBE7voYsjcGjR5UusSDhhKueg6wWfRAo8WQRdHngCuriaor6tZfzavB OjbieRNFPkONCPYCXEXozmZ9aEVB+bejg4y7WNOuvKq1czwVDgZ4LXpmMhZv3Hrfx+CR p1izfDei1LgGyAMWdlqsdRpR1hc5bHc2BbO5E8LXeuHx5fyl7dc91jSKEIqPzY1nclNY AHvQ== X-Gm-Message-State: APjAAAUrtmYGm8/RwHTCpeEl5wen4WaKB/lx+qOg0Nbhxq4IPx3Ebrn3 WhcoYvehfPDdabtC4scX07B/3w== X-Google-Smtp-Source: APXvYqxgauY45ibf73wi3p0hoxAqkU6DHS4QVjTpkjVPNK80DXm1njA6F3ttGXMyOm9J4P8w66euFA== X-Received: by 2002:adf:d183:: with SMTP id v3mr2504773wrc.180.1576105662868; Wed, 11 Dec 2019 15:07:42 -0800 (PST) Received: from linaro.org ([2a00:23c5:6815:3901:140f:3f8d:647c:49b0]) by smtp.gmail.com with ESMTPSA id n16sm3925655wro.88.2019.12.11.15.07.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2019 15:07:42 -0800 (PST) From: Mike Leach To: mike.leach@linaro.org, linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, devicetree@vger.kernel.org Subject: [PATCH v6 02/15] coresight: cti: Add sysfs coresight mgmt reg access. Date: Wed, 11 Dec 2019 23:07:39 +0000 Message-Id: <20191211230739.4985-1-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191211_150744_866370_E08D89C7 X-CRM114-Status: GOOD ( 10.07 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:442 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lorenzo.pieralisi@arm.com, mathieu.poirier@linaro.org, suzuki.poulose@arm.com, liviu.dudau@arm.com, agross@kernel.org, robh+dt@kernel.org, sudeep.holla@arm.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Adds sysfs access to the coresight management registers. Signed-off-by: Mike Leach Reviewed-by: Mathieu Poirier Reviewed-by: Suzuki K Poulose --- .../hwtracing/coresight/coresight-cti-sysfs.c | 53 +++++++++++++++++++ drivers/hwtracing/coresight/coresight-priv.h | 1 + 2 files changed, 54 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-cti-sysfs.c b/drivers/hwtracing/coresight/coresight-cti-sysfs.c index a832b8c6b866..507f8eb487fe 100644 --- a/drivers/hwtracing/coresight/coresight-cti-sysfs.c +++ b/drivers/hwtracing/coresight/coresight-cti-sysfs.c @@ -62,11 +62,64 @@ static struct attribute *coresight_cti_attrs[] = { NULL, }; +/* register based attributes */ + +/* macro to access RO registers with power check only (no enable check). */ +#define coresight_cti_reg(name, offset) \ +static ssize_t name##_show(struct device *dev, \ + struct device_attribute *attr, char *buf) \ +{ \ + struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); \ + u32 val = 0; \ + pm_runtime_get_sync(dev->parent); \ + spin_lock(&drvdata->spinlock); \ + if (drvdata->config.hw_powered) \ + val = readl_relaxed(drvdata->base + offset); \ + spin_unlock(&drvdata->spinlock); \ + pm_runtime_put_sync(dev->parent); \ + return scnprintf(buf, PAGE_SIZE, "0x%x\n", val); \ +} \ +static DEVICE_ATTR_RO(name) + +/* coresight management registers */ +coresight_cti_reg(devaff0, CTIDEVAFF0); +coresight_cti_reg(devaff1, CTIDEVAFF1); +coresight_cti_reg(authstatus, CORESIGHT_AUTHSTATUS); +coresight_cti_reg(devarch, CORESIGHT_DEVARCH); +coresight_cti_reg(devid, CORESIGHT_DEVID); +coresight_cti_reg(devtype, CORESIGHT_DEVTYPE); +coresight_cti_reg(pidr0, CORESIGHT_PERIPHIDR0); +coresight_cti_reg(pidr1, CORESIGHT_PERIPHIDR1); +coresight_cti_reg(pidr2, CORESIGHT_PERIPHIDR2); +coresight_cti_reg(pidr3, CORESIGHT_PERIPHIDR3); +coresight_cti_reg(pidr4, CORESIGHT_PERIPHIDR4); + +static struct attribute *coresight_cti_mgmt_attrs[] = { + &dev_attr_devaff0.attr, + &dev_attr_devaff1.attr, + &dev_attr_authstatus.attr, + &dev_attr_devarch.attr, + &dev_attr_devid.attr, + &dev_attr_devtype.attr, + &dev_attr_pidr0.attr, + &dev_attr_pidr1.attr, + &dev_attr_pidr2.attr, + &dev_attr_pidr3.attr, + &dev_attr_pidr4.attr, + NULL, +}; + static const struct attribute_group coresight_cti_group = { .attrs = coresight_cti_attrs, }; +static const struct attribute_group coresight_cti_mgmt_group = { + .attrs = coresight_cti_mgmt_attrs, + .name = "mgmt", +}; + const struct attribute_group *coresight_cti_groups[] = { &coresight_cti_group, + &coresight_cti_mgmt_group, NULL, }; diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h index 82e563cdc879..aba6b789c969 100644 --- a/drivers/hwtracing/coresight/coresight-priv.h +++ b/drivers/hwtracing/coresight/coresight-priv.h @@ -22,6 +22,7 @@ #define CORESIGHT_CLAIMCLR 0xfa4 #define CORESIGHT_LAR 0xfb0 #define CORESIGHT_LSR 0xfb4 +#define CORESIGHT_DEVARCH 0xfbc #define CORESIGHT_AUTHSTATUS 0xfb8 #define CORESIGHT_DEVID 0xfc8 #define CORESIGHT_DEVTYPE 0xfcc