d63587901d0c376e7d01f80b1aceb4b55f71a29f
[openwrt.git] / target / linux / ramips / patches-2.6.30 / 400-mips-multi-machine-update.patch
1 --- a/arch/mips/kernel/mips_machine.c
2 +++ b/arch/mips/kernel/mips_machine.c
3 @@ -7,12 +7,13 @@
4   *
5   */
6  #include <linux/mm.h>
7 +#include <linux/string.h>
8  
9  #include <asm/mips_machine.h>
10 -#include <asm/bootinfo.h>
11  
12  static struct list_head mips_machines __initdata =
13                 LIST_HEAD_INIT(mips_machines);
14 +static char *mips_machid __initdata;
15  
16  char *mips_machine_name = "Unknown";
17  
18 @@ -55,20 +56,65 @@ void __init mips_machine_set_name(char *
19         }
20  }
21  
22 -void __init mips_machine_setup(unsigned long machtype)
23 +void __init mips_machine_setup(void)
24  {
25         struct mips_machine *mach;
26  
27 -       mach = mips_machine_find(machtype);
28 +       mach = mips_machine_find(mips_machtype);
29         if (!mach) {
30 -               printk(KERN_ALERT "MIPS: no machine registered for "
31 -                       "machtype %lu\n", machtype);
32 +               printk(KERN_WARNING "MIPS: no machine registered for "
33 +                       "machtype %lu\n", mips_machtype);
34                 return;
35         }
36  
37         mips_machine_set_name(mach->mach_name);
38 -       printk(KERN_INFO "MIPS: machine is %s\n", mips_machine_name);
39 +       printk(KERN_NOTICE "MIPS: machine is %s\n", mips_machine_name);
40  
41         if (mach->mach_setup)
42                 mach->mach_setup();
43  }
44 +
45 +int __init mips_machtype_setup(char *id)
46 +{
47 +       if (mips_machid == NULL)
48 +               mips_machid = id;
49 +
50 +       return 1;
51 +}
52 +
53 +__setup("machtype=", mips_machtype_setup);
54 +
55 +static int __init mips_machtype_init(void)
56 +{
57 +       struct list_head *this;
58 +       struct mips_machine *mach;
59 +
60 +       if (mips_machid == NULL)
61 +               return 0;
62 +
63 +       list_for_each(this, &mips_machines) {
64 +               mach = list_entry(this, struct mips_machine, list);
65 +               if (mach->mach_id == NULL)
66 +                       continue;
67 +
68 +               if (strcmp(mach->mach_id, mips_machid) == 0) {
69 +                       mips_machtype = mach->mach_type;
70 +                       return 0;
71 +               }
72 +       }
73 +
74 +       printk(KERN_WARNING
75 +              "MIPS: no machine found for id: '%s', registered machines:\n",
76 +              mips_machid);
77 +       printk(KERN_WARNING "%32s %s\n", "id", "name");
78 +
79 +       list_for_each(this, &mips_machines) {
80 +               mach = list_entry(this, struct mips_machine, list);
81 +               printk(KERN_WARNING "%32s %s\n",
82 +                      mach->mach_id ? mach->mach_id : "", mach->mach_name);
83 +       }
84 +
85 +       return 0;
86 +}
87 +
88 +core_initcall(mips_machtype_init);
89 --- a/arch/mips/include/asm/mips_machine.h
90 +++ b/arch/mips/include/asm/mips_machine.h
91 @@ -13,25 +13,33 @@
92  #include <linux/init.h>
93  #include <linux/list.h>
94  
95 +#include <asm/bootinfo.h>
96 +
97  struct mips_machine {
98         unsigned long           mach_type;
99 -       void                    (*mach_setup)(void);
100 +       char                    *mach_id;
101         char                    *mach_name;
102 +       void                    (*mach_setup)(void);
103         struct list_head        list;
104  };
105  
106  void mips_machine_register(struct mips_machine *) __init;
107 -void mips_machine_setup(unsigned long machtype) __init;
108 +void mips_machine_setup(void) __init;
109 +int  mips_machtype_setup(char *id) __init;
110  void mips_machine_set_name(char *name) __init;
111  
112  extern char *mips_machine_name;
113  
114 -#define MIPS_MACHINE(_type, _name, _setup)                     \
115 -static char machine_name_##_type[] __initdata = _name;         \
116 +#define MIPS_MACHINE(_type, _id, _name, _setup)                \
117 +static const char machine_name_##_type[] __initconst           \
118 +                       __aligned(1) = _name;                   \
119 +static const char machine_id_##_type[] __initconst             \
120 +                       __aligned(1) = _id;                     \
121  static struct mips_machine machine_##_type __initdata =                \
122  {                                                              \
123         .mach_type      = _type,                                \
124 -       .mach_name      = machine_name_##_type,                 \
125 +       .mach_id        = (char *) machine_id_##_type,          \
126 +       .mach_name      = (char *) machine_name_##_type,        \
127         .mach_setup     = _setup,                               \
128  };                                                             \
129                                                                 \
130 @@ -44,4 +52,3 @@ static int __init register_machine_##_ty
131  pure_initcall(register_machine_##_type)
132  
133  #endif /* __ASM_MIPS_MACHINE_H */
134 -