Commit 72cac213 authored by Michael Ellerman's avatar Michael Ellerman Committed by Paul Mackerras
Browse files

[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
Signed-off-by: default avatarMichael Ellerman <>
Signed-off-by: default avatarPaul Mackerras <>
parent 475ca391
......@@ -14,6 +14,7 @@
#include <linux/pci.h>
#include <linux/msi.h>
#include <linux/of_platform.h>
#include <linux/debugfs.h>
#include <asm/dcr.h>
#include <asm/machdep.h>
......@@ -69,8 +70,19 @@ struct axon_msic {
dma_addr_t fifo_phys;
dcr_host_t dcr_host;
u32 read_offset;
#ifdef DEBUG
u32 __iomem *trigger;
#ifdef DEBUG
void axon_msi_debug_setup(struct device_node *dn, struct axon_msic *msic);
static inline void axon_msi_debug_setup(struct device_node *dn,
struct axon_msic *msic) { }
static void msic_dcr_write(struct axon_msic *msic, unsigned int dcr_n, u32 val)
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,
ppc_md.teardown_msi_irqs = axon_msi_teardown_msi_irqs;
ppc_md.msi_check_device = axon_msi_check_device;
axon_msi_debug_setup(dn, msic);
printk(KERN_DEBUG "axon_msi: setup MSIC on %s\n", dn->full_name);
return 0;
......@@ -418,3 +432,47 @@ static int __init axon_msi_init(void)
return of_register_platform_driver(&axon_msi_driver);
#ifdef DEBUG
static int msic_set(void *data, u64 val)
struct axon_msic *msic = data;
out_le32(msic->trigger, val);
return 0;
static int msic_get(void *data, u64 *val)
*val = 0;
return 0;
DEFINE_SIMPLE_ATTRIBUTE(fops_msic, msic_get, msic_set, "%llu\n");
void axon_msi_debug_setup(struct device_node *dn, struct axon_msic *msic)
char name[8];
u64 addr;
addr = of_translate_address(dn, of_get_property(dn, "reg", NULL));
if (addr == OF_BAD_ADDR) {
pr_debug("axon_msi: couldn't translate reg property\n");
msic->trigger = ioremap(addr, 0x4);
if (!msic->trigger) {
pr_debug("axon_msi: ioremap failed\n");
snprintf(name, sizeof(name), "msic_%d", of_node_to_nid(dn));
if (!debugfs_create_file(name, 0600, powerpc_debugfs_root,
msic, &fops_msic)) {
pr_debug("axon_msi: debugfs_create_file failed!\n");
#endif /* DEBUG */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment