event: Add fpga load event

This enables implementing custom logic after a bitstream was loaded
into the fpga.

Signed-off-by: Christian Taedcke <christian.taedcke@weidmueller.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
Link: https://lore.kernel.org/r/20230720072724.11516-1-christian.taedcke-oss@weidmueller.com
Signed-off-by: Michal Simek <michal.simek@amd.com>
This commit is contained in:
Christian Taedcke 2023-07-20 09:27:24 +02:00 committed by Michal Simek
parent 2a907542c7
commit a1190b4d6a
3 changed files with 40 additions and 0 deletions

View File

@ -36,6 +36,9 @@ const char *const type_name[] = {
/* init hooks */ /* init hooks */
"misc_init_f", "misc_init_f",
/* Fpga load hook */
"fpga_load",
/* fdt hooks */ /* fdt hooks */
"ft_fixup", "ft_fixup",

View File

@ -244,6 +244,21 @@ int fpga_loads(int devnum, const void *buf, size_t size,
} }
#endif #endif
static int fpga_load_event_notify(const void *buf, size_t bsize, int result)
{
if (CONFIG_IS_ENABLED(EVENT)) {
struct event_fpga_load load = {
.buf = buf,
.bsize = bsize,
.result = result
};
return event_notify(EVT_FPGA_LOAD, &load, sizeof(load));
}
return 0;
}
/* /*
* Generic multiplexing code * Generic multiplexing code
*/ */
@ -251,6 +266,7 @@ int fpga_load(int devnum, const void *buf, size_t bsize, bitstream_type bstype,
int flags) int flags)
{ {
int ret_val = FPGA_FAIL; /* assume failure */ int ret_val = FPGA_FAIL; /* assume failure */
int ret_notify;
const fpga_desc *desc = fpga_validate(devnum, buf, bsize, const fpga_desc *desc = fpga_validate(devnum, buf, bsize,
(char *)__func__); (char *)__func__);
@ -284,6 +300,10 @@ int fpga_load(int devnum, const void *buf, size_t bsize, bitstream_type bstype,
} }
} }
ret_notify = fpga_load_event_notify(buf, bsize, ret_val);
if (ret_notify)
return ret_notify;
return ret_val; return ret_val;
} }

View File

@ -11,6 +11,7 @@
#define __event_h #define __event_h
#include <dm/ofnode_decl.h> #include <dm/ofnode_decl.h>
#include <linux/types.h>
/** /**
* enum event_t - Types of events supported by U-Boot * enum event_t - Types of events supported by U-Boot
@ -31,6 +32,9 @@ enum event_t {
/* Init hooks */ /* Init hooks */
EVT_MISC_INIT_F, EVT_MISC_INIT_F,
/* Fpga load hook */
EVT_FPGA_LOAD,
/* Device tree fixups before booting */ /* Device tree fixups before booting */
EVT_FT_FIXUP, EVT_FT_FIXUP,
@ -59,6 +63,19 @@ union event_data {
struct udevice *dev; struct udevice *dev;
} dm; } dm;
/**
* struct event_fpga_load - fpga load event
*
* @buf: The buffer that was loaded into the fpga
* @bsize: The size of the buffer that was loaded into the fpga
* @result: Result of the load operation
*/
struct event_fpga_load {
const void *buf;
size_t bsize;
int result;
} fpga_load;
/** /**
* struct event_ft_fixup - FDT fixup before booting * struct event_ft_fixup - FDT fixup before booting
* *