10 #include <linux/export.h>
11 #include <linux/kernel.h>
12 #include <linux/stddef.h>
15 #include <linux/utsname.h>
20 #include <linux/screen_info.h>
22 #include <linux/kexec.h>
30 #include <linux/compiler.h>
36 #include <asm/cputype.h>
38 #include <asm/procinfo.h>
39 #include <asm/sections.h>
40 #include <asm/setup.h>
43 #include <asm/cacheflush.h>
44 #include <asm/cachetype.h>
45 #include <asm/tlbflush.h>
52 #include <asm/system_misc.h>
53 #include <asm/traps.h>
54 #include <asm/unwind.h>
55 #include <asm/memblock.h>
62 #if defined(CONFIG_FPE_NWFPE) || defined(CONFIG_FPE_FASTFPE)
113 #ifdef CONFIG_OUTER_CACHE
136 static const char *cpu_name;
137 static const char *machine_name;
141 static union {
char c[4];
unsigned long l; } endian_test
__initdata = { {
'l',
'?',
'?',
'b' } };
142 #define ENDIANNESS ((char)endian_test.l)
149 static struct resource mem_res[] = {
157 .name =
"Kernel code",
163 .name =
"Kernel data",
170 #define video_ram mem_res[0]
171 #define kernel_code mem_res[1]
172 #define kernel_data mem_res[2]
195 #define lp0 io_res[0]
196 #define lp1 io_res[1]
197 #define lp2 io_res[2]
199 static const char *proc_arch[] = {
219 static int __get_cpu_architecture(
void)
223 if ((read_cpuid_id() & 0x0008f000) == 0) {
225 }
else if ((read_cpuid_id() & 0x0008f000) == 0x00007000) {
227 }
else if ((read_cpuid_id() & 0x00080000) == 0x00000000) {
228 cpu_arch = (read_cpuid_id() >> 16) & 7;
231 }
else if ((read_cpuid_id() & 0x000f0000) == 0x000f0000) {
236 asm(
"mrc p15, 0, %0, c0, c1, 4"
238 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
239 (mmfr0 & 0x000000f0) >= 0x00000030)
241 else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
242 (mmfr0 & 0x000000f0) == 0x00000020)
256 return __cpu_architecture;
259 static int cpu_has_aliasing_icache(
unsigned int arch)
262 unsigned int id_reg, num_sets, line_size;
271 asm(
"mcr p15, 2, %0, c0, c0, 0 @ set CSSELR"
275 asm(
"mrc p15, 1, %0, c0, c0, 0 @ read CCSIDR"
277 line_size = 4 << ((id_reg & 0x7) + 2);
278 num_sets = ((id_reg >> 13) & 0x7fff) + 1;
279 aliasing_icache = (line_size * num_sets) >
PAGE_SIZE;
282 aliasing_icache = read_cpuid_cachetype() & (1 << 11);
289 return aliasing_icache;
292 static void __init cacheid_init(
void)
294 unsigned int cachetype = read_cpuid_cachetype();
298 if ((cachetype & (7 << 29)) == 4 << 29) {
302 switch (cachetype & (3 << 14)) {
312 if (cachetype & (1 << 23))
317 if (cpu_has_aliasing_icache(arch))
323 printk(
"CPU: %s data cache, %s instruction cache\n",
342 extern void printascii(
const char *);
350 #ifdef CONFIG_DEBUG_LL
356 static void __init feat_v6_fixup(
void)
358 int id = read_cpuid_id();
360 if ((
id & 0xff0f0000) != 0x41070000)
367 if ((((
id >> 4) & 0xfff) == 0xb36) && (((
id >> 20) & 3) == 0))
392 #ifdef CONFIG_THUMB2_KERNEL
403 "add r14, %0, %2\n\t"
406 "add r14, %0, %4\n\t"
409 "add r14, %0, %6\n\t"
429 u32 cpu = is_smp() ? read_cpuid_mpidr() & 0xff : 0;
438 static void __init setup_processor(
void)
440 struct proc_info_list *
list;
449 printk(
"CPU configuration botched (ID %08x), unable "
450 "to continue.\n", read_cpuid_id());
454 cpu_name = list->cpu_name;
455 __cpu_architecture = __get_cpu_architecture();
464 cpu_user = *list->user;
467 cpu_cache = *list->cache;
470 printk(
"CPU: %s [%08x] revision %d (ARMv%s), cr=%08lx\n",
471 cpu_name, read_cpuid_id(), read_cpuid_id() & 15,
479 #ifndef CONFIG_ARM_THUMB
493 early_print(
"Available machine support:\n\nID (hex)\tNAME\n");
497 early_print(
"\nPlease check your kernel config and/or bootloader.\n");
509 "ignoring memory at 0x%08llx\n", (
long long)start);
521 if (bank->
start + size < bank->start) {
523 "32-bit physical address space\n", (
long long)start);
550 static int __init early_mem(
char *
p)
580 struct memblock_region *
region;
588 for_each_memblock(
memory, region) {
590 res->
name =
"System RAM";
623 #if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_DUMMY_CONSOLE)
626 .orig_video_cols = 80,
627 .orig_video_mode = 0,
628 .orig_video_ega_bx = 0,
629 .orig_video_isVGA = 1,
630 .orig_video_points = 8
634 static int __init customize_machine(
void)
643 static int __init init_machine_late(
void)
652 static inline unsigned long long get_total_mem(
void)
667 static void __init reserve_crashkernel(
void)
669 unsigned long long crash_size, crash_base;
670 unsigned long long total_mem;
673 total_mem = get_total_mem();
675 &crash_size, &crash_base);
682 "memory is in use (0x%lx)\n", (
unsigned long)crash_base);
687 "for crashkernel (System RAM: %ldMB)\n",
688 (
unsigned long)(crash_size >> 20),
689 (
unsigned long)(crash_base >> 20),
690 (
unsigned long)(total_mem >> 20));
697 static inline void reserve_crashkernel(
void) {}
700 static int __init meminfo_cmp(
const void *_a,
const void *_b)
704 return cmp < 0 ? -1 : cmp > 0 ? 1 : 0;
709 #ifdef CONFIG_ARM_VIRT_EXT
710 if (is_hyp_mode_available()) {
711 pr_info(
"CPU: All CPU(s) started in HYP mode.\n");
712 pr_info(
"CPU: Virtualization extensions available.\n");
713 }
else if (is_hyp_mode_mismatched()) {
714 pr_warn(
"CPU: WARNING: CPU(s) started in wrong/inconsistent modes (primary CPU mode 0x%x)\n",
716 pr_warn(
"CPU: This may indicate a broken bootloader or firmware.\n");
718 pr_info(
"CPU: All CPU(s) started in SVC mode.\n");
731 machine_name = mdesc->
name;
745 *cmdline_p = cmd_line;
754 request_standard_resources(mdesc);
759 unflatten_device_tree();
771 reserve_crashkernel();
775 #ifdef CONFIG_MULTI_IRQ_HANDLER
780 #if defined(CONFIG_VGA_CONSOLE)
782 #elif defined(CONFIG_DUMMY_CONSOLE)
792 static int __init topology_init(
void)
798 cpuinfo->
cpu.hotpluggable = 1;
806 #ifdef CONFIG_HAVE_PROC_CPU
807 static int __init proc_cpu_init(
void)
819 static const char *hwcap_str[] = {
842 static int c_show(
struct seq_file *
m,
void *
v)
846 seq_printf(m,
"Processor\t: %s rev %d (%s)\n",
849 #if defined(CONFIG_SMP)
870 for (i = 0; hwcap_str[
i]; i++)
874 seq_printf(m,
"\nCPU implementer\t: 0x%02x\n", read_cpuid_id() >> 24);
877 if ((read_cpuid_id() & 0x0008f000) == 0x00000000) {
879 seq_printf(m,
"CPU part\t: %07x\n", read_cpuid_id() >> 4);
881 if ((read_cpuid_id() & 0x0008f000) == 0x00007000) {
884 (read_cpuid_id() >> 16) & 127);
888 (read_cpuid_id() >> 20) & 15);
891 (read_cpuid_id() >> 4) & 0xfff);
893 seq_printf(m,
"CPU revision\t: %d\n", read_cpuid_id() & 15);
897 seq_printf(m,
"Hardware\t: %s\n", machine_name);
907 return *pos < 1 ? (
void *)1 :
NULL;
910 static void *c_next(
struct seq_file *m,
void *v, loff_t *
pos)
916 static void c_stop(
struct seq_file *m,
void *v)