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