2 * Fuel gauge driver for CellWise 2013 / 2015
4 * Copyright (C) 2012, RockChip
6 * Authors: xuhuicong <xhc@rock-chips.com>
8 * Based on rk30_adc_battery.c
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
16 #ifndef CW2015_BATTERY_H
17 #define CW2015_BATTERY_H
19 #define SIZE_BATINFO 64
21 #define CW2015_GPIO_HIGH 1
22 #define CW2015_GPIO_LOW 0
24 #define REG_VERSION 0x0
27 #define REG_RRT_ALERT 0x6
28 #define REG_CONFIG 0x8
30 #define REG_BATINFO 0x10
32 #define MODE_SLEEP_MASK (0x3<<6)
33 #define MODE_SLEEP (0x3<<6)
34 #define MODE_NORMAL (0x0<<6)
35 #define MODE_QUICK_START (0x3<<4)
36 #define MODE_RESTART (0xf<<0)
38 #define CONFIG_UPDATE_FLG (0x1<<1)
41 #define CW_I2C_SPEED 100000
42 #define BATTERY_UP_MAX_CHANGE 420
43 #define BATTERY_DOWN_CHANGE 60
44 #define BATTERY_DOWN_MIN_CHANGE_RUN 30
45 #define BATTERY_DOWN_MIN_CHANGE_SLEEP 1800
47 #define BATTERY_DOWN_MAX_CHANGE_RUN_AC_ONLINE 3600
49 #define NO_STANDARD_AC_BIG_CHARGE_MODE 1
50 /* #define SYSTEM_SHUTDOWN_VOLTAGE 3400000 */
51 #define BAT_LOW_INTERRUPT 1
53 #define USB_CHARGER_MODE 1
54 #define AC_CHARGER_MODE 2
55 #define CW_QUICKSTART 0
57 struct cw_bat_platform_data {
64 int chg_mode_sel_level;
70 u32 *cw_bat_config_info;
74 struct i2c_client *client;
75 struct workqueue_struct *battery_workqueue;
76 struct delayed_work battery_delay_work;
77 struct delayed_work dc_wakeup_work;
78 struct delayed_work bat_low_wakeup_work;
79 struct cw_bat_platform_data plat_data;
81 struct power_supply rk_bat;
82 struct power_supply rk_ac;
83 struct power_supply rk_usb;
85 long sleep_time_capacity_change;
86 long run_time_capacity_change;
88 long sleep_time_charge_start;
89 long run_time_charge_start;
94 int charger_init_mode;
104 #if defined(CONFIG_ARCH_ROCKCHIP)
105 int get_gadget_connect_flag(void);
106 int dwc_otg_check_dpdm(void);
107 void rk_send_wakeup_key(void);
108 int dwc_vbus_status(void);
110 static inline int get_gadget_connect_flag(void)
115 static inline int dwc_otg_check_dpdm(bool wait)
120 static inline void rk_send_wakeup_key(void)
124 static inline int dwc_vbus_status(void);