/arch/arm/mach-msm/include/mach/qdsp6v2/apr.h
C++ Header | 178 lines | 119 code | 24 blank | 35 comment | 0 complexity | 088cc823188a3c03fb33c5c4b12ad5aa MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
1/* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
2 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are
5 * met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above
9 * copyright notice, this list of conditions and the following
10 * disclaimer in the documentation and/or other materials provided
11 * with the distribution.
12 * * Neither the name of Code Aurora Forum, Inc. nor the names of its
13 * contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 */
29#ifndef __APR_H_
30#define __APR_H_
31
32#define APR_Q6_NOIMG 0
33#define APR_Q6_LOADING 1
34#define APR_Q6_LOADED 2
35
36struct apr_q6 {
37 void *pil;
38 uint32_t state;
39 struct mutex lock;
40};
41
42struct apr_hdr {
43 uint16_t hdr_field;
44 uint16_t pkt_size;
45 uint8_t src_svc;
46 uint8_t src_domain;
47 uint16_t src_port;
48 uint8_t dest_svc;
49 uint8_t dest_domain;
50 uint16_t dest_port;
51 uint32_t token;
52 uint32_t opcode;
53};
54
55#define APR_HDR_LEN(hdr_len) ((hdr_len)/4)
56#define APR_PKT_SIZE(hdr_len, payload_len) ((hdr_len) + (payload_len))
57#define APR_HDR_FIELD(msg_type, hdr_len, ver)\
58 (((msg_type & 0x3) << 8) | ((hdr_len & 0xF) << 4) | (ver & 0xF))
59
60#define APR_HDR_SIZE sizeof(struct apr_hdr)
61
62/* Version */
63#define APR_PKT_VER 0x0
64
65/* Command and Response Types */
66#define APR_MSG_TYPE_EVENT 0x0
67#define APR_MSG_TYPE_CMD_RSP 0x1
68#define APR_MSG_TYPE_SEQ_CMD 0x2
69#define APR_MSG_TYPE_NSEQ_CMD 0x3
70#define APR_MSG_TYPE_MAX 0x04
71
72/* APR Basic Response Message */
73#define APR_BASIC_RSP_RESULT 0x000110E8
74#define APR_RSP_ACCEPTED 0x000100BE
75
76/* Domain IDs */
77#define APR_DOMAIN_SIM 0x1
78#define APR_DOMAIN_PC 0x2
79#define APR_DOMAIN_MODEM 0x3
80#define APR_DOMAIN_ADSP 0x4
81#define APR_DOMAIN_APPS 0x5
82#define APR_DOMAIN_MAX 0x6
83
84/* ADSP service IDs */
85#define APR_SVC_TEST_CLIENT 0x2
86#define APR_SVC_ADSP_CORE 0x3
87#define APR_SVC_AFE 0x4
88#define APR_SVC_VSM 0x5
89#define APR_SVC_VPM 0x6
90#define APR_SVC_ASM 0x7
91#define APR_SVC_ADM 0x8
92#define APR_SVC_ADSP_MVM 0x09
93#define APR_SVC_ADSP_CVS 0x0A
94#define APR_SVC_ADSP_CVP 0x0B
95#define APR_SVC_MAX 0x0C
96
97/* Modem Service IDs */
98#define APR_SVC_MVS 0x3
99#define APR_SVC_MVM 0x4
100#define APR_SVC_CVS 0x5
101#define APR_SVC_CVP 0x6
102#define APR_SVC_SRD 0x7
103
104/* APR Port IDs */
105#define APR_MAX_PORTS 0x40
106
107#define APR_NAME_MAX 0x40
108
109struct apr_client_data {
110 uint16_t payload_size;
111 uint16_t hdr_len;
112 uint16_t msg_type;
113 uint16_t src;
114 uint16_t dest_svc;
115 uint16_t src_port;
116 uint16_t dest_port;
117 uint32_t token;
118 uint32_t opcode;
119 void *payload;
120};
121
122typedef int32_t (*apr_fn)(struct apr_client_data *data, void *priv);
123
124struct apr_svc {
125 uint16_t id;
126 uint16_t dest_id;
127 uint16_t client_id;
128 uint8_t rvd;
129 uint8_t port_cnt;
130 uint8_t svc_cnt;
131 apr_fn port_fn[APR_MAX_PORTS];
132 void *port_priv[APR_MAX_PORTS];
133 apr_fn fn;
134 void *priv;
135 struct mutex m_lock;
136 spinlock_t w_lock;
137};
138
139struct apr_client {
140 uint8_t id;
141 uint8_t svc_cnt;
142 uint8_t rvd;
143 struct mutex m_lock;
144 struct apr_svc_ch_dev *handle;
145 struct apr_svc svc[APR_SVC_MAX];
146};
147
148#define ADSP_GET_VERSION 0x00011152
149#define ADSP_GET_VERSION_RSP 0x00011153
150
151struct adsp_get_version {
152 uint32_t build_id;
153 uint32_t svc_cnt;
154};
155
156struct adsp_service_info {
157 uint32_t svc_id;
158 uint32_t svc_ver;
159};
160
161#define ADSP_CMD_SET_POWER_COLLAPSE_STATE 0x0001115C
162struct adsp_power_collapse {
163 struct apr_hdr hdr;
164 uint32_t power_collapse;
165};
166
167struct apr_svc *apr_register(char *dest, char *svc_name, apr_fn svc_fn,
168 uint32_t src_port, void *priv);
169inline int apr_fill_hdr(void *handle, uint32_t *buf, uint16_t src_port,
170 uint16_t msg_type, uint16_t dest_port,
171 uint32_t token, uint32_t opcode, uint16_t len);
172
173int apr_send_pkt(void *handle, uint32_t *buf);
174int apr_deregister(void *handle);
175void change_q6_state(int state);
176void q6audio_dsp_not_responding(void);
177
178#endif