mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-25 20:14:25 +08:00
487d70d0b8
This patch adds a generic solution to support multiple machines based on a given SoC within a single kernel image. It is implemented already for several other architectures but MIPS has no generic support for that yet. [Ralf: This competes with DT but DT is a much more complex solution and this code has been used by OpenWRT for a long time so for now DT is a bad reason to stop the merge but longer term this should be migrated to DT.] Signed-off-by: Gabor Juhos <juhosg@openwrt.org> Cc: linux-mips@linux-mips.org Cc: kaloz@openwrt.org Cc: Luis R. Rodriguez <lrodriguez@atheros.com> Cc: Cliff Holden <Cliff.Holden@Atheros.com> Patchwork: https://patchwork.linux-mips.org/patch/1814/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
87 lines
1.8 KiB
C
87 lines
1.8 KiB
C
/*
|
|
* Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License version 2 as published
|
|
* by the Free Software Foundation.
|
|
*
|
|
*/
|
|
#include <linux/mm.h>
|
|
#include <linux/string.h>
|
|
#include <linux/slab.h>
|
|
|
|
#include <asm/mips_machine.h>
|
|
|
|
static struct mips_machine *mips_machine __initdata;
|
|
static char *mips_machine_name = "Unknown";
|
|
|
|
#define for_each_machine(mach) \
|
|
for ((mach) = (struct mips_machine *)&__mips_machines_start; \
|
|
(mach) && \
|
|
(unsigned long)(mach) < (unsigned long)&__mips_machines_end; \
|
|
(mach)++)
|
|
|
|
__init void mips_set_machine_name(const char *name)
|
|
{
|
|
char *p;
|
|
|
|
if (name == NULL)
|
|
return;
|
|
|
|
p = kstrdup(name, GFP_KERNEL);
|
|
if (!p)
|
|
pr_err("MIPS: no memory for machine_name\n");
|
|
|
|
mips_machine_name = p;
|
|
}
|
|
|
|
char *mips_get_machine_name(void)
|
|
{
|
|
return mips_machine_name;
|
|
}
|
|
|
|
__init int mips_machtype_setup(char *id)
|
|
{
|
|
struct mips_machine *mach;
|
|
|
|
for_each_machine(mach) {
|
|
if (mach->mach_id == NULL)
|
|
continue;
|
|
|
|
if (strcmp(mach->mach_id, id) == 0) {
|
|
mips_machtype = mach->mach_type;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
pr_err("MIPS: no machine found for id '%s', supported machines:\n", id);
|
|
pr_err("%-24s %s\n", "id", "name");
|
|
for_each_machine(mach)
|
|
pr_err("%-24s %s\n", mach->mach_id, mach->mach_name);
|
|
|
|
return 1;
|
|
}
|
|
|
|
__setup("machtype=", mips_machtype_setup);
|
|
|
|
__init void mips_machine_setup(void)
|
|
{
|
|
struct mips_machine *mach;
|
|
|
|
for_each_machine(mach) {
|
|
if (mips_machtype == mach->mach_type) {
|
|
mips_machine = mach;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!mips_machine)
|
|
return;
|
|
|
|
mips_set_machine_name(mips_machine->mach_name);
|
|
pr_info("MIPS: machine is %s\n", mips_machine_name);
|
|
|
|
if (mips_machine->mach_setup)
|
|
mips_machine->mach_setup();
|
|
}
|