From patchwork Tue Aug 6 07:33:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1969368 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=EUIo07Bx; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=IlDNC/Uz; 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 4WdQ7K0djSz1yYD for ; Tue, 6 Aug 2024 17:34:53 +1000 (AEST) 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:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wwxiHOgQx4dpvP7Oq95ihbimZXnFr3TXamXIux+US/Q=; b=EUIo07BxbzdPW+ Tqr6SOmo6r+d7EZmbaKxQdWGfng7KU84cE6bTO/ZDFR/Odi809oFour3D6a6d6O1M0crKJbkgrzSo m2DYDoH9TfFoQkhb+x86fUJf45Aoj7uxwsqqKLk2+msOvOW/z49pS+1ekm8u6e8RVDgmhBFajtagJ EfrJ1+Qnmt7FFtXMnDMwOiifhrr7IyYLsOQxhghqf0WLZiqOhhB3ofgAvcCfZJnzA98g8MKSQqFca kePaJe78r51AMbItbdn0JEQ2P/ULUzWNBXKp2AImpeiTe+HFhO4wk1hFi7yPR1CCjAhlwr1TTlKG0 8eI6buesaqnavBoL4LWw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sbEiS-00000000oKg-2Rwx; Tue, 06 Aug 2024 07:34:44 +0000 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sbEiD-00000000o9b-04gF for opensbi@lists.infradead.org; Tue, 06 Aug 2024 07:34:38 +0000 Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-7a1843b4cdbso327043a12.2 for ; Tue, 06 Aug 2024 00:34:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722929668; x=1723534468; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ay8ImBJARtaHmCOWagBjToOniPmKX3S+lmUJZyUxH4Y=; b=IlDNC/UzldOKCtZ+yO5qmiYH7hEWGjXBgZPUaJd3rNPguh5YOe8oFJ36dhSHAKRKqQ Xl86QyXSIJHLMz0uGl6ZMlszjgHKD8ZdAW0HAt03ObkaMnZ/zmoSar9rMBSjAC4/Hot3 5N/hRW2sPfD8zcO9kXRhtIIy/oMNF/p3ckz14Vd88zk4LNWGsb9qfUHIerDbAmiXC878 nMbcf40HOKL/u6Ke63fsD2Mi4fLEYuzTlkcCwH8bDJQLYYc+b+wey86AD07Qwy4kyk4x pSU2OLnO80VpA4p0YLQurWRp6fkcHDZ3r+O4JJWXSLKBULKiu7WzMUT1hTstJxXFIgDf KKpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722929668; x=1723534468; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ay8ImBJARtaHmCOWagBjToOniPmKX3S+lmUJZyUxH4Y=; b=xB17VeT3mV325x69Ym3Nnc/Xz06Q3KXpLS6KBIvDYcIZMiYY7hjVeAwrS1Ywv0OcPY qaZ7CNOtlAuBYGh8ZVV4NFdBVDe0Nz9kmBe9NycMLeUMYskHi++U/GENQ//LKp1R7Wzx fb02BN+BMQJv6Nn0hwCqxVDDgqhBB9EIAKsQarn++g+6Sp5hr2awmVicqi2xEjUqmgk3 2o6szBGIioZG2CSuU15LXSR06iXdoK85xoiORyCv8aQ6nSAGYPKerUoc9bLHKt1xsFRK h2+KaoW7c6ApRAOu2EZlL2ryX7gZBwvgNXnVcJCTp2OkRru9FB+07aY5UnVsbYDLhN2D LVFQ== X-Forwarded-Encrypted: i=1; AJvYcCV9D/7b/BhtUJnrMz4oGfB6O8kmFNYChjSo2X+j7O4LpBRegqxBMzsIAA2J8FoZoIPWjQvWrpRu@lists.infradead.org X-Gm-Message-State: AOJu0Yy9bCSpIEo2y51OrGfvjbOHrkc9NGbXYdfmMw9RXjOP+F7tHzwD c2DTUjHX862yKOkh/ATzJoUQ9H4BC9CGhlMnGwkubk4xj5zyI4JKtsASdwYiCFA= X-Google-Smtp-Source: AGHT+IGfBG5zHDUfK4ZBZDx5bW84TFWUhvk2fFYMBhwzV7gIjEvQGmv5HZi/YUzV8L9f60HBXWbqAA== X-Received: by 2002:a05:6a20:7f94:b0:1be:c2f7:275 with SMTP id adf61e73a8af0-1c69969b5c0mr14446885637.50.1722929667658; Tue, 06 Aug 2024 00:34:27 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([223.185.134.124]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7106ed2de28sm6455011b3a.191.2024.08.06.00.34.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Aug 2024 00:34:27 -0700 (PDT) From: Anup Patel To: Atish Patra Cc: Andrew Jones , Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 15/16] lib: utils: Add simple FDT based MPXY driver framework Date: Tue, 6 Aug 2024 13:03:37 +0530 Message-Id: <20240806073338.1856901-16-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240806073338.1856901-1-apatel@ventanamicro.com> References: <20240806073338.1856901-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240806_003429_165032_F7333C3D X-CRM114-Status: GOOD ( 18.74 ) 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: The generic platform can have multiple MPXY drivers so add a simple FDT based MPXY driver framework. Signed-off-by: Anup Patel --- include/sbi_utils/mpxy/fdt_mpxy.h | 31 ++++++++++++++++ lib/utils/Kconfig | 2 ++ lib/utils/mpxy/Kconfig | 10 ++++++ lib/utils/mpxy/fdt_mpxy.c | [...] 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:533 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_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -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 The generic platform can have multiple MPXY drivers so add a simple FDT based MPXY driver framework. Signed-off-by: Anup Patel --- include/sbi_utils/mpxy/fdt_mpxy.h | 31 ++++++++++++++++ lib/utils/Kconfig | 2 ++ lib/utils/mpxy/Kconfig | 10 ++++++ lib/utils/mpxy/fdt_mpxy.c | 50 ++++++++++++++++++++++++++ lib/utils/mpxy/fdt_mpxy_drivers.carray | 3 ++ lib/utils/mpxy/objects.mk | 11 ++++++ platform/generic/configs/defconfig | 1 + platform/generic/platform.c | 2 ++ 8 files changed, 110 insertions(+) create mode 100644 include/sbi_utils/mpxy/fdt_mpxy.h create mode 100644 lib/utils/mpxy/Kconfig create mode 100644 lib/utils/mpxy/fdt_mpxy.c create mode 100644 lib/utils/mpxy/fdt_mpxy_drivers.carray create mode 100644 lib/utils/mpxy/objects.mk diff --git a/include/sbi_utils/mpxy/fdt_mpxy.h b/include/sbi_utils/mpxy/fdt_mpxy.h new file mode 100644 index 00000000..7ea26055 --- /dev/null +++ b/include/sbi_utils/mpxy/fdt_mpxy.h @@ -0,0 +1,31 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2024 Ventana Micro Systems Inc. + * + * Authors: + * Anup Patel + */ + +#ifndef __FDT_MPXY_H__ +#define __FDT_MPXY_H__ + +#include + +#ifdef CONFIG_FDT_MPXY + +struct fdt_mpxy { + const struct fdt_match *match_table; + int (*init)(void *fdt, int nodeoff, const struct fdt_match *match); + void (*exit)(void); +}; + +int fdt_mpxy_init(void); + +#else + +static inline int fdt_mpxy_init(void) { return 0; } + +#endif + +#endif diff --git a/lib/utils/Kconfig b/lib/utils/Kconfig index 002d6f8f..901ba564 100644 --- a/lib/utils/Kconfig +++ b/lib/utils/Kconfig @@ -32,4 +32,6 @@ source "$(OPENSBI_SRC_DIR)/lib/utils/sys/Kconfig" source "$(OPENSBI_SRC_DIR)/lib/utils/timer/Kconfig" +source "$(OPENSBI_SRC_DIR)/lib/utils/mpxy/Kconfig" + endmenu diff --git a/lib/utils/mpxy/Kconfig b/lib/utils/mpxy/Kconfig new file mode 100644 index 00000000..d084b09a --- /dev/null +++ b/lib/utils/mpxy/Kconfig @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-2-Clause + +menu "MPXY Device Support" + +config FDT_MPXY + bool "FDT based MPXY drivers" + depends on FDT + default n + +endmenu diff --git a/lib/utils/mpxy/fdt_mpxy.c b/lib/utils/mpxy/fdt_mpxy.c new file mode 100644 index 00000000..41753fab --- /dev/null +++ b/lib/utils/mpxy/fdt_mpxy.c @@ -0,0 +1,50 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2024 Ventana Micro Systems Inc. + * + * Authors: + * Anup Patel + */ + +#include +#include +#include + +/* List of FDT MPXY drivers generated at compile time */ +extern struct fdt_mpxy *fdt_mpxy_drivers[]; +extern unsigned long fdt_mpxy_drivers_size; + +int fdt_mpxy_init(void) +{ + int pos, noff, rc; + struct fdt_mpxy *drv; + const struct fdt_match *match; + void *fdt = fdt_get_address(); + + for (pos = 0; pos < fdt_mpxy_drivers_size; pos++) { + drv = fdt_mpxy_drivers[pos]; + + noff = -1; + while ((noff = fdt_find_match(fdt, noff, + drv->match_table, &match)) >= 0) { + /* drv->init must not be NULL */ + if (drv->init == NULL) + return SBI_EFAIL; + + rc = drv->init(fdt, noff, match); + if (rc == SBI_ENODEV) + continue; + if (rc) + return rc; + + /* + * We will have multiple MPXY devices so we + * cannot break here. + */ + } + } + + /* Platforms might not have any MPXY devices so don't fail */ + return 0; +} diff --git a/lib/utils/mpxy/fdt_mpxy_drivers.carray b/lib/utils/mpxy/fdt_mpxy_drivers.carray new file mode 100644 index 00000000..d930753a --- /dev/null +++ b/lib/utils/mpxy/fdt_mpxy_drivers.carray @@ -0,0 +1,3 @@ +HEADER: sbi_utils/mpxy/fdt_mpxy.h +TYPE: struct fdt_mpxy +NAME: fdt_mpxy_drivers diff --git a/lib/utils/mpxy/objects.mk b/lib/utils/mpxy/objects.mk new file mode 100644 index 00000000..43e73c94 --- /dev/null +++ b/lib/utils/mpxy/objects.mk @@ -0,0 +1,11 @@ +# +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (c) 2024 Ventana Micro Systems Inc. +# +# Authors: +# Anup Patel +# + +libsbiutils-objs-$(CONFIG_FDT_MPXY) += mpxy/fdt_mpxy.o +libsbiutils-objs-$(CONFIG_FDT_MPXY) += mpxy/fdt_mpxy_drivers.carray.o diff --git a/platform/generic/configs/defconfig b/platform/generic/configs/defconfig index 384918f9..1f0880ee 100644 --- a/platform/generic/configs/defconfig +++ b/platform/generic/configs/defconfig @@ -53,3 +53,4 @@ CONFIG_FDT_SUSPEND_RPMI=y CONFIG_FDT_TIMER=y CONFIG_FDT_TIMER_MTIMER=y CONFIG_FDT_TIMER_PLMT=y +CONFIG_FDT_MPXY=y diff --git a/platform/generic/platform.c b/platform/generic/platform.c index d085647d..89bd3af9 100644 --- a/platform/generic/platform.c +++ b/platform/generic/platform.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -418,6 +419,7 @@ const struct sbi_platform_operations platform_ops = { .get_tlb_num_entries = generic_tlb_num_entries, .timer_init = fdt_timer_init, .timer_exit = fdt_timer_exit, + .mpxy_init = fdt_mpxy_init, .vendor_ext_check = generic_vendor_ext_check, .vendor_ext_provider = generic_vendor_ext_provider, };