Path: blob/master/drivers/accel/amdxdna/amdxdna_mailbox.h
26427 views
/* SPDX-License-Identifier: GPL-2.0 */1/*2* Copyright (C) 2022-2024, Advanced Micro Devices, Inc.3*/45#ifndef _AIE2_MAILBOX_H_6#define _AIE2_MAILBOX_H_78struct mailbox;9struct mailbox_channel;1011/*12* xdna_mailbox_msg - message struct13*14* @opcode: opcode for firmware15* @handle: handle used for the notify callback16* @notify_cb: callback function to notify the sender when there is response17* @send_data: pointing to sending data18* @send_size: size of the sending data19*20* The mailbox will split the sending data in to multiple firmware message if21* the size of the data is too big. This is transparent to the sender. The22* sender will receive one notification.23*/24struct xdna_mailbox_msg {25u32 opcode;26void *handle;27int (*notify_cb)(void *handle, void __iomem *data, size_t size);28u8 *send_data;29size_t send_size;30};3132/*33* xdna_mailbox_res - mailbox hardware resource34*35* @ringbuf_base: ring buffer base address36* @ringbuf_size: ring buffer size37* @mbox_base: mailbox base address38* @mbox_size: mailbox size39*/40struct xdna_mailbox_res {41void __iomem *ringbuf_base;42size_t ringbuf_size;43void __iomem *mbox_base;44size_t mbox_size;45const char *name;46};4748/*49* xdna_mailbox_chann_res - resources50*51* @rb_start_addr: ring buffer start address52* @rb_size: ring buffer size53* @mb_head_ptr_reg: mailbox head pointer register54* @mb_tail_ptr_reg: mailbox tail pointer register55*/56struct xdna_mailbox_chann_res {57u32 rb_start_addr;58u32 rb_size;59u32 mb_head_ptr_reg;60u32 mb_tail_ptr_reg;61};6263/*64* xdna_mailbox_create() -- create mailbox subsystem and initialize65*66* @ddev: device pointer67* @res: SRAM and mailbox resources68*69* Return: If success, return a handle of mailbox subsystem.70* Otherwise, return NULL pointer.71*/72struct mailbox *xdnam_mailbox_create(struct drm_device *ddev,73const struct xdna_mailbox_res *res);7475/*76* xdna_mailbox_create_channel() -- Create a mailbox channel instance77*78* @mailbox: the handle return from xdna_mailbox_create()79* @x2i: host to firmware mailbox resources80* @i2x: firmware to host mailbox resources81* @xdna_mailbox_intr_reg: register addr of MSI-X interrupt82* @mb_irq: Linux IRQ number associated with mailbox MSI-X interrupt vector index83*84* Return: If success, return a handle of mailbox channel. Otherwise, return NULL.85*/86struct mailbox_channel *87xdna_mailbox_create_channel(struct mailbox *mailbox,88const struct xdna_mailbox_chann_res *x2i,89const struct xdna_mailbox_chann_res *i2x,90u32 xdna_mailbox_intr_reg,91int mb_irq);9293/*94* xdna_mailbox_destroy_channel() -- destroy mailbox channel95*96* @mailbox_chann: the handle return from xdna_mailbox_create_channel()97*98* Return: if success, return 0. otherwise return error code99*/100int xdna_mailbox_destroy_channel(struct mailbox_channel *mailbox_chann);101102/*103* xdna_mailbox_stop_channel() -- stop mailbox channel104*105* @mailbox_chann: the handle return from xdna_mailbox_create_channel()106*107* Return: if success, return 0. otherwise return error code108*/109void xdna_mailbox_stop_channel(struct mailbox_channel *mailbox_chann);110111/*112* xdna_mailbox_send_msg() -- Send a message113*114* @mailbox_chann: Mailbox channel handle115* @msg: message struct for message information116* @tx_timeout: the timeout value for sending the message in ms.117*118* Return: If success return 0, otherwise, return error code119*/120int xdna_mailbox_send_msg(struct mailbox_channel *mailbox_chann,121const struct xdna_mailbox_msg *msg, u64 tx_timeout);122123#endif /* _AIE2_MAILBOX_ */124125126