1 // SPDX-License-Identifier: GPL-2.0
3 * linux/arch/alpha/kernel/setup.c
5 * Copyright (C) 1995 Linus Torvalds
8 /* 2.3.x bootmem, 1999 Andrea Arcangeli <andrea@suse.de> */
14 #include <linux/sched.h>
15 #include <linux/kernel.h>
17 #include <linux/stddef.h>
18 #include <linux/unistd.h>
19 #include <linux/ptrace.h>
20 #include <linux/slab.h>
21 #include <linux/user.h>
22 #include <linux/screen_info.h>
23 #include <linux/delay.h>
24 #include <linux/mc146818rtc.h>
25 #include <linux/console.h>
26 #include <linux/cpu.h>
27 #include <linux/errno.h>
28 #include <linux/init.h>
29 #include <linux/string.h>
30 #include <linux/ioport.h>
31 #include <linux/platform_device.h>
32 #include <linux/memblock.h>
33 #include <linux/pci.h>
34 #include <linux/seq_file.h>
35 #include <linux/root_dev.h>
36 #include <linux/initrd.h>
37 #include <linux/eisa.h>
38 #include <linux/pfn.h>
39 #ifdef CONFIG_MAGIC_SYSRQ
40 #include <linux/sysrq.h>
41 #include <linux/reboot.h>
43 #include <linux/notifier.h>
44 #include <asm/setup.h>
46 #include <linux/log2.h>
47 #include <linux/export.h>
49 extern struct atomic_notifier_head panic_notifier_list
;
50 static int alpha_panic_event(struct notifier_block
*, unsigned long, void *);
51 static struct notifier_block alpha_panic_block
= {
54 INT_MAX
/* try to do it first */
57 #include <linux/uaccess.h>
58 #include <asm/pgtable.h>
59 #include <asm/hwrpb.h>
61 #include <asm/mmu_context.h>
62 #include <asm/console.h>
68 struct hwrpb_struct
*hwrpb
;
70 unsigned long srm_hae
;
72 int alpha_l1i_cacheshape
;
73 int alpha_l1d_cacheshape
;
74 int alpha_l2_cacheshape
;
75 int alpha_l3_cacheshape
;
77 #ifdef CONFIG_VERBOSE_MCHECK
78 /* 0=minimum, 1=verbose, 2=all */
79 /* These can be overridden via the command line, ie "verbose_mcheck=2") */
80 unsigned long alpha_verbose_mcheck
= CONFIG_VERBOSE_MCHECK_ON
;
84 struct cpumask node_to_cpumask_map
[MAX_NUMNODES
] __read_mostly
;
85 EXPORT_SYMBOL(node_to_cpumask_map
);
88 /* Which processor we booted from. */
92 * Using SRM callbacks for initial console output. This works from
93 * setup_arch() time through the end of time_init(), as those places
94 * are under our (Alpha) control.
96 * "srmcons" specified in the boot command arguments allows us to
97 * see kernel messages during the period of time before the true
98 * console device is "registered" during console_init().
99 * As of this version (2.5.59), console_init() will call
100 * disable_early_printk() as the last action before initializing
101 * the console drivers. That's the last possible time srmcons can be
102 * unregistered without interfering with console behavior.
104 * By default, OFF; set it with a bootcommand arg of "srmcons" or
105 * "console=srm". The meaning of these two args is:
106 * "srmcons" - early callback prints
107 * "console=srm" - full callback based console, including early prints
109 int srmcons_output
= 0;
111 /* Enforce a memory size limit; useful for testing. By default, none. */
112 unsigned long mem_size_limit
= 0;
114 /* Set AGP GART window size (0 means disabled). */
115 unsigned long alpha_agpgart_size
= DEFAULT_AGP_APER_SIZE
;
117 #ifdef CONFIG_ALPHA_GENERIC
118 struct alpha_machine_vector alpha_mv
;
119 EXPORT_SYMBOL(alpha_mv
);
122 #ifndef alpha_using_srm
124 EXPORT_SYMBOL(alpha_using_srm
);
127 #ifndef alpha_using_qemu
128 int alpha_using_qemu
;
131 static struct alpha_machine_vector
*get_sysvec(unsigned long, unsigned long,
133 static struct alpha_machine_vector
*get_sysvec_byname(const char *);
134 static void get_sysnames(unsigned long, unsigned long, unsigned long,
136 static void determine_cpu_caches (unsigned int);
138 static char __initdata command_line
[COMMAND_LINE_SIZE
];
141 * The format of "screen_info" is strange, and due to early
142 * i386-setup code. This is just enough to make the console
143 * code think we're on a VGA color display.
146 struct screen_info screen_info
= {
149 .orig_video_cols
= 80,
150 .orig_video_lines
= 25,
151 .orig_video_isVGA
= 1,
152 .orig_video_points
= 16
155 EXPORT_SYMBOL(screen_info
);
158 * The direct map I/O window, if any. This should be the same
159 * for all busses, since it's used by virt_to_bus.
162 unsigned long __direct_map_base
;
163 unsigned long __direct_map_size
;
164 EXPORT_SYMBOL(__direct_map_base
);
165 EXPORT_SYMBOL(__direct_map_size
);
168 * Declare all of the machine vectors.
171 /* GCC 2.7.2 (on alpha at least) is lame. It does not support either
172 __attribute__((weak)) or #pragma weak. Bypass it and talk directly
176 extern struct alpha_machine_vector X; \
196 WEAK(mikasa_primo_mv
);
201 WEAK(noritake_primo_mv
);
209 WEAK(sable_gamma_mv
);
222 * I/O resources inherited from PeeCees. Except for perhaps the
223 * turbochannel alphas, everyone has these on some sort of SuperIO chip.
225 * ??? If this becomes less standard, move the struct out into the
230 reserve_std_resources(void)
232 static struct resource standard_io_resources
[] = {
233 { .name
= "rtc", .start
= -1, .end
= -1 },
234 { .name
= "dma1", .start
= 0x00, .end
= 0x1f },
235 { .name
= "pic1", .start
= 0x20, .end
= 0x3f },
236 { .name
= "timer", .start
= 0x40, .end
= 0x5f },
237 { .name
= "keyboard", .start
= 0x60, .end
= 0x6f },
238 { .name
= "dma page reg", .start
= 0x80, .end
= 0x8f },
239 { .name
= "pic2", .start
= 0xa0, .end
= 0xbf },
240 { .name
= "dma2", .start
= 0xc0, .end
= 0xdf },
243 struct resource
*io
= &ioport_resource
;
247 struct pci_controller
*hose
;
248 for (hose
= hose_head
; hose
; hose
= hose
->next
)
249 if (hose
->index
== 0) {
255 /* Fix up for the Jensen's queer RTC placement. */
256 standard_io_resources
[0].start
= RTC_PORT(0);
257 standard_io_resources
[0].end
= RTC_PORT(0) + 0x10;
259 for (i
= 0; i
< ARRAY_SIZE(standard_io_resources
); ++i
)
260 request_resource(io
, standard_io_resources
+i
);
263 #define PFN_MAX PFN_DOWN(0x80000000)
264 #define for_each_mem_cluster(memdesc, _cluster, i) \
265 for ((_cluster) = (memdesc)->cluster, (i) = 0; \
266 (i) < (memdesc)->numclusters; (i)++, (_cluster)++)
268 static unsigned long __init
269 get_mem_size_limit(char *s
)
271 unsigned long end
= 0;
274 end
= simple_strtoul(from
, &from
, 0);
275 if ( *from
== 'K' || *from
== 'k' ) {
278 } else if ( *from
== 'M' || *from
== 'm' ) {
281 } else if ( *from
== 'G' || *from
== 'g' ) {
285 return end
>> PAGE_SHIFT
; /* Return the PFN of the limit. */
288 #ifdef CONFIG_BLK_DEV_INITRD
290 move_initrd(unsigned long mem_limit
)
295 size
= initrd_end
- initrd_start
;
296 start
= memblock_alloc(PAGE_ALIGN(size
), PAGE_SIZE
);
297 if (!start
|| __pa(start
) + size
> mem_limit
) {
298 initrd_start
= initrd_end
= 0;
301 memmove(start
, (void *)initrd_start
, size
);
302 initrd_start
= (unsigned long)start
;
303 initrd_end
= initrd_start
+ size
;
304 printk("initrd moved to %p\n", start
);
309 #ifndef CONFIG_DISCONTIGMEM
311 setup_memory(void *kernel_end
)
313 struct memclust_struct
* cluster
;
314 struct memdesc_struct
* memdesc
;
315 unsigned long kernel_size
;
318 /* Find free clusters, and init and free the bootmem accordingly. */
319 memdesc
= (struct memdesc_struct
*)
320 (hwrpb
->mddt_offset
+ (unsigned long) hwrpb
);
322 for_each_mem_cluster(memdesc
, cluster
, i
) {
325 printk("memcluster %lu, usage %01lx, start %8lu, end %8lu\n",
326 i
, cluster
->usage
, cluster
->start_pfn
,
327 cluster
->start_pfn
+ cluster
->numpages
);
329 /* Bit 0 is console/PALcode reserved. Bit 1 is
330 non-volatile memory -- we might want to mark
332 if (cluster
->usage
& 3)
335 end
= cluster
->start_pfn
+ cluster
->numpages
;
336 if (end
> max_low_pfn
)
339 memblock_add(PFN_PHYS(cluster
->start_pfn
),
340 cluster
->numpages
<< PAGE_SHIFT
);
344 * Except for the NUMA systems (wildfire, marvel) all of the
345 * Alpha systems we run on support 32GB of memory or less.
346 * Since the NUMA systems introduce large holes in memory addressing,
347 * we can get into a situation where there is not enough contiguous
348 * memory for the memory map.
350 * Limit memory to the first 32GB to limit the NUMA systems to
351 * memory on their first node (wildfire) or 2 (marvel) to avoid
352 * not being able to produce the memory map. In order to access
353 * all of the memory on the NUMA systems, build with discontiguous
356 * If the user specified a memory limit, let that memory limit stand.
359 mem_size_limit
= (32ul * 1024 * 1024 * 1024) >> PAGE_SHIFT
;
361 if (mem_size_limit
&& max_low_pfn
>= mem_size_limit
)
363 printk("setup: forcing memory size to %ldK (from %ldK).\n",
364 mem_size_limit
<< (PAGE_SHIFT
- 10),
365 max_low_pfn
<< (PAGE_SHIFT
- 10));
366 max_low_pfn
= mem_size_limit
;
369 /* Reserve the kernel memory. */
370 kernel_size
= virt_to_phys(kernel_end
) - KERNEL_START_PHYS
;
371 memblock_reserve(KERNEL_START_PHYS
, kernel_size
);
373 #ifdef CONFIG_BLK_DEV_INITRD
374 initrd_start
= INITRD_START
;
376 initrd_end
= initrd_start
+INITRD_SIZE
;
377 printk("Initial ramdisk at: 0x%p (%lu bytes)\n",
378 (void *) initrd_start
, INITRD_SIZE
);
380 if ((void *)initrd_end
> phys_to_virt(PFN_PHYS(max_low_pfn
))) {
381 if (!move_initrd(PFN_PHYS(max_low_pfn
)))
382 printk("initrd extends beyond end of memory "
383 "(0x%08lx > 0x%p)\ndisabling initrd\n",
385 phys_to_virt(PFN_PHYS(max_low_pfn
)));
387 memblock_reserve(virt_to_phys((void *)initrd_start
),
391 #endif /* CONFIG_BLK_DEV_INITRD */
394 extern void setup_memory(void *);
395 #endif /* !CONFIG_DISCONTIGMEM */
398 page_is_ram(unsigned long pfn
)
400 struct memclust_struct
* cluster
;
401 struct memdesc_struct
* memdesc
;
404 memdesc
= (struct memdesc_struct
*)
405 (hwrpb
->mddt_offset
+ (unsigned long) hwrpb
);
406 for_each_mem_cluster(memdesc
, cluster
, i
)
408 if (pfn
>= cluster
->start_pfn
&&
409 pfn
< cluster
->start_pfn
+ cluster
->numpages
) {
410 return (cluster
->usage
& 3) ? 0 : 1;
422 for_each_possible_cpu(i
) {
423 struct cpu
*p
= kzalloc(sizeof(*p
), GFP_KERNEL
);
431 arch_initcall(register_cpus
);
434 setup_arch(char **cmdline_p
)
438 struct alpha_machine_vector
*vec
= NULL
;
439 struct percpu_struct
*cpu
;
440 char *type_name
, *var_name
, *p
;
441 void *kernel_end
= _end
; /* end of kernel */
442 char *args
= command_line
;
444 hwrpb
= (struct hwrpb_struct
*) __va(INIT_HWRPB
->phys_addr
);
445 boot_cpuid
= hard_smp_processor_id();
448 * Pre-process the system type to make sure it will be valid.
450 * This may restore real CABRIO and EB66+ family names, ie
453 * Oh, and "white box" AS800 (aka DIGITAL Server 3000 series)
454 * and AS1200 (DIGITAL Server 5000 series) have the type as
455 * the negative of the real one.
457 if ((long)hwrpb
->sys_type
< 0) {
458 hwrpb
->sys_type
= -((long)hwrpb
->sys_type
);
459 hwrpb_update_checksum(hwrpb
);
462 /* Register a call for panic conditions. */
463 atomic_notifier_chain_register(&panic_notifier_list
,
466 #ifndef alpha_using_srm
467 /* Assume that we've booted from SRM if we haven't booted from MILO.
468 Detect the later by looking for "MILO" in the system serial nr. */
469 alpha_using_srm
= strncmp((const char *)hwrpb
->ssn
, "MILO", 4) != 0;
471 #ifndef alpha_using_qemu
472 /* Similarly, look for QEMU. */
473 alpha_using_qemu
= strstr((const char *)hwrpb
->ssn
, "QEMU") != 0;
476 /* If we are using SRM, we want to allow callbacks
477 as early as possible, so do this NOW, and then
478 they should work immediately thereafter.
480 kernel_end
= callback_init(kernel_end
);
483 * Locate the command line.
485 /* Hack for Jensen... since we're restricted to 8 or 16 chars for
486 boot flags depending on the boot mode, we need some shorthand.
487 This should do for installation. */
488 if (strcmp(COMMAND_LINE
, "INSTALL") == 0) {
489 strlcpy(command_line
, "root=/dev/fd0 load_ramdisk=1", sizeof command_line
);
491 strlcpy(command_line
, COMMAND_LINE
, sizeof command_line
);
493 strcpy(boot_command_line
, command_line
);
494 *cmdline_p
= command_line
;
497 * Process command-line arguments.
499 while ((p
= strsep(&args
, " \t")) != NULL
) {
501 if (strncmp(p
, "alpha_mv=", 9) == 0) {
502 vec
= get_sysvec_byname(p
+9);
505 if (strncmp(p
, "cycle=", 6) == 0) {
506 est_cycle_freq
= simple_strtol(p
+6, NULL
, 0);
509 if (strncmp(p
, "mem=", 4) == 0) {
510 mem_size_limit
= get_mem_size_limit(p
+4);
513 if (strncmp(p
, "srmcons", 7) == 0) {
517 if (strncmp(p
, "console=srm", 11) == 0) {
521 if (strncmp(p
, "gartsize=", 9) == 0) {
523 get_mem_size_limit(p
+9) << PAGE_SHIFT
;
526 #ifdef CONFIG_VERBOSE_MCHECK
527 if (strncmp(p
, "verbose_mcheck=", 15) == 0) {
528 alpha_verbose_mcheck
= simple_strtol(p
+15, NULL
, 0);
534 /* Replace the command line, now that we've killed it with strsep. */
535 strcpy(command_line
, boot_command_line
);
537 /* If we want SRM console printk echoing early, do it now. */
538 if (alpha_using_srm
&& srmcons_output
) {
539 register_srm_console();
542 * If "console=srm" was specified, clear the srmcons_output
543 * flag now so that time.c won't unregister_srm_console
545 if (srmcons_output
& 2)
549 #ifdef CONFIG_MAGIC_SYSRQ
550 /* If we're using SRM, make sysrq-b halt back to the prom,
552 if (alpha_using_srm
) {
553 struct sysrq_key_op
*op
= __sysrq_get_key_op('b');
554 op
->handler
= (void *) machine_halt
;
559 * Identify and reconfigure for the current system.
561 cpu
= (struct percpu_struct
*)((char*)hwrpb
+ hwrpb
->processor_offset
);
563 get_sysnames(hwrpb
->sys_type
, hwrpb
->sys_variation
,
564 cpu
->type
, &type_name
, &var_name
);
565 if (*var_name
== '0')
569 vec
= get_sysvec(hwrpb
->sys_type
, hwrpb
->sys_variation
,
574 panic("Unsupported system type: %s%s%s (%ld %ld)\n",
575 type_name
, (*var_name
? " variation " : ""), var_name
,
576 hwrpb
->sys_type
, hwrpb
->sys_variation
);
578 if (vec
!= &alpha_mv
) {
583 #ifdef CONFIG_ALPHA_GENERIC
586 "on %s%s%s using machine vector %s from %s\n",
587 type_name
, (*var_name
? " variation " : ""),
588 var_name
, alpha_mv
.vector_name
,
589 (alpha_using_srm
? "SRM" : "MILO"));
591 printk("Major Options: "
595 #ifdef CONFIG_ALPHA_EV56
598 #ifdef CONFIG_ALPHA_EV67
601 #ifdef CONFIG_ALPHA_LEGACY_START_ADDRESS
604 #ifdef CONFIG_VERBOSE_MCHECK
608 #ifdef CONFIG_DISCONTIGMEM
615 #ifdef CONFIG_DEBUG_SPINLOCK
618 #ifdef CONFIG_MAGIC_SYSRQ
623 printk("Command line: %s\n", command_line
);
627 * Save the SRM's current value for restoration.
629 srm_hae
= *alpha_mv
.hae_register
;
630 __set_hae(alpha_mv
.hae_cache
);
632 /* Reset enable correctable error reports. */
635 /* Find our memory. */
636 setup_memory(kernel_end
);
637 memblock_set_bottom_up(true);
639 /* First guess at cpu cache sizes. Do this before init_arch. */
640 determine_cpu_caches(cpu
->type
);
642 /* Initialize the machine. Usually has to do with setting up
643 DMA windows and the like. */
644 if (alpha_mv
.init_arch
)
645 alpha_mv
.init_arch();
647 /* Reserve standard resources. */
648 reserve_std_resources();
651 * Give us a default console. TGA users will see nothing until
652 * chr_dev_init is called, rather late in the boot sequence.
656 #if defined(CONFIG_VGA_CONSOLE)
657 conswitchp
= &vga_con
;
658 #elif defined(CONFIG_DUMMY_CONSOLE)
659 conswitchp
= &dummy_con
;
663 /* Default root filesystem to sda2. */
664 ROOT_DEV
= Root_SDA2
;
667 /* FIXME: only set this when we actually have EISA in this box? */
672 * Check ASN in HWRPB for validity, report if bad.
673 * FIXME: how was this failing? Should we trust it instead,
674 * and copy the value into alpha_mv.max_asn?
677 if (hwrpb
->max_asn
!= MAX_ASN
) {
678 printk("Max ASN from HWRPB is bad (0x%lx)\n", hwrpb
->max_asn
);
682 * Identify the flock of penguins.
691 static char sys_unknown
[] = "Unknown";
692 static char systype_names
[][16] = {
694 "ADU", "Cobra", "Ruby", "Flamingo", "Mannequin", "Jensen",
695 "Pelican", "Morgan", "Sable", "Medulla", "Noname",
696 "Turbolaser", "Avanti", "Mustang", "Alcor", "Tradewind",
697 "Mikasa", "EB64", "EB66", "EB64+", "AlphaBook1",
698 "Rawhide", "K2", "Lynx", "XL", "EB164", "Noritake",
699 "Cortex", "29", "Miata", "XXM", "Takara", "Yukon",
700 "Tsunami", "Wildfire", "CUSCO", "Eiger", "Titan", "Marvel"
703 static char unofficial_names
[][8] = {"100", "Ruffian"};
705 static char api_names
[][16] = {"200", "Nautilus"};
707 static char eb164_names
[][8] = {"EB164", "PC164", "LX164", "SX164", "RX164"};
708 static int eb164_indices
[] = {0,0,0,1,1,1,1,1,2,2,2,2,3,3,3,3,4};
710 static char alcor_names
[][16] = {"Alcor", "Maverick", "Bret"};
711 static int alcor_indices
[] = {0,0,0,1,1,1,0,0,0,0,0,0,2,2,2,2,2,2};
713 static char eb64p_names
[][16] = {"EB64+", "Cabriolet", "AlphaPCI64"};
714 static int eb64p_indices
[] = {0,0,1,2};
716 static char eb66_names
[][8] = {"EB66", "EB66+"};
717 static int eb66_indices
[] = {0,0,1};
719 static char marvel_names
[][16] = {
722 static int marvel_indices
[] = { 0 };
724 static char rawhide_names
[][16] = {
725 "Dodge", "Wrangler", "Durango", "Tincup", "DaVinci"
727 static int rawhide_indices
[] = {0,0,0,1,1,2,2,3,3,4,4};
729 static char titan_names
[][16] = {
730 "DEFAULT", "Privateer", "Falcon", "Granite"
732 static int titan_indices
[] = {0,1,2,2,3};
734 static char tsunami_names
[][16] = {
735 "0", "DP264", "Warhol", "Windjammer", "Monet", "Clipper",
736 "Goldrush", "Webbrick", "Catamaran", "Brisbane", "Melbourne",
737 "Flying Clipper", "Shark"
739 static int tsunami_indices
[] = {0,1,2,3,4,5,6,7,8,9,10,11,12};
741 static struct alpha_machine_vector
* __init
742 get_sysvec(unsigned long type
, unsigned long variation
, unsigned long cpu
)
744 static struct alpha_machine_vector
*systype_vecs
[] __initdata
=
751 NULL
, /* Mannequin */
755 NULL
, /* Sable -- see below. */
758 NULL
, /* Turbolaser */
761 NULL
, /* Alcor, Bret, Maverick. HWRPB inaccurate? */
762 NULL
, /* Tradewind */
763 NULL
, /* Mikasa -- see below. */
765 NULL
, /* EB66 -- see variation. */
766 NULL
, /* EB64+ -- see variation. */
772 NULL
, /* EB164 -- see variation. */
773 NULL
, /* Noritake -- see below. */
780 NULL
, /* Tsunami -- see variation. */
781 &wildfire_mv
, /* Wildfire */
783 &eiger_mv
, /* Eiger */
788 static struct alpha_machine_vector
*unofficial_vecs
[] __initdata
=
794 static struct alpha_machine_vector
*api_vecs
[] __initdata
=
800 static struct alpha_machine_vector
*alcor_vecs
[] __initdata
=
802 &alcor_mv
, &xlt_mv
, &xlt_mv
805 static struct alpha_machine_vector
*eb164_vecs
[] __initdata
=
807 &eb164_mv
, &pc164_mv
, &lx164_mv
, &sx164_mv
, &rx164_mv
810 static struct alpha_machine_vector
*eb64p_vecs
[] __initdata
=
814 &cabriolet_mv
/* AlphaPCI64 */
817 static struct alpha_machine_vector
*eb66_vecs
[] __initdata
=
823 static struct alpha_machine_vector
*marvel_vecs
[] __initdata
=
828 static struct alpha_machine_vector
*titan_vecs
[] __initdata
=
830 &titan_mv
, /* default */
831 &privateer_mv
, /* privateer */
832 &titan_mv
, /* falcon */
833 &privateer_mv
, /* granite */
836 static struct alpha_machine_vector
*tsunami_vecs
[] __initdata
=
839 &dp264_mv
, /* dp264 */
840 &dp264_mv
, /* warhol */
841 &dp264_mv
, /* windjammer */
842 &monet_mv
, /* monet */
843 &clipper_mv
, /* clipper */
844 &dp264_mv
, /* goldrush */
845 &webbrick_mv
, /* webbrick */
846 &dp264_mv
, /* catamaran */
847 NULL
, /* brisbane? */
848 NULL
, /* melbourne? */
849 NULL
, /* flying clipper? */
850 &shark_mv
, /* shark */
853 /* ??? Do we need to distinguish between Rawhides? */
855 struct alpha_machine_vector
*vec
;
857 /* Search the system tables first... */
859 if (type
< ARRAY_SIZE(systype_vecs
)) {
860 vec
= systype_vecs
[type
];
861 } else if ((type
> ST_API_BIAS
) &&
862 (type
- ST_API_BIAS
) < ARRAY_SIZE(api_vecs
)) {
863 vec
= api_vecs
[type
- ST_API_BIAS
];
864 } else if ((type
> ST_UNOFFICIAL_BIAS
) &&
865 (type
- ST_UNOFFICIAL_BIAS
) < ARRAY_SIZE(unofficial_vecs
)) {
866 vec
= unofficial_vecs
[type
- ST_UNOFFICIAL_BIAS
];
869 /* If we've not found one, try for a variation. */
872 /* Member ID is a bit-field. */
873 unsigned long member
= (variation
>> 10) & 0x3f;
875 cpu
&= 0xffffffff; /* make it usable */
879 if (member
< ARRAY_SIZE(alcor_indices
))
880 vec
= alcor_vecs
[alcor_indices
[member
]];
883 if (member
< ARRAY_SIZE(eb164_indices
))
884 vec
= eb164_vecs
[eb164_indices
[member
]];
885 /* PC164 may show as EB164 variation with EV56 CPU,
886 but, since no true EB164 had anything but EV5... */
887 if (vec
== &eb164_mv
&& cpu
== EV56_CPU
)
891 if (member
< ARRAY_SIZE(eb64p_indices
))
892 vec
= eb64p_vecs
[eb64p_indices
[member
]];
895 if (member
< ARRAY_SIZE(eb66_indices
))
896 vec
= eb66_vecs
[eb66_indices
[member
]];
899 if (member
< ARRAY_SIZE(marvel_indices
))
900 vec
= marvel_vecs
[marvel_indices
[member
]];
903 vec
= titan_vecs
[0]; /* default */
904 if (member
< ARRAY_SIZE(titan_indices
))
905 vec
= titan_vecs
[titan_indices
[member
]];
908 if (member
< ARRAY_SIZE(tsunami_indices
))
909 vec
= tsunami_vecs
[tsunami_indices
[member
]];
912 if (cpu
== EV5_CPU
|| cpu
== EV56_CPU
)
913 vec
= &mikasa_primo_mv
;
917 case ST_DEC_NORITAKE
:
918 if (cpu
== EV5_CPU
|| cpu
== EV56_CPU
)
919 vec
= &noritake_primo_mv
;
923 case ST_DEC_2100_A500
:
924 if (cpu
== EV5_CPU
|| cpu
== EV56_CPU
)
925 vec
= &sable_gamma_mv
;
934 static struct alpha_machine_vector
* __init
935 get_sysvec_byname(const char *name
)
937 static struct alpha_machine_vector
*all_vecs
[] __initdata
=
980 for (i
= 0; i
< ARRAY_SIZE(all_vecs
); ++i
) {
981 struct alpha_machine_vector
*mv
= all_vecs
[i
];
982 if (strcasecmp(mv
->vector_name
, name
) == 0)
989 get_sysnames(unsigned long type
, unsigned long variation
, unsigned long cpu
,
990 char **type_name
, char **variation_name
)
992 unsigned long member
;
994 /* If not in the tables, make it UNKNOWN,
995 else set type name to family */
996 if (type
< ARRAY_SIZE(systype_names
)) {
997 *type_name
= systype_names
[type
];
998 } else if ((type
> ST_API_BIAS
) &&
999 (type
- ST_API_BIAS
) < ARRAY_SIZE(api_names
)) {
1000 *type_name
= api_names
[type
- ST_API_BIAS
];
1001 } else if ((type
> ST_UNOFFICIAL_BIAS
) &&
1002 (type
- ST_UNOFFICIAL_BIAS
) < ARRAY_SIZE(unofficial_names
)) {
1003 *type_name
= unofficial_names
[type
- ST_UNOFFICIAL_BIAS
];
1005 *type_name
= sys_unknown
;
1006 *variation_name
= sys_unknown
;
1010 /* Set variation to "0"; if variation is zero, done. */
1011 *variation_name
= systype_names
[0];
1012 if (variation
== 0) {
1016 member
= (variation
>> 10) & 0x3f; /* member ID is a bit-field */
1018 cpu
&= 0xffffffff; /* make it usable */
1020 switch (type
) { /* select by family */
1021 default: /* default to variation "0" for now */
1024 if (member
>= ARRAY_SIZE(eb164_indices
))
1026 *variation_name
= eb164_names
[eb164_indices
[member
]];
1027 /* PC164 may show as EB164 variation, but with EV56 CPU,
1028 so, since no true EB164 had anything but EV5... */
1029 if (eb164_indices
[member
] == 0 && cpu
== EV56_CPU
)
1030 *variation_name
= eb164_names
[1]; /* make it PC164 */
1033 if (member
< ARRAY_SIZE(alcor_indices
))
1034 *variation_name
= alcor_names
[alcor_indices
[member
]];
1037 if (member
< ARRAY_SIZE(eb64p_indices
))
1038 *variation_name
= eb64p_names
[eb64p_indices
[member
]];
1041 if (member
< ARRAY_SIZE(eb66_indices
))
1042 *variation_name
= eb66_names
[eb66_indices
[member
]];
1045 if (member
< ARRAY_SIZE(marvel_indices
))
1046 *variation_name
= marvel_names
[marvel_indices
[member
]];
1048 case ST_DEC_RAWHIDE
:
1049 if (member
< ARRAY_SIZE(rawhide_indices
))
1050 *variation_name
= rawhide_names
[rawhide_indices
[member
]];
1053 *variation_name
= titan_names
[0]; /* default */
1054 if (member
< ARRAY_SIZE(titan_indices
))
1055 *variation_name
= titan_names
[titan_indices
[member
]];
1057 case ST_DEC_TSUNAMI
:
1058 if (member
< ARRAY_SIZE(tsunami_indices
))
1059 *variation_name
= tsunami_names
[tsunami_indices
[member
]];
1065 * A change was made to the HWRPB via an ECO and the following code
1066 * tracks a part of the ECO. In HWRPB versions less than 5, the ECO
1067 * was not implemented in the console firmware. If it's revision 5 or
1068 * greater we can get the name of the platform as an ASCII string from
1069 * the HWRPB. That's what this function does. It checks the revision
1070 * level and if the string is in the HWRPB it returns the address of
1071 * the string--a pointer to the name of the platform.
1074 * - Pointer to a ASCII string if it's in the HWRPB
1075 * - Pointer to a blank string if the data is not in the HWRPB.
1079 platform_string(void)
1081 struct dsr_struct
*dsr
;
1082 static char unk_system_string
[] = "N/A";
1084 /* Go to the console for the string pointer.
1085 * If the rpb_vers is not 5 or greater the rpb
1086 * is old and does not have this data in it.
1088 if (hwrpb
->revision
< 5)
1089 return (unk_system_string
);
1091 /* The Dynamic System Recognition struct
1092 * has the system platform name starting
1093 * after the character count of the string.
1095 dsr
= ((struct dsr_struct
*)
1096 ((char *)hwrpb
+ hwrpb
->dsr_offset
));
1097 return ((char *)dsr
+ (dsr
->sysname_off
+
1103 get_nr_processors(struct percpu_struct
*cpubase
, unsigned long num
)
1105 struct percpu_struct
*cpu
;
1109 for (i
= 0; i
< num
; i
++) {
1110 cpu
= (struct percpu_struct
*)
1111 ((char *)cpubase
+ i
*hwrpb
->processor_size
);
1112 if ((cpu
->flags
& 0x1cc) == 0x1cc)
1119 show_cache_size (struct seq_file
*f
, const char *which
, int shape
)
1122 seq_printf (f
, "%s\t\t: n/a\n", which
);
1123 else if (shape
== 0)
1124 seq_printf (f
, "%s\t\t: unknown\n", which
);
1126 seq_printf (f
, "%s\t\t: %dK, %d-way, %db line\n",
1127 which
, shape
>> 10, shape
& 15,
1128 1 << ((shape
>> 4) & 15));
1132 show_cpuinfo(struct seq_file
*f
, void *slot
)
1134 extern struct unaligned_stat
{
1135 unsigned long count
, va
, pc
;
1138 static char cpu_names
[][8] = {
1139 "EV3", "EV4", "Simulate", "LCA4", "EV5", "EV45", "EV56",
1140 "EV6", "PCA56", "PCA57", "EV67", "EV68CB", "EV68AL",
1141 "EV68CX", "EV7", "EV79", "EV69"
1144 struct percpu_struct
*cpu
= slot
;
1145 unsigned int cpu_index
;
1148 char *sysvariation_name
;
1150 unsigned long timer_freq
;
1152 cpu_index
= (unsigned) (cpu
->type
- 1);
1153 cpu_name
= "Unknown";
1154 if (cpu_index
< ARRAY_SIZE(cpu_names
))
1155 cpu_name
= cpu_names
[cpu_index
];
1157 get_sysnames(hwrpb
->sys_type
, hwrpb
->sys_variation
,
1158 cpu
->type
, &systype_name
, &sysvariation_name
);
1160 nr_processors
= get_nr_processors(cpu
, hwrpb
->nr_processors
);
1162 #if CONFIG_HZ == 1024 || CONFIG_HZ == 1200
1163 timer_freq
= (100UL * hwrpb
->intr_freq
) / 4096;
1165 timer_freq
= 100UL * CONFIG_HZ
;
1168 seq_printf(f
, "cpu\t\t\t: Alpha\n"
1169 "cpu model\t\t: %s\n"
1170 "cpu variation\t\t: %ld\n"
1171 "cpu revision\t\t: %ld\n"
1172 "cpu serial number\t: %s\n"
1173 "system type\t\t: %s\n"
1174 "system variation\t: %s\n"
1175 "system revision\t\t: %ld\n"
1176 "system serial number\t: %s\n"
1177 "cycle frequency [Hz]\t: %lu %s\n"
1178 "timer frequency [Hz]\t: %lu.%02lu\n"
1179 "page size [bytes]\t: %ld\n"
1180 "phys. address bits\t: %ld\n"
1181 "max. addr. space #\t: %ld\n"
1182 "BogoMIPS\t\t: %lu.%02lu\n"
1183 "kernel unaligned acc\t: %ld (pc=%lx,va=%lx)\n"
1184 "user unaligned acc\t: %ld (pc=%lx,va=%lx)\n"
1185 "platform string\t\t: %s\n"
1186 "cpus detected\t\t: %d\n",
1187 cpu_name
, cpu
->variation
, cpu
->revision
,
1188 (char*)cpu
->serial_no
,
1189 systype_name
, sysvariation_name
, hwrpb
->sys_revision
,
1191 est_cycle_freq
? : hwrpb
->cycle_freq
,
1192 est_cycle_freq
? "est." : "",
1193 timer_freq
/ 100, timer_freq
% 100,
1197 loops_per_jiffy
/ (500000/HZ
),
1198 (loops_per_jiffy
/ (5000/HZ
)) % 100,
1199 unaligned
[0].count
, unaligned
[0].pc
, unaligned
[0].va
,
1200 unaligned
[1].count
, unaligned
[1].pc
, unaligned
[1].va
,
1201 platform_string(), nr_processors
);
1204 seq_printf(f
, "cpus active\t\t: %u\n"
1205 "cpu active mask\t\t: %016lx\n",
1206 num_online_cpus(), cpumask_bits(cpu_possible_mask
)[0]);
1209 show_cache_size (f
, "L1 Icache", alpha_l1i_cacheshape
);
1210 show_cache_size (f
, "L1 Dcache", alpha_l1d_cacheshape
);
1211 show_cache_size (f
, "L2 cache", alpha_l2_cacheshape
);
1212 show_cache_size (f
, "L3 cache", alpha_l3_cacheshape
);
1218 read_mem_block(int *addr
, int stride
, int size
)
1220 long nloads
= size
/ stride
, cnt
, tmp
;
1222 __asm__
__volatile__(
1226 /* Next two XORs introduce an explicit data dependency between
1227 consecutive loads in the loop, which will give us true load
1235 : "=&r" (cnt
), "=&r" (nloads
), "=&r" (addr
), "=&r" (tmp
)
1236 : "r" (stride
), "1" (nloads
), "2" (addr
));
1238 return cnt
/ (size
/ stride
);
1241 #define CSHAPE(totalsize, linesize, assoc) \
1242 ((totalsize & ~0xff) | (linesize << 4) | assoc)
1244 /* ??? EV5 supports up to 64M, but did the systems with more than
1245 16M of BCACHE ever exist? */
1246 #define MAX_BCACHE_SIZE 16*1024*1024
1248 /* Note that the offchip caches are direct mapped on all Alphas. */
1250 external_cache_probe(int minsize
, int width
)
1252 int cycles
, prev_cycles
= 1000000;
1253 int stride
= 1 << width
;
1254 long size
= minsize
, maxsize
= MAX_BCACHE_SIZE
* 2;
1256 if (maxsize
> (max_low_pfn
+ 1) << PAGE_SHIFT
)
1257 maxsize
= 1 << (ilog2(max_low_pfn
+ 1) + PAGE_SHIFT
);
1259 /* Get the first block cached. */
1260 read_mem_block(__va(0), stride
, size
);
1262 while (size
< maxsize
) {
1263 /* Get an average load latency in cycles. */
1264 cycles
= read_mem_block(__va(0), stride
, size
);
1265 if (cycles
> prev_cycles
* 2) {
1266 /* Fine, we exceed the cache. */
1267 printk("%ldK Bcache detected; load hit latency %d "
1268 "cycles, load miss latency %d cycles\n",
1269 size
>> 11, prev_cycles
, cycles
);
1270 return CSHAPE(size
>> 1, width
, 1);
1272 /* Try to get the next block cached. */
1273 read_mem_block(__va(size
), stride
, size
);
1274 prev_cycles
= cycles
;
1277 return -1; /* No BCACHE found. */
1281 determine_cpu_caches (unsigned int cpu_type
)
1283 int L1I
, L1D
, L2
, L3
;
1289 if (cpu_type
== EV4_CPU
)
1290 L1I
= CSHAPE(8*1024, 5, 1);
1292 L1I
= CSHAPE(16*1024, 5, 1);
1296 /* BIU_CTL is a write-only Abox register. PALcode has a
1297 shadow copy, and may be available from some versions
1298 of the CSERVE PALcall. If we can get it, then
1300 unsigned long biu_ctl, size;
1301 size = 128*1024 * (1 << ((biu_ctl >> 28) & 7));
1302 L2 = CSHAPE (size, 5, 1);
1304 Unfortunately, we can't rely on that.
1306 L2
= external_cache_probe(128*1024, 5);
1312 unsigned long car
, size
;
1314 L1I
= L1D
= CSHAPE(8*1024, 5, 1);
1317 car
= *(vuip
) phys_to_virt (0x120000078UL
);
1318 size
= 64*1024 * (1 << ((car
>> 5) & 7));
1319 /* No typo -- 8 byte cacheline size. Whodathunk. */
1320 L2
= (car
& 1 ? CSHAPE (size
, 3, 1) : -1);
1327 unsigned long sc_ctl
, width
;
1329 L1I
= L1D
= CSHAPE(8*1024, 5, 1);
1331 /* Check the line size of the Scache. */
1332 sc_ctl
= *(vulp
) phys_to_virt (0xfffff000a8UL
);
1333 width
= sc_ctl
& 0x1000 ? 6 : 5;
1334 L2
= CSHAPE (96*1024, width
, 3);
1336 /* BC_CONTROL and BC_CONFIG are write-only IPRs. PALcode
1337 has a shadow copy, and may be available from some versions
1338 of the CSERVE PALcall. If we can get it, then
1340 unsigned long bc_control, bc_config, size;
1341 size = 1024*1024 * (1 << ((bc_config & 7) - 1));
1342 L3 = (bc_control & 1 ? CSHAPE (size, width, 1) : -1);
1344 Unfortunately, we can't rely on that.
1346 L3
= external_cache_probe(1024*1024, width
);
1353 if (cpu_type
== PCA56_CPU
) {
1354 L1I
= CSHAPE(16*1024, 6, 1);
1355 L1D
= CSHAPE(8*1024, 5, 1);
1357 L1I
= CSHAPE(32*1024, 6, 2);
1358 L1D
= CSHAPE(16*1024, 5, 1);
1363 unsigned long cbox_config
, size
;
1365 cbox_config
= *(vulp
) phys_to_virt (0xfffff00008UL
);
1366 size
= 512*1024 * (1 << ((cbox_config
>> 12) & 3));
1368 L2
= ((cbox_config
>> 31) & 1 ? CSHAPE (size
, 6, 1) : -1);
1370 L2
= external_cache_probe(512*1024, 6);
1381 L1I
= L1D
= CSHAPE(64*1024, 6, 2);
1382 L2
= external_cache_probe(1024*1024, 6);
1388 L1I
= L1D
= CSHAPE(64*1024, 6, 2);
1389 L2
= CSHAPE(7*1024*1024/4, 6, 7);
1394 /* Nothing known about this cpu type. */
1395 L1I
= L1D
= L2
= L3
= 0;
1399 alpha_l1i_cacheshape
= L1I
;
1400 alpha_l1d_cacheshape
= L1D
;
1401 alpha_l2_cacheshape
= L2
;
1402 alpha_l3_cacheshape
= L3
;
1406 * We show only CPU #0 info.
1409 c_start(struct seq_file
*f
, loff_t
*pos
)
1411 return *pos
? NULL
: (char *)hwrpb
+ hwrpb
->processor_offset
;
1415 c_next(struct seq_file
*f
, void *v
, loff_t
*pos
)
1421 c_stop(struct seq_file
*f
, void *v
)
1425 const struct seq_operations cpuinfo_op
= {
1429 .show
= show_cpuinfo
,
1434 alpha_panic_event(struct notifier_block
*this, unsigned long event
, void *ptr
)
1437 /* FIXME FIXME FIXME */
1438 /* If we are using SRM and serial console, just hard halt here. */
1439 if (alpha_using_srm
&& srmcons_output
)
1445 static __init
int add_pcspkr(void)
1447 struct platform_device
*pd
;
1450 pd
= platform_device_alloc("pcspkr", -1);
1454 ret
= platform_device_add(pd
);
1456 platform_device_put(pd
);
1460 device_initcall(add_pcspkr
);