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"
|
xf.li | 8402749 | 2024-04-09 00:17:51 -0700 | [diff] [blame] | 30 | #include <dma_cfg.h>
|
you.chen | 94a5608 | 2024-06-20 21:22:25 +0800 | [diff] [blame^] | 31 | #include "../rsa/drv_rsa.h"
|
| 32 |
|
| 33 | #ifdef LYNQ_NV_CFG_SUPPORT
|
| 34 | extern void lynq_setup_nv_cfg(void);
|
| 35 | #endif
|
xf.li | 8402749 | 2024-04-09 00:17:51 -0700 | [diff] [blame] | 36 |
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 37 | //#include <gpio.h>
|
| 38 |
|
| 39 | /****************************************************************************
|
| 40 | * Local Macros
|
| 41 | ****************************************************************************/
|
| 42 | #define SD1_IO_1V8_EN 0x13c830
|
xf.li | 8402749 | 2024-04-09 00:17:51 -0700 | [diff] [blame] | 43 | #define REG32(x) (*(volatile u32*)(x))
|
| 44 | #define MMC0_USED_EN 1
|
| 45 | #define MMC1_USED_EN 1
|
| 46 |
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 47 | /****************************************************************************
|
| 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 | ***************************************************************************/
|
| 70 | int peripheral_init(void)
|
| 71 | {
|
| 72 | int ret = 0;
|
| 73 | ret = power_init();
|
xf.li | 8402749 | 2024-04-09 00:17:51 -0700 | [diff] [blame] | 74 |
|
you.chen | 94a5608 | 2024-06-20 21:22:25 +0800 | [diff] [blame^] | 75 | BOOT_PRINTF(UBOOT_NOTICE, "cy: peripheral_init 2\n");
|
| 76 |
|
| 77 | #ifndef LYNQ_NV_CFG_SUPPORT
|
xf.li | 8402749 | 2024-04-09 00:17:51 -0700 | [diff] [blame] | 78 | /*mmc config*/
|
you.chen | 94a5608 | 2024-06-20 21:22:25 +0800 | [diff] [blame^] | 79 | REG32(MMC_FLAG_ADDR) &=~0x3;//clear bit0~1
|
xf.li | 8402749 | 2024-04-09 00:17:51 -0700 | [diff] [blame] | 80 | REG32(MMC_FLAG_ADDR) |=((MMC0_USED_EN<<0)|(MMC1_USED_EN<<1));
|
you.chen | 94a5608 | 2024-06-20 21:22:25 +0800 | [diff] [blame^] | 81 | #else
|
| 82 | lynq_setup_nv_cfg();
|
| 83 | #endif
|
| 84 |
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 85 | /*led*/
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 86 | /*lcd*/
|
| 87 |
|
xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 88 | /* jtag调试 */
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 89 | #if 0
|
| 90 | jtag_init();
|
| 91 | #endif
|
| 92 |
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 93 | //#if 0//ref need ldo8 2.85V
|
xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 94 | #if defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 95 | /*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.li | 4e53099 | 2023-04-17 04:35:55 -0700 | [diff] [blame] | 101 | //xf.li@20230412 add for enable GNSS start
|
xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 102 | /*关闭gps电源*/
|
| 103 | zDrvGpio_SetFunc(GPIO86, GPIO86_GPIO86);
|
| 104 | zDrvGpio_SetDirection(GPIO86, GPIO_OUT);
|
| 105 | zDrvGpio_SetOutputValue(GPIO86, GPIO_LOW);
|
xf.li | 4e53099 | 2023-04-17 04:35:55 -0700 | [diff] [blame] | 106 |
|
| 107 | zDrvGpio_SetFunc(GPIO126,GPIO126_GPIO126);
|
| 108 | zDrvGpio_SetDirection(GPIO126,GPIO_OUT);
|
| 109 | zDrvGpio_SetOutputValue(GPIO126,GPIO_LOW);
|
xf.li | 4e53099 | 2023-04-17 04:35:55 -0700 | [diff] [blame] | 110 | //xf.li@20230412 add for enable GNSS end
|
xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 111 | #endif
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 112 | 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 | ***************************************************************************/
|
| 132 | int 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 | ***************************************************************************/
|
| 157 | int 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 | ***************************************************************************/
|
| 182 | int 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 | ***************************************************************************/
|
| 207 | int 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 | ***************************************************************************/
|
| 232 | int 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 | ***************************************************************************/
|
| 257 | int 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 |
|
| 283 | int 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 | ***************************************************************************/
|
| 309 | int 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 | ***************************************************************************/
|
| 334 | int 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 | ***************************************************************************/
|
| 356 | unsigned 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 |
|