18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Support for virtual IRQ subgroups debugfs mapping.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Copyright (C) 2010  Paul Mundt
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * Modelled after arch/powerpc/kernel/irq.c.
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public
98c2ecf20Sopenharmony_ci * License.  See the file "COPYING" in the main directory of this archive
108c2ecf20Sopenharmony_ci * for more details.
118c2ecf20Sopenharmony_ci */
128c2ecf20Sopenharmony_ci#include <linux/seq_file.h>
138c2ecf20Sopenharmony_ci#include <linux/fs.h>
148c2ecf20Sopenharmony_ci#include <linux/init.h>
158c2ecf20Sopenharmony_ci#include <linux/irq.h>
168c2ecf20Sopenharmony_ci#include <linux/debugfs.h>
178c2ecf20Sopenharmony_ci#include "internals.h"
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_cistatic int intc_irq_xlate_debug(struct seq_file *m, void *priv)
208c2ecf20Sopenharmony_ci{
218c2ecf20Sopenharmony_ci	int i;
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci	seq_printf(m, "%-5s  %-7s  %-15s\n", "irq", "enum", "chip name");
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci	for (i = 1; i < nr_irqs; i++) {
268c2ecf20Sopenharmony_ci		struct intc_map_entry *entry = intc_irq_xlate_get(i);
278c2ecf20Sopenharmony_ci		struct intc_desc_int *desc = entry->desc;
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci		if (!desc)
308c2ecf20Sopenharmony_ci			continue;
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci		seq_printf(m, "%5d  ", i);
338c2ecf20Sopenharmony_ci		seq_printf(m, "0x%05x  ", entry->enum_id);
348c2ecf20Sopenharmony_ci		seq_printf(m, "%-15s\n", desc->chip.name);
358c2ecf20Sopenharmony_ci	}
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci	return 0;
388c2ecf20Sopenharmony_ci}
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_cistatic int intc_irq_xlate_open(struct inode *inode, struct file *file)
418c2ecf20Sopenharmony_ci{
428c2ecf20Sopenharmony_ci	return single_open(file, intc_irq_xlate_debug, inode->i_private);
438c2ecf20Sopenharmony_ci}
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_cistatic const struct file_operations intc_irq_xlate_fops = {
468c2ecf20Sopenharmony_ci	.open = intc_irq_xlate_open,
478c2ecf20Sopenharmony_ci	.read = seq_read,
488c2ecf20Sopenharmony_ci	.llseek = seq_lseek,
498c2ecf20Sopenharmony_ci	.release = single_release,
508c2ecf20Sopenharmony_ci};
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_cistatic int __init intc_irq_xlate_init(void)
538c2ecf20Sopenharmony_ci{
548c2ecf20Sopenharmony_ci	/*
558c2ecf20Sopenharmony_ci	 * XXX.. use arch_debugfs_dir here when all of the intc users are
568c2ecf20Sopenharmony_ci	 * converted.
578c2ecf20Sopenharmony_ci	 */
588c2ecf20Sopenharmony_ci	if (debugfs_create_file("intc_irq_xlate", S_IRUGO, NULL, NULL,
598c2ecf20Sopenharmony_ci				&intc_irq_xlate_fops) == NULL)
608c2ecf20Sopenharmony_ci		return -ENOMEM;
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci	return 0;
638c2ecf20Sopenharmony_ci}
648c2ecf20Sopenharmony_cifs_initcall(intc_irq_xlate_init);
65