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>
|
| 28 | #include "common.h"
|
| 29 | //#include <gpio.h>
|
| 30 |
|
| 31 | /****************************************************************************
|
| 32 | * Local Macros
|
| 33 | ****************************************************************************/
|
| 34 | #define SD1_IO_1V8_EN 0x13c830
|
| 35 | #define REG32(x) (*(volatile u32*)(x))
|
xf.li | 563f248 | 2023-04-27 22:34:57 -0700 | [diff] [blame] | 36 |
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 37 | /****************************************************************************
|
| 38 | * Local Types
|
| 39 | ****************************************************************************/
|
| 40 |
|
| 41 | /****************************************************************************
|
| 42 | * Local Constants
|
| 43 | ****************************************************************************/
|
| 44 |
|
| 45 |
|
| 46 | /****************************************************************************
|
| 47 | * Function: peripheral_init
|
| 48 | * Description: init the peripheral include pmu\charger\led\lcd etc.
|
| 49 | * Parameters:
|
| 50 | * Input:
|
| 51 | *
|
| 52 | * Output:
|
| 53 | *
|
| 54 | * Returns:
|
| 55 | * int
|
| 56 | *
|
| 57 | *
|
| 58 | * Others:
|
| 59 | ***************************************************************************/
|
| 60 | int peripheral_init(void)
|
| 61 | {
|
| 62 | int ret = 0;
|
| 63 | ret = power_init();
|
| 64 |
|
| 65 | /*led*/
|
| 66 |
|
| 67 | /*lcd*/
|
| 68 |
|
| 69 | /* jtagµ÷ÊÔ */
|
| 70 | #if 0
|
| 71 | jtag_init();
|
| 72 | #endif
|
| 73 |
|
| 74 | #if 0//ref need ldo8 2.85V
|
| 75 | /*set mmc io and vccQ*/
|
| 76 | zx234290_set_ldo8_voltage(VLDOD_1_800);
|
| 77 | zx234290_set_ldo8_sleep_voltage(VLDOD_1_800);
|
| 78 | zx234290_ldo8_enable(1);
|
| 79 |
|
| 80 | REG32(SD1_IO_1V8_EN) |=(1<<1);
|
| 81 | #endif
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 82 | zx234502_charger_enable();
|
| 83 |
|
| 84 | return ret ;
|
| 85 | }
|
| 86 |
|
| 87 | /****************************************************************************
|
| 88 | * Function: Show_UpdateWait
|
| 89 | * Description: show the logo when the local updataing through lcd/led etc.
|
| 90 | * Parameters:
|
| 91 | * Input:
|
| 92 | *
|
| 93 | * Output:
|
| 94 | *
|
| 95 | *
|
| 96 | * Returns:
|
| 97 | * int
|
| 98 | *
|
| 99 | *
|
| 100 | * Others:
|
| 101 | ***************************************************************************/
|
| 102 | int Show_UpdateWait(void)
|
| 103 | {
|
| 104 | int ret = 0;
|
| 105 | /*led*/
|
| 106 |
|
| 107 | /*lcd*/
|
| 108 | ;
|
| 109 | return ret;
|
| 110 | }
|
| 111 |
|
| 112 | /****************************************************************************
|
| 113 | * Function: Show_UpdateSucc
|
| 114 | * Description: show the logo when the local updataing through lcd/led etc.
|
| 115 | * Parameters:
|
| 116 | * Input:
|
| 117 | *
|
| 118 | * Output:
|
| 119 | *
|
| 120 | *
|
| 121 | * Returns:
|
| 122 | * int
|
| 123 | *
|
| 124 | *
|
| 125 | * Others:
|
| 126 | ***************************************************************************/
|
| 127 | int Show_UpdateSucc(void)
|
| 128 | {
|
| 129 | int ret = 0;
|
| 130 | /*led*/
|
| 131 |
|
| 132 | /*lcd*/
|
| 133 | ;
|
| 134 | return ret;
|
| 135 | }
|
| 136 |
|
| 137 | /****************************************************************************
|
| 138 | * Function: Show_UpdateFail
|
| 139 | * Description: show the logo when the local updataing through lcd/led etc.
|
| 140 | * Parameters:
|
| 141 | * Input:
|
| 142 | *
|
| 143 | * Output:
|
| 144 | *
|
| 145 | *
|
| 146 | * Returns:
|
| 147 | * int
|
| 148 | *
|
| 149 | *
|
| 150 | * Others:
|
| 151 | ***************************************************************************/
|
| 152 | int Show_UpdateFail(void)
|
| 153 | {
|
| 154 | int ret = 0;
|
| 155 | /*led*/
|
| 156 |
|
| 157 | /*lcd*/
|
| 158 | ;
|
| 159 | return ret;
|
| 160 | }
|
| 161 |
|
| 162 | /****************************************************************************
|
| 163 | * Function: Show_LowPower
|
| 164 | * Description: show the logo when the local updataing through lcd/led etc.
|
| 165 | * Parameters:
|
| 166 | * Input:
|
| 167 | *
|
| 168 | * Output:
|
| 169 | *
|
| 170 | *
|
| 171 | * Returns:
|
| 172 | * int
|
| 173 | *
|
| 174 | *
|
| 175 | * Others:
|
| 176 | ***************************************************************************/
|
| 177 | int Show_LowPower(void)
|
| 178 | {
|
| 179 | int ret = 0;
|
| 180 | /*led*/
|
| 181 |
|
| 182 | /*lcd*/
|
| 183 | ;
|
| 184 | return ret;
|
| 185 | }
|
| 186 |
|
| 187 | /****************************************************************************
|
| 188 | * Function: Show_No_Battery
|
| 189 | * Description: show the logo when the local updataing through lcd/led etc.
|
| 190 | * Parameters:
|
| 191 | * Input:
|
| 192 | *
|
| 193 | * Output:
|
| 194 | *
|
| 195 | *
|
| 196 | * Returns:
|
| 197 | * int
|
| 198 | *
|
| 199 | *
|
| 200 | * Others:
|
| 201 | ***************************************************************************/
|
| 202 | int Show_No_Battery(void)
|
| 203 | {
|
| 204 | int ret = 0;
|
| 205 | /*led*/
|
| 206 |
|
| 207 | /*lcd*/
|
| 208 | ;
|
| 209 | return ret;
|
| 210 | }
|
| 211 |
|
| 212 | /****************************************************************************
|
| 213 | * Function: Show_PowerOn_Normal
|
| 214 | * Description: show the logo when the local updataing through lcd/led etc.
|
| 215 | * Parameters:
|
| 216 | * Input:
|
| 217 | *
|
| 218 | * Output:
|
| 219 | *
|
| 220 | *
|
| 221 | * Returns:
|
| 222 | * int
|
| 223 | *
|
| 224 | *
|
| 225 | * Others:
|
| 226 | ***************************************************************************/
|
| 227 | int Show_PowerOn_Normal(void)
|
| 228 | {
|
| 229 | int ret = 0;
|
| 230 | /*led*/
|
| 231 |
|
| 232 | /*lcd*/
|
| 233 | ;
|
| 234 | return ret;
|
| 235 | }
|
| 236 |
|
| 237 | /****************************************************************************
|
| 238 | * Function: Show_PowerOn_Normal
|
| 239 | * Description: show the logo when the local updataing through lcd/led etc.
|
| 240 | * Parameters:
|
| 241 | * Input:
|
| 242 | *
|
| 243 | * Output:
|
| 244 | *
|
| 245 | *
|
| 246 | * Returns:
|
| 247 | * int
|
| 248 | *
|
| 249 | *
|
| 250 | * Others:
|
| 251 | ***************************************************************************/
|
| 252 |
|
| 253 | int Show_PowerOn_Fota(void)
|
| 254 | {
|
| 255 | int ret = 0;
|
| 256 | /*led*/
|
| 257 |
|
| 258 | /*lcd*/
|
| 259 | ;
|
| 260 | return ret;
|
| 261 | }
|
| 262 |
|
| 263 |
|
| 264 | /****************************************************************************
|
| 265 | * Function: Show_Charging
|
| 266 | * Description: show the logo when the local updataing through lcd/led etc.
|
| 267 | * Parameters:
|
| 268 | * Input:
|
| 269 | *
|
| 270 | * Output:
|
| 271 | *
|
| 272 | *
|
| 273 | * Returns:
|
| 274 | * int
|
| 275 | *
|
| 276 | *
|
| 277 | * Others:
|
| 278 | ***************************************************************************/
|
| 279 | int Show_Charging(void)
|
| 280 | {
|
| 281 | int ret = 0;
|
| 282 | /*led*/
|
| 283 |
|
| 284 | /*lcd*/
|
| 285 | ;
|
| 286 | return ret;
|
| 287 | }
|
| 288 |
|
| 289 | /****************************************************************************
|
| 290 | * Function: zx_get_vbat_voltage
|
| 291 | * Description: .
|
| 292 | * Parameters:
|
| 293 | * Input:
|
| 294 | *
|
| 295 | * Output:
|
| 296 | *
|
| 297 | *
|
| 298 | * Returns:
|
| 299 | * int
|
| 300 | *
|
| 301 | *
|
| 302 | * Others:
|
| 303 | ***************************************************************************/
|
| 304 | int zx_get_vbat_voltage(void)
|
| 305 | {
|
| 306 | // int ret = 0;
|
| 307 |
|
| 308 | return zx234290_get_adc1_voltage();
|
| 309 | }
|
| 310 |
|
| 311 | /****************************************************************************
|
| 312 | * Function: zx_get_battery_Status
|
| 313 | * Description:
|
| 314 | * Parameters:
|
| 315 | * Input:
|
| 316 | *
|
| 317 | * Output:
|
| 318 | *
|
| 319 | *
|
| 320 | * Returns:
|
| 321 | * int
|
| 322 | *
|
| 323 | *
|
| 324 | * Others:
|
| 325 | ***************************************************************************/
|
| 326 | unsigned int zx_get_battery_Status(void)
|
| 327 | {
|
| 328 | int ret = 0;
|
| 329 | int boost_flag = 1;
|
| 330 |
|
| 331 | zx234502_battery_status(&boost_flag);
|
| 332 | if(boost_flag){
|
| 333 | return 0;/*battery uninstall*/
|
| 334 | }
|
| 335 | else
|
| 336 | return 1;/*battery install*/
|
| 337 | }
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|