Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752624AbeAESZd (ORCPT + 1 other); Fri, 5 Jan 2018 13:25:33 -0500 Received: from outils.crapouillou.net ([89.234.176.41]:56654 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752586AbeAESZc (ORCPT ); Fri, 5 Jan 2018 13:25:32 -0500 From: Paul Cercueil To: Ralf Baechle Cc: Maarten ter Huurne , Paul Burton , linux-kernel@vger.kernel.org, linux-mips@linux-mips.org, Paul Cercueil Subject: [PATCH v6 10/15] MIPS: ingenic: Detect machtype from SoC compatible string Date: Fri, 5 Jan 2018 19:25:08 +0100 Message-Id: <20180105182513.16248-11-paul@crapouillou.net> In-Reply-To: <20180105182513.16248-1-paul@crapouillou.net> References: <20180102150848.11314-1-paul@crapouillou.net> <20180105182513.16248-1-paul@crapouillou.net> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: Previously, the mips_machtype variable was always initialized to MACH_INGENIC_JZ4740 even if running on different SoCs. Signed-off-by: Paul Cercueil --- arch/mips/jz4740/prom.c | 1 - arch/mips/jz4740/setup.c | 26 ++++++++++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) v2: No change v3: No change v4: No change v5: Use SPDX license identifier v6: Init mips_machtype from DT compatible string instead of using MIPS_MACHINE 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..cd89536fbba1 100644 --- a/arch/mips/jz4740/setup.c +++ b/arch/mips/jz4740/setup.c @@ -53,16 +53,30 @@ 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; + if (!early_init_dt_scan(__dtb_start)) + return; + jz4740_reset_init(); - __dt_setup_arch(__dtb_start); 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 +89,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"; - - return "JZ4740"; + case MACH_INGENIC_JZ4770: + return "JZ4770"; + default: + return "JZ4740"; + } } void __init arch_init_irq(void) -- 2.11.0