blob: a4c60e81036d67cba160ddc7511cdca9c007a645 [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.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004 * Copyright (c) 2007-2011, 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>
Daniel Walker74df1d02010-03-17 10:51:10 -070022
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070023#define PC_APPS 0
24#define PC_MODEM 1
25
26#define VERSION_QDSP6 4
27#define VERSION_APPS_SBL 6
28#define VERSION_MODEM_SBL 7
29#define VERSION_APPS 8
30#define VERSION_MODEM 9
31#define VERSION_DSPS 10
32
33#define SMD_HEAP_SIZE 512
Brian Swetland03e00cd2009-07-01 17:58:37 -070034
Daniel Walker79848a22010-03-16 15:20:07 -070035struct smem_heap_info {
Brian Swetland2eb44eb2008-09-29 16:00:48 -070036 unsigned initialized;
37 unsigned free_offset;
38 unsigned heap_remaining;
39 unsigned reserved;
40};
41
Daniel Walker79848a22010-03-16 15:20:07 -070042struct smem_heap_entry {
Brian Swetland2eb44eb2008-09-29 16:00:48 -070043 unsigned allocated;
44 unsigned offset;
45 unsigned size;
46 unsigned reserved;
47};
48
Daniel Walker79848a22010-03-16 15:20:07 -070049struct smem_proc_comm {
Brian Swetland2eb44eb2008-09-29 16:00:48 -070050 unsigned command;
51 unsigned status;
52 unsigned data1;
53 unsigned data2;
54};
55
Daniel Walker79848a22010-03-16 15:20:07 -070056struct smem_shared {
Brian Swetland2eb44eb2008-09-29 16:00:48 -070057 struct smem_proc_comm proc_comm[4];
58 unsigned version[32];
59 struct smem_heap_info heap_info;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070060 struct smem_heap_entry heap_toc[SMD_HEAP_SIZE];
Brian Swetland2eb44eb2008-09-29 16:00:48 -070061};
62
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070063#if defined(CONFIG_MSM_SMD_PKG4)
Daniel Walker79848a22010-03-16 15:20:07 -070064struct smsm_interrupt_info {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070065 uint32_t aArm_en_mask;
66 uint32_t aArm_interrupts_pending;
67 uint32_t aArm_wakeup_reason;
68 uint32_t aArm_rpc_prog;
69 uint32_t aArm_rpc_proc;
70 char aArm_smd_port_name[20];
71 uint32_t aArm_gpio_info;
Brian Swetland2eb44eb2008-09-29 16:00:48 -070072};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070073#elif defined(CONFIG_MSM_SMD_PKG3)
74struct smsm_interrupt_info {
75 uint32_t aArm_en_mask;
76 uint32_t aArm_interrupts_pending;
77 uint32_t aArm_wakeup_reason;
78};
79#elif !defined(CONFIG_MSM_SMD)
80void *smem_alloc(unsigned id, unsigned size)
81{
82 return NULL;
83}
Arve Hjønnevågec9d3d12009-06-16 14:48:21 -070084#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070085#error No SMD Package Specified; aborting
Arve Hjønnevågec9d3d12009-06-16 14:48:21 -070086#endif
Brian Swetland2eb44eb2008-09-29 16:00:48 -070087
88#define SZ_DIAG_ERR_MSG 0xC8
89#define ID_DIAG_ERR_MSG SMEM_DIAG_ERR_MESSAGE
90#define ID_SMD_CHANNELS SMEM_SMD_BASE_ID
91#define ID_SHARED_STATE SMEM_SMSM_SHARED_STATE
92#define ID_CH_ALLOC_TBL SMEM_CHANNEL_ALLOC_TBL
93
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070094#define SMD_SS_CLOSED 0x00000000
95#define SMD_SS_OPENING 0x00000001
96#define SMD_SS_OPENED 0x00000002
97#define SMD_SS_FLUSHING 0x00000003
98#define SMD_SS_CLOSING 0x00000004
99#define SMD_SS_RESET 0x00000005
100#define SMD_SS_RESET_OPENING 0x00000006
Brian Swetland2eb44eb2008-09-29 16:00:48 -0700101
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700102#define SMD_BUF_SIZE 8192
103#define SMD_CHANNELS 64
104#define SMD_HEADER_SIZE 20
Brian Swetland2eb44eb2008-09-29 16:00:48 -0700105
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700106/* 'type' field of smd_alloc_elm structure
107 * has the following breakup
108 * bits 0-7 -> channel type
109 * bits 8-11 -> xfer type
110 * bits 12-31 -> reserved
111 */
Brian Swetland03e00cd2009-07-01 17:58:37 -0700112struct smd_alloc_elm {
113 char name[20];
114 uint32_t cid;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700115 uint32_t type;
Brian Swetland03e00cd2009-07-01 17:58:37 -0700116 uint32_t ref_count;
117};
118
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700119#define SMD_CHANNEL_TYPE(x) ((x) & 0x000000FF)
120#define SMD_XFER_TYPE(x) (((x) & 0x00000F00) >> 8)
121
Brian Swetland03e00cd2009-07-01 17:58:37 -0700122struct smd_half_channel {
123 unsigned state;
124 unsigned char fDSR;
125 unsigned char fCTS;
126 unsigned char fCD;
127 unsigned char fRI;
128 unsigned char fHEAD;
129 unsigned char fTAIL;
130 unsigned char fSTATE;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700131 unsigned char fBLOCKREADINTR;
Brian Swetland03e00cd2009-07-01 17:58:37 -0700132 unsigned tail;
133 unsigned head;
Brian Swetland03e00cd2009-07-01 17:58:37 -0700134};
135
Naveen Ramaraj76483ad2011-09-06 14:25:44 -0700136struct smem_ram_ptn {
137 char name[16];
138 unsigned start;
139 unsigned size;
140
141 /* RAM Partition attribute: READ_ONLY, READWRITE etc. */
142 unsigned attr;
143
144 /* RAM Partition category: EBI0, EBI1, IRAM, IMEM */
145 unsigned category;
146
147 /* RAM Partition domain: APPS, MODEM, APPS & MODEM (SHARED) etc. */
148 unsigned domain;
149
150 /* RAM Partition type: system, bootloader, appsboot, apps etc. */
151 unsigned type;
152
153 /* reserved for future expansion without changing version number */
154 unsigned reserved2, reserved3, reserved4, reserved5;
155} __attribute__ ((__packed__));
156
157
158struct smem_ram_ptable {
159 #define _SMEM_RAM_PTABLE_MAGIC_1 0x9DA5E0A8
160 #define _SMEM_RAM_PTABLE_MAGIC_2 0xAF9EC4E2
161 unsigned magic[2];
162 unsigned version;
163 unsigned reserved1;
164 unsigned len;
165 struct smem_ram_ptn parts[32];
166 unsigned buf;
167} __attribute__ ((__packed__));
168
169/* SMEM RAM Partition */
170enum {
171 DEFAULT_ATTRB = ~0x0,
172 READ_ONLY = 0x0,
173 READWRITE,
174};
175
176enum {
177 DEFAULT_CATEGORY = ~0x0,
178 SMI = 0x0,
179 EBI1,
180 EBI2,
181 QDSP6,
182 IRAM,
183 IMEM,
184 EBI0_CS0,
185 EBI0_CS1,
186 EBI1_CS0,
187 EBI1_CS1,
188 SDRAM = 0xE,
189};
190
191enum {
192 DEFAULT_DOMAIN = 0x0,
193 APPS_DOMAIN,
194 MODEM_DOMAIN,
195 SHARED_DOMAIN,
196};
197
198enum {
199 SYS_MEMORY = 1, /* system memory*/
200 BOOT_REGION_MEMORY1, /* boot loader memory 1*/
201 BOOT_REGION_MEMORY2, /* boot loader memory 2,reserved*/
202 APPSBL_MEMORY, /* apps boot loader memory*/
203 APPS_MEMORY, /* apps usage memory*/
204};
205
Brian Swetland03e00cd2009-07-01 17:58:37 -0700206extern spinlock_t smem_lock;
207
Brian Swetland03e00cd2009-07-01 17:58:37 -0700208
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700209void smd_diag(void);
Daniel Walker74df1d02010-03-17 10:51:10 -0700210
Brian Swetland2eb44eb2008-09-29 16:00:48 -0700211#endif