2 * rk818_battery.h: fuel gauge driver structures
4 * Copyright (C) 2016 Rockchip Electronics Co., Ltd
5 * Author: chenjh <chenjh@rock-chips.com>
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License,
9 * version 2, as published by the Free Software Foundation.
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
20 /* RK818_INT_STS_MSK_REG2 */
21 #define PLUG_IN_MSK BIT(0)
22 #define PLUG_OUT_MSK BIT(1)
23 #define CHRG_CVTLMT_INT_MSK BIT(6)
25 /* RK818_TS_CTRL_REG */
27 #define ADC_CUR_EN BIT(6)
28 #define ADC_TS1_EN BIT(5)
29 #define ADC_TS2_EN BIT(4)
32 #define OCV_SAMP_MIN_MSK 0x0c
33 #define OCV_SAMP_8MIN (0x00 << 2)
35 #define ADC_CAL_MIN_MSK 0x30
36 #define ADC_CAL_8MIN (0x00 << 4)
37 #define ADC_CUR_MODE BIT(1)
40 #define BAT_CON BIT(4)
41 #define RELAX_VOL1_UPD BIT(3)
42 #define RELAX_VOL2_UPD BIT(2)
43 #define RELAX_VOL12_UPD_MSK (RELAX_VOL1_UPD | RELAX_VOL2_UPD)
45 /* RK818_SUP_STS_REG */
46 #define CHRG_STATUS_MSK 0x70
47 #define BAT_EXS BIT(7)
48 #define CHARGE_OFF (0x0 << 4)
49 #define DEAD_CHARGE (0x1 << 4)
50 #define TRICKLE_CHARGE (0x2 << 4)
51 #define CC_OR_CV (0x3 << 4)
52 #define CHARGE_FINISH (0x4 << 4)
53 #define USB_OVER_VOL (0x5 << 4)
54 #define BAT_TMP_ERR (0x6 << 4)
55 #define TIMER_ERR (0x7 << 4)
56 #define USB_VLIMIT_EN BIT(3)
57 #define USB_CLIMIT_EN BIT(2)
58 #define USB_EXIST BIT(1)
59 #define USB_EFF BIT(0)
61 /* RK818_USB_CTRL_REG */
62 #define CHRG_CT_EN BIT(7)
63 #define FINISH_CUR_MSK 0xc0
64 #define TEMP_105C (0x02 << 2)
65 #define FINISH_100MA (0x00 << 6)
66 #define FINISH_150MA (0x01 << 6)
67 #define FINISH_200MA (0x02 << 6)
68 #define FINISH_250MA (0x03 << 6)
70 /* RK818_CHRG_CTRL_REG3 */
71 #define CHRG_TERM_MODE_MSK BIT(5)
72 #define CHRG_TERM_ANA_SIGNAL (0 << 5)
73 #define CHRG_TERM_DIG_SIGNAL BIT(5)
74 #define CHRG_TIMER_CCCV_EN BIT(2)
75 #define CHRG_EN BIT(7)
77 /* RK818_VB_MON_REG */
78 #define RK818_VBAT_LOW_3V0 0x02
79 #define RK818_VBAT_LOW_3V4 0x06
80 #define PLUG_IN_STS BIT(6)
82 /* RK818_THERMAL_REG */
83 #define FB_TEMP_MSK 0x0c
85 /* RK818_INT_STS_MSK_REG1 */
86 #define VB_LOW_INT_EN BIT(1)
88 /* RK818_MISC_MARK_REG */
89 #define FG_INIT BIT(5)
90 #define FG_RESET_LATE BIT(4)
91 #define FG_RESET_NOW BIT(3)
92 #define ALGO_REST_MODE_MSK (0xc0)
93 #define ALGO_REST_MODE_SHIFT 6
96 #define FB_TEMP_SHIFT 2
98 /* parse ocv table param */
99 #define TIMER_MS_COUNTS 1000
100 #define MAX_PERCENTAGE 100
101 #define MAX_INTERPOLATE 1000
102 #define MAX_INT 0x7FFF
104 #define DRIVER_VERSION "7.1"
106 struct battery_platform_data {
111 u32 max_chrg_voltage;
116 u32 zero_algorithm_vol;
117 u32 zero_reserve_dsoc;
121 u32 sleep_enter_current;
122 u32 sleep_exit_current;
144 static const u16 feedback_temp_array[] = {
148 static const u16 chrg_vol_sel_array[] = {
149 4050, 4100, 4150, 4200, 4250, 4300, 4350
152 static const u16 chrg_cur_sel_array[] = {
153 1000, 1200, 1400, 1600, 1800, 2000, 2250, 2400, 2600, 2800, 3000
156 static const u16 chrg_cur_input_array[] = {
157 450, 800, 850, 1000, 1250, 1500, 1750, 2000, 2250, 2500, 2750, 3000
160 void kernel_power_off(void);
161 void rk_send_wakeup_key(void);