Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.2/patches/2224263/?format=api
{ "id": 2224263, "url": "http://patchwork.ozlabs.org/api/1.2/patches/2224263/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/20260417080616.5050-1-othacehe@gnu.org/", "project": { "id": 18, "url": "http://patchwork.ozlabs.org/api/1.2/projects/18/?format=api", "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": "<20260417080616.5050-1-othacehe@gnu.org>", "list_archive_url": null, "date": "2026-04-17T08:06:15", "name": "[v2] misc: Add RZG2L OTP support", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "126fa0685c56435cbcd10a19ff11355717005376", "submitter": { "id": 87750, "url": "http://patchwork.ozlabs.org/api/1.2/people/87750/?format=api", "name": "Mathieu Othacehe", "email": "othacehe@gnu.org" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/uboot/patch/20260417080616.5050-1-othacehe@gnu.org/mbox/", "series": [ { "id": 500265, "url": "http://patchwork.ozlabs.org/api/1.2/series/500265/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/list/?series=500265", "date": "2026-04-17T08:06:15", "name": "[v2] misc: Add RZG2L OTP support", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/500265/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2224263/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2224263/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=pass (2048-bit key;\n unprotected) header.d=gnu.org header.i=@gnu.org header.a=rsa-sha256\n header.s=fencepost-gnu-org header.b=gyYQYXJq;\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=pass (p=none dis=none) header.from=gnu.org", "phobos.denx.de;\n spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de", "phobos.denx.de;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gnu.org header.i=@gnu.org header.b=\"gyYQYXJq\";\n\tdkim-atps=neutral", "phobos.denx.de;\n dmarc=pass (p=none dis=none) header.from=gnu.org", "phobos.denx.de;\n spf=pass smtp.mailfrom=othacehe@gnu.org" ], "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 4fxnX9403jz1yDF\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 17 Apr 2026 18:06:33 +1000 (AEST)", "from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id CD2B384223;\n\tFri, 17 Apr 2026 10:06:30 +0200 (CEST)", "by phobos.denx.de (Postfix, from userid 109)\n id 091E084228; Fri, 17 Apr 2026 10:06:29 +0200 (CEST)", "from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10])\n (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n (No client certificate requested)\n by phobos.denx.de (Postfix) with ESMTPS id CCAA583FC0\n for <u-boot@lists.denx.de>; Fri, 17 Apr 2026 10:06:26 +0200 (CEST)", "from fencepost.gnu.org ([2001:470:142:3::e])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <othacehe@gnu.org>)\n id 1wDeDY-0004sr-Mc; Fri, 17 Apr 2026 04:06:24 -0400" ], "X-Spam-Checker-Version": "SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de", "X-Spam-Level": "", "X-Spam-Status": "No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,\n DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,\n RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_PASS autolearn=ham\n autolearn_force=no version=3.4.2", "DKIM-Signature": "v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;\n s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to:\n references; bh=8V4OfZTzsuFp2RV55w/cWcNL/Cd5NYU/JsfBtVVo/xk=; b=gyYQYXJqJzTPaD\n FWhmVMfeUBSxb3Uzgpvnne7hX7OwgzPMJY8+JxBa4ZIabpXyEg0nH0UARynuIqF3v/6m0zpl+KrZK\n LwVeyXI6tljFuaFnc73zqui1lDk41bgH7DEQ/aftqFJilc3xcS+WuGs1cI5wK9gpFwUI0IcykdIsT\n alR+oVE9G1oN9R8aqjFODAwFBLujmJHxgATrR1pBWiFMH4lJqR/+kpD/TKu9ZGS8zqwppCP1RAU1n\n 1e8lhdiVe7GFr60EqbaUi+nDe5cdGZznQngPQHn02FZYWp+BNiFBjuZG1aYrhkh2TZ3umkh9Sei4E\n us1mWZ/Rht0UZ3o4tTUg==;", "From": "Mathieu Othacehe <othacehe@gnu.org>", "To": "Tom Rini <trini@konsulko.com>,\n Marek Vasut <marek.vasut+renesas@mailbox.org>,\n Paul Barker <paul@pbarker.dev>, Nobuhiro Iwamatsu <iwamatsu@nigauri.org>", "Cc": "Mathieu Othacehe <othacehe@gnu.org>,\n\tu-boot@lists.denx.de", "Subject": "[PATCH v2] misc: Add RZG2L OTP support", "Date": "Fri, 17 Apr 2026 10:06:15 +0200", "Message-ID": "<20260417080616.5050-1-othacehe@gnu.org>", "X-Mailer": "git-send-email 2.52.0", "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": "Add OTP support through the fuse command. Fusing is directly performed by\nU-Boot, which means that the trusted-firmware must allow the non-secure\nworld to perform fusing operations.\n\nSigned-off-by: Mathieu Othacehe <othacehe@gnu.org>\n---\nChangelog\nv2: Depend on CMD_FUSE. Use readl_poll_sleep_timeout and clrbits_le32 functions.\n\n drivers/misc/Kconfig | 7 ++\n drivers/misc/Makefile | 1 +\n drivers/misc/rzg2l_otp.c | 221 +++++++++++++++++++++++++++++++++++++++\n 3 files changed, 229 insertions(+)\n create mode 100644 drivers/misc/rzg2l_otp.c", "diff": "diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig\nindex ea785793d18..324a88c9494 100644\n--- a/drivers/misc/Kconfig\n+++ b/drivers/misc/Kconfig\n@@ -132,6 +132,13 @@ config SPL_ROCKCHIP_IODOMAIN\n \t for the IO-domain setting of the SoC to match the voltage supplied\n \t by the regulators.\n \n+config RZG2L_OTP\n+\tbool \"Renesas RZ/G2L OTP support\"\n+\tdepends on MISC && CMD_FUSE\n+\thelp\n+\t Enable support for the OTP controller on\n+\t Renesas RZ/G2L SoCs.\n+\n config SIFIVE_OTP\n \tbool \"SiFive eMemory OTP driver\"\n \tdepends on MISC\ndiff --git a/drivers/misc/Makefile b/drivers/misc/Makefile\nindex e2170212e5a..64b2701b672 100644\n--- a/drivers/misc/Makefile\n+++ b/drivers/misc/Makefile\n@@ -69,6 +69,7 @@ obj-$(CONFIG_QCOM_GENI) += qcom_geni.o\n obj-$(CONFIG_$(PHASE_)ROCKCHIP_EFUSE) += rockchip-efuse.o\n obj-$(CONFIG_$(PHASE_)ROCKCHIP_OTP) += rockchip-otp.o\n obj-$(CONFIG_$(PHASE_)ROCKCHIP_IODOMAIN) += rockchip-io-domain.o\n+obj-$(CONFIG_RZG2L_OTP) += rzg2l_otp.o\n obj-$(CONFIG_SANDBOX) += syscon_sandbox.o misc_sandbox.o\n obj-$(CONFIG_SIFIVE_OTP) += sifive-otp.o\n obj-$(CONFIG_SMSC_LPC47M) += smsc_lpc47m.o\ndiff --git a/drivers/misc/rzg2l_otp.c b/drivers/misc/rzg2l_otp.c\nnew file mode 100644\nindex 00000000000..fe971bcb6c3\n--- /dev/null\n+++ b/drivers/misc/rzg2l_otp.c\n@@ -0,0 +1,221 @@\n+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)\n+/*\n+ * Copyright (C) 2026 Mathieu Othacehe <m.othacehe@gmail.com>\n+ */\n+#include <fuse.h>\n+#include <asm/io.h>\n+#include <linux/delay.h>\n+#include <linux/iopoll.h>\n+\n+/*\n+ * XXX: To enable direct fusing through U-Boot, the trusted-firmware must\n+ * allow the non-secure world to perform fusing operations. This is controlled\n+ * by the SYS_SLVACCCTL7 register.\n+ */\n+#define RZG2L_OTP_BASE 0x11860000\n+#define RZG2L_SYSC_BASE 0x11020000\n+\n+#define RZ_SYS_BASE_DEVID (RZG2L_SYSC_BASE + 0x0A04)\n+#define RZ_OTP_BASE_DEVID (RZG2L_OTP_BASE + 0x1178)\n+#define RZ_OTP_BASE_CHIPID (RZG2L_OTP_BASE + 0x1140)\n+\n+#define RZ_OTP_PWR (RZG2L_OTP_BASE + 0x0000)\n+#define RZ_OTP_STR (RZG2L_OTP_BASE + 0x0004)\n+#define RZ_OTP_STAWR (RZG2L_OTP_BASE + 0x0008)\n+#define RZ_OTP_ADRWR (RZG2L_OTP_BASE + 0x000c)\n+#define RZ_OTP_DATAWR (RZG2L_OTP_BASE + 0x0010)\n+\n+#define RZ_OTP_ADRRD (RZG2L_OTP_BASE + 0x0014)\n+#define RZ_OTP_DATARD (RZG2L_OTP_BASE + 0x0018)\n+\n+#define RZ_OTP_FLAG (RZG2L_OTP_BASE + 0x001c)\n+\n+#define OTP_PWR\t\t BIT(0)\n+#define OTP_RDY\t\t BIT(0)\n+#define ERR_WR_1\t BIT(1)\n+#define ERR_WR_2\t BIT(2)\n+#define ERR_WP\t\t BIT(3)\n+#define OTP_ACCL\t BIT(4)\n+#define ERR_RDY_WR\t BIT(8)\n+#define OTP_DUMMY_READ\t 0x100\n+\n+#define RZ_OTP_POLL(reg, val, cond) \\\n+\treadl_poll_sleep_timeout((reg), (val), (cond), 1000, 1000000)\n+\n+static int rzg2l_otp_open(void)\n+{\n+\tu32 val;\n+\tint ret;\n+\n+\tif (readl(RZ_OTP_PWR) & OTP_PWR) {\n+\t\tdebug(\"OTP already powered up\\n\");\n+\t\treturn 0;\n+\t}\n+\n+\tret = RZ_OTP_POLL(RZ_OTP_STR, val, !(val & OTP_RDY));\n+\tif (ret) {\n+\t\tprintf(\"OTP power-up timeout\\n\");\n+\t\treturn ret;\n+\t}\n+\n+\tret = RZ_OTP_POLL(RZ_OTP_FLAG, val, val & OTP_RDY);\n+\tif (ret) {\n+\t\tprintf(\"OTP power-up timeout\\n\");\n+\t\treturn ret;\n+\t}\n+\n+\twritel(readl(RZ_OTP_PWR) | OTP_PWR | OTP_ACCL, RZ_OTP_PWR);\n+\n+\treturn 0;\n+}\n+\n+static int rzg2l_otp_dummy_read(void)\n+{\n+\tu32 val;\n+\tint ret;\n+\n+\tret = RZ_OTP_POLL(RZ_OTP_STR, val, val & OTP_RDY);\n+\tif (ret) {\n+\t\tprintf(\"Timeout polling ready for OTP read\\n\");\n+\t\treturn ret;\n+\t}\n+\n+\twritel(RZG2L_OTP_BASE + OTP_DUMMY_READ, RZ_OTP_ADRRD);\n+\treadl(RZ_OTP_DATARD);\n+\n+\treturn 0;\n+}\n+\n+static int rzg2l_otp_close(void)\n+{\n+\tu32 val;\n+\tint ret;\n+\n+\trzg2l_otp_dummy_read();\n+\n+\tclrbits_le32((void *)RZ_OTP_PWR, OTP_PWR | OTP_ACCL);\n+\n+\tret = RZ_OTP_POLL(RZ_OTP_STR, val, !(val & OTP_RDY));\n+\tif (ret) {\n+\t\tprintf(\"Timeout leaving OTP ready state\\n\");\n+\t\treturn ret;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static int rzg2l_otp_read_word(u32 addr, u32 *val)\n+{\n+\tu32 str;\n+\tint ret;\n+\n+\tret = rzg2l_otp_open();\n+\tif (ret < 0)\n+\t\treturn ret;\n+\n+\tret = RZ_OTP_POLL(RZ_OTP_STR, str, str & OTP_RDY);\n+\tif (ret) {\n+\t\tprintf(\"Timeout polling ready for OTP read\\n\");\n+\t\trzg2l_otp_close();\n+\t\treturn ret;\n+\t}\n+\n+\twritel(addr, RZ_OTP_ADRRD);\n+\t*val = readl(RZ_OTP_DATARD);\n+\n+\tret = rzg2l_otp_close();\n+\n+\treturn ret;\n+}\n+\n+static int rzg2l_otp_program_word(u32 addr, u32 val)\n+{\n+\tu32 str, otpval;\n+\tint ret;\n+\n+\tret = rzg2l_otp_open();\n+\tif (ret < 0)\n+\t\treturn ret;\n+\n+\tret = RZ_OTP_POLL(RZ_OTP_STR, str, str & OTP_RDY);\n+\tif (ret) {\n+\t\tprintf(\"Timeout polling ready for OTP write\\n\");\n+\t\tgoto close;\n+\t}\n+\n+\twritel(addr, RZ_OTP_ADRWR);\n+\twritel(val, RZ_OTP_DATAWR);\n+\n+\twritel(1, RZ_OTP_STAWR);\n+\n+\tif (readl(RZ_OTP_STR) & ERR_RDY_WR) {\n+\t\tprintf(\"OTP not ready for write\\n\");\n+\t\twritel(readl(RZ_OTP_STR) & ERR_RDY_WR, RZ_OTP_STR);\n+\t\tgoto close;\n+\t}\n+\n+\tret = RZ_OTP_POLL(RZ_OTP_STR, str, str & OTP_RDY);\n+\tif (ret) {\n+\t\tprintf(\"Timeout polling OTP write finished\\n\");\n+\t\tgoto close;\n+\t}\n+\n+\tret = RZ_OTP_POLL(RZ_OTP_STAWR, str, !(str & OTP_RDY));\n+\tif (ret) {\n+\t\tprintf(\"Timeout polling OTP write finished\\n\");\n+\t\tgoto close;\n+\t}\n+\n+\tif ((readl(RZ_OTP_STR) & ERR_WP) ||\n+\t (readl(RZ_OTP_STR) & ERR_WR_1) ||\n+\t (readl(RZ_OTP_STR) & ERR_WR_2)) {\n+\t\tprintf(\"OTP write error (protected or invalid)\\n\");\n+\t\tgoto close;\n+\t}\n+\n+\twritel(addr, RZ_OTP_ADRRD);\n+\totpval = readl(RZ_OTP_DATARD);\n+\n+\tif (otpval != val) {\n+\t\tprintf(\"OTP verify failed: wrote 0x%08x read 0x%08x\\n\",\n+\t\t val, otpval);\n+\t\tgoto close;\n+\t}\n+\n+close:\n+\tret = rzg2l_otp_close();\n+\treturn ret;\n+}\n+\n+/* ---------------------------------------------------------------- */\n+/* U-Boot fuse API */\n+\n+int fuse_read(u32 bank, u32 word, u32 *val)\n+{\n+\tu32 addr;\n+\n+\taddr = RZG2L_OTP_BASE + (word >> 2);\n+\n+\treturn rzg2l_otp_read_word(addr, val);\n+}\n+\n+int fuse_prog(u32 bank, u32 word, u32 val)\n+{\n+\tu32 addr;\n+\n+\taddr = RZG2L_OTP_BASE + (word >> 2);\n+\n+\treturn rzg2l_otp_program_word(addr, val);\n+}\n+\n+int fuse_sense(u32 bank, u32 word, u32 *val)\n+{\n+\t/* not supported */\n+\treturn -ENOSYS;\n+}\n+\n+int fuse_override(u32 bank, u32 word, u32 val)\n+{\n+\t/* not supported */\n+\treturn -ENOSYS;\n+}\n", "prefixes": [ "v2" ] }