2 * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published
6 * by the Free Software Foundation.
10 #include <linux/string.h>
11 #include <linux/slab.h>
13 #include <asm/mips_machine.h>
15 static struct mips_machine
*mips_machine __initdata
;
16 static char *mips_machine_name
= "Unknown";
18 #define for_each_machine(mach) \
19 for ((mach) = (struct mips_machine *)&__mips_machines_start; \
21 (unsigned long)(mach) < (unsigned long)&__mips_machines_end; \
24 __init
void mips_set_machine_name(const char *name
)
31 p
= kstrdup(name
, GFP_KERNEL
);
33 pr_err("MIPS: no memory for machine_name\n");
35 mips_machine_name
= p
;
38 char *mips_get_machine_name(void)
40 return mips_machine_name
;
43 __init
int mips_machtype_setup(char *id
)
45 struct mips_machine
*mach
;
47 for_each_machine(mach
) {
48 if (mach
->mach_id
== NULL
)
51 if (strcmp(mach
->mach_id
, id
) == 0) {
52 mips_machtype
= mach
->mach_type
;
57 pr_err("MIPS: no machine found for id '%s', supported machines:\n", id
);
58 pr_err("%-24s %s\n", "id", "name");
59 for_each_machine(mach
)
60 pr_err("%-24s %s\n", mach
->mach_id
, mach
->mach_name
);
65 __setup("machtype=", mips_machtype_setup
);
67 __init
void mips_machine_setup(void)
69 struct mips_machine
*mach
;
71 for_each_machine(mach
) {
72 if (mips_machtype
== mach
->mach_type
) {
81 mips_set_machine_name(mips_machine
->mach_name
);
82 pr_info("MIPS: machine is %s\n", mips_machine_name
);
84 if (mips_machine
->mach_setup
)
85 mips_machine
->mach_setup();