Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp344348pxb; Tue, 9 Feb 2021 01:39:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJx10vaj3wMutPyTIbI6y4/nX3KcAvXUR2Pp/Ct7uYpOPVYBPPRMpAuJ9pfHn7of0tBa4w4b X-Received: by 2002:a05:6402:1118:: with SMTP id u24mr21803642edv.386.1612863547789; Tue, 09 Feb 2021 01:39:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612863547; cv=none; d=google.com; s=arc-20160816; b=MC7Pkw8kP2fl3Umm5dr4gKuHagUJrNhdrXBJL42C8jM/Eeu2OFgKYaQkb4rBUYcVTW A6L3M5evCtvEAdOzg2djwKCd/GT2YGVeA0KQEdhLueEFPMqNr/k8xyCmq8pyv6oRaWhK 7ivMTxxMV5ijRIRS8q576vea0CMU+GNSa9+f9foC1lZte9iDD/GT6YSPv8KyTBlC6kxt VrD/wacsS/JDjVzNIsxlby/KiErWJfC1pDk/6goXCrATFYInnYji4cTAScgN+z+i20Gn vxJwroGx37OHeYIOKn5Z98MfgIzeLUxZOIanp44WHEIENAvfIeMMAdytYfJ3KjS2gviF b6bA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=UojieVFiE4vQzmp4MxGXvadp20bXrxpLU9xcYaR+nGA=; b=FFoMymsVpq4276aZJ3WulZclHdaKJdl2eApZgyItKuLJSm42pUsNKfxRPYqn/NZk4E oVfZP+SoiiM0cj0RWMLSKdGeit2tV8bhq3DEuuaoFM4imaTbJrb0S0b2665l/JJHiLBy mbGvXdeHucB8XhELUZHLrGlmoF3EY8++xkcJHzRNmz4JSKl9XjSxIeSG3vwWdOvyo7/b l68fZD4DWVrPlky/XQmZz1zWZd5Sua6puKpyJrWnBcpNkywTaUr5jLyxUYzwDR7gXEgG LgKGuXcrChvYVMWTZeenPy2AeQuy2lQ62s8MjQaMiVGT+SBNiHjnOJWDG+qk4fS9nR+6 Hdzg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h5si15165603edd.237.2021.02.09.01.38.41; Tue, 09 Feb 2021 01:39:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230202AbhBIJgx (ORCPT + 99 others); Tue, 9 Feb 2021 04:36:53 -0500 Received: from mail.loongson.cn ([114.242.206.163]:34846 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230296AbhBIJd1 (ORCPT ); Tue, 9 Feb 2021 04:33:27 -0500 Received: from localhost.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9AxSdSoViJgw40IAA--.11028S4; Tue, 09 Feb 2021 17:32:32 +0800 (CST) From: Qing Zhang To: Rob Herring , Thomas Bogendoerfer , Thomas Gleixner , Marc Zyngier , Huacai Chen Cc: devicetree@vger.kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Jiaxun Yang , Xingxing Su Subject: [PATCH 2/6] MIPS: Loongson64: Distinguish firmware dependencies DTB/LEFI. Date: Tue, 9 Feb 2021 17:32:20 +0800 Message-Id: <20210209093224.7085-3-zhangqing@loongson.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210209093224.7085-1-zhangqing@loongson.cn> References: <20210209093224.7085-1-zhangqing@loongson.c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xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87 Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIF yTuYvjfUUXdjDUUUU X-CM-SenderInfo: x2kd0wptlqwqxorr0wxvrqhubq/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add DTB boot support, only support LS2K1000 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. Signed-off-by: Jiaxun Yang Signed-off-by: Qing Zhang Signed-off-by: Xingxing Su --- .../include/asm/mach-loongson64/boot_param.h | 6 ++++++ arch/mips/include/asm/mach-loongson64/loongson.h | 3 ++- arch/mips/loongson64/env.c | 13 ++++++++++++- arch/mips/loongson64/init.c | 16 ++++++++++++++-- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/arch/mips/include/asm/mach-loongson64/boot_param.h b/arch/mips/include/asm/mach-loongson64/boot_param.h index 4592841b6b0c..53c29a305ff0 100644 --- a/arch/mips/include/asm/mach-loongson64/boot_param.h +++ b/arch/mips/include/asm/mach-loongson64/boot_param.h @@ -198,7 +198,13 @@ enum loongson_bridge_type { VIRTUAL = 3 }; +enum loongson_fw_interface { + LOONGSON_LEFI = 0, + LOONGSON_DTB = 1, +}; + struct loongson_system_configuration { + enum loongson_fw_interface fw_interface; u32 nr_cpus; u32 nr_nodes; int cores_per_node; diff --git a/arch/mips/include/asm/mach-loongson64/loongson.h b/arch/mips/include/asm/mach-loongson64/loongson.h index ac1c20e172a2..3f885fa26ba6 100644 --- a/arch/mips/include/asm/mach-loongson64/loongson.h +++ b/arch/mips/include/asm/mach-loongson64/loongson.h @@ -23,7 +23,8 @@ extern u32 memsize, highmemsize; extern const struct plat_smp_ops loongson3_smp_ops; /* 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 *loongson_fdt_blob; diff --git a/arch/mips/loongson64/env.c b/arch/mips/loongson64/env.c index 51a5d050a94c..e7d3a06175e3 100644 --- a/arch/mips/loongson64/env.c +++ b/arch/mips/loongson64/env.c @@ -43,7 +43,18 @@ const char *get_system_type(void) 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 loongson_params *loongson_p; diff --git a/arch/mips/loongson64/init.c b/arch/mips/loongson64/init.c index cfa788bca871..8bef1ebab72d 100644 --- a/arch/mips/loongson64/init.c +++ b/arch/mips/loongson64/init.c @@ -52,6 +52,10 @@ void __init szmem(unsigned int node) static unsigned long num_physpages; 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 */ for (i = 0; i < loongson_memmap->nr_map; i++) { node_id = loongson_memmap->map[i].node_id; @@ -94,12 +98,20 @@ static void __init prom_init_memory(void) void __init prom_init(void) { fw_init_cmdline(); - prom_init_env(); + + if (fw_arg2 == 0 || (be32_to_cpup((__be32 *)fw_arg2) == OF_DT_HEADER)) { + 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 */ set_io_port_base(PCI_IOBASE); - loongson_sysconf.early_config(); + if (loongson_sysconf.early_config) + loongson_sysconf.early_config(); #ifdef CONFIG_NUMA prom_init_numa_memory(); -- 2.20.1