Commit 9169a5d0 authored by John Crispin's avatar John Crispin Committed by Ralf Baechle

MIPS: move mips_{set,get}_machine_name() to a more generic place

Previously this functionality was only available to users of the mips_machine
api. Moving the code to prom.c allows us to also add a OF wrapper.
Signed-off-by: default avatarJohn Crispin <blogic@openwrt.org>
Patchwork: http://patchwork.linux-mips.org/patch/5164/
parent d41d547a
...@@ -42,13 +42,9 @@ extern long __mips_machines_end; ...@@ -42,13 +42,9 @@ extern long __mips_machines_end;
#ifdef CONFIG_MIPS_MACHINE #ifdef CONFIG_MIPS_MACHINE
int mips_machtype_setup(char *id) __init; int mips_machtype_setup(char *id) __init;
void mips_machine_setup(void) __init; void mips_machine_setup(void) __init;
void mips_set_machine_name(const char *name) __init;
char *mips_get_machine_name(void);
#else #else
static inline int mips_machtype_setup(char *id) { return 1; } static inline int mips_machtype_setup(char *id) { return 1; }
static inline void mips_machine_setup(void) { } static inline void mips_machine_setup(void) { }
static inline void mips_set_machine_name(const char *name) { }
static inline char *mips_get_machine_name(void) { return NULL; }
#endif /* CONFIG_MIPS_MACHINE */ #endif /* CONFIG_MIPS_MACHINE */
#endif /* __ASM_MIPS_MACHINE_H */ #endif /* __ASM_MIPS_MACHINE_H */
...@@ -48,4 +48,7 @@ extern void __dt_setup_arch(struct boot_param_header *bph); ...@@ -48,4 +48,7 @@ extern void __dt_setup_arch(struct boot_param_header *bph);
static inline void device_tree_init(void) { } static inline void device_tree_init(void) { }
#endif /* CONFIG_OF */ #endif /* CONFIG_OF */
extern char *mips_get_machine_name(void);
extern void mips_set_machine_name(const char *name);
#endif /* __ASM_PROM_H */ #endif /* __ASM_PROM_H */
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
extra-y := head.o vmlinux.lds extra-y := head.o vmlinux.lds
obj-y += cpu-probe.o branch.o entry.o genex.o irq.o process.o \ obj-y += cpu-probe.o branch.o entry.o genex.o irq.o process.o \
ptrace.o reset.o setup.o signal.o syscall.o \ prom.o ptrace.o reset.o setup.o signal.o syscall.o \
time.o topology.o traps.o unaligned.o watch.o vdso.o time.o topology.o traps.o unaligned.o watch.o vdso.o
ifdef CONFIG_FUNCTION_TRACER ifdef CONFIG_FUNCTION_TRACER
...@@ -86,8 +86,6 @@ obj-$(CONFIG_EARLY_PRINTK) += early_printk.o ...@@ -86,8 +86,6 @@ obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
obj-$(CONFIG_SPINLOCK_TEST) += spinlock_test.o obj-$(CONFIG_SPINLOCK_TEST) += spinlock_test.o
obj-$(CONFIG_MIPS_MACHINE) += mips_machine.o obj-$(CONFIG_MIPS_MACHINE) += mips_machine.o
obj-$(CONFIG_OF) += prom.o
CFLAGS_cpu-bugs64.o = $(shell if $(CC) $(KBUILD_CFLAGS) -Wa,-mdaddi -c -o /dev/null -x c /dev/null >/dev/null 2>&1; then echo "-DHAVE_AS_SET_DADDI"; fi) CFLAGS_cpu-bugs64.o = $(shell if $(CC) $(KBUILD_CFLAGS) -Wa,-mdaddi -c -o /dev/null -x c /dev/null >/dev/null 2>&1; then echo "-DHAVE_AS_SET_DADDI"; fi)
obj-$(CONFIG_HAVE_STD_PC_SERIAL_PORT) += 8250-platform.o obj-$(CONFIG_HAVE_STD_PC_SERIAL_PORT) += 8250-platform.o
......
...@@ -11,9 +11,9 @@ ...@@ -11,9 +11,9 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <asm/mips_machine.h> #include <asm/mips_machine.h>
#include <asm/prom.h>
static struct mips_machine *mips_machine __initdata; static struct mips_machine *mips_machine __initdata;
static char *mips_machine_name = "Unknown";
#define for_each_machine(mach) \ #define for_each_machine(mach) \
for ((mach) = (struct mips_machine *)&__mips_machines_start; \ for ((mach) = (struct mips_machine *)&__mips_machines_start; \
...@@ -21,25 +21,6 @@ static char *mips_machine_name = "Unknown"; ...@@ -21,25 +21,6 @@ static char *mips_machine_name = "Unknown";
(unsigned long)(mach) < (unsigned long)&__mips_machines_end; \ (unsigned long)(mach) < (unsigned long)&__mips_machines_end; \
(mach)++) (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) __init int mips_machtype_setup(char *id)
{ {
struct mips_machine *mach; struct mips_machine *mach;
...@@ -79,7 +60,6 @@ __init void mips_machine_setup(void) ...@@ -79,7 +60,6 @@ __init void mips_machine_setup(void)
return; return;
mips_set_machine_name(mips_machine->mach_name); mips_set_machine_name(mips_machine->mach_name);
pr_info("MIPS: machine is %s\n", mips_machine_name);
if (mips_machine->mach_setup) if (mips_machine->mach_setup)
mips_machine->mach_setup(); mips_machine->mach_setup();
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include <asm/cpu-features.h> #include <asm/cpu-features.h>
#include <asm/mipsregs.h> #include <asm/mipsregs.h>
#include <asm/processor.h> #include <asm/processor.h>
#include <asm/mips_machine.h> #include <asm/prom.h>
unsigned int vced_count, vcei_count; unsigned int vced_count, vcei_count;
......
...@@ -23,6 +23,23 @@ ...@@ -23,6 +23,23 @@
#include <asm/page.h> #include <asm/page.h>
#include <asm/prom.h> #include <asm/prom.h>
static char mips_machine_name[64] = "Unknown";
__init void mips_set_machine_name(const char *name)
{
if (name == NULL)
return;
strncpy(mips_machine_name, name, sizeof(mips_machine_name));
pr_info("MIPS: machine is %s\n", mips_get_machine_name());
}
char *mips_get_machine_name(void)
{
return mips_machine_name;
}
#ifdef CONFIG_OF
int __init early_init_dt_scan_memory_arch(unsigned long node, int __init early_init_dt_scan_memory_arch(unsigned long node,
const char *uname, int depth, const char *uname, int depth,
void *data) void *data)
...@@ -50,6 +67,18 @@ void __init early_init_dt_setup_initrd_arch(unsigned long start, ...@@ -50,6 +67,18 @@ void __init early_init_dt_setup_initrd_arch(unsigned long start,
} }
#endif #endif
int __init early_init_dt_scan_model(unsigned long node, const char *uname,
int depth, void *data)
{
if (!depth) {
char *model = of_get_flat_dt_prop(node, "model", NULL);
if (model)
mips_set_machine_name(model);
}
return 0;
}
void __init early_init_devtree(void *params) void __init early_init_devtree(void *params)
{ {
/* Setup flat device-tree pointer */ /* Setup flat device-tree pointer */
...@@ -65,6 +94,9 @@ void __init early_init_devtree(void *params) ...@@ -65,6 +94,9 @@ void __init early_init_devtree(void *params)
/* Scan memory nodes */ /* Scan memory nodes */
of_scan_flat_dt(early_init_dt_scan_root, NULL); of_scan_flat_dt(early_init_dt_scan_root, NULL);
of_scan_flat_dt(early_init_dt_scan_memory_arch, NULL); of_scan_flat_dt(early_init_dt_scan_memory_arch, NULL);
/* try to load the mips machine name */
of_scan_flat_dt(early_init_dt_scan_model, NULL);
} }
void __init __dt_setup_arch(struct boot_param_header *bph) void __init __dt_setup_arch(struct boot_param_header *bph)
...@@ -79,3 +111,4 @@ void __init __dt_setup_arch(struct boot_param_header *bph) ...@@ -79,3 +111,4 @@ void __init __dt_setup_arch(struct boot_param_header *bph)
early_init_devtree(initial_boot_params); early_init_devtree(initial_boot_params);
} }
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment