• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _AXP803_H_
2 #define _AXP803_H_
3 
4 #include "linux/types.h"
5 
6 /* reg AXP803_STATUS */
7 #define AXP803_STATUS_AC_PRESENT	BIT(7)
8 #define AXP803_STATUS_AC_USED		BIT(6)
9 #define AXP803_STATUS_VBUS_PRESENT	BIT(5)
10 #define AXP803_STATUS_VBUS_USED		BIT(4)
11 #define AXP803_STATUS_BAT_CUR_DIRCT	BIT(2)
12 
13 /* reg AXP803_MODE_CHGSTATUS */
14 #define AXP803_CHGSTATUS_BAT_CHARGING	BIT(6)
15 #define AXP803_CHGSTATUS_BAT_PRESENT	BIT(5)
16 #define AXP803_CHGSTATUS_BAT_PST_VALID	BIT(4)
17 
18 /* reg AXP803_MODE_CHGSTATUS */
19 #define AXP803_FAULT_LOG_COLD		BIT(0)
20 #define AXP803_FAULT_LOG_CHA_CUR_LOW	BIT(2)
21 #define AXP803_FAULT_LOG_BATINACT	BIT(3)
22 #define AXP803_FAULT_LOG_OVER_TEMP	BIT(7)
23 
24 /* AXP803_ADC_EN */
25 #define AXP803_ADC_BATVOL_ENABLE	BIT(7)
26 #define AXP803_ADC_BATCUR_ENABLE	BIT(6)
27 #define AXP803_ADC_TSVOL_ENABLE		BIT(0)
28 
29 #define AXP803_CHRG_CTRL1_TGT_VOLT	GENMASK(6, 5)
30 #define AXP803_CHRG_CTRL1_TGT_4_1V	(0 << 5)
31 #define AXP803_CHRG_CTRL1_TGT_4_15V	(1 << 5)
32 #define AXP803_CHRG_CTRL1_TGT_4_2V	(2 << 5)
33 #define AXP803_CHRG_CTRL1_TGT_4_35V	(3 << 5)
34 
35 #define AXP803_V_OFF_MASK		GENMASK(2, 0)
36 
37 struct axp_config_info {
38 	u32 pmu_used;
39 	u32 pmu_id;
40 	u32 pmu_battery_rdc;
41 	u32 pmu_battery_cap;
42 	u32 pmu_batdeten;
43 	u32 pmu_chg_ic_temp;
44 	u32 pmu_runtime_chgcur;
45 	u32 pmu_suspend_chgcur;
46 	u32 pmu_shutdown_chgcur;
47 	u32 pmu_init_chgvol;
48 	u32 pmu_init_chgend_rate;
49 	u32 pmu_init_chg_enabled;
50 	u32 pmu_init_bc_en;
51 	u32 pmu_init_adc_freq;
52 	u32 pmu_init_adcts_freq;
53 	u32 pmu_init_chg_pretime;
54 	u32 pmu_init_chg_csttime;
55 	u32 pmu_batt_cap_correct;
56 	u32 pmu_chg_end_on_en;
57 	u32 ocv_coulumb_100;
58 
59 	u32 pmu_bat_para1;
60 	u32 pmu_bat_para2;
61 	u32 pmu_bat_para3;
62 	u32 pmu_bat_para4;
63 	u32 pmu_bat_para5;
64 	u32 pmu_bat_para6;
65 	u32 pmu_bat_para7;
66 	u32 pmu_bat_para8;
67 	u32 pmu_bat_para9;
68 	u32 pmu_bat_para10;
69 	u32 pmu_bat_para11;
70 	u32 pmu_bat_para12;
71 	u32 pmu_bat_para13;
72 	u32 pmu_bat_para14;
73 	u32 pmu_bat_para15;
74 	u32 pmu_bat_para16;
75 	u32 pmu_bat_para17;
76 	u32 pmu_bat_para18;
77 	u32 pmu_bat_para19;
78 	u32 pmu_bat_para20;
79 	u32 pmu_bat_para21;
80 	u32 pmu_bat_para22;
81 	u32 pmu_bat_para23;
82 	u32 pmu_bat_para24;
83 	u32 pmu_bat_para25;
84 	u32 pmu_bat_para26;
85 	u32 pmu_bat_para27;
86 	u32 pmu_bat_para28;
87 	u32 pmu_bat_para29;
88 	u32 pmu_bat_para30;
89 	u32 pmu_bat_para31;
90 	u32 pmu_bat_para32;
91 
92 	u32 pmu_ac_vol;
93 	u32 pmu_ac_cur;
94 	u32 pmu_usbpc_vol;
95 	u32 pmu_usbpc_cur;
96 	u32 pmu_usbad_vol;
97 	u32 pmu_usbad_cur;
98 	u32 pmu_pwroff_vol;
99 	u32 pmu_pwron_vol;
100 	u32 pmu_powkey_off_time;
101 	u32 pmu_powkey_off_en;
102 	u32 pmu_powkey_off_delay_time;
103 	u32 pmu_powkey_off_func;
104 	u32 pmu_powkey_long_time;
105 	u32 pmu_powkey_on_time;
106 	u32 pmu_powkey_wakeup_irq;
107 	u32 pmu_pwrok_time;
108 	u32 pmu_pwrnoe_time;
109 	u32 pmu_reset_shutdown_en;
110 	u32 pmu_battery_warning_level1;
111 	u32 pmu_battery_warning_level2;
112 	u32 pmu_restvol_adjust_time;
113 	u32 pmu_ocv_cou_adjust_time;
114 	u32 pmu_chgled_func;
115 	u32 pmu_chgled_type;
116 	u32 pmu_vbusen_func;
117 	u32 pmu_reset;
118 	u32 pmu_irq_wakeup;
119 	u32 pmu_hot_shutdown;
120 	u32 pmu_inshort;
121 	u32 power_start;
122 	u32 pmu_as_slave;
123 	u32 pmu_bat_unused;
124 	u32 pmu_ocv_en;
125 	u32 pmu_cou_en;
126 	u32 pmu_update_min_time;
127 
128 	u32 pmu_bat_temp_enable;
129 	u32 pmu_bat_charge_ltf;
130 	u32 pmu_bat_charge_htf;
131 	u32 pmu_bat_shutdown_ltf;
132 	u32 pmu_bat_shutdown_htf;
133 	u32 pmu_bat_temp_para1;
134 	u32 pmu_bat_temp_para2;
135 	u32 pmu_bat_temp_para3;
136 	u32 pmu_bat_temp_para4;
137 	u32 pmu_bat_temp_para5;
138 	u32 pmu_bat_temp_para6;
139 	u32 pmu_bat_temp_para7;
140 	u32 pmu_bat_temp_para8;
141 	u32 pmu_bat_temp_para9;
142 	u32 pmu_bat_temp_para10;
143 	u32 pmu_bat_temp_para11;
144 	u32 pmu_bat_temp_para12;
145 	u32 pmu_bat_temp_para13;
146 	u32 pmu_bat_temp_para14;
147 	u32 pmu_bat_temp_para15;
148 	u32 pmu_bat_temp_para16;
149 
150 	u32 wakeup_usb_in;
151 	u32 wakeup_usb_out;
152 	u32 wakeup_ac_in;
153 	u32 wakeup_ac_out;
154 	u32 wakeup_bat_in;
155 	u32 wakeup_bat_out;
156 	u32 wakeup_bat_charging;
157 	u32 wakeup_bat_charge_over;
158 	u32 wakeup_low_warning1;
159 	u32 wakeup_low_warning2;
160 	u32 wakeup_bat_untemp_work;
161 	u32 wakeup_bat_ovtemp_work;
162 	u32 wakeup_untemp_chg;
163 	u32 wakeup_ovtemp_chg;
164 };
165 
166 struct axp803_charger_ps {
167 	char                      *name;
168 	struct device             *dev;
169 	struct axp_config_info     dts_info;
170 	struct regmap             *regmap;
171 	struct power_supply       *bat;
172 	struct power_supply       *usb;
173 	struct power_supply       *ac;
174 	struct delayed_work        charger_mon;
175 };
176 
177 #define BATRDC          100
178 #define INTCHGCUR       300000      /* set initial charging current limite */
179 #define SUSCHGCUR       1000000     /* set suspend charging current limite */
180 #define RESCHGCUR       INTCHGCUR   /* set resume charging current limite */
181 #define CLSCHGCUR       SUSCHGCUR   /* set shutdown charging current limite */
182 #define INTCHGVOL       4200000     /* set initial charing target voltage */
183 #define INTCHGENDRATE   10          /* set initial charing end current rate */
184 #define INTCHGENABLED   1           /* set initial charing enabled */
185 #define INTADCFREQ      25          /* set initial adc frequency */
186 #define INTADCFREQC     100         /* set initial coulomb adc coufrequency */
187 #define INTCHGPRETIME   50          /* set initial pre-charging time */
188 #define INTCHGCSTTIME   480         /* set initial pre-charging time */
189 #define BATMAXVOL       4200000     /* set battery max design volatge */
190 #define BATMINVOL       3500000     /* set battery min design volatge */
191 #define UPDATEMINTIME   30          /* set bat percent update min time */
192 
193 #define OCVREG0         0x00        /* 2.99V */
194 #define OCVREG1         0x00        /* 3.13V */
195 #define OCVREG2         0x00        /* 3.27V */
196 #define OCVREG3         0x00        /* 3.34V */
197 #define OCVREG4         0x00        /* 3.41V */
198 #define OCVREG5         0x00        /* 3.48V */
199 #define OCVREG6         0x00        /* 3.52V */
200 #define OCVREG7         0x00        /* 3.55V */
201 #define OCVREG8         0x04        /* 3.57V */
202 #define OCVREG9         0x05        /* 3.59V */
203 #define OCVREGA         0x06        /* 3.61V */
204 #define OCVREGB         0x07        /* 3.63V */
205 #define OCVREGC         0x0a        /* 3.64V */
206 #define OCVREGD         0x0d        /* 3.66V */
207 #define OCVREGE         0x1a        /* 3.70V */
208 #define OCVREGF         0x24        /* 3.73V */
209 #define OCVREG10        0x29        /* 3.77V */
210 #define OCVREG11        0x2e        /* 3.78V */
211 #define OCVREG12        0x32        /* 3.80V */
212 #define OCVREG13        0x35        /* 3.84V */
213 #define OCVREG14        0x39        /* 3.85V */
214 #define OCVREG15        0x3d        /* 3.87V */
215 #define OCVREG16        0x43        /* 3.91V */
216 #define OCVREG17        0x49        /* 3.94V */
217 #define OCVREG18        0x4f        /* 3.98V */
218 #define OCVREG19        0x54        /* 4.01V */
219 #define OCVREG1A        0x58        /* 4.05V */
220 #define OCVREG1B        0x5c        /* 4.08V */
221 #define OCVREG1C        0x5e        /* 4.10V */
222 #define OCVREG1D        0x60        /* 4.12V */
223 #define OCVREG1E        0x62        /* 4.14V */
224 #define OCVREG1F        0x64        /* 4.15V */
225 
226 #define AXP_OF_PROP_READ(name, def_value)\
227 do {\
228 	if (of_property_read_u32(node, #name, &axp_config->name))\
229 		axp_config->name = def_value;\
230 } while (0)
231 
232 struct axp_interrupts {
233 	char *name;
234 	irq_handler_t isr;
235 	int irq;
236 };
237 
238 #endif
239