Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3095288pxf; Mon, 15 Mar 2021 00:51:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAjHyt339MOJqDC7nrjeUlvTfYeRSvfLbPZyRZCym2jdLLOJXmthRByNJJoDgydVcq6B1G X-Received: by 2002:a05:6402:27d4:: with SMTP id c20mr28848812ede.271.1615794716875; Mon, 15 Mar 2021 00:51:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615794716; cv=none; d=google.com; s=arc-20160816; b=TXjWPSmzSb9ogfloCOm6YG87vvr6w/FI3tKb7wsDyBzZFj9anr/O4bDta4k773JbpI Z9g9SSOlnK6rZU1NaKIre2oFa7WxtQCvQEtGGLuZmeHUA4XQDXqP4usRTDak7RysTl7N AtJNKORNhyfsPMII6D/qZlihNxVi47D3+Yk5mv46DzGz6c3zsk2NROZSbmD3WMhwXxyP OTfbZQNINjg1vxvMgrpPePLhsMavOBGgVdgXLtjrduRzyUEYF2XSaIJZduHHZ393/2l+ GfYVj/7ywotIZeqnMtl9gRNxZhuTQwIQrSmPnp9gVebeQ5rU+G4MJ6ZM5BDNGTfyOjxT G/HQ== 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=ad7AYUqWBbuud0ouE/asjXq1eEi0HZ+XFAwEBkmBQFc=; b=Japp4m7EVEcMCSNGEEf2CSOPMI2+7wFIkc2+Jxqqvkb3LOrqN8X2lvcWxH8oX9M1Zq cPFBPmJLJLbSFbkoHlA8RRCI4YFQ2Ssc6HeMZHDqPUC9sO8Gbg+cmmusNNNsBuK5fzQN HZT0xf82FnUjKt52xAUXAE9ra3D8nFopxbyW5ITkG6M49fXm37aWJDd9bZvfOczPJc9Q ssOUI1LHsjWOd1ynXmkA0I4P98JicIqwUQZYrZt72xjm9dun5PMUrY1DIIkQL0AuyvjS shgS4XMOl5e0/VY8Xa/oijdYb/+NfJXUH9sBse5cNZqWoTIzrD2GFaFUW+vE1BAXmTLM a6BA== 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 v11si10234172eje.681.2021.03.15.00.51.34; Mon, 15 Mar 2021 00:51:56 -0700 (PDT) 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 S230513AbhCOHuu (ORCPT + 99 others); Mon, 15 Mar 2021 03:50:50 -0400 Received: from mail.loongson.cn ([114.242.206.163]:41268 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230270AbhCOHuU (ORCPT ); Mon, 15 Mar 2021 03:50:20 -0400 Received: from localhost.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9AxydSsEU9gcqMZAA--.1167S4; Mon, 15 Mar 2021 15:50:11 +0800 (CST) From: Qing Zhang To: Thomas Bogendoerfer , Thomas Gleixner , Marc Zyngier , Huacai Chen , Jiaxun Yang Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Ming Wang Subject: [PATCH v5 2/7] MIPS: Loongson64: Distinguish firmware dependencies DTB/LEFI Date: Mon, 15 Mar 2021 15:49:59 +0800 Message-Id: <20210315075004.15465-3-zhangqing@loongson.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210315075004.15465-1-zhangqing@loongson.cn> References: <20210315075004.15465-1-zhangq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IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87 Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfUUksqDUUUU 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 --- v4-v5: - Remake the patch based on the latest changes arch/mips/include/asm/mach-loongson64/loongson.h | 9 ++++++++- arch/mips/loongson64/env.c | 13 ++++++++++++- arch/mips/loongson64/init.c | 16 ++++++++++++++-- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/arch/mips/include/asm/mach-loongson64/loongson.h b/arch/mips/include/asm/mach-loongson64/loongson.h index 6189deb188cf..f7c3ab6d724e 100644 --- a/arch/mips/include/asm/mach-loongson64/loongson.h +++ b/arch/mips/include/asm/mach-loongson64/loongson.h @@ -12,8 +12,14 @@ #include #include +enum loongson_fw_interface { + LOONGSON_LEFI, + LOONGSON_DTB, +}; + /* machine-specific boot configuration */ struct loongson_system_configuration { + enum loongson_fw_interface fw_interface; u32 nr_cpus; u32 nr_nodes; int cores_per_node; @@ -41,7 +47,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 1821d461b606..c8bb75d58f17 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