Fixed MTP to work with TWRP

This commit is contained in:
awab228 2018-06-19 23:16:04 +02:00
commit f6dfaef42e
50820 changed files with 20846062 additions and 0 deletions

View file

@ -0,0 +1,37 @@
/*
* bq24260_charger.h
* Samsung BQ24260 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 __BQ24260_CHARGER_H
#define __BQ24260_CHARGER_H __FILE__
/* Slave address should be shifted to the right 1bit.
* R/W bit should NOT be included.
*/
#define SEC_CHARGER_I2C_SLAVEADDR (0x6B)
/* BQ24260 Registers. */
#define BQ24260_STATUS 0x00
#define BQ24260_CONTROL 0x01
#define BQ24260_VOLTAGE 0x02
#define BQ24260_VENDOR 0x03
#define BQ24260_CURRENT 0x04
#define BQ24260_SPECIAL 0x05
#define BQ24260_SAFETY 0x06
#endif /* __BQ24260_CHARGER_H */

View file

@ -0,0 +1,135 @@
/*
* p9015_charger.h
* Samsung P9015 Charger Header
*
* Copyright (C) 2014 Samsung Electronics, Inc.
* Yeongmi Ha <yeongmi86.ha@samsung.com>
*
* 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 __BQ51221_CHARGER_H
#define __BQ51221_CHARGER_H __FILE__
#include <linux/mfd/core.h>
#include <linux/regulator/machine.h>
#include <linux/i2c.h>
#include <linux/battery/sec_charging_common.h>
#include <linux/wakelock.h>
/* REGISTER MAPS */
#define BQ51221_REG_CURRENT_REGISTER 0X01
#define BQ51221_REG_CURRENT_REGISTER2 0X02
#define BQ51221_REG_MAILBOX 0XE0
#define BQ51221_REG_POD_RAM 0XE1
#define BQ51221_REG_USER_HEADER 0XE2
#define BQ51221_REG_VRECT_STATUS 0XE3
#define BQ51221_REG_VOUT_STATUS 0XE4
#define BQ51221_REG_PWR_BYTE_STATUS 0XE8
#define BQ51221_REG_INDICATOR 0XEF
#define BQ51221_REG_PROP_PACKET_PAYLOAD 0XF1
/* WPC HEADER */
#define BQ51221_EPT_HEADER_EPT 0x02
#define BQ51221_EPT_HEADER_CS100 0x05
/* END POWER TRANSFER CODES IN WPC */
#define BQ51221_EPT_CODE_UNKOWN 0x00
#define BQ51221_EPT_CODE_CHARGE_COMPLETE 0x01
#define BQ51221_EPT_CODE_INTERNAL_FAULT 0x02
#define BQ51221_EPT_CODE_OVER_TEMPERATURE 0x03
#define BQ51221_EPT_CODE_OVER_VOLTAGE 0x04
#define BQ51221_EPT_CODE_OVER_CURRENT 0x05
#define BQ51221_EPT_CODE_BATTERY_FAILURE 0x06
#define BQ51221_EPT_CODE_RECONFIGURE 0x07
#define BQ51221_EPT_CODE_NO_RESPONSE 0x08
#define BQ51221_POWER_MODE_MASK (0x1 << 0)
#define BQ51221_SEND_USER_PKT_DONE_MASK (0x1 << 7)
#define BQ51221_SEND_USER_PKT_ERR_MASK (0x3 << 5)
#define BQ51221_SEND_ALIGN_MASK (0x1 << 3)
#define BQ51221_SEND_EPT_CC_MASK (0x1 << 0)
#define BQ51221_SEND_EOC_MASK (0x1 << 0)
#define BQ51221_CS100_VALUE 0x64
#define BQ51221_IOREG_100_VALUE 0x07
#define BQ51221_IOREG_90_VALUE 0x06
#define BQ51221_IOREG_60_VALUE 0x05
#define BQ51221_IOREG_50_VALUE 0x04
#define BQ51221_IOREG_40_VALUE 0x03
#define BQ51221_IOREG_30_VALUE 0x02
#define BQ51221_IOREG_20_VALUE 0x01
#define BQ51221_IOREG_10_VALUE 0x00
#define BQ51221_PTK_ERR_NO_ERR 0x00
#define BQ51221_PTK_ERR_ERR 0x01
#define BQ51221_PTK_ERR_ILLEGAL_HD 0x02
#define BQ51221_PTK_ERR_NO_DEF 0x03
enum {
END_POWER_TRANSFER_CODE_UNKOWN = 0,
END_POWER_TRANSFER_CODE_CHARGECOMPLETE,
END_POWER_TRANSFER_CODE_INTERNAL_FAULT,
END_POWER_TRANSFER_CODE_OVER_TEMPERATURE,
END_POWER_TRANSFER_CODE_OVER_VOLTAGE,
END_POWER_TRANSFER_CODE_OVER_CURRENT,
END_POWER_TRANSFER_CODE_BATTERY_FAILURE,
END_POWER_TRANSFER_CODE_RECONFIGURE,
END_POWER_TRANSFER_CODE_NO_RESPONSE,
};
struct bq51221_charger_platform_data {
int irq_gpio;
int irq_base;
int tsb_gpio;
int cs100_status;
int pad_mode;
int wireless_cc_cv;
int siop_level;
bool default_voreg;
char *wireless_charger_name;
};
#define bq51221_charger_platform_data_t \
struct bq51221_charger_platform_data
struct bq51221_charger_data {
struct i2c_client *client;
struct device *dev;
bq51221_charger_platform_data_t *pdata;
struct mutex io_lock;
struct power_supply psy_chg;
struct wake_lock wpc_wake_lock;
struct workqueue_struct *wqueue;
struct work_struct chgin_work;
struct delayed_work wpc_work;
struct delayed_work isr_work;
int chg_irq;
int irq_base;
int irq_gpio;
int wpc_state;
};
enum {
BQ51221_EVENT_IRQ = 0,
BQ51221_IRQS_NR,
};
enum {
BQ51221_PAD_MODE_NONE = 0,
BQ51221_PAD_MODE_WPC,
BQ51221_PAD_MODE_PMA,
};
#endif /* __BQ51221_CHARGER_H */

View file

@ -0,0 +1,154 @@
/*
* MAX77693_charger.h
* Samsung MAX77693 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 __MAX77693_CHARGER_H
#define __MAX77693_CHARGER_H __FILE__
#include <linux/mfd/core.h>
#include <linux/mfd/max77693.h>
#include <linux/mfd/max77693-private.h>
#include <linux/regulator/machine.h>
#define ENABLE 1
#define DISABLE 0
/* 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))
/*
* Use for battery
*/
#define OFF_CURR 0 /* charger off current */
#define KEEP_CURR -1 /* keep previous current */
/* MAX77693_CHG_REG_CHG_INT */
#define MAX77693_BYP_I (1 << 0)
#define MAX77693_BATP_I (1 << 2)
#define MAX77693_BAT_I (1 << 3)
#define MAX77693_CHG_I (1 << 4)
#define MAX77693_WCIN_I (1 << 5)
#define MAX77693_CHGIN_I (1 << 6)
/* MAX77693_CHG_REG_CHG_INT_MASK */
#define MAX77693_BYP_IM (1 << 0)
#define MAX77693_THM_IM (1 << 2)
#define MAX77693_BAT_IM (1 << 3)
#define MAX77693_CHG_IM (1 << 4)
#define MAX77693_WCIN_IM (1 << 5)
#define MAX77693_CHGIN_IM (1 << 6)
/* MAX77693_CHG_REG_CHG_INT_OK */
#define MAX77693_BYP_OK 0x01
#define MAX77693_BYP_OK_SHIFT 0
#define MAX77693_BATP_OK 0x04
#define MAX77693_BATP_OK_SHIFT 2
#define MAX77693_BAT_OK 0x08
#define MAX77693_BAT_OK_SHIFT 3
#define MAX77693_CHG_OK 0x10
#define MAX77693_CHG_OK_SHIFT 4
#define MAX77693_WCIN_OK 0x20
#define MAX77693_WCIN_OK_SHIFT 5
#define MAX77693_CHGIN_OK 0x40
#define MAX77693_CHGIN_OK_SHIFT 6
#define MAX77693_DETBAT 0x04
#define MAX77693_DETBAT_SHIFT 2
/* MAX77693_CHG_REG_CHG_DTLS_00 */
#define MAX77693_BATP_DTLS 0x01
#define MAX77693_BATP_DTLS_SHIFT 0
#define MAX77693_WCIN_DTLS 0x18
#define MAX77693_WCIN_DTLS_SHIFT 3
#define MAX77693_CHGIN_DTLS 0x60
#define MAX77693_CHGIN_DTLS_SHIFT 5
/* MAX77693_CHG_REG_CHG_DTLS_01 */
#define MAX77693_CHG_DTLS 0x0F
#define MAX77693_CHG_DTLS_SHIFT 0
#define MAX77693_BAT_DTLS 0x70
#define MAX77693_BAT_DTLS_SHIFT 4
/* MAX77693_CHG_REG_CHG_DTLS_02 */
#define MAX77693_BYP_DTLS 0x0F
#define MAX77693_BYP_DTLS_SHIFT 0
#define MAX77693_BYP_DTLS0 0x1
#define MAX77693_BYP_DTLS1 0x2
#define MAX77693_BYP_DTLS2 0x4
#define MAX77693_BYP_DTLS3 0x8
/* MAX77693_CHG_REG_CHG_CNFG_00 */
#define MAX77693_MODE_DEFAULT 0x04
#define MAX77693_MODE_CHGR 0x01
#define MAX77693_MODE_OTG 0x02
#define MAX77693_MODE_BUCK 0x04
/* MAX77693_CHG_REG_CHG_CNFG_02 */
#define MAX77693_CHG_CC 0x3F
/* MAX77693_CHG_REG_CHG_CNFG_03 */
#define MAX77693_CHG_TO_ITH 0x07
/* MAX77693_CHG_REG_CHG_CNFG_04 */
#define MAX77693_CHG_MINVSYS_MASK 0xE0
#define MAX77693_CHG_MINVSYS_SHIFT 5
#define MAX77693_CHG_PRM_MASK 0x1F
#define MAX77693_CHG_PRM_SHIFT 0
/* MAX77693_CHG_REG_CHG_CNFG_09 */
#define MAX77693_CHG_CHGIN_LIM 0x7F
/* MAX77693_CHG_REG_CHG_CNFG_12 */
#define MAX77693_CHG_WCINSEL 0x40
/* MAX77693_MUIC_REG_CDETCTRL1 */
#define MAX77693_CHGTYPMAN 0x02
#define MAX77693_CHGTYPMAN_SHIFT 1
/* MAX77693_MUIC_REG_STATUS2 */
#define MAX77693_VBVOLT 0x40
#define MAX77693_VBVOLT_SHIFT 6
#define MAX77693_CHGDETRUN 0x08
#define MAX77693_CHGDETRUN_SHIFT 3
#define MAX77693_CHGTYPE 0x07
#define MAX77693_CHGTYPE_SHIFT 0
/* irq */
#define IRQ_DEBOUNCE_TIME 20 /* msec */
/* charger type detection */
#define DET_ERR_RETRY 5
#define DET_ERR_DELAY 200
/* soft charging */
#define SOFT_CHG_START_CURR 100 /* mA */
#define SOFT_CHG_START_DUR 100 /* ms */
#define SOFT_CHG_CURR_STEP 100 /* mA */
#define SOFT_CHG_STEP_DUR 20 /* ms */
#define DEFAULT_AC_CURRENT 1600 /* mA */
#define DEFAULT_USB_CURRENT 500 /* mA */
enum {
POWER_SUPPLY_VBUS_UNKNOWN = 0,
POWER_SUPPLY_VBUS_UVLO,
POWER_SUPPLY_VBUS_WEAK,
POWER_SUPPLY_VBUS_OVLO,
POWER_SUPPLY_VBUS_GOOD,
};
extern sec_battery_platform_data_t sec_battery_pdata;
#endif

View file

