{"id":2234891,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2234891/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20260508084834.45637-4-Alexander.Feilke@ew.tq-group.com/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/1.2/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260508084834.45637-4-Alexander.Feilke@ew.tq-group.com>","list_archive_url":null,"date":"2026-05-08T08:48:31","name":"[3/6] sysinfo: tq_eeprom: new driver","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"c669ba3c79a307d9860b9d05ec06d20dc39cf04a","submitter":{"id":92142,"url":"http://patchwork.ozlabs.org/api/1.2/people/92142/?format=json","name":"Feilke, Alexander","email":"Alexander.Feilke@ew.tq-group.com"},"delegate":{"id":151988,"url":"http://patchwork.ozlabs.org/api/1.2/users/151988/?format=json","username":"festevam","first_name":"Fabio","last_name":"Estevam","email":"festevam@gmail.com"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20260508084834.45637-4-Alexander.Feilke@ew.tq-group.com/mbox/","series":[{"id":503350,"url":"http://patchwork.ozlabs.org/api/1.2/series/503350/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=503350","date":"2026-05-08T08:48:28","name":"TQMa7 eeprom sysinfo driver","version":1,"mbox":"http://patchwork.ozlabs.org/series/503350/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2234891/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2234891/checks/","tags":{},"related":[],"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=ew.tq-group.com header.i=@ew.tq-group.com\n header.a=rsa-sha256 header.s=default2602 header.b=HTluKOFR;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;\n envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org)","phobos.denx.de;\n dmarc=fail (p=quarantine dis=none) header.from=ew.tq-group.com","phobos.denx.de;\n spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de","phobos.denx.de;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=ew.tq-group.com header.i=@ew.tq-group.com\n header.b=\"HTluKOFR\";\n\tdkim-atps=neutral","phobos.denx.de; dmarc=pass (p=quarantine dis=none)\n header.from=ew.tq-group.com","phobos.denx.de; spf=pass\n smtp.mailfrom=Alexander.Feilke@ew.tq-group.com"],"Received":["from phobos.denx.de (phobos.denx.de\n [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4gBjV563Wtz1yKd\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 08 May 2026 18:49:33 +1000 (AEST)","from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id AC3CA84C6E;\n\tFri,  8 May 2026 10:48:57 +0200 (CEST)","by phobos.denx.de (Postfix, from userid 109)\n id D132084C3B; Fri,  8 May 2026 10:48:55 +0200 (CEST)","from www537.your-server.de (www537.your-server.de [188.40.3.216])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))\n (No client certificate requested)\n by phobos.denx.de (Postfix) with ESMTPS id C503F84C3F\n for <u-boot@lists.denx.de>; Fri,  8 May 2026 10:48:52 +0200 (CEST)","from sslproxy03.your-server.de ([88.198.220.132])\n by www537.your-server.de with esmtpsa  (TLS1.3) tls TLS_AES_256_GCM_SHA384\n (Exim 4.96.2) (envelope-from <Alexander.Feilke@ew.tq-group.com>)\n id 1wLGt9-0009a0-2Q; Fri, 08 May 2026 10:48:51 +0200","from localhost ([127.0.0.1])\n by sslproxy03.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384\n (Exim 4.96) (envelope-from <Alexander.Feilke@ew.tq-group.com>)\n id 1wLGt8-000KsG-2d; Fri, 08 May 2026 10:48:51 +0200"],"X-Spam-Checker-Version":"SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,\n DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS\n autolearn=ham autolearn_force=no version=3.4.2","DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n d=ew.tq-group.com; s=default2602; h=Content-Transfer-Encoding:MIME-Version:\n References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:\n Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From:\n Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID;\n bh=bT5wr7KubC9tZo4WEjEqeyzRz7PhP8wIr7D4alAz+qE=; b=HTluKOFR534WHHfTK/ermlqTFs\n OIuegliEC13cToHABQTb2KMvvn3QAGvQZqIIRC5YCFedrptHkeFZDXOXNA4ncU2AOkaG+qSxHNxQ6\n Z9y7Y7j3qkn6ca0rlhuxDZJFGdiqvN1gkQWNWmctqAAfGGDH7J84WVGB5NUtHWMqohuhUVJs3l307\n 75OkrAjpG13IXUN2edytszMjx+6Rz3QFfJlBJxnGtdVX4VXBPQUdU7T3sQRTo8NBLnBPkq1MwwDKH\n dEudjrz7Fon3tAb171oGIIMEHzSYuh/0K57zh0dLiCOFXqrfnMAny6cUtDu+im9F51F0C9/qNqjCu\n +ofSws4A==;","From":"Alexander Feilke <Alexander.Feilke@ew.tq-group.com>","To":"\"NXP i.MX U-Boot Team\" <uboot-imx@nxp.com>, u-boot@ew.tq-group.com,\n u-boot@lists.denx.de","Cc":"Nora Schiffer <nora.schiffer@ew.tq-group.com>,\n Stefano Babic <sbabic@nabladev.com>, Fabio Estevam <festevam@gmail.com>,\n Alexander Feilke <Alexander.Feilke@ew.tq-group.com>,\n Tom Rini <trini@konsulko.com>, Max Merchel <Max.Merchel@ew.tq-group.com>,\n Alexander Feilke <alexander.feilke@ew.tq-group.com>","Subject":"[PATCH 3/6] sysinfo: tq_eeprom: new driver","Date":"Fri,  8 May 2026 10:48:31 +0200","Message-Id":"<20260508084834.45637-4-Alexander.Feilke@ew.tq-group.com>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20260508084834.45637-1-Alexander.Feilke@ew.tq-group.com>","References":"<20260508084834.45637-1-Alexander.Feilke@ew.tq-group.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.39","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<https://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=subscribe>","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>","X-Virus-Scanned":"clamav-milter 0.103.8 at phobos.denx.de","X-Virus-Status":"Clean"},"content":"From: Nora Schiffer <nora.schiffer@ew.tq-group.com>\n\nIntroduce a sysinfo driver that can be instantiated from the device,\nwhich will provide information from the EEPROM found on all TQ-Systems\nSoMs.\n\nSigned-off-by: Nora Schiffer <nora.schiffer@ew.tq-group.com>\nSigned-off-by: Max Merchel <Max.Merchel@ew.tq-group.com>\nSigned-off-by: Alexander Feilke <alexander.feilke@ew.tq-group.com>\n---\n drivers/sysinfo/Kconfig     |   8 ++\n drivers/sysinfo/Makefile    |   1 +\n drivers/sysinfo/tq_eeprom.c | 223 ++++++++++++++++++++++++++++++++++++\n include/sysinfo/tq_eeprom.h |  24 ++++\n 4 files changed, 256 insertions(+)\n create mode 100644 drivers/sysinfo/tq_eeprom.c\n create mode 100644 include/sysinfo/tq_eeprom.h","diff":"diff --git a/drivers/sysinfo/Kconfig b/drivers/sysinfo/Kconfig\nindex df83df69ffb..6922dac9170 100644\n--- a/drivers/sysinfo/Kconfig\n+++ b/drivers/sysinfo/Kconfig\n@@ -59,4 +59,12 @@ config SYSINFO_GPIO\n \t  This ternary number is then mapped to a board revision name using\n \t  device tree properties.\n \n+config SYSINFO_TQ_EEPROM\n+\tbool \"Enable TQ-Systems EEPROM sysinfo driver\"\n+\tdepends on I2C_EEPROM\n+\tdepends on SPL_I2C_EEPROM || !SPL_SYSINFO\n+\thelp\n+\t  Support querying EEPROM of TQ-Systems SOMs to determine board\n+\t  information.\n+\n endif\ndiff --git a/drivers/sysinfo/Makefile b/drivers/sysinfo/Makefile\nindex 26ca3150999..d21fb3c2270 100644\n--- a/drivers/sysinfo/Makefile\n+++ b/drivers/sysinfo/Makefile\n@@ -9,3 +9,4 @@ obj-$(CONFIG_SYSINFO_IOT2050) += iot2050.o\n obj-$(CONFIG_SYSINFO_RCAR3) += rcar3.o\n obj-$(CONFIG_SYSINFO_SANDBOX) += sandbox.o\n obj-$(CONFIG_SYSINFO_SMBIOS) += smbios.o\n+obj-$(CONFIG_SYSINFO_TQ_EEPROM) += tq_eeprom.o\ndiff --git a/drivers/sysinfo/tq_eeprom.c b/drivers/sysinfo/tq_eeprom.c\nnew file mode 100644\nindex 00000000000..b10803f9b5a\n--- /dev/null\n+++ b/drivers/sysinfo/tq_eeprom.c\n@@ -0,0 +1,223 @@\n+// SPDX-License-Identifier: GPL-2.0-or-later\n+/*\n+ * Copyright (c) 2014-2026 TQ-Systems GmbH <u-boot@ew.tq-group.com>,\n+ * D-82229 Seefeld, Germany.\n+ * Author: Nora Schiffer\n+ */\n+\n+#include <display_options.h>\n+#include <dm.h>\n+#include <i2c_eeprom.h>\n+#include <log.h>\n+#include <net.h>\n+#include <dm/device_compat.h>\n+#include <linux/ctype.h>\n+#include <linux/sizes.h>\n+#include <sysinfo/tq_eeprom.h>\n+\n+#define TQ_EE_RSV0_BYTES\t\t0x20\n+#define TQ_EE_RSV1_BYTES\t\t10\n+#define TQ_EE_SERIAL_BYTES\t\t8\n+#define TQ_EE_RSV2_BYTES\t\t8\n+#define TQ_EE_BDID_BYTES\t\t0x40\n+\n+struct tq_eeprom_data {\n+\tu8 rsv0[TQ_EE_RSV0_BYTES];\n+\tu8 mac[ETH_ALEN];\t\t/* 0x20 ... 0x25 */\n+\tu8 rsv1[TQ_EE_RSV1_BYTES];\n+\tu8 serial[TQ_EE_SERIAL_BYTES];\t/* 0x30 ... 0x37 */\n+\tu8 rsv2[TQ_EE_RSV2_BYTES];\n+\tu8 id[TQ_EE_BDID_BYTES];\t/* 0x40 ... 0x7f */\n+};\n+\n+static_assert(sizeof(struct tq_eeprom_data) == 0x80,\n+\t      \"struct tq_eeprom_data has incorrect size\");\n+\n+/**\n+ * struct sysinfo_tq_eeprom_priv - sysinfo private data\n+ */\n+struct sysinfo_tq_eeprom_priv {\n+\tstruct udevice *i2c_eeprom;\n+\tint offset;\n+\n+\t/* Reserve extra space for \\0 in id and serial */\n+\tchar id[TQ_EE_BDID_BYTES + 1];\n+\tchar serial[TQ_EE_SERIAL_BYTES + 1];\n+\tu8 mac[ETH_ALEN];\n+};\n+\n+static void tq_eeprom_parse_id(struct udevice *dev, const struct tq_eeprom_data *data)\n+{\n+\tstruct sysinfo_tq_eeprom_priv *priv = dev_get_priv(dev);\n+\tint i;\n+\n+\tfor (i = 0; i < sizeof(data->id); i++) {\n+\t\tif (!(isprint(data->id[i]) && isascii(data->id[i])))\n+\t\t\tbreak;\n+\t}\n+\n+\tif (i == 0)\n+\t\tdev_warn(dev, \"no valid model name in EEPROM\\n\");\n+\n+\tsnprintf(priv->id, sizeof(priv->id), \"%.*s\", i, data->id);\n+}\n+\n+static int tq_eeprom_serial_len_old(const struct tq_eeprom_data *data)\n+{\n+\tint i;\n+\n+\tfor (i = 0; i < sizeof(data->serial); i++) {\n+\t\tif (!isdigit(data->serial[i]))\n+\t\t\tbreak;\n+\t}\n+\n+\treturn i;\n+}\n+\n+static int tq_eeprom_serial_len_new(const struct tq_eeprom_data *data)\n+{\n+\tint i;\n+\n+\tfor (i = 0; i < sizeof(data->serial); i++) {\n+\t\tif (!(isdigit(data->serial[i]) || isupper(data->serial[i])))\n+\t\t\tbreak;\n+\t}\n+\n+\treturn i;\n+}\n+\n+static void tq_eeprom_parse_serial(struct udevice *dev, const struct tq_eeprom_data *data)\n+{\n+\tstruct sysinfo_tq_eeprom_priv *priv = dev_get_priv(dev);\n+\tint len;\n+\n+\tif (data->serial[0] == 'T' && data->serial[1] == 'Q')\n+\t\tlen = tq_eeprom_serial_len_new(data);\n+\telse\n+\t\tlen = tq_eeprom_serial_len_old(data);\n+\n+\t/* For now, only serial numbers with the exact size of the field are accepted */\n+\tif (len != sizeof(data->serial)) {\n+\t\tdev_warn(dev, \"no valid serial number in EEPROM\\n\");\n+\t\tlen = 0;\n+\t}\n+\n+\tsnprintf(priv->serial, sizeof(priv->serial), \"%.*s\", len, data->serial);\n+}\n+\n+static int tq_eeprom_dump(const struct sysinfo_tq_eeprom_priv *priv)\n+{\n+\tprintf(\"TQ EEPROM:\\n\");\n+\tprintf(\"  ID:  %s\\n\", priv->id[0] ? priv->id : \"<invalid>\");\n+\tprintf(\"  SN:  %s\\n\", priv->serial[0] ? priv->serial : \"<invalid>\");\n+\tprintf(\"  MAC: \");\n+\tif (is_valid_ethaddr(priv->mac))\n+\t\tprintf(\"%pM\\n\", priv->mac);\n+\telse\n+\t\tprintf(\"<invalid>\\n\");\n+\n+\treturn 0;\n+}\n+\n+static int sysinfo_tq_eeprom_detect(struct udevice *dev)\n+{\n+\tstruct sysinfo_tq_eeprom_priv *priv = dev_get_priv(dev);\n+\tstruct tq_eeprom_data data;\n+\tint ret;\n+\n+\tret = i2c_eeprom_read(priv->i2c_eeprom, priv->offset,\n+\t\t\t      (u8 *)&data, sizeof(data));\n+\tif (ret < 0) {\n+\t\tdev_err(dev, \"EEPROM read failed: %d\\n\", ret);\n+\t\treturn -EIO;\n+\t}\n+\n+\ttq_eeprom_parse_id(dev, &data);\n+\ttq_eeprom_parse_serial(dev, &data);\n+\tmemcpy(priv->mac, data.mac, ETH_ALEN);\n+\n+\tif (!IS_ENABLED(CONFIG_SPL_BUILD))\n+\t\ttq_eeprom_dump(priv);\n+\n+\treturn 0;\n+}\n+\n+static int sysinfo_tq_eeprom_get_str(struct udevice *dev, int id, size_t size, char *val)\n+{\n+\tstruct sysinfo_tq_eeprom_priv *priv = dev_get_priv(dev);\n+\n+\tswitch (id) {\n+\tcase SYSID_TQ_MODEL:\n+\t\tif (!priv->id[0])\n+\t\t\treturn -ENODATA;\n+\n+\t\tstrlcpy(val, priv->id, size);\n+\t\treturn 0;\n+\n+\tcase SYSID_TQ_SERIAL:\n+\t\tif (!priv->serial[0])\n+\t\t\treturn -ENODATA;\n+\n+\t\tstrlcpy(val, priv->serial, size);\n+\t\treturn 0;\n+\n+\tdefault:\n+\t\treturn -EINVAL;\n+\t}\n+}\n+\n+static int sysinfo_tq_eeprom_get_data(struct udevice *dev, int id, void **data, size_t *size)\n+{\n+\tstruct sysinfo_tq_eeprom_priv *priv = dev_get_priv(dev);\n+\n+\tswitch (id) {\n+\tcase SYSID_TQ_MAC_ADDR:\n+\t\tif (!is_valid_ethaddr(priv->mac))\n+\t\t\treturn -ENODATA;\n+\n+\t\t*data = priv->mac;\n+\t\t*size = sizeof(priv->mac);\n+\n+\t\treturn 0;\n+\n+\tdefault:\n+\t\treturn -EINVAL;\n+\t}\n+}\n+\n+static const struct sysinfo_ops sysinfo_tq_eeprom_ops = {\n+\t.detect = sysinfo_tq_eeprom_detect,\n+\t.get_str = sysinfo_tq_eeprom_get_str,\n+\t.get_data = sysinfo_tq_eeprom_get_data,\n+};\n+\n+static int sysinfo_tq_eeprom_probe(struct udevice *dev)\n+{\n+\tstruct sysinfo_tq_eeprom_priv *priv = dev_get_priv(dev);\n+\tint ret;\n+\n+\tret = uclass_get_device_by_phandle(UCLASS_I2C_EEPROM, dev, \"i2c-eeprom\",\n+\t\t\t\t\t   &priv->i2c_eeprom);\n+\tif (ret) {\n+\t\tdev_err(dev, \"i2c-eeprom backing device not found: %d\\n\", ret);\n+\t\treturn ret;\n+\t}\n+\n+\tpriv->offset = dev_read_u32_default(dev, \"offset\", 0);\n+\n+\treturn 0;\n+}\n+\n+static const struct udevice_id sysinfo_tq_eeprom_ids[] = {\n+\t{ .compatible = \"tq,eeprom-sysinfo\" },\n+\t{ /* sentinel */ }\n+};\n+\n+U_BOOT_DRIVER(sysinfo_tq_eeprom) = {\n+\t.name           = \"sysinfo_tq_eeprom\",\n+\t.id             = UCLASS_SYSINFO,\n+\t.of_match       = sysinfo_tq_eeprom_ids,\n+\t.ops\t\t= &sysinfo_tq_eeprom_ops,\n+\t.priv_auto\t= sizeof(struct sysinfo_tq_eeprom_priv),\n+\t.probe          = sysinfo_tq_eeprom_probe,\n+};\ndiff --git a/include/sysinfo/tq_eeprom.h b/include/sysinfo/tq_eeprom.h\nnew file mode 100644\nindex 00000000000..6b1bddd7ce0\n--- /dev/null\n+++ b/include/sysinfo/tq_eeprom.h\n@@ -0,0 +1,24 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (c) 2023-2026 TQ-Systems GmbH <u-boot@ew.tq-group.com>,\n+ * D-82229 Seefeld, Germany.\n+ * Author: Nora Schiffer\n+ */\n+\n+#ifndef __SYSINFO_TQ_EEPROM_H__\n+#define __SYSINFO_TQ_EEPROM_H__\n+\n+#include <sysinfo.h>\n+\n+enum {\n+\t/* Model string of TQ-Systems SOM. This is different from BOARD_MODEL,\n+\t * which usually combines SOM and baseboard names for TQ hardware\n+\t */\n+\tSYSID_TQ_MODEL = SYSID_USER,\n+\t/* SOM serial number */\n+\tSYSID_TQ_SERIAL,\n+\t/* MAC address */\n+\tSYSID_TQ_MAC_ADDR,\n+};\n+\n+#endif /* __SYSINFO_TQ_EEPROM_H__ */\n","prefixes":["3/6"]}