xref: /openbmc/linux/arch/mips/kernel/prom.c (revision 97e7f455)
1f2ffa5abSDezhong Diao /*
2f2ffa5abSDezhong Diao  * MIPS support for CONFIG_OF device tree support
3f2ffa5abSDezhong Diao  *
4f2ffa5abSDezhong Diao  * Copyright (C) 2010 Cisco Systems Inc. <dediao@cisco.com>
5f2ffa5abSDezhong Diao  *
6f2ffa5abSDezhong Diao  * This program is free software; you can redistribute it and/or modify
7f2ffa5abSDezhong Diao  * it under the terms of the GNU General Public License version 2 as
8f2ffa5abSDezhong Diao  * published by the Free Software Foundation.
9f2ffa5abSDezhong Diao  */
10f2ffa5abSDezhong Diao 
11f2ffa5abSDezhong Diao #include <linux/init.h>
1273bc256dSPaul Gortmaker #include <linux/export.h>
13f2ffa5abSDezhong Diao #include <linux/errno.h>
14f2ffa5abSDezhong Diao #include <linux/types.h>
15f2ffa5abSDezhong Diao #include <linux/bootmem.h>
16f2ffa5abSDezhong Diao #include <linux/debugfs.h>
17f2ffa5abSDezhong Diao #include <linux/of.h>
18f2ffa5abSDezhong Diao #include <linux/of_fdt.h>
19f2ffa5abSDezhong Diao 
20f2ffa5abSDezhong Diao #include <asm/page.h>
21f2ffa5abSDezhong Diao #include <asm/prom.h>
22f2ffa5abSDezhong Diao 
239169a5d0SJohn Crispin static char mips_machine_name[64] = "Unknown";
249169a5d0SJohn Crispin 
259169a5d0SJohn Crispin __init void mips_set_machine_name(const char *name)
269169a5d0SJohn Crispin {
279169a5d0SJohn Crispin 	if (name == NULL)
289169a5d0SJohn Crispin 		return;
299169a5d0SJohn Crispin 
3041c8366bSChen Gang 	strlcpy(mips_machine_name, name, sizeof(mips_machine_name));
319169a5d0SJohn Crispin 	pr_info("MIPS: machine is %s\n", mips_get_machine_name());
329169a5d0SJohn Crispin }
339169a5d0SJohn Crispin 
349169a5d0SJohn Crispin char *mips_get_machine_name(void)
359169a5d0SJohn Crispin {
369169a5d0SJohn Crispin 	return mips_machine_name;
379169a5d0SJohn Crispin }
389169a5d0SJohn Crispin 
399169a5d0SJohn Crispin #ifdef CONFIG_OF
40f2ffa5abSDezhong Diao void __init early_init_dt_add_memory_arch(u64 base, u64 size)
41f2ffa5abSDezhong Diao {
42f2ffa5abSDezhong Diao 	return add_memory_region(base, size, BOOT_MEM_RAM);
43f2ffa5abSDezhong Diao }
44f2ffa5abSDezhong Diao 
45672c5446SGrant Likely void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
46f2ffa5abSDezhong Diao {
47672c5446SGrant Likely 	return __alloc_bootmem(size, align, __pa(MAX_DMA_ADDRESS));
48f2ffa5abSDezhong Diao }
49f2ffa5abSDezhong Diao 
50f75813c0SRob Herring void __init __dt_setup_arch(struct boot_param_header *bph)
51f2ffa5abSDezhong Diao {
52f75813c0SRob Herring 	if (!early_init_dt_scan(bph))
53f75813c0SRob Herring 		return;
549169a5d0SJohn Crispin 
5597e7f455SRob Herring 	mips_set_machine_name(of_flat_dt_get_machine_name());
56f2ffa5abSDezhong Diao }
579169a5d0SJohn Crispin #endif
58