[PATCH v9 05/13] fpga: add fpga_compatible2flag
Oleksandr Suvorov
oleksandr.suvorov at foundries.io
Wed Jun 1 10:46:15 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>
---
(no changes since v1)
drivers/fpga/fpga.c | 26 ++++++++++++++++++++++++++
include/fpga.h | 1 +
2 files changed, 27 insertions(+)
diff --git a/drivers/fpga/fpga.c b/drivers/fpga/fpga.c
index 3b0a44b2420..fbfdd406e3b 100644
--- a/drivers/fpga/fpga.c
+++ b/drivers/fpga/fpga.c
@@ -356,3 +356,29 @@ 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 FPGA_FAIL;
+
+ switch (desc->devtype) {
+ case fpga_xilinx:
+#if defined(CONFIG_FPGA_XILINX)
+ {
+ xilinx_desc *xdesc = (xilinx_desc *)desc->devdesc;
+
+ if (xdesc->operations->str2flag)
+ return xdesc->operations->str2flag(xdesc, compatible);
+ }
+#else
+ return FPGA_FAIL;
+#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