diff options
author | Bryan Wu <bryan.wu@analog.com> | 2007-05-06 17:50:22 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-07 15:12:58 -0400 |
commit | 1394f03221790a988afc3e4b3cb79f2e477246a9 (patch) | |
tree | 2c1963c9a4f2d84a5e021307fde240c5d567cf70 /arch/blackfin/mach-common/cplbinfo.c | |
parent | 73243284463a761e04d69d22c7516b2be7de096c (diff) |
blackfin architecture
This adds support for the Analog Devices Blackfin processor architecture, and
currently supports the BF533, BF532, BF531, BF537, BF536, BF534, and BF561
(Dual Core) devices, with a variety of development platforms including those
avaliable from Analog Devices (BF533-EZKit, BF533-STAMP, BF537-STAMP,
BF561-EZKIT), and Bluetechnix! Tinyboards.
The Blackfin architecture was jointly developed by Intel and Analog Devices
Inc. (ADI) as the Micro Signal Architecture (MSA) core and introduced it in
December of 2000. Since then ADI has put this core into its Blackfin
processor family of devices. The Blackfin core has the advantages of a clean,
orthogonal,RISC-like microprocessor instruction set. It combines a dual-MAC
(Multiply/Accumulate), state-of-the-art signal processing engine and
single-instruction, multiple-data (SIMD) multimedia capabilities into a single
instruction-set architecture.
The Blackfin architecture, including the instruction set, is described by the
ADSP-BF53x/BF56x Blackfin Processor Programming Reference
http://blackfin.uclinux.org/gf/download/frsrelease/29/2549/Blackfin_PRM.pdf
The Blackfin processor is already supported by major releases of gcc, and
there are binary and source rpms/tarballs for many architectures at:
http://blackfin.uclinux.org/gf/project/toolchain/frs There is complete
documentation, including "getting started" guides available at:
http://docs.blackfin.uclinux.org/ which provides links to the sources and
patches you will need in order to set up a cross-compiling environment for
bfin-linux-uclibc
This patch, as well as the other patches (toolchain, distribution,
uClibc) are actively supported by Analog Devices Inc, at:
http://blackfin.uclinux.org/
We have tested this on LTP, and our test plan (including pass/fails) can
be found at:
http://docs.blackfin.uclinux.org/doku.php?id=testing_the_linux_kernel
[m.kozlowski@tuxland.pl: balance parenthesis in blackfin header files]
Signed-off-by: Bryan Wu <bryan.wu@analog.com>
Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>
Signed-off-by: Aubrey Li <aubrey.li@analog.com>
Signed-off-by: Jie Zhang <jie.zhang@analog.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/blackfin/mach-common/cplbinfo.c')
-rw-r--r-- | arch/blackfin/mach-common/cplbinfo.c | 211 |
1 files changed, 211 insertions, 0 deletions
diff --git a/arch/blackfin/mach-common/cplbinfo.c b/arch/blackfin/mach-common/cplbinfo.c new file mode 100644 index 000000000000..d65fac39d1bf --- /dev/null +++ b/arch/blackfin/mach-common/cplbinfo.c | |||
@@ -0,0 +1,211 @@ | |||
1 | /* | ||
2 | * File: arch/blackfin/mach-common/cplbinfo.c | ||
3 | * Based on: | ||
4 | * Author: Sonic Zhang <sonic.zhang@analog.com> | ||
5 | * | ||
6 | * Created: Jan. 2005 | ||
7 | * Description: Display CPLB status | ||
8 | * | ||
9 | * Modified: | ||
10 | * Copyright 2004-2006 Analog Devices Inc. | ||
11 | * | ||
12 | * Bugs: Enter bugs at http://blackfin.uclinux.org/ | ||
13 | * | ||
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. | ||
18 | * | ||
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. | ||
23 | * | ||
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 | ||
28 | */ | ||
29 | |||
30 | #include <linux/module.h> | ||
31 | #include <linux/kernel.h> | ||
32 | #include <linux/init.h> | ||
33 | #include <linux/proc_fs.h> | ||
34 | |||
35 | #include <asm/current.h> | ||
36 | #include <asm/uaccess.h> | ||
37 | #include <asm/system.h> | ||
38 | |||
39 | #include <asm/cplb.h> | ||
40 | #include <asm/blackfin.h> | ||
41 | |||
42 | #define CPLB_I 1 | ||
43 | #define CPLB_D 2 | ||
44 | |||
45 | #define SYNC_SYS SSYNC() | ||
46 | #define SYNC_CORE CSYNC() | ||
47 | |||
48 | #define CPLB_BIT_PAGESIZE 0x30000 | ||
49 | |||
50 | static int page_size_table[4] = { | ||
51 | 0x00000400, /* 1K */ | ||
52 | 0x00001000, /* 4K */ | ||
53 | 0x00100000, /* 1M */ | ||
54 | 0x00400000 /* 4M */ | ||
55 | }; | ||
56 | |||
57 | static char page_size_string_table[][4] = { "1K", "4K", "1M", "4M" }; | ||
58 | |||
59 | static int cplb_find_entry(unsigned long *cplb_addr, | ||
60 | unsigned long *cplb_data, unsigned long addr, | ||
61 | unsigned long data) | ||
62 | { | ||
63 | int ii; | ||
64 | |||
65 | for (ii = 0; ii < 16; ii++) | ||
66 | if (addr >= cplb_addr[ii] && addr < cplb_addr[ii] + | ||
67 | page_size_table[(cplb_data[ii] & CPLB_BIT_PAGESIZE) >> 16] | ||
68 | && (cplb_data[ii] == data)) | ||
69 | return ii; | ||
70 | |||
71 | return -1; | ||
72 | } | ||
73 | |||
74 | static char *cplb_print_entry(char *buf, int type) | ||
75 | { | ||
76 | unsigned long *p_addr = dpdt_table; | ||
77 | unsigned long *p_data = dpdt_table + 1; | ||
78 | unsigned long *p_icount = dpdt_swapcount_table; | ||
79 | unsigned long *p_ocount = dpdt_swapcount_table + 1; | ||
80 | unsigned long *cplb_addr = (unsigned long *)DCPLB_ADDR0; | ||
81 | unsigned long *cplb_data = (unsigned long *)DCPLB_DATA0; | ||
82 | int entry = 0, used_cplb = 0; | ||
83 | |||
84 | if (type == CPLB_I) { | ||
85 | buf += sprintf(buf, "Instrction CPLB entry:\n"); | ||
86 | p_addr = ipdt_table; | ||
87 | p_data = ipdt_table + 1; | ||
88 | p_icount = ipdt_swapcount_table; | ||
89 | p_ocount = ipdt_swapcount_table + 1; | ||
90 | cplb_addr = (unsigned long *)ICPLB_ADDR0; | ||
91 | cplb_data = (unsigned long *)ICPLB_DATA0; | ||
92 | } else | ||
93 | buf += sprintf(buf, "Data CPLB entry:\n"); | ||
94 | |||
95 | buf += sprintf(buf, "Address\t\tData\tSize\tValid\tLocked\tSwapin\ | ||
96 | \tiCount\toCount\n"); | ||
97 | |||
98 | while (*p_addr != 0xffffffff) { | ||
99 | entry = cplb_find_entry(cplb_addr, cplb_data, *p_addr, *p_data); | ||
100 | if (entry >= 0) | ||
101 | used_cplb |= 1 << entry; | ||
102 | |||
103 | buf += | ||
104 | sprintf(buf, | ||
105 | "0x%08lx\t0x%05lx\t%s\t%c\t%c\t%2d\t%ld\t%ld\n", | ||
106 | *p_addr, *p_data, | ||
107 | page_size_string_table[(*p_data & 0x30000) >> 16], | ||
108 | (*p_data & CPLB_VALID) ? 'Y' : 'N', | ||
109 | (*p_data & CPLB_LOCK) ? 'Y' : 'N', entry, *p_icount, | ||
110 | *p_ocount); | ||
111 | |||
112 | p_addr += 2; | ||
113 | p_data += 2; | ||
114 | p_icount += 2; | ||
115 | p_ocount += 2; | ||
116 | } | ||
117 | |||
118 | if (used_cplb != 0xffff) { | ||
119 | buf += sprintf(buf, "Unused/mismatched CPLBs:\n"); | ||
120 | |||
121 | for (entry = 0; entry < 16; entry++) | ||
122 | if (0 == ((1 << entry) & used_cplb)) { | ||
123 | int flags = cplb_data[entry]; | ||
124 | buf += | ||
125 | sprintf(buf, | ||
126 | "%2d: 0x%08lx\t0x%05x\t%s\t%c\t%c\n", | ||
127 | entry, cplb_addr[entry], flags, | ||
128 | page_size_string_table[(flags & | ||
129 | 0x30000) >> | ||
130 | 16], | ||
131 | (flags & CPLB_VALID) ? 'Y' : 'N', | ||
132 | (flags & CPLB_LOCK) ? 'Y' : 'N'); | ||
133 | } | ||
134 | } | ||
135 | |||
136 | buf += sprintf(buf, "\n"); | ||
137 | |||
138 | return buf; | ||
139 | } | ||
140 | |||
141 | static int cplbinfo_proc_output(char *buf) | ||
142 | { | ||
143 | char *p; | ||
144 | |||
145 | p = buf; | ||
146 | |||
147 | p += sprintf(p, | ||
148 | "------------------ CPLB Information ------------------\n\n"); | ||
149 | |||
150 | if (bfin_read_IMEM_CONTROL() & ENICPLB) | ||
151 | p = cplb_print_entry(p, CPLB_I); | ||
152 | else | ||
153 | p += sprintf(p, "Instruction CPLB is disabled.\n\n"); | ||
154 | |||
155 | if (bfin_read_DMEM_CONTROL() & ENDCPLB) | ||
156 | p = cplb_print_entry(p, CPLB_D); | ||
157 | else | ||
158 | p += sprintf(p, "Data CPLB is disabled.\n"); | ||
159 | |||
160 | return p - buf; | ||
161 | } | ||
162 | |||
163 | static int cplbinfo_read_proc(char *page, char **start, off_t off, | ||
164 | int count, int *eof, void *data) | ||
165 | { | ||
166 | int len; | ||
167 | |||
168 | len = cplbinfo_proc_output(page); | ||
169 | if (len <= off + count) | ||
170 | *eof = 1; | ||
171 | *start = page + off; | ||
172 | len -= off; | ||
173 | if (len > count) | ||
174 | len = count; | ||
175 | if (len < 0) | ||
176 | len = 0; | ||
177 | return len; | ||
178 | } | ||
179 | |||
180 | static int cplbinfo_write_proc(struct file *file, const char __user *buffer, | ||
181 | unsigned long count, void *data) | ||
182 | { | ||
183 | printk(KERN_INFO "Reset the CPLB swap in/out counts.\n"); | ||
184 | memset(ipdt_swapcount_table, 0, MAX_SWITCH_I_CPLBS * sizeof(unsigned long)); | ||
185 | memset(dpdt_swapcount_table, 0, MAX_SWITCH_D_CPLBS * sizeof(unsigned long)); | ||
186 | |||
187 | return count; | ||
188 | } | ||
189 | |||
190 | static int __init cplbinfo_init(void) | ||
191 | { | ||
192 | struct proc_dir_entry *entry; | ||
193 | |||
194 | if ((entry = create_proc_entry("cplbinfo", 0, NULL)) == NULL) { | ||
195 | return -ENOMEM; | ||
196 | } | ||
197 | |||
198 | entry->read_proc = cplbinfo_read_proc; | ||
199 | entry->write_proc = cplbinfo_write_proc; | ||
200 | entry->data = NULL; | ||
201 | |||
202 | return 0; | ||
203 | } | ||
204 | |||
205 | static void __exit cplbinfo_exit(void) | ||
206 | { | ||
207 | remove_proc_entry("cplbinfo", NULL); | ||
208 | } | ||
209 | |||
210 | module_init(cplbinfo_init); | ||
211 | module_exit(cplbinfo_exit); | ||