diff options
author | David E. Box <david.e.box@linux.intel.com> | 2014-08-27 17:40:40 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2014-08-27 17:48:36 -0400 |
commit | 8dc12f933c9d732c5bbfb233daf27377893b109c (patch) | |
tree | b5ca510f263c9fbd4f92dbe24163536af98c90fc | |
parent | aa8e4f22ab7773352ba3895597189b8097f2c307 (diff) |
x86/iosf: Add debugfs support
Allows access to the iosf sideband through debugfs.
Signed-off-by: David E. Box <david.e.box@linux.intel.com>
Link: http://lkml.kernel.org/r/1409175640-32426-3-git-send-email-david.e.box@linux.intel.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r-- | arch/x86/kernel/iosf_mbi.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/arch/x86/kernel/iosf_mbi.c b/arch/x86/kernel/iosf_mbi.c index 9030e83db6ee..0a2faa3892cb 100644 --- a/arch/x86/kernel/iosf_mbi.c +++ b/arch/x86/kernel/iosf_mbi.c | |||
@@ -22,6 +22,8 @@ | |||
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
23 | #include <linux/spinlock.h> | 23 | #include <linux/spinlock.h> |
24 | #include <linux/pci.h> | 24 | #include <linux/pci.h> |
25 | #include <linux/debugfs.h> | ||
26 | #include <linux/capability.h> | ||
25 | 27 | ||
26 | #include <asm/iosf_mbi.h> | 28 | #include <asm/iosf_mbi.h> |
27 | 29 | ||
@@ -187,6 +189,75 @@ bool iosf_mbi_available(void) | |||
187 | } | 189 | } |
188 | EXPORT_SYMBOL(iosf_mbi_available); | 190 | EXPORT_SYMBOL(iosf_mbi_available); |
189 | 191 | ||
192 | /********************** debugfs begin ****************************/ | ||
193 | static u32 dbg_mdr; | ||
194 | static u32 dbg_mcr; | ||
195 | static u32 dbg_mcrx; | ||
196 | |||
197 | static int mcr_get(void *data, u64 *val) | ||
198 | { | ||
199 | *val = *(u32 *)data; | ||
200 | return 0; | ||
201 | } | ||
202 | |||
203 | static int mcr_set(void *data, u64 val) | ||
204 | { | ||
205 | u8 command = ((u32)val & 0xFF000000) >> 24, | ||
206 | port = ((u32)val & 0x00FF0000) >> 16, | ||
207 | offset = ((u32)val & 0x0000FF00) >> 8; | ||
208 | int err; | ||
209 | |||
210 | *(u32 *)data = val; | ||
211 | |||
212 | if (!capable(CAP_SYS_RAWIO)) | ||
213 | return -EACCES; | ||
214 | |||
215 | if (command & 1u) | ||
216 | err = iosf_mbi_write(port, | ||
217 | command, | ||
218 | dbg_mcrx | offset, | ||
219 | dbg_mdr); | ||
220 | else | ||
221 | err = iosf_mbi_read(port, | ||
222 | command, | ||
223 | dbg_mcrx | offset, | ||
224 | &dbg_mdr); | ||
225 | |||
226 | return err; | ||
227 | } | ||
228 | DEFINE_SIMPLE_ATTRIBUTE(iosf_mcr_fops, mcr_get, mcr_set , "%llx\n"); | ||
229 | |||
230 | static struct dentry *iosf_dbg; | ||
231 | static void iosf_sideband_debug_init(void) | ||
232 | { | ||
233 | struct dentry *d; | ||
234 | |||
235 | iosf_dbg = debugfs_create_dir("iosf_sb", NULL); | ||
236 | if (IS_ERR_OR_NULL(iosf_dbg)) | ||
237 | return; | ||
238 | |||
239 | /* mdr */ | ||
240 | d = debugfs_create_x32("mdr", 0660, iosf_dbg, &dbg_mdr); | ||
241 | if (IS_ERR_OR_NULL(d)) | ||
242 | goto cleanup; | ||
243 | |||
244 | /* mcrx */ | ||
245 | debugfs_create_x32("mcrx", 0660, iosf_dbg, &dbg_mcrx); | ||
246 | if (IS_ERR_OR_NULL(d)) | ||
247 | goto cleanup; | ||
248 | |||
249 | /* mcr - initiates mailbox tranaction */ | ||
250 | debugfs_create_file("mcr", 0660, iosf_dbg, &dbg_mcr, &iosf_mcr_fops); | ||
251 | if (IS_ERR_OR_NULL(d)) | ||
252 | goto cleanup; | ||
253 | |||
254 | return; | ||
255 | |||
256 | cleanup: | ||
257 | debugfs_remove_recursive(d); | ||
258 | } | ||
259 | /********************** debugfs end ****************************/ | ||
260 | |||
190 | static int iosf_mbi_probe(struct pci_dev *pdev, | 261 | static int iosf_mbi_probe(struct pci_dev *pdev, |
191 | const struct pci_device_id *unused) | 262 | const struct pci_device_id *unused) |
192 | { | 263 | { |
@@ -217,11 +288,14 @@ static struct pci_driver iosf_mbi_pci_driver = { | |||
217 | 288 | ||
218 | static int __init iosf_mbi_init(void) | 289 | static int __init iosf_mbi_init(void) |
219 | { | 290 | { |
291 | iosf_sideband_debug_init(); | ||
220 | return pci_register_driver(&iosf_mbi_pci_driver); | 292 | return pci_register_driver(&iosf_mbi_pci_driver); |
221 | } | 293 | } |
222 | 294 | ||
223 | static void __exit iosf_mbi_exit(void) | 295 | static void __exit iosf_mbi_exit(void) |
224 | { | 296 | { |
297 | debugfs_remove_recursive(iosf_dbg); | ||
298 | |||
225 | pci_unregister_driver(&iosf_mbi_pci_driver); | 299 | pci_unregister_driver(&iosf_mbi_pci_driver); |
226 | if (mbi_pdev) { | 300 | if (mbi_pdev) { |
227 | pci_dev_put(mbi_pdev); | 301 | pci_dev_put(mbi_pdev); |