blob: 82b70610c712554b9867d58a6ba9a1c8a31bd6c9 [file] [log] [blame]
xf.libfc6e712025-02-07 01:54:34 -08001/*******************************************************************************
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 <drvs_gpio.h>
29#include "common.h"
30#include <dma_cfg.h>
31
32//#include <gpio.h>
33
34/****************************************************************************
35* Local Macros
36****************************************************************************/
37#define SD1_IO_1V8_EN 0x13c830
38#define REG32(x) (*(volatile u32*)(x))
39#define MMC0_USED_EN 1
40#define MMC1_USED_EN 1
41
42/****************************************************************************
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();
69
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));
73/*led*/
74/*lcd*/
75
76 /* jtag调试 */
77#if 0
78 jtag_init();
79#endif
80
81//#if 0//ref need ldo8 2.85V
82#if defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
83/*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);
89
90 /*关闭gps电源*/
91 zDrvGpio_SetFunc(GPIO86, GPIO86_GPIO86);
92 zDrvGpio_SetDirection(GPIO86, GPIO_OUT);
93 zDrvGpio_SetOutputValue(GPIO86, GPIO_LOW);
94#endif
95 zx234502_charger_enable();
96
97 return ret ;
98}
99
100/****************************************************************************
101 * Function: Show_UpdateWait
102 * Description: show the logo when the local updataing through lcd/led etc.
103 * Parameters:
104 * Input:
105 *
106 * Output:
107 *
108 *
109 * Returns:
110 * int
111 *
112 *
113 * Others:
114 ***************************************************************************/
115int Show_UpdateWait(void)
116{
117 int ret = 0;
118/*led*/
119
120/*lcd*/
121 ;
122 return ret;
123}
124
125/****************************************************************************
126 * Function: Show_UpdateSucc
127 * Description: show the logo when the local updataing through lcd/led etc.
128 * Parameters:
129 * Input:
130 *
131 * Output:
132 *
133 *
134 * Returns:
135 * int
136 *
137 *
138 * Others:
139 ***************************************************************************/
140int Show_UpdateSucc(void)
141{
142 int ret = 0;
143/*led*/
144
145/*lcd*/
146 ;
147 return ret;
148}
149
150/****************************************************************************
151 * Function: Show_UpdateFail
152 * Description: show the logo when the local updataing through lcd/led etc.
153 * Parameters:
154 * Input:
155 *
156 * Output:
157 *
158 *
159 * Returns:
160 * int
161 *
162 *
163 * Others:
164 ***************************************************************************/
165int Show_UpdateFail(void)
166{
167 int ret = 0;
168/*led*/
169
170/*lcd*/
171 ;
172 return ret;
173}
174
175/****************************************************************************
176 * Function: Show_LowPower
177 * Description: show the logo when the local updataing through lcd/led etc.
178 * Parameters:
179 * Input:
180 *
181 * Output:
182 *
183 *
184 * Returns:
185 * int
186 *
187 *
188 * Others:
189 ***************************************************************************/
190int Show_LowPower(void)
191{
192 int ret = 0;
193/*led*/
194
195/*lcd*/
196 ;
197 return ret;
198}
199
200/****************************************************************************
201 * Function: Show_No_Battery
202 * Description: show the logo when the local updataing through lcd/led etc.
203 * Parameters:
204 * Input:
205 *
206 * Output:
207 *
208 *
209 * Returns:
210 * int
211 *
212 *
213 * Others:
214 ***************************************************************************/
215int Show_No_Battery(void)
216{
217 int ret = 0;
218/*led*/
219
220/*lcd*/
221 ;
222 return ret;
223}
224
225/****************************************************************************
226 * Function: Show_PowerOn_Normal
227 * Description: show the logo when the local updataing through lcd/led etc.
228 * Parameters:
229 * Input:
230 *
231 * Output:
232 *
233 *
234 * Returns:
235 * int
236 *
237 *
238 * Others:
239 ***************************************************************************/
240int Show_PowerOn_Normal(void)
241{
242 int ret = 0;
243/*led*/
244
245/*lcd*/
246 ;
247 return ret;
248}
249
250/****************************************************************************
251 * Function: Show_PowerOn_Normal
252 * Description: show the logo when the local updataing through lcd/led etc.
253 * Parameters:
254 * Input:
255 *
256 * Output:
257 *
258 *
259 * Returns:
260 * int
261 *
262 *
263 * Others:
264 ***************************************************************************/
265
266int Show_PowerOn_Fota(void)
267{
268 int ret = 0;
269/*led*/
270
271/*lcd*/
272 ;
273 return ret;
274}
275
276
277/****************************************************************************
278 * Function: Show_Charging
279 * Description: show the logo when the local updataing through lcd/led etc.
280 * Parameters:
281 * Input:
282 *
283 * Output:
284 *
285 *
286 * Returns:
287 * int
288 *
289 *
290 * Others:
291 ***************************************************************************/
292int Show_Charging(void)
293{
294 int ret = 0;
295/*led*/
296
297/*lcd*/
298 ;
299 return ret;
300}
301
302/****************************************************************************
303 * Function: zx_get_vbat_voltage
304 * Description: .
305 * Parameters:
306 * Input:
307 *
308 * Output:
309 *
310 *
311 * Returns:
312 * int
313 *
314 *
315 * Others:
316 ***************************************************************************/
317int zx_get_vbat_voltage(void)
318{
319 // int ret = 0;
320
321 return zx234290_get_adc1_voltage();
322}
323
324/****************************************************************************
325 * Function: zx_get_battery_Status
326 * Description:
327 * Parameters:
328 * Input:
329 *
330 * Output:
331 *
332 *
333 * Returns:
334 * int
335 *
336 *
337 * Others:
338 ***************************************************************************/
339unsigned int zx_get_battery_Status(void)
340{
341 int ret = 0;
342 int boost_flag = 1;
343
344 zx234502_battery_status(&boost_flag);
345 if(boost_flag){
346 return 0;/*battery uninstall*/
347 }
348 else
349 return 1;/*battery install*/
350}
351
352
353
354