aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/power
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/power')
-rw-r--r--include/linux/power/charger-manager.h242
-rw-r--r--include/linux/power/max17042_battery.h2
-rw-r--r--include/linux/power/max17042_fuelgauge_px.h382
-rw-r--r--include/linux/power/max17042_fuelgauge_u1.h86
-rw-r--r--include/linux/power/max8922_charger_u1.h22
-rw-r--r--include/linux/power/sec_battery_px.h81
-rw-r--r--include/linux/power/sec_battery_u1.h85
-rw-r--r--include/linux/power/smb136_charger.h28
-rw-r--r--include/linux/power/smb136_charger_q1.h101
-rw-r--r--include/linux/power/smb328_charger.h104
-rwxr-xr-xinclude/linux/power/smb347_charger.h40
11 files changed, 1173 insertions, 0 deletions
diff --git a/include/linux/power/charger-manager.h b/include/linux/power/charger-manager.h
new file mode 100644
index 0000000..95bca90
--- /dev/null
+++ b/include/linux/power/charger-manager.h
@@ -0,0 +1,242 @@
+/* linux/include/linux/power/charger-manager.h
+ *
+ * Copyright (C) 2011 Samsung Electronics Co., Ltd.
+ * MyungJoo.Ham <myungjoo.ham@samsung.com>
+ *
+ * Charger Manager.
+ * This framework enables to control and multiple chargers and to
+ * monitor charging even in the context of suspend-to-RAM with
+ * an interface combining the chargers.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+**/
+
+#ifndef __SAMSUNG_DEV_CHARGER_H
+#define __SAMSUNG_DEV_CHARGER_H
+
+#include <linux/power_supply.h>
+#include <linux/extcon.h>
+
+enum data_source {
+ CM_ASSUME_ALWAYS_TRUE,
+ CM_ASSUME_ALWAYS_FALSE,
+ CM_FUEL_GAUGE,
+ CM_CHARGER_STAT,
+};
+
+enum cm_event_types {
+ CM_EVENT_UNDESCRIBED = 0,
+ CM_EVENT_BATT_FULL,
+ CM_EVENT_BATT_IN,
+ CM_EVENT_BATT_OUT,
+ CM_EVENT_EXT_PWR_IN_OUT,
+ CM_EVENT_CHG_START_STOP,
+ CM_EVENT_OTHERS,
+};
+
+enum polling_modes {
+ CM_POLL_DISABLE = 0,
+ CM_POLL_ALWAYS,
+ /* To use PWR-ONLY option, EXT_PWR_IN_OUT type irqs should exist */
+ CM_POLL_EXTERNAL_POWER_ONLY,
+ /* To use CHG-ONLY option, CHG_START_STOP type irqs should exist */
+ CM_POLL_CHARGING_ONLY,
+};
+
+struct charger_global_desc {
+ /*
+ * For in-suspend monitoring, suspend-again related data is
+ * required. These are used as global for Charger-Manager.
+ * They should work with no_irq with dpm_suspend()'ed environment.
+ *
+ * rtc is the name of RTC used to wakeup the system from
+ * suspend. Previously appointed alarm is saved and restored if
+ * enabled and the alarm time is later than now.
+ */
+ char *rtc;
+
+ /*
+ * If the system is waked up by waekup-sources other than the RTC or
+ * callbacks.setup provided with charger_global_desc, Charger Manager
+ * should recognize with is_rtc_only_wakeup_reason() returning false.
+ * If the RTC given to CM is the only wakeup reason,
+ * is_rtc_only_wakeup_reason should return true.
+ */
+ bool (*is_rtc_only_wakeup_reason)(void);
+
+ /*
+ * Assume that the jiffy timer stops in suspend-to-RAM.
+ * When enabled, CM does not rely on jiffies value in
+ * suspend_again and assumes that jiffies value does not
+ * change during suspend.
+ */
+ bool assume_timer_stops_in_suspend;
+};
+
+#ifdef CONFIG_EXTCON
+struct charger_cable {
+ const char *extcon_name;
+ const char *name;
+
+ /*
+ * Set min/max current of regulator to protect over-current issue
+ * according to a kind of charger cable when cable is attached.
+ */
+ int min_uA;
+ int max_uA;
+
+ /* The charger-manager use Exton framework*/
+ struct extcon_specific_cable_nb extcon_dev;
+ struct work_struct wq;
+ struct notifier_block nb;
+
+ /* The state of charger cable */
+ bool attached;
+
+ struct charger_regulator *charger;
+ struct charger_manager *cm;
+};
+
+struct charger_regulator {
+ /* The name of regulator for charging */
+ const char *regulator_name;
+ struct regulator *consumer;
+
+ /*
+ * Store constraint information related to current limit,
+ * each cable have different condition for charging.
+ */
+ struct charger_cable *cables;
+ int num_cables;
+};
+#endif
+
+struct charger_desc {
+ /*
+ * The name of psy (power-supply-class) entry.
+ * If psy_name is NULL, "battery" is used.
+ */
+ char *psy_name;
+
+ /* The manager may poll with shorter interval, but not longer. */
+ enum polling_modes polling_mode;
+ unsigned int polling_interval_ms;
+
+ /*
+ * Check voltage drop after the battery is fully charged.
+ * If it has dropped more than fullbatt_vchkdrop_uV after
+ * fullbatt_vchkdrop_ms, CM will restart charging.
+ */
+ unsigned int fullbatt_vchkdrop_ms;
+ unsigned int fullbatt_vchkdrop_uV;
+
+ /*
+ * If it is not being charged and VBATT >= fullbatt_uV,
+ * it is assumed to be full. In order not to use this, set
+ * fullbatt_uV 0.
+ */
+ unsigned int fullbatt_uV;
+
+ /*
+ * How the data is picked up for "PRESENT"?
+ * Are we reading the value from chargers or fuel gauges?
+ */
+ enum data_source battery_present;
+
+ /*
+ * The power-supply entries of psy_charger_stat[i] shows "PRESENT",
+ * "ONLINE", "STATUS (Should notify at least FULL or NOT)" of the
+ * charger-i. "Charging/Discharging/NotCharging" of "STATUS" are
+ * optional and recommended.
+ */
+ char **psy_charger_stat;
+
+ /*
+ * The power-supply entries with VOLTAGE_NOW, CAPACITY,
+ * and "PRESENT".
+ */
+ char *psy_fuel_gauge;
+
+ int (*is_temperature_error)(int *mC);
+ bool measure_ambient_temp;
+ bool measure_battery_temp;
+
+ int soc_margin;
+
+ struct charger_regulator *charger_regulators;
+ int num_charger_regulators;
+};
+
+#define PSY_NAME_MAX 30
+struct charger_manager {
+ struct list_head entry;
+ struct device *dev;
+ struct charger_desc *desc;
+
+ struct power_supply *fuel_gauge;
+ struct power_supply **charger_stat;
+
+ bool cancel_suspend; /* if there is a pending charger event. */
+ bool charger_enabled;
+
+ unsigned long fullbatt_vchk_jiffies_at; /* 0 for N/A */
+ unsigned int fullbatt_vchk_uV;
+ struct delayed_work fullbatt_vchk_work;
+
+ bool user_prohibit;
+ int emergency_stop; /* Do not charge */
+ int last_temp_mC;
+
+ char psy_name_buf[PSY_NAME_MAX + 1]; /* Output to user */
+ struct power_supply charger_psy;
+
+ /*
+ * status saved entering a suspend and if the saved status is
+ * changed at suspend_again, suspend_again STOPs
+ */
+ bool status_save_ext_pwr_inserted;
+ bool status_save_batt;
+
+ int batt_tmu_status;
+};
+
+/* In case IRQs cannot be given and notifications will be given. */
+#ifdef CONFIG_CHARGER_MANAGER
+extern void cm_notify_event(struct power_supply *psy, enum cm_event_types type,
+ char *msg); /* msg: optional */
+extern struct charger_manager *get_charger_manager(char *psy_name);
+extern int setup_charger_manager(struct charger_global_desc *gd);
+extern bool is_charger_manager_active(void);
+extern bool cm_suspend_again(void);
+extern void cm_prohibit_charging(struct charger_manager *cm);
+extern void cm_allow_charging(struct charger_manager *cm);
+#else
+static void __maybe_unused cm_notify_event(struct power_supply *psy,
+ enum cm_event_types type, char *msg)
+{ }
+
+static struct charger_manager __maybe_unused *get_charger_manager(
+ char *psy_name)
+{
+ return NULL;
+}
+
+static void __maybe_unused setup_charger_manager(struct charger_global_desc *gd)
+{ }
+
+static bool __maybe_unused is_charger_manager_active(void)
+{
+ return false;
+}
+
+static bool __maybe_unused cm_suspend_again(void)
+{
+ return false;
+}
+static void __maybe_unused cm_prohibit_charging(struct charger_manager *cm) { }
+static void __maybe_unused cm_allow_charging(struct charger_manager *cm) { }
+#endif
+
+#endif /* __SAMSUNG_DEV_CHARGER_H */
diff --git a/include/linux/power/max17042_battery.h b/include/linux/power/max17042_battery.h
index 7995deb..72ab5d7 100644
--- a/include/linux/power/max17042_battery.h
+++ b/include/linux/power/max17042_battery.h
@@ -25,6 +25,8 @@
struct max17042_platform_data {
bool enable_current_sense;
+
+ const char *psy_name;
};
#endif /* __MAX17042_BATTERY_H_ */
diff --git a/include/linux/power/max17042_fuelgauge_px.h b/include/linux/power/max17042_fuelgauge_px.h
new file mode 100644
index 0000000..c618e4d
--- /dev/null
+++ b/include/linux/power/max17042_fuelgauge_px.h
@@ -0,0 +1,382 @@
+/*
+ * max17042_battery.h
+ * fuel-gauge systems for lithium-ion (Li+) batteries
+ *
+ * Copyright (C) 2010 Samsung Electronics
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _MAX17042_BATTERY_H
+#define _MAX17042_BATTERY_H
+
+#if defined(CONFIG_TARGET_LOCALE_KOR)
+#include <linux/power_supply.h>
+#endif /* CONFIG_TARGET_LOCALE_KOR */
+
+/* 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
+#if defined(CONFIG_TARGET_LOCALE_KOR)
+#define FILTERCFG_REG 0x29
+#define CGAIN_REG 0x2E
+#endif /* CONFIG_TARGET_LOCALE_KOR */
+#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 FG_VOLTAGE_NOW 8
+#define FG_RAW_LEVEL 9
+
+#define LOW_BATT_COMP_RANGE_NUM 5
+#define LOW_BATT_COMP_LEVEL_NUM 2
+#define MAX_LOW_BATT_CHECK_CNT 10
+#define MAX17042_CURRENT_UNIT 15625 / 100000
+
+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;
+ int byd_capacity;
+ int byd_vfcapacity;
+ int byd_low_bat_comp_start_vol;
+ int fuel_alert_line;
+
+ int (*check_jig_status) (void);
+};
+
+struct fuelgauge_info {
+ /* test print count */
+ int pr_cnt;
+ /* battery type */
+ int battery_type;
+ /* full charge comp */
+ u32 prev_fullcap;
+ u32 prev_vffcap;
+ u32 full_charged_cap;
+ /* capacity and vfcapacity */
+ u16 capacity;
+ u16 vfcapacity;
+ int soc_restart_flag;
+ /* cap corruption check */
+ u32 prev_repsoc;
+ u32 prev_vfsoc;
+ u32 prev_remcap;
+ u32 prev_mixcap;
+ u32 prev_fullcapacity;
+ u32 prev_vfcapacity;
+ u32 prev_vfocv;
+ /* low battery comp */
+ int low_batt_comp_cnt[LOW_BATT_COMP_RANGE_NUM][LOW_BATT_COMP_LEVEL_NUM];
+ int check_start_vol;
+ int low_batt_comp_flag;
+ int psoc;
+};
+
+struct max17042_chip {
+ struct i2c_client *client;
+ struct max17042_platform_data *pdata;
+#if defined(CONFIG_TARGET_LOCALE_KOR)
+ struct power_supply battery;
+#endif /* CONFIG_TARGET_LOCALE_KOR */
+ struct fuelgauge_info info;
+ struct mutex fg_lock;
+};
+
+/* Battery parameter */
+/* Current range for P2(not dependent on battery type */
+#if defined(CONFIG_MACH_P2)
+#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_P4NOTE) /* 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
+/* BYD type low battery compensation offset */
+#define BYD_Range5_1_Offset 3318
+#define BYD_Range5_3_Offset 3383
+#define BYD_Range4_1_Offset 3451
+#define BYD_Range4_3_Offset 3618
+#define BYD_Range3_1_Offset 3453
+#define BYD_Range3_3_Offset 3615
+#define BYD_Range2_1_Offset 3447
+#define BYD_Range2_3_Offset 3606
+#define BYD_Range1_1_Offset 3438
+#define BYD_Range1_3_Offset 3591
+#define BYD_Range5_1_Slope 0
+#define BYD_Range5_3_Slope 0
+#define BYD_Range4_1_Slope 53
+#define BYD_Range4_3_Slope 94
+#define BYD_Range3_1_Slope 54
+#define BYD_Range3_3_Slope 92
+#define BYD_Range2_1_Slope 45
+#define BYD_Range2_3_Slope 78
+#define BYD_Range1_1_Slope 0
+#define BYD_Range1_3_Slope 0
+#elif defined(CONFIG_MACH_P8) || defined(CONFIG_MACH_P8LTE)
+/* 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
+#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
+
+enum {
+ POSITIVE = 0,
+ NEGATIVE,
+};
+
+enum {
+ UNKNOWN_TYPE = 0,
+ SDI_BATTERY_TYPE,
+ ATL_BATTERY_TYPE,
+ BYD_BATTERY_TYPE,
+};
+
+#ifdef CONFIG_MACH_P8LTE
+#define SEC_CURR_MEA_ADC_CH 6
+/*N.B. For a given battery type and aboard type both R_ISET and I_topOff
+are constant hence VtopOff = R_ISET * I_topOff should also be a constant
+under the given condns.
+Presently only implementing for P8-LTE, for other, consult with HW.
+For P8-LTE the limit is defined as 0.05C , where C is the battery capacity
+,5100mAh in this case.*/
+#define COUNT_TOP_OFF 3
+#define V_TOP_OFF 165 /* 200mA * 750ohms.(11_11_16) */
+/* #define V_TOP_OFF 208 *//* 250mA(default value) * 750ohms.(11_10_10) */
+#endif
+
+/* Temperature adjust value */
+#define SDI_TRIM1_1 122
+#define SDI_TRIM1_2 8950
+#define SDI_TRIM2_1 200
+#define SDI_TRIM2_2 51000
+
+void fg_periodic_read(void);
+
+extern int fg_reset_soc(void);
+extern int fg_reset_capacity(void);
+extern int fg_adjust_capacity(void);
+extern void fg_low_batt_compensation(u32 level);
+extern int fg_alert_init(void);
+extern void fg_fullcharged_compensation(u32 is_recharging, u32 pre_update);
+extern void fg_check_vf_fullcap_range(void);
+extern int fg_check_cap_corruption(void);
+extern int fg_check_cap_corruption_p4(void);
+extern void fg_set_full_charged(void);
+extern void fg_reset_fullcap_in_fullcharge(void);
+#endif
diff --git a/include/linux/power/max17042_fuelgauge_u1.h b/include/linux/power/max17042_fuelgauge_u1.h
new file mode 100644
index 0000000..6686fef
--- /dev/null
+++ b/include/linux/power/max17042_fuelgauge_u1.h
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2009 Samsung Electronics
+ *
+ * based on max17040_battery.h
+ *
+ * <ms925.kim@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __MAX17042_BATTERY_H_
+#define __MAX17042_BATTERY_H_
+
+/*#define NO_READ_I2C_FOR_MAXIM */
+#if !defined(CONFIG_MACH_Q1_BD) && !defined(CONFIG_MACH_TRATS)
+#define RECAL_SOC_FOR_MAXIM
+#endif
+/*#define LOG_REG_FOR_MAXIM */
+#ifdef RECAL_SOC_FOR_MAXIM
+#define NO_NEED_RECAL_SOC_HW_REV 0x0b /*REV1.0 */
+#endif
+#ifdef LOG_REG_FOR_MAXIM
+#undef RECAL_SOC_FOR_MAXIM
+#endif
+
+#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
+
+#define MAX17042_LONG_DELAY 2000
+#define MAX17042_SHORT_DELAY 0
+
+#define MAX17042_BATTERY_FULL 95
+
+#if defined(CONFIG_TARGET_LOCALE_KOR)
+#if defined(CONFIG_MACH_U1_KOR_LGT)
+#define MAX17042_NEW_RCOMP 0x0070
+#else
+#define MAX17042_NEW_RCOMP 0x0065
+#endif
+#endif
+
+struct max17042_reg_data {
+ u8 reg_addr;
+ u8 reg_data1;
+ u8 reg_data2;
+};
+
+struct max17042_platform_data {
+ int (*battery_online)(void);
+ int (*charger_online)(void);
+ int (*charger_enable)(void);
+ int (*low_batt_cb)(void);
+
+ struct max17042_reg_data *init;
+ int init_size;
+ struct max17042_reg_data *alert_init;
+ int alert_init_size;
+ int alert_gpio;
+ unsigned int alert_irq;
+
+ bool enable_current_sense;
+ bool enable_gauging_temperature;
+
+#ifdef RECAL_SOC_FOR_MAXIM
+ /*check need for re-calculation of soc */
+ bool (*need_soc_recal)(void);
+#endif
+};
+
+#endif
diff --git a/include/linux/power/max8922_charger_u1.h b/include/linux/power/max8922_charger_u1.h
new file mode 100644
index 0000000..058f77e
--- /dev/null
+++ b/include/linux/power/max8922_charger_u1.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2011 Samsung Electronics
+ *
+ * <ms925.kim@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __MAX8922_CHARGER_H_
+#define __MAX8922_CHARGER_H_ __FILE__
+
+struct max8922_platform_data {
+ int (*topoff_cb)(void);
+ int (*cfg_gpio)(void);
+ int gpio_chg_en;
+ int gpio_chg_ing;
+ int gpio_ta_nconnected;
+};
+
+#endif /* __MAX8922_CHARGER_H_ */
diff --git a/include/linux/power/sec_battery_px.h b/include/linux/power/sec_battery_px.h
new file mode 100644
index 0000000..7b8dadc
--- /dev/null
+++ b/include/linux/power/sec_battery_px.h
@@ -0,0 +1,81 @@
+/*
+ * sec_battery.h
+ * charger systems for lithium-ion (Li+) batteries
+ *
+ * Copyright (C) 2010 Samsung Electronics
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _LINUX_SEC_BATTERY_H
+#define _LINUX_SEC_BATTERY_H
+
+enum charger_type {
+ CHARGER_BATTERY = 0,
+ CHARGER_USB,
+ CHARGER_AC,
+ CHARGER_DOCK,
+ CHARGER_MISC,
+ CHARGER_DISCHARGE
+};
+
+struct max8903_charger_data {
+ int enable_line;
+ int connect_line;
+ int fullcharge_line;
+ int currentset_line;
+ int accessory_line;
+};
+
+struct sec_battery_platform_data {
+ struct max8903_charger_data charger;
+
+ void (*set_charging_state) (int, int);
+ int (*get_charging_state) (void);
+ void (*set_charging_current) (int);
+ int (*get_charging_current) (void);
+ int (*get_charger_is_full)(void);
+
+ void (*init_charger_gpio) (void);
+ void (*inform_charger_connection) (int);
+ int temp_high_threshold;
+ int temp_high_recovery;
+ int temp_low_recovery;
+ int temp_low_threshold;
+ int charge_duration;
+ int recharge_duration;
+ int recharge_voltage;
+ int (*check_lp_charging_boot) (void);
+ int (*check_jig_status) (void);
+
+};
+
+/* for test driver */
+#define __TEST_DEVICE_DRIVER__
+
+enum capacity_type {
+ CAPACITY_TYPE_FULL = 0,
+ CAPACITY_TYPE_MIX,
+ CAPACITY_TYPE_AV,
+ CAPACITY_TYPE_REP,
+};
+
+enum dock_type {
+ DOCK_NONE = 0,
+ DOCK_DESK,
+ DOCK_KEYBOARD,
+};
+
+extern int low_batt_compensation(int fg_soc, int fg_vcell, int fg_current);
+extern void reset_low_batt_comp_cnt(void);
+extern int get_fuelgauge_value(int data);
+extern struct max17042_chip *max17042_chip_data;
+extern int get_fuelgauge_capacity(enum capacity_type type);
+
+#if defined(CONFIG_STMPE811_ADC)
+u16 stmpe811_get_adc_data(u8 channel);
+#endif
+
+#endif
diff --git a/include/linux/power/sec_battery_u1.h b/include/linux/power/sec_battery_u1.h
new file mode 100644
index 0000000..1d214c9
--- /dev/null
+++ b/include/linux/power/sec_battery_u1.h
@@ -0,0 +1,85 @@
+/*
+ * 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_SEC_BATTERY_H
+#define __MACH_SEC_BATTERY_H __FILE__
+
+#if defined(CONFIG_TARGET_LOCALE_KOR)
+#if defined(CONFIG_MACH_U1_KOR_LGT)
+#define HWREV_FOR_BATTERY 0x03
+#else
+#define HWREV_FOR_BATTERY 0x06
+#endif
+#elif defined(CONFIG_TARGET_LOCALE_NTT)
+#define HWREV_FOR_BATTERY 0x0C
+#elif defined(CONFIG_MACH_U1_NA_SPR_EPIC2_REV00)
+#define HWREV_FOR_BATTERY 0x06
+#elif defined(CONFIG_MACH_Q1_BD)
+#define HWREV_FOR_BATTERY 0x02
+#elif defined(CONFIG_MACH_TRATS)
+#define HWREV_FOR_BATTERY 0x02
+#else /*U1 EUR OPEN */
+#define HWREV_FOR_BATTERY 0x08
+#endif
+
+/*soc level for 3.6V */
+#define SEC_BATTERY_SOC_3_6 7
+
+/* #define SEC_BATTERY_TOPOFF_BY_CHARGER */
+#define SEC_BATTERY_INDEPEDENT_VF_CHECK
+#if defined(CONFIG_MACH_Q1_BD)
+#define SEC_BATTERY_1ST_2ND_TOPOFF
+#endif
+
+/**
+ * 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;
+};
+
+/**
+ * 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
+ * @sub_charger_name: power supply name of sub-charger
+ * @adc_table: array of adc to temperature data
+ * @adc_arr_size: size of adc_table
+ * @irq_topoff: IRQ number for top-off interrupt
+ * @irq_lowbatt: IRQ number for low battery alert interrupt
+ */
+struct sec_bat_platform_data {
+ char *fuel_gauge_name;
+ char *charger_name;
+ char *sub_charger_name;
+
+ unsigned int adc_arr_size;
+ struct sec_bat_adc_table_data *adc_table;
+ unsigned int adc_channel;
+ unsigned int adc_sub_arr_size;
+ struct sec_bat_adc_table_data *adc_sub_table;
+ unsigned int adc_sub_channel;
+ unsigned int (*get_lpcharging_state) (void);
+ void (*no_bat_cb) (void);
+ void (*initial_check) (void);
+#if defined(CONFIG_TARGET_LOCALE_NAATT)
+ int adc_vf_channel;
+#endif
+};
+
+#endif /* __MACH_SEC_BATTERY_H */
diff --git a/include/linux/power/smb136_charger.h b/include/linux/power/smb136_charger.h
new file mode 100644
index 0000000..a6414d8
--- /dev/null
+++ b/include/linux/power/smb136_charger.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2011 Samsung Electronics
+ * Ikkeun Kim <iks.kim@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __SMB136_CHARGER_H_
+#define __SMB136_CHARGER_H_
+
+struct smb_charger_callbacks {
+ void (*set_charging_state) (int, int);
+ int (*get_charging_state) (void);
+ void (*set_charging_current) (int);
+ int (*get_charging_current) (void);
+};
+
+struct smb_charger_data {
+ void (*register_callbacks)(struct smb_charger_callbacks *);
+ void (*unregister_callbacks)(void);
+ int enable;
+ int stat;
+ int ta_nconnected;
+};
+
+#endif
diff --git a/include/linux/power/smb136_charger_q1.h b/include/linux/power/smb136_charger_q1.h
new file mode 100644
index 0000000..4658ef6
--- /dev/null
+++ b/include/linux/power/smb136_charger_q1.h
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2011 Samsung Electronics
+ * Ikkeun Kim <iks.kim@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __SMB136_CHARGER_H_
+#define __SMB136_CHARGER_H_
+
+#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 <plat/gpio-cfg.h>
+#include <linux/power/sec_battery_u1.h>
+
+/* Slave address */
+#define SMB136_SLAVE_ADDR 0x9A
+
+/* SMB136 Registers. */
+#define SMB_ChargeCurrent 0x00
+#define SMB_InputCurrentLimit 0x01
+#define SMB_FloatVoltage 0x02
+#define SMB_ControlA 0x03
+#define SMB_ControlB 0x04
+#define SMB_PinControl 0x05
+#define SMB_OTGControl 0x06
+#define SMB_Fault 0x07
+#define SMB_Temperature 0x08
+#define SMB_SafetyTimer 0x09
+#define SMB_VSYS 0x0A
+#define SMB_I2CAddr 0x0B
+
+#define SMB_IRQreset 0x30
+#define SMB_CommandA 0x31
+#define SMB_StatusA 0x32
+#define SMB_StatusB 0x33
+#define SMB_StatusC 0x34
+#define SMB_StatusD 0x35
+#define SMB_StatusE 0x36
+#define SMB_StatusF 0x37
+#define SMB_StatusG 0x38
+#define SMB_StatusH 0x39
+#define SMB_DeviceID 0x3B
+#define SMB_CommandB 0x3C
+
+/* SMB_StatusC register bit. */
+#define SMB_USB 1
+#define SMB_CHARGER 0
+#define Compelete 1
+#define Busy 0
+#define InputCurrent275 0xE
+#define InputCurrent500 0xF
+#define InputCurrent700 0x0
+#define InputCurrent800 0x1
+#define InputCurrent900 0x2
+#define InputCurrent1000 0x3
+#define InputCurrent1100 0x4
+#define InputCurrent1200 0x5
+#define InputCurrent1300 0x6
+#define InputCurrent1400 0x7
+
+static enum power_supply_property smb136_charger_props[] = {
+ POWER_SUPPLY_PROP_CHARGE_TYPE,
+ POWER_SUPPLY_PROP_STATUS,
+ POWER_SUPPLY_PROP_ONLINE,
+ POWER_SUPPLY_PROP_CURRENT_NOW,
+};
+
+struct smb136_platform_data {
+ int (*topoff_cb)(void);
+#if defined(CONFIG_MACH_Q1_CHN) && defined(CONFIG_SMB136_CHARGER)
+ int (*ovp_cb)(bool);
+#endif
+ void (*set_charger_name)(void);
+ int gpio_chg_en;
+ int gpio_otg_en;
+ int gpio_chg_ing;
+ int gpio_ta_nconnected;
+};
+
+struct smb136_chip {
+ struct i2c_client *client;
+ struct power_supply charger;
+ struct smb136_platform_data *pdata;
+
+ bool is_enable;
+ int cable_type;
+};
+
+#endif
diff --git a/include/linux/power/smb328_charger.h b/include/linux/power/smb328_charger.h
new file mode 100644
index 0000000..c72e9f9
--- /dev/null
+++ b/include/linux/power/smb328_charger.h
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2011 Samsung Electronics
+ * Ikkeun Kim <iks.kim@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __SMB328_CHARGER_H_
+#define __SMB328_CHARGER_H_
+
+#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 <plat/gpio-cfg.h>
+#include <linux/power/sec_battery_u1.h>
+
+/* Slave address */
+#define SMB328_SLAVE_ADDR 0x69
+
+/* 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
+
+/* fast charging current defines */
+#define FAST_500mA 500
+#define FAST_600mA 600
+#define FAST_700mA 700
+#define FAST_800mA 800
+#define FAST_900mA 900
+#define FAST_1000mA 1000
+#define FAST_1100mA 1100
+#define FAST_1200mA 1200
+
+/* input current limit defines */
+#define ICL_275mA 275
+#define ICL_450mA 450
+#define ICL_600mA 600
+#define ICL_700mA 700
+#define ICL_800mA 800
+#define ICL_900mA 900
+#define ICL_1000mA 1000
+#define ICL_1100mA 1100
+#define ICL_1200mA 1200
+
+static enum power_supply_property smb328_charger_props[] = {
+ POWER_SUPPLY_PROP_CHARGE_TYPE,
+ POWER_SUPPLY_PROP_STATUS,
+ POWER_SUPPLY_PROP_ONLINE,
+ POWER_SUPPLY_PROP_CURRENT_NOW,
+};
+
+struct smb328_platform_data {
+ int (*topoff_cb)(void);
+#if defined(CONFIG_MACH_Q1_CHN) && defined(CONFIG_SMB328_CHARGER)
+ int (*ovp_cb)(bool);
+#endif
+ void (*set_charger_name)(void);
+ int gpio_chg_en;
+ int gpio_otg_en;
+ int gpio_chg_ing;
+ int gpio_ta_nconnected;
+};
+
+struct smb328_chip {
+ struct i2c_client *client;
+ struct power_supply charger;
+ struct smb328_platform_data *pdata;
+
+ bool is_otg;
+ bool is_enable;
+ int cable_type;
+};
+
+#endif
diff --git a/include/linux/power/smb347_charger.h b/include/linux/power/smb347_charger.h
new file mode 100755
index 0000000..b8a1974
--- /dev/null
+++ b/include/linux/power/smb347_charger.h
@@ -0,0 +1,40 @@
+/*
+ * smb347_charger.c
+ *
+ * Copyright (C) 2011 Samsung Electronics
+ * SangYoung Son <hello.son@samsung.com>
+ *
+ * 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 __SMB347_CHARGER_H_
+#define __SMB347_CHARGER_H_
+
+struct smb_charger_callbacks {
+ void (*set_charging_state) (int, int);
+ int (*get_charging_state) (void);
+ void (*set_charging_current) (int);
+ int (*get_charging_current) (void);
+ int (*get_charger_is_full) (void);
+ int (*get_aicl_current)(void);
+ int (*get_input_current)(void);
+ void (*set_aicl_state)(int);
+};
+
+struct smb_charger_data {
+ void (*register_callbacks)(struct smb_charger_callbacks *);
+ void (*unregister_callbacks)(void);
+ int enable;
+ int stat;
+ int ta_nconnected;
+};
+
+#endif