[PATCH v11 05/13] fpga: add fpga_compatible2flag

Oleksandr Suvorov oleksandr.suvorov at foundries.io
Tue Jul 5 21:23:12 CEST 2022


Add a "compatible" string to binary flag converter, which uses
a callback str2flag() of given FPGA driver if available.

Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov at foundries.io>
Tested-by: Ricardo Salveti <ricardo at foundries.io>
Tested-by: Adrian Fiergolski <adrian.fiergolski at fastree3d.com>
---

(no changes since v10)

Changes in v10:
- fix mixed types of return value;

 drivers/fpga/fpga.c | 24 ++++++++++++++++++++++++
 include/fpga.h      |  1 +
 2 files changed, 25 insertions(+)

diff --git a/drivers/fpga/fpga.c b/drivers/fpga/fpga.c
index 3b0a44b2420..a63bff1df94 100644
--- a/drivers/fpga/fpga.c
+++ b/drivers/fpga/fpga.c
@@ -356,3 +356,27 @@ int fpga_info(int devnum)
 
 	return fpga_dev_info(devnum);
 }
+
+int fpga_compatible2flag(int devnum, const char *compatible)
+{
+	const fpga_desc * const desc = fpga_get_desc(devnum);
+
+	if (!desc)
+		return 0;
+
+	switch (desc->devtype) {
+#if defined(CONFIG_FPGA_XILINX)
+	case fpga_xilinx:
+	{
+		xilinx_desc *xdesc = (xilinx_desc *)desc->devdesc;
+
+		if (xdesc->operations && xdesc->operations->str2flag)
+			return xdesc->operations->str2flag(xdesc, compatible);
+	}
+#endif
+	default:
+		break;
+	}
+
+	return 0;
+}
diff --git a/include/fpga.h b/include/fpga.h
index ec5144334df..2172b0d015e 100644
--- a/include/fpga.h
+++ b/include/fpga.h
@@ -75,5 +75,6 @@ int fpga_dump(int devnum, const void *buf, size_t bsize);
 int fpga_info(int devnum);
 const fpga_desc *const fpga_validate(int devnum, const void *buf,
 				     size_t bsize, char *fn);
+int fpga_compatible2flag(int devnum, const char *compatible);
 
 #endif	/* _FPGA_H_ */
-- 
2.36.1



More information about the U-Boot mailing list