blob: 5a542a6a49f025bd088c8f05eb54e980aab41e11 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
/*
* Copyright (C) 2012 Spreadtrum Communications Inc.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef __SIPC_PRIV_H
#define __SIPC_PRIV_H
#define SMSG_CACHE_NR 256
struct smsg_channel {
/* wait queue for recv-buffer */
wait_queue_head_t rxwait;
struct mutex rxlock;
/* cached msgs for recv */
uintptr_t wrptr[1];
uintptr_t rdptr[1];
struct smsg caches[SMSG_CACHE_NR];
};
/* smsg ring-buffer between AP/CP ipc */
struct smsg_ipc {
char *name;
uint8_t dst;
uint8_t padding[3];
/* send-buffer info */
uintptr_t txbuf_addr;
uint32_t txbuf_size; /* must be 2^n */
uintptr_t txbuf_rdptr;
uintptr_t txbuf_wrptr;
/* recv-buffer info */
uintptr_t rxbuf_addr;
uint32_t rxbuf_size; /* must be 2^n */
uintptr_t rxbuf_rdptr;
uintptr_t rxbuf_wrptr;
#ifdef CONFIG_SPRD_MAILBOX
/* target core_id over mailbox */
int core_id;
#endif
/* sipc irq related */
int irq;
irq_handler_t irq_handler;
irq_handler_t irq_threadfn;
uint32_t (*rxirq_status)(void);
void (*rxirq_clear)(void);
void (*txirq_trigger)(void);
/* sipc ctrl thread */
struct task_struct *thread;
/* lock for send-buffer */
spinlock_t txpinlock;
/* all fixed channels receivers */
struct smsg_channel *channels[SMSG_CH_NR];
/* record the runtime status of smsg channel */
atomic_t busy[SMSG_CH_NR];
/* all channel states: 0 unused, 1 opened */
uint8_t states[SMSG_CH_NR];
};
#define CHAN_STATE_UNUSED 0
#define CHAN_STATE_WAITING 1
#define CHAN_STATE_OPENED 2
#define CHAN_STATE_FREE 3
/* create/destroy smsg ipc between AP/CP */
int smsg_ipc_create(uint8_t dst, struct smsg_ipc *ipc);
int smsg_ipc_destroy(uint8_t dst);
int smsg_suspend_init(void);
/* initialize smem pool for AP/CP */
int smem_init(uint32_t addr, uint32_t size);
#endif
|