@ -0,0 +1,182 @@
/*
* max77804_charger.h
* Samsung max77804 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 __MAX77804_CHARGER_H
#define __MAX77804_CHARGER_H __FILE__
#include <linux/mfd/core.h>
#include <linux/mfd/max77804.h>
#include <linux/mfd/max77804-private.h>
#include <linux/regulator/machine.h>
#if defined(CONFIG_V1A) || defined(CONFIG_N1A)
#define max77888_charger
#else
#undef max77888_charger
#endif
#define ENABLE 1
#define DISABLE 0
/* 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))
/*
* Use for battery
*/
#define OFF_CURR 0 /* charger off current */
#define KEEP_CURR -1 /* keep previous current */
/* MAX77803 CHG_CNFG_04 register */
#define CHG_CNFG_04_CHG_CV_PRM_SHIFT 0
#define CHG_CNFG_04_CHG_CV_PRM_MASK (0x1f << CHG_CNFG_04_CHG_CV_PRM_SHIFT)
/* MAX77803 CHG_CNFG_12 register */
#define CHG_CNFG_12_CHGINSEL_SHIFT 5
#define CHG_CNFG_12_CHGINSEL_MASK (0x1 << CHG_CNFG_12_CHGINSEL_SHIFT)
/* MAX77804_CHG_REG_CHG_INT */
#define MAX77804_BYP_I (1 << 0)
#define MAX77804_BATP_I (1 << 2)
#define MAX77804_BAT_I (1 << 3)
#define MAX77804_CHG_I (1 << 4)
#define MAX77804_WCIN_I (1 << 5)
#define MAX77804_CHGIN_I (1 << 6)
/* MAX77804_CHG_REG_CHG_INT_MASK */
#define MAX77804_BYP_IM (1 << 0)
#define MAX77804_THM_IM (1 << 2)
#define MAX77804_BAT_IM (1 << 3)
#define MAX77804_CHG_IM (1 << 4)
#define MAX77804_WCIN_IM (1 << 5)
#define MAX77804_CHGIN_IM (1 << 6)
/* MAX77804_CHG_REG_CHG_INT_OK */
#define MAX77804_BYP_OK 0x01
#define MAX77804_BYP_OK_SHIFT 0
#define MAX77804_BATP_OK 0x04
#define MAX77804_BATP_OK_SHIFT 2
#define MAX77804_BAT_OK 0x08
#define MAX77804_BAT_OK_SHIFT 3
#define MAX77804_CHG_OK 0x10
#define MAX77804_CHG_OK_SHIFT 4
#define MAX77804_WCIN_OK 0x20
#define MAX77804_WCIN_OK_SHIFT 5
#define MAX77804_CHGIN_OK 0x40
#define MAX77804_CHGIN_OK_SHIFT 6
#define MAX77804_DETBAT 0x04
#define MAX77804_DETBAT_SHIFT 2
/* MAX77804_CHG_REG_CHG_DTLS_00 */
#define MAX77804_BATP_DTLS 0x01
#define MAX77804_BATP_DTLS_SHIFT 0
#define MAX77804_WCIN_DTLS 0x18
#define MAX77804_WCIN_DTLS_SHIFT 3
#define MAX77804_CHGIN_DTLS 0x60
#define MAX77804_CHGIN_DTLS_SHIFT 5
/* MAX77804_CHG_REG_CHG_DTLS_01 */
#define MAX77804_CHG_DTLS 0x0F
#define MAX77804_CHG_DTLS_SHIFT 0
#define MAX77804_BAT_DTLS 0x70
#define MAX77804_BAT_DTLS_SHIFT 4
/* MAX77804_CHG_REG_CHG_DTLS_02 */
#define MAX77804_BYP_DTLS 0x0F
#define MAX77804_BYP_DTLS_SHIFT 0
#define MAX77804_BYP_DTLS0 0x1
#define MAX77804_BYP_DTLS1 0x2
#define MAX77804_BYP_DTLS2 0x4
#define MAX77804_BYP_DTLS3 0x8
/* MAX77804_CHG_REG_CHG_CNFG_00 */
#define MAX77804_MODE_DEFAULT 0x04
#define MAX77804_MODE_CHGR 0x01
#define MAX77804_MODE_OTG 0x02
#define MAX77804_MODE_BUCK 0x04
#define MAX77804_MODE_BOOST 0x08
/* MAX77804_CHG_REG_CHG_CNFG_02 */
#define MAX77804_CHG_CC 0x3F
/* MAX77804_CHG_REG_CHG_CNFG_03 */
#define MAX77804_CHG_TO_ITH 0x07
/* MAX77804_CHG_REG_CHG_CNFG_04 */
#define MAX77804_CHG_MINVSYS_MASK 0xE0
#define MAX77804_CHG_MINVSYS_SHIFT 5
#define MAX77804_CHG_PRM_MASK 0x1F
#define MAX77804_CHG_PRM_SHIFT 0
/* MAX77804_CHG_REG_CHG_CNFG_09 */
#define MAX77804_CHG_CHGIN_LIM 0x7F
/* MAX77804_CHG_REG_CHG_CNFG_12 */
#define MAX77804_CHG_WCINSEL 0x40
/* MAX77804_MUIC_REG_CDETCTRL1 */
#define MAX77804_CHGTYPMAN 0x02
#define MAX77804_CHGTYPMAN_SHIFT 1
/* MAX77804_MUIC_REG_STATUS2 */
#define MAX77804_VBVOLT 0x40
#define MAX77804_VBVOLT_SHIFT 6
#define MAX77804_CHGDETRUN 0x08
#define MAX77804_CHGDETRUN_SHIFT 3
#define MAX77804_CHGTYPE 0x07
#define MAX77804_CHGTYPE_SHIFT 0
/* irq */
#define IRQ_DEBOUNCE_TIME 20 /* msec */
/* charger type detection */
#define DET_ERR_RETRY 5
#define DET_ERR_DELAY 200
/* soft charging */
#define SOFT_CHG_START_CURR 100 /* mA */
#define SOFT_CHG_START_DUR 100 /* ms */
#define SOFT_CHG_CURR_STEP 100 /* mA */
#define SOFT_CHG_STEP_DUR 20 /* ms */
#define DEFAULT_AC_CURRENT 1600 /* mA */
#define DEFAULT_USB_CURRENT 500 /* mA */
enum {
POWER_SUPPLY_VBUS_UNKNOWN = 0,
POWER_SUPPLY_VBUS_UVLO,
POWER_SUPPLY_VBUS_WEAK,
POWER_SUPPLY_VBUS_OVLO,
POWER_SUPPLY_VBUS_GOOD,
};
extern sec_battery_platform_data_t sec_battery_pdata;
#if defined(CONFIG_TARGET_LOCALE_KOR)
#define SEC_CHG_ATTR(_name) \
{ \
.attr = {.name = #_name, .mode = 0664}, \
.show = sec_chg_show_attrs, \
.store = sec_chg_store_attrs, \
}
enum {
CHG_SIOP_INPUT_LIMIT = 0,
};
#endif
#endif

View file

@ -0,0 +1,216 @@
/*
* max77823_charger.h
* Samsung MAX77823 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 __MAX77823_CHARGER_H
#define __MAX77823_CHARGER_H __FILE__
#include <linux/mfd/core.h>
#include <linux/mfd/max77823.h>
#include <linux/mfd/max77823-private.h>
#include <linux/regulator/machine.h>
#define MAX77823_SAFEOUT2 0x80
/* MAX77823_CHG_REG_CHG_INT */
#define MAX77823_BYP_I (1 << 0)
#define MAX77823_BATP_I (1 << 2)
#define MAX77823_BAT_I (1 << 3)
#define MAX77823_CHG_I (1 << 4)
#define MAX77823_WCIN_I (1 << 5)
#define MAX77823_CHGIN_I (1 << 6)
/* MAX77823_CHG_REG_CHG_INT_MASK */
#define MAX77823_BYP_IM (1 << 0)
#define MAX77823_THM_IM (1 << 2)
#define MAX77823_BAT_IM (1 << 3)
#define MAX77823_CHG_IM (1 << 4)
#define MAX77823_WCIN_IM (1 << 5)
#define MAX77823_CHGIN_IM (1 << 6)
/* MAX77823_CHG_REG_CHG_INT_OK */
#define MAX77823_BYP_OK 0x01
#define MAX77823_BYP_OK_SHIFT 0
#define MAX77823_BATP_OK 0x04
#define MAX77823_BATP_OK_SHIFT 2
#define MAX77823_BAT_OK 0x08
#define MAX77823_BAT_OK_SHIFT 3
#define MAX77823_CHG_OK 0x10
#define MAX77823_CHG_OK_SHIFT 4
#define MAX77823_WCIN_OK 0x20
#define MAX77823_WCIN_OK_SHIFT 5
#define MAX77823_CHGIN_OK 0x40
#define MAX77823_CHGIN_OK_SHIFT 6
#define MAX77823_DETBAT 0x04
#define MAX77823_DETBAT_SHIFT 2
/* MAX77823_CHG_REG_CHG_DTLS_00 */
#define MAX77823_BATP_DTLS 0x01
#define MAX77823_BATP_DTLS_SHIFT 0
#define MAX77823_WCIN_DTLS 0x18
#define MAX77823_WCIN_DTLS_SHIFT 3
#define MAX77823_CHGIN_DTLS 0x60
#define MAX77823_CHGIN_DTLS_SHIFT 5
/* MAX77823_CHG_REG_CHG_DTLS_01 */
#define MAX77823_CHG_DTLS 0x0F
#define MAX77823_CHG_DTLS_SHIFT 0
#define MAX77823_BAT_DTLS 0x70
#define MAX77823_BAT_DTLS_SHIFT 4
/* MAX77823_CHG_REG_CHG_DTLS_02 */
#define MAX77823_BYP_DTLS 0x0F
#define MAX77823_BYP_DTLS_SHIFT 0
#define MAX77823_BYP_DTLS0 0x1
#define MAX77823_BYP_DTLS1 0x2
#define MAX77823_BYP_DTLS2 0x4
#define MAX77823_BYP_DTLS3 0x8
/* MAX77823_CHG_REG_CHG_CNFG_00 */
#define CHG_CNFG_00_MODE_SHIFT 0
#define CHG_CNFG_00_CHG_SHIFT 0
#define CHG_CNFG_00_OTG_SHIFT 1
#define CHG_CNFG_00_BUCK_SHIFT 2
#define CHG_CNFG_00_BOOST_SHIFT 3
#define CHG_CNFG_00_DIS_MUIC_CTRL_SHIFT 5
#define CHG_CNFG_00_MODE_MASK (0xf << CHG_CNFG_00_MODE_SHIFT)
#define CHG_CNFG_00_CHG_MASK (1 << CHG_CNFG_00_CHG_SHIFT)
#define CHG_CNFG_00_OTG_MASK (1 << CHG_CNFG_00_OTG_SHIFT)
#define CHG_CNFG_00_BUCK_MASK (1 << CHG_CNFG_00_BUCK_SHIFT)
#define CHG_CNFG_00_BOOST_MASK (1 << CHG_CNFG_00_BOOST_SHIFT)
#define CHG_CNFG_00_DIS_MUIC_CTRL_MASK (1 << CHG_CNFG_00_DIS_MUIC_CTRL_SHIFT)
#define MAX77823_MODE_DEFAULT 0x04
#define MAX77823_MODE_CHGR 0x01
#define MAX77823_MODE_OTG 0x02
#define MAX77823_MODE_BUCK 0x04
#define MAX77823_MODE_BOOST 0x08
/* MAX77823_CHG_REG_CHG_CNFG_02 */
#define MAX77823_CHG_CC 0x3F
/* MAX77823_CHG_REG_CHG_CNFG_03 */
#define MAX77823_CHG_TO_ITH 0x07
/* MAX77823_CHG_REG_CHG_CNFG_04 */
#define MAX77823_CHG_MINVSYS_MASK 0xE0
#define MAX77823_CHG_MINVSYS_SHIFT 5
#define MAX77823_CHG_PRM_MASK 0x1F
#define MAX77823_CHG_PRM_SHIFT 0
#define CHG_CNFG_04_CHG_CV_PRM_SHIFT 0
#define CHG_CNFG_04_CHG_CV_PRM_MASK (0x3F << CHG_CNFG_04_CHG_CV_PRM_SHIFT)
/* MAX77823_CHG_REG_CHG_CNFG_09 */
#define MAX77823_CHG_CHGIN_LIM 0x7F
/* MAX77823_CHG_REG_CHG_CNFG_12 */
#define MAX77823_CHG_WCINSEL 0x40
/* MAX77823_CHG_REG_CHG_DTLS_00 */
#define MAX77823_BATP_DTLS 0x01
#define MAX77823_BATP_DTLS_SHIFT 0
#define MAX77823_WCIN_DTLS 0x18
#define MAX77823_WCIN_DTLS_SHIFT 3
#define MAX77823_CHGIN_DTLS 0x60
#define MAX77823_CHGIN_DTLS_SHIFT 5
/* MAX77823_CHG_DETAILS_01 */
#define MAX77823_CHG_DTLS 0x0F
#define MAX77823_CHG_DTLS_SHIFT 0
#define MAX77823_BAT_DTLS 0x70
#define MAX77823_BAT_DTLS_SHIFT 4
#define SIOP_INPUT_LIMIT_CURRENT 1200
#define SIOP_CHARGING_LIMIT_CURRENT 1000
#define SLOW_CHARGING_CURRENT_STANDARD 400
struct max77823_charger_data {
struct device *dev;
struct i2c_client *i2c;
struct i2c_client *pmic_i2c;
struct mutex charger_mutex;
struct max77823_platform_data *max77823_pdata;
struct power_supply psy_chg;
struct workqueue_struct *wqueue;
struct work_struct chgin_work;
struct delayed_work isr_work;
struct delayed_work recovery_work; /* softreg recovery work */
struct delayed_work wpc_work; /* wpc detect work */
struct delayed_work chgin_init_work; /* chgin init work */
/* mutex */
struct mutex irq_lock;
struct mutex ops_lock;
/* wakelock */
struct wake_lock recovery_wake_lock;
struct wake_lock wpc_wake_lock;
struct wake_lock chgin_wake_lock;
unsigned int is_charging;
unsigned int charging_type;
unsigned int battery_state;
unsigned int battery_present;
unsigned int cable_type;
unsigned int charging_current_max;
unsigned int charging_current;
unsigned int input_current_limit;
unsigned int vbus_state;
int aicl_on;
int status;
int siop_level;
int uvlo_attach_flag;
int uvlo_attach_cable_type;
int irq_bypass;
int irq_batp;
int irq_battery;
int irq_chg;
int irq_wcin;
int irq_chgin;
/* software regulation */
bool soft_reg_state;
int soft_reg_current;
/* unsufficient power */
bool reg_loop_deted;
/* wireless charge, w(wpc), v(vbus) */
int wc_w_gpio;
int wc_w_irq;
int wc_w_state;
int wc_v_gpio;
int wc_v_irq;
int wc_v_state;
bool wc_pwr_det;
int soft_reg_recovery_cnt;
int pmic_ver;
int input_curr_limit_step;
int wpc_input_curr_limit_step;
int charging_curr_step;
sec_battery_platform_data_t *pdata;
};
extern void cp_usb_power_control(int enable);
#endif /* __MAX77823_CHARGER_H */

View file

@ -0,0 +1,231 @@
/*
* max77833_charger.h
* Samsung MAX77833 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 __MAX77833_CHARGER_H
#define __MAX77833_CHARGER_H __FILE__
#include <linux/mfd/core.h>
#include <linux/mfd/max77833.h>
#include <linux/mfd/max77833-private.h>
#include <linux/regulator/machine.h>
#include <linux/wakelock.h>
enum {
CHIP_ID = 0,
};
ssize_t max77833_chg_show_attrs(struct device *dev,
struct device_attribute *attr, char *buf);
ssize_t max77833_chg_store_attrs(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count);
#define MAX77833_CHARGER_ATTR(_name) \
{ \
.attr = {.name = #_name, .mode = 0664}, \
.show = max77833_chg_show_attrs, \
.store = max77833_chg_store_attrs, \
}
extern sec_battery_platform_data_t sec_battery_pdata;
#define MAX77833_CHG_SAFEOUT2 0x80
/* MAX77833_CHG_REG_CHG_INT */
#define MAX77833_BYP_I (1 << 0)
#define MAX77833_BATP_I (1 << 2)
#define MAX77833_BAT_I (1 << 3)
#define MAX77833_CHG_I (1 << 4)
#define MAX77833_WCIN_I (1 << 5)
#define MAX77833_CHGIN_I (1 << 6)
#define MAX77833_AICL_I (1 << 7)
/* MAX77833_CHG_REG_CHG_INT_MASK */
#define MAX77833_BYP_IM (1 << 0)
#define MAX77833_BATP_IM (1 << 2)
#define MAX77833_BAT_IM (1 << 3)
#define MAX77833_CHG_IM (1 << 4)
#define MAX77833_WCIN_IM (1 << 5)
#define MAX77833_CHGIN_IM (1 << 6)
#define MAX77833_AICL_IM (1 << 7)
/* MAX77833_CHG_REG_CHG_INT_OK */
#define MAX77833_BYP_OK 0x01
#define MAX77833_BYP_OK_SHIFT 0
#define MAX77833_BATP_OK 0x04
#define MAX77833_BATP_OK_SHIFT 2
#define MAX77833_BAT_OK 0x08
#define MAX77833_BAT_OK_SHIFT 3
#define MAX77833_CHG_OK 0x10
#define MAX77833_CHG_OK_SHIFT 4
#define MAX77833_WCIN_OK 0x20
#define MAX77833_WCIN_OK_SHIFT 5
#define MAX77833_CHGIN_OK 0x40
#define MAX77833_CHGIN_OK_SHIFT 6
#define MAX77833_AICL_OK 0x04
#define MAX77833_AICL_OK_SHIFT 7
/* MAX77833_CHG_REG_CHG_DTLS_00 */
#define MAX77833_BATP_DTLS 0x01
#define MAX77833_BATP_DTLS_SHIFT 0
#define MAX77833_WCIN_DTLS 0x30
#define MAX77833_WCIN_DTLS_SHIFT 4
#define MAX77833_CHGIN_DTLS 0xC0
#define MAX77833_CHGIN_DTLS_SHIFT 6
/* MAX77833_CHG_REG_CHG_DTLS_01 */
#define MAX77833_CHG_DTLS 0x0F
#define MAX77833_CHG_DTLS_SHIFT 0
#define MAX77833_BAT_DTLS 0x70
#define MAX77833_BAT_DTLS_SHIFT 4
/* MAX77833_CHG_REG_CHG_DTLS_02 */
#define MAX77833_BYP_DTLS 0x0F
#define MAX77833_BYP_DTLS_SHIFT 0
#define MAX77833_BYP_DTLS0 0x1
#define MAX77833_BYP_DTLS1 0x2
#define MAX77833_BYP_DTLS2 0x4
#define MAX77833_BYP_DTLS3 0x8
/* MAX77833_CHG_REG_CHG_CNFG_00 */
#define CHG_CNFG_00_MODE_SHIFT 0
#define CHG_CNFG_00_CHG_SHIFT 0
#define CHG_CNFG_00_OTG_SHIFT 1
#define CHG_CNFG_00_BUCK_SHIFT 2
#define CHG_CNFG_00_BOOST_SHIFT 3
#define CHG_CNFG_00_MODE_MASK (0xf << CHG_CNFG_00_MODE_SHIFT)
#define CHG_CNFG_00_CHG_MASK (1 << CHG_CNFG_00_CHG_SHIFT)
#define CHG_CNFG_00_OTG_MASK (1 << CHG_CNFG_00_OTG_SHIFT)
#define CHG_CNFG_00_BUCK_MASK (1 << CHG_CNFG_00_BUCK_SHIFT)
#define CHG_CNFG_00_BOOST_MASK (1 << CHG_CNFG_00_BOOST_SHIFT)
#define CHG_CNFG_00_OTG_CTRL (CHG_CNFG_00_OTG_MASK | CHG_CNFG_00_BOOST_MASK)
#define MAX77833_MODE_DEFAULT 0x04
#define MAX77833_MODE_CHGR 0x01
#define MAX77833_MODE_OTG 0x02
#define MAX77833_MODE_BUCK 0x04
#define MAX77833_MODE_BOOST 0x08
/* MAX77833_CHG_REG_CHG_CNFG_02 */
#define MAX77833_CHG_TO_ITH 0x07
#define MAX77833_CHG_TO_TIME 0x38
#define MAX77833_CHG_OTG_ILIM 0xC0
/* MAX77833_CHG_REG_CHG_CNFG_04 */
#define MAX77833_CHG_MINVSYS_MASK 0xE0
#define MAX77833_CHG_MINVSYS_SHIFT 5
#define MAX77833_CHG_PRM_MASK 0x1F
#define MAX77833_CHG_PRM_SHIFT 0
/* MAX77833_CHG_REG_CHG_CNFG_17 */
#define MAX77833_CHG_WCIN_LIM 0x7F
#define REDUCE_CURRENT_STEP 100
#define MINIMUM_INPUT_CURRENT 300
#define SIOP_INPUT_LIMIT_CURRENT 1200
#define SIOP_CHARGING_LIMIT_CURRENT 1000
#define SIOP_WIRELESS_INPUT_LIMIT_CURRENT 530
#define SIOP_WIRELESS_CHARGING_LIMIT_CURRENT 780
#define SIOP_HV_INPUT_LIMIT_CURRENT 700
#define SIOP_HV_CHARGING_LIMIT_CURRENT 1000
#define SLOW_CHARGING_CURRENT_STANDARD 400
#define INPUT_CURRENT_TA 1000
struct max77833_charger_data {
struct device *dev;
struct i2c_client *i2c;
struct i2c_client *pmic_i2c;
struct mutex charger_mutex;
struct max77833_platform_data *max77833_pdata;
struct power_supply psy_chg;
struct workqueue_struct *wqueue;
struct work_struct chgin_work;
struct delayed_work isr_work;
struct delayed_work recovery_work; /* softreg recovery work */
struct delayed_work wpc_work; /* wpc detect work */
struct delayed_work chgin_init_work; /* chgin init work */
struct delayed_work afc_work;
struct delayed_work aicl_work;
/* mutex */
struct mutex irq_lock;
struct mutex ops_lock;
/* wakelock */
struct wake_lock recovery_wake_lock;
struct wake_lock wpc_wake_lock;
struct wake_lock afc_wake_lock;
struct wake_lock chgin_wake_lock;
struct wake_lock aicl_wake_lock;
unsigned int is_charging;
unsigned int charging_type;
unsigned int battery_state;
unsigned int battery_present;
unsigned int cable_type;
unsigned int charging_current_max;
unsigned int charging_current;
unsigned int input_current_limit;
unsigned int vbus_state;
int aicl_on;
int status;
int siop_level;
int uvlo_attach_flag;
int uvlo_attach_cable_type;
int irq_bypass;
int irq_batp;
int irq_aicl;
int irq_battery;
int irq_chg;
int irq_wcin;
int irq_chgin;
/* software regulation */
bool soft_reg_state;
int soft_reg_current;
/* unsufficient power */
bool reg_loop_deted;
/* wireless charge, w(wpc), v(vbus) */
int wc_w_gpio;
int wc_w_irq;
int wc_w_state;
int wc_v_gpio;
int wc_v_irq;
int wc_v_state;
bool wc_pwr_det;
int soft_reg_recovery_cnt;
bool afc_detect;
bool is_mdock;
int pmic_ver;
int input_curr_limit_step;
int wpc_input_curr_limit_step;
int charging_curr_step;
sec_charger_platform_data_t *pdata;
};
#endif /* __MAX77833_CHARGER_H */

View file

@ -0,0 +1,225 @@
/*
* max77843_charger.h
* Samsung MAX77843 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 __MAX77843_CHARGER_H
#define __MAX77843_CHARGER_H __FILE__
#include <linux/mfd/core.h>
#include <linux/mfd/max77843.h>
#include <linux/mfd/max77843-private.h>
#include <linux/regulator/machine.h>
#define MAX77843_CHG_SAFEOUT2 0x80
/* MAX77843_CHG_REG_CHG_INT */
#define MAX77843_BYP_I (1 << 0)
#define MAX77843_BATP_I (1 << 2)
#define MAX77843_BAT_I (1 << 3)
#define MAX77843_CHG_I (1 << 4)
#define MAX77843_WCIN_I (1 << 5)
#define MAX77843_CHGIN_I (1 << 6)
/* MAX77843_CHG_REG_CHG_INT_MASK */
#define MAX77843_BYP_IM (1 << 0)
#define MAX77843_THM_IM (1 << 2)
#define MAX77843_BAT_IM (1 << 3)
#define MAX77843_CHG_IM (1 << 4)
#define MAX77843_WCIN_IM (1 << 5)
#define MAX77843_CHGIN_IM (1 << 6)
/* MAX77843_CHG_REG_CHG_INT_OK */
#define MAX77843_BYP_OK 0x01
#define MAX77843_BYP_OK_SHIFT 0
#define MAX77843_BATP_OK 0x04
#define MAX77843_BATP_OK_SHIFT 2
#define MAX77843_BAT_OK 0x08
#define MAX77843_BAT_OK_SHIFT 3
#define MAX77843_CHG_OK 0x10
#define MAX77843_CHG_OK_SHIFT 4
#define MAX77843_WCIN_OK 0x20
#define MAX77843_WCIN_OK_SHIFT 5
#define MAX77843_CHGIN_OK 0x40
#define MAX77843_CHGIN_OK_SHIFT 6
#define MAX77843_DETBAT 0x04
#define MAX77843_DETBAT_SHIFT 2
/* MAX77843_CHG_REG_CHG_DTLS_00 */
#define MAX77843_BATP_DTLS 0x01
#define MAX77843_BATP_DTLS_SHIFT 0
#define MAX77843_WCIN_DTLS 0x18
#define MAX77843_WCIN_DTLS_SHIFT 3
#define MAX77843_CHGIN_DTLS 0x60
#define MAX77843_CHGIN_DTLS_SHIFT 5
/* MAX77843_CHG_REG_CHG_DTLS_01 */
#define MAX77843_CHG_DTLS 0x0F
#define MAX77843_CHG_DTLS_SHIFT 0
#define MAX77843_BAT_DTLS 0x70
#define MAX77843_BAT_DTLS_SHIFT 4
/* MAX77843_CHG_REG_CHG_DTLS_02 */
#define MAX77843_BYP_DTLS 0x0F
#define MAX77843_BYP_DTLS_SHIFT 0
#define MAX77843_BYP_DTLS0 0x1
#define MAX77843_BYP_DTLS1 0x2
#define MAX77843_BYP_DTLS2 0x4
#define MAX77843_BYP_DTLS3 0x8
/* MAX77843_CHG_REG_CHG_CNFG_00 */
#define CHG_CNFG_00_MODE_SHIFT 0
#define CHG_CNFG_00_CHG_SHIFT 0
#define CHG_CNFG_00_OTG_SHIFT 1
#define CHG_CNFG_00_BUCK_SHIFT 2
#define CHG_CNFG_00_BOOST_SHIFT 3
#define CHG_CNFG_00_MODE_MASK (0xf << CHG_CNFG_00_MODE_SHIFT)
#define CHG_CNFG_00_CHG_MASK (1 << CHG_CNFG_00_CHG_SHIFT)
#define CHG_CNFG_00_OTG_MASK (1 << CHG_CNFG_00_OTG_SHIFT)
#define CHG_CNFG_00_BUCK_MASK (1 << CHG_CNFG_00_BUCK_SHIFT)
#define CHG_CNFG_00_BOOST_MASK (1 << CHG_CNFG_00_BOOST_SHIFT)
#define CHG_CNFG_00_OTG_CTRL (CHG_CNFG_00_OTG_MASK | CHG_CNFG_00_BOOST_MASK)
#define MAX77843_MODE_DEFAULT 0x04
#define MAX77843_MODE_CHGR 0x01
#define MAX77843_MODE_OTG 0x02
#define MAX77843_MODE_BUCK 0x04
#define MAX77843_MODE_BOOST 0x08
/* MAX&7843_CHG_REG_CHG_CNFG_01 */
#define MAX77843_CHG_FQ_2MHz (1 << 3)
/* MAX77843_CHG_REG_CHG_CNFG_02 */
#define MAX77843_CHG_CC 0x3F
/* MAX77843_CHG_REG_CHG_CNFG_03 */
#define MAX77843_CHG_TO_ITH 0x07
/* MAX77843_CHG_REG_CHG_CNFG_04 */
#define MAX77843_CHG_MINVSYS_MASK 0xE0
#define MAX77843_CHG_MINVSYS_SHIFT 5
#define MAX77843_CHG_PRM_MASK 0x1F
#define MAX77843_CHG_PRM_SHIFT 0
#define CHG_CNFG_04_CHG_CV_PRM_SHIFT 0
#define CHG_CNFG_04_CHG_CV_PRM_MASK (0x3F << CHG_CNFG_04_CHG_CV_PRM_SHIFT)
/* MAX77843_CHG_REG_CHG_CNFG_09 */
#define MAX77843_CHG_CHGIN_LIM 0x7F
/* MAX77843_CHG_REG_CHG_CNFG_10 */
#define MAX77843_CHG_WCIN_LIM 0x3F
/* MAX77843_CHG_REG_CHG_CNFG_12 */
#define MAX77843_CHG_WCINSEL 0x40
/* MAX77843_CHG_REG_CHG_DTLS_00 */
#define MAX77843_BATP_DTLS 0x01
#define MAX77843_BATP_DTLS_SHIFT 0
#define MAX77843_WCIN_DTLS 0x18
#define MAX77843_WCIN_DTLS_SHIFT 3
#define MAX77843_CHGIN_DTLS 0x60
#define MAX77843_CHGIN_DTLS_SHIFT 5
/* MAX77843_CHG_DETAILS_01 */
#define MAX77843_CHG_DTLS 0x0F
#define MAX77843_CHG_DTLS_SHIFT 0
#define MAX77843_BAT_DTLS 0x70
#define MAX77843_BAT_DTLS_SHIFT 4
#define SIOP_INPUT_LIMIT_CURRENT 1200
#define SIOP_CHARGING_LIMIT_CURRENT 1000
#define SIOP_WIRELESS_INPUT_LIMIT_CURRENT 660
#define SIOP_WIRELESS_CHARGING_LIMIT_CURRENT 780
#define SLOW_CHARGING_CURRENT_STANDARD 400
struct max77843_charger_data {
struct device *dev;
struct i2c_client *i2c;
struct i2c_client *pmic_i2c;
struct mutex charger_mutex;
struct max77843_platform_data *max77843_pdata;
struct power_supply psy_chg;
struct workqueue_struct *wqueue;
struct work_struct chgin_work;
struct delayed_work isr_work;
struct delayed_work recovery_work; /* softreg recovery work */
struct delayed_work wpc_work; /* wpc detect work */
struct delayed_work chgin_init_work; /* chgin init work */
struct delayed_work afc_work;
/* mutex */
struct mutex irq_lock;
struct mutex ops_lock;
/* wakelock */
struct wake_lock recovery_wake_lock;
struct wake_lock wpc_wake_lock;
struct wake_lock chgin_wake_lock;
unsigned int is_charging;
unsigned int charging_type;
unsigned int battery_state;
unsigned int battery_present;
unsigned int cable_type;
unsigned int charging_current_max;
unsigned int charging_current;
unsigned int input_current_limit;
unsigned int vbus_state;
int aicl_on;
int status;
int siop_level;
int uvlo_attach_flag;
int uvlo_attach_cable_type;
int irq_bypass;
int irq_batp;
int irq_battery;
int irq_chg;
int irq_wcin;
int irq_chgin;
/* software regulation */
bool soft_reg_state;
int soft_reg_current;
/* unsufficient power */
bool reg_loop_deted;
/* wireless charge, w(wpc), v(vbus) */
int wc_w_gpio;
int wc_w_irq;
int wc_w_state;
int wc_v_gpio;
int wc_v_irq;
int wc_v_state;
bool wc_pwr_det;
int soft_reg_recovery_cnt;
bool afc_detect;
bool is_mdock;
int pmic_ver;
int input_curr_limit_step;
int wpc_input_curr_limit_step;
int charging_curr_step;
sec_battery_platform_data_t *pdata;
};
#endif /* __MAX77843_CHARGER_H */

View file

@ -0,0 +1,104 @@
/*
* drivers/battery/s2mu003_charger.h
*
* Header of Richtek S2MU003 Fuelgauge Driver
*
* Copyright (C) 2013 Richtek Technology Corp.
* Patrick Chang <patrick_chang@richtek.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 S2MU003_CHARGER_H
#define S2MU003_CHARGER_H
#include <linux/mfd/samsung/s2mu003.h>
#include <linux/mfd/samsung/s2mu003_irq.h>
#define S2MU003_CHG_STATUS1 0x00
#define S2MU003_CHG_CTRL1 0x01
#define S2MU003_CHG_CTRL2 0x02
#define S2MU003_CHG_CTRL3 0x04
#define S2MU003_CHG_CTRL4 0x05
#define S2MU003_CHG_CTRL5 0x06
#define S2MU003_SOFTRESET 0x07
#define S2MU003_CHG_CTRL6 0x08
#define S2MU003_CHG_CTRL7 0x09
#define S2MU003_CHG_CTRL8 0x0A
#define S2MU003_CHG_STATUS2 0x0B
#define S2MU003_CHG_STATUS3 0x0C
#define S2MU003_CHG_STATUS4 0x0D
#define S2MU003_CHG_CTRL9 0x0E
#define S2MU003_OTG_SS_ENB_MASK (1 << 0)
#define S2MU003_OPAMODE_MASK (1 << 0)
#define S2MU003_CHG_EN_MASK (1 << 6)
#define S2MU003_TIMEREN_MASK (1 << 0)
#define S2MU003_SEL_SWFREQ_MASK (1 << 2)
#define S2MU003_TEEN_MASK (1 << 3)
#define S2MU003_AICR_LIMIT_MASK (0x7 << 5)
#define S2MU003_AICR_LIMIT_SHIFT 5
#define S2MU003_MIVR_MASK (0x7 << 5)
#define S2MU003_MIVR_SHIFT 5
#define S2MU003_VOREG_MASK (0x3f << 2)
#define S2MU003_VOREG_SHIFT 2
#define S2MU003_IEOC_MASK 0x07
#define S2MU003_IEOC_SHIFT 0
#define S2MU003_ICHRG_MASK 0xf0
#define S2MU003_ICHRG_SHIFT 4
#define S2MU003_CHG_IRQ1 0x60
#define S2MU003_CHG_IRQ2 0x61
#define S2MU003_CHG_IRQ3 0x62
#define S2MU003_CHG_IRQ_CTRL1 0x63
#define S2MU003_CHG_IRQ_CTRL2 0x64
#define S2MU003_CHG_IRQ_CTRL3 0x65
/* S2MU003_CHG_STAT */
#define S2MU003_EXT_PMOS_CTRL 0x1
#define S2MU003_EXT_PMOS_CTRL_SHIFT 7
#define S2MU003SW_HW_CTRL 0x1
#define S2MU003SW_HW_CTRL_SHIFT 2
#define S2MU003_OTG_SS_DISABLE 0x1
#define S2MU003_OTG_SS_DISABLE_SHIFT 1
/* S2MU003_CHR_CTRL1 */
#define S2MU003_IAICR 0x101
#define S2MU003_IAICR_SHIFT 5
#define S2MU003_HIGHER_OCP 0x1
#define S2MU003_HIGHER_OCP_SHIFT 4
#define S2MU003_TERMINATION_EN 0x0
#define S2MU003_TERMINATION_EN_SHIFT 3
#define S2MU003_SEL_SWFREQ 0x1
#define S2MU003_SEL_SWFREQ_SHIFT 2
#define S2MU003_HIGH_IMPEDANCE 0
#define S2MU003_HIGH_IMPEDANCE_SHIFT 1
#define S2MU003_OPA_MODE 2
#define S2MU003_OPA_MODE_SHIFT 0
/* S2MU003_CHG_CTRL2 */
#define S2MU003_REG_VOLTAGE 0x011100
#define S2MU003_REG_VOLTAGE_SHIFT 2
#define S2MU003_TDEG_EOC 0x0
#define S2MU003_TDEG_EOC_SHIFT 0
/* S2MU003_CHG_CTRL3 */
#define S2MU003_PPC_TE 0x0
#define S2MU003_PPC_TE_SHIFT 7
#define S2MU003_CHG_EN 0x1
#define S2MU003_CHG_EN_SHIFT 6
enum {
CHG_REG = 0,
CHG_DATA,
CHG_REGS,
};
struct charger_info {
int dummy;
};
#endif /*S2MU003_CHARGER_H*/

View file

@ -0,0 +1,59 @@
/*
* smb347_charger.h
* Samsung SMB347 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 __SMB347_CHARGER_H
#define __SMB347_CHARGER_H __FILE__
/* Slave address should be shifted to the right 1bit.
* R/W bit should NOT be included.
*/
#define SEC_CHARGER_I2C_SLAVEADDR (0x0C >> 1)
/* Register define */
#define SMB347_CHARGE_CURRENT 0x00
#define SMB347_INPUT_CURRENTLIMIT 0x01
#define SMB347_VARIOUS_FUNCTIONS 0x02
#define SMB347_FLOAT_VOLTAGE 0x03
#define SMB347_CHARGE_CONTROL 0x04
#define SMB347_STAT_TIMERS_CONTROL 0x05
#define SMB347_PIN_ENABLE_CONTROL 0x06
#define SMB347_THERM_CONTROL_A 0x07
#define SMB347_SYSOK_USB30_SELECTION 0x08
#define SMB347_OTHER_CONTROL_A 0x09
#define SMB347_OTG_TLIM_THERM_CONTROL 0x0A
#define SMB347_LIMIT_CELL_TEMPERATURE_MONITOR 0x0B
#define SMB347_FAULT_INTERRUPT 0x0C
#define SMB347_STATUS_INTERRUPT 0x0D
#define SMB347_I2C_BUS_SLAVE_ADDR 0x0E
#define SMB347_COMMAND_A 0x30
#define SMB347_COMMAND_B 0x31
#define SMB347_COMMAND_C 0x33
#define SMB347_INTERRUPT_STATUS_A 0x35
#define SMB347_INTERRUPT_STATUS_B 0x36
#define SMB347_INTERRUPT_STATUS_C 0x37
#define SMB347_INTERRUPT_STATUS_D 0x38
#define SMB347_INTERRUPT_STATUS_E 0x39
#define SMB347_INTERRUPT_STATUS_F 0x3A
#define SMB347_STATUS_A 0x3B
#define SMB347_STATUS_B 0x3C
#define SMB347_STATUS_C 0x3D
#define SMB347_STATUS_D 0x3E
#define SMB347_STATUS_E 0x3F
#endif /* __SMB347_CHARGER_H */

View file

@ -0,0 +1,58 @@
/*
* 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_OCV_MSB 0x0E
#define MAX17048_OCV_LSB 0x0F
#define MAX17048_CMD_MSB 0xFE
#define MAX17048_CMD_LSB 0xFF
#define RCOMP0_TEMP 20
#define AVER_SAMPLE_CNT 5
struct battery_data_t {
u8 RCOMP0;
u8 RCOMP_charging;
int temp_cohot;
int temp_cocold;
bool is_using_model_data;
u8 *type_str;
};
struct sec_fg_info {
bool dummy;
};
#endif /* __MAX17048_FUELGAUGE_H */

View file

@ -0,0 +1,182 @@
/*
* 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__
#if defined(ANDROID_ALARM_ACTIVATED)
#include <linux/android_alarm.h>
#endif
/* 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 battery_data_t {
u8 *type_str;
};
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 LOW_BATT_COMP_RANGE_NUM 5
#define LOW_BATT_COMP_LEVEL_NUM 2
#define MAX_LOW_BATT_CHECK_CNT 10
enum {
FG_LEVEL = 0,
FG_TEMPERATURE,
FG_VOLTAGE,
FG_CURRENT,
FG_CURRENT_AVG,
FG_CHECK_STATUS,
FG_RAW_SOC,
FG_VF_SOC,
FG_AV_SOC,
FG_FULLCAP,
FG_MIXCAP,
FG_AVCAP,
FG_REPCAP,
};
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 */

View file

@ -0,0 +1,186 @@
/*
* max77823_fuelgauge.h
* Samsung MAX77823 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__
#if defined(ANDROID_ALARM_ACTIVATED)
#include <linux/android_alarm.h>
#endif
#include <linux/mfd/core.h>
#include <linux/mfd/max77823.h>
#include <linux/mfd/max77823-private.h>
#include <linux/regulator/machine.h>
/* Slave address should be shifted to the right 1bit.
* R/W bit should NOT be included.
*/
#if defined(CONFIG_FUELGAUGE_MAX77823_VOLTAGE_TRACKING)
#define MAX77823_REG_STATUS 0x00
#define MAX77823_REG_VALRT_TH 0x01
#define MAX77823_REG_TALRT_TH 0x02
#define MAX77823_REG_SALRT_TH 0x03
#define MAX77823_REG_VCELL 0x09
#define MAX77823_REG_TEMPERATURE 0x08
#define MAX77823_REG_AVGVCELL 0x19
#define MAX77823_REG_CONFIG 0x1D
#define MAX77823_REG_VERSION 0x21
#define MAX77823_REG_LEARNCFG 0x28
#define MAX77823_REG_FILTERCFG 0x29
#define MAX77823_REG_MISCCFG 0x2B
#define MAX77823_REG_CGAIN 0x2E
#define MAX77823_REG_RCOMP 0x38
#define MAX77823_REG_VFOCV 0xFB
#define MAX77823_REG_SOC_VF 0xFF
struct battery_data_t {
u8 *type_str;
};
struct sec_fg_info {
bool dummy;
};
#endif
#if defined(CONFIG_FUELGAUGE_MAX77823_COULOMB_COUNTING)
#define PRINT_COUNT 10
#define LOW_BATT_COMP_RANGE_NUM 5
#define LOW_BATT_COMP_LEVEL_NUM 2
#define MAX_LOW_BATT_CHECK_CNT 10
enum {
FG_LEVEL = 0,
FG_TEMPERATURE,
FG_VOLTAGE,
FG_CURRENT,
FG_CURRENT_AVG,
FG_CHECK_STATUS,
FG_RAW_SOC,
FG_VF_SOC,
FG_AV_SOC,
FG_FULLCAP,
FG_MIXCAP,
FG_AVCAP,
FG_REPCAP,
};
enum {
POSITIVE = 0,
NEGATIVE,
};
enum {
RANGE = 0,
SLOPE,
OFFSET,
TABLE_MAX
};
#define CURRENT_RANGE_MAX_NUM 5
struct battery_data_t {
u32 Capacity;
u32 low_battery_comp_voltage;
s32 low_battery_table[CURRENT_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
struct max77823_fuelgauge_data {
struct device *dev;
struct i2c_client *i2c;
struct mutex fuelgauge_mutex;
struct max77823_platform_data *max77823_pdata;
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;
struct battery_data_t *battery_data;
bool is_fuel_alerted;
struct wake_lock fuel_alert_wake_lock;
unsigned int capacity_old; /* only for atomic calculation */
unsigned int capacity_max; /* only for dynamic calculation */
bool initial_update_of_soc;
struct mutex fg_lock;
/* register programming */
int reg_addr;
u8 reg_data[2];
int fg_irq;
};
#endif /* __MAX77823_FUELGAUGE_H */

View file

@ -0,0 +1,195 @@
/*
* max77833_fuelgauge.h
* Samsung MAX77833 Fuel Gauge Header
*
* Copyright (C) 2012 Samsung Electronics, Inc.
*
* This software is 77833 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 __MAX77833_FUELGAUGE_H
#define __MAX77833_FUELGAUGE_H __FILE__
#if defined(ANDROID_ALARM_ACTIVATED)
#include <linux/android_alarm.h>
#endif
#include <linux/battery/sec_charging_common.h>
#include <linux/mfd/core.h>
#include <linux/mfd/max77833.h>
#include <linux/mfd/max77833-private.h>
#include <linux/regulator/machine.h>
#include <linux/wakelock.h>
/* Slave address should be shifted to the right 1bit.
* R/W bit should NOT be included.
*/
#define PRINT_COUNT 10
#define LOW_BATT_COMP_RANGE_NUM 5
#define LOW_BATT_COMP_LEVEL_NUM 2
#define MAX_LOW_BATT_CHECK_CNT 10
#define ALERT_EN 0x04
struct sec_fuelgauge_reg_data {
u8 reg_addr;
u8 reg_data1;
u8 reg_data2;
};
struct max77833_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;
};
enum {
MAX77833_FG_LEVEL = 0,
MAX77833_FG_TEMPERATURE,
MAX77833_FG_VOLTAGE,
MAX77833_FG_CURRENT,
MAX77833_FG_CURRENT_AVG,
MAX77833_FG_CHECK_STATUS,
MAX77833_FG_RAW_SOC,
MAX77833_FG_VF_SOC,
MAX77833_FG_AV_SOC,
MAX77833_FG_FULLCAP,
MAX77833_FG_FULLCAPNOM,
MAX77833_FG_FULLCAPREP,
MAX77833_FG_MIXCAP,
MAX77833_FG_AVCAP,
MAX77833_FG_REPCAP,
MAX77833_FG_CYCLE,
};
enum {
MAX77833_POSITIVE = 0,
MAX77833_NEGATIVE,
};
enum {
MAX77833_RANGE = 0,
MAX77833_SLOPE,
MAX77833_OFFSET,
MAX77833_TABLE_MAX
};
#define CURRENT_RANGE_MAX_NUM 5
struct battery_data_t {
u32 QResidual20;
u32 QResidual30;
u32 Capacity;
u32 low_battery_comp_voltage;
s32 low_battery_table[CURRENT_RANGE_MAX_NUM][MAX77833_TABLE_MAX];
u8 *type_str;
u32 ichgterm;
u32 misccfg;
u32 fullsocthr;
u32 ichgterm_2nd;
u32 misccfg_2nd;
u32 fullsocthr_2nd;
};
/* 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
struct cv_slope{
int fg_current;
int soc;
int time;
};
struct max77833_fuelgauge_data {
struct device *dev;
struct i2c_client *i2c;
struct i2c_client *pmic;
struct mutex fuelgauge_mutex;
struct max77833_platform_data *max77833_pdata;
sec_fuelgauge_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 max77833_fg_info info;
struct battery_data_t *battery_data;
bool is_fuel_alerted;
struct wake_lock fuel_alert_wake_lock;
unsigned int capacity_old; /* only for atomic calculation */
unsigned int capacity_max; /* only for dynamic calculation */
unsigned int standard_capacity;
bool initial_update_of_soc;
struct mutex fg_lock;
/* register programming */
int reg_addr;
u8 reg_data[2];
unsigned int pre_soc;
int fg_irq;
int raw_capacity;
int current_now;
int current_avg;
struct cv_slope *cv_data;
int cv_data_lenth;
};
#endif /* __MAX77833_FUELGAUGE_H */

View file

@ -0,0 +1,169 @@
/*
* max77843_fuelgauge.h
* Samsung MAX77843 Fuel Gauge Header
*
* Copyright (C) 2012 Samsung Electronics, Inc.
*
* This software is 77843 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__
#if defined(ANDROID_ALARM_ACTIVATED)
#include <linux/android_alarm.h>
#endif
#include <linux/mfd/core.h>
#include <linux/mfd/max77843.h>
#include <linux/mfd/max77843-private.h>
#include <linux/regulator/machine.h>
/* Slave address should be shifted to the right 1bit.
* R/W bit should NOT be included.
*/
#define PRINT_COUNT 10
#define LOW_BATT_COMP_RANGE_NUM 5
#define LOW_BATT_COMP_LEVEL_NUM 2
#define MAX_LOW_BATT_CHECK_CNT 10
#define ALERT_EN 0x04
enum {
FG_LEVEL = 0,
FG_TEMPERATURE,
FG_VOLTAGE,
FG_CURRENT,
FG_CURRENT_AVG,
FG_CHECK_STATUS,
FG_RAW_SOC,
FG_VF_SOC,
FG_AV_SOC,
FG_FULLCAP,
FG_MIXCAP,
FG_AVCAP,
FG_REPCAP,
};
enum {
POSITIVE = 0,
NEGATIVE,
};
enum {
RANGE = 0,
SLOPE,
OFFSET,
TABLE_MAX
};
#define CURRENT_RANGE_MAX_NUM 5
struct battery_data_t {
u32 QResidual20;
u32 QResidual30;
u32 Capacity;
u32 low_battery_comp_voltage;
s32 low_battery_table[CURRENT_RANGE_MAX_NUM][TABLE_MAX];
u8 *type_str;
u32 ichgterm;
u32 misccfg;
u32 fullsocthr;
u32 ichgterm_2nd;
u32 misccfg_2nd;
u32 fullsocthr_2nd;
};
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
struct max77843_fuelgauge_data {
struct device *dev;
struct i2c_client *i2c;
struct i2c_client *pmic;
struct mutex fuelgauge_mutex;
struct max77843_platform_data *max77843_pdata;
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;
struct battery_data_t *battery_data;
bool is_fuel_alerted;
struct wake_lock fuel_alert_wake_lock;
unsigned int capacity_old; /* only for atomic calculation */
unsigned int capacity_max; /* only for dynamic calculation */
unsigned int standard_capacity;
bool initial_update_of_soc;
struct mutex fg_lock;
/* register programming */
int reg_addr;
u8 reg_data[2];
unsigned int pre_soc;
int fg_irq;
};
#endif /* __MAX77843_FUELGAUGE_H */

View file

@ -0,0 +1,37 @@
/*
* sec_adc.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_ADC_H
#define __SEC_ADC_H __FILE__
#include <linux/iio/consumer.h>
#include <linux/battery/sec_battery.h>
#include <linux/battery/sec_charging_common.h>
#define VENDOR_UNKNOWN 0
#define VENDOR_LSI 1
#define VENDOR_QCOM 2
#endif /* __SEC_ADC_H */

View file

@ -0,0 +1,498 @@
/*
* 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/of_gpio.h>
#include <linux/alarmtimer.h>
#include <linux/wakelock.h>
#include <linux/workqueue.h>
#include <linux/proc_fs.h>
#include <linux/jiffies.h>
#if defined(CONFIG_MUIC_NOTIFIER)
#include <linux/muic/muic.h>
#include <linux/muic/muic_notifier.h>
#endif /* CONFIG_MUIC_NOTIFIER */
#if defined(CONFIG_VBUS_NOTIFIER)
#include <linux/vbus_notifier.h>
#endif
#include <linux/sec_batt.h>
#define SEC_BAT_CURRENT_EVENT_NONE 0x0000
#define SEC_BAT_CURRENT_EVENT_AFC 0x0001
#define SEC_BAT_CURRENT_EVENT_LOW_TEMP_SWELLING 0x0010
#define SEC_BAT_CURRENT_EVENT_HIGH_TEMP_SWELLING 0x0020
#define SIOP_EVENT_NONE 0x0000
#define SIOP_EVENT_WPC_CALL 0x0001
#if defined(CONFIG_CHARGING_VZWCONCEPT)
#define STORE_MODE_CHARGING_MAX 35
#define STORE_MODE_CHARGING_MIN 30
#else
#define STORE_MODE_CHARGING_MAX 70
#define STORE_MODE_CHARGING_MIN 60
#endif
#define ADC_CH_COUNT 10
#define ADC_SAMPLE_COUNT 10
#define DEFAULT_HEALTH_CHECK_COUNT 5
#define TEMP_HIGHLIMIT_DEFAULT 2000
#define SIOP_INPUT_LIMIT_CURRENT 1200
#define SIOP_CHARGING_LIMIT_CURRENT 1000
#define SIOP_WIRELESS_INPUT_LIMIT_CURRENT 530
#define SIOP_WIRELESS_CHARGING_LIMIT_CURRENT 780
#define SIOP_HV_WIRELESS_INPUT_LIMIT_CURRENT 700
#define SIOP_HV_WIRELESS_CHARGING_LIMIT_CURRENT 600
#define SIOP_HV_INPUT_LIMIT_CURRENT 1200
#define SIOP_HV_CHARGING_LIMIT_CURRENT 1000
#define BATT_MISC_EVENT_UNDEFINED_RANGE_TYPE 0x00000001
#if defined(CONFIG_BATTERY_SWELLING)
enum swelling_mode_state {
SWELLING_MODE_NONE = 0,
SWELLING_MODE_CHARGING,
SWELLING_MODE_FULL,
SWELLING_MODE_ADDITIONAL,
};
#endif
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;
struct power_supply psy_wireless;
struct power_supply psy_ps;
unsigned int irq;
struct notifier_block batt_nb;
#if defined(CONFIG_VBUS_NOTIFIER)
struct notifier_block vbus_nb;
#endif
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 inbat_adc; /* inbat adc */
int current_avg; /* average current (mA) */
int current_max; /* input current limit (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 delayed_work monitor_work;
#ifdef CONFIG_SAMSUNG_BATTERY_FACTORY
struct wake_lock lpm_wake_lock;
#endif
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;
/* battery check */
unsigned int check_count;
/* ADC check */
unsigned int check_adc_count;
unsigned int check_adc_value;
/* health change check */
bool health_change;
/* ovp-uvlo health check */
int health_check_count;
/* time check */
unsigned long charging_start_time;
unsigned long charging_passed_time;
unsigned long charging_next_time;
unsigned long charging_fullcharged_time;
unsigned long wc_heating_start_time;
unsigned long wc_heating_passed_time;
unsigned int wc_heat_limit;
/* chg temperature check */
bool chg_limit;
/* wpc temperature and pad status check */
bool pad_limit;
/* temperature check */
int temperature; /* battery temperature */
int temper_amb; /* target temperature */
int chg_temp; /* charger temperature */
int pre_chg_temp;
int wpc_temp;
int slave_chg_temp;
int pre_slave_chg_temp;
int temp_adc;
int temp_ambient_adc;
int chg_temp_adc;
int wpc_temp_adc;
int slave_chg_temp_adc;
int temp_highlimit_threshold;
int temp_highlimit_recovery;
int temp_high_threshold;
int temp_high_recovery;
int temp_low_threshold;
int temp_low_recovery;
unsigned int temp_highlimit_cnt;
unsigned int temp_high_cnt;
unsigned int temp_low_cnt;
unsigned int temp_recover_cnt;
/* charging */
unsigned int charging_mode;
bool is_recharging;
int wdt_kick_disable;
bool is_jig_on;
int cable_type;
int muic_cable_type;
#if defined(CONFIG_VBUS_NOTIFIER)
int muic_vbus_status;
#endif
int extended_cable_type;
struct wake_lock cable_wake_lock;
struct delayed_work cable_work;
struct wake_lock vbus_wake_lock;
struct delayed_work siop_work;
struct wake_lock siop_wake_lock;
struct wake_lock afc_wake_lock;
struct delayed_work afc_work;
struct delayed_work wc_afc_work;
#if defined(CONFIG_WIRELESS_FIRMWARE_UPDATE)
struct delayed_work update_work;
struct delayed_work fw_init_work;
#endif
struct delayed_work siop_event_work;
struct wake_lock siop_event_wake_lock;
struct delayed_work siop_level_work;
struct wake_lock siop_level_wake_lock;
struct delayed_work wc_headroom_work;
struct wake_lock wc_headroom_wake_lock;
#if defined(CONFIG_UPDATE_BATTERY_DATA)
struct delayed_work batt_data_work;
struct wake_lock batt_data_wake_lock;
char *data_path;
#endif
unsigned int full_check_cnt;
unsigned int recharge_check_cnt;
struct mutex iolock;
int wired_input_current;
int wireless_input_current;
int charging_current;
int topoff_current;
unsigned int current_event;
/* wireless charging enable*/
int wc_enable;
int wc_status;
bool wc_cv_mode;
bool wc_pack_max_curr;
int wire_status;
/* wearable charging */
int ps_status;
int ps_enable;
/* test mode */
int test_mode;
bool factory_mode;
bool store_mode;
bool ignore_store_mode;
bool slate_mode;
/* MTBF test for CMCC */
bool is_hc_usb;
bool ignore_siop;
int r_siop_level;
int siop_level;
int siop_event;
int siop_prev_event;
int stability_test;
int eng_not_full_status;
bool skip_chg_temp_check;
bool skip_wpc_temp_check;
bool wpc_temp_mode;
#if defined(CONFIG_BATTERY_SWELLING_SELF_DISCHARGING)
bool factory_self_discharging_mode_on;
bool force_discharging;
bool self_discharging;
bool discharging_ntc;
int discharging_ntc_adc;
int self_discharging_adc;
#endif
#if defined(CONFIG_SW_SELF_DISCHARGING)
bool sw_self_discharging;
struct wake_lock self_discharging_wake_lock;
#endif
bool charging_block;
#if defined(CONFIG_BATTERY_SWELLING)
unsigned int swelling_mode;
int swelling_full_check_cnt;
#endif
#if defined(CONFIG_AFC_CHARGER_MODE)
char *hv_chg_name;
#endif
#if defined(CONFIG_CALC_TIME_TO_FULL)
int timetofull;
bool complete_timetofull;
struct delayed_work timetofull_work;
#endif
#if defined(CONFIG_BATTERY_AGE_FORECAST)
int batt_cycle;
#endif
#if defined(CONFIG_STEP_CHARGING)
int step_charging_status;
int step_charging_step;
#endif
int battery_type;
struct mutex misclock;
unsigned int misc_event;
unsigned int prev_misc_event;
struct delayed_work misc_event_work;
struct wake_lock misc_event_wake_lock;
};
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)
#define EVENT_LCD (0x1 << 12)
#define EVENT_GPS (0x1 << 13)
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_CURRENT_UA_NOW,
BATT_CURRENT_UA_AVG,
BATT_TEMP,
BATT_TEMP_ADC,
BATT_TEMP_AVER,
BATT_TEMP_ADC_AVER,
BATT_CHG_TEMP,
BATT_CHG_TEMP_ADC,
BATT_SLAVE_CHG_TEMP,
BATT_SLAVE_CHG_TEMP_ADC,
BATT_VF_ADC,
BATT_SLATE_MODE,
BATT_LP_CHARGING,
SIOP_ACTIVATED,
SIOP_LEVEL,
SIOP_EVENT,
BATT_CHARGING_SOURCE,
FG_REG_DUMP,
FG_RESET_CAP,
FG_CAPACITY,
FG_ASOC,
AUTH,
CHG_CURRENT_ADC,
WC_ADC,
WC_STATUS,
WC_ENABLE,
WC_CONTROL,
HV_CHARGER_STATUS,
HV_WC_CHARGER_STATUS,
HV_CHARGER_SET,
FACTORY_MODE,
STORE_MODE,
UPDATE,
TEST_MODE,
BATT_EVENT_CALL,
BATT_EVENT_2G_CALL,
BATT_EVENT_TALK_GSM,
BATT_EVENT_3G_CALL,
BATT_EVENT_TALK_WCDMA,
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_LCD,
BATT_EVENT_GPS,
BATT_EVENT,
BATT_TEMP_TABLE,
BATT_HIGH_CURRENT_USB,
#if defined(CONFIG_SAMSUNG_BATTERY_ENG_TEST)
BATT_TEST_CHARGE_CURRENT,
#endif
BATT_STABILITY_TEST,
BATT_CAPACITY_MAX,
BATT_INBAT_VOLTAGE,
#if defined(CONFIG_BATTERY_SWELLING_SELF_DISCHARGING)
BATT_DISCHARGING_CHECK,
BATT_DISCHARGING_CHECK_ADC,
BATT_DISCHARGING_NTC,
BATT_DISCHARGING_NTC_ADC,
BATT_SELF_DISCHARGING_CONTROL,
#endif
#if defined(CONFIG_SW_SELF_DISCHARGING)
BATT_SW_SELF_DISCHARGING,
#endif
BATT_INBAT_WIRELESS_CS100,
HMT_TA_CONNECTED,
HMT_TA_CHARGE,
#if defined(CONFIG_BATTERY_SMART)
FG_FIRMWARE,
#endif
#if defined(CONFIG_BATTERY_AGE_FORECAST)
FG_CYCLE,
FG_FULLCAPNOM,
BATTERY_CYCLE,
#endif
FG_FULL_VOLTAGE,
BATT_WPC_TEMP,
BATT_WPC_TEMP_ADC,
#if defined(CONFIG_WIRELESS_FIRMWARE_UPDATE)
BATT_WIRELESS_FIRMWARE_UPDATE,
BATT_WIRELESS_OTP_FIRMWARE_RESULT,
BATT_WIRELESS_IC_GRADE,
BATT_WIRELESS_FIRMWARE_VER_BIN,
BATT_WIRELESS_FIRMWARE_VER,
BATT_WIRELESS_TX_FIRMWARE_RESULT,
BATT_WIRELESS_TX_FIRMWARE_VER,
BATT_TX_STATUS,
#endif
BATT_WIRELESS_VOUT,
BATT_WIRELESS_VRCT,
BATT_HV_WIRELESS_STATUS,
BATT_HV_WIRELESS_PAD_CTRL,
BATT_TUNE_FLOAT_VOLTAGE,
BATT_TUNE_INPUT_CHARGE_CURRENT,
BATT_TUNE_FAST_CHARGE_CURRENT,
BATT_TUNE_UI_TERM_CURRENT_1ST,
BATT_TUNE_UI_TERM_CURRENT_2ND,
BATT_TUNE_TEMP_HIGH_NORMAL,
BATT_TUNE_TEMP_HIGH_REC_NORMAL,
BATT_TUNE_TEMP_LOW_NORMAL,
BATT_TUNE_TEMP_LOW_REC_NORMAL,
BATT_TUNE_CHG_TEMP_HIGH,
BATT_TUNE_CHG_TEMP_REC,
BATT_TUNE_CHG_LIMMIT_CURRENT,
BATT_TUNE_COIL_TEMP_HIGH,
BATT_TUNE_COIL_TEMP_REC,
BATT_TUNE_COIL_LIMMIT_CURRENT,
#if defined(CONFIG_UPDATE_BATTERY_DATA)
BATT_UPDATE_DATA,
#endif
BATT_MISC_EVENT,
FACTORY_MODE_RELIEVE,
FACTORY_MODE_BYPASS,
BATT_WDT_CONTROL,
};
#ifdef CONFIG_OF
extern int adc_read(struct sec_battery_info *battery, int channel);
extern void adc_init(struct platform_device *pdev, struct sec_battery_info *battery);
extern void adc_exit(struct sec_battery_info *battery);
#endif
#if defined(CONFIG_STEP_CHARGING)
extern void sec_bat_reset_step_charging(struct sec_battery_info *battery);
extern void sec_step_charging_init(struct sec_battery_info *battery, struct device *dev);
extern bool sec_bat_check_step_charging(struct sec_battery_info *battery);
#endif
#if defined(CONFIG_UPDATE_BATTERY_DATA)
extern int sec_battery_update_data(const char* file_path);
#endif
#endif /* __SEC_BATTERY_H */

