blob: 6a09eee622ecd2e2552f228cebb780e09ab42564 [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 GPIO40
39#define CHARGER_EN_GPIO_FUN GPIO40_GPIO40
40/****************************************************************************
41* Local Types
42****************************************************************************/
43
44/****************************************************************************
45* Local Constants
46****************************************************************************/
47static void ms_delay(unsigned long ms)
48{
49 volatile int i = 0;
50 while (i < (50000 * ms)) {i++;}
51}
52
53/****************************************************************************
54 * Function: peripheral_init
55 * Description: init the peripheral include pmu\charger\led\lcd etc.
56 * Parameters:
57 * Input:
58 *
59 * Output:
60 *
61 * Returns:
62 * int
63 *
64 *
65 * Others:
66 ***************************************************************************/
67int peripheral_init(void)
68{
69 int ret = 0;
70 ret = power_init();
71
72 /*charger enable*/
73 zDrvGpio_SetFunc(CHARGER_EN_GPIO,CHARGER_EN_GPIO_FUN);
74 zDrvGpio_SetDirection(CHARGER_EN_GPIO,GPIO_OUT);
75 zDrvGpio_SetOutputValue(CHARGER_EN_GPIO,GPIO_HIGH);
76
77 /*reset for the TF card LD08 */
78 zx234290_ldo8_enable(0);
79 udelay(100000/20); /*50ms*/
80 zx234290_ldo8_enable(1);
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/*led*/
179
180/*lcd*/
181 zDrvLcd_ShowLowBattery();
182 ms_delay(50);
183 zDrvLcd_TurnBacklightOnOff(1);
184 zDrvLcd_SetPulseLevel(14);
185
186 return ret;
187}
188
189/****************************************************************************
190 * Function: Show_No_Battery
191 * Description: show the logo when the local updataing through lcd/led etc.
192 * Parameters:
193 * Input:
194 *
195 * Output:
196 *
197 *
198 * Returns:
199 * int
200 *
201 *
202 * Others:
203 ***************************************************************************/
204int Show_No_Battery(void)
205{
206 int ret = 0;
207/*led*/
208
209/*lcd*/
210 zDrvLcd_ShowNoBattery();
211 ms_delay(50);
212 zDrvLcd_TurnBacklightOnOff(1);
213 zDrvLcd_SetPulseLevel(14);
214
215 return ret;
216}
217
218/****************************************************************************
219 * Function: Show_PowerOn_Normal
220 * Description: show the logo when the local updataing through lcd/led etc.
221 * Parameters:
222 * Input:
223 *
224 * Output:
225 *
226 *
227 * Returns:
228 * int
229 *
230 *
231 * Others:
232 ***************************************************************************/
233int Show_PowerOn_Normal(void)
234{
235 int ret = 0;
236/*led*/
237
238/*lcd*/
239 zDrvLcd_PowerOnLogo();
240 ms_delay(50);
241 zDrvLcd_TurnBacklightOnOff(1);
242 zDrvLcd_SetPulseLevel(14);
243
244 return ret;
245}
246
247/****************************************************************************
248 * Function: Show_PowerOn_Fota
249 * Description: show the logo when the local updataing through lcd/led etc.
250 * Parameters:
251 * Input:
252 *
253 * Output:
254 *
255 *
256 * Returns:
257 * int
258 *
259 *
260 * Others:
261 ***************************************************************************/
262
263int Show_PowerOn_Fota(void)
264{
265 int ret = 0;
266/*led*/
267
268/*lcd*/
269 zDrvLcd_ShowUpdateWait();
270 ms_delay(50);
271 zDrvLcd_TurnBacklightOnOff(1);
272 zDrvLcd_SetPulseLevel(14);
273
274 return ret;
275}
276
277
278/****************************************************************************
279 * Function: Show_Charging
280 * Description: show the logo when the local updataing through lcd/led etc.
281 * Parameters:
282 * Input:
283 *
284 * Output:
285 *
286 *
287 * Returns:
288 * int
289 *
290 *
291 * Others:
292 ***************************************************************************/
293int Show_Charging(void)
294{
295 int ret = 0;
296/*led*/
297
298/*lcd*/
299 zDrvLcd_PowerOnLogo();
300 ms_delay(50);
301 zDrvLcd_TurnBacklightOnOff(1);
302 zDrvLcd_SetPulseLevel(14);
303
304 return ret;
305}
306
307/****************************************************************************
308 * Function: Show_PowerOn_Rtc
309 * Description: show the logo when the local updataing through lcd/led etc.
310 * Parameters:
311 * Input:
312 *
313 * Output:
314 *
315 *
316 * Returns:
317 * int
318 *
319 *
320 * Others:
321 ***************************************************************************/
322
323int Show_PowerOn_Rtc(void)
324{
325 int ret = 0;
326/*led*/
327
328/*lcd*/
329 zDrvLcd_PowerOnLogo();
330 return ret;
331}
332
333/****************************************************************************
334 * Function: zx_get_vbat_voltage
335 * Description: .
336 * Parameters:
337 * Input:
338 *
339 * Output:
340 *
341 *
342 * Returns:
343 * int
344 *
345 *
346 * Others:
347 ***************************************************************************/
348int zx_get_vbat_voltage(void)
349{
350 // int ret = 0;
351
352 return zx234290_get_adc1_voltage();
353}
354
355/****************************************************************************
356 * Function: zx_get_battery_Status
357 * Description:
358 * Parameters:
359 * Input:
360 *
361 * Output:
362 *
363 *
364 * Returns:
365 * int
366 *
367 *
368 * Others:
369 ***************************************************************************/
370unsigned int zx_get_battery_Status(void)
371{
372 int ret = 0;
373 int battery_status = 0;
374
375 ret = zx234290_get_adc2_voltage();
376 if (ret < 0)
377 {
378 printf("\t[zx234290_get_adc2_voltage] return [%d] in [%s]\n", ret, __FUNCTION__);
379 return ret;
380 }
381
382 battery_status = (ret < 1670);
383
384 return battery_status;
385}