blob: 6db86251a694f2e533d05a943ba79e35cf169b52 [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
Brian Swetland03e00cd2009-07-01 17:58:37 -0700136extern spinlock_t smem_lock;
137
Brian Swetland03e00cd2009-07-01 17:58:37 -0700138
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700139void smd_diag(void);
Daniel Walker74df1d02010-03-17 10:51:10 -0700140
Brian Swetland2eb44eb2008-09-29 16:00:48 -0700141#endif