2 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
9 #include <linux/seq_file.h>
11 #include <linux/delay.h>
12 #include <linux/root_dev.h>
13 #include <linux/console.h>
14 #include <linux/module.h>
15 #include <linux/cpu.h>
16 #include <linux/of_fdt.h>
17 #include <asm/sections.h>
18 #include <asm/arcregs.h>
20 #include <asm/cache.h>
21 #include <asm/setup.h>
24 #include <asm/arcregs.h>
26 #include <asm/unwind.h>
28 #define FIX_PTR(x) __asm__ __volatile__(";" : "+r"(x))
30 int running_on_hw = 1; /* vs. on ISS */
32 char __initdata command_line[COMMAND_LINE_SIZE];
34 struct task_struct *_current_task[NR_CPUS]; /* For stack switching */
36 struct cpuinfo_arc cpuinfo_arc700[NR_CPUS];
38 void __init read_arc_build_cfg_regs(void)
40 read_decode_mmu_bcr();
41 read_decode_cache_bcr();
45 * Initialize and setup the processor core
46 * This is called by all the CPUs thus should not do special case stuff
47 * such as only for boot CPU etc
50 void __init setup_processor(void)
52 read_arc_build_cfg_regs();
58 void __init __attribute__((weak)) arc_platform_early_init(void)
62 void __init setup_arch(char **cmdline_p)
66 #ifdef CONFIG_CMDLINE_UBOOT
67 /* Make sure that a whitespace is inserted before */
68 strlcat(command_line, " ", sizeof(command_line));
71 * Append .config cmdline to base command line, which might already
72 * contain u-boot "bootargs" (handled by head.S, if so configured)
74 strlcat(command_line, CONFIG_CMDLINE, sizeof(command_line));
76 /* Save unparsed command line copy for /proc/cmdline */
77 strlcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
78 *cmdline_p = command_line;
80 rc = setup_machine_fdt(__dtb_start);
82 /* To force early parsing of things like mem=xxx */
85 /* Platform/board specific: e.g. early console registration */
86 arc_platform_early_init();
96 unflatten_device_tree();
98 /* Can be issue if someone passes cmd line arg "ro"
99 * But that is unlikely so keeping it as it is
101 root_mountflags &= ~MS_RDONLY;
105 #if defined(CONFIG_VT) && defined(CONFIG_DUMMY_CONSOLE)
106 conswitchp = &dummy_con;
114 * Get CPU information for use by the procfs.
117 #define cpu_to_ptr(c) ((void *)(0xFFFF0000 | (unsigned int)(c)))
118 #define ptr_to_cpu(p) (~0xFFFF0000UL & (unsigned int)(p))
120 static int show_cpuinfo(struct seq_file *m, void *v)
123 int cpu_id = ptr_to_cpu(v);
125 str = (char *)__get_free_page(GFP_TEMPORARY);
129 seq_printf(m, "ARC700 #%d\n", cpu_id);
131 seq_printf(m, "Bogo MIPS : \t%lu.%02lu\n",
132 loops_per_jiffy / (500000 / HZ),
133 (loops_per_jiffy / (5000 / HZ)) % 100);
135 free_page((unsigned long)str);
137 seq_printf(m, "\n\n");
142 static void *c_start(struct seq_file *m, loff_t *pos)
145 * Callback returns cpu-id to iterator for show routine, NULL to stop.
146 * However since NULL is also a valid cpu-id (0), we use a round-about
147 * way to pass it w/o having to kmalloc/free a 2 byte string.
148 * Encode cpu-id as 0xFFcccc, which is decoded by show routine.
150 return *pos < num_possible_cpus() ? cpu_to_ptr(*pos) : NULL;
153 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
156 return c_start(m, pos);
159 static void c_stop(struct seq_file *m, void *v)
163 const struct seq_operations cpuinfo_op = {
170 static DEFINE_PER_CPU(struct cpu, cpu_topology);
172 static int __init topology_init(void)
176 for_each_present_cpu(cpu)
177 register_cpu(&per_cpu(cpu_topology, cpu), cpu);
182 subsys_initcall(topology_init);