MIPS: ingenic: Detect machtype from SoC compatible string
"Linux Kernel Mailing List" <[email protected]>
| Newsgroups | gmane.linux.kernel.commits.head |
|---|---|
| Message-ID | <[email protected]> |
Web: https://git.kernel.org/torvalds/c/ce0d60f731f0011a3e0b6e7d17a01f229313d2a0 Commit: ce0d60f731f0011a3e0b6e7d17a01f229313d2a0 Parent: 147b7910c8bdb4e702c8813bb3de4f3dc4eb4046 Refname: refs/heads/master Author: Paul Cercueil <[email protected]> AuthorDate: Tue Jan 16 16:48:00 2018 +0100 Committer: James Hogan <[email protected]> CommitDate: Thu Jan 18 22:07:24 2018 +0000 MIPS: ingenic: Detect machtype from SoC compatible string Previously, the mips_machtype variable was always initialized to MACH_INGENIC_JZ4740 even if running on different SoCs. Signed-off-by: Paul Cercueil <[email protected]> Reviewed-by: James Hogan <[email protected]> Cc: Ralf Baechle <[email protected]> Cc: Maarten ter Huurne <[email protected]> Cc: [email protected] Patchwork: https://patchwork.linux-mips.org/patch/18486/ Signed-off-by: James Hogan <[email protected]> --- arch/mips/jz4740/prom.c | 1 - arch/mips/jz4740/setup.c | 22 +++++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/arch/mips/jz4740/prom.c b/arch/mips/jz4740/prom.c index a62dd8e6ecf9..eb9f2f97bedb 100644 --- a/arch/mips/jz4740/prom.c +++ b/arch/mips/jz4740/prom.c @@ -25,7 +25,6 @@ void __init prom_init(void) { - mips_machtype = MACH_INGENIC_JZ4740; fw_init_cmdline(); } diff --git a/arch/mips/jz4740/setup.c b/arch/mips/jz4740/setup.c index 6d0152321819..afb40f8bce96 100644 --- a/arch/mips/jz4740/setup.c +++ b/arch/mips/jz4740/setup.c @@ -53,6 +53,16 @@ static void __init jz4740_detect_mem(void) add_memory_region(0, size, BOOT_MEM_RAM); } +static unsigned long __init get_board_mach_type(const void *fdt) +{ + if (!fdt_node_check_compatible(fdt, 0, "ingenic,jz4780")) + return MACH_INGENIC_JZ4780; + if (!fdt_node_check_compatible(fdt, 0, "ingenic,jz4770")) + return MACH_INGENIC_JZ4770; + + return MACH_INGENIC_JZ4740; +} + void __init plat_mem_setup(void) { int offset; @@ -63,6 +73,8 @@ void __init plat_mem_setup(void) offset = fdt_path_offset(__dtb_start, "/memory"); if (offset < 0) jz4740_detect_mem(); + + mips_machtype = get_board_mach_type(__dtb_start); } void __init device_tree_init(void) @@ -75,10 +87,14 @@ void __init device_tree_init(void) const char *get_system_type(void) { - if (IS_ENABLED(CONFIG_MACH_JZ4780)) + switch (mips_machtype) { + case MACH_INGENIC_JZ4780: return "JZ4780";