2 * Copyright 2010 Tilera Corporation. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation, version 2.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11 * NON INFRINGEMENT. See the GNU General Public License for
15 #include <linux/smp.h>
16 #include <linux/seq_file.h>
17 #include <linux/threads.h>
18 #include <linux/cpumask.h>
19 #include <linux/timex.h>
20 #include <linux/delay.h>
22 #include <linux/proc_fs.h>
23 #include <linux/sysctl.h>
24 #include <linux/hardirq.h>
25 #include <linux/hugetlb.h>
26 #include <linux/mman.h>
27 #include <asm/unaligned.h>
28 #include <asm/pgtable.h>
29 #include <asm/processor.h>
30 #include <asm/sections.h>
31 #include <asm/homecache.h>
32 #include <asm/hardwall.h>
33 #include <arch/chip.h>
37 * Support /proc/cpuinfo
40 #define cpu_to_ptr(n) ((void *)((long)(n)+1))
41 #define ptr_to_cpu(p) ((long)(p) - 1)
43 static int show_cpuinfo(struct seq_file *m, void *v)
45 int n = ptr_to_cpu(v);
48 seq_printf(m, "cpu count\t: %d\n", num_online_cpus());
49 seq_printf(m, "cpu list\t: %*pbl\n",
50 cpumask_pr_args(cpu_online_mask));
51 seq_printf(m, "model name\t: %s\n", chip_model);
52 seq_printf(m, "flags\t\t:\n"); /* nothing for now */
53 seq_printf(m, "cpu MHz\t\t: %llu.%06llu\n",
54 get_clock_rate() / 1000000,
55 (get_clock_rate() % 1000000));
56 seq_printf(m, "bogomips\t: %lu.%02lu\n\n",
57 loops_per_jiffy/(500000/HZ),
58 (loops_per_jiffy/(5000/HZ)) % 100);
66 seq_printf(m, "processor\t: %d\n", n);
68 /* Print only num_online_cpus() blank lines total. */
69 if (cpumask_next(n, cpu_online_mask) < nr_cpu_ids)
75 static void *c_start(struct seq_file *m, loff_t *pos)
77 return *pos < nr_cpu_ids ? cpu_to_ptr(*pos) : NULL;
79 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
82 return c_start(m, pos);
84 static void c_stop(struct seq_file *m, void *v)
87 const struct seq_operations cpuinfo_op = {
95 * Support /proc/tile directory
98 static int __init proc_tile_init(void)
100 struct proc_dir_entry *root = proc_mkdir("tile", NULL);
104 proc_tile_hardwall_init(root);
109 arch_initcall(proc_tile_init);
112 * Support /proc/sys/tile directory
115 static struct ctl_table unaligned_subtable[] = {
117 .procname = "enabled",
118 .data = &unaligned_fixup,
119 .maxlen = sizeof(int),
121 .proc_handler = &proc_dointvec
124 .procname = "printk",
125 .data = &unaligned_printk,
126 .maxlen = sizeof(int),
128 .proc_handler = &proc_dointvec
132 .data = &unaligned_fixup_count,
133 .maxlen = sizeof(int),
135 .proc_handler = &proc_dointvec
140 static struct ctl_table unaligned_table[] = {
142 .procname = "unaligned_fixup",
144 .child = unaligned_subtable
149 static struct ctl_path tile_path[] = {
150 { .procname = "tile" },
154 static int __init proc_sys_tile_init(void)
156 register_sysctl_paths(tile_path, unaligned_table);
160 arch_initcall(proc_sys_tile_init);