aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/battery
diff options
context:
space:
mode:
authorcodeworkx <daniel.hillenbrand@codeworkx.de>2012-06-02 13:09:29 +0200
committercodeworkx <daniel.hillenbrand@codeworkx.de>2012-06-02 13:09:29 +0200
commitc6da2cfeb05178a11c6d062a06f8078150ee492f (patch)
treef3b4021d252c52d6463a9b3c1bb7245e399b009c /include/linux/battery
parentc6d7c4dbff353eac7919342ae6b3299a378160a6 (diff)
downloadkernel_samsung_smdk4412-c6da2cfeb05178a11c6d062a06f8078150ee492f.zip
kernel_samsung_smdk4412-c6da2cfeb05178a11c6d062a06f8078150ee492f.tar.gz
kernel_samsung_smdk4412-c6da2cfeb05178a11c6d062a06f8078150ee492f.tar.bz2
samsung update 1
Diffstat (limited to 'include/linux/battery')
-rw-r--r--include/linux/battery/charger/bq24190_charger.h60
-rw-r--r--include/linux/battery/charger/dummy_charger.h27
-rw-r--r--include/linux/battery/charger/max8903_charger.h27
-rw-r--r--include/linux/battery/charger/smb328_charger.h51
-rw-r--r--include/linux/battery/fuelgauge/dummy_fuelgauge.h30
-rw-r--r--include/linux/battery/fuelgauge/max17042_fuelgauge.h382
-rw-r--r--include/linux/battery/fuelgauge/max17048_fuelgauge.h53
-rw-r--r--include/linux/battery/fuelgauge/max17050_fuelgauge.h169
-rw-r--r--include/linux/battery/max17047_fuelgauge.h33
-rw-r--r--include/linux/battery/samsung_battery.h345
-rw-r--r--include/linux/battery/sec_battery.h255
-rw-r--r--include/linux/battery/sec_charger.h106
-rw-r--r--include/linux/battery/sec_charging_common.h503
-rw-r--r--include/linux/battery/sec_fuelgauge.h127
14 files changed, 2168 insertions, 0 deletions
diff --git a/include/linux/battery/charger/bq24190_charger.h b/include/linux/battery/charger/bq24190_charger.h
new file mode 100644
index 0000000..9302981
--- /dev/null
+++ b/include/linux/battery/charger/bq24190_charger.h
@@ -0,0 +1,60 @@
+/*
+ * bq24190_charger.h
+ * Samsung SMB328 Charger Header
+ *
+ * Copyright (C) 2012 Samsung Electronics, Inc.
+ *
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef __BQ24190_CHARGER_H
+#define __BQ24190_CHARGER_H __FILE__
+
+/* Slave address should be shifted to the right 1bit.
+ * R/W bit should NOT be included.
+ */
+#if defined(CONFIG_CHARGER_BQ24191)
+#define SEC_CHARGER_I2C_SLAVEADDR 0x6a
+#else
+/* bq24190, bq24192 */
+#define SEC_CHARGER_I2C_SLAVEADDR 0x6b
+#endif
+
+#define BQ24190_CHARGING_ENABLE 0x20
+#define BQ24190_CHARGING_DONE 0x30
+
+/* BQ2419x Registers */
+
+/* Input Source Control */
+#define BQ24190_REG_INSRC 0x00
+/* Power-On Configuration */
+#define BQ24190_REG_PWRON_CFG 0x01
+/* Charge Current Control */
+#define BQ24190_REG_CHRG_C 0x02
+/* Pre-charge/Termination Current Control */
+#define BQ24190_REG_PCHRG_TRM_C 0x03
+/* Charge Voltage Control */
+#define BQ24190_REG_CHRG_V 0x04
+/* Charge Termination/Timer Control */
+#define BQ24190_REG_CHRG_TRM_TMR 0x05
+/* IR Compensation / Thermal Regulation Control */
+#define BQ24190_REG_IRCMP_TREG 0x06
+/* Misc Operation Control */
+#define BQ24190_REG_MISC_OP 0x07
+/* System Status */
+#define BQ24190_REG_STATUS 0x08
+/* Fault */
+#define BQ24190_REG_FAULT 0x09
+/* Vendor / Part / Revision Status */
+#define BQ24190_REG_DEVID 0x0A
+
+#endif /* __BQ24190_CHARGER_H */
diff --git a/include/linux/battery/charger/dummy_charger.h b/include/linux/battery/charger/dummy_charger.h
new file mode 100644
index 0000000..66100b7
--- /dev/null
+++ b/include/linux/battery/charger/dummy_charger.h
@@ -0,0 +1,27 @@
+/*
+ * dummy_charger.h
+ * Samsung dummy Charger Header
+ *
+ * Copyright (C) 2012 Samsung Electronics, Inc.
+ *
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef __DUMMY_CHARGER_H
+#define __DUMMY_CHARGER_H __FILE__
+
+/* Slave address should be shifted to the right 1bit.
+ * R/W bit should NOT be included.
+ */
+#define SEC_CHARGER_I2C_SLAVEADDR 0x00
+
+#endif /* __DUMMY_CHARGER_H */
diff --git a/include/linux/battery/charger/max8903_charger.h b/include/linux/battery/charger/max8903_charger.h
new file mode 100644
index 0000000..2f42343
--- /dev/null
+++ b/include/linux/battery/charger/max8903_charger.h
@@ -0,0 +1,27 @@
+/*
+ * max8903_charger.h
+ * Samsung MAX8903 Charger Header
+ *
+ * Copyright (C) 2012 Samsung Electronics, Inc.
+ *
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef __MAX8903_CHARGER_H
+#define __MAX8903_CHARGER_H __FILE__
+
+/* Slave address should be shifted to the right 1bit.
+ * R/W bit should NOT be included.
+ */
+#define SEC_CHARGER_I2C_SLAVEADDR 0x00
+
+#endif /* __MAX8903_CHARGER_H */
diff --git a/include/linux/battery/charger/smb328_charger.h b/include/linux/battery/charger/smb328_charger.h
new file mode 100644
index 0000000..26f3d01
--- /dev/null
+++ b/include/linux/battery/charger/smb328_charger.h
@@ -0,0 +1,51 @@
+/*
+ * smb328_charger.h
+ * Samsung SMB328 Charger Header
+ *
+ * Copyright (C) 2012 Samsung Electronics, Inc.
+ *
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef __SMB328_CHARGER_H
+#define __SMB328_CHARGER_H __FILE__
+
+/* Slave address should be shifted to the right 1bit.
+ * R/W bit should NOT be included.
+ */
+#define SEC_CHARGER_I2C_SLAVEADDR (0x69>>1)
+
+/* Register define */
+#define SMB328A_INPUT_AND_CHARGE_CURRENTS 0x00
+#define SMB328A_CURRENT_TERMINATION 0x01
+#define SMB328A_FLOAT_VOLTAGE 0x02
+#define SMB328A_FUNCTION_CONTROL_A1 0x03
+#define SMB328A_FUNCTION_CONTROL_A2 0x04
+#define SMB328A_FUNCTION_CONTROL_B 0x05
+#define SMB328A_OTG_PWR_AND_LDO_CONTROL 0x06
+#define SMB328A_VARIOUS_CONTROL_FUNCTION_A 0x07
+#define SMB328A_CELL_TEMPERATURE_MONITOR 0x08
+#define SMB328A_INTERRUPT_SIGNAL_SELECTION 0x09
+#define SMB328A_I2C_BUS_SLAVE_ADDRESS 0x0A
+
+#define SMB328A_CLEAR_IRQ 0x30
+#define SMB328A_COMMAND 0x31
+#define SMB328A_INTERRUPT_STATUS_A 0x32
+#define SMB328A_BATTERY_CHARGING_STATUS_A 0x33
+#define SMB328A_INTERRUPT_STATUS_B 0x34
+#define SMB328A_BATTERY_CHARGING_STATUS_B 0x35
+#define SMB328A_BATTERY_CHARGING_STATUS_C 0x36
+#define SMB328A_INTERRUPT_STATUS_C 0x37
+#define SMB328A_BATTERY_CHARGING_STATUS_D 0x38
+#define SMB328A_AUTOMATIC_INPUT_CURRENT_LIMMIT_STATUS 0x39
+
+#endif /* __SMB328_CHARGER_H */
diff --git a/include/linux/battery/fuelgauge/dummy_fuelgauge.h b/include/linux/battery/fuelgauge/dummy_fuelgauge.h
new file mode 100644
index 0000000..14c466c
--- /dev/null
+++ b/include/linux/battery/fuelgauge/dummy_fuelgauge.h
@@ -0,0 +1,30 @@
+/*
+ * dummy_fuelgauge.h
+ * Samsung Dummy Fuel Gauge Header
+ *
+ * Copyright (C) 2012 Samsung Electronics, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef __DUMMY_FUELGAUGE_H
+#define __DUMMY_FUELGAUGE_H __FILE__
+
+/* Slave address should be shifted to the right 1bit.
+ * R/W bit should NOT be included.
+ */
+#define SEC_FUELGAUGE_I2C_SLAVEADDR 0x00
+
+struct sec_fg_info {
+ bool dummy;
+};
+
+#endif /* __DUMMY_FUELGAUGE_H */
diff --git a/include/linux/battery/fuelgauge/max17042_fuelgauge.h b/include/linux/battery/fuelgauge/max17042_fuelgauge.h
new file mode 100644
index 0000000..5513523
--- /dev/null
+++ b/include/linux/battery/fuelgauge/max17042_fuelgauge.h
@@ -0,0 +1,382 @@
+/*
+ * max17042_fuelgauge.h
+ * Samsung MAX17042 Fuel Gauge Header
+ *
+ * Copyright (C) 2012 Samsung Electronics, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef __MAX17042_FUELGAUGE_H
+#define __MAX17042_FUELGAUGE_H __FILE__
+
+/* Slave address should be shifted to the right 1bit.
+ * R/W bit should NOT be included.
+ */
+#define SEC_FUELGAUGE_I2C_SLAVEADDR 0x36
+
+#if defined(CONFIG_FUELGAUGE_MAX17042_VOLTAGE_TRACKING)
+#define MAX17042_REG_STATUS 0x00
+#define MAX17042_REG_VALRT_TH 0x01
+#define MAX17042_REG_TALRT_TH 0x02
+#define MAX17042_REG_SALRT_TH 0x03
+#define MAX17042_REG_VCELL 0x09
+#define MAX17042_REG_TEMPERATURE 0x08
+#define MAX17042_REG_AVGVCELL 0x19
+#define MAX17042_REG_CONFIG 0x1D
+#define MAX17042_REG_VERSION 0x21
+#define MAX17042_REG_LEARNCFG 0x28
+#define MAX17042_REG_FILTERCFG 0x29
+#define MAX17042_REG_MISCCFG 0x2B
+#define MAX17042_REG_CGAIN 0x2E
+#define MAX17042_REG_RCOMP 0x38
+#define MAX17042_REG_VFOCV 0xFB
+#define MAX17042_REG_SOC_VF 0xFF
+
+struct sec_fg_info {
+ bool dummy;
+};
+
+#endif
+
+#if defined(CONFIG_FUELGAUGE_MAX17042_COULOMB_COUNTING)
+#define PRINT_COUNT 10
+
+/* Register address */
+#define STATUS_REG 0x00
+#define VALRT_THRESHOLD_REG 0x01
+#define TALRT_THRESHOLD_REG 0x02
+#define SALRT_THRESHOLD_REG 0x03
+#define REMCAP_REP_REG 0x05
+#define SOCREP_REG 0x06
+#define TEMPERATURE_REG 0x08
+#define VCELL_REG 0x09
+#define CURRENT_REG 0x0A
+#define AVG_CURRENT_REG 0x0B
+#define SOCMIX_REG 0x0D
+#define SOCAV_REG 0x0E
+#define REMCAP_MIX_REG 0x0F
+#define FULLCAP_REG 0x10
+#define RFAST_REG 0x15
+#define AVR_TEMPERATURE_REG 0x16
+#define CYCLES_REG 0x17
+#define DESIGNCAP_REG 0x18
+#define AVR_VCELL_REG 0x19
+#define CONFIG_REG 0x1D
+#define REMCAP_AV_REG 0x1F
+#define FULLCAP_NOM_REG 0x23
+#define MISCCFG_REG 0x2B
+#define RCOMP_REG 0x38
+#define FSTAT_REG 0x3D
+#define DQACC_REG 0x45
+#define DPACC_REG 0x46
+#define OCV_REG 0xEE
+#define VFOCV_REG 0xFB
+#define VFSOC_REG 0xFF
+
+#define FG_LEVEL 0
+#define FG_TEMPERATURE 1
+#define FG_VOLTAGE 2
+#define FG_CURRENT 3
+#define FG_CURRENT_AVG 4
+#define FG_BATTERY_TYPE 5
+#define FG_CHECK_STATUS 6
+#define FG_VF_SOC 7
+
+#define LOW_BATT_COMP_RANGE_NUM 5
+#define LOW_BATT_COMP_LEVEL_NUM 2
+#define MAX_LOW_BATT_CHECK_CNT 10
+
+enum {
+ POSITIVE = 0,
+ NEGATIVE,
+};
+
+enum {
+ UNKNOWN_TYPE = 0,
+ SDI_BATTERY_TYPE,
+ ATL_BATTERY_TYPE,
+};
+
+struct max17042_platform_data {
+ int sdi_capacity;
+ int sdi_vfcapacity;
+ int sdi_low_bat_comp_start_vol;
+ int atl_capacity;
+ int atl_vfcapacity;
+ int atl_low_bat_comp_start_vol;
+};
+
+struct sec_fg_info {
+ /* test print count */
+ int pr_cnt;
+ /* battery type */
+ int battery_type;
+ /* capacity and vfcapacity */
+ u16 capacity;
+ u16 vfcapacity;
+ int soc_restart_flag;
+ /* full charge comp */
+ struct delayed_work full_comp_work;
+ u32 previous_fullcap;
+ u32 previous_vffullcap;
+ u32 full_charged_cap;
+ /* cap corruption check */
+ u32 previous_repsoc;
+ u32 previous_vfsoc;
+ u32 previous_remcap;
+ u32 previous_mixcap;
+ u32 previous_fullcapacity;
+ u32 previous_vfcapacity;
+ u32 previous_vfocv;
+ /* low battery comp */
+ int low_batt_comp_cnt[LOW_BATT_COMP_RANGE_NUM][LOW_BATT_COMP_LEVEL_NUM];
+ int low_batt_comp_flag;
+ int check_start_vol;
+ /* low battery boot */
+ int low_batt_boot_flag;
+
+ /* battery info */
+ u32 soc;
+
+ /* miscellaneous */
+ int fg_chk_cnt;
+ int fg_skip;
+ int fg_skip_cnt;
+ int full_check_flag;
+ bool is_first_check;
+};
+
+/* Battery parameter */
+#define sdi_capacity 0x3730
+#define sdi_vfcapacity 0x4996
+#define sdi_low_bat_comp_start_vol 3600
+#define atl_capacity 0x3022
+#define atl_vfcapacity 0x4024
+#define atl_low_bat_comp_start_vol 3450
+
+/* Current range for P2(not dependent on battery type */
+#if defined(CONFIG_MACH_P2_REV00) || defined(CONFIG_MACH_P2_REV01) || \
+ defined(CONFIG_MACH_P2_REV02)
+#define CURRENT_RANGE1 0
+#define CURRENT_RANGE2 -100
+#define CURRENT_RANGE3 -750
+#define CURRENT_RANGE4 -1250
+#define CURRENT_RANGE_MAX CURRENT_RANGE4
+#define CURRENT_RANGE_MAX_NUM 4
+/* SDI type low battery compensation offset */
+#define SDI_Range4_1_Offset 3320
+#define SDI_Range4_3_Offset 3410
+#define SDI_Range3_1_Offset 3451
+#define SDI_Range3_3_Offset 3454
+#define SDI_Range2_1_Offset 3461
+#define SDI_Range2_3_Offset 3544
+#define SDI_Range1_1_Offset 3456
+#define SDI_Range1_3_Offset 3536
+#define SDI_Range4_1_Slope 0
+#define SDI_Range4_3_Slope 0
+#define SDI_Range3_1_Slope 97
+#define SDI_Range3_3_Slope 27
+#define SDI_Range2_1_Slope 96
+#define SDI_Range2_3_Slope 134
+#define SDI_Range1_1_Slope 0
+#define SDI_Range1_3_Slope 0
+/* ATL type low battery compensation offset */
+#define ATL_Range5_1_Offset 3277
+#define ATL_Range5_3_Offset 3293
+#define ATL_Range4_1_Offset 3312
+#define ATL_Range4_3_Offset 3305
+#define ATL_Range3_1_Offset 3310
+#define ATL_Range3_3_Offset 3333
+#define ATL_Range2_1_Offset 3335
+#define ATL_Range2_3_Offset 3356
+#define ATL_Range1_1_Offset 3325
+#define ATL_Range1_3_Offset 3342
+#define ATL_Range5_1_Slope 0
+#define ATL_Range5_3_Slope 0
+#define ATL_Range4_1_Slope 30
+#define ATL_Range4_3_Slope 667
+#define ATL_Range3_1_Slope 20
+#define ATL_Range3_3_Slope 40
+#define ATL_Range2_1_Slope 60
+#define ATL_Range2_3_Slope 76
+#define ATL_Range1_1_Slope 0
+#define ATL_Range1_3_Slope 0
+#elif defined(CONFIG_MACH_P4W_REV00) || defined(CONFIG_MACH_P4W_REV01) || \
+ defined(CONFIG_MACH_P11) /* P4W battery parameter */
+/* Current range for P4W(not dependent on battery type */
+#define CURRENT_RANGE1 0
+#define CURRENT_RANGE2 -200
+#define CURRENT_RANGE3 -600
+#define CURRENT_RANGE4 -1500
+#define CURRENT_RANGE5 -2500
+#define CURRENT_RANGE_MAX CURRENT_RANGE5
+#define CURRENT_RANGE_MAX_NUM 5
+/* SDI type low battery compensation offset */
+#define SDI_Range5_1_Offset 3318
+#define SDI_Range5_3_Offset 3383
+#define SDI_Range4_1_Offset 3451
+#define SDI_Range4_3_Offset 3618
+#define SDI_Range3_1_Offset 3453
+#define SDI_Range3_3_Offset 3615
+#define SDI_Range2_1_Offset 3447
+#define SDI_Range2_3_Offset 3606
+#define SDI_Range1_1_Offset 3438
+#define SDI_Range1_3_Offset 3591
+#define SDI_Range5_1_Slope 0
+#define SDI_Range5_3_Slope 0
+#define SDI_Range4_1_Slope 53
+#define SDI_Range4_3_Slope 94
+#define SDI_Range3_1_Slope 54
+#define SDI_Range3_3_Slope 92
+#define SDI_Range2_1_Slope 45
+#define SDI_Range2_3_Slope 78
+#define SDI_Range1_1_Slope 0
+#define SDI_Range1_3_Slope 0
+/* Default value for build */
+/* ATL type low battery compensation offset */
+#define ATL_Range4_1_Offset 3298
+#define ATL_Range4_3_Offset 3330
+#define ATL_Range3_1_Offset 3375
+#define ATL_Range3_3_Offset 3445
+#define ATL_Range2_1_Offset 3371
+#define ATL_Range2_3_Offset 3466
+#define ATL_Range1_1_Offset 3362
+#define ATL_Range1_3_Offset 3443
+#define ATL_Range4_1_Slope 0
+#define ATL_Range4_3_Slope 0
+#define ATL_Range3_1_Slope 50
+#define ATL_Range3_3_Slope 77
+#define ATL_Range2_1_Slope 40
+#define ATL_Range2_3_Slope 111
+#define ATL_Range1_1_Slope 0
+#define ATL_Range1_3_Slope 0
+#elif defined(CONFIG_MACH_P8_REV00) || defined(CONFIG_MACH_P8_REV01) \
+ || defined(CONFIG_MACH_P8LTE_REV00) /* P8 battery parameter */
+/* Current range for P8(not dependent on battery type */
+#define CURRENT_RANGE1 0
+#define CURRENT_RANGE2 -200
+#define CURRENT_RANGE3 -600
+#define CURRENT_RANGE4 -1500
+#define CURRENT_RANGE5 -2500
+#define CURRENT_RANGE_MAX CURRENT_RANGE5
+#define CURRENT_RANGE_MAX_NUM 5
+/* SDI type low battery compensation Slope & Offset for 1% SOC range*/
+#define SDI_Range1_1_Slope 0
+#define SDI_Range2_1_Slope 54
+#define SDI_Range3_1_Slope 66
+#define SDI_Range4_1_Slope 69
+#define SDI_Range5_1_Slope 0
+
+#define SDI_Range1_1_Offset 3391
+#define SDI_Range2_1_Offset 3402
+#define SDI_Range3_1_Offset 3409
+#define SDI_Range4_1_Offset 3414
+#define SDI_Range5_1_Offset 3240
+
+/* SDI type low battery compensation Slope & Offset for 3% SOC range*/
+#define SDI_Range1_3_Slope 0
+#define SDI_Range2_3_Slope 92
+#define SDI_Range3_3_Slope 125
+#define SDI_Range4_3_Slope 110
+#define SDI_Range5_3_Slope 0
+
+#define SDI_Range1_3_Offset 3524
+#define SDI_Range2_3_Offset 3542
+#define SDI_Range3_3_Offset 3562
+#define SDI_Range4_3_Offset 3539
+#define SDI_Range5_3_Offset 3265
+
+/* ATL type low battery compensation offset */
+#define ATL_Range4_1_Offset 3298
+#define ATL_Range4_3_Offset 3330
+#define ATL_Range3_1_Offset 3375
+#define ATL_Range3_3_Offset 3445
+#define ATL_Range2_1_Offset 3371
+#define ATL_Range2_3_Offset 3466
+#define ATL_Range1_1_Offset 3362
+#define ATL_Range1_3_Offset 3443
+
+#define ATL_Range4_1_Slope 0
+#define ATL_Range4_3_Slope 0
+#define ATL_Range3_1_Slope 50
+#define ATL_Range3_3_Slope 77
+#define ATL_Range2_1_Slope 40
+#define ATL_Range2_3_Slope 111
+#define ATL_Range1_1_Slope 0
+#define ATL_Range1_3_Slope 0
+#else /* default value */
+/* Current range for default(not dependent on battery type */
+#define CURRENT_RANGE1 0
+#define CURRENT_RANGE2 -100
+#define CURRENT_RANGE3 -750
+#define CURRENT_RANGE4 -1250
+#define CURRENT_RANGE_MIN CURRENT_RANGE1
+#define CURRENT_RANGE_MAX CURRENT_RANGE4
+/* added as dummy value to fix build error */
+#define CURRENT_RANGE_MAX_NUM 4
+/* SDI type low battery compensation offset */
+#define SDI_Range4_1_Offset 3371
+#define SDI_Range4_3_Offset 3478
+#define SDI_Range3_1_Offset 3453
+#define SDI_Range3_3_Offset 3614
+#define SDI_Range2_1_Offset 3447
+#define SDI_Range2_3_Offset 3606
+#define SDI_Range1_1_Offset 3438
+#define SDI_Range1_3_Offset 3591
+#define SDI_Range4_1_Slope 0
+#define SDI_Range4_3_Slope 0
+#define SDI_Range3_1_Slope 50
+#define SDI_Range3_3_Slope 90
+#define SDI_Range2_1_Slope 50
+#define SDI_Range2_3_Slope 78
+#define SDI_Range1_1_Slope 0
+#define SDI_Range1_3_Slope 0
+/* ATL type low battery compensation offset */
+#define ATL_Range4_1_Offset 3298
+#define ATL_Range4_3_Offset 3330
+#define ATL_Range3_1_Offset 3375
+#define ATL_Range3_3_Offset 3445
+#define ATL_Range2_1_Offset 3371
+#define ATL_Range2_3_Offset 3466
+#define ATL_Range1_1_Offset 3362
+#define ATL_Range1_3_Offset 3443
+#define ATL_Range4_1_Slope 0
+#define ATL_Range4_3_Slope 0
+#define ATL_Range3_1_Slope 50
+#define ATL_Range3_3_Slope 77
+#define ATL_Range2_1_Slope 40
+#define ATL_Range2_3_Slope 111
+#define ATL_Range1_1_Slope 0
+#define ATL_Range1_3_Slope 0
+#endif
+
+/* Temperature adjust value */
+#define SDI_TRIM1_1 122
+#define SDI_TRIM1_2 8950
+#define SDI_TRIM2_1 200
+#define SDI_TRIM2_2 51000
+
+/* FullCap learning setting */
+#define VFSOC_FOR_FULLCAP_LEARNING 90
+#define LOW_CURRENT_FOR_FULLCAP_LEARNING 20
+#define HIGH_CURRENT_FOR_FULLCAP_LEARNING 120
+#define LOW_AVGCURRENT_FOR_FULLCAP_LEARNING 20
+#define HIGH_AVGCURRENT_FOR_FULLCAP_LEARNING 100
+
+/* power off margin */
+#define POWER_OFF_SOC_HIGH_MARGIN 0x200
+#define POWER_OFF_VOLTAGE_HIGH_MARGIN 3500
+
+#endif
+
+#endif /* __MAX17042_FUELGAUGE_H */
+
diff --git a/include/linux/battery/fuelgauge/max17048_fuelgauge.h b/include/linux/battery/fuelgauge/max17048_fuelgauge.h
new file mode 100644
index 0000000..3fe5ddf
--- /dev/null
+++ b/include/linux/battery/fuelgauge/max17048_fuelgauge.h
@@ -0,0 +1,53 @@
+/*
+ * max17048_fuelgauge.h
+ * Samsung MAX17048 Fuel Gauge Header
+ *
+ * Copyright (C) 2012 Samsung Electronics, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef __MAX17048_FUELGAUGE_H
+#define __MAX17048_FUELGAUGE_H __FILE__
+
+/* Slave address should be shifted to the right 1bit.
+ * R/W bit should NOT be included.
+ */
+#define SEC_FUELGAUGE_I2C_SLAVEADDR (0x6D >> 1)
+
+#define MAX17048_VCELL_MSB 0x02
+#define MAX17048_VCELL_LSB 0x03
+#define MAX17048_SOC_MSB 0x04
+#define MAX17048_SOC_LSB 0x05
+#define MAX17048_MODE_MSB 0x06
+#define MAX17048_MODE_LSB 0x07
+#define MAX17048_VER_MSB 0x08
+#define MAX17048_VER_LSB 0x09
+#define MAX17048_RCOMP_MSB 0x0C
+#define MAX17048_RCOMP_LSB 0x0D
+#define MAX17048_CMD_MSB 0xFE
+#define MAX17048_CMD_LSB 0xFF
+
+#define RCOMP0_TEMP 20
+
+struct battery_data_t {
+ u8 RCOMP0;
+ u8 RCOMP_charging;
+ int temp_cohot;
+ int temp_cocold;
+ u8 *type_str;
+};
+
+struct sec_fg_info {
+ bool dummy
+};
+
+#endif /* __MAX17048_FUELGAUGE_H */
diff --git a/include/linux/battery/fuelgauge/max17050_fuelgauge.h b/include/linux/battery/fuelgauge/max17050_fuelgauge.h
new file mode 100644
index 0000000..8576730
--- /dev/null
+++ b/include/linux/battery/fuelgauge/max17050_fuelgauge.h
@@ -0,0 +1,169 @@
+/*
+ * max17050_fuelgauge.h
+ * Samsung MAX17050 Fuel Gauge Header
+ *
+ * Copyright (C) 2012 Samsung Electronics, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef __MAX17050_FUELGAUGE_H
+#define __MAX17050_FUELGAUGE_H __FILE__
+
+#include <linux/android_alarm.h>
+
+/* Slave address should be shifted to the right 1bit.
+ * R/W bit should NOT be included.
+ */
+#define SEC_FUELGAUGE_I2C_SLAVEADDR 0x36
+
+#if defined(CONFIG_FUELGAUGE_MAX17050_VOLTAGE_TRACKING)
+#define MAX17050_REG_STATUS 0x00
+#define MAX17050_REG_VALRT_TH 0x01
+#define MAX17050_REG_TALRT_TH 0x02
+#define MAX17050_REG_SALRT_TH 0x03
+#define MAX17050_REG_VCELL 0x09
+#define MAX17050_REG_TEMPERATURE 0x08
+#define MAX17050_REG_AVGVCELL 0x19
+#define MAX17050_REG_CONFIG 0x1D
+#define MAX17050_REG_VERSION 0x21
+#define MAX17050_REG_LEARNCFG 0x28
+#define MAX17050_REG_FILTERCFG 0x29
+#define MAX17050_REG_MISCCFG 0x2B
+#define MAX17050_REG_CGAIN 0x2E
+#define MAX17050_REG_RCOMP 0x38
+#define MAX17050_REG_VFOCV 0xFB
+#define MAX17050_REG_SOC_VF 0xFF
+
+struct sec_fg_info {
+ bool dummy;
+};
+
+#endif
+
+#if defined(CONFIG_FUELGAUGE_MAX17050_COULOMB_COUNTING)
+#define PRINT_COUNT 10
+
+/* Register address */
+#define STATUS_REG 0x00
+#define VALRT_THRESHOLD_REG 0x01
+#define TALRT_THRESHOLD_REG 0x02
+#define SALRT_THRESHOLD_REG 0x03
+#define REMCAP_REP_REG 0x05
+#define SOCREP_REG 0x06
+#define TEMPERATURE_REG 0x08
+#define VCELL_REG 0x09
+#define CURRENT_REG 0x0A
+#define AVG_CURRENT_REG 0x0B
+#define SOCMIX_REG 0x0D
+#define SOCAV_REG 0x0E
+#define REMCAP_MIX_REG 0x0F
+#define FULLCAP_REG 0x10
+#define RFAST_REG 0x15
+#define AVR_TEMPERATURE_REG 0x16
+#define CYCLES_REG 0x17
+#define DESIGNCAP_REG 0x18
+#define AVR_VCELL_REG 0x19
+#define CONFIG_REG 0x1D
+#define REMCAP_AV_REG 0x1F
+#define FULLCAP_NOM_REG 0x23
+#define MISCCFG_REG 0x2B
+#define RCOMP_REG 0x38
+#define FSTAT_REG 0x3D
+#define DQACC_REG 0x45
+#define DPACC_REG 0x46
+#define OCV_REG 0xEE
+#define VFOCV_REG 0xFB
+#define VFSOC_REG 0xFF
+
+#define FG_LEVEL 0
+#define FG_TEMPERATURE 1
+#define FG_VOLTAGE 2
+#define FG_CURRENT 3
+#define FG_CURRENT_AVG 4
+#define FG_CHECK_STATUS 5
+#define FG_VF_SOC 6
+#define FG_AV_SOC 7
+
+#define LOW_BATT_COMP_RANGE_NUM 5
+#define LOW_BATT_COMP_LEVEL_NUM 2
+#define MAX_LOW_BATT_CHECK_CNT 10
+
+enum {
+ POSITIVE = 0,
+ NEGATIVE,
+};
+
+enum {
+ RANGE = 0,
+ SLOPE,
+ OFFSET,
+ TABLE_MAX
+};
+
+#define CURRENT_RANGE_MAX_NUM 5
+#define TEMP_RANGE_MAX_NUM 3
+
+struct battery_data_t {
+ u16 Capacity;
+ u16 low_battery_comp_voltage;
+ s32 low_battery_table[CURRENT_RANGE_MAX_NUM][TABLE_MAX];
+ s32 temp_adjust_table[TEMP_RANGE_MAX_NUM][TABLE_MAX];
+ u8 *type_str;
+};
+
+struct sec_fg_info {
+ /* test print count */
+ int pr_cnt;
+ /* full charge comp */
+ struct delayed_work full_comp_work;
+ u32 previous_fullcap;
+ u32 previous_vffullcap;
+ /* low battery comp */
+ int low_batt_comp_cnt[LOW_BATT_COMP_RANGE_NUM][LOW_BATT_COMP_LEVEL_NUM];
+ int low_batt_comp_flag;
+ /* low battery boot */
+ int low_batt_boot_flag;
+ bool is_low_batt_alarm;
+
+ /* battery info */
+ u32 soc;
+
+ /* miscellaneous */
+ unsigned long fullcap_check_interval;
+ int full_check_flag;
+ bool is_first_check;
+};
+
+/* FullCap learning setting */
+#define VFFULLCAP_CHECK_INTERVAL 300 /* sec */
+/* soc should be 0.1% unit */
+#define VFSOC_FOR_FULLCAP_LEARNING 950
+#define LOW_CURRENT_FOR_FULLCAP_LEARNING 20
+#define HIGH_CURRENT_FOR_FULLCAP_LEARNING 120
+#define LOW_AVGCURRENT_FOR_FULLCAP_LEARNING 20
+#define HIGH_AVGCURRENT_FOR_FULLCAP_LEARNING 100
+
+/* power off margin */
+/* soc should be 0.1% unit */
+#define POWER_OFF_SOC_HIGH_MARGIN 20
+#define POWER_OFF_VOLTAGE_HIGH_MARGIN 3500
+#define POWER_OFF_VOLTAGE_LOW_MARGIN 3400
+
+/* FG recovery handler */
+/* soc should be 0.1% unit */
+#define STABLE_LOW_BATTERY_DIFF 30
+#define STABLE_LOW_BATTERY_DIFF_LOWBATT 10
+#define LOW_BATTERY_SOC_REDUCE_UNIT 10
+#endif
+
+#endif /* __MAX17050_FUELGAUGE_H */
+
diff --git a/include/linux/battery/max17047_fuelgauge.h b/include/linux/battery/max17047_fuelgauge.h
new file mode 100644
index 0000000..dac19c6
--- /dev/null
+++ b/include/linux/battery/max17047_fuelgauge.h
@@ -0,0 +1,33 @@
+/*
+ * max17047_fuelgauge.h
+ *
+ * Copyright (C) 2011 Samsung Electronics
+ * SangYoung Son <hello.son@samsung.com>
+ *
+ * based on max17042_battery.h
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef __MAX17047_BATTERY_H_
+#define __MAX17047_BATTERY_H_
+
+struct max17047_platform_data {
+ int irq_gpio;
+
+ bool enable_current_sense;
+ bool enable_gauging_temperature;
+
+ const char *psy_name;
+};
+
+#endif
+
diff --git a/include/linux/battery/samsung_battery.h b/include/linux/battery/samsung_battery.h
new file mode 100644
index 0000000..4576d8f
--- /dev/null
+++ b/include/linux/battery/samsung_battery.h
@@ -0,0 +1,345 @@
+/*
+ * Copyright (C) 2010 Samsung Electronics, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef __MACH_SAMSUNG_BATTERY_H
+#define __MACH_SAMSUNG_BATTERY_H __FILE__
+
+#include <linux/gpio.h>
+#include <linux/delay.h>
+#include <linux/power_supply.h>
+#include <linux/android_alarm.h>
+
+/* macro */
+#define MAX(x, y) ((x) > (y) ? (x) : (y))
+#define MIN(x, y) ((x) < (y) ? (x) : (y))
+#define ABS(x) ((x) < 0 ? (-1 * (x)) : (x))
+
+/* common */
+enum {
+ DISABLE = 0,
+ ENABLE,
+};
+
+struct battery_info {
+ struct device *dev;
+ struct samsung_battery_platform_data *pdata;
+#if defined(CONFIG_S3C_ADC)
+ struct s3c_adc_client *adc_client;
+#endif
+
+ bool use_sub_charger;
+ char *fuelgauge_name;
+ char *charger_name;
+ char *sub_charger_name;
+
+ /* android common power supply */
+ struct power_supply psy_bat;
+ struct power_supply psy_usb;
+ struct power_supply psy_ac;
+
+ /* charger, fuelgauge psy depends on machine */
+ struct power_supply *psy_charger;
+ struct power_supply *psy_fuelgauge;
+ struct power_supply *psy_sub_charger;
+
+ /* workqueue */
+ struct work_struct monitor_work;
+ unsigned int monitor_mode;
+ unsigned int monitor_interval;
+ int monitor_weight;
+ unsigned int monitor_count;
+ struct work_struct error_work;
+
+ /* mutex */
+ struct mutex mon_lock;
+ struct mutex ops_lock;
+ struct mutex err_lock;
+
+ /* wakelock */
+ struct wake_lock charge_wake_lock;
+ struct wake_lock monitor_wake_lock;
+ struct wake_lock emer_wake_lock;
+
+ /* is_suspended */
+ bool is_suspended;
+
+ /* charge state */
+ unsigned int charge_real_state;
+ unsigned int charge_virt_state;
+ unsigned int charge_type;
+ unsigned int charge_current;
+ unsigned int input_current;
+
+ /* battery state */
+ unsigned int battery_health;
+ unsigned int battery_present;
+ unsigned int battery_vcell;
+ unsigned int battery_vfocv;
+ int battery_v_diff;
+ unsigned int battery_soc;
+ unsigned int battery_raw_soc;
+ int battery_r_s_delta;
+
+ /* temperature */
+ int battery_temper;
+ int battery_temper_adc;
+ int battery_t_delta;
+ int battery_temper_avg;
+ int battery_temper_adc_avg;
+
+ /* cable type */
+ unsigned int cable_type;
+
+ /* For SAMSUNG charge spec */
+ unsigned int vf_state;
+ unsigned int temper_state;
+ unsigned int overheated_state;
+ unsigned int freezed_state;
+ unsigned int full_charged_state;
+ unsigned int abstimer_state;
+ unsigned int recharge_phase;
+ unsigned int recharge_start;
+ unsigned int health_state;
+
+ unsigned int lpm_state;
+ unsigned int siop_state;
+ unsigned int siop_charge_current;
+ unsigned int led_state;
+
+ /* ambiguous state */
+ unsigned int ambiguous_state;
+
+ /* time management */
+ unsigned int charge_start_time;
+ struct alarm alarm;
+ bool slow_poll;
+ ktime_t last_poll;
+
+ struct proc_dir_entry *entry;
+
+ /* For debugging */
+ unsigned int battery_test_mode;
+ unsigned int battery_error_test;
+
+#if defined(CONFIG_TARGET_LOCALE_KOR) || defined(CONFIG_MACH_M0_CTC)
+ bool is_unspec_phase;
+ bool is_unspec_recovery;
+ int battery_full_soc;
+ unsigned int prev_cable_type;
+ unsigned int prev_battery_health;
+ unsigned int prev_charge_virt_state;
+ unsigned int prev_battery_soc;
+ struct wake_lock update_wake_lock;
+#endif
+};
+
+/* jig state */
+extern bool is_jig_attached;
+
+/*
+ * Use for charger
+ */
+enum charger_state {
+ CHARGER_STATE_ENABLE = 0,
+ CHARGER_STATE_DISABLE = 1
+};
+
+enum current_type {
+ CURRENT_TYPE_CHRAGE = 0,
+ CURRENT_TYPE_INPUT = 1,
+};
+
+/*
+ * Use for fuelgauge
+ */
+enum voltage_type {
+ VOLTAGE_TYPE_VCELL = 0,
+ VOLTAGE_TYPE_VFOCV = 1,
+};
+
+enum soc_type {
+ SOC_TYPE_ADJUSTED = 0,
+ SOC_TYPE_RAW = 1,
+#if defined(CONFIG_TARGET_LOCALE_KOR) || defined(CONFIG_MACH_M0_CTC)
+ SOC_TYPE_FULL = 2,
+#endif
+};
+
+/*
+ * Use for battery
+ */
+#define OFF_CURR 0 /* charger off current */
+#define KEEP_CURR -1 /* keep previous current */
+
+/* VF error check */
+#define VF_CHECK_COUNT 10
+#define VF_CHECK_DELAY 1000
+#define RESET_SOC_DIFF_TH 100000
+
+/* average count */
+#define CNT_VOLTAGE_AVG 5
+#define CNT_CURRENT_AVG 5
+#define CNT_TEMPER_AVG 5
+#define CNT_ADC_SAMPLE 6
+
+/* adc error retry */
+#define ADC_ERR_CNT 5
+#define ADC_ERR_DELAY 200
+
+/* voltage diff for recharge voltage calculation */
+#if defined(CONFIG_TARGET_LOCALE_KOR)
+/* KOR model spec : max-voltage minus 60mV */
+#define RECHG_DROP_VALUE 60000
+#else
+#define RECHG_DROP_VALUE 50000 /* 4300mV */
+#endif
+
+enum {
+ CHARGE_DISABLE = 0,
+ CHARGE_ENABLE,
+};
+
+enum {
+ JIG_OFF = 0,
+ JIG_ON,
+};
+
+/* cable detect source */
+enum {
+ CABLE_DET_MUIC = 0,
+ CABLE_DET_ADC,
+ CABLE_DET_CHARGER,
+
+ CABLE_DET_UNKNOWN,
+};
+
+
+/* temperature source */
+enum {
+ TEMPER_FUELGAUGE = 0,
+ TEMPER_AP_ADC,
+ TEMPER_EXT_ADC,
+
+ TEMPER_UNKNOWN,
+};
+
+/* siop state */
+enum {
+ SIOP_DEACTIVE = 0,
+ SIOP_ACTIVE,
+};
+
+/* monitoring mode */
+enum {
+ MONITOR_CHNG = 0,
+ MONITOR_CHNG_SUSP,
+ MONITOR_NORM,
+ MONITOR_NORM_SUSP,
+ MONITOR_EMER_LV1,
+ MONITOR_EMER_LV2,
+};
+
+/* Temperature from adc */
+#if defined(CONFIG_STMPE811_ADC)
+#define BATTERY_TEMPER_CH 7
+u16 stmpe811_get_adc_data(u8 channel);
+int stmpe811_get_adc_value(u8 channel);
+#endif
+
+/* LED control */
+enum led_state {
+ BATT_LED_CHARGING = 0,
+ BATT_LED_DISCHARGING,
+ BATT_LED_NOT_CHARGING,
+ BATT_LED_FULL,
+};
+
+enum led_color {
+ BATT_LED_RED = 0,
+ BATT_LED_GREEN,
+ BATT_LED_BLUE,
+};
+
+enum led_pattern {
+ BATT_LED_PATT_OFF = 0,
+ BATT_LED_PATT_CHG,
+ BATT_LED_PATT_NOT_CHG,
+};
+
+/**
+ * struct sec_bat_plaform_data - init data for sec batter driver
+ * @fuel_gauge_name: power supply name of fuel gauge
+ * @charger_name: power supply name of charger
+ */
+struct samsung_battery_platform_data {
+ char *charger_name;
+ char *fuelgauge_name;
+ char *sub_charger_name;
+ bool use_sub_charger;
+
+ /* battery voltage design */
+ unsigned int voltage_max;
+ unsigned int voltage_min;
+
+ /* charge current */
+ unsigned int in_curr_limit;
+ unsigned int chg_curr_ta;
+ unsigned int chg_curr_usb;
+ unsigned int chg_curr_cdp;
+ unsigned int chg_curr_wpc;
+ unsigned int chg_curr_dock;
+ unsigned int chg_curr_etc;
+
+ /* variable monitoring interval */
+ unsigned int chng_interval;
+ unsigned int chng_susp_interval;
+ unsigned int norm_interval;
+ unsigned int norm_susp_interval;
+ unsigned int emer_lv1_interval;
+ unsigned int emer_lv2_interval;
+
+ /* Recharge sceanario */
+ unsigned int recharge_voltage;
+ unsigned int abstimer_charge_duration;
+ unsigned int abstimer_recharge_duration;
+
+ /* cable detect */
+ int cb_det_src;
+ int cb_det_gpio;
+ int cb_det_adc_ch;
+
+ /* Temperature scenario */
+ int overheat_stop_temp;
+ int overheat_recovery_temp;
+ int freeze_stop_temp;
+ int freeze_recovery_temp;
+
+ /* Temperature source 0: fuelgauge, 1: ap adc, 2: ex. adc */
+ int temper_src;
+ int temper_ch;
+#ifdef CONFIG_S3C_ADC
+ int (*covert_adc) (int, int);
+#endif
+
+ /* suspend in charging */
+ bool suspend_chging;
+
+ /* support led indicator */
+ bool led_indicator;
+
+ /* support battery_standever */
+ bool battery_standever;
+};
+
+#endif /* __MACH_SAMSUNG_BATTERY_H */
diff --git a/include/linux/battery/sec_battery.h b/include/linux/battery/sec_battery.h
new file mode 100644
index 0000000..4c57e62
--- /dev/null
+++ b/include/linux/battery/sec_battery.h
@@ -0,0 +1,255 @@
+/*
+ * sec_battery.h
+ * Samsung Mobile Battery Header
+ *
+ *
+ * Copyright (C) 2012 Samsung Electronics, Inc.
+ *
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef __SEC_BATTERY_H
+#define __SEC_BATTERY_H __FILE__
+
+#include <linux/battery/sec_charging_common.h>
+#include <linux/android_alarm.h>
+#include <linux/wakelock.h>
+#include <linux/workqueue.h>
+#include <linux/proc_fs.h>
+#include <linux/jiffies.h>
+
+static enum power_supply_property sec_battery_props[] = {
+ POWER_SUPPLY_PROP_STATUS,
+ POWER_SUPPLY_PROP_CHARGE_TYPE,
+ POWER_SUPPLY_PROP_HEALTH,
+ POWER_SUPPLY_PROP_PRESENT,
+ POWER_SUPPLY_PROP_ONLINE,
+ POWER_SUPPLY_PROP_TECHNOLOGY,
+ POWER_SUPPLY_PROP_VOLTAGE_NOW,
+ POWER_SUPPLY_PROP_VOLTAGE_AVG,
+ POWER_SUPPLY_PROP_CURRENT_NOW,
+ POWER_SUPPLY_PROP_CURRENT_AVG,
+ POWER_SUPPLY_PROP_CAPACITY,
+ POWER_SUPPLY_PROP_TEMP,
+ POWER_SUPPLY_PROP_TEMP_AMBIENT,
+};
+
+static enum power_supply_property sec_power_props[] = {
+ POWER_SUPPLY_PROP_ONLINE,
+};
+
+#define ADC_CH_COUNT 10
+#define ADC_SAMPLE_COUNT 10
+
+struct adc_sample_info {
+ unsigned int cnt;
+ int total_adc;
+ int average_adc;
+ int adc_arr[ADC_SAMPLE_COUNT];
+ int index;
+};
+
+struct sec_battery_info {
+ struct device *dev;
+ sec_battery_platform_data_t *pdata;
+ /* power supply used in Android */
+ struct power_supply psy_bat;
+ struct power_supply psy_usb;
+ struct power_supply psy_ac;
+ unsigned int irq;
+
+ int status;
+ int health;
+ bool present;
+
+ int voltage_now; /* cell voltage (mV) */
+ int voltage_avg; /* average voltage (mV) */
+ int voltage_ocv; /* open circuit voltage (mV) */
+ int current_now; /* current (mA) */
+ int current_avg; /* average current (mA) */
+ int current_adc;
+
+ unsigned int capacity; /* SOC (%) */
+
+ struct mutex adclock;
+ struct adc_sample_info adc_sample[ADC_CH_COUNT];
+
+ /* keep awake until monitor is done */
+ struct wake_lock monitor_wake_lock;
+ struct workqueue_struct *monitor_wqueue;
+ struct work_struct monitor_work;
+ unsigned int polling_count;
+ unsigned int polling_time;
+ bool polling_in_sleep;
+ bool polling_short;
+
+ struct delayed_work polling_work;
+ struct alarm polling_alarm;
+ ktime_t last_poll_time;
+
+ /* event set */
+ unsigned int event;
+ unsigned int event_wait;
+ struct timer_list event_expired_timer;
+
+ /* battery check */
+ unsigned int check_count;
+ /* ADC check */
+ unsigned int check_adc_count;
+ unsigned int check_adc_value;
+
+ /* time check */
+ unsigned long charging_start_time;
+ unsigned long charging_passed_time;
+ unsigned long charging_next_time;
+
+ /* temperature check */
+ int temperature; /* battery temperature */
+ int temper_amb; /* target temperature */
+
+ int temp_adc;
+
+ int temp_high_threshold;
+ int temp_high_recovery;
+ int temp_low_threshold;
+ int temp_low_recovery;
+
+ unsigned int temp_high_cnt;
+ unsigned int temp_low_cnt;
+ unsigned int temp_recover_cnt;
+
+ /* charging */
+ unsigned int charging_mode;
+ int cable_type;
+ struct wake_lock cable_wake_lock;
+ struct work_struct cable_work;
+ struct wake_lock vbus_wake_lock;
+ unsigned int full_check_cnt;
+
+ /* test mode */
+ bool test_activated;
+};
+
+static char *supply_list[] = {
+ "battery",
+};
+
+ssize_t sec_bat_show_attrs(struct device *dev,
+ struct device_attribute *attr, char *buf);
+
+ssize_t sec_bat_store_attrs(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count);
+
+#define SEC_BATTERY_ATTR(_name) \
+{ \
+ .attr = {.name = #_name, .mode = 0664}, \
+ .show = sec_bat_show_attrs, \
+ .store = sec_bat_store_attrs, \
+}
+
+/* event check */
+#define EVENT_NONE (0)
+#define EVENT_2G_CALL (0x1 << 0)
+#define EVENT_3G_CALL (0x1 << 1)
+#define EVENT_MUSIC (0x1 << 2)
+#define EVENT_VIDEO (0x1 << 3)
+#define EVENT_BROWSER (0x1 << 4)
+#define EVENT_HOTSPOT (0x1 << 5)
+#define EVENT_CAMERA (0x1 << 6)
+#define EVENT_CAMCORDER (0x1 << 7)
+#define EVENT_DATA_CALL (0x1 << 8)
+#define EVENT_WIFI (0x1 << 9)
+#define EVENT_WIBRO (0x1 << 10)
+#define EVENT_LTE (0x1 << 11)
+
+static struct device_attribute sec_battery_attrs[] = {
+ SEC_BATTERY_ATTR(batt_reset_soc),
+ SEC_BATTERY_ATTR(batt_read_raw_soc),
+ SEC_BATTERY_ATTR(batt_read_adj_soc),
+ SEC_BATTERY_ATTR(batt_type),
+ SEC_BATTERY_ATTR(batt_vfocv),
+ SEC_BATTERY_ATTR(batt_vol_adc),
+ SEC_BATTERY_ATTR(batt_vol_adc_cal),
+ SEC_BATTERY_ATTR(batt_vol_aver),
+ SEC_BATTERY_ATTR(batt_vol_adc_aver),
+ SEC_BATTERY_ATTR(batt_temp_adc),
+ SEC_BATTERY_ATTR(batt_temp_aver),
+ SEC_BATTERY_ATTR(batt_temp_adc_aver),
+ SEC_BATTERY_ATTR(batt_vf_adc),
+
+ SEC_BATTERY_ATTR(batt_lp_charging),
+ SEC_BATTERY_ATTR(siop_activated),
+ SEC_BATTERY_ATTR(batt_charging_source),
+ SEC_BATTERY_ATTR(fg_reg_dump),
+ SEC_BATTERY_ATTR(fg_reset_cap),
+ SEC_BATTERY_ATTR(auth),
+ SEC_BATTERY_ATTR(chg_current_adc),
+ SEC_BATTERY_ATTR(wc_adc),
+ SEC_BATTERY_ATTR(wc_status),
+
+ SEC_BATTERY_ATTR(2g_call),
+ SEC_BATTERY_ATTR(3g_call),
+ SEC_BATTERY_ATTR(music),
+ SEC_BATTERY_ATTR(video),
+ SEC_BATTERY_ATTR(browser),
+ SEC_BATTERY_ATTR(hotspot),
+ SEC_BATTERY_ATTR(camera),
+ SEC_BATTERY_ATTR(camcorger),
+ SEC_BATTERY_ATTR(data_call),
+ SEC_BATTERY_ATTR(wifi),
+ SEC_BATTERY_ATTR(wibro),
+ SEC_BATTERY_ATTR(lte),
+ SEC_BATTERY_ATTR(event),
+};
+
+enum {
+ BATT_RESET_SOC = 0,
+ BATT_READ_RAW_SOC,
+ BATT_READ_ADJ_SOC,
+ BATT_TYPE,
+ BATT_VFOCV,
+ BATT_VOL_ADC,
+ BATT_VOL_ADC_CAL,
+ BATT_VOL_AVER,
+ BATT_VOL_ADC_AVER,
+ BATT_TEMP_ADC,
+ BATT_TEMP_AVER,
+ BATT_TEMP_ADC_AVER,
+ BATT_VF_ADC,
+
+ BATT_LP_CHARGING,
+ SIOP_ACTIVATED,
+ BATT_CHARGING_SOURCE,
+ FG_REG_DUMP,
+ FG_RESET_CAP,
+ AUTH,
+ CHG_CURRENT_ADC,
+ WC_ADC,
+ WC_STATUS,
+
+ BATT_EVENT_2G_CALL,
+ BATT_EVENT_3G_CALL,
+ BATT_EVENT_MUSIC,
+ BATT_EVENT_VIDEO,
+ BATT_EVENT_BROWSER,
+ BATT_EVENT_HOTSPOT,
+ BATT_EVENT_CAMERA,
+ BATT_EVENT_CAMCORDER,
+ BATT_EVENT_DATA_CALL,
+ BATT_EVENT_WIFI,
+ BATT_EVENT_WIBRO,
+ BATT_EVENT_LTE,
+ BATT_EVENT,
+};
+
+#endif /* __SEC_BATTERY_H */
diff --git a/include/linux/battery/sec_charger.h b/include/linux/battery/sec_charger.h
new file mode 100644
index 0000000..c84b272
--- /dev/null
+++ b/include/linux/battery/sec_charger.h
@@ -0,0 +1,106 @@
+/*
+ * sec_charger.h
+ * Samsung Mobile Charger Header
+ *
+ * Copyright (C) 2012 Samsung Electronics, Inc.
+ *
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef __SEC_CHARGER_H
+#define __SEC_CHARGER_H __FILE__
+
+#include <linux/battery/sec_charging_common.h>
+
+#if defined(CONFIG_CHARGER_DUMMY)
+#include <linux/battery/charger/dummy_charger.h>
+#elif defined(CONFIG_CHARGER_MAX8903)
+#include <linux/battery/charger/max8903_charger.h>
+#elif defined(CONFIG_CHARGER_SMB328)
+#include <linux/battery/charger/smb328_charger.h>
+#elif defined(CONFIG_CHARGER_SMB347)
+#include <linux/battery/charger/smb347_charger.h>
+#elif defined(CONFIG_CHARGER_BQ24157)
+#include <linux/battery/charger/bq24157_charger.h>
+#elif defined(CONFIG_CHARGER_BQ24190) || \
+ defined(CONFIG_CHARGER_BQ24191)
+#include <linux/battery/charger/bq24190_charger.h>
+#endif
+
+static enum power_supply_property sec_charger_props[] = {
+ POWER_SUPPLY_PROP_STATUS,
+ POWER_SUPPLY_PROP_HEALTH,
+ POWER_SUPPLY_PROP_ONLINE,
+ POWER_SUPPLY_PROP_CURRENT_NOW,
+};
+
+struct sec_charger_info {
+ struct i2c_client *client;
+ sec_battery_platform_data_t *pdata;
+ struct power_supply psy_chg;
+ struct delayed_work isr_work;
+
+ int cable_type;
+ bool is_charging;
+
+ /* charging current : + charging, - OTG */
+ int charging_current;
+
+ /* register programming */
+ int reg_addr;
+ int reg_data;
+};
+
+bool sec_hal_chg_init(struct i2c_client *);
+bool sec_hal_chg_suspend(struct i2c_client *);
+bool sec_hal_chg_resume(struct i2c_client *);
+bool sec_hal_chg_get_property(struct i2c_client *,
+ enum power_supply_property,
+ union power_supply_propval *);
+bool sec_hal_chg_set_property(struct i2c_client *,
+ enum power_supply_property,
+ const union power_supply_propval *);
+
+ssize_t sec_hal_chg_show_attrs(struct device *dev,
+ const ptrdiff_t offset, char *buf);
+
+ssize_t sec_hal_chg_store_attrs(struct device *dev,
+ const ptrdiff_t offset,
+ const char *buf, size_t count);
+
+ssize_t sec_chg_show_attrs(struct device *dev,
+ struct device_attribute *attr, char *buf);
+
+ssize_t sec_chg_store_attrs(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count);
+
+#define SEC_CHARGER_ATTR(_name) \
+{ \
+ .attr = {.name = #_name, .mode = 0666}, \
+ .show = sec_chg_show_attrs, \
+ .store = sec_chg_store_attrs, \
+}
+
+static struct device_attribute sec_charger_attrs[] = {
+ SEC_CHARGER_ATTR(reg),
+ SEC_CHARGER_ATTR(data),
+ SEC_CHARGER_ATTR(regs),
+};
+
+enum {
+ CHG_REG = 0,
+ CHG_DATA,
+ CHG_REGS,
+};
+
+#endif /* __SEC_CHARGER_H */
diff --git a/include/linux/battery/sec_charging_common.h b/include/linux/battery/sec_charging_common.h
new file mode 100644
index 0000000..d35f77b
--- /dev/null
+++ b/include/linux/battery/sec_charging_common.h
@@ -0,0 +1,503 @@
+/*
+ * sec_charging_common.h
+ * Samsung Mobile Charging Common Header
+ *
+ * Copyright (C) 2012 Samsung Electronics, Inc.
+ *
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef __SEC_CHARGING_COMMON_H
+#define __SEC_CHARGING_COMMON_H __FILE__
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/err.h>
+#include <linux/delay.h>
+#include <linux/gpio.h>
+#include <linux/irq.h>
+#include <linux/interrupt.h>
+#include <linux/i2c.h>
+#include <linux/power_supply.h>
+#include <linux/slab.h>
+#include <linux/device.h>
+
+/* definitions */
+#define SEC_SIZEOF_POWER_SUPPLY_TYPE 11 /* P10 */
+
+enum sec_battery_voltage_mode {
+ /* average voltage */
+ SEC_BATTEY_VOLTAGE_AVERAGE = 0,
+ /* open circuit voltage */
+ SEC_BATTEY_VOLTAGE_OCV,
+};
+
+/* ADC type */
+#define SEC_BATTERY_ADC_TYPE_NUM 3
+
+enum sec_battery_adc_type {
+ /* NOT using this ADC channel */
+ SEC_BATTERY_ADC_TYPE_NONE = 0,
+ /* ADC in AP */
+ SEC_BATTERY_ADC_TYPE_AP,
+ /* ADC by additional IC */
+ SEC_BATTERY_ADC_TYPE_IC,
+};
+
+enum sec_battery_adc_channel {
+ SEC_BAT_ADC_CHANNEL_CABLE_CHECK = 0,
+ SEC_BAT_ADC_CHANNEL_BAT_CHECK,
+ SEC_BAT_ADC_CHANNEL_TEMP,
+ SEC_BAT_ADC_CHANNEL_TEMP_AMBIENT,
+ SEC_BAT_ADC_CHANNEL_FULL_CHECK,
+};
+
+/* charging mode */
+enum sec_battery_charging_mode {
+ /* no charging */
+ SEC_BATTERY_CHARGING_NONE = 0,
+ /* normal charging */
+ SEC_BATTERY_CHARGING_NORMAL,
+ /* charging after 1st full-check*/
+ SEC_BATTERY_CHARGING_2ND,
+ /* recharging */
+ SEC_BATTERY_CHARGING_RECHARGING,
+};
+
+struct sec_bat_adc_api {
+ bool (*init)(struct platform_device *);
+ bool (*exit)(void);
+ int (*read)(unsigned int);
+};
+#define sec_bat_adc_api_t struct sec_bat_adc_api
+
+/* monitor activation */
+enum sec_battery_polling_time_type {
+ /* same order with power supply status */
+ SEC_BATTERY_POLLING_TIME_BASIC = 0,
+ SEC_BATTERY_POLLING_TIME_CHARGING,
+ SEC_BATTERY_POLLING_TIME_DISCHARGING,
+ SEC_BATTERY_POLLING_TIME_NOT_CHARGING,
+ SEC_BATTERY_POLLING_TIME_SLEEP,
+};
+
+enum sec_battery_monitor_polling {
+ /* polling work queue */
+ SEC_BATTERY_MONITOR_WORKQUEUE,
+ /* alarm polling */
+ SEC_BATTERY_MONITOR_ALARM,
+ /* timer polling */
+ SEC_BATTERY_MONITOR_TIMER,
+};
+#define sec_battery_monitor_polling_t \
+ enum sec_battery_monitor_polling
+
+/* full charged check : POWER_SUPPLY_PROP_STATUS */
+enum sec_battery_full_charged {
+ /* current check by ADC */
+ SEC_BATTERY_FULLCHARGED_ADC,
+ /* current check by ADC and dual check (1st, 2nd top-off) */
+ SEC_BATTERY_FULLCHARGED_ADC_DUAL,
+ /* fuel gauge current check */
+ SEC_BATTERY_FULLCHARGED_FG_CURRENT,
+ /* fuel gauge current check and dual check (1st, 2nd top-off) */
+ SEC_BATTERY_FULLCHARGED_FG_CURRENT_DUAL,
+ /* charger GPIO */
+ SEC_BATTERY_FULLCHARGED_CHGGPIO,
+ /* charger interrupt */
+ SEC_BATTERY_FULLCHARGED_CHGINT,
+ /* charger power supply property */
+ SEC_BATTERY_FULLCHARGED_CHGPSY,
+};
+#define sec_battery_full_charged_t \
+ enum sec_battery_full_charged
+
+/* full check condition type (can be used overlapped) */
+#define sec_battery_full_condition_t unsigned int
+/* SEC_BATTERY_FULL_CONDITION_NOTIMEFULL
+ * no full-charged by absolute-timer
+ */
+#define SEC_BATTERY_FULL_CONDITION_NOTIMEFULL 1
+/* SEC_BATTERY_FULL_CONDITION_SOC
+ * use capacity for full-charged check
+ */
+#define SEC_BATTERY_FULL_CONDITION_SOC 2
+/* SEC_BATTERY_FULL_CONDITION_AVGVCELL
+ * use average VCELL for full-charged check
+ */
+#define SEC_BATTERY_FULL_CONDITION_AVGVCELL 4
+/* SEC_BATTERY_FULL_CONDITION_OCV
+ * use OCV for full-charged check
+ */
+#define SEC_BATTERY_FULL_CONDITION_OCV 8
+
+/* recharge check condition type (can be used overlapped) */
+#define sec_battery_recharge_condition_t unsigned int
+/* SEC_BATTERY_RECHARGE_CONDITION_SOC
+ * use capacity for recharging check
+ */
+#define SEC_BATTERY_RECHARGE_CONDITION_SOC 1
+/* SEC_BATTERY_RECHARGE_CONDITION_AVGVCELL
+ * use average VCELL for recharging check
+ */
+#define SEC_BATTERY_RECHARGE_CONDITION_AVGVCELL 2
+/* SEC_BATTERY_RECHARGE_CONDITION_VCELL
+ * use VCELL for recharging check
+ */
+#define SEC_BATTERY_RECHARGE_CONDITION_VCELL 4
+
+/* battery check : POWER_SUPPLY_PROP_PRESENT */
+enum sec_battery_check {
+ /* No Check for internal battery */
+ SEC_BATTERY_CHECK_NONE,
+ /* by ADC */
+ SEC_BATTERY_CHECK_ADC,
+ /* by callback function (battery certification by 1 wired)*/
+ SEC_BATTERY_CHECK_CALLBACK,
+ /* by PMIC */
+ SEC_BATTERY_CHECK_PMIC,
+ /* by fuel gauge */
+ SEC_BATTERY_CHECK_FUELGAUGE,
+ /* by charger */
+ SEC_BATTERY_CHECK_CHARGER,
+ /* by interrupt (use check_battery_callback() to check battery) */
+ SEC_BATTERY_CHECK_INT,
+};
+#define sec_battery_check_t \
+ enum sec_battery_check
+
+/* OVP, UVLO check : POWER_SUPPLY_PROP_HEALTH */
+enum sec_battery_ovp_uvlo {
+ /* by callback function */
+ SEC_BATTERY_OVP_UVLO_CALLBACK,
+ /* by PMIC polling */
+ SEC_BATTERY_OVP_UVLO_PMICPOLLING,
+ /* by PMIC interrupt */
+ SEC_BATTERY_OVP_UVLO_PMICINT,
+ /* by charger polling */
+ SEC_BATTERY_OVP_UVLO_CHGPOLLING,
+ /* by charger interrupt */
+ SEC_BATTERY_OVP_UVLO_CHGINT,
+};
+#define sec_battery_ovp_uvlo_t \
+ enum sec_battery_ovp_uvlo
+
+/* thermal source */
+enum sec_battery_thermal_source {
+ /* by fuel gauge */
+ SEC_BATTERY_THERMAL_SOURCE_FG,
+ /* by external source */
+ SEC_BATTERY_THERMAL_SOURCE_CALLBACK,
+ /* by ADC */
+ SEC_BATTERY_THERMAL_SOURCE_ADC,
+};
+#define sec_battery_thermal_source_t \
+ enum sec_battery_thermal_source
+
+/* temperature check type */
+enum sec_battery_temp_check {
+ SEC_BATTERY_TEMP_CHECK_NONE = 0, /* no temperature check */
+ SEC_BATTERY_TEMP_CHECK_ADC, /* by ADC value */
+ SEC_BATTERY_TEMP_CHECK_TEMP, /* by temperature */
+};
+#define sec_battery_temp_check_t \
+ enum sec_battery_temp_check
+
+/* cable check (can be used overlapped) */
+#define sec_battery_cable_check_t unsigned int
+/* SEC_BATTERY_CABLE_CHECK_NOUSBCHARGE
+ * for USB cable in tablet model,
+ * status is stick to discharging,
+ * but internal charging logic is working
+ */
+#define SEC_BATTERY_CABLE_CHECK_NOUSBCHARGE 1
+/* SEC_BATTERY_CABLE_CHECK_PSY
+ * check cable by power supply set_property
+ */
+#define SEC_BATTERY_CABLE_CHECK_PSY 2
+/* SEC_BATTERY_CABLE_CHECK_INT
+ * check cable by interrupt
+ */
+#define SEC_BATTERY_CABLE_CHECK_INT 4
+/* SEC_BATTERY_CABLE_CHECK_POLLING
+ * check cable by GPIO polling
+ */
+#define SEC_BATTERY_CABLE_CHECK_POLLING 8
+
+/* check cable source */
+enum sec_battery_cable_source {
+ /* already given by external argument */
+ SEC_BATTERY_CABLE_SOURCE_EXTERNAL,
+ /* by callback (MUIC, USB switch) */
+ SEC_BATTERY_CABLE_SOURCE_CALLBACK,
+ /* by ADC */
+ SEC_BATTERY_CABLE_SOURCE_ADC,
+};
+#define sec_battery_cable_source_t \
+ enum sec_battery_cable_source
+
+/* capacity calculation type (can be used overlapped) */
+#define sec_fuelgauge_capacity_type_t unsigned int
+/* SEC_FUELGAUGE_CAPACITY_TYPE_RESET
+ * use capacity information to reset fuel gauge
+ * (only for driver algorithm, can NOT be set by user)
+ */
+#define SEC_FUELGAUGE_CAPACITY_TYPE_RESET (-1)
+/* SEC_FUELGAUGE_CAPACITY_TYPE_RAW
+ * use capacity information from fuel gauge directly
+ */
+#define SEC_FUELGAUGE_CAPACITY_TYPE_RAW 0
+/* SEC_FUELGAUGE_CAPACITY_TYPE_SCALE
+ * rescale capacity by scaling, need min and max value for scaling
+ */
+#define SEC_FUELGAUGE_CAPACITY_TYPE_SCALE 1
+/* SEC_FUELGAUGE_CAPACITY_TYPE_ATOMIC
+ * change capacity value by only -1 or +1
+ * no sudden change of capacity
+ */
+#define SEC_FUELGAUGE_CAPACITY_TYPE_ATOMIC 2
+
+/**
+ * struct sec_bat_adc_table_data - adc to temperature table for sec battery
+ * driver
+ * @adc: adc value
+ * @temperature: temperature(C) * 10
+ */
+struct sec_bat_adc_table_data {
+ int adc;
+ int temperature;
+};
+#define sec_bat_adc_table_data_t \
+ struct sec_bat_adc_table_data
+
+struct sec_bat_adc_region {
+ int min;
+ int max;
+};
+#define sec_bat_adc_region_t \
+ struct sec_bat_adc_region
+
+struct sec_charging_current {
+ int input_current_limit;
+ int fast_charging_current;
+ int full_check_current_1st;
+ int full_check_current_2nd;
+};
+#define sec_charging_current_t \
+ struct sec_charging_current
+
+struct sec_battery_platform_data {
+ /* NO NEED TO BE CHANGED */
+ /* callback functions */
+ void (*initial_check)(void);
+ bool (*bat_gpio_init)(void);
+ bool (*fg_gpio_init)(void);
+ bool (*chg_gpio_init)(void);
+ bool (*is_lpm)(void);
+ bool (*check_jig_status) (void);
+ int (*check_cable_callback)(void);
+ void (*cable_switch_check)(void);
+ void (*cable_switch_normal)(void);
+ bool (*check_cable_result_callback)(int);
+ bool (*check_battery_callback)(void);
+ bool (*check_battery_result_callback)(void);
+ int (*ovp_uvlo_callback)(void);
+ bool (*ovp_uvlo_result_callback)(int);
+ bool (*fuelalert_process)(bool);
+ bool (*get_temperature_callback)(
+ enum power_supply_property,
+ union power_supply_propval*);
+
+ /* ADC API for each ADC type */
+ sec_bat_adc_api_t adc_api[SEC_BATTERY_ADC_TYPE_NUM];
+ /* ADC region by power supply type
+ * ADC region should be exclusive
+ */
+ sec_bat_adc_region_t *cable_adc_value;
+ /* charging current for type (0: not use) */
+ sec_charging_current_t *charging_current;
+ int *polling_time;
+ /* NO NEED TO BE CHANGED */
+
+ char *pmic_name;
+
+ /* battery */
+ char *vendor;
+ int technology;
+ int battery_type;
+ void *battery_data;
+
+ int bat_gpio_ta_nconnected;
+ /* 1 : active high, 0 : active low */
+ int bat_polarity_ta_nconnected;
+ int bat_irq;
+ unsigned long bat_irq_attr;
+ sec_battery_cable_check_t cable_check_type;
+ sec_battery_cable_source_t cable_source_type;
+
+ bool use_LED; /* use charging LED */
+
+ bool event_check;
+ /* sustaining event after deactivated (second) */
+ unsigned int event_waiting_time;
+
+ /* Monitor setting */
+ sec_battery_monitor_polling_t polling_type;
+ /* for initial check */
+ unsigned int monitor_initial_count;
+
+ /* Battery check */
+ sec_battery_check_t battery_check_type;
+ /* how many times do we need to check battery */
+ unsigned int check_count;
+ /* ADC */
+ /* battery check ADC maximum value */
+ unsigned int check_adc_max;
+ /* battery check ADC minimum value */
+ unsigned int check_adc_min;
+
+ /* OVP/UVLO check */
+ sec_battery_ovp_uvlo_t ovp_uvlo_check_type;
+
+ sec_battery_thermal_source_t thermal_source;
+ sec_bat_adc_table_data_t *temp_adc_table;
+ unsigned int temp_adc_table_size;
+ sec_bat_adc_table_data_t *temp_amb_adc_table;
+ unsigned int temp_amb_adc_table_size;
+
+ sec_battery_temp_check_t temp_check_type;
+ unsigned int temp_check_count;
+ /*
+ * limit can be ADC value or Temperature
+ * depending on temp_check_type
+ * temperature should be temp x 10 (0.1 degree)
+ */
+ int temp_high_threshold_event;
+ int temp_high_recovery_event;
+ int temp_low_threshold_event;
+ int temp_low_recovery_event;
+ int temp_high_threshold_normal;
+ int temp_high_recovery_normal;
+ int temp_low_threshold_normal;
+ int temp_low_recovery_normal;
+ int temp_high_threshold_lpm;
+ int temp_high_recovery_lpm;
+ int temp_low_threshold_lpm;
+ int temp_low_recovery_lpm;
+
+ sec_battery_full_charged_t full_check_type;
+ unsigned int full_check_count;
+ /* ADC for single termination */
+ unsigned int full_check_adc_1st;
+ /* ADC for dual termination */
+ unsigned int full_check_adc_2nd;
+ int chg_gpio_full_check;
+ /* 1 : active high, 0 : active low */
+ int chg_polarity_full_check;
+ sec_battery_full_condition_t full_condition_type;
+ unsigned int full_condition_soc;
+ unsigned int full_condition_avgvcell;
+ unsigned int full_condition_ocv;
+
+ sec_battery_recharge_condition_t recharge_condition_type;
+ unsigned int recharge_condition_soc;
+ unsigned int recharge_condition_avgvcell;
+ unsigned int recharge_condition_vcell;
+
+ /* for absolute timer (second) */
+ unsigned long charging_total_time;
+ /* for recharging timer (second) */
+ unsigned long recharging_total_time;
+ /* reset charging for abnormal malfunction (0: not use) */
+ unsigned long charging_reset_time;
+
+ /* fuel gauge */
+ char *fuelgauge_name;
+ int fg_irq;
+ unsigned long fg_irq_attr;
+ /* fuel alert SOC (-1: not use) */
+ int fuel_alert_soc;
+ /* fuel alert can be repeated */
+ bool repeated_fuelalert;
+ sec_fuelgauge_capacity_type_t capacity_calculation_type;
+ /* soc should be soc x 10 (0.1% degree)
+ * only for scaling
+ */
+ unsigned int capacity_max;
+ unsigned int capacity_min;
+
+ /* charger */
+ char *charger_name;
+ int chg_gpio_en;
+ /* 1 : active high, 0 : active low */
+ int chg_polarity_en;
+ int chg_gpio_curr_adj;
+ /* 1 : active high, 0 : active low */
+ int chg_polarity_curr_adj;
+ int chg_gpio_status;
+ /* 1 : active high, 0 : active low */
+ int chg_polarity_status;
+ int chg_irq;
+ unsigned long chg_irq_attr;
+ /* float voltage (mV) */
+ int chg_float_voltage;
+
+ /* ADC setting */
+ unsigned int adc_check_count;
+ /* ADC type for each channel */
+ unsigned int adc_type[];
+};
+#define sec_battery_platform_data_t \
+ struct sec_battery_platform_data
+
+static inline struct power_supply *get_power_supply_by_name(char *name)
+{
+ if (!name)
+ return (struct power_supply *)NULL;
+ else
+ return power_supply_get_by_name(name);
+}
+
+#define psy_do_property(name, function, property, value) \
+{ \
+ struct power_supply *psy; \
+ int ret; \
+ psy = get_power_supply_by_name((name)); \
+ if (!psy) { \
+ pr_err("%s: Fail to "#function" psy (%s)\n", \
+ __func__, (name)); \
+ value.intval = 0; \
+ } else { \
+ ret = psy->function##_property(psy, (property), &(value)); \
+ if (ret < 0) { \
+ pr_err("%s: Fail to "#name" "#function" (%d=>%d)\n", \
+ __func__, (property), ret); \
+ value.intval = 0; \
+ } \
+ } \
+}
+
+#define adc_init(pdev, pdata, channel) \
+ ((pdata)->adc_api)[((pdata)->adc_type[(channel)])].init((pdev))
+
+#define adc_exit(pdata, channel) \
+ ((pdata)->adc_api)[((pdata)->adc_type[(channel)])].exit()
+
+#define adc_read(pdata, channel) \
+ ((pdata)->adc_api)[((pdata)->adc_type[(channel)])].read((channel))
+
+#define get_battery_data(driver) \
+ (((struct battery_data_t *)(driver)->pdata->battery_data) \
+ [(driver)->pdata->battery_type])
+
+#endif /* __SEC_CHARGING_COMMON_H */
diff --git a/include/linux/battery/sec_fuelgauge.h b/include/linux/battery/sec_fuelgauge.h
new file mode 100644
index 0000000..c3c3ab6
--- /dev/null
+++ b/include/linux/battery/sec_fuelgauge.h
@@ -0,0 +1,127 @@
+/*
+ * sec_fuelgauge.h
+ * Samsung Mobile Fuel Gauge Header
+ *
+ * Copyright (C) 2012 Samsung Electronics, Inc.
+ *
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef __SEC_FUELGAUGE_H
+#define __SEC_FUELGAUGE_H __FILE__
+
+#include <linux/battery/sec_charging_common.h>
+
+#if defined(CONFIG_FUELGAUGE_DUMMY)
+#include <linux/battery/fuelgauge/dummy_fuelgauge.h>
+#elif defined(CONFIG_FUELGAUGE_MAX17042)
+#include <linux/battery/fuelgauge/max17042_fuelgauge.h>
+#elif defined(CONFIG_FUELGAUGE_MAX17048)
+#include <linux/battery/fuelgauge/max17048_fuelgauge.h>
+#elif defined(CONFIG_FUELGAUGE_MAX17050)
+#include <linux/battery/fuelgauge/max17050_fuelgauge.h>
+#endif
+
+struct sec_fuelgauge_reg_data {
+ u8 reg_addr;
+ u8 reg_data1;
+ u8 reg_data2;
+};
+
+static enum power_supply_property sec_fuelgauge_props[] = {
+ POWER_SUPPLY_PROP_STATUS,
+ POWER_SUPPLY_PROP_VOLTAGE_NOW,
+ POWER_SUPPLY_PROP_VOLTAGE_AVG,
+ POWER_SUPPLY_PROP_CURRENT_NOW,
+ POWER_SUPPLY_PROP_CURRENT_AVG,
+ POWER_SUPPLY_PROP_CAPACITY,
+ POWER_SUPPLY_PROP_TEMP,
+ POWER_SUPPLY_PROP_TEMP_AMBIENT,
+};
+
+struct sec_fuelgauge_info {
+ struct i2c_client *client;
+ sec_battery_platform_data_t *pdata;
+ struct power_supply psy_fg;
+ struct delayed_work isr_work;
+
+ int cable_type;
+ bool is_charging;
+
+ /* HW-dedicated fuel guage info structure
+ * used in individual fuel gauge file only
+ * (ex. dummy_fuelgauge.c)
+ */
+ struct sec_fg_info info;
+
+ bool is_fuel_alerted;
+ struct wake_lock fuel_alert_wake_lock;
+
+ unsigned int capacity_old; /* only for atomic calculation */
+
+ bool initial_update_of_soc;
+ struct mutex fg_lock;
+
+ /* register programming */
+ int reg_addr;
+ u8 reg_data[2];
+};
+
+bool sec_hal_fg_init(struct i2c_client *);
+bool sec_hal_fg_suspend(struct i2c_client *);
+bool sec_hal_fg_resume(struct i2c_client *);
+bool sec_hal_fg_fuelalert_init(struct i2c_client *, int);
+bool sec_hal_fg_is_fuelalerted(struct i2c_client *);
+bool sec_hal_fg_fuelalert_process(void *, bool);
+bool sec_hal_fg_full_charged(struct i2c_client *);
+bool sec_hal_fg_reset(struct i2c_client *);
+bool sec_hal_fg_get_property(struct i2c_client *,
+ enum power_supply_property,
+ union power_supply_propval *);
+bool sec_hal_fg_set_property(struct i2c_client *,
+ enum power_supply_property,
+ const union power_supply_propval *);
+
+ssize_t sec_hal_fg_show_attrs(struct device *dev,
+ const ptrdiff_t offset, char *buf);
+
+ssize_t sec_hal_fg_store_attrs(struct device *dev,
+ const ptrdiff_t offset,
+ const char *buf, size_t count);
+
+ssize_t sec_fg_show_attrs(struct device *dev,
+ struct device_attribute *attr, char *buf);
+
+ssize_t sec_fg_store_attrs(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count);
+
+#define SEC_FG_ATTR(_name) \
+{ \
+ .attr = {.name = #_name, .mode = 0666}, \
+ .show = sec_fg_show_attrs, \
+ .store = sec_fg_store_attrs, \
+}
+
+static struct device_attribute sec_fg_attrs[] = {
+ SEC_FG_ATTR(reg),
+ SEC_FG_ATTR(data),
+ SEC_FG_ATTR(regs),
+};
+
+enum {
+ FG_REG = 0,
+ FG_DATA,
+ FG_REGS,
+};
+
+#endif /* __SEC_FUELGAUGE_H */