ec8c4fa8ec595458e458e3390a4067efa6d2ce83
[firefly-linux-kernel-4.4.55.git] / include / linux / power / ricoh619_battery.h
1 /*
2  * include/linux/power/ricoh619_battery.h
3  *
4  * RICOH RC5T619 Charger Driver
5  * 
6  * Copyright (C) 2012-2013 RICOH COMPANY,LTD
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
16  * more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 #ifndef __LINUX_POWER_RICOH619_H_
23 #define __LINUX_POWER_RICOH619_H_
24
25 /* #include <linux/power_supply.h> */
26 /* #include <linux/types.h> */
27
28 #if 0
29 #define RICOH_FG_DBG(fmt, args...) printk( "RICOH_FG_DBG:\t"fmt, ##args)
30 #else
31 #define RICOH_FG_DBG(fmt, args...) {while(0);}
32 #endif
33
34 /* Defined battery information */
35 #define ADC_VDD_MV      2800
36 #define MIN_VOLTAGE     3100
37 #define MAX_VOLTAGE     4200
38 #define B_VALUE         3435
39
40 /* 619 Register information */
41 /* bank 0 */
42 #define PSWR_REG                0x07
43 #define VINDAC_REG              0x03
44 /* for ADC */
45 #define INTEN_REG               0x9D
46 #define EN_ADCIR3_REG           0x8A
47 #define ADCCNT3_REG             0x66
48 #define VBATDATAH_REG           0x6A
49 #define VBATDATAL_REG           0x6B
50 #define VSYSDATAH_REG           0x70
51 #define VSYSDATAL_REG           0x71
52
53 #define CHGCTL1_REG             0xB3
54 #define REGISET1_REG            0xB6
55 #define REGISET2_REG            0xB7
56 #define CHGISET_REG             0xB8
57 #define TIMSET_REG              0xB9
58 #define BATSET1_REG             0xBA
59 #define BATSET2_REG             0xBB
60
61 #define CHGSTATE_REG            0xBD
62
63 #define FG_CTRL_REG             0xE0
64 #define SOC_REG                 0xE1
65 #define RE_CAP_H_REG            0xE2
66 #define RE_CAP_L_REG            0xE3
67 #define FA_CAP_H_REG            0xE4
68 #define FA_CAP_L_REG            0xE5
69 #define TT_EMPTY_H_REG          0xE7
70 #define TT_EMPTY_L_REG          0xE8
71 #define TT_FULL_H_REG           0xE9
72 #define TT_FULL_L_REG           0xEA
73 #define VOLTAGE_1_REG           0xEB
74 #define VOLTAGE_2_REG           0xEC
75 #define TEMP_1_REG              0xED
76 #define TEMP_2_REG              0xEE
77
78 #define CC_CTRL_REG             0xEF
79 #define CC_SUMREG3_REG          0xF3
80 #define CC_SUMREG2_REG          0xF4
81 #define CC_SUMREG1_REG          0xF5
82 #define CC_SUMREG0_REG          0xF6
83 #define CC_AVERAGE1_REG         0xFB
84 #define CC_AVERAGE0_REG         0xFC
85
86 /* bank 1 */
87 /* Top address for battery initial setting */
88 #define BAT_INIT_TOP_REG        0xBC
89 #define TEMP_GAIN_H_REG         0xD6
90 #define TEMP_OFF_H_REG          0xD8
91 #define BAT_REL_SEL_REG         0xDA
92 #define BAT_TA_SEL_REG          0xDB
93 /**************************/
94
95 /* detailed status in CHGSTATE (0xBD) */
96 enum ChargeState {
97         CHG_STATE_CHG_OFF = 0,
98         CHG_STATE_CHG_READY_VADP,
99         CHG_STATE_CHG_TRICKLE,
100         CHG_STATE_CHG_RAPID,
101         CHG_STATE_CHG_COMPLETE,
102         CHG_STATE_SUSPEND,
103         CHG_STATE_VCHG_OVER_VOL,
104         CHG_STATE_BAT_ERROR,
105         CHG_STATE_NO_BAT,
106         CHG_STATE_BAT_OVER_VOL,
107         CHG_STATE_BAT_TEMP_ERR,
108         CHG_STATE_DIE_ERR,
109         CHG_STATE_DIE_SHUTDOWN,
110         CHG_STATE_NO_BAT2,
111         CHG_STATE_CHG_READY_VUSB,
112 };
113
114 enum SupplyState {
115         SUPPLY_STATE_BAT = 0,
116         SUPPLY_STATE_ADP,
117         SUPPLY_STATE_USB,
118 } ;
119
120 struct ricoh619_battery_type_data {
121         int     ch_vfchg;
122         int     ch_vrchg;
123         int     ch_vbatovset;
124         int     ch_ichg;
125         int     ch_icchg;
126         int     ch_ilim_adp;
127         int     ch_ilim_usb;
128         int     fg_target_vsys;
129         int     fg_target_ibat;
130         int     fg_poff_vbat;
131         int     jt_en;
132         int     jt_hw_sw;
133         int     jt_temp_h;
134         int     jt_temp_l;
135         int     jt_vfchg_h;
136         int     jt_vfchg_l;
137         int     jt_ichg_h;
138         int     jt_ichg_l;
139 };
140
141 #define BATTERY_TYPE_NUM 1
142 struct ricoh619_battery_platform_data {
143         int     irq;
144         int     alarm_vol_mv;
145         int     multiple;
146         unsigned long   monitor_time;
147         struct ricoh619_battery_type_data type[BATTERY_TYPE_NUM];
148 };
149
150 extern struct ricoh619 *g_ricoh619;
151
152
153 #endif