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