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