rjw | 6c1fd8f | 2022-11-30 14:33:01 +0800 | [diff] [blame] | 1 | /***************************************************************************** |
| 2 | * Copyright Statement: |
| 3 | * -------------------- |
| 4 | * This software is protected by Copyright and the information contained |
| 5 | * herein is confidential. The software may not be copied and the information |
| 6 | * contained herein may not be used or disclosed except with the written |
| 7 | * permission of MediaTek Inc. (C) 2005 |
| 8 | * |
| 9 | * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| 10 | * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") |
| 11 | * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON |
| 12 | * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, |
| 13 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF |
| 14 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. |
| 15 | * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE |
| 16 | * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR |
| 17 | * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH |
| 18 | * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO |
| 19 | * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S |
| 20 | * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. |
| 21 | * |
| 22 | * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE |
| 23 | * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, |
| 24 | * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, |
| 25 | * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO |
| 26 | * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. |
| 27 | * |
| 28 | * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE |
| 29 | * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF |
| 30 | * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND |
| 31 | * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER |
| 32 | * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). |
| 33 | * |
| 34 | *****************************************************************************/ |
| 35 | |
| 36 | /***************************************************************************** |
| 37 | * |
| 38 | * Filename: |
| 39 | * --------- |
| 40 | * sim_mtk.h |
| 41 | * |
| 42 | * Project: |
| 43 | * -------- |
| 44 | * Maui_Software |
| 45 | * |
| 46 | * Description: |
| 47 | * ------------ |
| 48 | * This file is the header file for MTK dual SIM controllers. |
| 49 | * |
| 50 | * Author: |
| 51 | * ------- |
| 52 | * ------- |
| 53 | * |
| 54 | *============================================================================ |
| 55 | * HISTORY |
| 56 | * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 57 | *------------------------------------------------------------------------------ |
| 58 | * removed! |
| 59 | * removed! |
| 60 | * removed! |
| 61 | * |
| 62 | * removed! |
| 63 | * removed! |
| 64 | * removed! |
| 65 | * removed! |
| 66 | * |
| 67 | * removed! |
| 68 | * removed! |
| 69 | * |
| 70 | * removed! |
| 71 | * removed! |
| 72 | * |
| 73 | * removed! |
| 74 | * removed! |
| 75 | * removed! |
| 76 | * |
| 77 | * removed! |
| 78 | * removed! |
| 79 | * removed! |
| 80 | * |
| 81 | * removed! |
| 82 | * removed! |
| 83 | * removed! |
| 84 | * |
| 85 | * removed! |
| 86 | * removed! |
| 87 | * removed! |
| 88 | * |
| 89 | * removed! |
| 90 | * removed! |
| 91 | * removed! |
| 92 | * |
| 93 | * removed! |
| 94 | * removed! |
| 95 | * removed! |
| 96 | * |
| 97 | * removed! |
| 98 | * removed! |
| 99 | * |
| 100 | * |
| 101 | * removed! |
| 102 | * removed! |
| 103 | * |
| 104 | * |
| 105 | * removed! |
| 106 | * removed! |
| 107 | * |
| 108 | * |
| 109 | * removed! |
| 110 | * removed! |
| 111 | * |
| 112 | * |
| 113 | * removed! |
| 114 | * removed! |
| 115 | * |
| 116 | * |
| 117 | * removed! |
| 118 | * removed! |
| 119 | * |
| 120 | *------------------------------------------------------------------------------ |
| 121 | * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 122 | *============================================================================ |
| 123 | ****************************************************************************/ |
| 124 | /*RHR*/ |
| 125 | #include "drv_features.h" |
| 126 | #include "sim_sw_comm.h" |
| 127 | #include "sim_hw_mtk.h" |
| 128 | #include "sim_reg_adp.h" |
| 129 | #include "intrCtrl.h" |
| 130 | /*RHR*/ |
| 131 | |
| 132 | #ifndef __SIM_DRV_MULTI_DRV_ARCH__ |
| 133 | #ifdef DRV_2_SIM_CONTROLLER |
| 134 | typedef enum |
| 135 | { |
| 136 | SIM_DRIVER_ACT = 0x00000001, |
| 137 | SIM_DRIVER_DEACT = 0x00000002, |
| 138 | SIM_PDNDIS = 0x00000003, |
| 139 | SIM_PDNEN = 0x00000004, |
| 140 | SIM_INT_SIM = 0x00000005, |
| 141 | SIM_INT_USIM = 0x00000006, |
| 142 | SIM_DRIVER_ACT_SIMD = 0x00000007, |
| 143 | SIM_DRIVER_DEACT_SIMD = 0x00000008, |
| 144 | SIM_CMD_TX_LOG = 0x00010001, |
| 145 | SIM_CMD_INS_LOG = 0x00010002, |
| 146 | SIM_CMD_TXDELAY = 0x00010003, |
| 147 | SIM_INIT_USIM = 0x00020001, |
| 148 | SIM_DEACTIVATE_1 = 0x00030001, |
| 149 | SIM_DEACTIVATE_2 = 0x00030002, |
| 150 | SIM_ACTION_RESET = 0x000F0001, |
| 151 | SIM_ACTION_POWOFF = 0x000F0002, |
| 152 | SIM_ACTION_COMMAND = 0x000F0003, |
| 153 | SIM_ACTION_EOC = 0x000F0004 |
| 154 | } sim_msgTag; |
| 155 | |
| 156 | typedef struct |
| 157 | { |
| 158 | sim_msgTag tag; |
| 159 | kal_uint32 event; |
| 160 | kal_uint32 data1; |
| 161 | kal_uint32 data2; |
| 162 | kal_uint32 time; |
| 163 | } sim_msg; |
| 164 | |
| 165 | //redefine new MACRO since there is no sim_MT6302_addMsg API in MT6235, MT6238 and I don't want to change MT6302 again |
| 166 | #define SIM_Reject_MTK(simInterface) \ |
| 167 | {\ |
| 168 | SIM_DisAllIntr(simInterface);\ |
| 169 | if (SIM_Reg((SIM0_BASE_ADDR_MTK + SIM_CTRL_MTK))&SIM_CTRL_SIMON)\ |
| 170 | {\ |
| 171 | sim_addMsg(SIM_DRIVER_DEACT_SIMD, simInterface, 2, 0);\ |
| 172 | SimCard->State = SIM_PWROFF;\ |
| 173 | SIM_WriteReg(SIM0_BASE_ADDR_MTK + SIM_IRQEN_MTK, SIM_IRQEN_SIMOFF);\ |
| 174 | SIM_FIFO_Flush();\ |
| 175 | SIM_ClearBits(SIM0_BASE_ADDR_MTK + SIM_CTRL_MTK, SIM_CTRL_SIMON);\ |
| 176 | }\ |
| 177 | else\ |
| 178 | {\ |
| 179 | sim_PDNEnable(simInterface);\ |
| 180 | if(SimCard->reject_set_event)\ |
| 181 | SIM_SetEvent_MTK(SimCard,SIM_NOREADY);\ |
| 182 | }\ |
| 183 | } |
| 184 | #ifdef NO_SLIM_DEF |
| 185 | /********************************************************************************************* |
| 186 | *we move this macro from sim_sw_comm.h to here, since we need a distinguish from dual controllers or MT6302. |
| 187 | *In dual controllers solution, we need to enable interrupt according to simInterface, but in MT6302 solution, we only need to enable SIM's. |
| 188 | **********************************************************************************************/ |
| 189 | #define SIM_WaitEvent_MTK(_SIMCARD,_flag, _unmaskSIMIntr) \ |
| 190 | {\ |
| 191 | kal_uint32 _event_group;\ |
| 192 | extern void sim_dump_error_line(void);\ |
| 193 | _SIMCARD->event_state = KAL_TRUE;\ |
| 194 | _SIMCARD->EvtFlag = _flag;\ |
| 195 | sim_workingTaskWaiting = KAL_TRUE;\ |
| 196 | if(KAL_TRUE == _unmaskSIMIntr){\ |
| 197 | if(0 == simInterface)\ |
| 198 | IRQUnmask(IRQ_USIM0_CODE);\ |
| 199 | else\ |
| 200 | IRQUnmask(IRQ_USIM1_CODE);\ |
| 201 | }\ |
| 202 | kal_retrieve_eg_events(_SIMCARD->event,_flag,KAL_OR_CONSUME,&_event_group,KAL_SUSPEND);\ |
| 203 | sim_workingTaskWaiting = KAL_FALSE;\ |
| 204 | sim_dump_error_line();\ |
| 205 | } |
| 206 | |
| 207 | //redefine new MACRO since there is no sim_MT6302_addMsg API in MT6235, MT6238 and I don't want to change MT6302 again |
| 208 | #define SIM_SetEvent_MTK(_SIMCARD,_result) \ |
| 209 | {\ |
| 210 | _SIMCARD->result = _result;\ |
| 211 | _SIMCARD->event_state = KAL_FALSE;\ |
| 212 | if(0 == _SIMCARD->EvtFlag)\ |
| 213 | kal_set_eg_events(_SIMCARD->event,CMD_END,KAL_OR);\ |
| 214 | else\ |
| 215 | kal_set_eg_events(_SIMCARD->event,_SIMCARD->EvtFlag,KAL_OR);\ |
| 216 | SIM_WriteReg((SIM0_BASE_ADDR_MTK + SIM_IRQEN_MTK), SIM_IRQEN_ALLOFF);\ |
| 217 | sim_addMsg(0x12345678, _SIMCARD->EvtFlag, __LINE__, drv_get_current_time());\ |
| 218 | } |
| 219 | #endif /*#ifdef NO_SLIM_DEF*/ |
| 220 | #endif /*DRV_2_SIM_CONTROLLER*/ |
| 221 | #endif /*__SIM_DRV_MULTI_DRV_ARCH__*/ |