Registering and Unregistering the Event Handler - 2024.1 English

Versal Adaptive SoC System Software Developers Guide (UG1304)

Document ID
UG1304
Release Date
2024-05-30
Version
2024.1 English
Use the xlnx_register_event() API to register handler for the event(s). You can register a single handler for multiple events by using the OR operator on multiple event masks.
int xlnx_register_event(const enum pm_api_cb_id cb_type, const u32 node_id, const u32 event, const bool wake, event_cb_func_t cb_fun, void *data)

where,

cb_type
Type of callback from pm_api_cb_id
  • PM_NOTIFY_CB for error events.
  • PM_INIT_SUSPEND_CB for suspend callbacks.
node_id
The node ID for the error event.
event
The error event mask for the error event.
wake
Flag specifying whether the subsystem should be woken upon event notification.
cb_fun
Function pointer to store the callback function.
data
Pointer for the driver instance.

To get information or the macro for error event node-id and error event mask for Versal devices, see the include/linux/firmware/xlnx-versal-error-events.h file in Linux.

For example, assume that the agent is the DDRMC driver.

  1. Define the user callback function that needs to handle this error event.
    void xddr_err_callback(const u32 *payload, void *data)
    {
        /* Tack action */
    }

    The driver wants the appropriate data when xddr_err_callback() is called on occurrence of error event in firmware.

    Struct xddr_data
    {
        U32 var1;
        .
        .
    }
  2. Register for the DDRMC correctable and non-correctable error.
    xlnx_register_event(PM_NOTIFY_CB, XPM_NODETYPE_VERSAL_EVENT_ERROR_PMC_ERR1, XPM_VERSAL_EVENT_ERROR_MASK_DDRMC_CR | XPM_VERSAL_EVENT_ERROR_MASK_DDRMC_NCR, false, xddr_err_callback, (void *) data);
  3. Unregister for the DDRMC correctable and non-correctable error.
    ret = xlnx_unregister_event(PM_NOTIFY_CB, XPM_NODETYPE_VERSAL_EVENT_ERROR_PMC_ERR1, XPM_VERSAL_EVENT_ERROR_MASK_DDRMC_CR | XPM_VERSAL_EVENT_ERROR_MASK_DDRMC_NCR,
    xddr_err_callback,);