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 | |
Brian Swetland | 03e00cd | 2009-07-01 17:58:37 -0700 | [diff] [blame] | 136 | extern spinlock_t smem_lock; |
| 137 | |
Brian Swetland | 03e00cd | 2009-07-01 17:58:37 -0700 | [diff] [blame] | 138 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 139 | void smd_diag(void); |
Daniel Walker | 74df1d0 | 2010-03-17 10:51:10 -0700 | [diff] [blame] | 140 | |
Brian Swetland | 2eb44eb | 2008-09-29 16:00:48 -0700 | [diff] [blame] | 141 | #endif |