blob: 6ffd5d2b91311e3eddff185e4f1e06eb7efe4302 [file] [log] [blame]
Brian Swetland2eb44eb2008-09-29 16:00:48 -07001/* arch/arm/mach-msm/smd_private.h
2 *
3 * Copyright (C) 2007 Google, Inc.
Eric Holmberg7ad623a2012-03-01 14:41:10 -07004 * Copyright (c) 2007-2012, Code Aurora Forum. All rights reserved.
Brian Swetland2eb44eb2008-09-29 16:00:48 -07005 *
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16#ifndef _ARCH_ARM_MACH_MSM_MSM_SMD_PRIVATE_H_
17#define _ARCH_ARM_MACH_MSM_MSM_SMD_PRIVATE_H_
18
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070019#include <linux/types.h>
Brian Swetland03e00cd2009-07-01 17:58:37 -070020#include <linux/spinlock.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070021#include <mach/msm_smsm.h>
Eric Holmberg7ad623a2012-03-01 14:41:10 -070022#include <mach/msm_smd.h>
Daniel Walker74df1d02010-03-17 10:51:10 -070023
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070024#define PC_APPS 0
25#define PC_MODEM 1
26
27#define VERSION_QDSP6 4
28#define VERSION_APPS_SBL 6
29#define VERSION_MODEM_SBL 7
30#define VERSION_APPS 8
31#define VERSION_MODEM 9
32#define VERSION_DSPS 10
33
34#define SMD_HEAP_SIZE 512
Brian Swetland03e00cd2009-07-01 17:58:37 -070035
Daniel Walker79848a22010-03-16 15:20:07 -070036struct smem_heap_info {
Brian Swetland2eb44eb2008-09-29 16:00:48 -070037 unsigned initialized;
38 unsigned free_offset;
39 unsigned heap_remaining;
40 unsigned reserved;
41};
42
Daniel Walker79848a22010-03-16 15:20:07 -070043struct smem_heap_entry {
Brian Swetland2eb44eb2008-09-29 16:00:48 -070044 unsigned allocated;
45 unsigned offset;
46 unsigned size;
Jeff Hugobdc734d2012-03-26 16:05:39 -060047 unsigned reserved; /* bits 1:0 reserved, bits 31:2 aux smem base addr */
Brian Swetland2eb44eb2008-09-29 16:00:48 -070048};
Jeff Hugobdc734d2012-03-26 16:05:39 -060049#define BASE_ADDR_MASK 0xfffffffc
Brian Swetland2eb44eb2008-09-29 16:00:48 -070050
Daniel Walker79848a22010-03-16 15:20:07 -070051struct smem_proc_comm {
Brian Swetland2eb44eb2008-09-29 16:00:48 -070052 unsigned command;
53 unsigned status;
54 unsigned data1;
55 unsigned data2;
56};
57
Daniel Walker79848a22010-03-16 15:20:07 -070058struct smem_shared {
Brian Swetland2eb44eb2008-09-29 16:00:48 -070059 struct smem_proc_comm proc_comm[4];
60 unsigned version[32];
61 struct smem_heap_info heap_info;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070062 struct smem_heap_entry heap_toc[SMD_HEAP_SIZE];
Brian Swetland2eb44eb2008-09-29 16:00:48 -070063};
64
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070065#if defined(CONFIG_MSM_SMD_PKG4)
Daniel Walker79848a22010-03-16 15:20:07 -070066struct smsm_interrupt_info {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070067 uint32_t aArm_en_mask;
68 uint32_t aArm_interrupts_pending;
69 uint32_t aArm_wakeup_reason;
70 uint32_t aArm_rpc_prog;
71 uint32_t aArm_rpc_proc;
72 char aArm_smd_port_name[20];
73 uint32_t aArm_gpio_info;
Brian Swetland2eb44eb2008-09-29 16:00:48 -070074};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070075#elif defined(CONFIG_MSM_SMD_PKG3)
76struct smsm_interrupt_info {
77 uint32_t aArm_en_mask;
78 uint32_t aArm_interrupts_pending;
79 uint32_t aArm_wakeup_reason;
80};
81#elif !defined(CONFIG_MSM_SMD)
82void *smem_alloc(unsigned id, unsigned size)
83{
84 return NULL;
85}
Arve Hjønnevågec9d3d12009-06-16 14:48:21 -070086#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070087#error No SMD Package Specified; aborting
Arve Hjønnevågec9d3d12009-06-16 14:48:21 -070088#endif
Brian Swetland2eb44eb2008-09-29 16:00:48 -070089
90#define SZ_DIAG_ERR_MSG 0xC8
91#define ID_DIAG_ERR_MSG SMEM_DIAG_ERR_MESSAGE
92#define ID_SMD_CHANNELS SMEM_SMD_BASE_ID
93#define ID_SHARED_STATE SMEM_SMSM_SHARED_STATE
94#define ID_CH_ALLOC_TBL SMEM_CHANNEL_ALLOC_TBL
95
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070096#define SMD_SS_CLOSED 0x00000000
97#define SMD_SS_OPENING 0x00000001
98#define SMD_SS_OPENED 0x00000002
99#define SMD_SS_FLUSHING 0x00000003
100#define SMD_SS_CLOSING 0x00000004
101#define SMD_SS_RESET 0x00000005
102#define SMD_SS_RESET_OPENING 0x00000006
Brian Swetland2eb44eb2008-09-29 16:00:48 -0700103
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700104#define SMD_BUF_SIZE 8192
105#define SMD_CHANNELS 64
106#define SMD_HEADER_SIZE 20
Brian Swetland2eb44eb2008-09-29 16:00:48 -0700107
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700108/* 'type' field of smd_alloc_elm structure
109 * has the following breakup
110 * bits 0-7 -> channel type
111 * bits 8-11 -> xfer type
112 * bits 12-31 -> reserved
113 */
Brian Swetland03e00cd2009-07-01 17:58:37 -0700114struct smd_alloc_elm {
115 char name[20];
116 uint32_t cid;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700117 uint32_t type;
Brian Swetland03e00cd2009-07-01 17:58:37 -0700118 uint32_t ref_count;
119};
120
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700121#define SMD_CHANNEL_TYPE(x) ((x) & 0x000000FF)
122#define SMD_XFER_TYPE(x) (((x) & 0x00000F00) >> 8)
123
Brian Swetland03e00cd2009-07-01 17:58:37 -0700124struct smd_half_channel {
125 unsigned state;
126 unsigned char fDSR;
127 unsigned char fCTS;
128 unsigned char fCD;
129 unsigned char fRI;
130 unsigned char fHEAD;
131 unsigned char fTAIL;
132 unsigned char fSTATE;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700133 unsigned char fBLOCKREADINTR;
Brian Swetland03e00cd2009-07-01 17:58:37 -0700134 unsigned tail;
135 unsigned head;
Brian Swetland03e00cd2009-07-01 17:58:37 -0700136};
137
Jeff Hugo918b2dc2012-03-21 13:42:09 -0600138struct smd_half_channel_word_access {
139 unsigned state;
140 unsigned fDSR;
141 unsigned fCTS;
142 unsigned fCD;
143 unsigned fRI;
144 unsigned fHEAD;
145 unsigned fTAIL;
146 unsigned fSTATE;
147 unsigned fBLOCKREADINTR;
148 unsigned tail;
149 unsigned head;
150};
151
152struct smd_half_channel_access {
153 void (*set_state)(volatile void *half_channel, unsigned data);
154 unsigned (*get_state)(volatile void *half_channel);
155 void (*set_fDSR)(volatile void *half_channel, unsigned char data);
156 unsigned (*get_fDSR)(volatile void *half_channel);
157 void (*set_fCTS)(volatile void *half_channel, unsigned char data);
158 unsigned (*get_fCTS)(volatile void *half_channel);
159 void (*set_fCD)(volatile void *half_channel, unsigned char data);
160 unsigned (*get_fCD)(volatile void *half_channel);
161 void (*set_fRI)(volatile void *half_channel, unsigned char data);
162 unsigned (*get_fRI)(volatile void *half_channel);
163 void (*set_fHEAD)(volatile void *half_channel, unsigned char data);
164 unsigned (*get_fHEAD)(volatile void *half_channel);
165 void (*set_fTAIL)(volatile void *half_channel, unsigned char data);
166 unsigned (*get_fTAIL)(volatile void *half_channel);
167 void (*set_fSTATE)(volatile void *half_channel, unsigned char data);
168 unsigned (*get_fSTATE)(volatile void *half_channel);
169 void (*set_fBLOCKREADINTR)(volatile void *half_channel,
170 unsigned char data);
171 unsigned (*get_fBLOCKREADINTR)(volatile void *half_channel);
172 void (*set_tail)(volatile void *half_channel, unsigned data);
173 unsigned (*get_tail)(volatile void *half_channel);
174 void (*set_head)(volatile void *half_channel, unsigned data);
175 unsigned (*get_head)(volatile void *half_channel);
176};
177
178int is_word_access_ch(unsigned ch_type);
179
180struct smd_half_channel_access *get_half_ch_funcs(unsigned ch_type);
181
Naveen Ramaraj76483ad2011-09-06 14:25:44 -0700182struct smem_ram_ptn {
183 char name[16];
184 unsigned start;
185 unsigned size;
186
187 /* RAM Partition attribute: READ_ONLY, READWRITE etc. */
188 unsigned attr;
189
190 /* RAM Partition category: EBI0, EBI1, IRAM, IMEM */
191 unsigned category;
192
193 /* RAM Partition domain: APPS, MODEM, APPS & MODEM (SHARED) etc. */
194 unsigned domain;
195
196 /* RAM Partition type: system, bootloader, appsboot, apps etc. */
197 unsigned type;
198
199 /* reserved for future expansion without changing version number */
200 unsigned reserved2, reserved3, reserved4, reserved5;
201} __attribute__ ((__packed__));
202
203
204struct smem_ram_ptable {
205 #define _SMEM_RAM_PTABLE_MAGIC_1 0x9DA5E0A8
206 #define _SMEM_RAM_PTABLE_MAGIC_2 0xAF9EC4E2
207 unsigned magic[2];
208 unsigned version;
209 unsigned reserved1;
210 unsigned len;
211 struct smem_ram_ptn parts[32];
212 unsigned buf;
213} __attribute__ ((__packed__));
214
215/* SMEM RAM Partition */
216enum {
217 DEFAULT_ATTRB = ~0x0,
218 READ_ONLY = 0x0,
219 READWRITE,
220};
221
222enum {
223 DEFAULT_CATEGORY = ~0x0,
224 SMI = 0x0,
225 EBI1,
226 EBI2,
227 QDSP6,
228 IRAM,
229 IMEM,
230 EBI0_CS0,
231 EBI0_CS1,
232 EBI1_CS0,
233 EBI1_CS1,
234 SDRAM = 0xE,
235};
236
237enum {
238 DEFAULT_DOMAIN = 0x0,
239 APPS_DOMAIN,
240 MODEM_DOMAIN,
241 SHARED_DOMAIN,
242};
243
244enum {
245 SYS_MEMORY = 1, /* system memory*/
246 BOOT_REGION_MEMORY1, /* boot loader memory 1*/
247 BOOT_REGION_MEMORY2, /* boot loader memory 2,reserved*/
248 APPSBL_MEMORY, /* apps boot loader memory*/
249 APPS_MEMORY, /* apps usage memory*/
250};
251
Brian Swetland03e00cd2009-07-01 17:58:37 -0700252extern spinlock_t smem_lock;
253
Brian Swetland03e00cd2009-07-01 17:58:37 -0700254
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700255void smd_diag(void);
Daniel Walker74df1d02010-03-17 10:51:10 -0700256
Eric Holmberg7ad623a2012-03-01 14:41:10 -0700257struct interrupt_stat {
258 uint32_t smd_in_count;
259 uint32_t smd_out_hardcode_count;
260 uint32_t smd_out_config_count;
261
262 uint32_t smsm_in_count;
263 uint32_t smsm_out_hardcode_count;
264 uint32_t smsm_out_config_count;
265};
266extern struct interrupt_stat interrupt_stats[NUM_SMD_SUBSYSTEMS];
267
Brian Swetland2eb44eb2008-09-29 16:00:48 -0700268#endif