Skip to content

Commit fcecdcd

Browse files
FlyGoattsbogend
authored andcommitted
MIPS: Loongson64: Load built-in dtbs
Load proper dtb according to firmware passed parameters and CPU PRID. Signed-off-by: Jiaxun Yang <[email protected]> Co-developed-by: Huacai Chen <[email protected]> Signed-off-by: Huacai Chen <[email protected]> Signed-off-by: Thomas Bogendoerfer <[email protected]>
1 parent 87fcfa7 commit fcecdcd

File tree

4 files changed

+53
-0
lines changed

4 files changed

+53
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* SPDX-License-Identifier: GPL-2.0-or-later */
2+
/*
3+
* Copyright (C) 2019 Jiaxun Yang <[email protected]>
4+
*
5+
* Built-in Generic dtbs for MACH_LOONGSON64
6+
*/
7+
8+
#ifndef __ASM_MACH_LOONGSON64_BUILTIN_DTBS_H_
9+
#define __ASM_MACH_LOONGSON64_BUILTIN_DTBS_H_
10+
11+
extern u32 __dtb_loongson3_4core_rs780e_begin[];
12+
extern u32 __dtb_loongson3_8core_rs780e_begin[];
13+
#endif

arch/mips/include/asm/mach-loongson64/loongson.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ extern const struct plat_smp_ops loongson3_smp_ops;
2525
/* loongson-specific command line, env and memory initialization */
2626
extern void __init prom_init_memory(void);
2727
extern void __init prom_init_env(void);
28+
extern void *loongson_fdt_blob;
2829

2930
/* irq operation functions */
3031
extern void mach_irq_dispatch(unsigned int pending);

arch/mips/loongson64/env.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <asm/bootinfo.h>
1818
#include <loongson.h>
1919
#include <boot_param.h>
20+
#include <builtin_dtbs.h>
2021
#include <workarounds.h>
2122

2223
u32 cpu_clock_freq;
@@ -120,6 +121,28 @@ void __init prom_init_env(void)
120121
loongson_sysconf.cores_per_node - 1) /
121122
loongson_sysconf.cores_per_node;
122123

124+
if ((read_c0_prid() & PRID_IMP_MASK) == PRID_IMP_LOONGSON_64C) {
125+
switch (read_c0_prid() & PRID_REV_MASK) {
126+
case PRID_REV_LOONGSON3A_R1:
127+
case PRID_REV_LOONGSON3A_R2_0:
128+
case PRID_REV_LOONGSON3A_R2_1:
129+
case PRID_REV_LOONGSON3A_R3_0:
130+
case PRID_REV_LOONGSON3A_R3_1:
131+
loongson_fdt_blob = __dtb_loongson3_4core_rs780e_begin;
132+
break;
133+
case PRID_REV_LOONGSON3B_R1:
134+
case PRID_REV_LOONGSON3B_R2:
135+
loongson_fdt_blob = __dtb_loongson3_8core_rs780e_begin;
136+
break;
137+
default:
138+
break;
139+
}
140+
}
141+
142+
143+
if (!loongson_fdt_blob)
144+
pr_err("Failed to determine built-in Loongson64 dtb\n");
145+
123146
loongson_sysconf.pci_mem_start_addr = eirq_source->pci_mem_start_addr;
124147
loongson_sysconf.pci_mem_end_addr = eirq_source->pci_mem_end_addr;
125148
loongson_sysconf.pci_io_base = eirq_source->pci_io_start_addr;

arch/mips/loongson64/setup.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,15 @@
88

99
#include <asm/wbflush.h>
1010
#include <asm/bootinfo.h>
11+
#include <linux/libfdt.h>
12+
#include <linux/of_fdt.h>
13+
14+
#include <asm/prom.h>
1115

1216
#include <loongson.h>
1317

18+
void *loongson_fdt_blob;
19+
1420
static void wbflush_loongson(void)
1521
{
1622
asm(".set\tpush\n\t"
@@ -27,4 +33,14 @@ EXPORT_SYMBOL(__wbflush);
2733

2834
void __init plat_mem_setup(void)
2935
{
36+
if (loongson_fdt_blob)
37+
__dt_setup_arch(loongson_fdt_blob);
38+
}
39+
40+
void __init device_tree_init(void)
41+
{
42+
if (!initial_boot_params)
43+
return;
44+
45+
unflatten_and_copy_device_tree();
3046
}

0 commit comments

Comments
 (0)