lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /*******************************************************************************
|
| 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.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 28 | #include <drvs_gpio.h>
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 29 | #include "common.h"
|
| 30 | //#include <gpio.h>
|
| 31 |
|
| 32 | /****************************************************************************
|
| 33 | * Local Macros
|
| 34 | ****************************************************************************/
|
| 35 | #define SD1_IO_1V8_EN 0x13c830
|
| 36 | #define REG32(x) (*(volatile u32*)(x))
|
xf.li | 4e53099 | 2023-04-17 04:35:55 -0700 | [diff] [blame] | 37 | //xf.li@20230412 add for enable GNSS start
|
| 38 | #define ZX_TOP_CRM_BASE 0x0013B000
|
| 39 | //xf.li@20230412 add for enable GNSS end
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 40 | /****************************************************************************
|
| 41 | * Local Types
|
| 42 | ****************************************************************************/
|
| 43 |
|
| 44 | /****************************************************************************
|
| 45 | * Local Constants
|
| 46 | ****************************************************************************/
|
| 47 |
|
| 48 |
|
| 49 | /****************************************************************************
|
| 50 | * Function: peripheral_init
|
| 51 | * Description: init the peripheral include pmu\charger\led\lcd etc.
|
| 52 | * Parameters:
|
| 53 | * Input:
|
| 54 | *
|
| 55 | * Output:
|
| 56 | *
|
| 57 | * Returns:
|
| 58 | * int
|
| 59 | *
|
| 60 | *
|
| 61 | * Others:
|
| 62 | ***************************************************************************/
|
| 63 | int peripheral_init(void)
|
| 64 | {
|
| 65 | int ret = 0;
|
| 66 | ret = power_init();
|
| 67 |
|
| 68 | /*led*/
|
| 69 |
|
| 70 | /*lcd*/
|
| 71 |
|
xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 72 | /* jtag调试 */
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 73 | #if 0
|
| 74 | jtag_init();
|
| 75 | #endif
|
| 76 |
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 77 | //#if 0//ref need ldo8 2.85V
|
xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 78 | #if defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 79 | /*set mmc io and vccQ*/
|
| 80 | zx234290_set_ldo8_voltage(VLDOD_1_800);
|
| 81 | zx234290_set_ldo8_sleep_voltage(VLDOD_1_800);
|
| 82 | zx234290_ldo8_enable(1);
|
| 83 |
|
| 84 | REG32(SD1_IO_1V8_EN) |=(1<<1);
|
xf.li | 4e53099 | 2023-04-17 04:35:55 -0700 | [diff] [blame] | 85 | //xf.li@20230412 add for enable GNSS start
|
xf.li | 4e53099 | 2023-04-17 04:35:55 -0700 | [diff] [blame] | 86 | REG32(ZX_TOP_CRM_BASE + 0x34) |= (0x1<<5);
|
| 87 | zDrvGpio_SetFunc(GPIO15,GPIO15_CLK_OUT0);
|
xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 88 | /*关闭gps电源*/
|
| 89 | zDrvGpio_SetFunc(GPIO86, GPIO86_GPIO86);
|
| 90 | zDrvGpio_SetDirection(GPIO86, GPIO_OUT);
|
| 91 | zDrvGpio_SetOutputValue(GPIO86, GPIO_LOW);
|
xf.li | 4e53099 | 2023-04-17 04:35:55 -0700 | [diff] [blame] | 92 |
|
| 93 | zDrvGpio_SetFunc(GPIO126,GPIO126_GPIO126);
|
| 94 | zDrvGpio_SetDirection(GPIO126,GPIO_OUT);
|
| 95 | zDrvGpio_SetOutputValue(GPIO126,GPIO_LOW);
|
xf.li | 4e53099 | 2023-04-17 04:35:55 -0700 | [diff] [blame] | 96 | //xf.li@20230412 add for enable GNSS end
|
xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 97 | #endif
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 98 | 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 | ***************************************************************************/
|
| 118 | int 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 | ***************************************************************************/
|
| 143 | int 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 | ***************************************************************************/
|
| 168 | int 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 | ***************************************************************************/
|
| 193 | int 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 | ***************************************************************************/
|
| 218 | int 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 | ***************************************************************************/
|
| 243 | int 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 |
|
| 269 | int 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 | ***************************************************************************/
|
| 295 | int 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 | ***************************************************************************/
|
| 320 | int 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 | ***************************************************************************/
|
| 342 | unsigned 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 |
|