Files
kernel_samsung_sdm670/drivers/battery_v2/include/charger/sm5705_charger.h
Bruno Martins dbcc8fefd9 treewide: Import Samsung changes from T725XXU2DUD1
Change-Id: I5c31dc4a8006a967910963fb9e7d1a0ab4ab9731
2022-02-23 22:14:25 +01:00

136 lines
4.1 KiB
C

/*
* sm5705_charger.h
* Samsung SM5705 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 __SM5705_CHARGER_H
#define __SM5705_CHARGER_H __FILE__
#include <linux/mfd/core.h>
#include <linux/mfd/sm5705/sm5705.h>
#include <linux/regulator/machine.h>
#include "include/sec_charging_common.h"
/* CONFIG: Kernel Feature & Target System configuration */
//#define SM5705_SUPPORT_AICL_CONTROL - New A series dosen't support, It's MUST be disabled
#define SM5705_SUPPORT_OTG_CONTROL //- New A series dosen't support, It's MUST be disabled
#if defined(CONFIG_USE_POGO)
#define SM5705_STATUS1_WPCINPOK (1 << 4)
#endif
enum {
CHIP_ID = 0,
CHARGER_OP_MODE=1,
DATA,
};
ssize_t sm5705_chg_show_attrs(struct device *dev, struct device_attribute *attr, char *buf);
ssize_t sm5705_chg_store_attrs(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count);
#define SM5705_CHARGER_ATTR(_name) \
{ \
.attr = {.name = #_name, .mode = 0664}, \
.show = sm5705_chg_show_attrs, \
.store = sm5705_chg_store_attrs, \
}
enum {
SM5705_MANUAL_RESET_TIME_7s = 0x1,
SM5705_MANUAL_RESET_TIME_8s = 0x2,
SM5705_MANUAL_RESET_TIME_9s = 0x3,
};
enum {
SM5705_WATCHDOG_RESET_TIME_30s = 0x0,
SM5705_WATCHDOG_RESET_TIME_60s = 0x1,
SM5705_WATCHDOG_RESET_TIME_90s = 0x2,
SM5705_WATCHDOG_RESET_TIME_120s = 0x3,
};
enum {
SM5705_TOPOFF_TIMER_10m = 0x0,
SM5705_TOPOFF_TIMER_20m = 0x1,
SM5705_TOPOFF_TIMER_30m = 0x2,
SM5705_TOPOFF_TIMER_45m = 0x3,
};
enum {
SM5705_BUCK_BOOST_FREQ_3MHz = 0x0,
SM5705_BUCK_BOOST_FREQ_2_4MHz = 0x1,
SM5705_BUCK_BOOST_FREQ_1_5MHz = 0x2,
SM5705_BUCK_BOOST_FREQ_1_8MHz = 0x3,
};
/* for VZW support */
#if defined(CONFIG_TABLET_MODEL_CONCEPT) && !defined(CONFIG_SEC_FACTORY)
#define SLOW_CHARGING_CURRENT_STANDARD 1000
#else
#define SLOW_CHARGING_CURRENT_STANDARD 400
#endif
/* SM5705 Charger - AICL reduce current configuration */
#define REDUCE_CURRENT_STEP 100
#define MINIMUM_INPUT_CURRENT 300
#define AICL_VALID_CHECK_DELAY_TIME 10
#define SM5705_EN_DISCHG_FORCE_MASK 0x02
#define SM5705_SBPS_MASK 0x07
struct sm5705_charger_data {
struct device *dev;
struct i2c_client *i2c;
struct sec_charger_platform_data *pdata;
struct power_supply *psy_chg;
struct power_supply *psy_otg;
/* for IRQ-service handling */
int irq_aicl;
int irq_vbus_pok;
int irq_wpcin_pok;
#if defined(CONFIG_USE_POGO)
int irq_wpcin_pok_pogo;
int irq_wpcin_uvlo_pogo;
#endif
int irq_topoff;
int irq_done;
int irq_otgfail;
/* for Workqueue & wake-lock, mutex process */
struct mutex charger_mutex;
struct workqueue_struct *wqueue;
struct delayed_work wpc_work;
struct delayed_work slow_chg_work;
struct delayed_work aicl_work;
#if defined(CONFIG_USE_POGO)
struct delayed_work pogo_work;
#endif
struct delayed_work topoff_work;
// temp for rev2 SW WA
struct delayed_work op_mode_switch_work; /* for WA obnormal switch case in JIG cable */
struct wake_lock wpc_wake_lock;
struct wake_lock afc_wake_lock;
#if defined(SM5705_SW_SOFT_START)
struct wake_lock softstart_wake_lock;
#endif
struct wake_lock check_slow_wake_lock;
struct wake_lock aicl_wake_lock;
/* for charging operation handling */
int status;
int charge_mode;
unsigned int is_charging;
unsigned int cable_type;
unsigned int input_current;
unsigned int charging_current;
int irq_wpcin_state;
int aicl_on;
bool topoff_pending;
// temp for rev2 SW WA
bool is_rev2_wa_done;
bool slow_late_chg_mode;
};
extern int sm5705_call_fg_device_id(void);
#if defined(SM5705_WATCHDOG_RESET_ACTIVATE)
extern void sm5705_charger_watchdog_timer_keepalive(void);
#endif
#endif /* __SM5705_CHARGER_H */