Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp63164pxf; Tue, 9 Mar 2021 23:58:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJzXLL8ukvUSdR9NQCGhCeSzYwV1Umx//KsJU6yxo0Om/g85xtZ2ynnapCI8mn1dtoOrUG1H X-Received: by 2002:a17:906:8904:: with SMTP id fr4mr2372859ejc.136.1615363122606; Tue, 09 Mar 2021 23:58:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615363122; cv=none; d=google.com; s=arc-20160816; b=HQHLbCFBwHOpQtsqrh8U3uhz8g/pGDb3O/MHFzPL9RxPwqXTBN1KE9Pp89MMn5OxAY 6gYJte2GQMYdBoDAgvIYrC2x7+eOu2dBt16Y8nDBNG5oPSLN9zHIXLR/C3YPJ5ep5uSF nJG+n6QGI6xZ/yghqDnzjJ3EowwKuQ6Gqj19E/akQ0ngtgJ+eF6XDpMxgJp4htWwq5lG p/GdL8SmAhlhfHWh55QGcs1RyFul1gHs9AF1IYplgY7rp9qJDv2LIM0OcA+QG5cGOxBV qrcNAMHgWh0hTvrmcgC3cKWFSRqdtAaa3R40J3LJ3b/fiDNKc8b2zZrY/D1UKbw+I/Vi dYqg== 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=A7QIxRtK0dWLLOqmQlmpAZAH5Kyjk4LQKTk5SK5v5qw=; b=lWfMtcSRaQ7b3YuWTepHaK4EdIO8uzAepSMzOrnq9TPVH11l+RqLnIRsWJeTGRcDlT Sh5h/TfunHKWYVbERLzGwNP3tYLWJ86ZGQVXfZTdMRzbsOSil/VEYNfeOTIEWGtdnYEP EzEjlluQNAtX1SStTDuL+AhFygrDfrhS+mDhm6uM7j/O8KViJgQWBQd+oYDouLYGqTFi Cxt5J3qi2awVKneUYlDoSzf6ns3uWKekycUbHNK7WHCXuyC974t9fWjFw07N2U9NagoP i0UKcNjGhXQsQvtNr8E1jCvC4VfUPq1/hHQN1CVTxfJzS4OGlTpNjjcObsxAZIRSge8F IVUg== 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 s14si11248805edy.365.2021.03.09.23.58.20; Tue, 09 Mar 2021 23:58:42 -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 S230489AbhCJH5U (ORCPT + 99 others); Wed, 10 Mar 2021 02:57:20 -0500 Received: from mail.loongson.cn ([114.242.206.163]:33358 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229725AbhCJH4z (ORCPT ); Wed, 10 Mar 2021 02:56:55 -0500 Received: from localhost.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dxn_O3e0hg6KoXAA--.12657S4; Wed, 10 Mar 2021 15:56:46 +0800 (CST) From: Qing Zhang To: Huacai Chen , Jiaxun Yang , Thomas Bogendoerfer , Thomas Gleixner , Marc Zyngier Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Ming Wang Subject: [PATCH v4 2/7] MIPS: Loongson64: Distinguish firmware dependencies DTB/LEFI Date: Wed, 10 Mar 2021 15:56:34 +0800 Message-Id: <20210310075639.20372-3-zhangqing@loongson.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210310075639.20372-1-zhangqing@loongson.cn> References: <20210310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IIF 0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87 Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfU1a0PDUUUU X-CM-SenderInfo: x2kd0wptlqwqxorr0wxvrqhubq/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add DTB boot support, only support Loongson-2K1000 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. loongson_fw_interface will be used in the future. Signed-off-by: Jiaxun Yang Signed-off-by: Qing Zhang Tested-by: Ming Wang --- v3-v4: Standard submission of information Fix error handling .../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..43737401dc06 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, + LOONGSON_DTB, +}; + 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..ed280b73bf89 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 || (fdt_magic(fw_arg2) == FDT_MAGIC)) { + 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