Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/drivers/accel/amdxdna/amdxdna_mailbox.h
26427 views
1
/* SPDX-License-Identifier: GPL-2.0 */
2
/*
3
* Copyright (C) 2022-2024, Advanced Micro Devices, Inc.
4
*/
5
6
#ifndef _AIE2_MAILBOX_H_
7
#define _AIE2_MAILBOX_H_
8
9
struct mailbox;
10
struct mailbox_channel;
11
12
/*
13
* xdna_mailbox_msg - message struct
14
*
15
* @opcode: opcode for firmware
16
* @handle: handle used for the notify callback
17
* @notify_cb: callback function to notify the sender when there is response
18
* @send_data: pointing to sending data
19
* @send_size: size of the sending data
20
*
21
* The mailbox will split the sending data in to multiple firmware message if
22
* the size of the data is too big. This is transparent to the sender. The
23
* sender will receive one notification.
24
*/
25
struct xdna_mailbox_msg {
26
u32 opcode;
27
void *handle;
28
int (*notify_cb)(void *handle, void __iomem *data, size_t size);
29
u8 *send_data;
30
size_t send_size;
31
};
32
33
/*
34
* xdna_mailbox_res - mailbox hardware resource
35
*
36
* @ringbuf_base: ring buffer base address
37
* @ringbuf_size: ring buffer size
38
* @mbox_base: mailbox base address
39
* @mbox_size: mailbox size
40
*/
41
struct xdna_mailbox_res {
42
void __iomem *ringbuf_base;
43
size_t ringbuf_size;
44
void __iomem *mbox_base;
45
size_t mbox_size;
46
const char *name;
47
};
48
49
/*
50
* xdna_mailbox_chann_res - resources
51
*
52
* @rb_start_addr: ring buffer start address
53
* @rb_size: ring buffer size
54
* @mb_head_ptr_reg: mailbox head pointer register
55
* @mb_tail_ptr_reg: mailbox tail pointer register
56
*/
57
struct xdna_mailbox_chann_res {
58
u32 rb_start_addr;
59
u32 rb_size;
60
u32 mb_head_ptr_reg;
61
u32 mb_tail_ptr_reg;
62
};
63
64
/*
65
* xdna_mailbox_create() -- create mailbox subsystem and initialize
66
*
67
* @ddev: device pointer
68
* @res: SRAM and mailbox resources
69
*
70
* Return: If success, return a handle of mailbox subsystem.
71
* Otherwise, return NULL pointer.
72
*/
73
struct mailbox *xdnam_mailbox_create(struct drm_device *ddev,
74
const struct xdna_mailbox_res *res);
75
76
/*
77
* xdna_mailbox_create_channel() -- Create a mailbox channel instance
78
*
79
* @mailbox: the handle return from xdna_mailbox_create()
80
* @x2i: host to firmware mailbox resources
81
* @i2x: firmware to host mailbox resources
82
* @xdna_mailbox_intr_reg: register addr of MSI-X interrupt
83
* @mb_irq: Linux IRQ number associated with mailbox MSI-X interrupt vector index
84
*
85
* Return: If success, return a handle of mailbox channel. Otherwise, return NULL.
86
*/
87
struct mailbox_channel *
88
xdna_mailbox_create_channel(struct mailbox *mailbox,
89
const struct xdna_mailbox_chann_res *x2i,
90
const struct xdna_mailbox_chann_res *i2x,
91
u32 xdna_mailbox_intr_reg,
92
int mb_irq);
93
94
/*
95
* xdna_mailbox_destroy_channel() -- destroy mailbox channel
96
*
97
* @mailbox_chann: the handle return from xdna_mailbox_create_channel()
98
*
99
* Return: if success, return 0. otherwise return error code
100
*/
101
int xdna_mailbox_destroy_channel(struct mailbox_channel *mailbox_chann);
102
103
/*
104
* xdna_mailbox_stop_channel() -- stop mailbox channel
105
*
106
* @mailbox_chann: the handle return from xdna_mailbox_create_channel()
107
*
108
* Return: if success, return 0. otherwise return error code
109
*/
110
void xdna_mailbox_stop_channel(struct mailbox_channel *mailbox_chann);
111
112
/*
113
* xdna_mailbox_send_msg() -- Send a message
114
*
115
* @mailbox_chann: Mailbox channel handle
116
* @msg: message struct for message information
117
* @tx_timeout: the timeout value for sending the message in ms.
118
*
119
* Return: If success return 0, otherwise, return error code
120
*/
121
int xdna_mailbox_send_msg(struct mailbox_channel *mailbox_chann,
122
const struct xdna_mailbox_msg *msg, u64 tx_timeout);
123
124
#endif /* _AIE2_MAILBOX_ */
125
126