2 * Copyright (C) 2001 Kyle A. Lucke IBM Corporation
3 * Copyright (C) 2001 Mike Corrigan & Dave Engebretsen IBM Corporation
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #include <linux/init.h>
20 #include <linux/proc_fs.h>
21 #include <linux/seq_file.h>
22 #include <linux/param.h> /* for HZ */
24 #include <asm/processor.h>
26 #include <asm/lppaca.h>
27 #include <asm/iSeries/ItLpQueue.h>
28 #include <asm/iSeries/HvCallXm.h>
30 #include "processor_vpd.h"
31 #include "main_store.h"
33 static int __init iseries_proc_create(void)
35 struct proc_dir_entry *e = proc_mkdir("iSeries", 0);
41 core_initcall(iseries_proc_create);
43 static unsigned long startTitan = 0;
44 static unsigned long startTb = 0;
46 static int proc_titantod_show(struct seq_file *m, void *v)
48 unsigned long tb0, titan_tod;
51 titan_tod = HvCallXm_loadTod();
53 seq_printf(m, "Titan\n" );
54 seq_printf(m, " time base = %016lx\n", tb0);
55 seq_printf(m, " titan tod = %016lx\n", titan_tod);
56 seq_printf(m, " xProcFreq = %016x\n",
57 xIoHriProcessorVpd[0].xProcFreq);
58 seq_printf(m, " xTimeBaseFreq = %016x\n",
59 xIoHriProcessorVpd[0].xTimeBaseFreq);
60 seq_printf(m, " tb_ticks_per_jiffy = %lu\n", tb_ticks_per_jiffy);
61 seq_printf(m, " tb_ticks_per_usec = %lu\n", tb_ticks_per_usec);
64 startTitan = titan_tod;
67 unsigned long titan_usec = (titan_tod - startTitan) >> 12;
68 unsigned long tb_ticks = (tb0 - startTb);
69 unsigned long titan_jiffies = titan_usec / (1000000/HZ);
70 unsigned long titan_jiff_usec = titan_jiffies * (1000000/HZ);
71 unsigned long titan_jiff_rem_usec =
72 titan_usec - titan_jiff_usec;
73 unsigned long tb_jiffies = tb_ticks / tb_ticks_per_jiffy;
74 unsigned long tb_jiff_ticks = tb_jiffies * tb_ticks_per_jiffy;
75 unsigned long tb_jiff_rem_ticks = tb_ticks - tb_jiff_ticks;
76 unsigned long tb_jiff_rem_usec =
77 tb_jiff_rem_ticks / tb_ticks_per_usec;
78 unsigned long new_tb_ticks_per_jiffy =
79 (tb_ticks * (1000000/HZ))/titan_usec;
81 seq_printf(m, " titan elapsed = %lu uSec\n", titan_usec);
82 seq_printf(m, " tb elapsed = %lu ticks\n", tb_ticks);
83 seq_printf(m, " titan jiffies = %lu.%04lu \n", titan_jiffies,
85 seq_printf(m, " tb jiffies = %lu.%04lu\n", tb_jiffies,
87 seq_printf(m, " new tb_ticks_per_jiffy = %lu\n",
88 new_tb_ticks_per_jiffy);
94 static int proc_titantod_open(struct inode *inode, struct file *file)
96 return single_open(file, proc_titantod_show, NULL);
99 static struct file_operations proc_titantod_operations = {
100 .open = proc_titantod_open,
103 .release = single_release,
106 static int __init iseries_proc_init(void)
108 struct proc_dir_entry *e;
110 e = create_proc_entry("iSeries/titanTod", S_IFREG|S_IRUGO, NULL);
112 e->proc_fops = &proc_titantod_operations;
116 __initcall(iseries_proc_init);