Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp227667ybb; Tue, 24 Mar 2020 21:03:28 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtgOwP/u0jLr1guMkIF6lpq6p7WbB5kkD2A7MI5CXIK2FKDapcdLi8t1vluO6Aj/zyiKkBf X-Received: by 2002:aca:210c:: with SMTP id 12mr1119746oiz.0.1585109008384; Tue, 24 Mar 2020 21:03:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585109008; cv=none; d=google.com; s=arc-20160816; b=jY43gW7fL7BVAUiyIBUPmx2xcDg5cqfibLLcxlvoxS3BQNtxp67BlUWR641sPRKgyE HGLSbt370SA8ngOy8qRb/PvA2uo9ujgo4KV8aPE6a8uTa2ALli/iqQ62h6fqrZN2FFOt yVnoBMCSyMAlaE3F46eCzEtuKWb6yGPo3RUswRFU2lor7HfMMM1Ov9MQuVg7pZfg/NHg OpFNXr7Ysx8zQsyGTR3G5vUsqZI5Di7blSvreVTWjeevbs8B6+xHxDBZIAS3kj2KlZvv ktRrCYoFGSdZf0ef2D4nOcuRkfReWgnk+u9yqubGl5+IxtTs7MwQfJlIP/e1pB+0v+4x 61vA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:subject:message-id:cc:to:from :dkim-signature; bh=cLyI0BpamZw44VwG9Zfsq9MpkvbcqMXVy1374BYQT2Y=; b=v8FllqR0eF/1ralZryFXBFjYhhQRaMosPhzrCDsXEyuKgTbBeXrLHiBAG+95d5kgBP pCdZoKb/Mxd5pvNKQQ9gMhm9Wdq7a3nNSQFehfoGYKJoMFkkoYhegpBoOa6yfm+rl/dy yb2p52wpOYGEA6MzVpUQuzfVHw6SP+628avcPz6cf5T+sRBgj2YSV9zNVs1WjTCMTGMG P4+6CyWXN5zTcJSJlOgpJ2sD2AXgWeZz/+pFym5IxzjJaMfd87W/2pjlTIv+VGN7AK4H dPGPu3OlsBYNu2/DO4HeVXoP9rt72HylCXo39M+Aous4hSf59z26F7wJMmEONdSzlXhP LyJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@flygoat.com header.s=mail header.b=SFyAX5SD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p27si10531130ota.194.2020.03.24.21.03.16; Tue, 24 Mar 2020 21:03:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@flygoat.com header.s=mail header.b=SFyAX5SD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727290AbgCYECh (ORCPT + 99 others); Wed, 25 Mar 2020 00:02:37 -0400 Received: from sender3-op-o12.zoho.com.cn ([124.251.121.243]:17855 "EHLO sender3-op-o12.zoho.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725939AbgCYECg (ORCPT ); Wed, 25 Mar 2020 00:02:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1585108885; s=mail; d=flygoat.com; i=jiaxun.yang@flygoat.com; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=cLyI0BpamZw44VwG9Zfsq9MpkvbcqMXVy1374BYQT2Y=; b=SFyAX5SDD8yvS0iV6jyB6fgTB7gYXfumRFKrkkcbp+JPTNkjnCdp3pJNS7vfafJA uvn5cga2SfcX5qgmbYqmCdSn0jbWqpVL/xEpstH9snBNli2Q6gMRxNEc4bAEt3Moe60 uJoFgjLlERCXBy3O4vtXB/Snw1slrkx1mMZrCVTk= Received: from localhost.localdomain (39.155.141.144 [39.155.141.144]) by mx.zoho.com.cn with SMTPS id 1585108884023721.9200297881632; Wed, 25 Mar 2020 12:01:24 +0800 (CST) From: Jiaxun Yang To: linux-mips@vger.kernel.org Cc: Jiaxun Yang , Huacai Chen , Thomas Gleixner , Jason Cooper , Marc Zyngier , Rob Herring , Mark Rutland , Thomas Bogendoerfer , Mauro Carvalho Chehab , "David S. Miller" , Jonathan Cameron , Greg Kroah-Hartman , Andy Shevchenko , Allison Randal , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Message-ID: <20200325035537.156911-11-jiaxun.yang@flygoat.com> Subject: [PATCH v8 10/11] MIPS: Loongson64: Load built-in dtbs Date: Wed, 25 Mar 2020 11:55:03 +0800 X-Mailer: git-send-email 2.26.0.rc2 In-Reply-To: <20200325035537.156911-1-jiaxun.yang@flygoat.com> References: <20200325035537.156911-1-jiaxun.yang@flygoat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoCNMailClient: External Content-Type: text/plain; charset=utf8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Load proper dtb according to firmware passed parameters and CPU PRID. Signed-off-by: Jiaxun Yang Co-developed-by: Huacai Chen Signed-off-by: Huacai Chen --- .../asm/mach-loongson64/builtin_dtbs.h | 13 +++++++++++ .../include/asm/mach-loongson64/loongson.h | 1 + arch/mips/loongson64/env.c | 23 +++++++++++++++++++ arch/mips/loongson64/setup.c | 16 +++++++++++++ 4 files changed, 53 insertions(+) create mode 100644 arch/mips/include/asm/mach-loongson64/builtin_dtbs.h diff --git a/arch/mips/include/asm/mach-loongson64/builtin_dtbs.h b/arch/mi= ps/include/asm/mach-loongson64/builtin_dtbs.h new file mode 100644 index 000000000000..853c6d80887b --- /dev/null +++ b/arch/mips/include/asm/mach-loongson64/builtin_dtbs.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2019 Jiaxun Yang + * + * Built-in Generic dtbs for MACH_LOONGSON64 + */ + +#ifndef __ASM_MACH_LOONGSON64_BUILTIN_DTBS_H_ +#define __ASM_MACH_LOONGSON64_BUILTIN_DTBS_H_ + +extern u32 __dtb_loongson3_4core_rs780e_begin[]; +extern u32 __dtb_loongson3_8core_rs780e_begin[]; +#endif diff --git a/arch/mips/include/asm/mach-loongson64/loongson.h b/arch/mips/i= nclude/asm/mach-loongson64/loongson.h index a8fce112a9b0..fde1b75c45ea 100644 --- a/arch/mips/include/asm/mach-loongson64/loongson.h +++ b/arch/mips/include/asm/mach-loongson64/loongson.h @@ -25,6 +25,7 @@ extern const struct plat_smp_ops loongson3_smp_ops; /* loongson-specific command line, env and memory initialization */ extern void __init prom_init_memory(void); extern void __init prom_init_env(void); +extern void *loongson_fdt_blob; =20 /* irq operation functions */ extern void mach_irq_dispatch(unsigned int pending); diff --git a/arch/mips/loongson64/env.c b/arch/mips/loongson64/env.c index 0daeb7bcf023..2554ef11170d 100644 --- a/arch/mips/loongson64/env.c +++ b/arch/mips/loongson64/env.c @@ -17,6 +17,7 @@ #include #include #include +#include #include =20 u32 cpu_clock_freq; @@ -120,6 +121,28 @@ void __init prom_init_env(void) =09=09loongson_sysconf.cores_per_node - 1) / =09=09loongson_sysconf.cores_per_node; =20 +=09if ((read_c0_prid() & PRID_IMP_MASK) =3D=3D PRID_IMP_LOONGSON_64C) { +=09=09switch (read_c0_prid() & PRID_REV_MASK) { +=09=09case PRID_REV_LOONGSON3A_R1: +=09=09case PRID_REV_LOONGSON3A_R2_0: +=09=09case PRID_REV_LOONGSON3A_R2_1: +=09=09case PRID_REV_LOONGSON3A_R3_0: +=09=09case PRID_REV_LOONGSON3A_R3_1: +=09=09=09loongson_fdt_blob =3D __dtb_loongson3_4core_rs780e_begin; +=09=09=09break; +=09=09case PRID_REV_LOONGSON3B_R1: +=09=09case PRID_REV_LOONGSON3B_R2: +=09=09=09loongson_fdt_blob =3D __dtb_loongson3_8core_rs780e_begin; +=09=09=09break; +=09=09default: +=09=09=09break; +=09=09} +=09} + + +=09if (!loongson_fdt_blob) +=09=09pr_err("Failed to determine built-in Loongson64 dtb\n"); + =09loongson_sysconf.pci_mem_start_addr =3D eirq_source->pci_mem_start_addr= ; =09loongson_sysconf.pci_mem_end_addr =3D eirq_source->pci_mem_end_addr; =09loongson_sysconf.pci_io_base =3D eirq_source->pci_io_start_addr; diff --git a/arch/mips/loongson64/setup.c b/arch/mips/loongson64/setup.c index 4fd27f4f90ed..6fe3ffffcaa6 100644 --- a/arch/mips/loongson64/setup.c +++ b/arch/mips/loongson64/setup.c @@ -8,9 +8,15 @@ =20 #include #include +#include +#include + +#include =20 #include =20 +void *loongson_fdt_blob; + static void wbflush_loongson(void) { =09asm(".set\tpush\n\t" @@ -27,4 +33,14 @@ EXPORT_SYMBOL(__wbflush); =20 void __init plat_mem_setup(void) { +=09if (loongson_fdt_blob) +=09=09__dt_setup_arch(loongson_fdt_blob); +} + +void __init device_tree_init(void) +{ +=09if (!initial_boot_params) +=09=09return; + +=09unflatten_and_copy_device_tree(); } --=20 2.26.0.rc2