Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2695396ybl; Sun, 12 Jan 2020 00:24:14 -0800 (PST) X-Google-Smtp-Source: APXvYqzzL0ByZk3cwC2ndcxQd2rwez9T72ty45lw3fNN3xZsA1FyNsiOGBWemzOcP+ChkmfYe2bx X-Received: by 2002:a9d:7:: with SMTP id 7mr8732584ota.26.1578817454768; Sun, 12 Jan 2020 00:24:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578817454; cv=none; d=google.com; s=arc-20160816; b=EP8bdlD2mwcr+wuKi14yBkmMwD1wWv9gwacoiWsDrlPJ6wbHkkh5ouDbggxwFxsBfs 9qkRpRZQsLdMvutSw8+s9q7BQLBOaXqLQG0nrIv76OECl2jH6ZaWz1GQSo5ybEtXj8+T 1g28IY1CVGq6pDmFmsjSDUtxIpZygNiGoe4T+aHbyihL1LXH85gQhR5GrLZFDorzaV32 qJIgGbLVJ8g5T/dwaxpe3bFvbrKTu5CwcGEwl8MrQFPSjMyST5fwryjBNpfHguLqGAOC dTAoGGCTW0CNkn6yLcSnZnkGwvSzEoe32ADaer8ob3/HjvwQ8DzevcZuRzArGC+ONyc1 9QJg== 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:message-id:date:subject:cc:to:from :dkim-signature; bh=ZF4UnfCbDyKUT35YCijKiYicTuas0pwMkPes6YsV4VA=; b=yZIFQjQDQ4GFQW/V55k/SjxLgouL2kA0o5zSi8+WR5EXoMaKjU/mLDEYQhQXsjEOYR ZuYVyMvhT+/u3SWvuGhotomD5cltORUpUXnsUbwD2acQNh0b+idvaSAw00LPCE4VyRZz w+G/dNpoxn+dK9fb9rN3Ve/Wegn6cdXJUnT9wsZFd6a++qOXjUpd9phENovD4GsErhrt DdCChGFWd9w+J9QY1C4G1tMkKYaasHd1k/WZxjEneqLT3pNamqCQsrXWQ6mdN5GTckfN 5Qv+J3eAQE9F+mEtixC+QDuNvme6W8FWVPAxR05jAkDiwJMSNO2tl+2NaQoLvKTZ2by0 7APA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@flygoat.com header.s=mail header.b="rGO//L39"; 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 z1si5059663otq.21.2020.01.12.00.24.03; Sun, 12 Jan 2020 00:24:14 -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="rGO//L39"; 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 S1732455AbgALIXC (ORCPT + 99 others); Sun, 12 Jan 2020 03:23:02 -0500 Received: from forward102p.mail.yandex.net ([77.88.28.102]:57625 "EHLO forward102p.mail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732371AbgALIXB (ORCPT ); Sun, 12 Jan 2020 03:23:01 -0500 Received: from forward101q.mail.yandex.net (forward101q.mail.yandex.net [IPv6:2a02:6b8:c0e:4b:0:640:4012:bb98]) by forward102p.mail.yandex.net (Yandex) with ESMTP id 7407B1D40C97; Sun, 12 Jan 2020 11:16:37 +0300 (MSK) Received: from mxback1q.mail.yandex.net (mxback1q.mail.yandex.net [IPv6:2a02:6b8:c0e:39:0:640:25b3:aea5]) by forward101q.mail.yandex.net (Yandex) with ESMTP id 6F23ACF40007; Sun, 12 Jan 2020 11:16:37 +0300 (MSK) Received: from vla1-ee05250d997a.qloud-c.yandex.net (vla1-ee05250d997a.qloud-c.yandex.net [2a02:6b8:c0d:3495:0:640:ee05:250d]) by mxback1q.mail.yandex.net (mxback/Yandex) with ESMTP id Q7ZMkSEcVy-Gb8Gorow; Sun, 12 Jan 2020 11:16:37 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; s=mail; t=1578816997; bh=ZF4UnfCbDyKUT35YCijKiYicTuas0pwMkPes6YsV4VA=; h=In-Reply-To:Subject:To:From:Cc:References:Date:Message-Id; b=rGO//L39Zj4/svE77D63WP2DeNDcMUQVQbRvIeL4hYCZtYiRD1yH6liD4+RE6Uvt3 U71+gxf/Ob8xe4zbGBrphlZHNVDmCBJr7Dll8MPqpvATeB3NDWtohrz8+JTOEl4eTz jNoMDCDTXIxiFEHwj7/2gjmxXkSyhq3fB7j8+iDQ= Authentication-Results: mxback1q.mail.yandex.net; dkim=pass header.i=@flygoat.com Received: by vla1-ee05250d997a.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id 3jM5RHRYtF-GPV4YZPD; Sun, 12 Jan 2020 11:16:30 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) From: Jiaxun Yang To: linux-mips@vger.kernel.org Cc: chenhc@lemote.com, paul.burton@mips.com, tglx@linutronix.de, jason@lakedaemon.net, maz@kernel.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, mark.rutland@arm.co, devicetree@vger.kernel.org, Jiaxun Yang Subject: [PATCH v3 10/10] MIPS: Loongson64: Load built-in dtbs Date: Sun, 12 Jan 2020 16:14:16 +0800 Message-Id: <20200112081416.722218-11-jiaxun.yang@flygoat.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200112081416.722218-1-jiaxun.yang@flygoat.com> References: <20200112081416.722218-1-jiaxun.yang@flygoat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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/mips/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/include/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; /* 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 u32 cpu_clock_freq; @@ -120,6 +121,28 @@ void __init prom_init_env(void) loongson_sysconf.cores_per_node - 1) / loongson_sysconf.cores_per_node; + if ((read_c0_prid() & PRID_IMP_MASK) == PRID_IMP_LOONGSON_64C) { + switch (read_c0_prid() & PRID_REV_MASK) { + case PRID_REV_LOONGSON3A_R1: + case PRID_REV_LOONGSON3A_R2_0: + case PRID_REV_LOONGSON3A_R2_1: + case PRID_REV_LOONGSON3A_R3_0: + case PRID_REV_LOONGSON3A_R3_1: + loongson_fdt_blob = __dtb_loongson3_4core_rs780e_begin; + break; + case PRID_REV_LOONGSON3B_R1: + case PRID_REV_LOONGSON3B_R2: + loongson_fdt_blob = __dtb_loongson3_8core_rs780e_begin; + break; + default: + break; + } + } + + + if (!loongson_fdt_blob) + pr_err("Failed to determine built-in Loongson64 dtb\n"); + loongson_sysconf.pci_mem_start_addr = eirq_source->pci_mem_start_addr; loongson_sysconf.pci_mem_end_addr = eirq_source->pci_mem_end_addr; loongson_sysconf.pci_io_base = 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 @@ #include #include +#include +#include + +#include #include +void *loongson_fdt_blob; + static void wbflush_loongson(void) { asm(".set\tpush\n\t" @@ -27,4 +33,14 @@ EXPORT_SYMBOL(__wbflush); void __init plat_mem_setup(void) { + if (loongson_fdt_blob) + __dt_setup_arch(loongson_fdt_blob); +} + +void __init device_tree_init(void) +{ + if (!initial_boot_params) + return; + + unflatten_and_copy_device_tree(); } -- 2.24.1