From patchwork Sun Sep 27 14:52:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1372079 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=LwpMteqO; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BzpYM48hYz9sSJ for ; Mon, 28 Sep 2020 00:53:11 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 873668238F; Sun, 27 Sep 2020 16:53:02 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="LwpMteqO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AB79782387; Sun, 27 Sep 2020 16:52:58 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oo1-xc41.google.com (mail-oo1-xc41.google.com [IPv6:2607:f8b0:4864:20::c41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D181682365 for ; Sun, 27 Sep 2020 16:52:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-oo1-xc41.google.com with SMTP id h8so1957653ooc.12 for ; Sun, 27 Sep 2020 07:52:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TFkFYMZBfO2hzfMtRejMYdkiQR0a+yB1sXuTNRc7Hvw=; b=LwpMteqOmS7Im3Rh3Pmmo0pTuG+7lXKZhdngp2PuTXwjJUqbJrY3xstgO+3Jacklsk 2/eE96O2HoH2UKZYsVjsR7X9LN9M1q/N0w9ZHmWxRs6PXX+uw4gOWZd4Tb7Z/XMJhVFf G3Gfvxlk3bZXTdY/GMbHb6OzsvbRq+O1MY4UQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TFkFYMZBfO2hzfMtRejMYdkiQR0a+yB1sXuTNRc7Hvw=; b=ryB1ilPWwK+iIhqJiO/YnGu3D/7E1bYO6ihkuIuhUCRQFbgDGDJYH2FX3bUMxuMKvY RCu1VOcvcYHERxUbgrHdxGMLKmfD773FbysH1wX1BH7iiPZQiILCajYHebNdy8jYAUCj 7HxKHBLEQrOClJrLOUW/iIksSodS4Oo1WUDGTz482U2A3j6/TGchEpQpgiDWSgDamlC/ ADZKaRx8WRHMh7PTifF+O4o/UROkE7LdIW7J4P9iEX7pJrIxh5/FYkycIBjuvFSSrx77 PZxRCoAR5uAuXK2bJ3Q1cKS4yyQpYALha8LDQl8N/ps2MFzgJUPcG3C5xwTSedyNWPxJ 6E5Q== X-Gm-Message-State: AOAM530BkqAuqlgK8qGfu92RR0aRkihBF8UVVmNdMPYFV9URgz9XOGR9 7yNy1fNxiAOhC4GVVUfI1qxFmXb2P3VKlX/Q X-Google-Smtp-Source: ABdhPJz8AvaoDk6nTzQQLerHHjhBgJYwxPAvkADRrc4nu1CKY8cQkezYDWbERmZbZDikJSiCaDCevA== X-Received: by 2002:a4a:6f0c:: with SMTP id h12mr6767588ooc.57.1601218374262; Sun, 27 Sep 2020 07:52:54 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l136sm2024966oig.7.2020.09.27.07.52.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 07:52:53 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Bernhard Messerklinger , Wolfgang Wallner , Walter Lozano , Simon Glass , Bin Meng Subject: [PATCH 1/4] x86: Pass an ofnode into each SMBIOS function Date: Sun, 27 Sep 2020 08:52:44 -0600 Message-Id: <20200927085243.1.I9fdd5f232eb03edc10714dbe8e46289e9a1971af@changeid> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog In-Reply-To: <20200927145247.1544339-1-sjg@chromium.org> References: <20200927145247.1544339-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean As a first step to obtaining SMBIOS information from the devicetree, add an ofnode parameter to the writing functions. Signed-off-by: Simon Glass --- include/smbios.h | 5 ++++- lib/smbios.c | 40 +++++++++++++++++++++++----------------- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/include/smbios.h b/include/smbios.h index 97b9ddce237..c19afbe16c7 100644 --- a/include/smbios.h +++ b/include/smbios.h @@ -8,6 +8,8 @@ #ifndef _SMBIOS_H_ #define _SMBIOS_H_ +#include + /* SMBIOS spec version implemented */ #define SMBIOS_MAJOR_VER 3 #define SMBIOS_MINOR_VER 0 @@ -222,9 +224,10 @@ static inline void fill_smbios_header(void *table, int type, * * @addr: start address to write the structure * @handle: the structure's handle, a unique 16-bit number + * @node: node containing the information to write (ofnode_null() if none) * @return: size of the structure */ -typedef int (*smbios_write_type)(ulong *addr, int handle); +typedef int (*smbios_write_type)(ulong *addr, int handle, ofnode node); /** * write_smbios_table() - Write SMBIOS table diff --git a/lib/smbios.c b/lib/smbios.c index 11790443e1a..dd4b8841d6c 100644 --- a/lib/smbios.c +++ b/lib/smbios.c @@ -25,7 +25,7 @@ * * @start: string area start address * @str: string to add - * @return: string number in the string area + * @return: string number in the string area (1 or more) */ static int smbios_add_string(char *start, const char *str) { @@ -74,7 +74,7 @@ static int smbios_string_table_len(char *start) return len + 1; } -static int smbios_write_type0(ulong *current, int handle) +static int smbios_write_type0(ulong *current, int handle, ofnode node) { struct smbios_type0 *t; int len = sizeof(struct smbios_type0); @@ -111,7 +111,7 @@ static int smbios_write_type0(ulong *current, int handle) return len; } -static int smbios_write_type1(ulong *current, int handle) +static int smbios_write_type1(ulong *current, int handle, ofnode node) { struct smbios_type1 *t; int len = sizeof(struct smbios_type1); @@ -134,7 +134,7 @@ static int smbios_write_type1(ulong *current, int handle) return len; } -static int smbios_write_type2(ulong *current, int handle) +static int smbios_write_type2(ulong *current, int handle, ofnode node) { struct smbios_type2 *t; int len = sizeof(struct smbios_type2); @@ -154,7 +154,7 @@ static int smbios_write_type2(ulong *current, int handle) return len; } -static int smbios_write_type3(ulong *current, int handle) +static int smbios_write_type3(ulong *current, int handle, ofnode node) { struct smbios_type3 *t; int len = sizeof(struct smbios_type3); @@ -176,7 +176,7 @@ static int smbios_write_type3(ulong *current, int handle) return len; } -static void smbios_write_type4_dm(struct smbios_type4 *t) +static void smbios_write_type4_dm(struct smbios_type4 *t, ofnode node) { u16 processor_family = SMBIOS_PROCESSOR_FAMILY_UNKNOWN; const char *vendor = "Unknown"; @@ -185,20 +185,20 @@ static void smbios_write_type4_dm(struct smbios_type4 *t) #ifdef CONFIG_CPU char processor_name[49]; char vendor_name[49]; - struct udevice *dev = NULL; + struct udevice *cpu = NULL; - uclass_find_first_device(UCLASS_CPU, &dev); - if (dev) { - struct cpu_platdata *plat = dev_get_parent_platdata(dev); + uclass_find_first_device(UCLASS_CPU, &cpu); + if (cpu) { + struct cpu_platdata *plat = dev_get_parent_platdata(cpu); if (plat->family) processor_family = plat->family; t->processor_id[0] = plat->id[0]; t->processor_id[1] = plat->id[1]; - if (!cpu_get_vendor(dev, vendor_name, sizeof(vendor_name))) + if (!cpu_get_vendor(cpu, vendor_name, sizeof(vendor_name))) vendor = vendor_name; - if (!cpu_get_desc(dev, processor_name, sizeof(processor_name))) + if (!cpu_get_desc(cpu, processor_name, sizeof(processor_name))) name = processor_name; } #endif @@ -208,7 +208,7 @@ static void smbios_write_type4_dm(struct smbios_type4 *t) t->processor_version = smbios_add_string(t->eos, name); } -static int smbios_write_type4(ulong *current, int handle) +static int smbios_write_type4(ulong *current, int handle, ofnode node) { struct smbios_type4 *t; int len = sizeof(struct smbios_type4); @@ -217,7 +217,7 @@ static int smbios_write_type4(ulong *current, int handle) memset(t, 0, sizeof(struct smbios_type4)); fill_smbios_header(t, SMBIOS_PROCESSOR_INFORMATION, len, handle); t->processor_type = SMBIOS_PROCESSOR_TYPE_CENTRAL; - smbios_write_type4_dm(t); + smbios_write_type4_dm(t, node); t->status = SMBIOS_PROCESSOR_STATUS_ENABLED; t->processor_upgrade = SMBIOS_PROCESSOR_UPGRADE_NONE; t->l1_cache_handle = 0xffff; @@ -232,7 +232,7 @@ static int smbios_write_type4(ulong *current, int handle) return len; } -static int smbios_write_type32(ulong *current, int handle) +static int smbios_write_type32(ulong *current, int handle, ofnode node) { struct smbios_type32 *t; int len = sizeof(struct smbios_type32); @@ -247,7 +247,7 @@ static int smbios_write_type32(ulong *current, int handle) return len; } -static int smbios_write_type127(ulong *current, int handle) +static int smbios_write_type127(ulong *current, int handle, ofnode node) { struct smbios_type127 *t; int len = sizeof(struct smbios_type127); @@ -274,7 +274,9 @@ static smbios_write_type smbios_write_funcs[] = { ulong write_smbios_table(ulong addr) { + ofnode node = ofnode_null(); struct smbios_entry *se; + struct udevice *dev; ulong table_addr; ulong tables; int len = 0; @@ -284,6 +286,10 @@ ulong write_smbios_table(ulong addr) int isize; int i; + uclass_first_device(UCLASS_BOARD, &dev); + if (dev) + node = dev_read_subnode(dev, "smbios"); + /* 16 byte align the table address */ addr = ALIGN(addr, 16); @@ -296,7 +302,7 @@ ulong write_smbios_table(ulong addr) /* populate minimum required tables */ for (i = 0; i < ARRAY_SIZE(smbios_write_funcs); i++) { - int tmp = smbios_write_funcs[i]((ulong *)&addr, handle++); + int tmp = smbios_write_funcs[i]((ulong *)&addr, handle++, node); max_struct_size = max(max_struct_size, tmp); len += tmp; From patchwork Sun Sep 27 14:52:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1372080 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=SjtIM+Yo; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BzpYb0tVJz9sSJ for ; Mon, 28 Sep 2020 00:53:22 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4141C8239C; Sun, 27 Sep 2020 16:53:04 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="SjtIM+Yo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1EFE882390; Sun, 27 Sep 2020 16:53:00 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A014782374 for ; Sun, 27 Sep 2020 16:52:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-ot1-x342.google.com with SMTP id u25so7095506otq.6 for ; Sun, 27 Sep 2020 07:52:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Elhc7pEi0OkGLd96xd3rN9uWVLUzgIg2jwAqZABQeM4=; b=SjtIM+YoDgNYFNfIJRcE8U0cbe9HYZARfd9vhntl7UGeTtfaRSFEoWH3wAl+zET0GD luhjGRihmzFXDB7459TUhgp54H6L8P3nzou7ZOZnKU5/fmaeXiLDmqDSlSnXF76vNJ93 MONNfT3UfWgmFcldsEcHHSBze8cuqama+gvxQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Elhc7pEi0OkGLd96xd3rN9uWVLUzgIg2jwAqZABQeM4=; b=f7IrV1z7FWjKVGRSIHectCO9h/8XT0crkYa2qJPR9lSznB0grH9HNKevnLQDZohV4+ HMhEnnhoGWxm2b6ln8q03sAtEU1gktOIt67QWPa9xoODmpspiljzZjuKqdcyYfX5JqRc thdV7U7VQC+8BFbgVpX0W46LktmmokwsI4cwk3cIbZjlA8VK9JINffkJi0Fts1SF+flB nTJ8vCT9wWrdYugty1HORVM54KmMrN6pe+rLKR2hR7URuQhJDrC6W2JNS1J6ybbYq39A AoC61tHgvsvc1t/zCUVFbJmQXOWPIZsH81wDYqbeuawpU67+KITpKyG6pzjEuoPxfyXW +nBw== X-Gm-Message-State: AOAM533J1sLPzme/O+aG2jTIfiVBCSTApbGmuPAExM0PHg8Z+zmQlWga A2l0lyAqgdb4cVeY1UmNnJgAFQItGfbq2uXo X-Google-Smtp-Source: ABdhPJzwdZevw6P6aVU77ize8HsQpc8SND7M5xESkCOowGKc5PL3yUASl6IiSa/rjlT7o0oZ94I97g== X-Received: by 2002:a9d:7448:: with SMTP id p8mr6095159otk.306.1601218375249; Sun, 27 Sep 2020 07:52:55 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l136sm2024966oig.7.2020.09.27.07.52.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 07:52:54 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Bernhard Messerklinger , Wolfgang Wallner , Walter Lozano , Simon Glass Subject: [PATCH 2/4] smbios: Allow properties to come from the device tree Date: Sun, 27 Sep 2020 08:52:45 -0600 Message-Id: <20200927145247.1544339-2-sjg@chromium.org> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog In-Reply-To: <20200927145247.1544339-1-sjg@chromium.org> References: <20200927145247.1544339-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean Support a way to put SMBIOS properties in the device tree. These can be placed in a 'board' device in an 'smbios' subnode. Signed-off-by: Simon Glass --- lib/smbios.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 6 deletions(-) diff --git a/lib/smbios.c b/lib/smbios.c index dd4b8841d6c..1b5f43ef989 100644 --- a/lib/smbios.c +++ b/lib/smbios.c @@ -52,6 +52,42 @@ static int smbios_add_string(char *start, const char *str) } } +/** + * smbios_add_prop_default() - Add a property from the device tree or default + * + * @start: string area start address + * @node: node containing the information to write (ofnode_null() if none) + * @prop: property to write + * @def: default string if the node has no such property + * @return 0 if not found, else SMBIOS string number (1 or more) + */ +static int smbios_add_prop_default(char *start, ofnode node, const char *prop, + const char *def) +{ + const char *str; + + str = ofnode_read_string(node, prop); + if (str) + return smbios_add_string(start, str); + else if (def) + return smbios_add_string(start, def); + + return 0; +} + +/** + * smbios_add_prop() - Add a property from the device tree + * + * @start: string area start address + * @node: node containing the information to write (ofnode_null() if none) + * @prop: property to write + * @return 0 if not found, else SMBIOS string number (1 or more) + */ +static int smbios_add_prop(char *start, ofnode node, const char *prop) +{ + return smbios_add_prop_default(start, node, prop, NULL); +} + /** * smbios_string_table_len() - compute the string area size * @@ -120,11 +156,15 @@ static int smbios_write_type1(ulong *current, int handle, ofnode node) t = map_sysmem(*current, len); memset(t, 0, sizeof(struct smbios_type1)); fill_smbios_header(t, SMBIOS_SYSTEM_INFORMATION, len, handle); - t->manufacturer = smbios_add_string(t->eos, CONFIG_SMBIOS_MANUFACTURER); - t->product_name = smbios_add_string(t->eos, CONFIG_SMBIOS_PRODUCT_NAME); + t->manufacturer = smbios_add_prop_default(t->eos, node, "manufactuer", + CONFIG_SMBIOS_MANUFACTURER); + t->product_name = smbios_add_prop_default(t->eos, node, "product", + CONFIG_SMBIOS_PRODUCT_NAME); if (serial_str) { - strncpy((char *)t->uuid, serial_str, sizeof(t->uuid)); t->serial_number = smbios_add_string(t->eos, serial_str); + strncpy((char *)t->uuid, serial_str, sizeof(t->uuid)); + } else { + t->serial_number = smbios_add_prop(t->eos, node, "serial"); } len = t->length + smbios_string_table_len(t->eos); @@ -142,8 +182,10 @@ static int smbios_write_type2(ulong *current, int handle, ofnode node) t = map_sysmem(*current, len); memset(t, 0, sizeof(struct smbios_type2)); fill_smbios_header(t, SMBIOS_BOARD_INFORMATION, len, handle); - t->manufacturer = smbios_add_string(t->eos, CONFIG_SMBIOS_MANUFACTURER); - t->product_name = smbios_add_string(t->eos, CONFIG_SMBIOS_PRODUCT_NAME); + t->manufacturer = smbios_add_prop_default(t->eos, node, "manufactuer", + CONFIG_SMBIOS_MANUFACTURER); + t->product_name = smbios_add_prop_default(t->eos, node, "product", + CONFIG_SMBIOS_PRODUCT_NAME); t->feature_flags = SMBIOS_BOARD_FEATURE_HOSTING; t->board_type = SMBIOS_BOARD_MOTHERBOARD; @@ -162,7 +204,8 @@ static int smbios_write_type3(ulong *current, int handle, ofnode node) t = map_sysmem(*current, len); memset(t, 0, sizeof(struct smbios_type3)); fill_smbios_header(t, SMBIOS_SYSTEM_ENCLOSURE, len, handle); - t->manufacturer = smbios_add_string(t->eos, CONFIG_SMBIOS_MANUFACTURER); + t->manufacturer = smbios_add_prop_default(t->eos, node, "manufactuer", + CONFIG_SMBIOS_MANUFACTURER); t->chassis_type = SMBIOS_ENCLOSURE_DESKTOP; t->bootup_state = SMBIOS_STATE_SAFE; t->power_supply_state = SMBIOS_STATE_SAFE; From patchwork Sun Sep 27 14:52:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1372081 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=bshMnz6k; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BzpYp1Sqnz9sSJ for ; Mon, 28 Sep 2020 00:53:34 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B1D0A82380; Sun, 27 Sep 2020 16:53:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="bshMnz6k"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3746282380; Sun, 27 Sep 2020 16:53:00 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ot1-x341.google.com (mail-ot1-x341.google.com [IPv6:2607:f8b0:4864:20::341]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 6CCF182378 for ; Sun, 27 Sep 2020 16:52:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-ot1-x341.google.com with SMTP id m13so7057226otl.9 for ; Sun, 27 Sep 2020 07:52:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XvR0IWFr5bMX7cfelOrFTkc7SOJZ2Vj+u++a1E2qJ3g=; b=bshMnz6kDND9i14xi7Ks8FX9jCCJ/jeZr32tDC8LjPt/XrfhhzHVglTt1/w2a6u9LG c/QpYEGaNIuu3fRKsI1AXenCkA/wEPlnzM4TG1rheR2AguIvEoQGKXIVGssgvFUO9sAf UuTqGkZGKt7ptewfqzvYoV3HmL3aLQJSTMUns= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XvR0IWFr5bMX7cfelOrFTkc7SOJZ2Vj+u++a1E2qJ3g=; b=uCr1HYF6tzWDnKGG8TvWO5GyS7rfJaTP77C35ypW+Kk33JHpWfj5+YEWX9Gx6y9NVK ysCu9mCSraqNb9G5WkLSOju2WKfHsJOIKTbVUM7DLGqsO1Ptei5ur+Tq9re/rhuRFoKc ZWaIjGl5AIsy+Ar2QByHeH33Sfuj2OgWc0G1tv5yOBeinwsGni9VKxe4WFayrtzUDkX7 9W9rFxQhY0trL58WnsExfOErHpm3lSEhT2+xw3NKBrRm31Uf7qJOVx4CZoL0OWi+REET GfpLwL2kxN7lKv73K4TGhOfYJrUHZIE45rBNCsQbh3POyRLcR9inWA8jZErkJPVhmRTR WYvA== X-Gm-Message-State: AOAM531E1zH251kRz/yzDXX8oXkMTvuz+jX2JSsCVm5U2ICfBR4tNXAb urE4hsek+cjP1HfpqOIktfagTyNNpJUMtRuE X-Google-Smtp-Source: ABdhPJzqqOYzIl8Pqmv1pbk/qXF4ZfrBoa/skMJwzv06/sK+Dyf479XlL5CRocBs6J0zetlLS1RvNA== X-Received: by 2002:a05:6830:110b:: with SMTP id w11mr5839429otq.109.1601218376176; Sun, 27 Sep 2020 07:52:56 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l136sm2024966oig.7.2020.09.27.07.52.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 07:52:55 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Bernhard Messerklinger , Wolfgang Wallner , Walter Lozano , Simon Glass Subject: [PATCH 3/4] smbios: Add more properties Date: Sun, 27 Sep 2020 08:52:46 -0600 Message-Id: <20200927145247.1544339-3-sjg@chromium.org> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog In-Reply-To: <20200927145247.1544339-1-sjg@chromium.org> References: <20200927145247.1544339-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean The current tables only support a subset of the available fields defined by the SMBIOS spec. Add a few more. Signed-off-by: Simon Glass --- lib/smbios.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/smbios.c b/lib/smbios.c index 1b5f43ef989..f3bbf7f02c8 100644 --- a/lib/smbios.c +++ b/lib/smbios.c @@ -160,12 +160,15 @@ static int smbios_write_type1(ulong *current, int handle, ofnode node) CONFIG_SMBIOS_MANUFACTURER); t->product_name = smbios_add_prop_default(t->eos, node, "product", CONFIG_SMBIOS_PRODUCT_NAME); + t->version = smbios_add_prop(t->eos, node, "version"); if (serial_str) { t->serial_number = smbios_add_string(t->eos, serial_str); strncpy((char *)t->uuid, serial_str, sizeof(t->uuid)); } else { t->serial_number = smbios_add_prop(t->eos, node, "serial"); } + t->sku_number = smbios_add_prop(t->eos, node, "sku"); + t->family = smbios_add_prop(t->eos, node, "family"); len = t->length + smbios_string_table_len(t->eos); *current += len; @@ -186,6 +189,7 @@ static int smbios_write_type2(ulong *current, int handle, ofnode node) CONFIG_SMBIOS_MANUFACTURER); t->product_name = smbios_add_prop_default(t->eos, node, "product", CONFIG_SMBIOS_PRODUCT_NAME); + t->asset_tag_number = smbios_add_prop(t->eos, node, "asset-tag"); t->feature_flags = SMBIOS_BOARD_FEATURE_HOSTING; t->board_type = SMBIOS_BOARD_MOTHERBOARD; From patchwork Sun Sep 27 14:52:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1372082 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=I+0lAVL4; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BzpZ03VHWz9sSJ for ; Mon, 28 Sep 2020 00:53:44 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1BDF3823AE; Sun, 27 Sep 2020 16:53:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="I+0lAVL4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7BBA482378; Sun, 27 Sep 2020 16:53:01 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oo1-xc42.google.com (mail-oo1-xc42.google.com [IPv6:2607:f8b0:4864:20::c42]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 6E22182384 for ; Sun, 27 Sep 2020 16:52:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-oo1-xc42.google.com with SMTP id r10so1974945oor.5 for ; Sun, 27 Sep 2020 07:52:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BunqwSBNJiCpnHexd2+sgKN3dLOwr++Mzp4kisTFDfM=; b=I+0lAVL4tBiGxtI10Wx8DB7zcBvBi5fGmE0cRVjANEnVMObpGvYpRRb5kRbGxk8R4s 8CfSf+vpkrQ0Qkpb3W2k+5kAXMLpvwQ1MnU4BWNB5TLXj6SSL9lS5UQYBz5ZDPrQR4aD LePxEWeng4/dSH6BBwagTAL5T1Okicz1UbvEU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BunqwSBNJiCpnHexd2+sgKN3dLOwr++Mzp4kisTFDfM=; b=jdX70w1Aa7FDkkeXxLl3Xga+/IHWf71uPEZ32nJZqjXwX3v6W3aZjrYWAN+4rikgTt 3VHwaIGNkfN66KTZvTOcI5AEvCiDRPfmHM6B9cXFqNeoWoCz0TE8/Xki7xBCwwwZImaM 4p+9CFUqe76VnbG6qFw9eoqDLM0mjAd9c7jn74r83b44soGEiaTWr/co6eRWvc1XCAcT muk+zPna64PcABhBo2EToWVpdSpURGhkFnQOhkLEh3AT5iAV+CQefX0Ta/qT0DdpqIFg PsvwVsJsiaZpjU+ZuSkpkzhCHExWLByUfgtWUCLpbsRaXKU5XyUhv0tVLO2IfLxlYpgZ 9Amg== X-Gm-Message-State: AOAM530tYIptCRhmHXIBPERDLMJILnM6GvaqZMixHpsNxdhEzaoszhnm Bf1LK8C98xENii0uieFY6PcAzB2/g4PlkAIb X-Google-Smtp-Source: ABdhPJxsRb+n+6/V38gOWqLHyI0usBdeHnLuqgf/82YC+2vn0LLXwhhEkaHM2BQl1I7zLm5x4i7I0Q== X-Received: by 2002:a4a:4845:: with SMTP id p66mr6778431ooa.68.1601218377136; Sun, 27 Sep 2020 07:52:57 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l136sm2024966oig.7.2020.09.27.07.52.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 07:52:56 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Bernhard Messerklinger , Wolfgang Wallner , Walter Lozano , Simon Glass , Bin Meng Subject: [PATCH 4/4] smbios: Add documentation and devicetree binding Date: Sun, 27 Sep 2020 08:52:47 -0600 Message-Id: <20200927145247.1544339-4-sjg@chromium.org> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog In-Reply-To: <20200927145247.1544339-1-sjg@chromium.org> References: <20200927145247.1544339-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean Add information about how to set SMBIOS properties using the devicetree. Signed-off-by: Simon Glass --- doc/arch/x86.rst | 8 +++++ doc/device-tree-bindings/board/board_x86.txt | 36 ++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 doc/device-tree-bindings/board/board_x86.txt diff --git a/doc/arch/x86.rst b/doc/arch/x86.rst index c6b70ce61a3..45f9ba308c7 100644 --- a/doc/arch/x86.rst +++ b/doc/arch/x86.rst @@ -740,6 +740,14 @@ Note that this is a development feature only. It is not intended for use in production environments. Also it is not currently part of the automated tests so may break in the future. +SMBIOS tables +------------- + +To generate SMBIOS tables in U-Boot, for use by the OS, enable the +CONFIG_GENERATE_SMBIOS_TABLE option. The easiest way to provide the values to +use is via the device tree. For details see +device-tree-bindings/board/board_x86.txt + TODO List --------- - Audio diff --git a/doc/device-tree-bindings/board/board_x86.txt b/doc/device-tree-bindings/board/board_x86.txt new file mode 100644 index 00000000000..3766751896a --- /dev/null +++ b/doc/device-tree-bindings/board/board_x86.txt @@ -0,0 +1,36 @@ +x86 board driver +================ + +This driver allows providing board-specific features such as power control +GPIOs. In addition, the SMBIOS values can be specified in the device tree, +as below: + +An optional 'smbios' subnode can be used to provide these properties. + +Optional properties: + - manufacturer: Product manufacturer for system / baseboard + - product: Product name + - version: Product version string + - serial: Serial number for system (note that this can be overridden by + the serial# environment variable) + - sku: Product SKU (Stock-Keeping Unit) + - family: Product family + - asset-tag: Asset tag for the motherboard, sometimes used in organisations + to track devices + + +Example: + + board { + compatible = "google,coral"; + + smbios { + manufacturer = "Google"; + product = "Coral"; + version = "rev2"; + serial = "123456789"; + sku = "sku3"; + family = "Google_Coral"; + asset-tag = "ABC123"; + }; + };