aboutsummaryrefslogtreecommitdiff
path: root/techpack/audio/asoc/codecs/wcd_cpe_services.h
blob: 68eb61996a69ccbf4da1afebd7c60b5b8713b71d (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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * 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 __CPE_SERVICES__
#define __CPE_SERVICES__

#define CPE_IRQ_OUTBOX_IRQ		0x01
#define CPE_IRQ_MEM_ACCESS_ERROR	0x02
#define CPE_IRQ_WDOG_BITE		0x04
#define CPE_IRQ_BUFFER_OVERFLOW		0x08
#define CPE_IRQ_LAB_OVFUNF		0x10
#define CPE_IRQ_FLL_LOCK_LOST		0x20
#define CPE_IRQ_RCO_WDOG_INT		0x40

#define EFAILED (MAX_ERRNO - 1)
#define ENOTREADY (MAX_ERRNO - 2)

#define MAX_SUPPORTED_CLKFREQ 8
#define CPE_SVC_INIT_PARAM_V1 1

enum cpe_svc_result {
	CPE_SVC_SUCCESS			= 0,
	CPE_SVC_FAILED			= -EFAILED,
	CPE_SVC_NO_MEMORY		= -ENOMEM,
	CPE_SVC_INVALID_HANDLE		= -EINVAL,
	CPE_SVC_NOT_READY		= -ENOTREADY,
	CPE_SVC_SHUTTING_DOWN		= -ESHUTDOWN,
	CPE_SVC_BUSY			= -EBUSY,
};

enum cpe_svc_event {
	CPE_SVC_CMI_MSG			= 0x01,
	CPE_SVC_OFFLINE			= 0x02,
	CPE_SVC_ONLINE			= 0x04,
	CPE_SVC_BOOT_FAILED		= 0x08,
	CPE_SVC_READ_COMPLETE		= 0x10,
	CPE_SVC_READ_ERROR		= 0x20,
	CPE_SVC_BOOT			= 0x40,
	CPE_SVC_CMI_CLIENTS_DEREG	= 0x100,
	CPE_SVC_EVENT_ANCHOR		= 0x7FFF
};

enum cpe_svc_module {
	CPE_SVC_LISTEN_PROC		= 1,
	CPE_SVC_MODULE_ANCHOR		= 0x7F
};

enum cpe_svc_route_dest {
	CPE_SVC_EXTERNAL		= 1,
	CPE_SVC_INTERNAL		= 2,
	CPE_SVC_ROUTE_ANCHOR		= 0x7F
};

enum cpe_svc_mem_type {
	CPE_SVC_DATA_MEM		= 1,
	CPE_SVC_INSTRUCTION_MEM		= 2,
	CPE_SVC_IPC_MEM			= 3,
	CPE_SVC_MEM_TYPE_ANCHOR		= 0x7F
};

enum cpe_svc_codec_id {
	CPE_SVC_CODEC_TOMTOM		= 5,
	CPE_SVC_CODEC_WCD9335		= 7,
	CPE_SVC_CODEC_WCD9326		= 8,
	CPE_SVC_CODEC_ID_ANCHOR		= 0x7ffffff
};

enum cpe_svc_codec_version {
	CPE_SVC_CODEC_V1P0		= 1,
	CPE_SVC_CODEC_VERSION_ANCHOR	= 0x7fffffff
};

struct cpe_svc_codec_info_v1 {
	u16			major_version;/*must be 1*/
	u16			minor_version;/*must be 0*/
	u32			id;
	u32			version;
	/*Add 1.1 version fields after this line*/
};

struct cpe_svc_notification {
	enum cpe_svc_event event;
	enum cpe_svc_result result;
	void *payload;
	void *private_data;
};

struct cpe_svc_msg_payload {
	u8    *cmi_msg;
};

struct cpe_svc_read_complete {
	u8    *buffer;
	size_t   size;
};

struct cpe_svc_boot_event {
	u32 debug_address;
	size_t debug_buffer_size;
	u32 status;
};

struct cpe_svc_mem_segment {
	enum cpe_svc_mem_type type;
	u32 cpe_addr;
	size_t size;
	u8 *data;
};

struct cpe_svc_hw_cfg {
	size_t DRAM_size;
	u32 DRAM_offset;
	size_t IRAM_size;
	u32 IRAM_offset;
	u8 inbox_size;
	u8 outbox_size;
};

struct cpe_svc_cfg_clk_plan {
	u32 current_clk_feq;
	u32 num_clk_freqs;
	u32 clk_freqs[MAX_SUPPORTED_CLKFREQ];
};

struct cpe_svc_init_param {
	void *context;
	u32 version;
	void (*query_freq_plans_cb)(void *cdc_priv,
			struct cpe_svc_cfg_clk_plan *clk_freq);
	void (*change_freq_plan_cb)(void *cdc_priv,
			u32 clk_freq);
};


void *cpe_svc_initialize(
		void irq_control_callback(u32 enable),
		const void *codec_info, void *context);
enum cpe_svc_result cpe_svc_deinitialize(void *cpe_handle);

void *cpe_svc_register(void *cpe_handle,
		void (*notification_callback)(
			const struct cpe_svc_notification *parameter),
		u32 mask, const char *name);

enum cpe_svc_result cpe_svc_deregister(void *cpe_handle, void *reg_handle);

enum cpe_svc_result cpe_svc_download_segment(void *cpe_handle,
		const struct cpe_svc_mem_segment *segment);

enum cpe_svc_result cpe_svc_boot(void *cpe_handle, int debug_mode);

enum cpe_svc_result cpe_svc_shutdown(void *cpe_handle);

enum cpe_svc_result cpe_svc_reset(void *cpe_handle);

enum cpe_svc_result cpe_svc_process_irq(void *cpe_handle, u32 cpe_irq);

enum cpe_svc_result
cpe_svc_route_notification(void *cpe_handle, enum cpe_svc_module module,
		enum cpe_svc_route_dest dest);

enum cpe_svc_result cpe_svc_ramdump(void *cpe_handle,
		struct cpe_svc_mem_segment *buffer);

enum cpe_svc_result cpe_svc_set_debug_mode(void *cpe_handle, u32 mode);

const struct cpe_svc_hw_cfg *cpe_svc_get_hw_cfg(void *cpe_handle);
enum cpe_svc_result cpe_svc_toggle_lab(void *cpe_handle, bool enable);
enum cpe_svc_result cpe_svc_ftm_test(void *cpe_handle, u32 *status);
#endif /*__CPE_SERVICES__*/