From: "David E. Box" <david.e.box@linux.intel.com>
To: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com
Cc: x86@kernel.org, linux-kernel@vger.kernel.org, alan@linux.intel.com
Subject: [PATCH 2/2] x86: iosf: Add debugfs support
Date: Wed, 27 Aug 2014 14:40:40 -0700 [thread overview]
Message-ID: <1409175640-32426-3-git-send-email-david.e.box@linux.intel.com> (raw)
In-Reply-To: <1409175640-32426-1-git-send-email-david.e.box@linux.intel.com>
Allows access to the iosf sideband through debugfs.
Signed-off-by: David E. Box <david.e.box@linux.intel.com>
---
arch/x86/kernel/iosf_mbi.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 74 insertions(+)
diff --git a/arch/x86/kernel/iosf_mbi.c b/arch/x86/kernel/iosf_mbi.c
index d30acdc..bf848ca 100644
--- a/arch/x86/kernel/iosf_mbi.c
+++ b/arch/x86/kernel/iosf_mbi.c
@@ -22,6 +22,8 @@
#include <linux/init.h>
#include <linux/spinlock.h>
#include <linux/pci.h>
+#include <linux/debugfs.h>
+#include <linux/capability.h>
#include <asm/iosf_mbi.h>
@@ -187,6 +189,75 @@ bool iosf_mbi_available(void)
}
EXPORT_SYMBOL(iosf_mbi_available);
+/********************** debugfs begin ****************************/
+static u32 dbg_mdr;
+static u32 dbg_mcr;
+static u32 dbg_mcrx;
+
+static int mcr_get(void *data, u64 *val)
+{
+ *val = *(u32 *)data;
+ return 0;
+}
+
+static int mcr_set(void *data, u64 val)
+{
+ u8 command = ((u32)val & 0xFF000000) >> 24,
+ port = ((u32)val & 0x00FF0000) >> 16,
+ offset = ((u32)val & 0x0000FF00) >> 8;
+ int err;
+
+ *(u32 *)data = val;
+
+ if (!capable(CAP_SYS_RAWIO))
+ return -EACCES;
+
+ if (command & 1u)
+ err = iosf_mbi_write(port,
+ command,
+ dbg_mcrx | offset,
+ dbg_mdr);
+ else
+ err = iosf_mbi_read(port,
+ command,
+ dbg_mcrx | offset,
+ &dbg_mdr);
+
+ return err;
+}
+DEFINE_SIMPLE_ATTRIBUTE(iosf_mcr_fops, mcr_get, mcr_set , "%llx\n");
+
+static struct dentry *iosf_dbg;
+static void iosf_sideband_debug_init(void)
+{
+ struct dentry *d;
+
+ iosf_dbg = debugfs_create_dir("iosf_sb", NULL);
+ if (IS_ERR_OR_NULL(iosf_dbg))
+ return;
+
+ /* mdr */
+ d = debugfs_create_x32("mdr", 0660, iosf_dbg, &dbg_mdr);
+ if (IS_ERR_OR_NULL(d))
+ goto cleanup;
+
+ /* mcrx */
+ debugfs_create_x32("mcrx", 0660, iosf_dbg, &dbg_mcrx);
+ if (IS_ERR_OR_NULL(d))
+ goto cleanup;
+
+ /* mcr - initiates mailbox tranaction */
+ debugfs_create_file("mcr", 0660, iosf_dbg, &dbg_mcr, &iosf_mcr_fops);
+ if (IS_ERR_OR_NULL(d))
+ goto cleanup;
+
+ return;
+
+cleanup:
+ debugfs_remove_recursive(d);
+}
+/********************** debugfs end ****************************/
+
static int iosf_mbi_probe(struct pci_dev *pdev,
const struct pci_device_id *unused)
{
@@ -217,11 +288,14 @@ static struct pci_driver iosf_mbi_pci_driver = {
static int __init iosf_mbi_init(void)
{
+ iosf_sideband_debug_init();
return pci_register_driver(&iosf_mbi_pci_driver);
}
static void __exit iosf_mbi_exit(void)
{
+ debugfs_remove_recursive(iosf_dbg);
+
pci_unregister_driver(&iosf_mbi_pci_driver);
if (mbi_pdev) {
pci_dev_put(mbi_pdev);
--
1.9.1
next prev parent reply other threads:[~2014-08-27 21:43 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-27 21:40 [PATCH 0/2] x86: iosf: change Kconfig selection and add debugfs David E. Box
2014-08-27 21:40 ` [PATCH 1/2] x86: iosf: Add Kconfig prompt for IOSF_MBI selection David E. Box
2014-09-02 21:07 ` [tip:x86/platform] x86/iosf: " tip-bot for David E. Box
2014-08-27 21:40 ` David E. Box [this message]
2014-08-27 22:20 ` [PATCH 2/2] x86: iosf: Add debugfs support H. Peter Anvin
2014-09-02 21:07 ` [tip:x86/platform] x86/iosf: " tip-bot for David E. Box
2014-09-17 3:26 ` [PATCH 0/3] x86: iosf: Additions to iosf patch set David E. Box
2014-09-18 5:13 ` [PATCH V2 " David E. Box
2014-09-18 5:13 ` [PATCH V2 1/3] x86: iosf: Add Braswell PCI ID David E. Box
2014-09-19 11:49 ` [tip:x86/platform] x86/platform/intel/iosf: " tip-bot for David E. Box
2014-09-18 5:13 ` [PATCH V2 2/3] x86: iosf: Add better description of IOSF driver in config David E. Box
2014-09-19 11:49 ` [tip:x86/platform] x86/platform/intel/iosf: " tip-bot for David E. Box
2014-09-18 5:13 ` [PATCH V2 3/3] x86: iosf: Add debugfs config option for iosf David E. Box
2014-09-19 11:49 ` [tip:x86/platform] x86/platform/intel/iosf: Add debugfs config option for IOSF tip-bot for David E. Box
2014-09-17 3:26 ` [PATCH 1/3] x86: iosf: Add Braswell PCI ID David E. Box
2014-09-17 3:26 ` [PATCH 2/3] x86: iosf: Move Kconfig to proper submenu David E. Box
2014-09-17 12:31 ` Ingo Molnar
2014-09-17 3:26 ` [PATCH 3/3] x86: iosf: Make debugfs addition a separate config option David E. Box
2014-09-17 12:26 ` Ingo Molnar
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=1409175640-32426-3-git-send-email-david.e.box@linux.intel.com \
--to=david.e.box@linux.intel.com \
--cc=alan@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.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).