1b29290e5e313c230390bf38bc0016e562e1a90d
[openwrt.git] / target / linux / generic-2.6 / patches-2.6.32 / 020-mips_multi_machine_support.patch
1 --- /dev/null
2 +++ b/include/asm-mips/mips_machine.h
3 @@ -0,0 +1,46 @@
4 +/*
5 + * Copyright (C) 2008-2009 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 +struct mips_machine {
20 + unsigned long mach_type;
21 + void (*mach_setup)(void);
22 + char *mach_name;
23 + struct list_head list;
24 +};
25 +
26 +void mips_machine_register(struct mips_machine *) __init;
27 +void mips_machine_setup(unsigned long machtype) __init;
28 +
29 +extern char *mips_machine_name;
30 +
31 +#define MIPS_MACHINE(_type, _name, _setup) \
32 +static char machine_name_##_type[] __initdata = _name; \
33 +static struct mips_machine machine_##_type __initdata = \
34 +{ \
35 + .mach_type = _type, \
36 + .mach_name = machine_name_##_type, \
37 + .mach_setup = _setup, \
38 +}; \
39 + \
40 +static int __init register_machine_##_type(void) \
41 +{ \
42 + mips_machine_register(&machine_##_type); \
43 + return 0; \
44 +} \
45 + \
46 +pure_initcall(register_machine_##_type)
47 +
48 +#endif /* __ASM_MIPS_MACHINE_H */
49 +
50 --- /dev/null
51 +++ b/arch/mips/kernel/mips_machine.c
52 @@ -0,0 +1,70 @@
53 +/*
54 + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
55 + *
56 + * This program is free software; you can redistribute it and/or modify it
57 + * under the terms of the GNU General Public License version 2 as published
58 + * by the Free Software Foundation.
59 + *
60 + */
61 +#include <linux/mm.h>
62 +
63 +#include <asm/mips_machine.h>
64 +#include <asm/bootinfo.h>
65 +
66 +static struct list_head mips_machines __initdata =
67 + LIST_HEAD_INIT(mips_machines);
68 +
69 +char *mips_machine_name = "Unknown";
70 +
71 +static struct mips_machine * __init mips_machine_find(unsigned long machtype)
72 +{
73 + struct list_head *this;
74 +
75 + list_for_each(this, &mips_machines) {
76 + struct mips_machine *mach;
77 +
78 + mach = list_entry(this, struct mips_machine, list);
79 + if (mach->mach_type == machtype)
80 + return mach;
81 + }
82 +
83 + return NULL;
84 +}
85 +
86 +void __init mips_machine_register(struct mips_machine *mach)
87 +{
88 + list_add_tail(&mach->list, &mips_machines);
89 +}
90 +
91 +void __init mips_machine_setup(unsigned long machtype)
92 +{
93 + struct mips_machine *mach;
94 +
95 + mach = mips_machine_find(machtype);
96 + if (!mach) {
97 + printk(KERN_ALERT "MIPS: no machine registered for "
98 + "machtype %lu\n", machtype);
99 + return;
100 + }
101 +
102 + if (mach->mach_name) {
103 + char *name;
104 + unsigned int len;
105 +
106 + len = strlen(mach->mach_name);
107 + name = kmalloc(len + 1, GFP_KERNEL);
108 + if (name) {
109 + strncpy(name, mach->mach_name,len);
110 + name[len] = '\0';
111 + mips_machine_name = name;
112 + } else {
113 + printk(KERN_WARNING "MIPS: no memory for machine_name\n");
114 + }
115 + }
116 +
117 + printk(KERN_INFO "MIPS: machine is %s\n", mips_machine_name);
118 +
119 + if (mach->mach_setup)
120 + mach->mach_setup();
121 +}
122 +
123 --- a/arch/mips/kernel/Makefile
124 +++ b/arch/mips/kernel/Makefile
125 @@ -87,6 +87,7 @@ obj-$(CONFIG_GPIO_TXX9) += gpio_txx9.o
126
127 obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o
128 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
129 +obj-$(CONFIG_MIPS_MACHINE) += mips_machine.o
130
131 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)
132
133 --- a/arch/mips/Kconfig
134 +++ b/arch/mips/Kconfig
135 @@ -839,6 +839,9 @@ config MIPS_DISABLE_OBSOLETE_IDE
136 config SYNC_R4K
137 bool
138
139 +config MIPS_MACHINE
140 + def_bool n
141 +
142 config NO_IOPORT
143 def_bool n
144
145 --- a/arch/mips/kernel/proc.c
146 +++ b/arch/mips/kernel/proc.c
147 @@ -12,6 +12,7 @@
148 #include <asm/cpu-features.h>
149 #include <asm/mipsregs.h>
150 #include <asm/processor.h>
151 +#include <asm/mips_machine.h>
152
153 unsigned int vced_count, vcei_count;
154
155 @@ -31,8 +32,12 @@ static int show_cpuinfo(struct seq_file
156 /*
157 * For the first processor also print the system type
158 */
159 - if (n == 0)
160 + if (n == 0) {
161 seq_printf(m, "system type\t\t: %s\n", get_system_type());
162 +#ifdef CONFIG_MIPS_MACHINE
163 + seq_printf(m, "machine\t\t\t: %s\n", mips_machine_name);
164 +#endif
165 + }
166
167 seq_printf(m, "processor\t\t: %ld\n", n);
168 sprintf(fmt, "cpu model\t\t: %%s V%%d.%%d%s\n",
This page took 0.065306 seconds and 3 git commands to generate.