mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-29 15:43:59 +08:00
MIPS: of: Introduce helper function to get DTB
Selection of the DTB to be used was burried in more or less readable code in head.S. Move this code into a inline helper function and use it. Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de> Acked-by: Florian Fainelli <f.fainelli@gmail.com>
This commit is contained in:
parent
a056aacd2d
commit
b83ba0b9df
@ -213,16 +213,17 @@ unsigned int get_c0_compare_int(void)
|
|||||||
|
|
||||||
void __init plat_mem_setup(void)
|
void __init plat_mem_setup(void)
|
||||||
{
|
{
|
||||||
unsigned long fdt_start;
|
void *dtb;
|
||||||
|
|
||||||
set_io_port_base(KSEG1);
|
set_io_port_base(KSEG1);
|
||||||
|
|
||||||
/* Get the position of the FDT passed by the bootloader */
|
/* Get the position of the FDT passed by the bootloader */
|
||||||
fdt_start = fw_getenvl("fdt_start");
|
dtb = (void *)fw_getenvl("fdt_start");
|
||||||
if (fdt_start)
|
if (dtb == NULL)
|
||||||
__dt_setup_arch((void *)KSEG0ADDR(fdt_start));
|
dtb = get_fdt();
|
||||||
else if (fw_passed_dtb)
|
|
||||||
__dt_setup_arch((void *)KSEG0ADDR(fw_passed_dtb));
|
if (dtb)
|
||||||
|
__dt_setup_arch((void *)KSEG0ADDR(dtb));
|
||||||
|
|
||||||
ath79_reset_base = ioremap(AR71XX_RESET_BASE,
|
ath79_reset_base = ioremap(AR71XX_RESET_BASE,
|
||||||
AR71XX_RESET_SIZE);
|
AR71XX_RESET_SIZE);
|
||||||
|
@ -161,11 +161,10 @@ void __init plat_mem_setup(void)
|
|||||||
/* intended to somewhat resemble ARM; see Documentation/arm/booting.rst */
|
/* intended to somewhat resemble ARM; see Documentation/arm/booting.rst */
|
||||||
if (fw_arg0 == 0 && fw_arg1 == 0xffffffff)
|
if (fw_arg0 == 0 && fw_arg1 == 0xffffffff)
|
||||||
dtb = phys_to_virt(fw_arg2);
|
dtb = phys_to_virt(fw_arg2);
|
||||||
else if (fw_passed_dtb) /* UHI interface or appended dtb */
|
|
||||||
dtb = (void *)fw_passed_dtb;
|
|
||||||
else if (&__dtb_start != &__dtb_end)
|
|
||||||
dtb = (void *)__dtb_start;
|
|
||||||
else
|
else
|
||||||
|
dtb = get_fdt();
|
||||||
|
|
||||||
|
if (!dtb)
|
||||||
panic("no dtb found");
|
panic("no dtb found");
|
||||||
|
|
||||||
__dt_setup_arch(dtb);
|
__dt_setup_arch(dtb);
|
||||||
|
@ -39,14 +39,13 @@ void __init *plat_get_fdt(void)
|
|||||||
/* Already set up */
|
/* Already set up */
|
||||||
return (void *)fdt;
|
return (void *)fdt;
|
||||||
|
|
||||||
if (fw_passed_dtb && !fdt_check_header((void *)fw_passed_dtb)) {
|
fdt = (void *)get_fdt();
|
||||||
|
if (fdt && !fdt_check_header(fdt)) {
|
||||||
/*
|
/*
|
||||||
* We have been provided with the appropriate device tree for
|
* We have been provided with the appropriate device tree for
|
||||||
* the board. Make use of it & search for any machine struct
|
* the board. Make use of it & search for any machine struct
|
||||||
* based upon the root compatible string.
|
* based upon the root compatible string.
|
||||||
*/
|
*/
|
||||||
fdt = (void *)fw_passed_dtb;
|
|
||||||
|
|
||||||
for_each_mips_machine(check_mach) {
|
for_each_mips_machine(check_mach) {
|
||||||
match = mips_machine_is_compatible(check_mach, fdt);
|
match = mips_machine_is_compatible(check_mach, fdt);
|
||||||
if (match) {
|
if (match) {
|
||||||
|
@ -112,7 +112,27 @@ extern char arcs_cmdline[COMMAND_LINE_SIZE];
|
|||||||
extern unsigned long fw_arg0, fw_arg1, fw_arg2, fw_arg3;
|
extern unsigned long fw_arg0, fw_arg1, fw_arg2, fw_arg3;
|
||||||
|
|
||||||
#ifdef CONFIG_USE_OF
|
#ifdef CONFIG_USE_OF
|
||||||
extern unsigned long fw_passed_dtb;
|
#include <linux/libfdt.h>
|
||||||
|
#include <linux/of_fdt.h>
|
||||||
|
|
||||||
|
extern char __appended_dtb[];
|
||||||
|
|
||||||
|
static inline void *get_fdt(void)
|
||||||
|
{
|
||||||
|
if (IS_ENABLED(CONFIG_MIPS_RAW_APPENDED_DTB) ||
|
||||||
|
IS_ENABLED(CONFIG_MIPS_ELF_APPENDED_DTB))
|
||||||
|
if (fdt_magic(&__appended_dtb) == FDT_MAGIC)
|
||||||
|
return &__appended_dtb;
|
||||||
|
|
||||||
|
if (fw_arg0 == -2) /* UHI interface */
|
||||||
|
return (void *)fw_arg1;
|
||||||
|
|
||||||
|
if (IS_ENABLED(CONFIG_BUILTIN_DTB))
|
||||||
|
if (&__dtb_start != &__dtb_end)
|
||||||
|
return &__dtb_start;
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -282,7 +282,6 @@ union octeon_cvmemctl {
|
|||||||
extern void octeon_check_cpu_bist(void);
|
extern void octeon_check_cpu_bist(void);
|
||||||
|
|
||||||
int octeon_prune_device_tree(void);
|
int octeon_prune_device_tree(void);
|
||||||
extern const char __appended_dtb;
|
|
||||||
extern const char __dtb_octeon_3xxx_begin;
|
extern const char __dtb_octeon_3xxx_begin;
|
||||||
extern const char __dtb_octeon_68xx_begin;
|
extern const char __dtb_octeon_68xx_begin;
|
||||||
|
|
||||||
|
@ -93,33 +93,6 @@ NESTED(kernel_entry, 16, sp) # kernel entry point
|
|||||||
jr t0
|
jr t0
|
||||||
0:
|
0:
|
||||||
|
|
||||||
#ifdef CONFIG_USE_OF
|
|
||||||
#if defined(CONFIG_MIPS_RAW_APPENDED_DTB) || \
|
|
||||||
defined(CONFIG_MIPS_ELF_APPENDED_DTB)
|
|
||||||
|
|
||||||
PTR_LA t2, __appended_dtb
|
|
||||||
|
|
||||||
#ifdef CONFIG_CPU_BIG_ENDIAN
|
|
||||||
li t1, 0xd00dfeed
|
|
||||||
#else /* !CONFIG_CPU_BIG_ENDIAN */
|
|
||||||
li t1, 0xedfe0dd0
|
|
||||||
#endif /* !CONFIG_CPU_BIG_ENDIAN */
|
|
||||||
lw t0, (t2)
|
|
||||||
beq t0, t1, dtb_found
|
|
||||||
#endif /* CONFIG_MIPS_RAW_APPENDED_DTB || CONFIG_MIPS_ELF_APPENDED_DTB */
|
|
||||||
li t1, -2
|
|
||||||
move t2, a1
|
|
||||||
beq a0, t1, dtb_found
|
|
||||||
|
|
||||||
#ifdef CONFIG_BUILTIN_DTB
|
|
||||||
PTR_LA t2, __dtb_start
|
|
||||||
PTR_LA t1, __dtb_end
|
|
||||||
bne t1, t2, dtb_found
|
|
||||||
#endif /* CONFIG_BUILTIN_DTB */
|
|
||||||
|
|
||||||
li t2, 0
|
|
||||||
dtb_found:
|
|
||||||
#endif /* CONFIG_USE_OF */
|
|
||||||
PTR_LA t0, __bss_start # clear .bss
|
PTR_LA t0, __bss_start # clear .bss
|
||||||
LONG_S zero, (t0)
|
LONG_S zero, (t0)
|
||||||
PTR_LA t1, __bss_stop - LONGSIZE
|
PTR_LA t1, __bss_stop - LONGSIZE
|
||||||
@ -133,10 +106,6 @@ dtb_found:
|
|||||||
LONG_S a2, fw_arg2
|
LONG_S a2, fw_arg2
|
||||||
LONG_S a3, fw_arg3
|
LONG_S a3, fw_arg3
|
||||||
|
|
||||||
#ifdef CONFIG_USE_OF
|
|
||||||
LONG_S t2, fw_passed_dtb
|
|
||||||
#endif
|
|
||||||
|
|
||||||
MTC0 zero, CP0_CONTEXT # clear context register
|
MTC0 zero, CP0_CONTEXT # clear context register
|
||||||
#ifdef CONFIG_64BIT
|
#ifdef CONFIG_64BIT
|
||||||
MTC0 zero, CP0_XCONTEXT
|
MTC0 zero, CP0_XCONTEXT
|
||||||
|
@ -792,10 +792,6 @@ void __init setup_arch(char **cmdline_p)
|
|||||||
unsigned long kernelsp[NR_CPUS];
|
unsigned long kernelsp[NR_CPUS];
|
||||||
unsigned long fw_arg0, fw_arg1, fw_arg2, fw_arg3;
|
unsigned long fw_arg0, fw_arg1, fw_arg2, fw_arg3;
|
||||||
|
|
||||||
#ifdef CONFIG_USE_OF
|
|
||||||
unsigned long fw_passed_dtb;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_DEBUG_FS
|
#ifdef CONFIG_DEBUG_FS
|
||||||
struct dentry *mips_debugfs_dir;
|
struct dentry *mips_debugfs_dir;
|
||||||
static int __init debugfs_mips(void)
|
static int __init debugfs_mips(void)
|
||||||
|
@ -73,11 +73,8 @@ void __init plat_mem_setup(void)
|
|||||||
|
|
||||||
set_io_port_base((unsigned long) KSEG1);
|
set_io_port_base((unsigned long) KSEG1);
|
||||||
|
|
||||||
if (fw_passed_dtb) /* UHI interface */
|
dtb = get_fdt();
|
||||||
dtb = (void *)fw_passed_dtb;
|
if (dtb == NULL)
|
||||||
else if (&__dtb_start != &__dtb_end)
|
|
||||||
dtb = (void *)__dtb_start;
|
|
||||||
else
|
|
||||||
panic("no dtb found");
|
panic("no dtb found");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -21,24 +21,11 @@ const char *get_system_type(void)
|
|||||||
return "PIC32MZDA";
|
return "PIC32MZDA";
|
||||||
}
|
}
|
||||||
|
|
||||||
static ulong get_fdtaddr(void)
|
|
||||||
{
|
|
||||||
ulong ftaddr = 0;
|
|
||||||
|
|
||||||
if (fw_passed_dtb && !fw_arg2 && !fw_arg3)
|
|
||||||
return (ulong)fw_passed_dtb;
|
|
||||||
|
|
||||||
if (&__dtb_start < &__dtb_end)
|
|
||||||
ftaddr = (ulong)__dtb_start;
|
|
||||||
|
|
||||||
return ftaddr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void __init plat_mem_setup(void)
|
void __init plat_mem_setup(void)
|
||||||
{
|
{
|
||||||
void *dtb;
|
void *dtb;
|
||||||
|
|
||||||
dtb = (void *)get_fdtaddr();
|
dtb = get_fdt();
|
||||||
if (!dtb) {
|
if (!dtb) {
|
||||||
pr_err("pic32: no DTB found.\n");
|
pr_err("pic32: no DTB found.\n");
|
||||||
return;
|
return;
|
||||||
|
@ -64,20 +64,15 @@ static int __init early_init_dt_find_memory(unsigned long node,
|
|||||||
|
|
||||||
void __init plat_mem_setup(void)
|
void __init plat_mem_setup(void)
|
||||||
{
|
{
|
||||||
void *dtb = NULL;
|
void *dtb;
|
||||||
|
|
||||||
set_io_port_base(KSEG1);
|
set_io_port_base(KSEG1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Load the builtin devicetree. This causes the chosen node to be
|
* Load the builtin devicetree. This causes the chosen node to be
|
||||||
* parsed resulting in our memory appearing. fw_passed_dtb is used
|
* parsed resulting in our memory appearing.
|
||||||
* by CONFIG_MIPS_APPENDED_RAW_DTB as well.
|
|
||||||
*/
|
*/
|
||||||
if (fw_passed_dtb)
|
dtb = get_fdt();
|
||||||
dtb = (void *)fw_passed_dtb;
|
|
||||||
else if (&__dtb_start != &__dtb_end)
|
|
||||||
dtb = (void *)__dtb_start;
|
|
||||||
|
|
||||||
__dt_setup_arch(dtb);
|
__dt_setup_arch(dtb);
|
||||||
|
|
||||||
of_scan_flat_dt(early_init_dt_find_memory, NULL);
|
of_scan_flat_dt(early_init_dt_find_memory, NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user