Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp181332pxb; Fri, 5 Mar 2021 18:49:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJxe9ACoHlamsam1/kDXefxmYZ3reK8iJqFJMTvw6sEy/P6AVE5qnux1xdE5eD8SuJMBS30I X-Received: by 2002:a17:906:3883:: with SMTP id q3mr5091691ejd.160.1614998962751; Fri, 05 Mar 2021 18:49:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614998962; cv=none; d=google.com; s=arc-20160816; b=Rpn9WJ2+/AX/7GfBvNEygBBOwoEDhVRDvBOc1yRDJN75ULI+LNwJfQF+5RlPZfrEv7 uVjN/7y9WyrlT1dLcxhWQTawWhOYvo+me9GjhU04JUTZPb3P9PO3acRpqT/MRRAkis5R fOll42T+oL6XFlzsQbRBE1SO5tyF9q1KTfb3Mj2dUnt/0CElsLzO3UkXXzM4Qi5hNZ/m qwWPSxSwr+Ynrhx8Np6528XcEI80Byx3J1KZWgLBsNUfSDyXf6C4uJRd9d7dxQzAh+di Nsb7Gcv2ivWqkd90IgqWSkGVSrUE7y6KictLyJVLHEDdTshR978n3UVTzX33KHKgz//q IaZQ== 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=FB0/J9/a3ysTb1YKW1zpgc2g2pzo2zA5Al3ZPNtlNHw=; b=0YTkbeGiUZDzbZoiIw0a+yofpJ3SuC86u5JvP+onNd5s4+J7DH8AJpjavejgn/38V4 Qvgbb0qVUOi3BZQ3ZRxUOQyj/opE2w9Db1DuubCU22KWVZwYc1/CaHGG4HgJdEVeNrox +YscJezaQLfDbXB6BWqIoiorc60jItkcz/2Bjqw8m80gBMhSWjsWjOT/zMPVseit67KO JbPiDw7TciqJeUlyZWBYAUOSNm6+TbHFj5mjuBaVXGevxe5hjpbP1NR7CTgricZadiE0 96D4IgH18WYzF6ObE0uT6X/wjaoNEKJz/rYAt5C1+1nfnkCOVJLT9F7OhrkIJBRXKEzV ipUA== 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 v7si2675431edj.572.2021.03.05.18.49.00; Fri, 05 Mar 2021 18:49:22 -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 S230300AbhCFChF (ORCPT + 99 others); Fri, 5 Mar 2021 21:37:05 -0500 Received: from mail.loongson.cn ([114.242.206.163]:52710 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229818AbhCFCgq (ORCPT ); Fri, 5 Mar 2021 21:36:46 -0500 Received: from localhost.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9DxH_Gx6kJgzxwVAA--.9772S4; Sat, 06 Mar 2021 10:36:39 +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, wangming01@loongson.cn Subject: [PATCH v3 2/7] MIPS: Loongson64: Distinguish firmware dependencies DTB/LEFI Date: Sat, 6 Mar 2021 10:36:28 +0800 Message-Id: <20210306023633.9579-3-zhangqing@loongson.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210306023633.9579-1-zhangqing@loongson.cn> References: <20210306023633.9579-1-zhangqing@loongson.cn> MIME-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I8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I 8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfU8jjgUUUUU 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.loongson_fw _interface will be used in the future. Signed-off-by: Jiaxun Yang Signed-off-by: Qing Zhang --- v2-v3: No change .../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..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