Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4661058ybb; Tue, 24 Mar 2020 02:59:21 -0700 (PDT) X-Google-Smtp-Source: ADFU+vs4w3G8XhPH2kA/NCwB39AQqnaXDZ8beEESoSjHNKo4rGWFEj9z7rD8pBRHmJwIJ6G7BlU2 X-Received: by 2002:a9d:4f0:: with SMTP id 103mr20763300otm.336.1585043961013; Tue, 24 Mar 2020 02:59:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585043961; cv=none; d=google.com; s=arc-20160816; b=SNL1tN/dbxFTmjx2MP0uNdRqQfUlR0CR2e1kzR5NfPn/YeuPqAc/k5VNsmJWM9YtbQ VLIJHCjHdKm2qMt2SB1aywKXuzdw8RTwPSovDXB8omUodEQcd8HFP4e4yj1bV7UWmh+f dWvQnYzXWcRN/TB4jlejV3ZXBnTYyB5P2mZvxheRaRJn2/vuW3s7wCIgi6YtLwShcVRh td5yCQYpJE7EhrBHbsycxV/ExAN0a1rclvLF7t22EpgzekEUyWr8axwpT7AXeJSaajmx cnbQtXXIkwu7YGhnmZkTLrAGVDgFZUtbiKfDsEddhepeicrIKAHJX0N3EfihlSC22bam EjUA== 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:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=wwSVbrz5oFAR6EnjJbLDQmrAcs8HSCW1+Rd1ihO9px4=; b=sAmc7FnsV1sER+wWDL0Ip//snH5LTGGXycoSWxinBriqwU43xx3kbFrhmJ4MmXVWN8 hnHzO1nR9NkOH4HfogsCoGR9KWbiPLwbAPlLTYcI0N5hI3c77yrOcyqNwS9xobK5IYza FKGxQGtfmxrNcNfm9gNB6D+6e5EU5ckseCrt5KG31m+Opj1qUBFVdpCUSQ6BK5gfyqKn +WQ0lJ1RM2Xol9cdzd7gZ/zAnPhX/WM0JysLgNWZWy45+DP0aAK+enevvEb3xrTyq05h MpHrLnZZwSFFCftzj6UprfYP9lkmbSHc+KE5b+21w1Uoyj+wnJuZh0CIrr7jPVUzSMaP FGKw== 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 a66si8437573otc.172.2020.03.24.02.59.08; Tue, 24 Mar 2020 02:59:21 -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 S1727063AbgCXJ6l (ORCPT + 99 others); Tue, 24 Mar 2020 05:58:41 -0400 Received: from mail.loongson.cn ([114.242.206.163]:43054 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726563AbgCXJ6k (ORCPT ); Tue, 24 Mar 2020 05:58:40 -0400 Received: from [10.130.0.79] (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9DxT2nJ2XlehHIfAA--.11S3; Tue, 24 Mar 2020 17:58:35 +0800 (CST) Subject: Re: [PATCH v2 1/3] MIPS: Loongson: Get host bridge information To: Jiaxun Yang , Thomas Bogendoerfer , Huacai Chen References: <1584932355-3642-1-git-send-email-yangtiezhu@loongson.cn> <1584932355-3642-2-git-send-email-yangtiezhu@loongson.cn> Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Xuefeng Li From: Tiezhu Yang Message-ID: Date: Tue, 24 Mar 2020 17:58:33 +0800 User-Agent: Mozilla/5.0 (X11; Linux mips64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf9DxT2nJ2XlehHIfAA--.11S3 X-Coremail-Antispam: 1UD129KBjvJXoWxJw1fKw47Xr1UCr15JrWrKrg_yoW5tFyfpa yxA3W5Gr4rWr17ursxZ3y7urySya95KFW3GF42q3WYkFyDuw1FqF4DKF1UAF4xuF18Ja40 qFyFgr1xWFnIkaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkK14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r1I6r4UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UM28EF7xvwVC2z280aVAFwI0_Cr1j6rxdM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcVAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCYjI0SjxkI62AI1cAE67vI Y487MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI 0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y 0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxV WUJVW8JwCI42IY6xAIw20EY4v20xvaj40_Wr1j6rW3Jr1lIxAIcVC2z280aVAFwI0_Jr0_ Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7VUb0D73 UUUUU== X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/24/2020 03:36 PM, Jiaxun Yang wrote: > > 于 2020年3月23日 GMT+08:00 上午10:59:13, Tiezhu Yang 写到: >> 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); > Is that pointer cast required? Yes, otherwise it will compile failed: arch/mips/loongson64/env.c:163:13: error: passing argument 1 of ‘readl’ makes pointer from integer without a cast [-Werror] id = readl(HT1_LO_BUS_CONFIG_BASE); ^ > > And you'd better add a comment here like > /* Read HT PCI 00:00:00 Host Bridge's ID to detect bridge model */ > Otherwise it's hard for others to understand what you are doing. OK, I will do it. > >> + vendor = id & 0xffff; >> + device = (id >> 16) & 0xffff; >> + >> + if (vendor == 0x0014 && device == 0x7a00) { > Please confirm with hardware design guys that bridge chip in future will have different dev ID. Yes, it maybe have a new device ID for the new bridge chip. > > Thanks. > >> + 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; >> + } >> }