View file

@ -0,0 +1,124 @@
/*
* 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) || \
defined(CONFIG_CHARGER_PM8917)
#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_SMB358)
#include <linux/battery/charger/smb358_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>
#elif defined(CONFIG_CHARGER_BQ24260)
#include <linux/battery/charger/bq24260_charger.h>
#elif defined(CONFIG_CHARGER_MAX77803)
#include <linux/battery/charger/max77803_charger.h>
#elif defined(CONFIG_CHARGER_MAX77804)
#include <linux/battery/charger/max77804_charger.h>
#elif defined(CONFIG_CHARGER_MAX77823)
#include <linux/battery/charger/max77823_charger.h>
#elif defined(CONFIG_CHARGER_MAX77833)
#include <linux/battery/charger/max77833_charger.h>
#elif defined(CONFIG_CHARGER_MAX77843)
#include <linux/battery/charger/max77843_charger.h>
#elif defined(CONFIG_CHARGER_MAX77888)
#include <linux/battery/charger/max77888_charger.h>
#elif defined(CONFIG_CHARGER_MAX77693)
#include <linux/battery/charger/max77693_charger.h>
#elif defined(CONFIG_CHARGER_NCP1851)
#include <linux/battery/charger/ncp1851_charger.h>
#endif
enum {
CHIP_ID = 0,
};
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;
int status;
bool is_charging;
/* charging current : + charging, - OTG */
int charging_current;
unsigned charging_current_max;
/* register programming */
int reg_addr;
int reg_data;
int irq_base;
};
bool sec_hal_chg_init(struct i2c_client *);
bool sec_hal_chg_suspend(struct i2c_client *);
bool sec_hal_chg_shutdown(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 = 0664}, \
.show = sec_chg_show_attrs, \
.store = sec_chg_store_attrs, \
}
enum {
CHG_REG = 0,
CHG_DATA,
CHG_REGS,
};
extern sec_battery_platform_data_t sec_battery_pdata;
#endif /* __SEC_CHARGER_H */

