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