Path: blob/master/arch/powerpc/platforms/iseries/proc.c
10820 views
/*1* Copyright (C) 2001 Kyle A. Lucke IBM Corporation2* Copyright (C) 2001 Mike Corrigan & Dave Engebretsen IBM Corporation3*4* This program is free software; you can redistribute it and/or modify5* it under the terms of the GNU General Public License as published by6* the Free Software Foundation; either version 2 of the License, or7* (at your option) any later version.8*9* This program is distributed in the hope that it will be useful,10* but WITHOUT ANY WARRANTY; without even the implied warranty of11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12* GNU General Public License for more details.13*14* You should have received a copy of the GNU General Public License15* along with this program; if not, write to the Free Software16* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA17*/18#include <linux/init.h>19#include <linux/proc_fs.h>20#include <linux/seq_file.h>21#include <linux/param.h> /* for HZ */22#include <asm/paca.h>23#include <asm/processor.h>24#include <asm/time.h>25#include <asm/lppaca.h>26#include <asm/firmware.h>27#include <asm/iseries/hv_call_xm.h>2829#include "processor_vpd.h"30#include "main_store.h"3132static int __init iseries_proc_create(void)33{34struct proc_dir_entry *e;3536if (!firmware_has_feature(FW_FEATURE_ISERIES))37return 0;3839e = proc_mkdir("iSeries", 0);40if (!e)41return 1;4243return 0;44}45core_initcall(iseries_proc_create);4647static unsigned long startTitan = 0;48static unsigned long startTb = 0;4950static int proc_titantod_show(struct seq_file *m, void *v)51{52unsigned long tb0, titan_tod;5354tb0 = get_tb();55titan_tod = HvCallXm_loadTod();5657seq_printf(m, "Titan\n" );58seq_printf(m, " time base = %016lx\n", tb0);59seq_printf(m, " titan tod = %016lx\n", titan_tod);60seq_printf(m, " xProcFreq = %016x\n",61xIoHriProcessorVpd[0].xProcFreq);62seq_printf(m, " xTimeBaseFreq = %016x\n",63xIoHriProcessorVpd[0].xTimeBaseFreq);64seq_printf(m, " tb_ticks_per_jiffy = %lu\n", tb_ticks_per_jiffy);65seq_printf(m, " tb_ticks_per_usec = %lu\n", tb_ticks_per_usec);6667if (!startTitan) {68startTitan = titan_tod;69startTb = tb0;70} else {71unsigned long titan_usec = (titan_tod - startTitan) >> 12;72unsigned long tb_ticks = (tb0 - startTb);73unsigned long titan_jiffies = titan_usec / (1000000/HZ);74unsigned long titan_jiff_usec = titan_jiffies * (1000000/HZ);75unsigned long titan_jiff_rem_usec =76titan_usec - titan_jiff_usec;77unsigned long tb_jiffies = tb_ticks / tb_ticks_per_jiffy;78unsigned long tb_jiff_ticks = tb_jiffies * tb_ticks_per_jiffy;79unsigned long tb_jiff_rem_ticks = tb_ticks - tb_jiff_ticks;80unsigned long tb_jiff_rem_usec =81tb_jiff_rem_ticks / tb_ticks_per_usec;82unsigned long new_tb_ticks_per_jiffy =83(tb_ticks * (1000000/HZ))/titan_usec;8485seq_printf(m, " titan elapsed = %lu uSec\n", titan_usec);86seq_printf(m, " tb elapsed = %lu ticks\n", tb_ticks);87seq_printf(m, " titan jiffies = %lu.%04lu\n", titan_jiffies,88titan_jiff_rem_usec);89seq_printf(m, " tb jiffies = %lu.%04lu\n", tb_jiffies,90tb_jiff_rem_usec);91seq_printf(m, " new tb_ticks_per_jiffy = %lu\n",92new_tb_ticks_per_jiffy);93}9495return 0;96}9798static int proc_titantod_open(struct inode *inode, struct file *file)99{100return single_open(file, proc_titantod_show, NULL);101}102103static const struct file_operations proc_titantod_operations = {104.open = proc_titantod_open,105.read = seq_read,106.llseek = seq_lseek,107.release = single_release,108};109110static int __init iseries_proc_init(void)111{112if (!firmware_has_feature(FW_FEATURE_ISERIES))113return 0;114115proc_create("iSeries/titanTod", S_IFREG|S_IRUGO, NULL,116&proc_titantod_operations);117return 0;118}119__initcall(iseries_proc_init);120121122