FreeCalypso > hg > freecalypso-citrine
comparison bsp/abb+spi/abb_inth.c @ 0:75a11d740a02
initial import of gsm-fw from freecalypso-sw rev 1033:5ab737ac3ad7
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 09 Jun 2016 00:02:41 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:75a11d740a02 |
---|---|
1 /******************************************************************************/ | |
2 /* TEXAS INSTRUMENTS INCORPORATED PROPRIETARY INFORMATION */ | |
3 /* */ | |
4 /* Property of Texas Instruments -- For Unrestricted Internal Use Only */ | |
5 /* Unauthorized reproduction and/or distribution is strictly prohibited. This*/ | |
6 /* product is protected under copyright law and trade secret law as an*/ | |
7 /* unpublished work. Created 1987, (C) Copyright 1997 Texas Instruments. All*/ | |
8 /* rights reserved. */ | |
9 /* */ | |
10 /* */ | |
11 /* Filename : abb_inth.c */ | |
12 /* */ | |
13 /* Description : Functions to manage the ABB device interrupt. */ | |
14 /* The Serial Port Interface is used to connect the TI */ | |
15 /* Analog BaseBand (ABB). */ | |
16 /* It is assumed that the ABB is connected as the SPI */ | |
17 /* device 0, and ABB interrupt is mapped as external IT. */ | |
18 /* */ | |
19 /* Author : Pascal PUEL */ | |
20 /* */ | |
21 /* Version number : 1.2 */ | |
22 /* */ | |
23 /* Date and time : 07/02/03 */ | |
24 /* */ | |
25 /* Previous delta : Creation */ | |
26 /* */ | |
27 /******************************************************************************/ | |
28 /* */ | |
29 /* 17/12/03 */ | |
30 /* The original abb_inth.c has been splitted between the actual abb_inth.c */ | |
31 /* located in drv_apps directory and abb_inth_core.c located in drv_core */ | |
32 /* directory. */ | |
33 /* */ | |
34 /******************************************************************************/ | |
35 | |
36 #include "../../include/config.h" | |
37 #include "../../include/sys_types.h" | |
38 #include "../../riviera/rv/general.h" | |
39 #include "../../nucleus/nucleus.h" // for NUCLEUS functions and types | |
40 | |
41 #include "../../L1/include/l1_confg.h" | |
42 #include "../../L1/include/l1_macro.h" | |
43 | |
44 #include <string.h> | |
45 #include "abb_inth.h" | |
46 | |
47 #include "../../riviera/rv/rv_defined_swe.h" // for RVM_PWR_SWE | |
48 | |
49 #if (CHIPSET == 12) | |
50 #include "sys_inth.h" | |
51 #else | |
52 #include "../iq.h" | |
53 #endif | |
54 | |
55 #include "../../gpf/inc/cust_os.h" | |
56 #include "../../L1/include/l1_signa.h" | |
57 #include "abb.h" | |
58 | |
59 #if defined (OP_WCP) | |
60 #include "ffs/ffs.h" | |
61 #include "ffs/board/ffspcm.h" | |
62 #endif | |
63 | |
64 #include "../../riviera/rvm/rvm_use_id_list.h" // for SPI_USE_ID | |
65 #include "spi_env.h" | |
66 #include "spi_process.h" // for ABB_EXT_IRQ_EVT | |
67 #if 0 // FreeCalypso | |
68 #include "kpd/kpd_power_api.h" // for kpd_power_key_pressed() | |
69 #include "power/power.h" | |
70 #endif | |
71 | |
72 #ifdef RVM_LCC_SWE | |
73 #include "lcc/lcc_api.h" | |
74 #include "lcc/lcc_cfg_i.h" | |
75 #include "lcc/lcc.h" | |
76 #include "lcc/lcc_env.h" | |
77 #endif | |
78 /******************************************************************************/ | |
79 /* */ | |
80 /* Function Name: spi_abb_read_int_reg_callback */ | |
81 /* */ | |
82 /* Purpose: Callback function */ | |
83 /* Called when an external interrupt has occured and the */ | |
84 /* ABB interrupt register has been read. */ | |
85 /* */ | |
86 /******************************************************************************/ | |
87 void spi_abb_read_int_reg_callback(SYS_UWORD16 *read_value) | |
88 { | |
89 SYS_UWORD16 loop_count; | |
90 SYS_UWORD16 status_value; | |
91 xSignalHeaderRec *adc_msg; | |
92 volatile SYS_UWORD8 i; | |
93 | |
94 #ifdef RVM_LCC_SWE | |
95 struct pwr_adc_ind_s *addr; | |
96 extern T_PWR_CTRL_BLOCK *pwr_ctrl; | |
97 #endif | |
98 | |
99 /* | |
100 * FreeCalypso: the following logic, which makes sense for complete | |
101 * phones but not for Openmoko-style modems, has not been integrated | |
102 * yet. | |
103 */ | |
104 #if 0 | |
105 // check all the possible causes of the ABB IT | |
106 if (*read_value & PUSHOFF_IT_STS) | |
107 { | |
108 /* Push Button from ON to OFF */ | |
109 if (SPI_GBL_INFO_PTR->is_gsm_on == TRUE) | |
110 { | |
111 NU_Sleep(SHORT_OFF_KEY_PRESSED); | |
112 | |
113 // WCP Patch | |
114 #if (OP_WCP == 1) | |
115 // Backup of GSM FFS is remotely handled by MPU-S | |
116 // we trigger the backup upon each ON->OFF transition | |
117 ffs_backup (); | |
118 #else | |
119 /* Since this callback function is called from the SPI task | |
120 it can't be interrupted by another task | |
121 so we can directly access the SPI through the low-level driver */ | |
122 | |
123 #if ((ANLG_FAM == 1) || (ANLG_FAM == 2)) | |
124 status_value = (ABB_Read_Status() & ONREFLT); | |
125 #elif (ANLG_FAM == 3) | |
126 status_value = (ABB_Read_Register_on_page(PAGE1, VRPCCFG) & PWOND); | |
127 #endif | |
128 | |
129 if (status_value == PWR_OFF_KEY_PRESSED) | |
130 { | |
131 /* Inform keypad that key ON/OFF has been pressed */ | |
132 kpd_power_key_pressed(); | |
133 | |
134 loop_count = 0; | |
135 /* Wait loop for Power-OFF */ | |
136 while ((loop_count < OFF_LOOP_COUNT) && | |
137 (status_value == PWR_OFF_KEY_PRESSED)) | |
138 { | |
139 NU_Sleep(SHORT_OFF_KEY_PRESSED); | |
140 #if ((ANLG_FAM == 1) || (ANLG_FAM == 2)) | |
141 status_value = (ABB_Read_Status() & ONREFLT); | |
142 #elif (ANLG_FAM == 3) | |
143 status_value = (ABB_Read_Register_on_page(PAGE1, VRPCCFG) & PWOND); | |
144 #endif | |
145 loop_count++; | |
146 } | |
147 | |
148 if (status_value == PWR_OFF_KEY_PRESSED) /* Power-OFF request detected */ | |
149 { | |
150 rvf_send_trace("IQ EXT: Power Off request",25, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID); | |
151 | |
152 Power_OFF_Button(); | |
153 } | |
154 } | |
155 #endif //WCP | |
156 } | |
157 else /* GSM OFF */ | |
158 { | |
159 rvf_send_trace("IQ EXT: Power On request",24, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID); | |
160 | |
161 Power_ON_Button(); | |
162 } | |
163 } | |
164 | |
165 else if (*read_value & REMOT_IT_STS) | |
166 { | |
167 rvf_send_trace("IQ EXT: Power Off remote request",32, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID); | |
168 | |
169 /* 'Remote Power' from ON to OFF */ | |
170 Power_OFF_Remote(); | |
171 } | |
172 #else | |
173 /* dummy to satisfy C */ | |
174 if (0) | |
175 ; | |
176 #endif | |
177 | |
178 else if (*read_value & ADCEND_IT_STS) | |
179 { | |
180 rvf_send_trace("IQ EXT: ADC End",15, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID); | |
181 | |
182 /* ADC end of conversion */ | |
183 ABB_Read_ADC(&SPI_GBL_INFO_PTR->adc_result[0]); | |
184 adc_msg = os_alloc_sig(sizeof(T_CST_ADC_RESULT)); | |
185 if(adc_msg != NULL) | |
186 { | |
187 adc_msg->SignalCode = CST_ADC_RESULT; | |
188 | |
189 for(i=0;i<MADC_NUMBER_OF_MEAS;i++) | |
190 { | |
191 ((T_CST_ADC_RESULT *)(adc_msg->SigP))->adc_result[i] = SPI_GBL_INFO_PTR->adc_result[i]; | |
192 } | |
193 os_send_sig(adc_msg, RRM1_QUEUE); | |
194 #ifdef RVM_LCC_SWE | |
195 // Send ADC measurement to PWR (LCC) task | |
196 // NOTE that memory is allocated externally in the PWR task | |
197 if (rvf_get_buf(pwr_ctrl->prim_id, sizeof(struct pwr_adc_ind_s), (void *)&addr) == RVF_RED) { | |
198 rvf_send_trace("rvf_get_buf failed",18, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID); | |
199 /* Unmask External interrupt */ | |
200 IQ_Unmask(IQ_EXT); | |
201 // rvf_dump_mem(); | |
202 return; | |
203 } | |
204 addr->header.msg_id = PWR_ADC_IND; | |
205 addr->header.src_addr_id = SPI_GBL_INFO_PTR->addr_id; | |
206 addr->header.dest_addr_id = pwr_ctrl->addr_id; | |
207 addr->header.callback_func = NULL; | |
208 // FIXME: memcpy from SPI_GBL_INFO_PTR->adc_result - make sure it has not been de-allocated | |
209 memcpy(addr->data, SPI_GBL_INFO_PTR->adc_result, 8*2); | |
210 addr->data[9] = ABB_Read_Status();; // Read & assign ITSTATREG status so we save the polling in PWR task!! | |
211 if (rvf_send_msg(pwr_ctrl->addr_id, addr) != RV_OK) { | |
212 rvf_send_trace("SPI FATAL: Send failed!",23, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID); | |
213 } | |
214 #endif | |
215 } | |
216 } | |
217 | |
218 #if (defined(RVM_PWR_SWE) || defined(RVM_LCC_SWE)) | |
219 else if (*read_value & CHARGER_IT_STS) | |
220 { | |
221 /* Charger plug IN or OUT */ | |
222 #if ((ANLG_FAM == 1) || (ANLG_FAM == 2)) | |
223 status_value = ABB_Read_Status(); | |
224 #elif (ANLG_FAM == 3) | |
225 status_value = ABB_Read_Register_on_page(PAGE1, VRPCCFG); | |
226 #endif | |
227 if (status_value & CHGPRES) | |
228 { | |
229 rvf_send_trace("IQ EXT: Charger Plug",20, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID); | |
230 #ifdef RVM_PWR_SWE | |
231 PWR_Charger_Plug(); /* charger plugged IN */ | |
232 #endif | |
233 #ifdef RVM_LCC_SWE | |
234 // Forward charger plug indication to PWR (LCC) task | |
235 // NOTE that memory is allocated externally in the PWR task | |
236 if (rvf_get_buf(pwr_ctrl->prim_id, sizeof(struct pwr_req_s), (void *)&addr) == RVF_RED) { | |
237 rvf_send_trace("rvf_get_buf failed#1",20, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID); | |
238 rvf_dump_mem(); | |
239 } | |
240 addr->header.msg_id = PWR_CHARGER_PLUGGED_IND; | |
241 addr->header.src_addr_id = SPI_GBL_INFO_PTR->addr_id; | |
242 addr->header.dest_addr_id = pwr_ctrl->addr_id; | |
243 addr->header.callback_func = NULL; | |
244 if (rvf_send_msg(pwr_ctrl->addr_id, addr) != RV_OK) { | |
245 rvf_send_trace("SPI FATAL: Send failed!",23, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID); | |
246 } | |
247 #endif | |
248 } | |
249 else | |
250 { | |
251 rvf_send_trace("IQ EXT: Charger Unplug",22, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID); | |
252 | |
253 #ifdef RVM_PWR_SWE | |
254 PWR_Charger_Unplug(); /* charger plugged OUT */ | |
255 #endif | |
256 #ifdef RVM_LCC_SWE | |
257 // Forward charger unplug indication to PWR (LCC) task | |
258 // NOTE that memory is allocated externally in the PWR task | |
259 if (rvf_get_buf(pwr_ctrl->prim_id, sizeof(struct pwr_req_s), (void *)&addr) == RVF_RED) { | |
260 rvf_send_trace("rvf_get_buf failed#2",20, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID); | |
261 rvf_dump_mem(); | |
262 } | |
263 addr->header.msg_id = PWR_CHARGER_UNPLUGGED_IND; | |
264 addr->header.src_addr_id = SPI_GBL_INFO_PTR->addr_id; | |
265 addr->header.dest_addr_id = pwr_ctrl->addr_id; | |
266 addr->header.callback_func = NULL; | |
267 if (rvf_send_msg(pwr_ctrl->addr_id, addr) != RV_OK) { | |
268 rvf_send_trace("SPI FATAL: Send failed!",23, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID); | |
269 } | |
270 #endif | |
271 } | |
272 } | |
273 | |
274 #endif /* RVM_PWR_SWE || RVM_LCC_SWE */ | |
275 | |
276 /* Unmask External interrupt */ | |
277 #if (CHIPSET == 12) | |
278 // Unmask ABB ext interrupt | |
279 F_INTH_ENABLE_ONE_IT(C_INTH_ABB_IRQ_IT); | |
280 #else | |
281 // Unmask external (ABB) interrupt | |
282 IQ_Unmask(IQ_EXT); | |
283 #endif | |
284 } |