Committer: Michael Beasley <mike@snafu.setup>
[mikesnafu-overlay.git] / arch / blackfin / kernel / cplb-mpu / cplbinfo.c
blobbd072299f7f24519144f052577682fae283bcad3
1 /*
2 * File: arch/blackfin/mach-common/cplbinfo.c
3 * Based on:
4 * Author: Sonic Zhang <sonic.zhang@analog.com>
6 * Created: Jan. 2005
7 * Description: Display CPLB status
9 * Modified:
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>
38 #include <asm/cplb.h>
39 #include <asm/cplbinit.h>
40 #include <asm/blackfin.h>
42 #define CPLB_I 1
43 #define CPLB_D 2
45 #define SYNC_SYS SSYNC()
46 #define SYNC_CORE CSYNC()
48 #define CPLB_BIT_PAGESIZE 0x30000
50 static char page_size_string_table[][4] = { "1K", "4K", "1M", "4M" };
52 static char *cplb_print_entry(char *buf, struct cplb_entry *tbl, int switched)
54 int i;
55 buf += sprintf(buf, "Index\tAddress\t\tData\tSize\tU/RD\tU/WR\tS/WR\tSwitch\n");
56 for (i = 0; i < MAX_CPLBS; i++) {
57 unsigned long data = tbl[i].data;
58 unsigned long addr = tbl[i].addr;
59 if (!(data & CPLB_VALID))
60 continue;
62 buf +=
63 sprintf(buf,
64 "%d\t0x%08lx\t%06lx\t%s\t%c\t%c\t%c\t%c\n",
65 i, addr, data,
66 page_size_string_table[(data & 0x30000) >> 16],
67 (data & CPLB_USER_RD) ? 'Y' : 'N',
68 (data & CPLB_USER_WR) ? 'Y' : 'N',
69 (data & CPLB_SUPV_WR) ? 'Y' : 'N',
70 i < switched ? 'N' : 'Y');
72 buf += sprintf(buf, "\n");
74 return buf;
77 int cplbinfo_proc_output(char *buf)
79 char *p;
81 p = buf;
83 p += sprintf(p, "------------------ CPLB Information ------------------\n\n");
85 if (bfin_read_IMEM_CONTROL() & ENICPLB) {
86 p += sprintf(p, "Instruction CPLB entry:\n");
87 p = cplb_print_entry(p, icplb_tbl, first_switched_icplb);
88 } else
89 p += sprintf(p, "Instruction CPLB is disabled.\n\n");
91 if (1 || bfin_read_DMEM_CONTROL() & ENDCPLB) {
92 p += sprintf(p, "Data CPLB entry:\n");
93 p = cplb_print_entry(p, dcplb_tbl, first_switched_dcplb);
94 } else
95 p += sprintf(p, "Data CPLB is disabled.\n");
97 p += sprintf(p, "ICPLB miss: %d\nICPLB supervisor miss: %d\n",
98 nr_icplb_miss, nr_icplb_supv_miss);
99 p += sprintf(p, "DCPLB miss: %d\nDCPLB protection fault:%d\n",
100 nr_dcplb_miss, nr_dcplb_prot);
101 p += sprintf(p, "CPLB flushes: %d\n",
102 nr_cplb_flush);
104 return p - buf;
107 static int cplbinfo_read_proc(char *page, char **start, off_t off,
108 int count, int *eof, void *data)
110 int len;
112 len = cplbinfo_proc_output(page);
113 if (len <= off + count)
114 *eof = 1;
115 *start = page + off;
116 len -= off;
117 if (len > count)
118 len = count;
119 if (len < 0)
120 len = 0;
121 return len;
124 static int __init cplbinfo_init(void)
126 struct proc_dir_entry *entry;
128 entry = create_proc_entry("cplbinfo", 0, NULL);
129 if (!entry)
130 return -ENOMEM;
132 entry->read_proc = cplbinfo_read_proc;
133 entry->data = NULL;
135 return 0;
138 static void __exit cplbinfo_exit(void)
140 remove_proc_entry("cplbinfo", NULL);
143 module_init(cplbinfo_init);
144 module_exit(cplbinfo_exit);