Commit 8e2fe0ec authored by Qing Zhang's avatar Qing Zhang Committed by Thomas Bogendoerfer

MIPS: Loongson64: Distinguish firmware dependencies DTB/LEFI

Add DTB boot support, only support Loongson-2K1000 processor
for now, determine whether to use the built-in DTB or the DTB
from the firmware by checking the range of CKSEG0 and XKPHYS.
loongson_fw_interface will be used in the future.
Signed-off-by: default avatarJiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: default avatarQing Zhang <zhangqing@loongson.cn>
Tested-by: default avatarMing Wang <wangming01@loongson.cn>
Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
parent b1a79260
...@@ -12,8 +12,14 @@ ...@@ -12,8 +12,14 @@
#include <linux/irq.h> #include <linux/irq.h>
#include <boot_param.h> #include <boot_param.h>
enum loongson_fw_interface {
LOONGSON_LEFI,
LOONGSON_DTB,
};
/* machine-specific boot configuration */ /* machine-specific boot configuration */
struct loongson_system_configuration { struct loongson_system_configuration {
enum loongson_fw_interface fw_interface;
u32 nr_cpus; u32 nr_cpus;
u32 nr_nodes; u32 nr_nodes;
int cores_per_node; int cores_per_node;
...@@ -41,7 +47,8 @@ extern u32 memsize, highmemsize; ...@@ -41,7 +47,8 @@ extern u32 memsize, highmemsize;
extern const struct plat_smp_ops loongson3_smp_ops; extern const struct plat_smp_ops loongson3_smp_ops;
/* loongson-specific command line, env and memory initialization */ /* loongson-specific command line, env and memory initialization */
extern void __init prom_init_env(void); extern void __init prom_dtb_init_env(void);
extern void __init prom_lefi_init_env(void);
extern void __init szmem(unsigned int node); extern void __init szmem(unsigned int node);
extern void *loongson_fdt_blob; extern void *loongson_fdt_blob;
......
...@@ -43,7 +43,18 @@ const char *get_system_type(void) ...@@ -43,7 +43,18 @@ const char *get_system_type(void)
return "Generic Loongson64 System"; return "Generic Loongson64 System";
} }
void __init prom_init_env(void)
void __init prom_dtb_init_env(void)
{
if ((fw_arg2 < CKSEG0 || fw_arg2 > CKSEG1)
&& (fw_arg2 < XKPHYS || fw_arg2 > XKSEG))
loongson_fdt_blob = __dtb_loongson64_2core_2k1000_begin;
else
loongson_fdt_blob = (void *)fw_arg2;
}
void __init prom_lefi_init_env(void)
{ {
struct boot_params *boot_p; struct boot_params *boot_p;
struct loongson_params *loongson_p; struct loongson_params *loongson_p;
......
...@@ -52,6 +52,10 @@ void __init szmem(unsigned int node) ...@@ -52,6 +52,10 @@ void __init szmem(unsigned int node)
static unsigned long num_physpages; static unsigned long num_physpages;
u64 node_id, node_psize, start_pfn, end_pfn, mem_start, mem_size; u64 node_id, node_psize, start_pfn, end_pfn, mem_start, mem_size;
/* Otherwise come from DTB */
if (loongson_sysconf.fw_interface != LOONGSON_LEFI)
return;
/* Parse memory information and activate */ /* Parse memory information and activate */
for (i = 0; i < loongson_memmap->nr_map; i++) { for (i = 0; i < loongson_memmap->nr_map; i++) {
node_id = loongson_memmap->map[i].node_id; node_id = loongson_memmap->map[i].node_id;
...@@ -94,12 +98,20 @@ static void __init prom_init_memory(void) ...@@ -94,12 +98,20 @@ static void __init prom_init_memory(void)
void __init prom_init(void) void __init prom_init(void)
{ {
fw_init_cmdline(); fw_init_cmdline();
prom_init_env();
if (fw_arg2 == 0 || (fdt_magic(fw_arg2) == FDT_MAGIC)) {
loongson_sysconf.fw_interface = LOONGSON_DTB;
prom_dtb_init_env();
} else {
loongson_sysconf.fw_interface = LOONGSON_LEFI;
prom_lefi_init_env();
}
/* init base address of io space */ /* init base address of io space */
set_io_port_base(PCI_IOBASE); set_io_port_base(PCI_IOBASE);
loongson_sysconf.early_config(); if (loongson_sysconf.early_config)
loongson_sysconf.early_config();
#ifdef CONFIG_NUMA #ifdef CONFIG_NUMA
prom_init_numa_memory(); prom_init_numa_memory();
......
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