Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2010 Tilera Corporation. All Rights Reserved. |
| 3 | * |
| 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. |
| 7 | * |
| 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 |
| 12 | * more details. |
| 13 | */ |
| 14 | |
| 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> |
| 21 | #include <linux/fs.h> |
| 22 | #include <linux/proc_fs.h> |
| 23 | #include <linux/sysctl.h> |
| 24 | #include <linux/hardirq.h> |
| 25 | #include <linux/mman.h> |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 26 | #include <asm/pgtable.h> |
| 27 | #include <asm/processor.h> |
| 28 | #include <asm/sections.h> |
| 29 | #include <asm/homecache.h> |
Chris Metcalf | f133ecc | 2011-05-26 12:40:09 -0400 | [diff] [blame] | 30 | #include <asm/hardwall.h> |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 31 | #include <arch/chip.h> |
| 32 | |
| 33 | |
| 34 | /* |
| 35 | * Support /proc/cpuinfo |
| 36 | */ |
| 37 | |
| 38 | #define cpu_to_ptr(n) ((void *)((long)(n)+1)) |
| 39 | #define ptr_to_cpu(p) ((long)(p) - 1) |
| 40 | |
| 41 | static int show_cpuinfo(struct seq_file *m, void *v) |
| 42 | { |
| 43 | int n = ptr_to_cpu(v); |
| 44 | |
| 45 | if (n == 0) { |
| 46 | char buf[NR_CPUS*5]; |
| 47 | cpulist_scnprintf(buf, sizeof(buf), cpu_online_mask); |
| 48 | seq_printf(m, "cpu count\t: %d\n", num_online_cpus()); |
| 49 | seq_printf(m, "cpu list\t: %s\n", buf); |
| 50 | seq_printf(m, "model name\t: %s\n", chip_model); |
| 51 | seq_printf(m, "flags\t\t:\n"); /* nothing for now */ |
| 52 | seq_printf(m, "cpu MHz\t\t: %llu.%06llu\n", |
| 53 | get_clock_rate() / 1000000, |
| 54 | (get_clock_rate() % 1000000)); |
| 55 | seq_printf(m, "bogomips\t: %lu.%02lu\n\n", |
| 56 | loops_per_jiffy/(500000/HZ), |
| 57 | (loops_per_jiffy/(5000/HZ)) % 100); |
| 58 | } |
| 59 | |
| 60 | #ifdef CONFIG_SMP |
| 61 | if (!cpu_online(n)) |
| 62 | return 0; |
| 63 | #endif |
| 64 | |
| 65 | seq_printf(m, "processor\t: %d\n", n); |
| 66 | |
| 67 | /* Print only num_online_cpus() blank lines total. */ |
| 68 | if (cpumask_next(n, cpu_online_mask) < nr_cpu_ids) |
| 69 | seq_printf(m, "\n"); |
| 70 | |
| 71 | return 0; |
| 72 | } |
| 73 | |
| 74 | static void *c_start(struct seq_file *m, loff_t *pos) |
| 75 | { |
| 76 | return *pos < nr_cpu_ids ? cpu_to_ptr(*pos) : NULL; |
| 77 | } |
| 78 | static void *c_next(struct seq_file *m, void *v, loff_t *pos) |
| 79 | { |
| 80 | ++*pos; |
| 81 | return c_start(m, pos); |
| 82 | } |
| 83 | static void c_stop(struct seq_file *m, void *v) |
| 84 | { |
| 85 | } |
| 86 | const struct seq_operations cpuinfo_op = { |
| 87 | .start = c_start, |
| 88 | .next = c_next, |
| 89 | .stop = c_stop, |
| 90 | .show = show_cpuinfo, |
| 91 | }; |
Chris Metcalf | f133ecc | 2011-05-26 12:40:09 -0400 | [diff] [blame] | 92 | |
| 93 | /* |
| 94 | * Support /proc/tile directory |
| 95 | */ |
| 96 | |
| 97 | static int __init proc_tile_init(void) |
| 98 | { |
| 99 | struct proc_dir_entry *root = proc_mkdir("tile", NULL); |
| 100 | if (root == NULL) |
| 101 | return 0; |
| 102 | |
| 103 | proc_tile_hardwall_init(root); |
| 104 | |
| 105 | return 0; |
| 106 | } |
| 107 | |
| 108 | arch_initcall(proc_tile_init); |
| 109 | |
| 110 | /* |
| 111 | * Support /proc/sys/tile directory |
| 112 | */ |
| 113 | |
| 114 | #ifndef __tilegx__ /* FIXME: GX: no support for unaligned access yet */ |
| 115 | static ctl_table unaligned_subtable[] = { |
| 116 | { |
| 117 | .procname = "enabled", |
| 118 | .data = &unaligned_fixup, |
| 119 | .maxlen = sizeof(int), |
| 120 | .mode = 0644, |
| 121 | .proc_handler = &proc_dointvec |
| 122 | }, |
| 123 | { |
| 124 | .procname = "printk", |
| 125 | .data = &unaligned_printk, |
| 126 | .maxlen = sizeof(int), |
| 127 | .mode = 0644, |
| 128 | .proc_handler = &proc_dointvec |
| 129 | }, |
| 130 | { |
| 131 | .procname = "count", |
| 132 | .data = &unaligned_fixup_count, |
| 133 | .maxlen = sizeof(int), |
| 134 | .mode = 0644, |
| 135 | .proc_handler = &proc_dointvec |
| 136 | }, |
| 137 | {} |
| 138 | }; |
| 139 | |
| 140 | static ctl_table unaligned_table[] = { |
| 141 | { |
| 142 | .procname = "unaligned_fixup", |
| 143 | .mode = 0555, |
| 144 | .child = unaligned_subtable |
| 145 | }, |
| 146 | {} |
| 147 | }; |
| 148 | #endif |
| 149 | |
| 150 | static struct ctl_path tile_path[] = { |
| 151 | { .procname = "tile" }, |
| 152 | { } |
| 153 | }; |
| 154 | |
| 155 | static int __init proc_sys_tile_init(void) |
| 156 | { |
| 157 | #ifndef __tilegx__ /* FIXME: GX: no support for unaligned access yet */ |
| 158 | register_sysctl_paths(tile_path, unaligned_table); |
| 159 | #endif |
| 160 | return 0; |
| 161 | } |
| 162 | |
| 163 | arch_initcall(proc_sys_tile_init); |