View file

@ -0,0 +1,946 @@
/*
* 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 POWER_SUPPLY_TYPE_MAX
enum sec_battery_voltage_mode {
/* average voltage */
SEC_BATTERY_VOLTAGE_AVERAGE = 0,
/* open circuit voltage */
SEC_BATTERY_VOLTAGE_OCV,
};
enum sec_battery_current_mode {
/* uA */
SEC_BATTERY_CURRENT_UA = 0,
/* mA */
SEC_BATTERY_CURRENT_MA,
};
enum sec_battery_capacity_mode {
/* designed capacity */
SEC_BATTERY_CAPACITY_DESIGNED = 0,
/* absolute capacity by fuel gauge */
SEC_BATTERY_CAPACITY_ABSOLUTE,
/* temperary capacity in the time */
SEC_BATTERY_CAPACITY_TEMPERARY,
/* current capacity now */
SEC_BATTERY_CAPACITY_CURRENT,
/* cell aging information */
SEC_BATTERY_CAPACITY_AGEDCELL,
/* charge count */
SEC_BATTERY_CAPACITY_CYCLE,
};
enum sec_wireless_info_mode {
SEC_WIRELESS_OTP_FIRM_RESULT = 0,
SEC_WIRELESS_IC_GRADE,
SEC_WIRELESS_IC_REVISION,
SEC_WIRELESS_OTP_FIRM_VER_BIN,
SEC_WIRELESS_OTP_FIRM_VER,
SEC_WIRELESS_TX_FIRM_RESULT,
SEC_WIRELESS_TX_FIRM_VER,
SEC_TX_FIRMWARE,
SEC_WIRELESS_OTP_FIRM_VERIFY,
};
enum sec_wireless_firm_update_mode {
SEC_WIRELESS_RX_SDCARD_MODE = 0,
SEC_WIRELESS_RX_BUILT_IN_MODE,
SEC_WIRELESS_TX_ON_MODE,
SEC_WIRELESS_TX_OFF_MODE,
SEC_WIRELESS_RX_INIT,
};
enum sec_tx_firmware_mode {
SEC_TX_OFF = 0,
SEC_TX_STANDBY,
SEC_TX_POWER_TRANSFER,
SEC_TX_ERROR,
};
enum sec_wireless_control_mode {
WIRELESS_VOUT_OFF = 0,
WIRELESS_VOUT_NORMAL_VOLTAGE, /* 5V , reserved by factory */
WIRELESS_VOUT_RESERVED, /* 6V */
WIRELESS_VOUT_HIGH_VOLTAGE, /* 9V , reserved by factory */
WIRELESS_VOUT_CC_CV_VOUT,
WIRELESS_VOUT_CV_CALL,
WIRELESS_VOUT_CC_CALL,
WIRELESS_VOUT_5V,
WIRELESS_VOUT_9V,
WIRELESS_VOUT_9V_OTG,
WIRELESS_PAD_FAN_OFF,
WIRELESS_PAD_FAN_ON,
WIRELESS_PAD_LED_OFF,
WIRELESS_PAD_LED_ON,
WIRELESS_VRECT_ADJ_ON,
WIRELESS_VRECT_ADJ_OFF,
WIRELESS_VRECT_ADJ_ROOM_0,
WIRELESS_VRECT_ADJ_ROOM_1,
WIRELESS_VRECT_ADJ_ROOM_2,
WIRELESS_VRECT_ADJ_ROOM_3,
WIRELESS_VRECT_ADJ_ROOM_4,
WIRELESS_VRECT_ADJ_ROOM_5,
WIRELESS_CLAMP_ENABLE,
};
enum sec_siop_event_mode {
SIOP_EVENT_IDLE = 0,
SIOP_EVENT_WPC_CALL_START, /* 5V wireless charging + Call */
SIOP_EVENT_WPC_CALL_END, /* 5V wireless charging + Call */
SIOP_EVENT_MAX, /* end */
};
enum sec_wireless_pad_mode {
SEC_WIRELESS_PAD_NONE = 0,
SEC_WIRELESS_PAD_WPC,
SEC_WIRELESS_PAD_WPC_PACK,
SEC_WIRELESS_PAD_WPC_PACK_TA,
SEC_WIRELESS_PAD_WPC_HV,
SEC_WIRELESS_PAD_PMA,
};
/* ADC type */
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,
SEC_BATTERY_ADC_TYPE_NUM
};
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,
SEC_BAT_ADC_CHANNEL_VOLTAGE_NOW,
SEC_BAT_ADC_CHANNEL_CHG_TEMP,
SEC_BAT_ADC_CHANNEL_INBAT_VOLTAGE,
SEC_BAT_ADC_CHANNEL_DISCHARGING_CHECK,
SEC_BAT_ADC_CHANNEL_DISCHARGING_NTC,
SEC_BAT_ADC_CHANNEL_WPC_TEMP,
SEC_BAT_ADC_CHANNEL_SLAVE_CHG_TEMP,
SEC_BAT_ADC_CHANNEL_NUM,
};
enum sec_battery_charge_mode {
SEC_BAT_CHG_MODE_CHARGING = 0,
SEC_BAT_CHG_MODE_CHARGING_OFF,
SEC_BAT_CHG_MODE_BUCK_OFF,
};
/* charging mode */
enum sec_battery_charging_mode {
/* no charging */
SEC_BATTERY_CHARGING_NONE = 0,
/* 1st charging */
SEC_BATTERY_CHARGING_1ST,
/* 2nd charging */
SEC_BATTERY_CHARGING_2ND,
/* recharging */
SEC_BATTERY_CHARGING_RECHARGING,
};
/* chg_temp state */
enum sec_battery_chg_temp_state {
SEC_BATTERY_CHG_TEMP_NONE = 0,
SEC_BATTERY_CHG_TEMP_HIGH_1ST,
SEC_BATTERY_CHG_TEMP_HIGH_2ND,
};
/* pad_limit state */
enum sec_battery_wpc_pad_state {
SEC_BATTERY_WPC_TEMP_NONE = 0,
SEC_BATTERY_WPC_TEMP_HIGH,
};
/* heat_limit state */
enum sec_battery_wc_heat_state {
SEC_BATTERY_WC_HEAT_NONE = 0, /* (9V, 1A), (9V, 600mA) */
SEC_BATTERY_WC_HEAT_HIGH, /* (5V, 400mA) */
};
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 (NOT USE) */
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 {
SEC_BATTERY_FULLCHARGED_NONE = 0,
/* current check by ADC */
SEC_BATTERY_FULLCHARGED_ADC,
/* fuel gauge current check */
SEC_BATTERY_FULLCHARGED_FG_CURRENT,
/* time check */
SEC_BATTERY_FULLCHARGED_TIME,
/* SOC check */
SEC_BATTERY_FULLCHARGED_SOC,
/* charger GPIO, NO additional full condition */
SEC_BATTERY_FULLCHARGED_CHGGPIO,
/* charger interrupt, NO additional full condition */
SEC_BATTERY_FULLCHARGED_CHGINT,
/* charger power supply property, NO additional full condition */
SEC_BATTERY_FULLCHARGED_CHGPSY,
SEC_BATTERY_FULLCHARGED_SMART_FG,
};
/* Self discharger type */
enum sec_battery_discharger_type {
/* type ADC */
SEC_BAT_SELF_DISCHARGING_BY_ADC = 0,
/* type Fuel Gauge */
SEC_BAT_SELF_DISCHARGING_BY_FG,
/* type Charger */
SEC_BAT_SELF_DISCHARGING_BY_CHG,
};
#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
* full-charged by absolute-timer only in high voltage
*/
#define SEC_BATTERY_FULL_CONDITION_NOTIMEFULL 1
/* SEC_BATTERY_FULL_CONDITION_NOSLEEPINFULL
* do not set polling time as sleep polling time in full-charged
*/
#define SEC_BATTERY_FULL_CONDITION_NOSLEEPINFULL 2
/* SEC_BATTERY_FULL_CONDITION_SOC
* use capacity for full-charged check
*/
#define SEC_BATTERY_FULL_CONDITION_SOC 4
/* SEC_BATTERY_FULL_CONDITION_VCELL
* use VCELL for full-charged check
*/
#define SEC_BATTERY_FULL_CONDITION_VCELL 8
/* SEC_BATTERY_FULL_CONDITION_AVGVCELL
* use average VCELL for full-charged check
*/
#define SEC_BATTERY_FULL_CONDITION_AVGVCELL 16
/* SEC_BATTERY_FULL_CONDITION_OCV
* use OCV for full-charged check
*/
#define SEC_BATTERY_FULL_CONDITION_OCV 32
/* 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 stuck into discharging,
* but internal charging logic is working
*/
#define SEC_BATTERY_CABLE_CHECK_NOUSBCHARGE 1
/* SEC_BATTERY_CABLE_CHECK_NOINCOMPATIBLECHARGE
* for incompatible charger
* (Not compliant to USB specification,
* cable type is POWER_SUPPLY_TYPE_UNKNOWN),
* do NOT charge and show message to user
* (only for VZW)
*/
#define SEC_BATTERY_CABLE_CHECK_NOINCOMPATIBLECHARGE 2
/* SEC_BATTERY_CABLE_CHECK_PSY
* check cable by power supply set_property
*/
#define SEC_BATTERY_CABLE_CHECK_PSY 4
/* SEC_BATTERY_CABLE_CHECK_INT
* check cable by interrupt
*/
#define SEC_BATTERY_CABLE_CHECK_INT 8
/* SEC_BATTERY_CABLE_CHECK_CHGINT
* check cable by charger interrupt
*/
#define SEC_BATTERY_CABLE_CHECK_CHGINT 16
/* SEC_BATTERY_CABLE_CHECK_POLLING
* check cable by GPIO polling
*/
#define SEC_BATTERY_CABLE_CHECK_POLLING 32
/* check cable source (can be used overlapped) */
#define sec_battery_cable_source_t unsigned int
/* SEC_BATTERY_CABLE_SOURCE_EXTERNAL
* already given by external argument
*/
#define SEC_BATTERY_CABLE_SOURCE_EXTERNAL 1
/* SEC_BATTERY_CABLE_SOURCE_CALLBACK
* by callback (MUIC, USB switch)
*/
#define SEC_BATTERY_CABLE_SOURCE_CALLBACK 2
/* SEC_BATTERY_CABLE_SOURCE_ADC
* by ADC
*/
#define SEC_BATTERY_CABLE_SOURCE_ADC 4
/* capacity calculation type (can be used overlapped) */
#define sec_fuelgauge_capacity_type_t 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 1
/* SEC_FUELGAUGE_CAPACITY_TYPE_SCALE
* rescale capacity by scaling, need min and max value for scaling
*/
#define SEC_FUELGAUGE_CAPACITY_TYPE_SCALE 2
/* SEC_FUELGAUGE_CAPACITY_TYPE_DYNAMIC_SCALE
* change only maximum capacity dynamically
* to keep time for every SOC unit
*/
#define SEC_FUELGAUGE_CAPACITY_TYPE_DYNAMIC_SCALE 4
/* SEC_FUELGAUGE_CAPACITY_TYPE_ATOMIC
* change capacity value by only -1 or +1
* no sudden change of capacity
*/
#define SEC_FUELGAUGE_CAPACITY_TYPE_ATOMIC 8
/* SEC_FUELGAUGE_CAPACITY_TYPE_SKIP_ABNORMAL
* skip current capacity value
* if it is abnormal value
*/
#define SEC_FUELGAUGE_CAPACITY_TYPE_SKIP_ABNORMAL 16
/* charger function settings (can be used overlapped) */
#define sec_charger_functions_t unsigned int
/* SEC_CHARGER_NO_GRADUAL_CHARGING_CURRENT
* disable gradual charging current setting
* SUMMIT:AICL, MAXIM:regulation loop
*/
#define SEC_CHARGER_NO_GRADUAL_CHARGING_CURRENT 1
/* SEC_CHARGER_MINIMUM_SIOP_CHARGING_CURRENT
* charging current should be over than USB charging current
*/
#define SEC_CHARGER_MINIMUM_SIOP_CHARGING_CURRENT 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 data;
};
#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 {
#ifdef CONFIG_OF
unsigned int input_current_limit;
unsigned int fast_charging_current;
unsigned int full_check_current_1st;
unsigned int full_check_current_2nd;
#else
int input_current_limit;
int fast_charging_current;
int full_check_current_1st;
int full_check_current_2nd;
#endif
};
#define sec_charging_current_t \
struct sec_charging_current
#if defined(CONFIG_BATTERY_AGE_FORECAST)
struct sec_age_data {
unsigned int cycle;
unsigned int float_voltage;
unsigned int recharge_condition_vcell;
unsigned int full_condition_vcell;
unsigned int full_condition_soc;
};
#define sec_age_data_t \
struct sec_age_data
#endif
struct sec_battery_platform_data {
/* NO NEED TO BE CHANGED */
/* callback functions */
void (*initial_check)(void);
void (*monitor_additional_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);
bool (*is_interrupt_cable_check_possible)(int);
int (*check_cable_callback)(void);
int (*get_cable_from_extended_cable_type)(int);
bool (*cable_switch_check)(void);
bool (*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;
#ifdef CONFIG_OF
unsigned int *polling_time;
char *chip_vendor;
unsigned int temp_adc_type;
#else
int *polling_time;
#endif
/* NO NEED TO BE CHANGED */
unsigned int pre_afc_input_current;
unsigned int pre_wc_afc_input_current;
unsigned int store_mode_afc_input_current;
unsigned int store_mode_hv_wireless_input_current;
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;
int bat_irq_gpio;
unsigned int bat_irq_attr;
int jig_irq;
unsigned long jig_irq_attr;
sec_battery_cable_check_t cable_check_type;
sec_battery_cable_source_t cable_source_type;
bool use_LED; /* use charging LED */
/* flag for skipping the swelling mode */
bool swelling_mode_skip_in_high_temp;
/* sustaining event after deactivated (second) */
unsigned int event_waiting_time;
/* battery swelling */
int swelling_high_temp_block;
int swelling_high_temp_recov;
int swelling_low_temp_block;
int swelling_low_temp_recov;
int swelling_low_temp_additional;
unsigned int swelling_low_temp_current;
unsigned int swelling_low_temp_topoff;
unsigned int swelling_high_temp_current;
unsigned int swelling_low_temp_additional_current;
unsigned int swelling_high_temp_topoff;
unsigned int swelling_normal_float_voltage;
unsigned int swelling_drop_float_voltage;
unsigned int swelling_high_rechg_voltage;
unsigned int swelling_low_rechg_voltage;
#if defined(CONFIG_CALC_TIME_TO_FULL)
unsigned int ttf_hv_charge_current;
unsigned int ttf_hv_wireless_charge_current;
#endif
#if defined(CONFIG_STEP_CHARGING)
/* step charging */
unsigned int *step_charging_condition;
unsigned int *step_charging_current;
#endif
/* self discharging */
bool self_discharging_en;
unsigned int discharging_adc_max;
unsigned int discharging_adc_min;
unsigned int self_discharging_voltage_limit;
unsigned int discharging_ntc_limit;
int force_discharging_limit;
int force_discharging_recov;
int factory_discharging;
unsigned int self_discharging_type;
#if defined(CONFIG_SW_SELF_DISCHARGING)
/* sw self discharging */
int self_discharging_temp_block;
int self_discharging_volt_block;
int self_discharging_temp_recov;
int self_discharging_temp_pollingtime;
#endif
/* 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;
/*
* inbat_adc_table
* in-battery voltage check for table models:
* To read real battery voltage with Jig cable attached,
* dedicated hw pin & conversion table of adc-voltage are required
*/
#ifdef CONFIG_OF
sec_bat_adc_table_data_t *temp_adc_table;
sec_bat_adc_table_data_t *temp_amb_adc_table;
sec_bat_adc_table_data_t *chg_temp_adc_table;
sec_bat_adc_table_data_t *wpc_temp_adc_table;
sec_bat_adc_table_data_t *slave_chg_temp_adc_table;
sec_bat_adc_table_data_t *inbat_adc_table;
#else
const sec_bat_adc_table_data_t *temp_adc_table;
const sec_bat_adc_table_data_t *temp_amb_adc_table;
#endif
unsigned int temp_adc_table_size;
unsigned int temp_amb_adc_table_size;
unsigned int chg_temp_adc_table_size;
unsigned int wpc_temp_adc_table_size;
unsigned int slave_chg_temp_adc_table_size;
unsigned int inbat_adc_table_size;
sec_battery_temp_check_t temp_check_type;
unsigned int temp_check_count;
unsigned int chg_temp_check; /* Control the charging current depending on the chg_thm */
unsigned int chg_thermal_source; /* To confirm the charger temperature */
unsigned int wpc_temp_check;
unsigned int wpc_thermal_source; /* To confirm the wpc temperature */
unsigned int slave_chg_temp_check;
unsigned int slave_thermal_source; /* To confirm the slave charger temperature */
unsigned int inbat_voltage;
/*
* limit can be ADC value or Temperature
* depending on temp_check_type
* temperature should be temp x 10 (0.1 degree)
*/
int temp_highlimit_threshold_normal;
int temp_highlimit_recovery_normal;
int temp_high_threshold_normal;
int temp_high_recovery_normal;
int temp_low_threshold_normal;
int temp_low_recovery_normal;
int temp_highlimit_threshold_lpm;
int temp_highlimit_recovery_lpm;
int temp_high_threshold_lpm;
int temp_high_recovery_lpm;
int temp_low_threshold_lpm;
int temp_low_recovery_lpm;
int chg_high_temp_1st;
int chg_high_temp_2nd;
int chg_high_temp_recovery;
unsigned int chg_charging_limit_current;
unsigned int chg_charging_limit_current_2nd;
unsigned int chg_skip_check_time;
unsigned int chg_skip_check_capacity;
int wpc_high_temp;
int wpc_high_temp_recovery;
int wpc_heat_temp_recovery;
int wpc_lcd_on_high_temp;
int wpc_lcd_on_high_temp_rec;
unsigned int wpc_hv_lcd_on_input_limit_current;
unsigned int wpc_charging_limit_current;
unsigned int sleep_mode_limit_current;
unsigned int wc_full_input_limit_current;
unsigned int wc_heating_input_limit_current;
unsigned int wc_heating_time;
unsigned int wc_cv_current;
unsigned int wpc_skip_check_time;
unsigned int wpc_skip_check_capacity;
/* If these is NOT full check type or NONE full check type,
* it is skipped
*/
/* 1st full check */
sec_battery_full_charged_t full_check_type;
/* 2nd full check */
sec_battery_full_charged_t full_check_type_2nd;
unsigned int full_check_count;
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_vcell;
unsigned int full_condition_avgvcell;
unsigned int full_condition_ocv;
unsigned int recharge_check_count;
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
*/
int capacity_max;
int capacity_max_hv;
int capacity_max_margin;
int capacity_min;
/* charger */
char *charger_name;
char *fgsrc_switch_name;
bool support_fgsrc_change;
/* wireless charger */
char *wireless_charger_name;
int wireless_cc_cv;
int wpc_det;
int wpc_en;
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) */
#ifdef CONFIG_OF
unsigned int chg_float_voltage;
#else
int chg_float_voltage;
#endif
#if defined(CONFIG_BATTERY_AGE_FORECAST)
int num_age_step;
int age_step;
int age_data_length;
sec_age_data_t* age_data;
#endif
unsigned int siop_event_check_type;
unsigned int siop_call_cc_current;
unsigned int siop_call_cv_current;
int siop_input_limit_current;
int siop_charging_limit_current;
int siop_hv_input_limit_current;
int siop_hv_charging_limit_current;
int siop_wireless_input_limit_current;
int siop_wireless_charging_limit_current;
int siop_hv_wireless_input_limit_current;
int siop_hv_wireless_charging_limit_current;
sec_charger_functions_t chg_functions_setting;
bool fake_capacity;
bool always_enable;
bool chg_eoc_dualpath;
/* ADC setting */
unsigned int adc_check_count;
/* ADC type for each channel */
unsigned int adc_type[];
};
struct sec_charger_platform_data {
bool (*chg_gpio_init)(void);
/* charging current for type (0: not use) */
sec_charging_current_t *charging_current;
/* wirelss charger */
char *wireless_charger_name;
int wireless_cc_cv;
int vbus_ctrl_gpio;
int chg_gpio_en;
/* 1 : active high, 0 : active low */
int chg_polarity_en;
/* float voltage (mV) */
int chg_float_voltage;
int irq_gpio;
int chg_irq;
unsigned long chg_irq_attr;
bool support_slow_charging;
/* otg_en setting */
int otg_en;
/* OVP/UVLO check */
sec_battery_ovp_uvlo_t ovp_uvlo_check_type;
/* 1st full check */
sec_battery_full_charged_t full_check_type;
/* 2nd full check */
sec_battery_full_charged_t full_check_type_2nd;
sec_charger_functions_t chg_functions_setting;
};
struct sec_fuelgauge_platform_data {
bool (*fg_gpio_init)(void);
bool (*check_jig_status)(void);
int (*check_cable_callback)(void);
bool (*fuelalert_process)(bool);
/* charging current for type (0: not use) */
sec_charging_current_t *charging_current;
int jig_irq;
int jig_gpio;
unsigned long jig_irq_attr;
sec_battery_thermal_source_t thermal_source;
int fg_irq;
unsigned long fg_irq_attr;
/* fuel alert SOC (-1: not use) */
int fuel_alert_soc;
int fuel_alert_vol;
/* 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
*/
int capacity_max;
int capacity_max_hv;
int capacity_max_margin;
int capacity_min;
int rcomp0;
int rcomp_charging;
#if defined(CONFIG_BATTERY_AGE_FORECAST)
unsigned int full_condition_soc;
#endif
};
#define sec_battery_platform_data_t \
struct sec_battery_platform_data
#define sec_charger_platform_data_t \
struct sec_charger_platform_data
#define sec_fuelgauge_platform_data_t \
struct sec_fuelgauge_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 { \
if (psy->function##_property != NULL) { \
ret = psy->function##_property(psy, (property), &(value)); \
if (ret < 0) { \
pr_err("%s: Fail to %s "#function" (%d=>%d)\n", \
__func__, name, (property), ret); \
value.intval = 0; \
} \
} \
} \
}
#ifndef CONFIG_OF
#define adc_init(pdev, pdata, channel) \
(((pdata)->adc_api)[((((pdata)->adc_type[(channel)]) < \
SEC_BATTERY_ADC_TYPE_NUM) ? ((pdata)->adc_type[(channel)]) : \
SEC_BATTERY_ADC_TYPE_NONE)].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)))
#endif
#define get_battery_data(driver) \
(((struct battery_data_t *)(driver)->pdata->battery_data) \
[(driver)->pdata->battery_type])
#endif /* __SEC_CHARGING_COMMON_H */

View file

@ -0,0 +1,119 @@
/*
* 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_MAX77823)
#include <linux/battery/fuelgauge/max77823_fuelgauge.h>
#elif defined(CONFIG_FUELGAUGE_MAX77833)
#include <linux/battery/fuelgauge/max77833_fuelgauge.h>
#elif defined(CONFIG_FUELGAUGE_MAX77843)
#include <linux/battery/fuelgauge/max77843_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;
};
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 */
unsigned int capacity_max; /* only for dynamic calculation */
bool initial_update_of_soc;
struct mutex fg_lock;
/* register programming */
int reg_addr;
u8 reg_data[2];
int fg_irq;
};
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 = 0664}, \
.show = sec_fg_show_attrs, \
.store = sec_fg_store_attrs, \
}
enum {
FG_REG = 0,
FG_DATA,
FG_REGS,
};
#endif /* __SEC_FUELGAUGE_H */