]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
fpga: add fpga_compatible2flag
authorOleksandr Suvorov <oleksandr.suvorov@foundries.io>
Fri, 22 Jul 2022 14:16:08 +0000 (17:16 +0300)
committerMichal Simek <michal.simek@amd.com>
Tue, 26 Jul 2022 07:34:21 +0000 (09:34 +0200)
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@foundries.io>
Tested-by: Ricardo Salveti <ricardo@foundries.io>
Tested-by: Adrian Fiergolski <adrian.fiergolski@fastree3d.com>
Link: https://lore.kernel.org/r/20220722141614.297383-8-oleksandr.suvorov@foundries.io
Signed-off-by: Michal Simek <michal.simek@amd.com>
drivers/fpga/fpga.c
include/fpga.h

index 185bd547cb5e4409c23bfc20c2dd352b4f406079..4db5c0a91e98f5ff76fd433580fef7d8e3b8aefc 100644 (file)
@@ -357,3 +357,29 @@ int fpga_info(int devnum)
 
        return fpga_dev_info(devnum);
 }
+
+#if CONFIG_IS_ENABLED(FPGA_LOAD_SECURE)
+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;
+}
+#endif
index 6365e1569e3e0a144e09c7bbc56b49bd40f89ad6..13b1bbee3ca14bb1be34f3908a5809beb35fabf8 100644 (file)
@@ -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_ */