Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3265262ybb; Sun, 22 Mar 2020 19:59:57 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtWzgsm8G0rV91qJzLa28U4iILnf2zlUnlTRH4c837Mcwo/CZQFvTvQZnQGMSSptpqBG7OA X-Received: by 2002:a9d:5ad:: with SMTP id 42mr17171972otd.231.1584932397785; Sun, 22 Mar 2020 19:59:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584932397; cv=none; d=google.com; s=arc-20160816; b=uYv/XPZZLpFu9n/AVheTixt2F93alWayaOI+Fy0u09wCDMSvRlrK2J1zq1s8OF/bs5 UuItMBC3KOW0QC7ljECMMd+Gu3vZ69cQ5NvSAyX8TlExJij8DkAh92Y5wfEJg21U7vm6 dVwXcoSKX9tlIaArU0y6asCLPV53If/jD9N4J54/TJ5zZlbV/B92XLEkxsIWN0ZDcI+s p6t5zwgx6mSY8DHz6ZhYIivlCTeT8UDHET/vwKY3rpbTA4LjUOUDMR97uYoJi4iCo1iu X72iHXNay8DHlamVbe2wevABb2y20c4r3UKoZfAasQSchBLJBswR1LMN90e/COEiUDPq OOlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=GDOoXbMoQtZ8dtqaDxPPDsCroT/rO5vYYD1KYDrNa0I=; b=DtVGC9jtp0enik7JFf6KFvhYW4iPZ5DPFoQ+oslDzkzsbM8N0eF1Ih15Wo0gCVE1Rz +6mxN++bugJ8gWjGqwrHnlB4rLqvfBkeryMpiwy/n3d9RpM3kJVA5jq8QS/oFxwOsTwA a1//WS2TkCIVLec1qhtliHMoJNzEfLGVHpYLie6lZ9cvNsQmcYUDKMFrDYWXl6++7AQ3 EpjhvN5LodwYWs5mtcd50ZtCRGCY+deVbhcgORUiPoasKPwse9lSF8n9XVJS0HFS8yFD L7uTt/mJtILaII3zoo8i4j0ovQSI0KJaWadse2pFWPUQ/WXwRxZoaPd9KF4AqycWdsYM T58A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k26si6910995otr.68.2020.03.22.19.59.45; Sun, 22 Mar 2020 19:59:57 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727188AbgCWC7Z (ORCPT + 99 others); Sun, 22 Mar 2020 22:59:25 -0400 Received: from mail.loongson.cn ([114.242.206.163]:56014 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727112AbgCWC7Y (ORCPT ); Sun, 22 Mar 2020 22:59:24 -0400 Received: from linux.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9AxP+gDJnhedaseAA--.407S3; Mon, 23 Mar 2020 10:59:17 +0800 (CST) From: Tiezhu Yang To: Thomas Bogendoerfer , Huacai Chen , Jiaxun Yang Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Xuefeng Li Subject: [PATCH v2 1/3] MIPS: Loongson: Get host bridge information Date: Mon, 23 Mar 2020 10:59:13 +0800 Message-Id: <1584932355-3642-2-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1584932355-3642-1-git-send-email-yangtiezhu@loongson.cn> References: <1584932355-3642-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf9AxP+g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xVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUa-erUUUUU= X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Read the address of HyperTransport Configuration Space to get the vendor ID and device ID of bridge chip, and then we can distinguish various types of bridge chip such as Loongson 7A1000 or AMD RS780E. Signed-off-by: Tiezhu Yang --- arch/mips/include/asm/mach-loongson64/boot_param.h | 6 ++++++ arch/mips/loongson64/env.c | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/arch/mips/include/asm/mach-loongson64/boot_param.h b/arch/mips/include/asm/mach-loongson64/boot_param.h index 8c286be..5e8c70d 100644 --- a/arch/mips/include/asm/mach-loongson64/boot_param.h +++ b/arch/mips/include/asm/mach-loongson64/boot_param.h @@ -190,6 +190,11 @@ struct boot_params { struct efi_reset_system_t reset_system; }; +enum loongson_bridge_type { + RS780E = 1, + LS7A1000 = 2 +}; + struct loongson_system_configuration { u32 nr_cpus; u32 nr_nodes; @@ -198,6 +203,7 @@ struct loongson_system_configuration { u16 boot_cpu_id; u16 reserved_cpus_mask; enum loongson_cpu_type cputype; + enum loongson_bridge_type bridgetype; u64 ht_control_base; u64 pci_mem_start_addr; u64 pci_mem_end_addr; diff --git a/arch/mips/loongson64/env.c b/arch/mips/loongson64/env.c index 0daeb7b..42542c7 100644 --- a/arch/mips/loongson64/env.c +++ b/arch/mips/loongson64/env.c @@ -19,6 +19,8 @@ #include #include +#define HT1_LO_BUS_CONFIG_BASE 0x90000efdfe000000 + u32 cpu_clock_freq; EXPORT_SYMBOL(cpu_clock_freq); struct efi_memory_map_loongson *loongson_memmap; @@ -42,6 +44,8 @@ void __init prom_init_env(void) struct system_loongson *esys; struct efi_cpuinfo_loongson *ecpu; struct irq_source_routing_table *eirq_source; + u32 id; + u16 vendor, device; /* firmware arguments are initialized in head.S */ boot_p = (struct boot_params *)fw_arg2; @@ -155,4 +159,16 @@ void __init prom_init_env(void) memcpy(loongson_sysconf.sensors, esys->sensors, sizeof(struct sensor_device) * loongson_sysconf.nr_sensors); pr_info("CpuClock = %u\n", cpu_clock_freq); + + id = readl((u32 *)HT1_LO_BUS_CONFIG_BASE); + vendor = id & 0xffff; + device = (id >> 16) & 0xffff; + + if (vendor == 0x0014 && device == 0x7a00) { + pr_info("The bridge chip is Loongson 7A1000\n"); + loongson_sysconf.bridgetype = LS7A1000; + } else { + pr_info("The bridge chip is AMD RS780E or SR5690\n"); + loongson_sysconf.bridgetype = RS780E; + } } -- 2.1.0