2 +++ b/arch/mips/include/asm/mips_machine.h
5 + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
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.
13 +#ifndef __ASM_MIPS_MACHINE_H
14 +#define __ASM_MIPS_MACHINE_H
16 +#include <linux/init.h>
17 +#include <linux/list.h>
19 +struct mips_machine {
20 + unsigned long mach_type;
21 + void (*mach_setup)(void);
23 + struct list_head list;
26 +void mips_machine_register(struct mips_machine *) __init;
27 +void mips_machine_setup(unsigned long machtype) __init;
28 +void mips_machine_set_name(char *name) __init;
30 +extern char *mips_machine_name;
32 +#define MIPS_MACHINE(_type, _name, _setup) \
33 +static char machine_name_##_type[] __initdata = _name; \
34 +static struct mips_machine machine_##_type __initdata = \
36 + .mach_type = _type, \
37 + .mach_name = machine_name_##_type, \
38 + .mach_setup = _setup, \
41 +static int __init register_machine_##_type(void) \
43 + mips_machine_register(&machine_##_type); \
47 +pure_initcall(register_machine_##_type)
49 +#endif /* __ASM_MIPS_MACHINE_H */
52 +++ b/arch/mips/kernel/mips_machine.c
55 + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
57 + * This program is free software; you can redistribute it and/or modify it
58 + * under the terms of the GNU General Public License version 2 as published
59 + * by the Free Software Foundation.
62 +#include <linux/mm.h>
64 +#include <asm/mips_machine.h>
65 +#include <asm/bootinfo.h>
67 +static struct list_head mips_machines __initdata =
68 + LIST_HEAD_INIT(mips_machines);
70 +char *mips_machine_name = "Unknown";
72 +static struct mips_machine * __init mips_machine_find(unsigned long machtype)
74 + struct list_head *this;
76 + list_for_each(this, &mips_machines) {
77 + struct mips_machine *mach;
79 + mach = list_entry(this, struct mips_machine, list);
80 + if (mach->mach_type == machtype)
87 +void __init mips_machine_register(struct mips_machine *mach)
89 + list_add_tail(&mach->list, &mips_machines);
92 +void __init mips_machine_set_name(char *name)
100 + len = strlen(name);
101 + p = kmalloc(len + 1, GFP_KERNEL);
103 + strncpy(p, name, len);
105 + mips_machine_name = p;
107 + printk(KERN_WARNING "MIPS: no memory for machine_name\n");
111 +void __init mips_machine_setup(unsigned long machtype)
113 + struct mips_machine *mach;
115 + mach = mips_machine_find(machtype);
117 + printk(KERN_ALERT "MIPS: no machine registered for "
118 + "machtype %lu\n", machtype);
122 + mips_machine_set_name(mach->mach_name);
123 + printk(KERN_INFO "MIPS: machine is %s\n", mips_machine_name);
125 + if (mach->mach_setup)
126 + mach->mach_setup();
128 --- a/arch/mips/kernel/Makefile
129 +++ b/arch/mips/kernel/Makefile
130 @@ -94,6 +94,7 @@ obj-$(CONFIG_GPIO_TXX9) += gpio_txx9.o
131 obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o
132 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
133 obj-$(CONFIG_SPINLOCK_TEST) += spinlock_test.o
134 +obj-$(CONFIG_MIPS_MACHINE) += mips_machine.o
136 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)
138 --- a/arch/mips/Kconfig
139 +++ b/arch/mips/Kconfig
140 @@ -851,6 +851,9 @@ config MIPS_DISABLE_OBSOLETE_IDE
150 --- a/arch/mips/kernel/proc.c
151 +++ b/arch/mips/kernel/proc.c
153 #include <asm/cpu-features.h>
154 #include <asm/mipsregs.h>
155 #include <asm/processor.h>
156 +#include <asm/mips_machine.h>
158 unsigned int vced_count, vcei_count;
160 @@ -31,8 +32,12 @@ static int show_cpuinfo(struct seq_file
162 * For the first processor also print the system type
166 seq_printf(m, "system type\t\t: %s\n", get_system_type());
167 +#ifdef CONFIG_MIPS_MACHINE
168 + seq_printf(m, "machine\t\t\t: %s\n", mips_machine_name);
172 seq_printf(m, "processor\t\t: %ld\n", n);
173 sprintf(fmt, "cpu model\t\t: %%s V%%d.%%d%s\n",