Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3474587pxu; Sun, 11 Oct 2020 11:00:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKonEYwSIZCCCnm1JOmHxgfuYCVE+CillvSVWnPYDCPwsYzsq6J09Ghm1bdCxFlL584QeI X-Received: by 2002:a17:906:ce5c:: with SMTP id se28mr23212059ejb.365.1602439215716; Sun, 11 Oct 2020 11:00:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602439215; cv=none; d=google.com; s=arc-20160816; b=OK7p1CV6cVLlCe7qL0dZUTzqED9KwOXZQUgmrEeQjLCV5DWF2j/s5Mm8M+pklfx4GK SvXxlUYJFjbQdxnW1m10v5gY4feUWmHM39xXALy7YX4ub1D0JT52Saab+vJYtmDcEA7g lCTqp3AeY5ta3y1iGK9lvY3IHsb1yrMT0VXsU2hqbdHf2ZFz0qVH/D0jDyYVC8R3NY1W vc6g4W188npQz7YPsPN37kDXcJeKd89tZkTHytnss+nwk9QJdE5SqFJ29gxAPKJhB85R UwVzeuSv76Vx+itgpGcEe06QWx9BpoMWMgQMIQYC/cd8xO/uCUV4izcEa81H1RnrQHJL UHpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=prpQN2rdKYrEFMuA2E2SQJifWTh1i14dEctDxAF5bzs=; b=YpVw0aENqa3Y7A35pZpM8RoPwoQkHmPiAYcMHKfm+0kuPHWTj06v74Ta/2j1yEP1tD 44Zqdr1FQ4M3zjm7O5n2oWJd+gE4RIFfOHgoCqW7NlX/jn1K19e7gYioHVNl0MB3jSoh vZ+fc4wTJXN1OgsW7QxcFn5mE7RpwShZQq08CTGy9p932p/6i+48ihvyHcRbbZLNs83V 4fNblH+e2ONrWM9ucxi6qUPVCzPJiYDtm9XZkB7pjY93jbBU1Mf3lbXW4WVg9W3346ah iXXOlWTRGNzqME5yF9qv2zgfYhK/I0e2dTCsQUYOcvWU/FcnYAD6P67ZqFGQzWepOtq8 5ZcQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h22si10734833edq.32.2020.10.11.10.59.52; Sun, 11 Oct 2020 11:00:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729636AbgJJXsM (ORCPT + 99 others); Sat, 10 Oct 2020 19:48:12 -0400 Received: from mail.loongson.cn ([114.242.206.163]:36524 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726989AbgJJXsD (ORCPT ); Sat, 10 Oct 2020 19:48:03 -0400 Received: from linux.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9DxGMQrSIJfLfobAA--.13680S5; Sun, 11 Oct 2020 07:47:56 +0800 (CST) From: Tiezhu Yang To: Thomas Bogendoerfer , Jonathan Corbet , Huacai Chen , Jiaxun Yang Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Xuefeng Li Subject: [PATCH v2 3/4 RESEND] MIPS: Loongson64: Add /proc/boardinfo Date: Sun, 11 Oct 2020 07:47:53 +0800 Message-Id: <1602373674-4579-4-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1602373674-4579-1-git-send-email-yangtiezhu@loongson.cn> References: <1602373674-4579-1-git-send-email-yangtiezhu@lo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_Gr1lIxAIcVC2z280aV CY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7VUjTq2tUUUUU== X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add /proc/boardinfo to get mainboard and BIOS info easily on the Loongson platform, this is useful to point out the current used mainboard type and BIOS version when there exists problems related with hardware or firmware. E.g. with this patch: [loongson@linux ~]$ cat /proc/boardinfo Board Info Manufacturer : LEMOTE Board Name : LEMOTE-LS3A4000-7A1000-1w-V01-pc Family : LOONGSON3 BIOS Info Vendor : Kunlun Version : Kunlun-A1901-V4.1.3-20200414093938 ROM Size : 4 KB Release Date : 2020-04-14 Signed-off-by: Tiezhu Yang --- v2: no changes arch/mips/include/asm/mach-loongson64/boot_param.h | 4 +++ arch/mips/loongson64/Makefile | 2 +- arch/mips/loongson64/boardinfo.c | 40 ++++++++++++++++++++++ arch/mips/loongson64/env.c | 10 ++++++ 4 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 arch/mips/loongson64/boardinfo.c diff --git a/arch/mips/include/asm/mach-loongson64/boot_param.h b/arch/mips/include/asm/mach-loongson64/boot_param.h index afc92b7..4592841 100644 --- a/arch/mips/include/asm/mach-loongson64/boot_param.h +++ b/arch/mips/include/asm/mach-loongson64/boot_param.h @@ -228,6 +228,10 @@ struct loongson_system_configuration { extern struct efi_memory_map_loongson *loongson_memmap; extern struct loongson_system_configuration loongson_sysconf; +extern struct board_devices *eboard; +extern struct interface_info *einter; +extern struct loongson_special_attribute *especial; + extern u32 node_id_offset; extern void ls7a_early_config(void); extern void rs780e_early_config(void); diff --git a/arch/mips/loongson64/Makefile b/arch/mips/loongson64/Makefile index 39c06f5..bc77b5a 100644 --- a/arch/mips/loongson64/Makefile +++ b/arch/mips/loongson64/Makefile @@ -3,7 +3,7 @@ # Makefile for Loongson-3 family machines # obj-$(CONFIG_MACH_LOONGSON64) += cop2-ex.o platform.o dma.o \ - setup.o init.o env.o time.o reset.o \ + setup.o init.o env.o time.o reset.o boardinfo.o\ obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_NUMA) += numa.o diff --git a/arch/mips/loongson64/boardinfo.c b/arch/mips/loongson64/boardinfo.c new file mode 100644 index 0000000..2e8086b --- /dev/null +++ b/arch/mips/loongson64/boardinfo.c @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include +#include +#include +#include +#include + +static int loongson_boardinfo_proc_show(struct seq_file *m, void *v) +{ + char board_manufacturer[64] = {0}; + char *tmp_board_manufacturer = board_manufacturer; + char bios_vendor[64] = {0}; + char *tmp_bios_vendor = bios_vendor; + + strcpy(board_manufacturer, eboard->name); + strcpy(bios_vendor, einter->description); + + seq_puts(m, "Board Info\n"); + seq_printf(m, "Manufacturer\t\t: %s\n", strsep(&tmp_board_manufacturer, "-")); + seq_printf(m, "Board Name\t\t: %s\n", eboard->name); + seq_puts(m, "Family\t\t\t: LOONGSON3\n"); + seq_puts(m, "\n"); + + seq_puts(m, "BIOS Info\n"); + seq_printf(m, "Vendor\t\t\t: %s\n", strsep(&tmp_bios_vendor, "-")); + seq_printf(m, "Version\t\t\t: %s\n", einter->description); + seq_printf(m, "ROM Size\t\t: %d KB\n", einter->size); + seq_printf(m, "Release Date\t\t: %s\n", especial->special_name); + + return 0; +} + +static int __init proc_boardinfo_init(void) +{ + proc_create_single("boardinfo", 0, NULL, loongson_boardinfo_proc_show); + return 0; +} + +module_init(proc_boardinfo_init); diff --git a/arch/mips/loongson64/env.c b/arch/mips/loongson64/env.c index 134cb8e..51a5d05 100644 --- a/arch/mips/loongson64/env.c +++ b/arch/mips/loongson64/env.c @@ -28,6 +28,10 @@ EXPORT_SYMBOL(cpu_clock_freq); struct efi_memory_map_loongson *loongson_memmap; struct loongson_system_configuration loongson_sysconf; +struct board_devices *eboard; +struct interface_info *einter; +struct loongson_special_attribute *especial; + u64 loongson_chipcfg[MAX_PACKAGES] = {0xffffffffbfc00180}; u64 loongson_chiptemp[MAX_PACKAGES]; u64 loongson_freqctrl[MAX_PACKAGES]; @@ -57,6 +61,12 @@ void __init prom_init_env(void) ((u64)loongson_p + loongson_p->system_offset); ecpu = (struct efi_cpuinfo_loongson *) ((u64)loongson_p + loongson_p->cpu_offset); + eboard = (struct board_devices *) + ((u64)loongson_p + loongson_p->boarddev_table_offset); + einter = (struct interface_info *) + ((u64)loongson_p + loongson_p->interface_offset); + especial = (struct loongson_special_attribute *) + ((u64)loongson_p + loongson_p->special_offset); eirq_source = (struct irq_source_routing_table *) ((u64)loongson_p + loongson_p->irq_offset); loongson_memmap = (struct efi_memory_map_loongson *) -- 2.1.0