0001
0002
0003 #ifndef _AB8500_CHARGER_H_
0004 #define _AB8500_CHARGER_H_
0005
0006 #include <linux/kernel.h>
0007
0008
0009
0010
0011
0012 #define AB8500_MAIN_WDOG_CTRL_REG 0x01
0013 #define AB8500_LOW_BAT_REG 0x03
0014 #define AB8500_BATT_OK_REG 0x04
0015
0016
0017
0018
0019 #define AB8500_USB_LINE_STAT_REG 0x80
0020 #define AB8500_USB_LINE_CTRL2_REG 0x82
0021 #define AB8500_USB_LINK1_STAT_REG 0x94
0022
0023
0024
0025
0026
0027 #define AB8500_CH_STATUS1_REG 0x00
0028 #define AB8500_CH_STATUS2_REG 0x01
0029 #define AB8500_CH_USBCH_STAT1_REG 0x02
0030 #define AB8500_CH_USBCH_STAT2_REG 0x03
0031 #define AB8540_CH_USBCH_STAT3_REG 0x04
0032 #define AB8500_CH_STAT_REG 0x05
0033
0034
0035
0036
0037
0038 #define AB8500_CH_VOLT_LVL_REG 0x40
0039 #define AB8500_CH_VOLT_LVL_MAX_REG 0x41
0040 #define AB8500_CH_OPT_CRNTLVL_REG 0x42
0041 #define AB8500_CH_OPT_CRNTLVL_MAX_REG 0x43
0042 #define AB8500_CH_WD_TIMER_REG 0x50
0043 #define AB8500_CHARG_WD_CTRL 0x51
0044 #define AB8500_BTEMP_HIGH_TH 0x52
0045 #define AB8500_LED_INDICATOR_PWM_CTRL 0x53
0046 #define AB8500_LED_INDICATOR_PWM_DUTY 0x54
0047 #define AB8500_BATT_OVV 0x55
0048 #define AB8500_CHARGER_CTRL 0x56
0049 #define AB8500_BAT_CTRL_CURRENT_SOURCE 0x60
0050
0051
0052
0053
0054
0055 #define AB8500_MCH_CTRL1 0x80
0056 #define AB8500_MCH_CTRL2 0x81
0057 #define AB8500_MCH_IPT_CURLVL_REG 0x82
0058 #define AB8500_CH_WD_REG 0x83
0059
0060
0061
0062
0063
0064 #define AB8500_USBCH_CTRL1_REG 0xC0
0065 #define AB8500_USBCH_CTRL2_REG 0xC1
0066 #define AB8500_USBCH_IPT_CRNTLVL_REG 0xC2
0067 #define AB8540_USB_PP_MODE_REG 0xC5
0068 #define AB8540_USB_PP_CHR_REG 0xC6
0069
0070
0071
0072
0073
0074 #define AB8500_GASG_CC_CTRL_REG 0x00
0075 #define AB8500_GASG_CC_ACCU1_REG 0x01
0076 #define AB8500_GASG_CC_ACCU2_REG 0x02
0077 #define AB8500_GASG_CC_ACCU3_REG 0x03
0078 #define AB8500_GASG_CC_ACCU4_REG 0x04
0079 #define AB8500_GASG_CC_SMPL_CNTRL_REG 0x05
0080 #define AB8500_GASG_CC_SMPL_CNTRH_REG 0x06
0081 #define AB8500_GASG_CC_SMPL_CNVL_REG 0x07
0082 #define AB8500_GASG_CC_SMPL_CNVH_REG 0x08
0083 #define AB8500_GASG_CC_CNTR_AVGOFF_REG 0x09
0084 #define AB8500_GASG_CC_OFFSET_REG 0x0A
0085 #define AB8500_GASG_CC_NCOV_ACCU 0x10
0086 #define AB8500_GASG_CC_NCOV_ACCU_CTRL 0x11
0087 #define AB8500_GASG_CC_NCOV_ACCU_LOW 0x12
0088 #define AB8500_GASG_CC_NCOV_ACCU_MED 0x13
0089 #define AB8500_GASG_CC_NCOV_ACCU_HIGH 0x14
0090
0091
0092
0093
0094
0095 #define AB8500_IT_SOURCE2_REG 0x01
0096 #define AB8500_IT_SOURCE21_REG 0x14
0097
0098
0099
0100
0101
0102 #define AB8500_RTC_BACKUP_CHG_REG 0x0C
0103 #define AB8500_RTC_CC_CONF_REG 0x01
0104 #define AB8500_RTC_CTRL_REG 0x0B
0105 #define AB8500_RTC_CTRL1_REG 0x11
0106
0107
0108
0109
0110
0111 #define AB8500_OTP_CONF_15 0x0E
0112
0113
0114 #define ADC_RESOLUTION 1024
0115 #define ADC_CH_MAIN_MIN 0
0116 #define ADC_CH_MAIN_MAX 20030
0117 #define ADC_CH_VBUS_MIN 0
0118 #define ADC_CH_VBUS_MAX 20030
0119 #define ADC_CH_VBAT_MIN 2300
0120 #define ADC_CH_VBAT_MAX 4800
0121 #define ADC_CH_BKBAT_MIN 0
0122 #define ADC_CH_BKBAT_MAX 3200
0123
0124
0125 #define MAIN_CH_IP_CUR_0P9A 0x80
0126 #define MAIN_CH_IP_CUR_1P0A 0x90
0127 #define MAIN_CH_IP_CUR_1P1A 0xA0
0128 #define MAIN_CH_IP_CUR_1P2A 0xB0
0129 #define MAIN_CH_IP_CUR_1P3A 0xC0
0130 #define MAIN_CH_IP_CUR_1P4A 0xD0
0131 #define MAIN_CH_IP_CUR_1P5A 0xE0
0132
0133
0134 #define CH_VOL_LVL_3P5 0x00
0135 #define CH_VOL_LVL_4P0 0x14
0136 #define CH_VOL_LVL_4P05 0x16
0137 #define CH_VOL_LVL_4P1 0x1B
0138 #define CH_VOL_LVL_4P15 0x20
0139 #define CH_VOL_LVL_4P2 0x25
0140 #define CH_VOL_LVL_4P6 0x4D
0141
0142
0143 #define CH_OP_CUR_LVL_0P1 0x00
0144 #define CH_OP_CUR_LVL_0P2 0x01
0145 #define CH_OP_CUR_LVL_0P3 0x02
0146 #define CH_OP_CUR_LVL_0P4 0x03
0147 #define CH_OP_CUR_LVL_0P5 0x04
0148 #define CH_OP_CUR_LVL_0P6 0x05
0149 #define CH_OP_CUR_LVL_0P7 0x06
0150 #define CH_OP_CUR_LVL_0P8 0x07
0151 #define CH_OP_CUR_LVL_0P9 0x08
0152 #define CH_OP_CUR_LVL_1P4 0x0D
0153 #define CH_OP_CUR_LVL_1P5 0x0E
0154 #define CH_OP_CUR_LVL_1P6 0x0F
0155 #define CH_OP_CUR_LVL_2P 0x3F
0156
0157
0158 #define BTEMP_HIGH_TH_57_0 0x00
0159 #define BTEMP_HIGH_TH_52 0x01
0160 #define BTEMP_HIGH_TH_57_1 0x02
0161 #define BTEMP_HIGH_TH_62 0x03
0162
0163 #define LOW_BAT_3P1V 0x20
0164 #define LOW_BAT_2P3V 0x00
0165 #define LOW_BAT_RESET 0x01
0166 #define LOW_BAT_ENABLE 0x01
0167
0168
0169 #define BUP_ICH_SEL_50UA 0x00
0170 #define BUP_ICH_SEL_150UA 0x04
0171 #define BUP_ICH_SEL_300UA 0x08
0172 #define BUP_ICH_SEL_700UA 0x0C
0173
0174 enum bup_vch_sel {
0175 BUP_VCH_SEL_2P5V,
0176 BUP_VCH_SEL_2P6V,
0177 BUP_VCH_SEL_2P8V,
0178 BUP_VCH_SEL_3P1V,
0179
0180
0181
0182
0183
0184 BUP_VCH_SEL_2P7V,
0185 BUP_VCH_SEL_2P9V,
0186 BUP_VCH_SEL_3P0V,
0187 BUP_VCH_SEL_3P2V,
0188 BUP_VCH_SEL_3P3V,
0189 };
0190
0191 #define BUP_VCH_RANGE 0x02
0192 #define VBUP33_VRTCN 0x01
0193
0194
0195 #define BATT_OVV_ENA 0x02
0196 #define BATT_OVV_TH_3P7 0x00
0197 #define BATT_OVV_TH_4P75 0x01
0198
0199
0200 #define BATT_OVV_VALUE 4750000
0201
0202
0203 #define VBUS_OVV_SELECT_MASK 0x78
0204 #define VBUS_OVV_SELECT_5P6V 0x00
0205 #define VBUS_OVV_SELECT_5P7V 0x08
0206 #define VBUS_OVV_SELECT_5P8V 0x10
0207 #define VBUS_OVV_SELECT_5P9V 0x18
0208 #define VBUS_OVV_SELECT_6P0V 0x20
0209 #define VBUS_OVV_SELECT_6P1V 0x28
0210 #define VBUS_OVV_SELECT_6P2V 0x30
0211 #define VBUS_OVV_SELECT_6P3V 0x38
0212
0213 #define VBUS_AUTO_IN_CURR_LIM_ENA 0x04
0214
0215
0216 #define RESET_ACCU 0x02
0217 #define READ_REQ 0x01
0218 #define CC_DEEP_SLEEP_ENA 0x02
0219 #define CC_PWR_UP_ENA 0x01
0220 #define CC_SAMPLES_40 0x28
0221 #define RD_NCONV_ACCU_REQ 0x01
0222 #define CC_CALIB 0x08
0223 #define CC_INTAVGOFFSET_ENA 0x10
0224 #define CC_MUXOFFSET 0x80
0225 #define CC_INT_CAL_N_AVG_MASK 0x60
0226 #define CC_INT_CAL_SAMPLES_16 0x40
0227 #define CC_INT_CAL_SAMPLES_8 0x20
0228 #define CC_INT_CAL_SAMPLES_4 0x00
0229
0230
0231 #define RTC_BUP_CH_ENA 0x10
0232
0233
0234 #define BAT_CTRL_7U_ENA 0x01
0235 #define BAT_CTRL_20U_ENA 0x02
0236 #define BAT_CTRL_18U_ENA 0x01
0237 #define BAT_CTRL_16U_ENA 0x02
0238 #define BAT_CTRL_CMP_ENA 0x04
0239 #define FORCE_BAT_CTRL_CMP_HIGH 0x08
0240 #define BAT_CTRL_PULL_UP_ENA 0x10
0241
0242
0243 #define BATTERY_UNKNOWN 00
0244
0245
0246 #define AB8505_RTC_PCUT_CTL_STATUS_REG 0x12
0247 #define AB8505_RTC_PCUT_TIME_REG 0x13
0248 #define AB8505_RTC_PCUT_MAX_TIME_REG 0x14
0249 #define AB8505_RTC_PCUT_FLAG_TIME_REG 0x15
0250 #define AB8505_RTC_PCUT_RESTART_REG 0x16
0251 #define AB8505_RTC_PCUT_DEBOUNCE_REG 0x17
0252
0253
0254 #define BUS_VSYS_VOL_SELECT_MASK 0x06
0255 #define BUS_VSYS_VOL_SELECT_3P6V 0x00
0256 #define BUS_VSYS_VOL_SELECT_3P325V 0x02
0257 #define BUS_VSYS_VOL_SELECT_3P9V 0x04
0258 #define BUS_VSYS_VOL_SELECT_4P3V 0x06
0259 #define BUS_POWER_PATH_MODE_ENA 0x01
0260 #define BUS_PP_PRECHG_CURRENT_MASK 0x0E
0261 #define BUS_POWER_PATH_PRECHG_ENA 0x01
0262
0263
0264 struct ab8500_fg;
0265
0266
0267
0268
0269
0270
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283
0284
0285
0286
0287
0288
0289
0290
0291
0292
0293
0294 struct ab8500_fg_parameters {
0295 int recovery_sleep_timer;
0296 int recovery_total_time;
0297 int init_timer;
0298 int init_discard_time;
0299 int init_total_time;
0300 int high_curr_time;
0301 int accu_charging;
0302 int accu_high_curr;
0303 int high_curr_threshold_ua;
0304 int lowbat_threshold_uv;
0305 int battok_falling_th_sel0;
0306 int battok_raising_th_sel1;
0307 int user_cap_limit;
0308 int maint_thres;
0309 bool pcut_enable;
0310 u8 pcut_max_time;
0311 u8 pcut_flag_time;
0312 u8 pcut_max_restart;
0313 u8 pcut_debounce_time;
0314 };
0315
0316
0317
0318
0319
0320
0321
0322
0323 struct ab8500_maxim_parameters {
0324 bool ena_maxi;
0325 int chg_curr_ua;
0326 int wait_cycles;
0327 int charger_curr_step_ua;
0328 };
0329
0330
0331
0332
0333
0334
0335
0336
0337
0338 struct ab8500_bm_capacity_levels {
0339 int critical;
0340 int low;
0341 int normal;
0342 int high;
0343 int full;
0344 };
0345
0346
0347
0348
0349
0350
0351
0352
0353 struct ab8500_bm_charger_parameters {
0354 int usb_volt_max_uv;
0355 int usb_curr_max_ua;
0356 int ac_volt_max_uv;
0357 int ac_curr_max_ua;
0358 };
0359
0360
0361
0362
0363
0364
0365
0366
0367
0368
0369
0370
0371
0372
0373
0374
0375
0376
0377
0378
0379
0380
0381
0382
0383 struct ab8500_bm_data {
0384 struct power_supply_battery_info *bi;
0385 int temp_now;
0386 int temp_interval_chg;
0387 int temp_interval_nochg;
0388 int main_safety_tmr_h;
0389 int usb_safety_tmr_h;
0390 int bkup_bat_v;
0391 int bkup_bat_i;
0392 bool capacity_scaling;
0393 bool chg_unknown_bat;
0394 bool enable_overshoot;
0395 bool auto_trig;
0396 int fg_res;
0397 int interval_charging;
0398 int interval_not_charging;
0399 int temp_hysteresis;
0400 const struct ab8500_maxim_parameters *maxi;
0401 const struct ab8500_bm_capacity_levels *cap_levels;
0402 const struct ab8500_bm_charger_parameters *chg_params;
0403 const struct ab8500_fg_parameters *fg_params;
0404 };
0405
0406
0407 struct ab8500_fg;
0408
0409 extern struct ab8500_bm_data ab8500_bm_data;
0410
0411 void ab8500_charger_usb_state_changed(u8 bm_usb_state, u16 mA);
0412 struct ab8500_fg *ab8500_fg_get(void);
0413 int ab8500_fg_inst_curr_blocking(struct ab8500_fg *dev);
0414 int ab8500_fg_inst_curr_start(struct ab8500_fg *di);
0415 int ab8500_fg_inst_curr_finalize(struct ab8500_fg *di, int *res);
0416 int ab8500_fg_inst_curr_started(struct ab8500_fg *di);
0417 int ab8500_fg_inst_curr_done(struct ab8500_fg *di);
0418 int ab8500_bm_of_probe(struct power_supply *psy,
0419 struct ab8500_bm_data *bm);
0420 void ab8500_bm_of_remove(struct power_supply *psy,
0421 struct ab8500_bm_data *bm);
0422
0423 extern struct platform_driver ab8500_fg_driver;
0424 extern struct platform_driver ab8500_btemp_driver;
0425 extern struct platform_driver ab8500_chargalg_driver;
0426
0427 #endif