Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4977263ybb; Tue, 24 Mar 2020 08:42:38 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtl7owKFnClhD1UG2aEv9QAf+hvBEbEr7bTk7g08orsmgUScOHLZ1KgANpcrOTV+iUimf3q X-Received: by 2002:aca:bc56:: with SMTP id m83mr3679899oif.11.1585064558195; Tue, 24 Mar 2020 08:42:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585064558; cv=none; d=google.com; s=arc-20160816; b=FymiAeYLt+iEnwX9N5nl4cN576w/ZfYabxrb/BEYLZTQ2aNiij9ZpLV60rxE3r1DYq 7Vo/Rk3w9AnmUDGqS9tjYq6lOQD1IX0lqsw+U2BuE7JnLZQ28wVsTm8Mu+ArTWCDGiDM vUs1JvywwFBHydP6kE3zf7jazl2lHxnaznQ64TvB0+Ph/FwAVrDaqrY0U8Cu1gGyaBUT MvufYtbbGFLqyHnDwaIabn/MPFehHkARNF7eQdohcLNvbpgD92zb7TvNUUPMHG+j7Nw9 m00DIKlD/O+R8LPY5BWIOIM0BRWru67+jbnFamcMZu0nowOD/FOxwNsscl8sSzEJs/dO skrQ== 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=OQ5OE3w1viosmJrsXRBfnKypE5pS7SQGzAkYxUMxCIQZKk3BhLMdjOMfFgh/970Iz2 2hoSyB/m+Zez1sZuBPXANIHq0IhUSowJVcdneOBg+8uNQ+FmLYYP/HMuKPmZT50vLfqx U9i8vOurwuYqJOkicfeynjAo14lw8ytzHsBleFMOL8wsJaNhFEydAofUBjI146+y4fnn 0bbLG18o409Z39J7z2RquNNKkHlqEL/ZxTGudn8VRmyM2SL2Q77fccah12SrxWSZXfhK AWZ1klavHWkDKozvunxz/saqmitqFyAw3Aagida6A3S31jMM7t3T0Av2QKXZv+Bgi7Ld q2uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@flygoat.com header.s=mail header.b=c7DOg8nY; 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 50si5174283otv.259.2020.03.24.08.42.23; Tue, 24 Mar 2020 08:42:38 -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=c7DOg8nY; 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 S1728745AbgCXPl5 (ORCPT + 99 others); Tue, 24 Mar 2020 11:41:57 -0400 Received: from sender3-op-o12.zoho.com.cn ([124.251.121.243]:17814 "EHLO sender3-op-o12.zoho.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727881AbgCXPl5 (ORCPT ); Tue, 24 Mar 2020 11:41:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1585064367; 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=c7DOg8nYQ/PyEclChl4wZ15zbTHMIPL/8MT+IycvZO3UHtogcS1NtPkfxgU5itxY QpEnB11hzGHtqYB3Sy/LiS5CyXDPyvNgfKi43u4G0NACvrXsdWYxUAdfPBWeNfITvRd qfS561Ua3htnrUAy6WSKpSJJLDnZJdGWGHqK9Ykk= Received: from localhost.localdomain (39.155.141.144 [39.155.141.144]) by mx.zoho.com.cn with SMTPS id 1585064365864969.1587293558431; Tue, 24 Mar 2020 23:39:25 +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 , Greg Kroah-Hartman , Allison Randal , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Message-ID: <20200324153624.23109-11-jiaxun.yang@flygoat.com> Subject: [PATCH v6 10/11] MIPS: Loongson64: Load built-in dtbs Date: Tue, 24 Mar 2020 23:36:07 +0800 X-Mailer: git-send-email 2.26.0.rc2 In-Reply-To: <20200324153624.23109-1-jiaxun.yang@flygoat.com> References: <20200324153624.23109-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