2 * File: arch/blackfin/mach-common/cplbinfo.c
4 * Author: Sonic Zhang <sonic.zhang@analog.com>
7 * Description: Display CPLB status
10 * Copyright 2004-2006 Analog Devices Inc.
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 #include <linux/module.h>
31 #include <linux/kernel.h>
32 #include <linux/init.h>
33 #include <linux/proc_fs.h>
34 #include <linux/uaccess.h>
36 #include <asm/current.h>
37 #include <asm/system.h>
39 #include <asm/cplbinit.h>
40 #include <asm/blackfin.h>
42 static char page_size_string_table[][4] = { "1K", "4K", "1M", "4M" };
44 static char *cplb_print_entry(char *buf, struct cplb_entry *tbl, int switched)
47 buf += sprintf(buf, "Index\tAddress\t\tData\tSize\tU/RD\tU/WR\tS/WR\tSwitch\n");
48 for (i = 0; i < MAX_CPLBS; i++) {
49 unsigned long data = tbl[i].data;
50 unsigned long addr = tbl[i].addr;
51 if (!(data & CPLB_VALID))
56 "%d\t0x%08lx\t%06lx\t%s\t%c\t%c\t%c\t%c\n",
58 page_size_string_table[(data & 0x30000) >> 16],
59 (data & CPLB_USER_RD) ? 'Y' : 'N',
60 (data & CPLB_USER_WR) ? 'Y' : 'N',
61 (data & CPLB_SUPV_WR) ? 'Y' : 'N',
62 i < switched ? 'N' : 'Y');
64 buf += sprintf(buf, "\n");
69 int cplbinfo_proc_output(char *buf, void *data)
72 unsigned int cpu = (unsigned int)data;;
76 p += sprintf(p, "------------- CPLB Information on CPU%u --------------\n\n", cpu);
77 if (bfin_read_IMEM_CONTROL() & ENICPLB) {
78 p += sprintf(p, "Instruction CPLB entry:\n");
79 p = cplb_print_entry(p, icplb_tbl[cpu], first_switched_icplb);
81 p += sprintf(p, "Instruction CPLB is disabled.\n\n");
83 if (1 || bfin_read_DMEM_CONTROL() & ENDCPLB) {
84 p += sprintf(p, "Data CPLB entry:\n");
85 p = cplb_print_entry(p, dcplb_tbl[cpu], first_switched_dcplb);
87 p += sprintf(p, "Data CPLB is disabled.\n");
89 p += sprintf(p, "ICPLB miss: %d\nICPLB supervisor miss: %d\n",
90 nr_icplb_miss[cpu], nr_icplb_supv_miss[cpu]);
91 p += sprintf(p, "DCPLB miss: %d\nDCPLB protection fault:%d\n",
92 nr_dcplb_miss[cpu], nr_dcplb_prot[cpu]);
93 p += sprintf(p, "CPLB flushes: %d\n",
99 static int cplbinfo_read_proc(char *page, char **start, off_t off,
100 int count, int *eof, void *data)
104 len = cplbinfo_proc_output(page, data);
105 if (len <= off + count)
116 static int __init cplbinfo_init(void)
118 struct proc_dir_entry *parent, *entry;
120 unsigned char str[10];
122 parent = proc_mkdir("cplbinfo", NULL);
124 for_each_online_cpu(cpu) {
125 sprintf(str, "cpu%u", cpu);
126 entry = create_proc_entry(str, 0, parent);
130 entry->read_proc = cplbinfo_read_proc;
131 entry->data = (void *)cpu;
137 static void __exit cplbinfo_exit(void)
140 unsigned char str[20];
141 for_each_online_cpu(cpu) {
142 sprintf(str, "cplbinfo/cpu%u", cpu);
143 remove_proc_entry(str, NULL);
145 remove_proc_entry("cplbinfo", NULL);
148 module_init(cplbinfo_init);
149 module_exit(cplbinfo_exit);