diff options
Diffstat (limited to 'arch/arc/kernel/setup.c')
-rw-r--r-- | arch/arc/kernel/setup.c | 166 |
1 files changed, 166 insertions, 0 deletions
diff --git a/arch/arc/kernel/setup.c b/arch/arc/kernel/setup.c new file mode 100644 index 000000000000..82ac20603398 --- /dev/null +++ b/arch/arc/kernel/setup.c | |||
@@ -0,0 +1,166 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) | ||
3 | * | ||
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. | ||
7 | */ | ||
8 | |||
9 | #include <linux/seq_file.h> | ||
10 | #include <linux/fs.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 <asm/arcregs.h> | ||
17 | #include <asm/tlb.h> | ||
18 | #include <asm/cache.h> | ||
19 | #include <asm/setup.h> | ||
20 | #include <asm/page.h> | ||
21 | #include <asm/irq.h> | ||
22 | #include <asm/arcregs.h> | ||
23 | |||
24 | #define FIX_PTR(x) __asm__ __volatile__(";" : "+r"(x)) | ||
25 | |||
26 | int running_on_hw = 1; /* vs. on ISS */ | ||
27 | |||
28 | char __initdata command_line[COMMAND_LINE_SIZE]; | ||
29 | |||
30 | struct task_struct *_current_task[NR_CPUS]; /* For stack switching */ | ||
31 | |||
32 | struct cpuinfo_arc cpuinfo_arc700[NR_CPUS]; | ||
33 | |||
34 | void __init read_arc_build_cfg_regs(void) | ||
35 | { | ||
36 | read_decode_mmu_bcr(); | ||
37 | read_decode_cache_bcr(); | ||
38 | } | ||
39 | |||
40 | /* | ||
41 | * Initialize and setup the processor core | ||
42 | * This is called by all the CPUs thus should not do special case stuff | ||
43 | * such as only for boot CPU etc | ||
44 | */ | ||
45 | |||
46 | void __init setup_processor(void) | ||
47 | { | ||
48 | read_arc_build_cfg_regs(); | ||
49 | arc_init_IRQ(); | ||
50 | arc_mmu_init(); | ||
51 | arc_cache_init(); | ||
52 | } | ||
53 | |||
54 | void __init __attribute__((weak)) arc_platform_early_init(void) | ||
55 | { | ||
56 | } | ||
57 | |||
58 | void __init setup_arch(char **cmdline_p) | ||
59 | { | ||
60 | #ifdef CONFIG_CMDLINE_UBOOT | ||
61 | /* Make sure that a whitespace is inserted before */ | ||
62 | strlcat(command_line, " ", sizeof(command_line)); | ||
63 | #endif | ||
64 | /* | ||
65 | * Append .config cmdline to base command line, which might already | ||
66 | * contain u-boot "bootargs" (handled by head.S, if so configured) | ||
67 | */ | ||
68 | strlcat(command_line, CONFIG_CMDLINE, sizeof(command_line)); | ||
69 | |||
70 | /* Save unparsed command line copy for /proc/cmdline */ | ||
71 | strlcpy(boot_command_line, command_line, COMMAND_LINE_SIZE); | ||
72 | *cmdline_p = command_line; | ||
73 | |||
74 | /* To force early parsing of things like mem=xxx */ | ||
75 | parse_early_param(); | ||
76 | |||
77 | /* Platform/board specific: e.g. early console registration */ | ||
78 | arc_platform_early_init(); | ||
79 | |||
80 | setup_processor(); | ||
81 | |||
82 | setup_arch_memory(); | ||
83 | |||
84 | /* Can be issue if someone passes cmd line arg "ro" | ||
85 | * But that is unlikely so keeping it as it is | ||
86 | */ | ||
87 | root_mountflags &= ~MS_RDONLY; | ||
88 | |||
89 | console_verbose(); | ||
90 | |||
91 | #if defined(CONFIG_VT) && defined(CONFIG_DUMMY_CONSOLE) | ||
92 | conswitchp = &dummy_con; | ||
93 | #endif | ||
94 | |||
95 | } | ||
96 | |||
97 | /* | ||
98 | * Get CPU information for use by the procfs. | ||
99 | */ | ||
100 | |||
101 | #define cpu_to_ptr(c) ((void *)(0xFFFF0000 | (unsigned int)(c))) | ||
102 | #define ptr_to_cpu(p) (~0xFFFF0000UL & (unsigned int)(p)) | ||
103 | |||
104 | static int show_cpuinfo(struct seq_file *m, void *v) | ||
105 | { | ||
106 | char *str; | ||
107 | int cpu_id = ptr_to_cpu(v); | ||
108 | |||
109 | str = (char *)__get_free_page(GFP_TEMPORARY); | ||
110 | if (!str) | ||
111 | goto done; | ||
112 | |||
113 | seq_printf(m, "ARC700 #%d\n", cpu_id); | ||
114 | |||
115 | seq_printf(m, "Bogo MIPS : \t%lu.%02lu\n", | ||
116 | loops_per_jiffy / (500000 / HZ), | ||
117 | (loops_per_jiffy / (5000 / HZ)) % 100); | ||
118 | |||
119 | free_page((unsigned long)str); | ||
120 | done: | ||
121 | seq_printf(m, "\n\n"); | ||
122 | |||
123 | return 0; | ||
124 | } | ||
125 | |||
126 | static void *c_start(struct seq_file *m, loff_t *pos) | ||
127 | { | ||
128 | /* | ||
129 | * Callback returns cpu-id to iterator for show routine, NULL to stop. | ||
130 | * However since NULL is also a valid cpu-id (0), we use a round-about | ||
131 | * way to pass it w/o having to kmalloc/free a 2 byte string. | ||
132 | * Encode cpu-id as 0xFFcccc, which is decoded by show routine. | ||
133 | */ | ||
134 | return *pos < num_possible_cpus() ? cpu_to_ptr(*pos) : NULL; | ||
135 | } | ||
136 | |||
137 | static void *c_next(struct seq_file *m, void *v, loff_t *pos) | ||
138 | { | ||
139 | ++*pos; | ||
140 | return c_start(m, pos); | ||
141 | } | ||
142 | |||
143 | static void c_stop(struct seq_file *m, void *v) | ||
144 | { | ||
145 | } | ||
146 | |||
147 | const struct seq_operations cpuinfo_op = { | ||
148 | .start = c_start, | ||
149 | .next = c_next, | ||
150 | .stop = c_stop, | ||
151 | .show = show_cpuinfo | ||
152 | }; | ||
153 | |||
154 | static DEFINE_PER_CPU(struct cpu, cpu_topology); | ||
155 | |||
156 | static int __init topology_init(void) | ||
157 | { | ||
158 | int cpu; | ||
159 | |||
160 | for_each_present_cpu(cpu) | ||
161 | register_cpu(&per_cpu(cpu_topology, cpu), cpu); | ||
162 | |||
163 | return 0; | ||
164 | } | ||
165 | |||
166 | subsys_initcall(topology_init); | ||