blob: e39c57bfba0f77945100014f20c78a5cb5f2a8a4 [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;
47 unsigned reserved;
48};
49
Daniel Walker79848a22010-03-16 15:20:07 -070050struct smem_proc_comm {
Brian Swetland2eb44eb2008-09-29 16:00:48 -070051 unsigned command;
52 unsigned status;
53 unsigned data1;
54 unsigned data2;
55};
56
Daniel Walker79848a22010-03-16 15:20:07 -070057struct smem_shared {
Brian Swetland2eb44eb2008-09-29 16:00:48 -070058 struct smem_proc_comm proc_comm[4];
59 unsigned version[32];
60 struct smem_heap_info heap_info;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070061 struct smem_heap_entry heap_toc[SMD_HEAP_SIZE];
Brian Swetland2eb44eb2008-09-29 16:00:48 -070062};
63
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070064#if defined(CONFIG_MSM_SMD_PKG4)
Daniel Walker79848a22010-03-16 15:20:07 -070065struct smsm_interrupt_info {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070066 uint32_t aArm_en_mask;
67 uint32_t aArm_interrupts_pending;
68 uint32_t aArm_wakeup_reason;
69 uint32_t aArm_rpc_prog;
70 uint32_t aArm_rpc_proc;
71 char aArm_smd_port_name[20];
72 uint32_t aArm_gpio_info;
Brian Swetland2eb44eb2008-09-29 16:00:48 -070073};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070074#elif defined(CONFIG_MSM_SMD_PKG3)
75struct smsm_interrupt_info {
76 uint32_t aArm_en_mask;
77 uint32_t aArm_interrupts_pending;
78 uint32_t aArm_wakeup_reason;
79};
80#elif !defined(CONFIG_MSM_SMD)
81void *smem_alloc(unsigned id, unsigned size)
82{
83 return NULL;
84}
Arve Hjønnevågec9d3d12009-06-16 14:48:21 -070085#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070086#error No SMD Package Specified; aborting
Arve Hjønnevågec9d3d12009-06-16 14:48:21 -070087#endif
Brian Swetland2eb44eb2008-09-29 16:00:48 -070088
89#define SZ_DIAG_ERR_MSG 0xC8
90#define ID_DIAG_ERR_MSG SMEM_DIAG_ERR_MESSAGE
91#define ID_SMD_CHANNELS SMEM_SMD_BASE_ID
92#define ID_SHARED_STATE SMEM_SMSM_SHARED_STATE
93#define ID_CH_ALLOC_TBL SMEM_CHANNEL_ALLOC_TBL
94
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070095#define SMD_SS_CLOSED 0x00000000
96#define SMD_SS_OPENING 0x00000001
97#define SMD_SS_OPENED 0x00000002
98#define SMD_SS_FLUSHING 0x00000003
99#define SMD_SS_CLOSING 0x00000004
100#define SMD_SS_RESET 0x00000005
101#define SMD_SS_RESET_OPENING 0x00000006
Brian Swetland2eb44eb2008-09-29 16:00:48 -0700102
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700103#define SMD_BUF_SIZE 8192
104#define SMD_CHANNELS 64
105#define SMD_HEADER_SIZE 20
Brian Swetland2eb44eb2008-09-29 16:00:48 -0700106
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700107/* 'type' field of smd_alloc_elm structure
108 * has the following breakup
109 * bits 0-7 -> channel type
110 * bits 8-11 -> xfer type
111 * bits 12-31 -> reserved
112 */
Brian Swetland03e00cd2009-07-01 17:58:37 -0700113struct smd_alloc_elm {
114 char name[20];
115 uint32_t cid;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700116 uint32_t type;
Brian Swetland03e00cd2009-07-01 17:58:37 -0700117 uint32_t ref_count;
118};
119
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700120#define SMD_CHANNEL_TYPE(x) ((x) & 0x000000FF)
121#define SMD_XFER_TYPE(x) (((x) & 0x00000F00) >> 8)
122
Brian Swetland03e00cd2009-07-01 17:58:37 -0700123struct smd_half_channel {
124 unsigned state;
125 unsigned char fDSR;
126 unsigned char fCTS;
127 unsigned char fCD;
128 unsigned char fRI;
129 unsigned char fHEAD;
130 unsigned char fTAIL;
131 unsigned char fSTATE;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700132 unsigned char fBLOCKREADINTR;
Brian Swetland03e00cd2009-07-01 17:58:37 -0700133 unsigned tail;
134 unsigned head;
Brian Swetland03e00cd2009-07-01 17:58:37 -0700135};
136
Naveen Ramaraj76483ad2011-09-06 14:25:44 -0700137struct smem_ram_ptn {
138 char name[16];
139 unsigned start;
140 unsigned size;
141
142 /* RAM Partition attribute: READ_ONLY, READWRITE etc. */
143 unsigned attr;
144
145 /* RAM Partition category: EBI0, EBI1, IRAM, IMEM */
146 unsigned category;
147
148 /* RAM Partition domain: APPS, MODEM, APPS & MODEM (SHARED) etc. */
149 unsigned domain;
150
151 /* RAM Partition type: system, bootloader, appsboot, apps etc. */
152 unsigned type;
153
154 /* reserved for future expansion without changing version number */
155 unsigned reserved2, reserved3, reserved4, reserved5;
156} __attribute__ ((__packed__));
157
158
159struct smem_ram_ptable {
160 #define _SMEM_RAM_PTABLE_MAGIC_1 0x9DA5E0A8
161 #define _SMEM_RAM_PTABLE_MAGIC_2 0xAF9EC4E2
162 unsigned magic[2];
163 unsigned version;
164 unsigned reserved1;
165 unsigned len;
166 struct smem_ram_ptn parts[32];
167 unsigned buf;
168} __attribute__ ((__packed__));
169
170/* SMEM RAM Partition */
171enum {
172 DEFAULT_ATTRB = ~0x0,
173 READ_ONLY = 0x0,
174 READWRITE,
175};
176
177enum {
178 DEFAULT_CATEGORY = ~0x0,
179 SMI = 0x0,
180 EBI1,
181 EBI2,
182 QDSP6,
183 IRAM,
184 IMEM,
185 EBI0_CS0,
186 EBI0_CS1,
187 EBI1_CS0,
188 EBI1_CS1,
189 SDRAM = 0xE,
190};
191
192enum {
193 DEFAULT_DOMAIN = 0x0,
194 APPS_DOMAIN,
195 MODEM_DOMAIN,
196 SHARED_DOMAIN,
197};
198
199enum {
200 SYS_MEMORY = 1, /* system memory*/
201 BOOT_REGION_MEMORY1, /* boot loader memory 1*/
202 BOOT_REGION_MEMORY2, /* boot loader memory 2,reserved*/
203 APPSBL_MEMORY, /* apps boot loader memory*/
204 APPS_MEMORY, /* apps usage memory*/
205};
206
Brian Swetland03e00cd2009-07-01 17:58:37 -0700207extern spinlock_t smem_lock;
208
Brian Swetland03e00cd2009-07-01 17:58:37 -0700209
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700210void smd_diag(void);
Daniel Walker74df1d02010-03-17 10:51:10 -0700211
Eric Holmberg7ad623a2012-03-01 14:41:10 -0700212struct interrupt_stat {
213 uint32_t smd_in_count;
214 uint32_t smd_out_hardcode_count;
215 uint32_t smd_out_config_count;
216
217 uint32_t smsm_in_count;
218 uint32_t smsm_out_hardcode_count;
219 uint32_t smsm_out_config_count;
220};
221extern struct interrupt_stat interrupt_stats[NUM_SMD_SUBSYSTEMS];
222
Brian Swetland2eb44eb2008-09-29 16:00:48 -0700223#endif