import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / arm / mach-mt8127 / ttab / power / cust_battery_meter.h
1 #ifndef _CUST_BATTERY_METER_H
2 #define _CUST_BATTERY_METER_H
3
4 #include <mach/mt_typedefs.h>
5
6 // ============================================================
7 // define
8 // ============================================================
9 //#define SOC_BY_AUXADC
10 #ifdef CONFIG_MTK_PMIC_MT6397
11 #define SOC_BY_HW_FG //fg auxadc
12 #else
13 #define SOC_BY_SW_FG //oam
14 #endif
15
16 //#define CONFIG_DIS_CHECK_BATTERY
17 //#define FIXED_TBAT_25
18
19 #if defined(CONFIG_MTK_BQ24296_SUPPORT) \
20 || defined(CONFIG_MTK_BQ24196_SUPPORT)
21 #define BAT_VOL_USE_ISENSE
22 #define SWCHR_POWER_PATH
23 #endif
24
25 #if defined(CONFIG_MTK_FAN5402_SUPPORT) \
26 || defined(CONFIG_MTK_FAN5405_SUPPORT) \
27 || defined(CONFIG_MTK_BQ24158_SUPPORT) \
28 || defined(CONFIG_MTK_BQ24196_SUPPORT) \
29 || defined(CONFIG_MTK_BQ24296_SUPPORT) \
30 || defined(CONFIG_MTK_NCP1851_SUPPORT) \
31 || defined(CONFIG_MTK_NCP1854_SUPPORT) \
32 || defined(CONFIG_MTK_BQ24160_SUPPORT) \
33 || defined(CONFIG_MTK_BQ24157_SUPPORT) \
34 || defined(CONFIG_MTK_BQ24250_SUPPORT) \
35 || defined(CONFIG_MTK_BQ24261_SUPPORT)
36 #define EXTERNAL_SWCHR_SUPPORT
37 #endif
38
39 /* ADC Channel Number */
40 #ifdef CONFIG_MTK_PMIC_MT6397
41 #define CUST_TABT_NUMBER 8
42 #ifdef BAT_VOL_USE_ISENSE
43 #define VBAT_CHANNEL_NUMBER 1 // w/ powerpath, battery voltage is ISENSE(1)
44 #define ISENSE_CHANNEL_NUMBER 0 // w/ powerpath, system voltage is VSENSE(0)
45 #else
46 #define VBAT_CHANNEL_NUMBER 0
47 #define ISENSE_CHANNEL_NUMBER 1
48 #endif
49 #define VCHARGER_CHANNEL_NUMBER 2
50 #define VBATTEMP_CHANNEL_NUMBER 3
51
52 #else //6323
53
54 #define CUST_TABT_NUMBER 17
55 #ifdef BAT_VOL_USE_ISENSE
56 #define VBAT_CHANNEL_NUMBER 6 // w/ powerpath, battery voltage is ISENSE(1)
57 #define ISENSE_CHANNEL_NUMBER 7 // w/ powerpath, system voltage is VSENSE(0)
58 #else
59 #define VBAT_CHANNEL_NUMBER 7
60 #define ISENSE_CHANNEL_NUMBER 6
61 #endif
62 #define VCHARGER_CHANNEL_NUMBER 4
63 #define VBATTEMP_CHANNEL_NUMBER 5
64
65 #endif
66
67 /* ADC resistor */
68 #define R_BAT_SENSE 4
69 #define R_I_SENSE 4
70 #define R_CHARGER_1 330
71 #define R_CHARGER_2 39
72
73 #define TEMPERATURE_T0 110
74 #define TEMPERATURE_T1 0
75 #define TEMPERATURE_T2 25
76 #define TEMPERATURE_T3 50
77 #define TEMPERATURE_T 255 // This should be fixed, never change the value
78
79 #define FG_METER_RESISTANCE 0
80
81 /* Qmax for battery */
82 #define Q_MAX_POS_50 3009
83 #define Q_MAX_POS_25 3009
84 #define Q_MAX_POS_0 3009
85 #define Q_MAX_NEG_10 3009
86
87 #define Q_MAX_POS_50_H_CURRENT 2975
88 #define Q_MAX_POS_25_H_CURRENT 2975
89 #define Q_MAX_POS_0_H_CURRENT 2975
90 #define Q_MAX_NEG_10_H_CURRENT 2975
91
92
93 /* Discharge Percentage */
94 #define OAM_D5 1 // 1 : D5, 0: D2
95
96
97 /* battery meter parameter */
98 #define CUST_TRACKING_POINT 14
99 #define CUST_R_SENSE 200
100 #define CUST_HW_CC 0
101 #define AGING_TUNING_VALUE 100
102 #define CUST_R_FG_OFFSET 23
103
104 #define OCV_BOARD_COMPESATE 0 //mV
105 #define R_FG_BOARD_BASE 1000
106 #define R_FG_BOARD_SLOPE 1000 //slope
107 #define CAR_TUNE_VALUE 89
108
109
110 /* HW Fuel gague */
111 #define CURRENT_DETECT_R_FG (-1) //turn off auto detect for auxadc gauge
112 #define MinErrorOffset 1000
113 #define FG_VBAT_AVERAGE_SIZE 18
114 #define R_FG_VALUE 20 // mOhm, base is 20
115
116 #define CUST_POWERON_DELTA_CAPACITY_TOLRANCE 60
117 #define CUST_POWERON_LOW_CAPACITY_TOLRANCE 5
118 #define CUST_POWERON_MAX_VBAT_TOLRANCE 70
119 #define CUST_POWERON_DELTA_VBAT_TOLRANCE 60
120
121 /* Disable Battery check for HQA */
122 #ifdef MTK_DISABLE_POWER_ON_OFF_VOLTAGE_LIMITATION
123 #define FIXED_TBAT_25
124 #endif
125
126 /* Dynamic change wake up period of battery thread when suspend*/
127 #define VBAT_NORMAL_WAKEUP 3600 //3.6V
128 #define VBAT_LOW_POWER_WAKEUP 3500 //3.5v
129 #define NORMAL_WAKEUP_PERIOD 5400 //90 * 60 = 90 min
130 #define LOW_POWER_WAKEUP_PERIOD 300 //5 * 60 = 5 min
131 #define CLOSE_POWEROFF_WAKEUP_PERIOD 30 //30 s
132
133 #endif //#ifndef _CUST_BATTERY_METER_H