blob: 4394c7b58e40e3797a13eb2a0e364e82a6204bd3 [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.li4e530992023-04-17 04:35:55 -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
xf.libdd93d52023-05-12 07:10:14 -070076//#if 0//ref need ldo8 2.85V
77#ifdef CONFIG_ZX297520V3E_VEHICLE_DC
lh9ed821d2023-04-07 01:36:19 -070078/*set mmc io and vccQ*/
79 zx234290_set_ldo8_voltage(VLDOD_1_800);
80 zx234290_set_ldo8_sleep_voltage(VLDOD_1_800);
81 zx234290_ldo8_enable(1);
82
83 REG32(SD1_IO_1V8_EN) |=(1<<1);
84#endif
xf.li4e530992023-04-17 04:35:55 -070085//xf.li@20230412 add for enable GNSS start
86#if 1 //enable GNSS
87 REG32(ZX_TOP_CRM_BASE + 0x34) |= (0x1<<5);
88 zDrvGpio_SetFunc(GPIO15,GPIO15_CLK_OUT0);
89
90 zDrvGpio_SetFunc(GPIO86,GPIO86_GPIO86);
91 zDrvGpio_SetDirection(GPIO86,GPIO_OUT);
92 zDrvGpio_SetOutputValue(GPIO86,GPIO_HIGH);
93
94 zDrvGpio_SetFunc(GPIO126,GPIO126_GPIO126);
95 zDrvGpio_SetDirection(GPIO126,GPIO_OUT);
96 zDrvGpio_SetOutputValue(GPIO126,GPIO_LOW);
97#endif
98//xf.li@20230412 add for enable GNSS end
lh9ed821d2023-04-07 01:36:19 -070099 zx234502_charger_enable();
100
101 return ret ;
102}
103
104/****************************************************************************
105 * Function: Show_UpdateWait
106 * Description: show the logo when the local updataing through lcd/led etc.
107 * Parameters:
108 * Input:
109 *
110 * Output:
111 *
112 *
113 * Returns:
114 * int
115 *
116 *
117 * Others:
118 ***************************************************************************/
119int Show_UpdateWait(void)
120{
121 int ret = 0;
122/*led*/
123
124/*lcd*/
125 ;
126 return ret;
127}
128
129/****************************************************************************
130 * Function: Show_UpdateSucc
131 * Description: show the logo when the local updataing through lcd/led etc.
132 * Parameters:
133 * Input:
134 *
135 * Output:
136 *
137 *
138 * Returns:
139 * int
140 *
141 *
142 * Others:
143 ***************************************************************************/
144int Show_UpdateSucc(void)
145{
146 int ret = 0;
147/*led*/
148
149/*lcd*/
150 ;
151 return ret;
152}
153
154/****************************************************************************
155 * Function: Show_UpdateFail
156 * Description: show the logo when the local updataing through lcd/led etc.
157 * Parameters:
158 * Input:
159 *
160 * Output:
161 *
162 *
163 * Returns:
164 * int
165 *
166 *
167 * Others:
168 ***************************************************************************/
169int Show_UpdateFail(void)
170{
171 int ret = 0;
172/*led*/
173
174/*lcd*/
175 ;
176 return ret;
177}
178
179/****************************************************************************
180 * Function: Show_LowPower
181 * Description: show the logo when the local updataing through lcd/led etc.
182 * Parameters:
183 * Input:
184 *
185 * Output:
186 *
187 *
188 * Returns:
189 * int
190 *
191 *
192 * Others:
193 ***************************************************************************/
194int Show_LowPower(void)
195{
196 int ret = 0;
197/*led*/
198
199/*lcd*/
200 ;
201 return ret;
202}
203
204/****************************************************************************
205 * Function: Show_No_Battery
206 * Description: show the logo when the local updataing through lcd/led etc.
207 * Parameters:
208 * Input:
209 *
210 * Output:
211 *
212 *
213 * Returns:
214 * int
215 *
216 *
217 * Others:
218 ***************************************************************************/
219int Show_No_Battery(void)
220{
221 int ret = 0;
222/*led*/
223
224/*lcd*/
225 ;
226 return ret;
227}
228
229/****************************************************************************
230 * Function: Show_PowerOn_Normal
231 * Description: show the logo when the local updataing through lcd/led etc.
232 * Parameters:
233 * Input:
234 *
235 * Output:
236 *
237 *
238 * Returns:
239 * int
240 *
241 *
242 * Others:
243 ***************************************************************************/
244int Show_PowerOn_Normal(void)
245{
246 int ret = 0;
247/*led*/
248
249/*lcd*/
250 ;
251 return ret;
252}
253
254/****************************************************************************
255 * Function: Show_PowerOn_Normal
256 * Description: show the logo when the local updataing through lcd/led etc.
257 * Parameters:
258 * Input:
259 *
260 * Output:
261 *
262 *
263 * Returns:
264 * int
265 *
266 *
267 * Others:
268 ***************************************************************************/
269
270int Show_PowerOn_Fota(void)
271{
272 int ret = 0;
273/*led*/
274
275/*lcd*/
276 ;
277 return ret;
278}
279
280
281/****************************************************************************
282 * Function: Show_Charging
283 * Description: show the logo when the local updataing through lcd/led etc.
284 * Parameters:
285 * Input:
286 *
287 * Output:
288 *
289 *
290 * Returns:
291 * int
292 *
293 *
294 * Others:
295 ***************************************************************************/
296int Show_Charging(void)
297{
298 int ret = 0;
299/*led*/
300
301/*lcd*/
302 ;
303 return ret;
304}
305
306/****************************************************************************
307 * Function: zx_get_vbat_voltage
308 * Description: .
309 * Parameters:
310 * Input:
311 *
312 * Output:
313 *
314 *
315 * Returns:
316 * int
317 *
318 *
319 * Others:
320 ***************************************************************************/
321int zx_get_vbat_voltage(void)
322{
323 // int ret = 0;
324
325 return zx234290_get_adc1_voltage();
326}
327
328/****************************************************************************
329 * Function: zx_get_battery_Status
330 * Description:
331 * Parameters:
332 * Input:
333 *
334 * Output:
335 *
336 *
337 * Returns:
338 * int
339 *
340 *
341 * Others:
342 ***************************************************************************/
343unsigned int zx_get_battery_Status(void)
344{
345 int ret = 0;
346 int boost_flag = 1;
347
348 zx234502_battery_status(&boost_flag);
349 if(boost_flag){
350 return 0;/*battery uninstall*/
351 }
352 else
353 return 1;/*battery install*/
354}
355
356
357
358