blob: 4b0d8feb566099e6d67238d931c7568d3318102b [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -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 "drvs_general.h"
24//#include "drvs_i2c.h"
25#include <linux/types.h>
26#include <zx234290.h>
27#include <led.h>
28#include "common.h"
29//#include <gpio.h>
30
31/****************************************************************************
32* Local Macros
33****************************************************************************/
34#define SD1_IO_1V8_EN 0x13c830
35#define REG32(x) (*(volatile u32*)(x))
xf.lie2a34102023-04-14 01:29:53 -070036//xf.li@20230412 add for enable GNSS start
37#define ZX_TOP_CRM_BASE 0x0013B000
38//xf.li@20230412 add for enable GNSS end
lh9ed821d2023-04-07 01:36:19 -070039/****************************************************************************
40* Local Types
41****************************************************************************/
42
43/****************************************************************************
44* Local Constants
45****************************************************************************/
46
47
48/****************************************************************************
49 * Function: peripheral_init
50 * Description: init the peripheral include pmu\charger\led\lcd etc.
51 * Parameters:
52 * Input:
53 *
54 * Output:
55 *
56 * Returns:
57 * int
58 *
59 *
60 * Others:
61 ***************************************************************************/
62int peripheral_init(void)
63{
64 int ret = 0;
65 ret = power_init();
66
67/*led*/
68
69/*lcd*/
70
71 /* jtagµ÷ÊÔ */
72#if 0
73 jtag_init();
74#endif
75
76#if 0//ref need ldo8 2.85V
77/*set mmc io and vccQ*/
78 zx234290_set_ldo8_voltage(VLDOD_1_800);
79 zx234290_set_ldo8_sleep_voltage(VLDOD_1_800);
80 zx234290_ldo8_enable(1);
81
82 REG32(SD1_IO_1V8_EN) |=(1<<1);
83#endif
xf.lie2a34102023-04-14 01:29:53 -070084//xf.li@20230412 add for enable GNSS start
85#if 1 //enable GNSS
86 REG32(ZX_TOP_CRM_BASE + 0x34) |= (0x1<<5);
87 zDrvGpio_SetFunc(GPIO15,GPIO15_CLK_OUT0);
88
89 zDrvGpio_SetFunc(GPIO86,GPIO86_GPIO86);
90 zDrvGpio_SetDirection(GPIO86,GPIO_OUT);
91 zDrvGpio_SetOutputValue(GPIO86,GPIO_HIGH);
92
93 zDrvGpio_SetFunc(GPIO126,GPIO126_GPIO126);
94 zDrvGpio_SetDirection(GPIO126,GPIO_OUT);
95 zDrvGpio_SetOutputValue(GPIO126,GPIO_LOW);
96#endif
97//xf.li@20230412 add for enable GNSS end
lh9ed821d2023-04-07 01:36:19 -070098 zx234502_charger_enable();
99
100 return ret ;
101}
102
103/****************************************************************************
104 * Function: Show_UpdateWait
105 * Description: show the logo when the local updataing through lcd/led etc.
106 * Parameters:
107 * Input:
108 *
109 * Output:
110 *
111 *
112 * Returns:
113 * int
114 *
115 *
116 * Others:
117 ***************************************************************************/
118int Show_UpdateWait(void)
119{
120 int ret = 0;
121/*led*/
122
123/*lcd*/
124 ;
125 return ret;
126}
127
128/****************************************************************************
129 * Function: Show_UpdateSucc
130 * Description: show the logo when the local updataing through lcd/led etc.
131 * Parameters:
132 * Input:
133 *
134 * Output:
135 *
136 *
137 * Returns:
138 * int
139 *
140 *
141 * Others:
142 ***************************************************************************/
143int Show_UpdateSucc(void)
144{
145 int ret = 0;
146/*led*/
147
148/*lcd*/
149 ;
150 return ret;
151}
152
153/****************************************************************************
154 * Function: Show_UpdateFail
155 * Description: show the logo when the local updataing through lcd/led etc.
156 * Parameters:
157 * Input:
158 *
159 * Output:
160 *
161 *
162 * Returns:
163 * int
164 *
165 *
166 * Others:
167 ***************************************************************************/
168int Show_UpdateFail(void)
169{
170 int ret = 0;
171/*led*/
172
173/*lcd*/
174 ;
175 return ret;
176}
177
178/****************************************************************************
179 * Function: Show_LowPower
180 * Description: show the logo when the local updataing through lcd/led etc.
181 * Parameters:
182 * Input:
183 *
184 * Output:
185 *
186 *
187 * Returns:
188 * int
189 *
190 *
191 * Others:
192 ***************************************************************************/
193int Show_LowPower(void)
194{
195 int ret = 0;
196/*led*/
197
198/*lcd*/
199 ;
200 return ret;
201}
202
203/****************************************************************************
204 * Function: Show_No_Battery
205 * Description: show the logo when the local updataing through lcd/led etc.
206 * Parameters:
207 * Input:
208 *
209 * Output:
210 *
211 *
212 * Returns:
213 * int
214 *
215 *
216 * Others:
217 ***************************************************************************/
218int Show_No_Battery(void)
219{
220 int ret = 0;
221/*led*/
222
223/*lcd*/
224 ;
225 return ret;
226}
227
228/****************************************************************************
229 * Function: Show_PowerOn_Normal
230 * Description: show the logo when the local updataing through lcd/led etc.
231 * Parameters:
232 * Input:
233 *
234 * Output:
235 *
236 *
237 * Returns:
238 * int
239 *
240 *
241 * Others:
242 ***************************************************************************/
243int Show_PowerOn_Normal(void)
244{
245 int ret = 0;
246/*led*/
247
248/*lcd*/
249 ;
250 return ret;
251}
252
253/****************************************************************************
254 * Function: Show_PowerOn_Normal
255 * Description: show the logo when the local updataing through lcd/led etc.
256 * Parameters:
257 * Input:
258 *
259 * Output:
260 *
261 *
262 * Returns:
263 * int
264 *
265 *
266 * Others:
267 ***************************************************************************/
268
269int Show_PowerOn_Fota(void)
270{
271 int ret = 0;
272/*led*/
273
274/*lcd*/
275 ;
276 return ret;
277}
278
279
280/****************************************************************************
281 * Function: Show_Charging
282 * Description: show the logo when the local updataing through lcd/led etc.
283 * Parameters:
284 * Input:
285 *
286 * Output:
287 *
288 *
289 * Returns:
290 * int
291 *
292 *
293 * Others:
294 ***************************************************************************/
295int Show_Charging(void)
296{
297 int ret = 0;
298/*led*/
299
300/*lcd*/
301 ;
302 return ret;
303}
304
305/****************************************************************************
306 * Function: zx_get_vbat_voltage
307 * Description: .
308 * Parameters:
309 * Input:
310 *
311 * Output:
312 *
313 *
314 * Returns:
315 * int
316 *
317 *
318 * Others:
319 ***************************************************************************/
320int zx_get_vbat_voltage(void)
321{
322 // int ret = 0;
323
324 return zx234290_get_adc1_voltage();
325}
326
327/****************************************************************************
328 * Function: zx_get_battery_Status
329 * Description:
330 * Parameters:
331 * Input:
332 *
333 * Output:
334 *
335 *
336 * Returns:
337 * int
338 *
339 *
340 * Others:
341 ***************************************************************************/
342unsigned int zx_get_battery_Status(void)
343{
344 int ret = 0;
345 int boost_flag = 1;
346
347 zx234502_battery_status(&boost_flag);
348 if(boost_flag){
349 return 0;/*battery uninstall*/
350 }
351 else
352 return 1;/*battery install*/
353}
354
355
356
357