Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1472086ybv; Thu, 20 Feb 2020 21:17:01 -0800 (PST) X-Google-Smtp-Source: APXvYqxlsccLnGQd/1l2r/O13yeK3YD3ddnCWf6DHJNk03dj/LsMJ/gyIc1lAtx1GuQDQGFhlT89 X-Received: by 2002:a05:6830:114f:: with SMTP id x15mr25757783otq.291.1582262221431; Thu, 20 Feb 2020 21:17:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582262221; cv=none; d=google.com; s=arc-20160816; b=sb8qw7Q6kUdCIA7SqMqN/JtyTF7e6tFrxSh2raot3hPx+XYOoBxWwTIY3YGhssXyM2 UgzGOKZ2QUZvyDrYYIaE3AP36IcvFU05CqHn5y8Z4DUFNZSMbXCa7kX7wB+6P9x37D4e 1odFtPBO0iJ3nb6c3OPeYcvofn1I41M2F6GnDVYVyP6ygpas7f9nM+0voUxSo9qp1AGF bc6YV0taeAQWQrSEdsfB5W1EZcsubi85iyeOksSDRX6tHCO7/VL21hRIxY0wyod6Gf+u 12y6svu479fiBsNvVtV4M9/30zcSY2TAsAk61OuHpyzrfRshRdbSS66rAuHX59fibh0U wGew== 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=GMsmbrI9/BLBWFuYIg+sygdLa2erlXzlYRX1a5u/aA0=; b=t+sU0jFNxhIMeR9IIZUZTluDt/MzeZOtcmCSfGMX3Om52li+m2r5bT2NbeJU+BtFC6 U6Xl0QKdjTmdSuwWynGdemwdZUYlpIxBO6+YjKD4FmILlzR3NhE/rMmXQ/IX9vPcw+Wm 8DsW2bCyoYn0zsQgLaVTRoqwgwgLNJs1cHRt1xaE7XXeiuI3dXQvm1xOvFjzqD7NLrad 82dYYZvfdkyPdtEe3aUYzEiPmD3D9xF9uO20Rk40foaQXjWltHKSNIyTC4WGt7r27l/y BcoSpWqRtj4QqJIkoXpkAPKPIYO94efsAnGfmHdkYYc2BReWTM/D44/CXl5dxdQncG74 gyBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@flygoat.com header.s=mail header.b=aE4+C2Ry; 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 j2si970704otk.164.2020.02.20.21.16.49; Thu, 20 Feb 2020 21:17:01 -0800 (PST) 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=aE4+C2Ry; 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 S1726287AbgBUFQe (ORCPT + 99 others); Fri, 21 Feb 2020 00:16:34 -0500 Received: from sender3-op-o12.zoho.com.cn ([124.251.121.243]:17850 "EHLO sender3-op-o12.zoho.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726084AbgBUFQd (ORCPT ); Fri, 21 Feb 2020 00:16:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1582262039; 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=GMsmbrI9/BLBWFuYIg+sygdLa2erlXzlYRX1a5u/aA0=; b=aE4+C2RyPQ1+iVt2OeKlwdP0ZLsBN5bX5MKPwv0wkdmxNOpbvWfU7WSZWFsZWdQn iL8dvcAIvNgqiJ8/l6NMMgQBz4DaE4mE9ZPCRHBkX+AYqK6ZCQ4oxipAQjyqEbm6ZAp jfwU7qK3Vl1z1wSGf9yy/Z8vQodsLpbheMSUa+Q8= Received: from localhost.localdomain (39.155.141.144 [39.155.141.144]) by mx.zoho.com.cn with SMTPS id 1582262037275559.787205491624; Fri, 21 Feb 2020 13:13:57 +0800 (CST) From: Jiaxun Yang To: linux-mips@vger.kernel.org Cc: Jiaxun Yang , Thomas Gleixner , Jason Cooper , Marc Zyngier , Rob Herring , Mark Rutland , Ralf Baechle , Paul Burton , Huacai Chen , Greg Kroah-Hartman , Allison Randal , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Message-ID: <20200221050942.507775-10-jiaxun.yang@flygoat.com> Subject: [PATCH v4 09/10] MIPS: Loongson64: Load built-in dtbs Date: Fri, 21 Feb 2020 13:09:24 +0800 X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200221050942.507775-1-jiaxun.yang@flygoat.com> References: <20200221050942.507775-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 --- .../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.25.0