mirror of
https://github.com/torvalds/linux.git
synced 2026-06-08 14:42:37 +02:00
power_supply: add cw2015 battery support
Change-Id: I36d65b9765a3303169f0ff60025d9ae722ceb1a9 Signed-off-by: Shunqing Chen <csq@rock-chips.com>
This commit is contained in:
parent
1f58bcd52f
commit
be11109547
|
|
@ -490,6 +490,13 @@ config BATTERY_EC
|
|||
If you say yes here you will get support for the battery of EC.
|
||||
This driver can give support for EC Battery Interface.
|
||||
|
||||
config BATTERY_CW2015
|
||||
bool "CW2015 Battery driver"
|
||||
default n
|
||||
help
|
||||
If you say yes here you will get support for the battery of CW2015.
|
||||
This driver can give support for CW2015 Battery Interface.
|
||||
|
||||
config BATTERY_GOLDFISH
|
||||
tristate "Goldfish battery driver"
|
||||
depends on GOLDFISH || COMPILE_TEST
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ obj-$(CONFIG_TEST_POWER) += test_power.o
|
|||
|
||||
obj-$(CONFIG_BATTERY_88PM860X) += 88pm860x_battery.o
|
||||
obj-$(CONFIG_BATTERY_EC) += ec_battery.o
|
||||
obj-$(CONFIG_BATTERY_CW2015) += cw2015_battery.o
|
||||
obj-$(CONFIG_BATTERY_DS2760) += ds2760_battery.o
|
||||
obj-$(CONFIG_BATTERY_DS2780) += ds2780_battery.o
|
||||
obj-$(CONFIG_BATTERY_DS2781) += ds2781_battery.o
|
||||
|
|
|
|||
1302
drivers/power/cw2015_battery.c
Executable file → Normal file
1302
drivers/power/cw2015_battery.c
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
|
|
@ -38,11 +38,20 @@
|
|||
#define CONFIG_UPDATE_FLG (0x1<<1)
|
||||
#define ATHD (0x0<<3)
|
||||
|
||||
#define CW_I2C_SPEED 100000
|
||||
#define BATTERY_UP_MAX_CHANGE 420
|
||||
#define BATTERY_DOWN_CHANGE 60
|
||||
#define BATTERY_DOWN_MIN_CHANGE_RUN 30
|
||||
#define BATTERY_DOWN_MIN_CHANGE_SLEEP 1800
|
||||
#define CW_I2C_SPEED 100000
|
||||
#define BATTERY_UP_MAX_CHANGE (420 * 1000)
|
||||
#define BATTERY_DOWN_MAX_CHANGE (120 * 1000)
|
||||
#define BATTERY_DOWN_CHANGE 60
|
||||
#define BATTERY_DOWN_MIN_CHANGE_RUN 30
|
||||
#define BATTERY_DOWN_MIN_CHANGE_SLEEP 1800
|
||||
#define BATTERY_JUMP_TO_ZERO (30 * 1000)
|
||||
#define BATTERY_CAPACITY_ERROR (40 * 1000)
|
||||
#define BATTERY_CHARGING_ZERO (1800 * 1000)
|
||||
|
||||
#define DOUBLE_SERIES_BATTERY 0
|
||||
|
||||
#define CHARGING_ON 1
|
||||
#define NO_CHARGING 0
|
||||
|
||||
#define BATTERY_DOWN_MAX_CHANGE_RUN_AC_ONLINE 3600
|
||||
|
||||
|
|
@ -54,19 +63,26 @@
|
|||
#define AC_CHARGER_MODE 2
|
||||
#define CW_QUICKSTART 0
|
||||
|
||||
#define TIMER_MS_COUNTS 1000
|
||||
#define DEFAULT_MONITOR_SEC 8
|
||||
|
||||
/* virtual params */
|
||||
#define VIRTUAL_CURRENT 1000
|
||||
#define VIRTUAL_VOLTAGE 3888
|
||||
#define VIRTUAL_SOC 66
|
||||
#define VIRTUAL_PRESET 1
|
||||
#define VIRTUAL_TEMPERATURE 188
|
||||
#define VIRTUAL_TIME2EMPTY 60
|
||||
#define VIRTUAL_STATUS POWER_SUPPLY_STATUS_CHARGING
|
||||
|
||||
enum bat_mode {
|
||||
MODE_BATTARY = 0,
|
||||
MODE_VIRTUAL,
|
||||
};
|
||||
|
||||
struct cw_bat_platform_data {
|
||||
int is_dc_charge;
|
||||
int dc_det_pin;
|
||||
int dc_det_level;
|
||||
|
||||
int is_usb_charge;
|
||||
int chg_mode_sel_pin;
|
||||
int chg_mode_sel_level;
|
||||
|
||||
int bat_low_pin;
|
||||
int bat_low_level;
|
||||
int chg_ok_pin;
|
||||
int chg_ok_level;
|
||||
int divider_res1;
|
||||
int divider_res2;
|
||||
u32 *cw_bat_config_info;
|
||||
};
|
||||
|
||||
|
|
@ -74,52 +90,27 @@ struct cw_battery {
|
|||
struct i2c_client *client;
|
||||
struct workqueue_struct *battery_workqueue;
|
||||
struct delayed_work battery_delay_work;
|
||||
struct delayed_work dc_wakeup_work;
|
||||
struct delayed_work bat_low_wakeup_work;
|
||||
struct cw_bat_platform_data plat_data;
|
||||
|
||||
struct power_supply rk_bat;
|
||||
struct power_supply rk_ac;
|
||||
struct power_supply rk_usb;
|
||||
struct power_supply *rk_bat;
|
||||
|
||||
long sleep_time_capacity_change;
|
||||
long run_time_capacity_change;
|
||||
struct power_supply *chrg_usb_psy;
|
||||
struct power_supply *chrg_ac_psy;
|
||||
|
||||
long sleep_time_charge_start;
|
||||
long run_time_charge_start;
|
||||
|
||||
int dc_online;
|
||||
int usb_online;
|
||||
#ifdef CONFIG_PM
|
||||
struct timespec suspend_time_before;
|
||||
struct timespec after;
|
||||
int suspend_resume_mark;
|
||||
#endif
|
||||
int charger_mode;
|
||||
int charger_init_mode;
|
||||
int capacity;
|
||||
int voltage;
|
||||
int status;
|
||||
int time_to_empty;
|
||||
int alt;
|
||||
|
||||
u32 monitor_sec;
|
||||
u32 bat_mode;
|
||||
int bat_change;
|
||||
};
|
||||
|
||||
#if defined(CONFIG_ARCH_ROCKCHIP)
|
||||
int get_gadget_connect_flag(void);
|
||||
int dwc_otg_check_dpdm(void);
|
||||
int dwc_vbus_status(void);
|
||||
#else
|
||||
static inline int get_gadget_connect_flag(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int dwc_otg_check_dpdm(bool wait)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int dwc_vbus_status(void);
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user