Root/
Source at commit 7ed5276 created 13 years 8 months ago. By florian, [kernel] refresh 2.6.32 patches | |
---|---|
1 | --- /dev/null |
2 | +++ b/arch/mips/include/asm/mips_machine.h |
3 | @@ -0,0 +1,54 @@ |
4 | +/* |
5 | + * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org> |
6 | + * |
7 | + * This program is free software; you can redistribute it and/or modify it |
8 | + * under the terms of the GNU General Public License version 2 as published |
9 | + * by the Free Software Foundation. |
10 | + * |
11 | + */ |
12 | + |
13 | +#ifndef __ASM_MIPS_MACHINE_H |
14 | +#define __ASM_MIPS_MACHINE_H |
15 | + |
16 | +#include <linux/init.h> |
17 | +#include <linux/list.h> |
18 | + |
19 | +#include <asm/bootinfo.h> |
20 | + |
21 | +struct mips_machine { |
22 | + unsigned long mach_type; |
23 | + const char *mach_id; |
24 | + const char *mach_name; |
25 | + void (*mach_setup)(void); |
26 | +}; |
27 | + |
28 | +#define MIPS_MACHINE(_type, _id, _name, _setup) \ |
29 | +static const char machine_name_##_type[] __initconst \ |
30 | + __aligned(1) = _name; \ |
31 | +static const char machine_id_##_type[] __initconst \ |
32 | + __aligned(1) = _id; \ |
33 | +static struct mips_machine machine_##_type \ |
34 | + __used __section(.mips.machines.init) = \ |
35 | +{ \ |
36 | + .mach_type = _type, \ |
37 | + .mach_id = machine_id_##_type, \ |
38 | + .mach_name = machine_name_##_type, \ |
39 | + .mach_setup = _setup, \ |
40 | +}; |
41 | + |
42 | +extern long __mips_machines_start; |
43 | +extern long __mips_machines_end; |
44 | + |
45 | +#ifdef CONFIG_MIPS_MACHINE |
46 | +int mips_machtype_setup(char *id) __init; |
47 | +void mips_machine_setup(void) __init; |
48 | +void mips_set_machine_name(const char *name) __init; |
49 | +char *mips_get_machine_name(void); |
50 | +#else |
51 | +static inline int mips_machtype_setup(char *id) { return 1; } |
52 | +static inline void mips_machine_setup(void) { } |
53 | +static inline void mips_set_machine_name(const char *name) { } |
54 | +static inline char *mips_get_machine_name(void) { return NULL; } |
55 | +#endif /* CONFIG_MIPS_MACHINE */ |
56 | + |
57 | +#endif /* __ASM_MIPS_MACHINE_H */ |
58 | --- /dev/null |
59 | +++ b/arch/mips/kernel/mips_machine.c |
60 | @@ -0,0 +1,86 @@ |
61 | +/* |
62 | + * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org> |
63 | + * |
64 | + * This program is free software; you can redistribute it and/or modify it |
65 | + * under the terms of the GNU General Public License version 2 as published |
66 | + * by the Free Software Foundation. |
67 | + * |
68 | + */ |
69 | +#include <linux/mm.h> |
70 | +#include <linux/string.h> |
71 | +#include <linux/slab.h> |
72 | + |
73 | +#include <asm/mips_machine.h> |
74 | + |
75 | +static struct mips_machine *mips_machine __initdata; |
76 | +static char *mips_machine_name = "Unknown"; |
77 | + |
78 | +#define for_each_machine(mach) \ |
79 | + for ((mach) = (struct mips_machine *)&__mips_machines_start; \ |
80 | + (mach) && \ |
81 | + (unsigned long)(mach) < (unsigned long)&__mips_machines_end; \ |
82 | + (mach)++) |
83 | + |
84 | +__init void mips_set_machine_name(const char *name) |
85 | +{ |
86 | + char *p; |
87 | + |
88 | + if (name == NULL) |
89 | + return; |
90 | + |
91 | + p = kstrdup(name, GFP_KERNEL); |
92 | + if (!p) |
93 | + pr_err("MIPS: no memory for machine_name\n"); |
94 | + |
95 | + mips_machine_name = p; |
96 | +} |
97 | + |
98 | +char *mips_get_machine_name(void) |
99 | +{ |
100 | + return mips_machine_name; |
101 | +} |
102 | + |
103 | +__init int mips_machtype_setup(char *id) |
104 | +{ |
105 | + struct mips_machine *mach; |
106 | + |
107 | + for_each_machine(mach) { |
108 | + if (mach->mach_id == NULL) |
109 | + continue; |
110 | + |
111 | + if (strcmp(mach->mach_id, id) == 0) { |
112 | + mips_machtype = mach->mach_type; |
113 | + return 0; |
114 | + } |
115 | + } |
116 | + |
117 | + pr_err("MIPS: no machine found for id '%s', supported machines:\n", id); |
118 | + pr_err("%-24s : %s\n", "id", "name"); |
119 | + for_each_machine(mach) |
120 | + pr_err("%-24s : %s\n", mach->mach_id, mach->mach_name); |
121 | + |
122 | + return 1; |
123 | +} |
124 | + |
125 | +__setup("machtype=", mips_machtype_setup); |
126 | + |
127 | +__init void mips_machine_setup(void) |
128 | +{ |
129 | + struct mips_machine *mach; |
130 | + |
131 | + for_each_machine(mach) { |
132 | + if (mips_machtype == mach->mach_type) { |
133 | + mips_machine = mach; |
134 | + break; |
135 | + } |
136 | + } |
137 | + |
138 | + if (!mips_machine) |
139 | + return; |
140 | + |
141 | + mips_set_machine_name(mips_machine->mach_name); |
142 | + pr_info("MIPS: machine is %s\n", mips_machine_name); |
143 | + |
144 | + if (mips_machine->mach_setup) |
145 | + mips_machine->mach_setup(); |
146 | +} |
147 | --- a/arch/mips/kernel/Makefile |
148 | +++ b/arch/mips/kernel/Makefile |
149 | @@ -87,6 +87,7 @@ obj-$(CONFIG_GPIO_TXX9) += gpio_txx9.o |
150 | |
151 | obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o |
152 | obj-$(CONFIG_EARLY_PRINTK) += early_printk.o |
153 | +obj-$(CONFIG_MIPS_MACHINE) += mips_machine.o |
154 | |
155 | CFLAGS_cpu-bugs64.o = $(shell if $(CC) $(KBUILD_CFLAGS) -Wa,-mdaddi -c -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-DHAVE_AS_SET_DADDI"; fi) |
156 | |
157 | --- a/arch/mips/Kconfig |
158 | +++ b/arch/mips/Kconfig |
159 | @@ -854,6 +854,9 @@ config MIPS_DISABLE_OBSOLETE_IDE |
160 | config SYNC_R4K |
161 | bool |
162 | |
163 | +config MIPS_MACHINE |
164 | + def_bool n |
165 | + |
166 | config NO_IOPORT |
167 | def_bool n |
168 | |
169 | --- a/arch/mips/kernel/proc.c |
170 | +++ b/arch/mips/kernel/proc.c |
171 | @@ -12,6 +12,7 @@ |
172 | #include <asm/cpu-features.h> |
173 | #include <asm/mipsregs.h> |
174 | #include <asm/processor.h> |
175 | +#include <asm/mips_machine.h> |
176 | |
177 | unsigned int vced_count, vcei_count; |
178 | |
179 | @@ -31,8 +32,12 @@ static int show_cpuinfo(struct seq_file |
180 | /* |
181 | * For the first processor also print the system type |
182 | */ |
183 | - if (n == 0) |
184 | + if (n == 0) { |
185 | seq_printf(m, "system type\t\t: %s\n", get_system_type()); |
186 | + if (mips_get_machine_name()) |
187 | + seq_printf(m, "machine\t\t\t: %s\n", |
188 | + mips_get_machine_name()); |
189 | + } |
190 | |
191 | seq_printf(m, "processor\t\t: %ld\n", n); |
192 | sprintf(fmt, "cpu model\t\t: %%s V%%d.%%d%s\n", |
193 | --- a/arch/mips/kernel/vmlinux.lds.S |
194 | +++ b/arch/mips/kernel/vmlinux.lds.S |
195 | @@ -97,6 +97,13 @@ SECTIONS |
196 | INIT_TEXT_SECTION(PAGE_SIZE) |
197 | INIT_DATA_SECTION(16) |
198 | |
199 | + . = ALIGN(4); |
200 | + .mips.machines.init : AT(ADDR(.mips.machines.init) - LOAD_OFFSET) { |
201 | + __mips_machines_start = .; |
202 | + *(.mips.machines.init) |
203 | + __mips_machines_end = .; |
204 | + } |
205 | + |
206 | /* .exit.text is discarded at runtime, not link time, to deal with |
207 | * references from .rodata |
208 | */ |
209 |