blob: 94b76e51f9291807cdc9b073e143032fb0e5ce77 [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001/*******************************************************************************
2 * Copyright (C) 2016, ZIXC Corporation.
3 *
4 * File Name: hal_led.c
5 * File Mark:
6 * Description: This file contains the hal layer routines for i2c driver.
7 * Others:
8 * Version: V1.0
9 * Author: yx
10 * Date: 2014-07-03
11 * History 1:
12 * Date:
13 * Version:
14 * Author:
15 * Modification:
16 * History 2:
17 ******************************************************************************/
18
19/****************************************************************************
20* Include files
21****************************************************************************/
22
23#include <common.h>
24//#include "drvs_general.h"
25//#include "drvs_i2c.h"
26#include <linux/types.h>
27#include <power.h>
28#include <zx234290.h>
29#include <led.h>
30#include <lcd.h>
31//#include <lcd_blg.h>
32#include <charge.h>
33#include <zx234502.h>
34#include <partition_table.h>
35#include <linux/mtd/compat.h>
36/****************************************************************************
37* Local Macros
38****************************************************************************/
39
40
41/****************************************************************************
42* Local Types
43****************************************************************************/
44
45/****************************************************************************
46* Local Constants
47****************************************************************************/
48extern volatile T_ZDrvLcd_Info s_lcd_info;
49
50/****************************************************************************
51 * Function: peripheral_init
52 * Description: init the peripheral include pmu\charger\led\lcd etc.
53 * Parameters:
54 * Input:
55 *
56 * Output:
57 *
58 * Returns:
59 * int
60 *
61 *
62 * Others:
63 ***************************************************************************/
64int peripheral_init(void)
65{
66 int ret = 0;
67 ret = power_init();
68/*led*/
69 zx29_led_init();
70/*lcd*/
71 //ret |= zDrvLcd_Initiate();
72#if 0
73 usb_charger_init();
74#endif
75 zx234502_charger_enable();
76
77 /* jtagµ÷ÊÔ */
78#if 0
79 jtag_init();
80#endif
81
82 return ret ;
83}
84
85/****************************************************************************
86 * Function: Show_UpdateWait
87 * Description: show the logo when the local updataing through lcd/led etc.
88 * Parameters:
89 * Input:
90 *
91 * Output:
92 *
93 *
94 * Returns:
95 * int
96 *
97 *
98 * Others:
99 ***************************************************************************/
100int Show_UpdateWait(void)
101{
102 int ret = 0;
103/*led*/
104
105/*lcd*/
106 ;
107 return ret;
108}
109
110/****************************************************************************
111 * Function: Show_UpdateSucc
112 * Description: show the logo when the local updataing through lcd/led etc.
113 * Parameters:
114 * Input:
115 *
116 * Output:
117 *
118 *
119 * Returns:
120 * int
121 *
122 *
123 * Others:
124 ***************************************************************************/
125int Show_UpdateSucc(void)
126{
127 int ret = 0;
128/*led*/
129
130/*lcd*/
131 ;
132 return ret;
133}
134
135/****************************************************************************
136 * Function: Show_UpdateFail
137 * Description: show the logo when the local updataing through lcd/led etc.
138 * Parameters:
139 * Input:
140 *
141 * Output:
142 *
143 *
144 * Returns:
145 * int
146 *
147 *
148 * Others:
149 ***************************************************************************/
150int Show_UpdateFail(void)
151{
152 int ret = 0;
153/*led*/
154
155/*lcd*/
156 ;
157 return ret;
158}
159
160/****************************************************************************
161 * Function: Show_LowPower
162 * Description: show the logo when the local updataing through lcd/led etc.
163 * Parameters:
164 * Input:
165 *
166 * Output:
167 *
168 *
169 * Returns:
170 * int
171 *
172 *
173 * Others:
174 ***************************************************************************/
175int Show_LowPower(void)
176{
177 int ret = 0;
178
179 /*led*/
180 zx29_led_PowerOnLedOn();
181
182 /*lcd*/
183 zDrvLcd_ShowLowBattery();
184
185 udelay(300);
186 zx29_led_PowerOnLedOff();
187
188 /*lcd*/
189 if (strcmp(s_lcd_info.lcm_info.name,"mifi_no_lcd") == 0)
190 {
191 zDrvLcd_TurnBacklightOnOff(0);
192 }
193 else
194 {
195 zDrvLcd_TurnBacklightOnOff(1);
196 }
197
198 return ret;
199}
200
201/****************************************************************************
202 * Function: Show_No_Battery
203 * Description: show the logo when the local updataing through lcd/led etc.
204 * Parameters:
205 * Input:
206 *
207 * Output:
208 *
209 *
210 * Returns:
211 * int
212 *
213 *
214 * Others:
215 ***************************************************************************/
216int Show_No_Battery(void)
217{
218 int ret = 0;
219 /*led*/
220 zx29_led_PowerOnLedOn();
221
222 /*lcd*/
223 zDrvLcd_ShowNoBattery();
224
225 udelay(300);
226 /*led*/
227 zx29_led_PowerOnLedOff();
228
229 if (strcmp(s_lcd_info.lcm_info.name,"mifi_no_lcd") == 0)
230 {
231 zDrvLcd_TurnBacklightOnOff(0);
232 }
233 else
234 {
235 zDrvLcd_TurnBacklightOnOff(1);
236 }
237
238 return ret;
239}
240
241/****************************************************************************
242 * Function: Show_PowerOn_Normal
243 * Description: show the logo when the local updataing through lcd/led etc.
244 * Parameters:
245 * Input:
246 *
247 * Output:
248 *
249 *
250 * Returns:
251 * int
252 *
253 *
254 * Others:
255 ***************************************************************************/
256int Show_PowerOn_Normal(void)
257{
258 int ret = 0;
259 /*led*/
260 zx29_led_PowerOnLedOn();
261
262 /*lcd*/
263 zDrvLcd_PowerOnLogo();
264 udelay(300);
265 zx29_led_PowerOnLedOff();
266
267 if (strcmp(s_lcd_info.lcm_info.name,"mifi_no_lcd") == 0)
268 {
269 zDrvLcd_TurnBacklightOnOff(0);
270 }
271 else
272 {
273 zDrvLcd_TurnBacklightOnOff(1);
274 }
275
276 return ret;
277}
278
279/****************************************************************************
280 * Function: Show_PowerOn_Normal
281 * Description: show the logo when the local updataing through lcd/led etc.
282 * Parameters:
283 * Input:
284 *
285 * Output:
286 *
287 *
288 * Returns:
289 * int
290 *
291 *
292 * Others:
293 ***************************************************************************/
294
295int Show_PowerOn_Fota(void)
296{
297 int ret = 0;
298 /*led*/
299 zx29_led_PowerOnLedOn();
300
301 /*lcd*/
302 zDrvLcd_ShowUpdateWait();
303
304 udelay(300);
305 zx29_led_PowerOnLedOff();
306
307 if (strcmp(s_lcd_info.lcm_info.name,"mifi_no_lcd") == 0)
308 {
309 zDrvLcd_TurnBacklightOnOff(0);
310 }
311 else
312 {
313 zDrvLcd_TurnBacklightOnOff(1);
314 }
315
316 return ret;
317}
318
319
320/****************************************************************************
321 * Function: Show_Charging
322 * Description: show the logo when the local updataing through lcd/led etc.
323 * Parameters:
324 * Input:
325 *
326 * Output:
327 *
328 *
329 * Returns:
330 * int
331 *
332 *
333 * Others:
334 ***************************************************************************/
335int Show_Charging(void)
336{
337 int ret = 0;
338 /*led*/
339 zx29_led_PowerOnLedOn();
340
341 /*lcd*/
342 zDrvLcd_ShowCharging();
343 udelay(300);
344 zx29_led_PowerOnLedOff();
345
346 if (strcmp(s_lcd_info.lcm_info.name,"mifi_no_lcd") == 0)
347 {
348 zDrvLcd_TurnBacklightOnOff(0);
349 }
350 else
351 {
352 zDrvLcd_TurnBacklightOnOff(1);
353 }
354
355 return ret;
356}
357
358/****************************************************************************
359 * Function: zx_get_vbat_voltage
360 * Description: .
361 * Parameters:
362 * Input:
363 *
364 * Output:
365 *
366 *
367 * Returns:
368 * int
369 *
370 *
371 * Others:
372 ***************************************************************************/
373int zx_get_vbat_voltage(void)
374{
375 // int ret = 0;
376
377 return zx234290_get_adc1_voltage();
378}
379
380/****************************************************************************
381 * Function: zx_get_battery_Status
382 * Description:
383 * Parameters:
384 * Input:
385 *
386 * Output:
387 *
388 *
389 * Returns:
390 * int
391 *
392 *
393 * Others:
394 ***************************************************************************/
395unsigned int zx_get_battery_Status(void)
396{
397#if 0
398 int ret = 0;
399 int boost_flag = 1;
400
401 zx234502_battery_status(&boost_flag);
402 if(boost_flag){
403 return 0;/*battery uninstall*/
404 }
405 else
406 return 1;/*battery install*/
407#else
408 int ret = 0;
409 int battery_status = 0;
410
411 ret = zx234290_get_adc2_voltage();
412 if (ret < 0)
413 {
414 printf("\t[zx234290_get_adc2_voltage] return [%d] in [%s]\n", ret, __FUNCTION__);
415 return ret;
416 }
417
418 battery_status = (ret < 1770);
419
420#if 0
421 if (battery_status)
422 printf("\t[%s] get %d and return battery connected\n", __FUNCTION__, ret);
423 else
424 printf("\t[%s] get %d and return battery disconnected\n", __FUNCTION__, ret);
425#endif
426
427 return battery_status;
428#endif
429}
430