2 * Definitions for mma8452 compass chip.
6 #include <linux/power_supply.h>
8 /* I2C register define */
9 #define INPUT_SOURCE_CONTROL_REGISTER 0x00
10 #define POWE_ON_CONFIGURATION_REGISTER 0x01
11 #define CHARGE_CURRENT_CONTROL_REGISTER 0x02
12 #define PRE_CHARGE_TERMINATION_CURRENT_CONTROL_REGISTER 0x03
13 #define CHARGE_VOLTAGE_CONTROL_REGISTER 0x04
14 #define TERMINATION_TIMER_CONTROL_REGISTER 0x05
15 #define THERMAIL_REGULATOION_CONTROL_REGISTER 0x06
16 #define MISC_OPERATION_CONTROL_REGISTER 0x07
17 #define SYSTEM_STATS_REGISTER 0x08
18 #define FAULT_STATS_REGISTER 0x09
19 #define VENDOR_STATS_REGISTER 0x0A
21 /* power-on configuration register value */
22 #define REGISTER_RESET_ENABLE 1
23 #define REGISTER_RESET_DISABLE 0
24 #define REGISTER_RESET_OFFSET 7
25 #define REGISTER_RESET_MASK 1
27 /* input source control register value */
28 #define EN_HIZ_ENABLE 1
29 #define EN_HIZ_DISABLE 0
30 #define EN_HIZ_OFFSET 7
33 #define IINLIM_100MA 0
34 #define IINLIM_150MA 1
35 #define IINLIM_500MA 2
36 #define IINLIM_900MA 3
37 #define IINLIM_1200MA 4
38 #define IINLIM_1500MA 5
39 #define IINLIM_2000MA 6
40 #define IINLIM_3000MA 7
41 #define IINLIM_OFFSET 0
44 #define CHARGE_CURRENT_64MA 0x01
45 #define CHARGE_CURRENT_128MA 0x02
46 #define CHARGE_CURRENT_256MA 0x04
47 #define CHARGE_CURRENT_512MA 0x08
48 #define CHARGE_CURRENT_1024MA 0x10
49 #define CHARGE_CURRENT_1536MA 0x18
50 #define CHARGE_CURRENT_2048MA 0x20
51 #define CHARGE_CURRENT_OFFSET 2
52 #define CHARGE_CURRENT_MASK 0x3f
54 /* Charge Termination/Timer control register value */
55 #define WATCHDOG_DISABLE 0
56 #define WATCHDOG_40S 1
57 #define WATCHDOG_80S 2
58 #define WATCHDOG_160S 3
59 #define WATCHDOG_OFFSET 4
60 #define WATCHDOG_MASK 3
62 /* misc operation control register value */
64 #define DPDM_DISABLE 0
68 /* system status register value */
69 #define VBUS_UNKNOWN 0
70 #define VBUS_USB_HOST 1
71 #define VBUS_ADAPTER_PORT 2
76 #define CHRG_NO_CHARGING 0
77 #define CHRG_PRE_CHARGE 1
78 #define CHRG_FAST_CHARGE 2
79 #define CHRG_CHRGE_DONE 3
83 /* vendor status register value */
84 #define CHIP_BQ24190 0
85 #define CHIP_BQ24191 1
86 #define CHIP_BQ24192 2
87 #define CHIP_BQ24192I 3
88 #define CHIP_BQ24190_DEBUG 4
89 #define CHIP_BQ24192_DEBUG 5
90 #define CHIP_BQ24296 10
94 /* Pre-Charge/Termination Current Control Register value */
95 /* Pre-Charge Current Limit */
96 #define PRE_CHARGE_CURRENT_LIMIT_128MA 0x00
97 #define PRE_CHARGE_CURRENT_LIMIT_256MA 0x01
98 #define PRE_CHARGE_CURRENT_LIMIT_OFFSET 4
99 #define PRE_CHARGE_CURRENT_LIMIT_MASK 0x0f
100 /* Termination Current Limit */
101 #define TERMINATION_CURRENT_LIMIT_128MA 0x00
102 #define TERMINATION_CURRENT_LIMIT_256MA 0x01
103 #define TERMINATION_CURRENT_LIMIT_OFFSET 0
104 #define TERMINATION_CURRENT_LIMIT_MASK 0x0f
105 /* Charge Mode Config */
106 #define CHARGE_MODE_CONFIG_CHARGE_DISABLE 0x00
107 #define CHARGE_MODE_CONFIG_CHARGE_BATTERY 0x01
108 #define CHARGE_MODE_CONFIG_OTG_OUTPUT 0x02
109 #define CHARGE_MODE_CONFIG_OFFSET 4
110 #define CHARGE_MODE_CONFIG_MASK 0x03
111 /* OTG Mode Current Config */
112 #define OTG_MODE_CURRENT_CONFIG_500MA 0x00
113 #define OTG_MODE_CURRENT_CONFIG_1300MA 0x01
114 #define OTG_MODE_CURRENT_CONFIG_OFFSET 0
115 #define OTG_MODE_CURRENT_CONFIG_MASK 0x01
117 #define BQ24296_CHG_COMPELET 0x03
118 #define BQ24296_NO_CHG 0x00
120 #define BQ24296_DC_CHG 0x02
121 #define BQ24296_USB_CHG 0x01
123 #define BQ24296_SPEED 300 * 1000
130 struct bq24296_device_info {
132 struct delayed_work usb_detect_work;
133 struct i2c_client *client;
134 unsigned int interval;
135 struct mutex var_lock;
136 struct workqueue_struct *freezable_work;
137 struct work_struct irq_work; /* for Charging & VUSB/VADP */
139 struct workqueue_struct *workqueue;
141 u8 usb_input_current;
142 u8 adp_input_current;
143 //struct timer_list timer;
146 struct bq24296_platform_data {
147 unsigned int otg_usb_pin;
148 unsigned int chg_irq_pin;
149 unsigned int psel_pin;
150 int (*irq_init)(void);
153 struct bq24296_board {
154 unsigned int otg_usb_pin;
155 unsigned int chg_irq_pin;
156 unsigned int dc_det_pin;
157 unsigned int psel_pin;
158 struct device_node *of_node;
159 unsigned int chg_current[3];
162 int bq24296_charge_otg_en(int chg_en,int otg_en);