Brian Swetland | 2eb44eb | 2008-09-29 16:00:48 -0700 | [diff] [blame] | 1 | /* arch/arm/mach-msm/smd_private.h |
| 2 | * |
| 3 | * Copyright (C) 2007 Google, Inc. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4 | * Copyright (c) 2007-2011, Code Aurora Forum. All rights reserved. |
Brian Swetland | 2eb44eb | 2008-09-29 16:00:48 -0700 | [diff] [blame] | 5 | * |
| 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 Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 19 | #include <linux/types.h> |
Brian Swetland | 03e00cd | 2009-07-01 17:58:37 -0700 | [diff] [blame] | 20 | #include <linux/spinlock.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 21 | #include <mach/msm_smsm.h> |
Daniel Walker | 74df1d0 | 2010-03-17 10:51:10 -0700 | [diff] [blame] | 22 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 23 | #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 Swetland | 03e00cd | 2009-07-01 17:58:37 -0700 | [diff] [blame] | 34 | |
Daniel Walker | 79848a2 | 2010-03-16 15:20:07 -0700 | [diff] [blame] | 35 | struct smem_heap_info { |
Brian Swetland | 2eb44eb | 2008-09-29 16:00:48 -0700 | [diff] [blame] | 36 | unsigned initialized; |
| 37 | unsigned free_offset; |
| 38 | unsigned heap_remaining; |
| 39 | unsigned reserved; |
| 40 | }; |
| 41 | |
Daniel Walker | 79848a2 | 2010-03-16 15:20:07 -0700 | [diff] [blame] | 42 | struct smem_heap_entry { |
Brian Swetland | 2eb44eb | 2008-09-29 16:00:48 -0700 | [diff] [blame] | 43 | unsigned allocated; |
| 44 | unsigned offset; |
| 45 | unsigned size; |
| 46 | unsigned reserved; |
| 47 | }; |
| 48 | |
Daniel Walker | 79848a2 | 2010-03-16 15:20:07 -0700 | [diff] [blame] | 49 | struct smem_proc_comm { |
Brian Swetland | 2eb44eb | 2008-09-29 16:00:48 -0700 | [diff] [blame] | 50 | unsigned command; |
| 51 | unsigned status; |
| 52 | unsigned data1; |
| 53 | unsigned data2; |
| 54 | }; |
| 55 | |
Daniel Walker | 79848a2 | 2010-03-16 15:20:07 -0700 | [diff] [blame] | 56 | struct smem_shared { |
Brian Swetland | 2eb44eb | 2008-09-29 16:00:48 -0700 | [diff] [blame] | 57 | struct smem_proc_comm proc_comm[4]; |
| 58 | unsigned version[32]; |
| 59 | struct smem_heap_info heap_info; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 60 | struct smem_heap_entry heap_toc[SMD_HEAP_SIZE]; |
Brian Swetland | 2eb44eb | 2008-09-29 16:00:48 -0700 | [diff] [blame] | 61 | }; |
| 62 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 63 | #if defined(CONFIG_MSM_SMD_PKG4) |
Daniel Walker | 79848a2 | 2010-03-16 15:20:07 -0700 | [diff] [blame] | 64 | struct smsm_interrupt_info { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 65 | 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 Swetland | 2eb44eb | 2008-09-29 16:00:48 -0700 | [diff] [blame] | 72 | }; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 73 | #elif defined(CONFIG_MSM_SMD_PKG3) |
| 74 | struct 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) |
| 80 | void *smem_alloc(unsigned id, unsigned size) |
| 81 | { |
| 82 | return NULL; |
| 83 | } |
Arve Hjønnevåg | ec9d3d1 | 2009-06-16 14:48:21 -0700 | [diff] [blame] | 84 | #else |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 85 | #error No SMD Package Specified; aborting |
Arve Hjønnevåg | ec9d3d1 | 2009-06-16 14:48:21 -0700 | [diff] [blame] | 86 | #endif |
Brian Swetland | 2eb44eb | 2008-09-29 16:00:48 -0700 | [diff] [blame] | 87 | |
| 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 Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 94 | #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 Swetland | 2eb44eb | 2008-09-29 16:00:48 -0700 | [diff] [blame] | 101 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 102 | #define SMD_BUF_SIZE 8192 |
| 103 | #define SMD_CHANNELS 64 |
| 104 | #define SMD_HEADER_SIZE 20 |
Brian Swetland | 2eb44eb | 2008-09-29 16:00:48 -0700 | [diff] [blame] | 105 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 106 | /* '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 Swetland | 03e00cd | 2009-07-01 17:58:37 -0700 | [diff] [blame] | 112 | struct smd_alloc_elm { |
| 113 | char name[20]; |
| 114 | uint32_t cid; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 115 | uint32_t type; |
Brian Swetland | 03e00cd | 2009-07-01 17:58:37 -0700 | [diff] [blame] | 116 | uint32_t ref_count; |
| 117 | }; |
| 118 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 119 | #define SMD_CHANNEL_TYPE(x) ((x) & 0x000000FF) |
| 120 | #define SMD_XFER_TYPE(x) (((x) & 0x00000F00) >> 8) |
| 121 | |
Brian Swetland | 03e00cd | 2009-07-01 17:58:37 -0700 | [diff] [blame] | 122 | struct 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 Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 131 | unsigned char fBLOCKREADINTR; |
Brian Swetland | 03e00cd | 2009-07-01 17:58:37 -0700 | [diff] [blame] | 132 | unsigned tail; |
| 133 | unsigned head; |
Brian Swetland | 03e00cd | 2009-07-01 17:58:37 -0700 | [diff] [blame] | 134 | }; |
| 135 | |
Naveen Ramaraj | 76483ad | 2011-09-06 14:25:44 -0700 | [diff] [blame^] | 136 | struct 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 | |
| 158 | struct 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 */ |
| 170 | enum { |
| 171 | DEFAULT_ATTRB = ~0x0, |
| 172 | READ_ONLY = 0x0, |
| 173 | READWRITE, |
| 174 | }; |
| 175 | |
| 176 | enum { |
| 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 | |
| 191 | enum { |
| 192 | DEFAULT_DOMAIN = 0x0, |
| 193 | APPS_DOMAIN, |
| 194 | MODEM_DOMAIN, |
| 195 | SHARED_DOMAIN, |
| 196 | }; |
| 197 | |
| 198 | enum { |
| 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 Swetland | 03e00cd | 2009-07-01 17:58:37 -0700 | [diff] [blame] | 206 | extern spinlock_t smem_lock; |
| 207 | |
Brian Swetland | 03e00cd | 2009-07-01 17:58:37 -0700 | [diff] [blame] | 208 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 209 | void smd_diag(void); |
Daniel Walker | 74df1d0 | 2010-03-17 10:51:10 -0700 | [diff] [blame] | 210 | |
Brian Swetland | 2eb44eb | 2008-09-29 16:00:48 -0700 | [diff] [blame] | 211 | #endif |