From patchwork Tue Nov 5 04:20:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 2006640 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=MhMjjbDB; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256 header.s=google header.b=R+I5dZ3g; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XjFYn55P1z1xyM for ; Tue, 5 Nov 2024 15:22:53 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=eo3U55p4QLFz9nWaWTajXkQLdeXffibII4LInqOkqiE=; b=MhMjjbDB23nNjM jsrU/yTy1aSFW+MRaqFwtAoW5KiRuf3BO5of/8bwHKu9a39dbBW4yiUtZ+I9N53s0P9DzAU2dkWaS 2NaI7WQNQUxEDXUduQcKpsXfi6i/HKePgmk5UvR8dK7AoaKwWdN906JZCEB54Wr/kbR/0BQupBsof sD3s7ddm+z2p6brC+Nj2/mhsMT7wNbCyuCDsOEqRcJ7k8ZnF+SqktKRvswZmfPcV2e2hZB74j5fV7 7ygr4c7UCKN3Zu6Xczxkq8s1hzTauszczKljTf+F7F6zUPSRCnnCoc7d4fmy0WE7Ra1OnsbYDOdZr 2Sd2mem8juOqabLJ12ig==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t8B5Z-0000000FrJw-1hYn; Tue, 05 Nov 2024 04:22:45 +0000 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t8B5W-0000000FrIe-1id2 for opensbi@lists.infradead.org; Tue, 05 Nov 2024 04:22:44 +0000 Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-7ea7ad1e01fso3526115a12.0 for ; Mon, 04 Nov 2024 20:22:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1730780562; x=1731385362; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=bTmvnYp7d5Oo7l8i3SDDd/qzSxAKLGlLIF3k/Ih/RG4=; b=R+I5dZ3gbxuARvxMPGfZEjJOtdtOFCjSY3gcCiQM7XFwHE00ZrpC7mPvF0q3L0TFWe AFmIKzG3yUrJIrzKohBFyfKw0fpuYfWfb9YVyyE0ERbXGizIUn2j9laDP2PGYNfF075o yNP6n987AppgO57Jgo4FV2tcM+OhL7CwyXYnNGf0f6vxwIDRtF0GIxPNIvsE8GjR/9nO 7jeN18oQRv8o7C2rc9nBQ4TP+ebnUbUgyq4KXX7vL9XtRf6EPD7UgTzjqzYFLu4abZ6K paS6T5k/Xp/gv8Txqw4tz8JqfpM60JhmFcuywSero1GzLJyijbRMfiEZfotVeWWHvitd xSGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730780562; x=1731385362; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bTmvnYp7d5Oo7l8i3SDDd/qzSxAKLGlLIF3k/Ih/RG4=; b=ecYaXI9Ucsy/1Xj0gdwuPak0MR8S852itsv/4RTJEq4r8wvwHU5Q/oRdLcDhnq4iCk wXMvAc5IEhm1AegppTWBS2B1sB4wEJzKUN5D3kra2ASn8gbMYTjYq1JwMRYjja3IE279 8R/9nw0fu7x9aXecklqgqnjIjaqqmraTG/FWpdyW/bg5kCDYcG9gW12HOr9er0/y8rdi JeGf2KZO86LmIjoLYhhJwBe7rR/27Bvdsf/xkGtVABXVeUVf+6uVYVu9hBEakEKVkq+u JEobT4l73XEMiSKhu3iApn3P/LGtkDcjihAFihBEAdOK8wkqwwMlz16jfKjWcI6uXZB6 XVCQ== X-Gm-Message-State: AOJu0Yyg8psYqO90pakO9FaqvADsr1qX8vSlQxrllU3EhZwnUtPORVpf EZc63IlQFS026hhXgFMpnt6av6x+UJgJr6ezN/9tbjD0F0PoYbW2q7sj6O2AuetovzHS4V6GFXb FZM/jsaYITYYIJbsPi32NlTY1bu+QEQSUhhbDGrPJMKS9UgK4ucSWw5r21a5km+Q2nJ4mPylvI4 uKInPxzZEA3wJY9SwXOngUsZCygLTJA64FSxJMv6+PFZxE1BtqqPU= X-Google-Smtp-Source: AGHT+IHpQmTH2b9JSF3BI4nbOIsK2DDIb6MbNPlET/DVvdLuRcUyJlpzq/RCXhKr/vZPZQ7DZV3bhA== X-Received: by 2002:a05:6a21:6d9f:b0:1db:d6e4:d1d9 with SMTP id adf61e73a8af0-1dbd6e4d46dmr10322816637.1.1730780561529; Mon, 04 Nov 2024 20:22:41 -0800 (PST) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-720bc1e5a64sm8493782b3a.65.2024.11.04.20.22.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 20:22:41 -0800 (PST) From: Samuel Holland To: opensbi@lists.infradead.org Subject: [PATCH 0/6] Deduplicate driver initialization code Date: Mon, 4 Nov 2024 20:20:02 -0800 Message-ID: <20241105042240.2994849-1-samuel.holland@sifive.com> X-Mailer: git-send-email 2.45.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241104_202242_564615_443F5813 X-CRM114-Status: GOOD ( 10.29 ) X-Spam-Score: -2.1 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Upstreaming support for some of SiFive's security and power management features will require adding some new driver subsystems (e.g. caches, WorldGuard gadgets, power management domains, etc.). To avo [...] Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:529 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Upstreaming support for some of SiFive's security and power management features will require adding some new driver subsystems (e.g. caches, WorldGuard gadgets, power management domains, etc.). To avoid copy-and- pasting the FDT-based driver matching code to each new subsystem, this series refactors it into some efficient and easily-reusable helper functions. This series only converts three existing subsystems to use the new helpers, but the remaining subsystems are trivial to convert once the corresponding patch series I have already sent is applied: - gpio: http://lists.infradead.org/pipermail/opensbi/2024-September/007340.html - ipi: http://lists.infradead.org/pipermail/opensbi/2024-October/007546.html - irqchip: http://lists.infradead.org/pipermail/opensbi/2024-November/007555.html - regmap: http://lists.infradead.org/pipermail/opensbi/2024-September/007340.html - timer: http://lists.infradead.org/pipermail/opensbi/2024-September/007332.html Samuel Holland (6): lib: utils/gpio: Remove fdt_gpio_driver() function treewide: Make carray arrays const and NULL-terminated lib: utils/fdt: Add helpers for generic driver initialization lib: utils/i2c: Use fdt_driver for initialization lib: utils/reset: Use fdt_driver for initialization lib: utils/serial: Use fdt_driver for initialization include/sbi_utils/fdt/fdt_driver.h | 59 +++++++++++++++ include/sbi_utils/i2c/fdt_i2c.h | 8 +- include/sbi_utils/reset/fdt_reset.h | 15 +--- include/sbi_utils/serial/fdt_serial.h | 6 +- lib/sbi/sbi_ecall.c | 5 +- lib/sbi/tests/sbi_unit_test.c | 5 +- lib/utils/fdt/fdt_driver.c | 80 ++++++++++++++++++++ lib/utils/fdt/objects.mk | 1 + lib/utils/gpio/fdt_gpio.c | 22 +----- lib/utils/i2c/fdt_i2c.c | 31 +------- lib/utils/i2c/fdt_i2c_adapter_drivers.carray | 2 +- lib/utils/i2c/fdt_i2c_dw.c | 2 +- lib/utils/i2c/fdt_i2c_sifive.c | 2 +- lib/utils/ipi/fdt_ipi.c | 5 +- lib/utils/irqchip/fdt_irqchip.c | 5 +- lib/utils/regmap/fdt_regmap.c | 5 +- lib/utils/reset/fdt_reset.c | 37 +-------- lib/utils/reset/fdt_reset_atcwdt200.c | 2 +- lib/utils/reset/fdt_reset_drivers.carray | 2 +- lib/utils/reset/fdt_reset_gpio.c | 4 +- lib/utils/reset/fdt_reset_htif.c | 2 +- lib/utils/reset/fdt_reset_sg2042_hwmon_mcu.c | 2 +- lib/utils/reset/fdt_reset_sunxi_wdt.c | 2 +- lib/utils/reset/fdt_reset_syscon.c | 4 +- lib/utils/serial/fdt_serial.c | 53 ++----------- lib/utils/serial/fdt_serial_cadence.c | 2 +- lib/utils/serial/fdt_serial_drivers.carray | 2 +- lib/utils/serial/fdt_serial_gaisler.c | 2 +- lib/utils/serial/fdt_serial_htif.c | 2 +- lib/utils/serial/fdt_serial_litex.c | 2 +- lib/utils/serial/fdt_serial_renesas_scif.c | 2 +- lib/utils/serial/fdt_serial_shakti.c | 2 +- lib/utils/serial/fdt_serial_sifive.c | 2 +- lib/utils/serial/fdt_serial_uart8250.c | 2 +- lib/utils/serial/fdt_serial_xlnx_uartlite.c | 2 +- lib/utils/timer/fdt_timer.c | 5 +- platform/generic/platform.c | 5 +- platform/generic/sifive/fu740.c | 9 ++- platform/generic/starfive/jh7110.c | 9 ++- scripts/carray.sh | 7 +- 40 files changed, 211 insertions(+), 205 deletions(-) create mode 100644 include/sbi_utils/fdt/fdt_driver.h create mode 100644 lib/utils/fdt/fdt_driver.c