1a942a721d5193a693303e80b08e364a0a8fb3db
[safe/jmp/linux-2.6] / arch / blackfin / kernel / setup.c
1 /*
2  * File:         arch/blackfin/kernel/setup.c
3  * Based on:
4  * Author:
5  *
6  * Created:
7  * Description:
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/delay.h>
31 #include <linux/console.h>
32 #include <linux/bootmem.h>
33 #include <linux/seq_file.h>
34 #include <linux/cpu.h>
35 #include <linux/module.h>
36 #include <linux/tty.h>
37
38 #include <linux/ext2_fs.h>
39 #include <linux/cramfs_fs.h>
40 #include <linux/romfs_fs.h>
41
42 #include <asm/cplb.h>
43 #include <asm/cacheflush.h>
44 #include <asm/blackfin.h>
45 #include <asm/cplbinit.h>
46 #include <asm/div64.h>
47 #include <asm/fixed_code.h>
48 #include <asm/early_printk.h>
49
50 u16 _bfin_swrst;
51
52 unsigned long memory_start, memory_end, physical_mem_end;
53 unsigned long reserved_mem_dcache_on;
54 unsigned long reserved_mem_icache_on;
55 EXPORT_SYMBOL(memory_start);
56 EXPORT_SYMBOL(memory_end);
57 EXPORT_SYMBOL(physical_mem_end);
58 EXPORT_SYMBOL(_ramend);
59
60 #ifdef CONFIG_MTD_UCLINUX
61 unsigned long memory_mtd_end, memory_mtd_start, mtd_size;
62 unsigned long _ebss;
63 EXPORT_SYMBOL(memory_mtd_end);
64 EXPORT_SYMBOL(memory_mtd_start);
65 EXPORT_SYMBOL(mtd_size);
66 #endif
67
68 char __initdata command_line[COMMAND_LINE_SIZE];
69
70 void __init bf53x_cache_init(void)
71 {
72 #if defined(CONFIG_BFIN_DCACHE) || defined(CONFIG_BFIN_ICACHE)
73         generate_cpl_tables();
74 #endif
75
76 #ifdef CONFIG_BFIN_ICACHE
77         bfin_icache_init();
78         printk(KERN_INFO "Instruction Cache Enabled\n");
79 #endif
80
81 #ifdef CONFIG_BFIN_DCACHE
82         bfin_dcache_init();
83         printk(KERN_INFO "Data Cache Enabled"
84 # if defined CONFIG_BFIN_WB
85                 " (write-back)"
86 # elif defined CONFIG_BFIN_WT
87                 " (write-through)"
88 # endif
89                 "\n");
90 #endif
91 }
92
93 void __init bf53x_relocate_l1_mem(void)
94 {
95         unsigned long l1_code_length;
96         unsigned long l1_data_a_length;
97         unsigned long l1_data_b_length;
98
99         l1_code_length = _etext_l1 - _stext_l1;
100         if (l1_code_length > L1_CODE_LENGTH)
101                 l1_code_length = L1_CODE_LENGTH;
102         /* cannot complain as printk is not available as yet.
103          * But we can continue booting and complain later!
104          */
105
106         /* Copy _stext_l1 to _etext_l1 to L1 instruction SRAM */
107         dma_memcpy(_stext_l1, _l1_lma_start, l1_code_length);
108
109         l1_data_a_length = _ebss_l1 - _sdata_l1;
110         if (l1_data_a_length > L1_DATA_A_LENGTH)
111                 l1_data_a_length = L1_DATA_A_LENGTH;
112
113         /* Copy _sdata_l1 to _ebss_l1 to L1 data bank A SRAM */
114         dma_memcpy(_sdata_l1, _l1_lma_start + l1_code_length, l1_data_a_length);
115
116         l1_data_b_length = _ebss_b_l1 - _sdata_b_l1;
117         if (l1_data_b_length > L1_DATA_B_LENGTH)
118                 l1_data_b_length = L1_DATA_B_LENGTH;
119
120         /* Copy _sdata_b_l1 to _ebss_b_l1 to L1 data bank B SRAM */
121         dma_memcpy(_sdata_b_l1, _l1_lma_start + l1_code_length +
122                         l1_data_a_length, l1_data_b_length);
123
124 }
125
126 /*
127  * Initial parsing of the command line.  Currently, we support:
128  *  - Controlling the linux memory size: mem=xxx[KMG]
129  *  - Controlling the physical memory size: max_mem=xxx[KMG][$][#]
130  *       $ -> reserved memory is dcacheable
131  *       # -> reserved memory is icacheable
132  */
133 static __init void parse_cmdline_early(char *cmdline_p)
134 {
135         char c = ' ', *to = cmdline_p;
136         unsigned int memsize;
137         for (;;) {
138                 if (c == ' ') {
139
140                         if (!memcmp(to, "mem=", 4)) {
141                                 to += 4;
142                                 memsize = memparse(to, &to);
143                                 if (memsize)
144                                         _ramend = memsize;
145
146                         } else if (!memcmp(to, "max_mem=", 8)) {
147                                 to += 8;
148                                 memsize = memparse(to, &to);
149                                 if (memsize) {
150                                         physical_mem_end = memsize;
151                                         if (*to != ' ') {
152                                                 if (*to == '$'
153                                                     || *(to + 1) == '$')
154                                                         reserved_mem_dcache_on =
155                                                             1;
156                                                 if (*to == '#'
157                                                     || *(to + 1) == '#')
158                                                         reserved_mem_icache_on =
159                                                             1;
160                                         }
161                                 }
162                         } else if (!memcmp(to, "earlyprintk=", 12)) {
163                                 to += 12;
164                                 setup_early_printk(to);
165                         }
166                 }
167                 c = *(to++);
168                 if (!c)
169                         break;
170         }
171 }
172
173 void __init setup_arch(char **cmdline_p)
174 {
175         int bootmap_size;
176         unsigned long l1_length, sclk, cclk;
177 #ifdef CONFIG_MTD_UCLINUX
178         unsigned long mtd_phys = 0;
179 #endif
180
181 #ifdef CONFIG_DUMMY_CONSOLE
182         conswitchp = &dummy_con;
183 #endif
184
185 #if defined(CONFIG_CMDLINE_BOOL)
186         strncpy(&command_line[0], CONFIG_CMDLINE, sizeof(command_line));
187         command_line[sizeof(command_line) - 1] = 0;
188 #endif
189
190         /* Keep a copy of command line */
191         *cmdline_p = &command_line[0];
192         memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
193         boot_command_line[COMMAND_LINE_SIZE - 1] = '\0';
194
195         /* setup memory defaults from the user config */
196         physical_mem_end = 0;
197         _ramend = CONFIG_MEM_SIZE * 1024 * 1024;
198
199         parse_cmdline_early(&command_line[0]);
200
201         cclk = get_cclk();
202         sclk = get_sclk();
203
204 #if !defined(CONFIG_BFIN_KERNEL_CLOCK)
205         if (ANOMALY_05000273 && cclk == sclk)
206                 panic("ANOMALY 05000273, SCLK can not be same as CCLK");
207 #endif
208
209 #ifdef BF561_FAMILY
210         if (ANOMALY_05000266) {
211                 bfin_read_IMDMA_D0_IRQ_STATUS();
212                 bfin_read_IMDMA_D1_IRQ_STATUS();
213         }
214 #endif
215
216         printk(KERN_INFO "Hardware Trace ");
217         if (bfin_read_TBUFCTL() & 0x1 )
218                 printk("Active ");
219         else
220                 printk("Off ");
221         if (bfin_read_TBUFCTL() & 0x2)
222                 printk("and Enabled\n");
223         else
224         printk("and Disabled\n");
225
226
227 #if defined(CONFIG_CHR_DEV_FLASH) || defined(CONFIG_BLK_DEV_FLASH)
228         /* we need to initialize the Flashrom device here since we might
229          * do things with flash early on in the boot
230          */
231         flash_probe();
232 #endif
233
234         if (physical_mem_end == 0)
235                 physical_mem_end = _ramend;
236
237         /* by now the stack is part of the init task */
238         memory_end = _ramend - DMA_UNCACHED_REGION;
239
240         _ramstart = (unsigned long)__bss_stop;
241 #ifdef CONFIG_MPU
242         /* Round up to multiple of 4MB.  */
243         memory_start = (_ramstart + 0x3fffff) & ~0x3fffff;
244 #else
245         memory_start = PAGE_ALIGN(_ramstart);
246 #endif
247
248 #if defined(CONFIG_MTD_UCLINUX)
249         /* generic memory mapped MTD driver */
250         memory_mtd_end = memory_end;
251
252         mtd_phys = _ramstart;
253         mtd_size = PAGE_ALIGN(*((unsigned long *)(mtd_phys + 8)));
254
255 # if defined(CONFIG_EXT2_FS) || defined(CONFIG_EXT3_FS)
256         if (*((unsigned short *)(mtd_phys + 0x438)) == EXT2_SUPER_MAGIC)
257                 mtd_size =
258                     PAGE_ALIGN(*((unsigned long *)(mtd_phys + 0x404)) << 10);
259 # endif
260
261 # if defined(CONFIG_CRAMFS)
262         if (*((unsigned long *)(mtd_phys)) == CRAMFS_MAGIC)
263                 mtd_size = PAGE_ALIGN(*((unsigned long *)(mtd_phys + 0x4)));
264 # endif
265
266 # if defined(CONFIG_ROMFS_FS)
267         if (((unsigned long *)mtd_phys)[0] == ROMSB_WORD0
268             && ((unsigned long *)mtd_phys)[1] == ROMSB_WORD1)
269                 mtd_size =
270                     PAGE_ALIGN(be32_to_cpu(((unsigned long *)mtd_phys)[2]));
271 #  if (defined(CONFIG_BFIN_ICACHE) && ANOMALY_05000263)
272         /* Due to a Hardware Anomaly we need to limit the size of usable
273          * instruction memory to max 60MB, 56 if HUNT_FOR_ZERO is on
274          * 05000263 - Hardware loop corrupted when taking an ICPLB exception
275          */
276 #   if (defined(CONFIG_DEBUG_HUNT_FOR_ZERO))
277         if (memory_end >= 56 * 1024 * 1024)
278                 memory_end = 56 * 1024 * 1024;
279 #   else
280         if (memory_end >= 60 * 1024 * 1024)
281                 memory_end = 60 * 1024 * 1024;
282 #   endif                               /* CONFIG_DEBUG_HUNT_FOR_ZERO */
283 #  endif                                /* ANOMALY_05000263 */
284 # endif                         /* CONFIG_ROMFS_FS */
285
286         memory_end -= mtd_size;
287
288         if (mtd_size == 0) {
289                 console_init();
290                 panic("Don't boot kernel without rootfs attached.\n");
291         }
292
293         /* Relocate MTD image to the top of memory after the uncached memory area */
294         dma_memcpy((char *)memory_end, __bss_stop, mtd_size);
295
296         memory_mtd_start = memory_end;
297         _ebss = memory_mtd_start;       /* define _ebss for compatible */
298 #endif                          /* CONFIG_MTD_UCLINUX */
299
300 #if (defined(CONFIG_BFIN_ICACHE) && ANOMALY_05000263)
301         /* Due to a Hardware Anomaly we need to limit the size of usable
302          * instruction memory to max 60MB, 56 if HUNT_FOR_ZERO is on
303          * 05000263 - Hardware loop corrupted when taking an ICPLB exception
304          */
305 #if (defined(CONFIG_DEBUG_HUNT_FOR_ZERO))
306         if (memory_end >= 56 * 1024 * 1024)
307                 memory_end = 56 * 1024 * 1024;
308 #else
309         if (memory_end >= 60 * 1024 * 1024)
310                 memory_end = 60 * 1024 * 1024;
311 #endif                          /* CONFIG_DEBUG_HUNT_FOR_ZERO */
312         printk(KERN_NOTICE "Warning: limiting memory to %liMB due to hardware anomaly 05000263\n", memory_end >> 20);
313 #endif                          /* ANOMALY_05000263 */
314
315 #ifdef CONFIG_MPU
316         page_mask_nelts = ((_ramend >> PAGE_SHIFT) + 31) / 32;
317         page_mask_order = get_order(3 * page_mask_nelts * sizeof(long));
318 #endif
319
320 #if !defined(CONFIG_MTD_UCLINUX)
321         memory_end -= SIZE_4K; /*In case there is no valid CPLB behind memory_end make sure we don't get to close*/
322 #endif
323         init_mm.start_code = (unsigned long)_stext;
324         init_mm.end_code = (unsigned long)_etext;
325         init_mm.end_data = (unsigned long)_edata;
326         init_mm.brk = (unsigned long)0;
327
328         _bfin_swrst = bfin_read_SWRST();
329
330         if (_bfin_swrst & RESET_DOUBLE)
331                 printk(KERN_INFO "Recovering from Double Fault event\n");
332         else if (_bfin_swrst & RESET_WDOG)
333                 printk(KERN_INFO "Recovering from Watchdog event\n");
334         else if (_bfin_swrst & RESET_SOFTWARE)
335                 printk(KERN_NOTICE "Reset caused by Software reset\n");
336
337         printk(KERN_INFO "Blackfin support (C) 2004-2007 Analog Devices, Inc.\n");
338         if (bfin_compiled_revid() == 0xffff)
339                 printk(KERN_INFO "Compiled for ADSP-%s Rev any\n", CPU);
340         else if (bfin_compiled_revid() == -1)
341                 printk(KERN_INFO "Compiled for ADSP-%s Rev none\n", CPU);
342         else
343                 printk(KERN_INFO "Compiled for ADSP-%s Rev 0.%d\n", CPU, bfin_compiled_revid());
344         if (bfin_revid() != bfin_compiled_revid()) {
345                 if (bfin_compiled_revid() == -1)
346                         printk(KERN_ERR "Warning: Compiled for Rev none, but running on Rev %d\n",
347                                bfin_revid());
348                 else if (bfin_compiled_revid() != 0xffff)
349                         printk(KERN_ERR "Warning: Compiled for Rev %d, but running on Rev %d\n",
350                                bfin_compiled_revid(), bfin_revid());
351         }
352         if (bfin_revid() < SUPPORTED_REVID)
353                 printk(KERN_ERR "Warning: Unsupported Chip Revision ADSP-%s Rev 0.%d detected\n",
354                        CPU, bfin_revid());
355         printk(KERN_INFO "Blackfin Linux support by http://blackfin.uclinux.org/\n");
356
357         printk(KERN_INFO "Processor Speed: %lu MHz core clock and %lu MHz System Clock\n",
358                cclk / 1000000,  sclk / 1000000);
359
360         if (ANOMALY_05000273 && (cclk >> 1) <= sclk)
361                 printk("\n\n\nANOMALY_05000273: CCLK must be >= 2*SCLK !!!\n\n\n");
362
363         printk(KERN_INFO "Board Memory: %ldMB\n", physical_mem_end >> 20);
364         printk(KERN_INFO "Kernel Managed Memory: %ldMB\n", _ramend >> 20);
365
366         printk(KERN_INFO "Memory map:\n"
367                KERN_INFO "  text      = 0x%p-0x%p\n"
368                KERN_INFO "  rodata    = 0x%p-0x%p\n"
369                KERN_INFO "  data      = 0x%p-0x%p\n"
370                KERN_INFO "    stack   = 0x%p-0x%p\n"
371                KERN_INFO "  init      = 0x%p-0x%p\n"
372                KERN_INFO "  bss       = 0x%p-0x%p\n"
373                KERN_INFO "  available = 0x%p-0x%p\n"
374 #ifdef CONFIG_MTD_UCLINUX
375                KERN_INFO "  rootfs    = 0x%p-0x%p\n"
376 #endif
377 #if DMA_UNCACHED_REGION > 0
378                KERN_INFO "  DMA Zone  = 0x%p-0x%p\n"
379 #endif
380                , _stext, _etext,
381                __start_rodata, __end_rodata,
382                _sdata, _edata,
383                (void *)&init_thread_union, (void *)((int)(&init_thread_union) + 0x2000),
384                __init_begin, __init_end,
385                __bss_start, __bss_stop,
386                (void *)_ramstart, (void *)memory_end
387 #ifdef CONFIG_MTD_UCLINUX
388                , (void *)memory_mtd_start, (void *)(memory_mtd_start + mtd_size)
389 #endif
390 #if DMA_UNCACHED_REGION > 0
391                , (void *)(_ramend - DMA_UNCACHED_REGION), (void *)(_ramend)
392 #endif
393                );
394
395         /*
396          * give all the memory to the bootmap allocator,  tell it to put the
397          * boot mem_map at the start of memory
398          */
399         bootmap_size = init_bootmem_node(NODE_DATA(0), memory_start >> PAGE_SHIFT,      /* map goes here */
400                                          PAGE_OFFSET >> PAGE_SHIFT,
401                                          memory_end >> PAGE_SHIFT);
402         /*
403          * free the usable memory,  we have to make sure we do not free
404          * the bootmem bitmap so we then reserve it after freeing it :-)
405          */
406         free_bootmem(memory_start, memory_end - memory_start);
407
408         reserve_bootmem(memory_start, bootmap_size);
409         /*
410          * get kmalloc into gear
411          */
412         paging_init();
413
414         /* check the size of the l1 area */
415         l1_length = _etext_l1 - _stext_l1;
416         if (l1_length > L1_CODE_LENGTH)
417                 panic("L1 code memory overflow\n");
418
419         l1_length = _ebss_l1 - _sdata_l1;
420         if (l1_length > L1_DATA_A_LENGTH)
421                 panic("L1 data memory overflow\n");
422
423         /* Copy atomic sequences to their fixed location, and sanity check that
424            these locations are the ones that we advertise to userspace.  */
425         memcpy((void *)FIXED_CODE_START, &fixed_code_start,
426                FIXED_CODE_END - FIXED_CODE_START);
427         BUG_ON((char *)&sigreturn_stub - (char *)&fixed_code_start
428                != SIGRETURN_STUB - FIXED_CODE_START);
429         BUG_ON((char *)&atomic_xchg32 - (char *)&fixed_code_start
430                != ATOMIC_XCHG32 - FIXED_CODE_START);
431         BUG_ON((char *)&atomic_cas32 - (char *)&fixed_code_start
432                != ATOMIC_CAS32 - FIXED_CODE_START);
433         BUG_ON((char *)&atomic_add32 - (char *)&fixed_code_start
434                != ATOMIC_ADD32 - FIXED_CODE_START);
435         BUG_ON((char *)&atomic_sub32 - (char *)&fixed_code_start
436                != ATOMIC_SUB32 - FIXED_CODE_START);
437         BUG_ON((char *)&atomic_ior32 - (char *)&fixed_code_start
438                != ATOMIC_IOR32 - FIXED_CODE_START);
439         BUG_ON((char *)&atomic_and32 - (char *)&fixed_code_start
440                != ATOMIC_AND32 - FIXED_CODE_START);
441         BUG_ON((char *)&atomic_xor32 - (char *)&fixed_code_start
442                != ATOMIC_XOR32 - FIXED_CODE_START);
443         BUG_ON((char *)&safe_user_instruction - (char *)&fixed_code_start
444                 != SAFE_USER_INSTRUCTION - FIXED_CODE_START);
445
446         init_exception_vectors();
447         bf53x_cache_init();
448 }
449
450 static int __init topology_init(void)
451 {
452 #if defined (CONFIG_BF561)
453         static struct cpu cpu[2];
454         register_cpu(&cpu[0], 0);
455         register_cpu(&cpu[1], 1);
456         return 0;
457 #else
458         static struct cpu cpu[1];
459         return register_cpu(cpu, 0);
460 #endif
461 }
462
463 subsys_initcall(topology_init);
464
465 static u_long get_vco(void)
466 {
467         u_long msel;
468         u_long vco;
469
470         msel = (bfin_read_PLL_CTL() >> 9) & 0x3F;
471         if (0 == msel)
472                 msel = 64;
473
474         vco = CONFIG_CLKIN_HZ;
475         vco >>= (1 & bfin_read_PLL_CTL());      /* DF bit */
476         vco = msel * vco;
477         return vco;
478 }
479
480 /* Get the Core clock */
481 u_long get_cclk(void)
482 {
483         u_long csel, ssel;
484         if (bfin_read_PLL_STAT() & 0x1)
485                 return CONFIG_CLKIN_HZ;
486
487         ssel = bfin_read_PLL_DIV();
488         csel = ((ssel >> 4) & 0x03);
489         ssel &= 0xf;
490         if (ssel && ssel < (1 << csel)) /* SCLK > CCLK */
491                 return get_vco() / ssel;
492         return get_vco() >> csel;
493 }
494 EXPORT_SYMBOL(get_cclk);
495
496 /* Get the System clock */
497 u_long get_sclk(void)
498 {
499         u_long ssel;
500
501         if (bfin_read_PLL_STAT() & 0x1)
502                 return CONFIG_CLKIN_HZ;
503
504         ssel = (bfin_read_PLL_DIV() & 0xf);
505         if (0 == ssel) {
506                 printk(KERN_WARNING "Invalid System Clock\n");
507                 ssel = 1;
508         }
509
510         return get_vco() / ssel;
511 }
512 EXPORT_SYMBOL(get_sclk);
513
514 unsigned long sclk_to_usecs(unsigned long sclk)
515 {
516         u64 tmp = USEC_PER_SEC * (u64)sclk;
517         do_div(tmp, get_sclk());
518         return tmp;
519 }
520 EXPORT_SYMBOL(sclk_to_usecs);
521
522 unsigned long usecs_to_sclk(unsigned long usecs)
523 {
524         u64 tmp = get_sclk() * (u64)usecs;
525         do_div(tmp, USEC_PER_SEC);
526         return tmp;
527 }
528 EXPORT_SYMBOL(usecs_to_sclk);
529
530 /*
531  *      Get CPU information for use by the procfs.
532  */
533 static int show_cpuinfo(struct seq_file *m, void *v)
534 {
535         char *cpu, *mmu, *fpu, *vendor, *cache;
536         uint32_t revid;
537
538         u_long cclk = 0, sclk = 0;
539         u_int dcache_size = 0, dsup_banks = 0;
540
541         cpu = CPU;
542         mmu = "none";
543         fpu = "none";
544         revid = bfin_revid();
545
546         cclk = get_cclk();
547         sclk = get_sclk();
548
549         switch (bfin_read_CHIPID() & CHIPID_MANUFACTURE) {
550         case 0xca:
551                 vendor = "Analog Devices";
552                 break;
553         default:
554                 vendor = "unknown";
555                 break;
556         }
557
558         seq_printf(m, "processor\t: %d\n"
559                 "vendor_id\t: %s\n"
560                 "cpu family\t: 0x%x\n"
561                 "model name\t: ADSP-%s %lu(MHz CCLK) %lu(MHz SCLK)\n"
562                 "stepping\t: %d\n",
563                 0,
564                 vendor,
565                 (bfin_read_CHIPID() & CHIPID_FAMILY),
566                 cpu, cclk/1000000, sclk/1000000,
567                 revid);
568
569         seq_printf(m, "cpu MHz\t\t: %lu.%03lu/%lu.%03lu\n",
570                 cclk/1000000, cclk%1000000,
571                 sclk/1000000, sclk%1000000);
572         seq_printf(m, "bogomips\t: %lu.%02lu\n"
573                 "Calibration\t: %lu loops\n",
574                 (loops_per_jiffy * HZ) / 500000,
575                 ((loops_per_jiffy * HZ) / 5000) % 100,
576                 (loops_per_jiffy * HZ));
577
578         /* Check Cache configutation */
579         switch (bfin_read_DMEM_CONTROL() & (1 << DMC0_P | 1 << DMC1_P)) {
580         case ACACHE_BSRAM:
581                 cache = "dbank-A/B\t: cache/sram";
582                 dcache_size = 16;
583                 dsup_banks = 1;
584                 break;
585         case ACACHE_BCACHE:
586                 cache = "dbank-A/B\t: cache/cache";
587                 dcache_size = 32;
588                 dsup_banks = 2;
589                 break;
590         case ASRAM_BSRAM:
591                 cache = "dbank-A/B\t: sram/sram";
592                 dcache_size = 0;
593                 dsup_banks = 0;
594                 break;
595         default:
596                 cache = "unknown";
597                 dcache_size = 0;
598                 dsup_banks = 0;
599                 break;
600         }
601
602         /* Is it turned on? */
603         if (!((bfin_read_DMEM_CONTROL()) & (ENDCPLB | DMC_ENABLE)))
604                 dcache_size = 0;
605
606         seq_printf(m, "cache size\t: %d KB(L1 icache) "
607                 "%d KB(L1 dcache-%s) %d KB(L2 cache)\n",
608                 BFIN_ICACHESIZE / 1024, dcache_size,
609 #if defined CONFIG_BFIN_WB
610                 "wb"
611 #elif defined CONFIG_BFIN_WT
612                 "wt"
613 #endif
614                 "", 0);
615
616         seq_printf(m, "%s\n", cache);
617
618         seq_printf(m, "icache setup\t: %d Sub-banks/%d Ways, %d Lines/Way\n",
619                    BFIN_ISUBBANKS, BFIN_IWAYS, BFIN_ILINES);
620         seq_printf(m,
621                    "dcache setup\t: %d Super-banks/%d Sub-banks/%d Ways, %d Lines/Way\n",
622                    dsup_banks, BFIN_DSUBBANKS, BFIN_DWAYS,
623                    BFIN_DLINES);
624 #ifdef CONFIG_BFIN_ICACHE_LOCK
625         switch (read_iloc()) {
626         case WAY0_L:
627                 seq_printf(m, "Way0 Locked-Down\n");
628                 break;
629         case WAY1_L:
630                 seq_printf(m, "Way1 Locked-Down\n");
631                 break;
632         case WAY01_L:
633                 seq_printf(m, "Way0,Way1 Locked-Down\n");
634                 break;
635         case WAY2_L:
636                 seq_printf(m, "Way2 Locked-Down\n");
637                 break;
638         case WAY02_L:
639                 seq_printf(m, "Way0,Way2 Locked-Down\n");
640                 break;
641         case WAY12_L:
642                 seq_printf(m, "Way1,Way2 Locked-Down\n");
643                 break;
644         case WAY012_L:
645                 seq_printf(m, "Way0,Way1 & Way2 Locked-Down\n");
646                 break;
647         case WAY3_L:
648                 seq_printf(m, "Way3 Locked-Down\n");
649                 break;
650         case WAY03_L:
651                 seq_printf(m, "Way0,Way3 Locked-Down\n");
652                 break;
653         case WAY13_L:
654                 seq_printf(m, "Way1,Way3 Locked-Down\n");
655                 break;
656         case WAY013_L:
657                 seq_printf(m, "Way 0,Way1,Way3 Locked-Down\n");
658                 break;
659         case WAY32_L:
660                 seq_printf(m, "Way3,Way2 Locked-Down\n");
661                 break;
662         case WAY320_L:
663                 seq_printf(m, "Way3,Way2,Way0 Locked-Down\n");
664                 break;
665         case WAY321_L:
666                 seq_printf(m, "Way3,Way2,Way1 Locked-Down\n");
667                 break;
668         case WAYALL_L:
669                 seq_printf(m, "All Ways are locked\n");
670                 break;
671         default:
672                 seq_printf(m, "No Ways are locked\n");
673         }
674 #endif
675
676         seq_printf(m, "board name\t: %s\n", bfin_board_name);
677         seq_printf(m, "board memory\t: %ld kB (0x%p -> 0x%p)\n",
678                  physical_mem_end >> 10, (void *)0, (void *)physical_mem_end);
679         seq_printf(m, "kernel memory\t: %d kB (0x%p -> 0x%p)\n",
680                 ((int)memory_end - (int)_stext) >> 10,
681                 _stext,
682                 (void *)memory_end);
683
684         return 0;
685 }
686
687 static void *c_start(struct seq_file *m, loff_t *pos)
688 {
689         return *pos < NR_CPUS ? ((void *)0x12345678) : NULL;
690 }
691
692 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
693 {
694         ++*pos;
695         return c_start(m, pos);
696 }
697
698 static void c_stop(struct seq_file *m, void *v)
699 {
700 }
701
702 struct seq_operations cpuinfo_op = {
703         .start = c_start,
704         .next = c_next,
705         .stop = c_stop,
706         .show = show_cpuinfo,
707 };
708
709 void __init cmdline_init(const char *r0)
710 {
711         if (r0)
712                 strncpy(command_line, r0, COMMAND_LINE_SIZE);
713 }