ca989adeaf545b8316d13cab6a0a96578c2f9362
[openwrt-10.03/.git] / target / linux / ar71xx / patches-2.6.26 / 900-mips_multi_machine_support.patch
1 --- /dev/null
2 +++ b/include/asm-mips/mips_machine.h
3 @@ -0,0 +1,49 @@
4 +/*
5 + *  Copyright (C) 2008 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 +#define MIPS_MACHINE_NAME_LEN  64
22 +
23 +struct mips_machine {
24 +       unsigned long           mach_type;
25 +       void                    (*mach_setup)(void);
26 +       unsigned char           mach_name[MIPS_MACHINE_NAME_LEN];
27 +       struct list_head        list;
28 +};
29 +
30 +void mips_machine_register(struct mips_machine *) __init;
31 +void mips_machine_setup(void) __init;
32 +
33 +extern unsigned char mips_machine_name[MIPS_MACHINE_NAME_LEN];
34 +
35 +#define MIPS_MACHINE(_type, _name, _setup)                     \
36 +static struct mips_machine machine_##_type __initdata =                \
37 +{                                                              \
38 +       .mach_type      = _type,                                \
39 +       .mach_name      = _name,                                \
40 +       .mach_setup     = _setup,                               \
41 +};                                                             \
42 +                                                               \
43 +static int __init register_machine_##_type(void)               \
44 +{                                                              \
45 +       mips_machine_register(&machine_##_type);                \
46 +       return 0;                                               \
47 +}                                                              \
48 +                                                               \
49 +pure_initcall(register_machine_##_type)
50 +
51 +#endif /* __ASM_MIPS_MACHINE_H */
52 +
53 --- /dev/null
54 +++ b/arch/mips/kernel/mips_machine.c
55 @@ -0,0 +1,58 @@
56 +/*
57 + *  Copyright (C) 2008 Gabor Juhos <juhosg@openwrt.org>
58 + *
59 + *  This program is free software; you can redistribute it and/or modify it
60 + *  under the terms of the GNU General Public License version 2 as published
61 + *  by the Free Software Foundation.
62 + *
63 + */
64 +
65 +#include <asm/mips_machine.h>
66 +#include <asm/bootinfo.h>
67 +
68 +static struct list_head mips_machines __initdata =
69 +               LIST_HEAD_INIT(mips_machines);
70 +
71 +unsigned char mips_machine_name[MIPS_MACHINE_NAME_LEN] = "Unknown";
72 +
73 +static struct mips_machine * __init mips_machine_find(unsigned long machtype)
74 +{
75 +       struct list_head *this;
76 +
77 +       list_for_each(this, &mips_machines) {
78 +               struct mips_machine *mach;
79 +
80 +               mach = list_entry(this, struct mips_machine, list);
81 +               if (mach->mach_type == machtype)
82 +                       return mach;
83 +       }
84 +
85 +       return NULL;
86 +}
87 +
88 +void __init mips_machine_register(struct mips_machine *mach)
89 +{
90 +       list_add_tail(&mach->list, &mips_machines);
91 +}
92 +
93 +void __init mips_machine_setup(void)
94 +{
95 +       struct mips_machine *mach;
96 +
97 +       mach = mips_machine_find(mips_machtype);
98 +       if (!mach) {
99 +               printk(KERN_ALERT "MIPS: no machine registered for "
100 +                       "machtype %lu\n", mips_machtype);
101 +               return;
102 +       }
103 +
104 +       if (mach->mach_name[0])
105 +               strncpy(mips_machine_name, mach->mach_name,
106 +                       MIPS_MACHINE_NAME_LEN);
107 +
108 +       printk(KERN_INFO "MIPS: machine is %s\n", mips_machine_name);
109 +
110 +       if (mach->mach_setup)
111 +               mach->mach_setup();
112 +}
113 +
114 --- a/arch/mips/kernel/Makefile
115 +++ b/arch/mips/kernel/Makefile
116 @@ -86,6 +86,7 @@
117  
118  obj-$(CONFIG_KEXEC)            += machine_kexec.o relocate_kernel.o
119  obj-$(CONFIG_EARLY_PRINTK)     += early_printk.o
120 +obj-$(CONFIG_MIPS_MACHINE)     += mips_machine.o
121  
122  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)
123  
124 --- a/arch/mips/Kconfig
125 +++ b/arch/mips/Kconfig
126 @@ -705,6 +705,7 @@
127  
128  endchoice
129  
130 +source "arch/mips/ar71xx/Kconfig"
131  source "arch/mips/au1000/Kconfig"
132  source "arch/mips/basler/excite/Kconfig"
133  source "arch/mips/jazz/Kconfig"
134 @@ -876,6 +877,9 @@
135  config SYNC_R4K
136         bool
137  
138 +config MIPS_MACHINE
139 +       def_bool n
140 +
141  config NO_IOPORT
142         def_bool n
143