Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp296642ybb; Fri, 3 Apr 2020 02:56:51 -0700 (PDT) X-Google-Smtp-Source: APiQypIr78hpT1A2wgV0x/PAT0sNSaJy/xiwSLCXvyNp+AKnnldkS9Sg0C6RFJFgG2qkLI1AMZl0 X-Received: by 2002:aca:4a86:: with SMTP id x128mr2396326oia.29.1585907811324; Fri, 03 Apr 2020 02:56:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585907811; cv=none; d=google.com; s=arc-20160816; b=d1oAzwmKHCq89hshAVTXLv70MWUTAb/g3iITUsrO2g8O/rYk29rZl+sheMqT5gAYcw sXsjAart72jDFAzGGVXOnu//nbFZ2ftawrw+sRcC7hWELqwpzy5NrQlcb+lRwo674kxj a1qkYGfdVtxZsJflTUFEC7xbjYaj7G1STgqgYjYPAz5wdDQ5PaTB36JLwEu4f3oqBkuw IHjdFPmo4BC3whgEDAaTE7pJ+O3+b9voyK4hQiMMr8lE3QGzuNadFk17WDMxquXnzhN3 Z/28nkPTiiJzseHsRSATXj6h7Xp02UZzLEdgykLsRp8P/yvCYXmE6vOkJtg1b4m1Morf X36A== 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=B+gioxWQ4En4T8qA/hsDVIQXb8yCO1vcPk12ohUkq5E=; b=pTKltTSOEJIFv2LGthDvvJ3UF+G153seK4ImJLRnAkP2lErzSLWlTJaeHtJI7l4XII P6zwKaZqn3gMl3CT5Pogrd//MnSIckwzl0jUGL3fwjI3TYfYKGAg+WGhcQKQe1kpn+GZ mokGVL24LtywhHHHiFCt68/PrJKECPzcUA+eqO6poOb4t82Hglpe/pYghQB3gmPyy5Zt SMRxGiReM1sMM7AC8mWIpJjv1CLYceKHsBTNauemTmxKKGhfSnYQgWAe3FGZFNBvJMz0 zwomooDB48boP94wtXM9r//KyYj3q3bgyoSYDDqKCEoDJsI72gmCh42eOtGLC3eaHGAi B2Sg== 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 x30si4067246otj.27.2020.04.03.02.56.39; Fri, 03 Apr 2020 02:56:51 -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 S2390572AbgDCJaH (ORCPT + 99 others); Fri, 3 Apr 2020 05:30:07 -0400 Received: from mail.loongson.cn ([114.242.206.163]:42908 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727431AbgDCJaG (ORCPT ); Fri, 3 Apr 2020 05:30:06 -0400 Received: from linux.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9DxX2gQAodeHGAjAA--.150S3; Fri, 03 Apr 2020 17:29:58 +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 v4 1/3] MIPS: Loongson: Get host bridge information Date: Fri, 3 Apr 2020 17:29:49 +0800 Message-Id: <1585906191-26037-2-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1585906191-26037-1-git-send-email-yangtiezhu@loongson.cn> References: <1585906191-26037-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf9DxX2gQAodeHGAjAA--.150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U0xZFpf9x0JU39NfUUUUU= 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 host bridge configuration space to get the vendor ID and device ID of host bridge, and then we can distinguish various types of host bridge such as LS7A or RS780E. Signed-off-by: Tiezhu Yang --- v3: - Modify the macro definition HOST_BRIDGE_CONFIG_ADDR and add comment to make it easy to read. - Use PCI_VENDOR_ID_LOONGSON in pci_ids.h instead of 0x0014 PCI_VENDOR_ID_LOONGSON depends on the mainline tree's commit: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9acb9fe18d86 v4: - Use LS7A instead of Loongson 7A1000 in the description - Use LS7A or ls7a instead of LS7A1000 or ls7a1000 in the code arch/mips/include/asm/mach-loongson64/boot_param.h | 6 ++++++ arch/mips/loongson64/env.c | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/arch/mips/include/asm/mach-loongson64/boot_param.h b/arch/mips/include/asm/mach-loongson64/boot_param.h index 2ed483e..fc9f14b 100644 --- a/arch/mips/include/asm/mach-loongson64/boot_param.h +++ b/arch/mips/include/asm/mach-loongson64/boot_param.h @@ -192,6 +192,11 @@ struct boot_params { struct efi_reset_system_t reset_system; }; +enum loongson_bridge_type { + RS780E = 1, + LS7A = 2 +}; + struct loongson_system_configuration { u32 nr_cpus; u32 nr_nodes; @@ -200,6 +205,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 2554ef1..71f4aaf 100644 --- a/arch/mips/loongson64/env.c +++ b/arch/mips/loongson64/env.c @@ -14,12 +14,15 @@ * Author: Wu Zhangjin, wuzhangjin@gmail.com */ #include +#include #include #include #include #include #include +#define HOST_BRIDGE_CONFIG_ADDR ((void __iomem *)TO_UNCAC(0x1a000000)) + u32 cpu_clock_freq; EXPORT_SYMBOL(cpu_clock_freq); struct efi_memory_map_loongson *loongson_memmap; @@ -43,6 +46,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; @@ -178,4 +183,17 @@ 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); + + /* Read the ID of PCI host bridge to detect bridge type */ + id = readl(HOST_BRIDGE_CONFIG_ADDR); + vendor = id & 0xffff; + device = (id >> 16) & 0xffff; + + if (vendor == PCI_VENDOR_ID_LOONGSON && device == 0x7a00) { + pr_info("The bridge chip is LS7A\n"); + loongson_sysconf.bridgetype = LS7A; + } else { + pr_info("The bridge chip is RS780E or SR5690\n"); + loongson_sysconf.bridgetype = RS780E; + } } -- 2.1.0