2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (C) 2000-2005 Silicon Graphics, Inc. All rights reserved.
10 #include <linux/proc_fs.h>
11 #include <linux/seq_file.h>
12 #include <asm/uaccess.h>
13 #include <asm/sn/sn_sal.h>
15 static int partition_id_show(struct seq_file
*s
, void *p
)
17 seq_printf(s
, "%d\n", sn_partition_id
);
21 static int partition_id_open(struct inode
*inode
, struct file
*file
)
23 return single_open(file
, partition_id_show
, NULL
);
26 static int system_serial_number_show(struct seq_file
*s
, void *p
)
28 seq_printf(s
, "%s\n", sn_system_serial_number());
32 static int system_serial_number_open(struct inode
*inode
, struct file
*file
)
34 return single_open(file
, system_serial_number_show
, NULL
);
37 static int licenseID_show(struct seq_file
*s
, void *p
)
39 seq_printf(s
, "0x%llx\n", sn_partition_serial_number_val());
43 static int licenseID_open(struct inode
*inode
, struct file
*file
)
45 return single_open(file
, licenseID_show
, NULL
);
49 * Enable forced interrupt by default.
50 * When set, the sn interrupt handler writes the force interrupt register on
51 * the bridge chip. The hardware will then send an interrupt message if the
52 * interrupt line is active. This mimics a level sensitive interrupt.
54 extern int sn_force_interrupt_flag
;
56 static int sn_force_interrupt_show(struct seq_file
*s
, void *p
)
58 seq_printf(s
, "Force interrupt is %s\n",
59 sn_force_interrupt_flag
? "enabled" : "disabled");
63 static ssize_t
sn_force_interrupt_write_proc(struct file
*file
,
64 const char __user
*buffer
, size_t count
, loff_t
*data
)
68 if (copy_from_user(&val
, buffer
, 1))
71 sn_force_interrupt_flag
= (val
== '0') ? 0 : 1;
75 static int sn_force_interrupt_open(struct inode
*inode
, struct file
*file
)
77 return single_open(file
, sn_force_interrupt_show
, NULL
);
80 static int coherence_id_show(struct seq_file
*s
, void *p
)
82 seq_printf(s
, "%d\n", partition_coherence_id());
87 static int coherence_id_open(struct inode
*inode
, struct file
*file
)
89 return single_open(file
, coherence_id_show
, NULL
);
92 /* /proc/sgi_sn/sn_topology uses seq_file, see sn_hwperf.c */
93 extern int sn_topology_open(struct inode
*, struct file
*);
94 extern int sn_topology_release(struct inode
*, struct file
*);
96 static const struct file_operations proc_partition_id_fops
= {
97 .open
= partition_id_open
,
100 .release
= single_release
,
103 static const struct file_operations proc_system_sn_fops
= {
104 .open
= system_serial_number_open
,
107 .release
= single_release
,
110 static const struct file_operations proc_license_id_fops
= {
111 .open
= licenseID_open
,
114 .release
= single_release
,
117 static const struct file_operations proc_sn_force_intr_fops
= {
118 .open
= sn_force_interrupt_open
,
120 .write
= sn_force_interrupt_write_proc
,
122 .release
= single_release
,
125 static const struct file_operations proc_coherence_id_fops
= {
126 .open
= coherence_id_open
,
129 .release
= single_release
,
132 static const struct file_operations proc_sn_topo_fops
= {
133 .open
= sn_topology_open
,
136 .release
= sn_topology_release
,
139 void register_sn_procfs(void)
141 static struct proc_dir_entry
*sgi_proc_dir
= NULL
;
143 BUG_ON(sgi_proc_dir
!= NULL
);
144 if (!(sgi_proc_dir
= proc_mkdir("sgi_sn", NULL
)))
147 proc_create("partition_id", 0444, sgi_proc_dir
,
148 &proc_partition_id_fops
);
149 proc_create("system_serial_number", 0444, sgi_proc_dir
,
150 &proc_system_sn_fops
);
151 proc_create("licenseID", 0444, sgi_proc_dir
, &proc_license_id_fops
);
152 proc_create("sn_force_interrupt", 0644, sgi_proc_dir
,
153 &proc_sn_force_intr_fops
);
154 proc_create("coherence_id", 0444, sgi_proc_dir
,
155 &proc_coherence_id_fops
);
156 proc_create("sn_topology", 0444, sgi_proc_dir
, &proc_sn_topo_fops
);
159 #endif /* CONFIG_PROC_FS */