1 #ifndef __MSGBOX_SX_H
2 #define __MSGBOX_SX_H
3 
4 #include "hal_msgbox.h"
5 #include "errno.h"
6 #include <stdint.h>
7 
8 enum msgbox_direction {
9     MSGBOX_DIRECTION_DSP,
10     MSGBOX_DIRECTION_CPU,
11 };
12 
13 enum msgbox_channel_direction {
14     MSGBOX_CHANNEL_RECEIVE,
15     MSGBOX_CHANNEL_SEND,
16 };
17 
18 
19 struct messagebox;
20 
21 struct msg_channel {
22     struct messagebox *mb;
23     enum msgbox_channel_direction dir;
24     void *data;
25     unsigned char *send;
26     int len;
27     int idx;
28     int (*cb_of_msg_queue)(int queue, void *data);
29     int (*cb_tx_done)(unsigned long d, void *data);
30     int (*cb_rx)(unsigned long d, void *data);
31     int channel;
32 };
33 
34 /**
35  * @base: messagebox base address
36  * @this_user: the messagebox user
37  */
38 struct messagebox {
39     unsigned long base;
40     int this_user;
41 
42     int (*channel_set_direction)(struct messagebox *, int channel,
43                       enum msgbox_channel_direction dir);
44 
45     int (*channel_irq_set)(struct messagebox *, int channel, int enable);
46 
47     int (*channel_read)(struct messagebox *, int channel,
48                 unsigned long *read);
49     int (*channel_write)(struct messagebox *, int channel,
50                  unsigned long write);
51     int (*channel_fifo_len)(struct messagebox *, int channel);
52 
53     struct msg_channel msg_handler[0];
54 };
55 
56 extern struct messagebox *msgbox_dsp;
57 extern struct messagebox *msgbox_cpu;
58 
59 int messagebox_init_sx(void);
60 
61 struct msg_channel *msgbox_alloc_channel_sx(struct messagebox *mb, int channel,
62                      enum msgbox_channel_direction dir,
63                      int (*func)(unsigned long, void *),
64                      void *data);
65 
66 void msgbox_free_channel_sx(struct messagebox *mb, struct msg_channel *ch);
67 
68 int msgbox_channel_send_data_sx(struct msg_channel *ch, unsigned char *d,
69                  size_t len);
70 
71 
72 #define MSGBOX_CHANNEL_DEPTH    8
73 #define MSGBOX_MAX_QUEUE    8
74 #define MSGBOX_MAX_USER     2
75 
76 int msg_ops_init_sx(struct messagebox *mb);
77 int msg_irq_handler_sx(int i, void *mb);
78 
79 #endif /* __MSGBOX_SX_H */
80