Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp290097ybh; Tue, 17 Mar 2020 23:28:42 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuBOe7ir/mSrbLJ+nquJXOaNkCelV4GJaXwoVwqdBOFZmzgj583gbQKkXOU7pK1CKUi2jcE X-Received: by 2002:a05:6808:c8:: with SMTP id t8mr1910833oic.3.1584512921930; Tue, 17 Mar 2020 23:28:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584512921; cv=none; d=google.com; s=arc-20160816; b=I+mmKRHcJojvoiZdtTWyeDRyeTADhthvVnQO+VChlxuOrrPlY3tdckzf+n/8ioFtuL rGRyH1GLSgLgI0n57OoVqRI3C2N8GizGSngv7gfmXuCYb5QjqFRt8rd6yQ6tAyp8TkXA X5jf5gwMvSbec5anZFHMggybAO0Qbn5tREQThw9HCsFybHo6pFFQqQ6e1U1RumHOvjHW hfZomOrvCNN/dRyNf3tCgeB+ACZ45Wv32RnXd4z9zasmqr+E76SBqBSoIyAsK+vIPgXO aWO3222U5g3qJEj58yRyw87hQWselvR/OjtQ7TlmZOwyAePs9Jy86aQW67Nizk5GUuDw kz0g== 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=hAuy/ueuSQn9aO4qlqIkzQvGpLae3maBW3p1GTqU5gk=; b=Ra4mKMT31KaSV3RpLpQXBOliMiAhVVU/pitRANQUW6trwioRuVzb9Kz3XsphH6NxMs ZqbojH41STJwqdewOiH/ucxW0V8/AsBSmfzr+/qJYxamfMClcoGd118kaIy1vhuk/uWw Nvdx7aLXZ7hGflM8nL+MyK1mrLdxxqIZ5/hwwZZKQ+jzwhOKtY3n3tuuX9m4wsSxlAwV c5KVnlI8gzJEf02kjJYS6uB4Kd4pg8HAWOJ1DAsfJeShwVT2tUHfpBfeHJOVIiFT907y Dgw+pexkS5TsGCkbhEjLy4gnV61N66jg1A2HtXOq61eeEnAa9xnW9VqyeaGg3t3RrGMg abPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@flygoat.com header.s=mail header.b=KD0G8vnP; 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 w1si2982354otl.7.2020.03.17.23.28.31; Tue, 17 Mar 2020 23:28:41 -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=KD0G8vnP; 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 S1727281AbgCRG00 (ORCPT + 99 others); Wed, 18 Mar 2020 02:26:26 -0400 Received: from sender3-op-o12.zoho.com.cn ([124.251.121.243]:17815 "EHLO sender3-op-o12.zoho.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726478AbgCRG0Z (ORCPT ); Wed, 18 Mar 2020 02:26:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1584512726; 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=hAuy/ueuSQn9aO4qlqIkzQvGpLae3maBW3p1GTqU5gk=; b=KD0G8vnPFgd0LzLIpeXHv7cKhfHUDocWEmWXtPDQXrxYWCdq7yf/uedpLuvUoFrH mZb0Oek2GqiaZAQdp+k8qx9R1GSLTKRMSa5y3EddY6R0nL3Gy0lE2sbQ/YfYFenpcL0 /kLJlkZAb8UvVI8Utc02JAqAeiJeX1pL8yI3YNMI= Received: from localhost.localdomain (39.155.141.144 [39.155.141.144]) by mx.zoho.com.cn with SMTPS id 1584512724536640.9015939976849; Wed, 18 Mar 2020 14:25: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 , Ralf Baechle , Paul Burton , Allison Randal , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Message-ID: <20200318062102.8145-11-jiaxun.yang@flygoat.com> Subject: [PATCH v5 10/11] MIPS: Loongson64: Load built-in dtbs Date: Wed, 18 Mar 2020 14:20:38 +0800 X-Mailer: git-send-email 2.26.0.rc2 In-Reply-To: <20200318062102.8145-1-jiaxun.yang@flygoat.com> References: <20200318062102.8145-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. Co-developed-by: Huacai Chen Signed-off-by: Jiaxun Yang --- .../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