diff options
author | Michael Ellerman <michael@ellerman.id.au> | 2008-05-23 00:21:30 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2008-05-23 01:27:28 -0400 |
commit | 72cac213fda6a2dd402e91692b70e175795eab7d (patch) | |
tree | 2cf09cccac05f0ef194be3627c0b83385909ca7d /arch/powerpc | |
parent | 475ca391b490a683d66bf19999a8a7a24913f139 (diff) |
[POWERPC] Add debugging trigger to Axon MSI code
This adds some debugging code to the Axon MSI driver. It creates a
file per MSIC in /sys/kernel/debug/powerpc, which allows the user to
trigger a fake MSI interrupt by writing to the file.
This can be used to test some of the MSI generation path. In
particular, that the MSIC recognises a write to the MSI address,
generates an interrupt and writes the MSI packet into the ring buffer.
All the code is inside #ifdef DEBUG so it causes no harm unless it's
enabled.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/platforms/cell/axon_msi.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/arch/powerpc/platforms/cell/axon_msi.c b/arch/powerpc/platforms/cell/axon_msi.c index c39f5c225f2e..8b055bce27fe 100644 --- a/arch/powerpc/platforms/cell/axon_msi.c +++ b/arch/powerpc/platforms/cell/axon_msi.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/pci.h> | 14 | #include <linux/pci.h> |
15 | #include <linux/msi.h> | 15 | #include <linux/msi.h> |
16 | #include <linux/of_platform.h> | 16 | #include <linux/of_platform.h> |
17 | #include <linux/debugfs.h> | ||
17 | 18 | ||
18 | #include <asm/dcr.h> | 19 | #include <asm/dcr.h> |
19 | #include <asm/machdep.h> | 20 | #include <asm/machdep.h> |
@@ -69,8 +70,19 @@ struct axon_msic { | |||
69 | dma_addr_t fifo_phys; | 70 | dma_addr_t fifo_phys; |
70 | dcr_host_t dcr_host; | 71 | dcr_host_t dcr_host; |
71 | u32 read_offset; | 72 | u32 read_offset; |
73 | #ifdef DEBUG | ||
74 | u32 __iomem *trigger; | ||
75 | #endif | ||
72 | }; | 76 | }; |
73 | 77 | ||
78 | #ifdef DEBUG | ||
79 | void axon_msi_debug_setup(struct device_node *dn, struct axon_msic *msic); | ||
80 | #else | ||
81 | static inline void axon_msi_debug_setup(struct device_node *dn, | ||
82 | struct axon_msic *msic) { } | ||
83 | #endif | ||
84 | |||
85 | |||
74 | static void msic_dcr_write(struct axon_msic *msic, unsigned int dcr_n, u32 val) | 86 | static void msic_dcr_write(struct axon_msic *msic, unsigned int dcr_n, u32 val) |
75 | { | 87 | { |
76 | pr_debug("axon_msi: dcr_write(0x%x, 0x%x)\n", val, dcr_n); | 88 | pr_debug("axon_msi: dcr_write(0x%x, 0x%x)\n", val, dcr_n); |
@@ -381,6 +393,8 @@ static int axon_msi_probe(struct of_device *device, | |||
381 | ppc_md.teardown_msi_irqs = axon_msi_teardown_msi_irqs; | 393 | ppc_md.teardown_msi_irqs = axon_msi_teardown_msi_irqs; |
382 | ppc_md.msi_check_device = axon_msi_check_device; | 394 | ppc_md.msi_check_device = axon_msi_check_device; |
383 | 395 | ||
396 | axon_msi_debug_setup(dn, msic); | ||
397 | |||
384 | printk(KERN_DEBUG "axon_msi: setup MSIC on %s\n", dn->full_name); | 398 | printk(KERN_DEBUG "axon_msi: setup MSIC on %s\n", dn->full_name); |
385 | 399 | ||
386 | return 0; | 400 | return 0; |
@@ -418,3 +432,47 @@ static int __init axon_msi_init(void) | |||
418 | return of_register_platform_driver(&axon_msi_driver); | 432 | return of_register_platform_driver(&axon_msi_driver); |
419 | } | 433 | } |
420 | subsys_initcall(axon_msi_init); | 434 | subsys_initcall(axon_msi_init); |
435 | |||
436 | |||
437 | #ifdef DEBUG | ||
438 | static int msic_set(void *data, u64 val) | ||
439 | { | ||
440 | struct axon_msic *msic = data; | ||
441 | out_le32(msic->trigger, val); | ||
442 | return 0; | ||
443 | } | ||
444 | |||
445 | static int msic_get(void *data, u64 *val) | ||
446 | { | ||
447 | *val = 0; | ||
448 | return 0; | ||
449 | } | ||
450 | |||
451 | DEFINE_SIMPLE_ATTRIBUTE(fops_msic, msic_get, msic_set, "%llu\n"); | ||
452 | |||
453 | void axon_msi_debug_setup(struct device_node *dn, struct axon_msic *msic) | ||
454 | { | ||
455 | char name[8]; | ||
456 | u64 addr; | ||
457 | |||
458 | addr = of_translate_address(dn, of_get_property(dn, "reg", NULL)); | ||
459 | if (addr == OF_BAD_ADDR) { | ||
460 | pr_debug("axon_msi: couldn't translate reg property\n"); | ||
461 | return; | ||
462 | } | ||
463 | |||
464 | msic->trigger = ioremap(addr, 0x4); | ||
465 | if (!msic->trigger) { | ||
466 | pr_debug("axon_msi: ioremap failed\n"); | ||
467 | return; | ||
468 | } | ||
469 | |||
470 | snprintf(name, sizeof(name), "msic_%d", of_node_to_nid(dn)); | ||
471 | |||
472 | if (!debugfs_create_file(name, 0600, powerpc_debugfs_root, | ||
473 | msic, &fops_msic)) { | ||
474 | pr_debug("axon_msi: debugfs_create_file failed!\n"); | ||
475 | return; | ||
476 | } | ||
477 | } | ||
478 | #endif /* DEBUG */ | ||