2 * Driver for the TI bq24190 battery charger.
4 * Author: Mark A. Greer <mgreer@animalcreek.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
11 #include <linux/module.h>
12 #include <linux/interrupt.h>
13 #include <linux/delay.h>
14 #include <linux/of_irq.h>
15 #include <linux/of_device.h>
16 #include <linux/pm_runtime.h>
17 #include <linux/power_supply.h>
18 #include <linux/power/bq24190_charger.h>
19 #include <linux/regulator/driver.h>
20 #include <linux/regulator/machine.h>
21 #include <linux/workqueue.h>
22 #include <linux/gpio.h>
23 #include <linux/i2c.h>
25 #define BQ24190_MANUFACTURER "Texas Instruments"
27 #define BQ24190_REG_ISC 0x00 /* Input Source Control */
28 #define BQ24190_REG_ISC_EN_HIZ_MASK BIT(7)
29 #define BQ24190_REG_ISC_EN_HIZ_SHIFT 7
30 #define BQ24190_REG_ISC_VINDPM_MASK (BIT(6) | BIT(5) | BIT(4) | \
32 #define BQ24190_REG_ISC_VINDPM_SHIFT 3
33 #define BQ24190_REG_ISC_IINLIM_MASK (BIT(2) | BIT(1) | BIT(0))
34 #define BQ24190_REG_ISC_IINLIM_SHIFT 0
36 #define BQ24190_REG_POC 0x01 /* Power-On Configuration */
37 #define BQ24190_REG_POC_RESET_MASK BIT(7)
38 #define BQ24190_REG_POC_RESET_SHIFT 7
39 #define BQ24190_REG_POC_WDT_RESET_MASK BIT(6)
40 #define BQ24190_REG_POC_WDT_RESET_SHIFT 6
41 #define BQ24190_REG_POC_CHG_CONFIG_MASK (BIT(5) | BIT(4))
42 #define BQ24190_REG_POC_CHG_CONFIG_SHIFT 4
43 #define BQ24190_REG_POC_CHG_CONFIG_DISABLE 0x0
44 #define BQ24190_REG_POC_CHG_CONFIG_CHARGE 0x1
45 #define BQ24190_REG_POC_CHG_CONFIG_OTG 0x2
46 #define BQ24190_REG_POC_SYS_MIN_MASK (BIT(3) | BIT(2) | BIT(1))
47 #define BQ24190_REG_POC_SYS_MIN_SHIFT 1
48 #define BQ24190_REG_POC_SYS_MIN_MIN 3000
49 #define BQ24190_REG_POC_SYS_MIN_MAX 3700
50 #define BQ24190_REG_POC_BOOST_LIM_MASK BIT(0)
51 #define BQ24190_REG_POC_BOOST_LIM_SHIFT 0
53 #define BQ24190_REG_CCC 0x02 /* Charge Current Control */
54 #define BQ24190_REG_CCC_ICHG_MASK (BIT(7) | BIT(6) | BIT(5) | \
55 BIT(4) | BIT(3) | BIT(2))
56 #define BQ24190_REG_CCC_ICHG_SHIFT 2
57 #define BQ24190_REG_CCC_FORCE_20PCT_MASK BIT(0)
58 #define BQ24190_REG_CCC_FORCE_20PCT_SHIFT 0
60 #define BQ24190_REG_PCTCC 0x03 /* Pre-charge/Termination Current Cntl */
61 #define BQ24190_REG_PCTCC_IPRECHG_MASK (BIT(7) | BIT(6) | BIT(5) | \
63 #define BQ24190_REG_PCTCC_IPRECHG_SHIFT 4
64 #define BQ24190_REG_PCTCC_IPRECHG_MIN 128
65 #define BQ24190_REG_PCTCC_IPRECHG_MAX 2048
66 #define BQ24190_REG_PCTCC_ITERM_MASK (BIT(3) | BIT(2) | BIT(1) | \
68 #define BQ24190_REG_PCTCC_ITERM_SHIFT 0
69 #define BQ24190_REG_PCTCC_ITERM_MIN 128
70 #define BQ24190_REG_PCTCC_ITERM_MAX 2048
72 #define BQ24190_REG_CVC 0x04 /* Charge Voltage Control */
73 #define BQ24190_REG_CVC_VREG_MASK (BIT(7) | BIT(6) | BIT(5) | \
74 BIT(4) | BIT(3) | BIT(2))
75 #define BQ24190_REG_CVC_VREG_SHIFT 2
76 #define BQ24190_REG_CVC_BATLOWV_MASK BIT(1)
77 #define BQ24190_REG_CVC_BATLOWV_SHIFT 1
78 #define BQ24190_REG_CVC_VRECHG_MASK BIT(0)
79 #define BQ24190_REG_CVC_VRECHG_SHIFT 0
81 #define BQ24190_REG_CTTC 0x05 /* Charge Term/Timer Control */
82 #define BQ24190_REG_CTTC_EN_TERM_MASK BIT(7)
83 #define BQ24190_REG_CTTC_EN_TERM_SHIFT 7
84 #define BQ24190_REG_CTTC_TERM_STAT_MASK BIT(6)
85 #define BQ24190_REG_CTTC_TERM_STAT_SHIFT 6
86 #define BQ24190_REG_CTTC_WATCHDOG_MASK (BIT(5) | BIT(4))
87 #define BQ24190_REG_CTTC_WATCHDOG_SHIFT 4
88 #define BQ24190_REG_CTTC_EN_TIMER_MASK BIT(3)
89 #define BQ24190_REG_CTTC_EN_TIMER_SHIFT 3
90 #define BQ24190_REG_CTTC_CHG_TIMER_MASK (BIT(2) | BIT(1))
91 #define BQ24190_REG_CTTC_CHG_TIMER_SHIFT 1
92 #define BQ24190_REG_CTTC_JEITA_ISET_MASK BIT(0)
93 #define BQ24190_REG_CTTC_JEITA_ISET_SHIFT 0
95 #define BQ24190_REG_ICTRC 0x06 /* IR Comp/Thermal Regulation Control */
96 #define BQ24190_REG_ICTRC_BAT_COMP_MASK (BIT(7) | BIT(6) | BIT(5))
97 #define BQ24190_REG_ICTRC_BAT_COMP_SHIFT 5
98 #define BQ24190_REG_ICTRC_VCLAMP_MASK (BIT(4) | BIT(3) | BIT(2))
99 #define BQ24190_REG_ICTRC_VCLAMP_SHIFT 2
100 #define BQ24190_REG_ICTRC_TREG_MASK (BIT(1) | BIT(0))
101 #define BQ24190_REG_ICTRC_TREG_SHIFT 0
103 #define BQ24190_REG_MOC 0x07 /* Misc. Operation Control */
104 #define BQ24190_REG_MOC_DPDM_EN_MASK BIT(7)
105 #define BQ24190_REG_MOC_DPDM_EN_SHIFT 7
106 #define BQ24190_REG_MOC_TMR2X_EN_MASK BIT(6)
107 #define BQ24190_REG_MOC_TMR2X_EN_SHIFT 6
108 #define BQ24190_REG_MOC_BATFET_DISABLE_MASK BIT(5)
109 #define BQ24190_REG_MOC_BATFET_DISABLE_SHIFT 5
110 #define BQ24190_REG_MOC_JEITA_VSET_MASK BIT(4)
111 #define BQ24190_REG_MOC_JEITA_VSET_SHIFT 4
112 #define BQ24190_REG_MOC_INT_MASK_MASK (BIT(1) | BIT(0))
113 #define BQ24190_REG_MOC_INT_MASK_SHIFT 0
115 #define BQ24190_REG_SS 0x08 /* System Status */
116 #define BQ24190_REG_SS_VBUS_STAT_MASK (BIT(7) | BIT(6))
117 #define BQ24190_REG_SS_VBUS_STAT_SHIFT 6
118 #define BQ24190_REG_SS_CHRG_STAT_MASK (BIT(5) | BIT(4))
119 #define BQ24190_REG_SS_CHRG_STAT_SHIFT 4
120 #define BQ24190_REG_SS_DPM_STAT_MASK BIT(3)
121 #define BQ24190_REG_SS_DPM_STAT_SHIFT 3
122 #define BQ24190_REG_SS_PG_STAT_MASK BIT(2)
123 #define BQ24190_REG_SS_PG_STAT_SHIFT 2
124 #define BQ24190_REG_SS_THERM_STAT_MASK BIT(1)
125 #define BQ24190_REG_SS_THERM_STAT_SHIFT 1
126 #define BQ24190_REG_SS_VSYS_STAT_MASK BIT(0)
127 #define BQ24190_REG_SS_VSYS_STAT_SHIFT 0
129 #define BQ24190_REG_F 0x09 /* Fault */
130 #define BQ24190_REG_F_WATCHDOG_FAULT_MASK BIT(7)
131 #define BQ24190_REG_F_WATCHDOG_FAULT_SHIFT 7
132 #define BQ24190_REG_F_BOOST_FAULT_MASK BIT(6)
133 #define BQ24190_REG_F_BOOST_FAULT_SHIFT 6
134 #define BQ24190_REG_F_CHRG_FAULT_MASK (BIT(5) | BIT(4))
135 #define BQ24190_REG_F_CHRG_FAULT_SHIFT 4
136 #define BQ24190_REG_F_BAT_FAULT_MASK BIT(3)
137 #define BQ24190_REG_F_BAT_FAULT_SHIFT 3
138 #define BQ24190_REG_F_NTC_FAULT_MASK (BIT(2) | BIT(1) | BIT(0))
139 #define BQ24190_REG_F_NTC_FAULT_SHIFT 0
141 #define BQ24190_REG_VPRS 0x0A /* Vendor/Part/Revision Status */
142 #define BQ24190_REG_VPRS_PN_MASK (BIT(5) | BIT(4) | BIT(3))
143 #define BQ24190_REG_VPRS_PN_SHIFT 3
144 #define BQ24190_REG_VPRS_PN_24190 0x4
145 #define BQ24190_REG_VPRS_PN_24192 0x5 /* Also 24193 */
146 #define BQ24190_REG_VPRS_PN_24192I 0x3
147 #define BQ24190_REG_VPRS_TS_PROFILE_MASK BIT(2)
148 #define BQ24190_REG_VPRS_TS_PROFILE_SHIFT 2
149 #define BQ24190_REG_VPRS_DEV_REG_MASK (BIT(1) | BIT(0))
150 #define BQ24190_REG_VPRS_DEV_REG_SHIFT 0
153 * The FAULT register is latched by the bq24190 (except for NTC_FAULT)
154 * so the first read after a fault returns the latched value and subsequent
155 * reads return the current value. In order to return the fault status
156 * to the user, have the interrupt handler save the reg's value and retrieve
157 * it in the appropriate health/status routine.
159 struct bq24190_dev_info
{
160 struct i2c_client
*client
;
162 struct power_supply
*charger
;
163 struct power_supply
*battery
;
164 struct delayed_work input_current_limit_work
;
165 char model_name
[I2C_NAME_SIZE
];
171 struct mutex f_reg_lock
;
178 * The tables below provide a 2-way mapping for the value that goes in
179 * the register field and the real-world value that it represents.
180 * The index of the array is the value that goes in the register; the
181 * number at that index in the array is the real-world value that it
185 /* REG00[2:0] (IINLIM) in uAh */
186 static const int bq24190_isc_iinlim_values
[] = {
187 100000, 150000, 500000, 900000, 1200000, 1500000, 2000000, 3000000
190 /* REG02[7:2] (ICHG) in uAh */
191 static const int bq24190_ccc_ichg_values
[] = {
192 512000, 576000, 640000, 704000, 768000, 832000, 896000, 960000,
193 1024000, 1088000, 1152000, 1216000, 1280000, 1344000, 1408000, 1472000,
194 1536000, 1600000, 1664000, 1728000, 1792000, 1856000, 1920000, 1984000,
195 2048000, 2112000, 2176000, 2240000, 2304000, 2368000, 2432000, 2496000,
196 2560000, 2624000, 2688000, 2752000, 2816000, 2880000, 2944000, 3008000,
197 3072000, 3136000, 3200000, 3264000, 3328000, 3392000, 3456000, 3520000,
198 3584000, 3648000, 3712000, 3776000, 3840000, 3904000, 3968000, 4032000,
199 4096000, 4160000, 4224000, 4288000, 4352000, 4416000, 4480000, 4544000
202 /* REG04[7:2] (VREG) in uV */
203 static const int bq24190_cvc_vreg_values
[] = {
204 3504000, 3520000, 3536000, 3552000, 3568000, 3584000, 3600000, 3616000,
205 3632000, 3648000, 3664000, 3680000, 3696000, 3712000, 3728000, 3744000,
206 3760000, 3776000, 3792000, 3808000, 3824000, 3840000, 3856000, 3872000,
207 3888000, 3904000, 3920000, 3936000, 3952000, 3968000, 3984000, 4000000,
208 4016000, 4032000, 4048000, 4064000, 4080000, 4096000, 4112000, 4128000,
209 4144000, 4160000, 4176000, 4192000, 4208000, 4224000, 4240000, 4256000,
210 4272000, 4288000, 4304000, 4320000, 4336000, 4352000, 4368000, 4384000,
214 /* REG06[1:0] (TREG) in tenths of degrees Celsius */
215 static const int bq24190_ictrc_treg_values
[] = {
220 * Return the index in 'tbl' of greatest value that is less than or equal to
221 * 'val'. The index range returned is 0 to 'tbl_size' - 1. Assumes that
222 * the values in 'tbl' are sorted from smallest to largest and 'tbl_size'
225 static u8
bq24190_find_idx(const int tbl
[], int tbl_size
, int v
)
229 for (i
= 1; i
< tbl_size
; i
++)
236 /* Basic driver I/O routines */
238 static int bq24190_read(struct bq24190_dev_info
*bdi
, u8 reg
, u8
*data
)
242 ret
= i2c_smbus_read_byte_data(bdi
->client
, reg
);
250 static int bq24190_write(struct bq24190_dev_info
*bdi
, u8 reg
, u8 data
)
252 return i2c_smbus_write_byte_data(bdi
->client
, reg
, data
);
255 static int bq24190_read_mask(struct bq24190_dev_info
*bdi
, u8 reg
,
256 u8 mask
, u8 shift
, u8
*data
)
261 ret
= bq24190_read(bdi
, reg
, &v
);
272 static int bq24190_write_mask(struct bq24190_dev_info
*bdi
, u8 reg
,
273 u8 mask
, u8 shift
, u8 data
)
278 ret
= bq24190_read(bdi
, reg
, &v
);
283 v
|= ((data
<< shift
) & mask
);
285 return bq24190_write(bdi
, reg
, v
);
288 static int bq24190_get_field_val(struct bq24190_dev_info
*bdi
,
289 u8 reg
, u8 mask
, u8 shift
,
290 const int tbl
[], int tbl_size
,
296 ret
= bq24190_read_mask(bdi
, reg
, mask
, shift
, &v
);
300 v
= (v
>= tbl_size
) ? (tbl_size
- 1) : v
;
306 static int bq24190_set_field_val(struct bq24190_dev_info
*bdi
,
307 u8 reg
, u8 mask
, u8 shift
,
308 const int tbl
[], int tbl_size
,
313 idx
= bq24190_find_idx(tbl
, tbl_size
, val
);
315 return bq24190_write_mask(bdi
, reg
, mask
, shift
, idx
);
320 * There are a numerous options that are configurable on the bq24190
321 * that go well beyond what the power_supply properties provide access to.
322 * Provide sysfs access to them so they can be examined and possibly modified
323 * on the fly. They will be provided for the charger power_supply object only
324 * and will be prefixed by 'f_' to make them easier to recognize.
327 #define BQ24190_SYSFS_FIELD(_name, r, f, m, store) \
329 .attr = __ATTR(f_##_name, m, bq24190_sysfs_show, store), \
330 .reg = BQ24190_REG_##r, \
331 .mask = BQ24190_REG_##r##_##f##_MASK, \
332 .shift = BQ24190_REG_##r##_##f##_SHIFT, \
335 #define BQ24190_SYSFS_FIELD_RW(_name, r, f) \
336 BQ24190_SYSFS_FIELD(_name, r, f, S_IWUSR | S_IRUGO, \
339 #define BQ24190_SYSFS_FIELD_RO(_name, r, f) \
340 BQ24190_SYSFS_FIELD(_name, r, f, S_IRUGO, NULL)
342 static ssize_t
bq24190_sysfs_show(struct device
*dev
,
343 struct device_attribute
*attr
, char *buf
);
344 static ssize_t
bq24190_sysfs_store(struct device
*dev
,
345 struct device_attribute
*attr
, const char *buf
, size_t count
);
347 struct bq24190_sysfs_field_info
{
348 struct device_attribute attr
;
354 /* On i386 ptrace-abi.h defines SS that breaks the macro calls below. */
357 static struct bq24190_sysfs_field_info bq24190_sysfs_field_tbl
[] = {
358 /* sysfs name reg field in reg */
359 BQ24190_SYSFS_FIELD_RW(en_hiz
, ISC
, EN_HIZ
),
360 BQ24190_SYSFS_FIELD_RW(vindpm
, ISC
, VINDPM
),
361 BQ24190_SYSFS_FIELD_RW(iinlim
, ISC
, IINLIM
),
362 BQ24190_SYSFS_FIELD_RW(chg_config
, POC
, CHG_CONFIG
),
363 BQ24190_SYSFS_FIELD_RW(sys_min
, POC
, SYS_MIN
),
364 BQ24190_SYSFS_FIELD_RW(boost_lim
, POC
, BOOST_LIM
),
365 BQ24190_SYSFS_FIELD_RW(ichg
, CCC
, ICHG
),
366 BQ24190_SYSFS_FIELD_RW(force_20_pct
, CCC
, FORCE_20PCT
),
367 BQ24190_SYSFS_FIELD_RW(iprechg
, PCTCC
, IPRECHG
),
368 BQ24190_SYSFS_FIELD_RW(iterm
, PCTCC
, ITERM
),
369 BQ24190_SYSFS_FIELD_RW(vreg
, CVC
, VREG
),
370 BQ24190_SYSFS_FIELD_RW(batlowv
, CVC
, BATLOWV
),
371 BQ24190_SYSFS_FIELD_RW(vrechg
, CVC
, VRECHG
),
372 BQ24190_SYSFS_FIELD_RW(en_term
, CTTC
, EN_TERM
),
373 BQ24190_SYSFS_FIELD_RW(term_stat
, CTTC
, TERM_STAT
),
374 BQ24190_SYSFS_FIELD_RO(watchdog
, CTTC
, WATCHDOG
),
375 BQ24190_SYSFS_FIELD_RW(en_timer
, CTTC
, EN_TIMER
),
376 BQ24190_SYSFS_FIELD_RW(chg_timer
, CTTC
, CHG_TIMER
),
377 BQ24190_SYSFS_FIELD_RW(jeta_iset
, CTTC
, JEITA_ISET
),
378 BQ24190_SYSFS_FIELD_RW(bat_comp
, ICTRC
, BAT_COMP
),
379 BQ24190_SYSFS_FIELD_RW(vclamp
, ICTRC
, VCLAMP
),
380 BQ24190_SYSFS_FIELD_RW(treg
, ICTRC
, TREG
),
381 BQ24190_SYSFS_FIELD_RW(dpdm_en
, MOC
, DPDM_EN
),
382 BQ24190_SYSFS_FIELD_RW(tmr2x_en
, MOC
, TMR2X_EN
),
383 BQ24190_SYSFS_FIELD_RW(batfet_disable
, MOC
, BATFET_DISABLE
),
384 BQ24190_SYSFS_FIELD_RW(jeita_vset
, MOC
, JEITA_VSET
),
385 BQ24190_SYSFS_FIELD_RO(int_mask
, MOC
, INT_MASK
),
386 BQ24190_SYSFS_FIELD_RO(vbus_stat
, SS
, VBUS_STAT
),
387 BQ24190_SYSFS_FIELD_RO(chrg_stat
, SS
, CHRG_STAT
),
388 BQ24190_SYSFS_FIELD_RO(dpm_stat
, SS
, DPM_STAT
),
389 BQ24190_SYSFS_FIELD_RO(pg_stat
, SS
, PG_STAT
),
390 BQ24190_SYSFS_FIELD_RO(therm_stat
, SS
, THERM_STAT
),
391 BQ24190_SYSFS_FIELD_RO(vsys_stat
, SS
, VSYS_STAT
),
392 BQ24190_SYSFS_FIELD_RO(watchdog_fault
, F
, WATCHDOG_FAULT
),
393 BQ24190_SYSFS_FIELD_RO(boost_fault
, F
, BOOST_FAULT
),
394 BQ24190_SYSFS_FIELD_RO(chrg_fault
, F
, CHRG_FAULT
),
395 BQ24190_SYSFS_FIELD_RO(bat_fault
, F
, BAT_FAULT
),
396 BQ24190_SYSFS_FIELD_RO(ntc_fault
, F
, NTC_FAULT
),
397 BQ24190_SYSFS_FIELD_RO(pn
, VPRS
, PN
),
398 BQ24190_SYSFS_FIELD_RO(ts_profile
, VPRS
, TS_PROFILE
),
399 BQ24190_SYSFS_FIELD_RO(dev_reg
, VPRS
, DEV_REG
),
402 static struct attribute
*
403 bq24190_sysfs_attrs
[ARRAY_SIZE(bq24190_sysfs_field_tbl
) + 1];
405 static const struct attribute_group bq24190_sysfs_attr_group
= {
406 .attrs
= bq24190_sysfs_attrs
,
409 static void bq24190_sysfs_init_attrs(void)
411 int i
, limit
= ARRAY_SIZE(bq24190_sysfs_field_tbl
);
413 for (i
= 0; i
< limit
; i
++)
414 bq24190_sysfs_attrs
[i
] = &bq24190_sysfs_field_tbl
[i
].attr
.attr
;
416 bq24190_sysfs_attrs
[limit
] = NULL
; /* Has additional entry for this */
419 static struct bq24190_sysfs_field_info
*bq24190_sysfs_field_lookup(
422 int i
, limit
= ARRAY_SIZE(bq24190_sysfs_field_tbl
);
424 for (i
= 0; i
< limit
; i
++)
425 if (!strcmp(name
, bq24190_sysfs_field_tbl
[i
].attr
.attr
.name
))
431 return &bq24190_sysfs_field_tbl
[i
];
434 static ssize_t
bq24190_sysfs_show(struct device
*dev
,
435 struct device_attribute
*attr
, char *buf
)
437 struct power_supply
*psy
= dev_get_drvdata(dev
);
438 struct bq24190_dev_info
*bdi
= power_supply_get_drvdata(psy
);
439 struct bq24190_sysfs_field_info
*info
;
444 info
= bq24190_sysfs_field_lookup(attr
->attr
.name
);
448 ret
= pm_runtime_get_sync(bdi
->dev
);
452 ret
= bq24190_read_mask(bdi
, info
->reg
, info
->mask
, info
->shift
, &v
);
456 count
= scnprintf(buf
, PAGE_SIZE
, "%hhx\n", v
);
458 pm_runtime_mark_last_busy(bdi
->dev
);
459 pm_runtime_put_autosuspend(bdi
->dev
);
464 static ssize_t
bq24190_sysfs_store(struct device
*dev
,
465 struct device_attribute
*attr
, const char *buf
, size_t count
)
467 struct power_supply
*psy
= dev_get_drvdata(dev
);
468 struct bq24190_dev_info
*bdi
= power_supply_get_drvdata(psy
);
469 struct bq24190_sysfs_field_info
*info
;
473 info
= bq24190_sysfs_field_lookup(attr
->attr
.name
);
477 ret
= kstrtou8(buf
, 0, &v
);
481 ret
= pm_runtime_get_sync(bdi
->dev
);
485 ret
= bq24190_write_mask(bdi
, info
->reg
, info
->mask
, info
->shift
, v
);
489 pm_runtime_mark_last_busy(bdi
->dev
);
490 pm_runtime_put_autosuspend(bdi
->dev
);
495 static int bq24190_sysfs_create_group(struct bq24190_dev_info
*bdi
)
497 bq24190_sysfs_init_attrs();
499 return sysfs_create_group(&bdi
->charger
->dev
.kobj
,
500 &bq24190_sysfs_attr_group
);
503 static void bq24190_sysfs_remove_group(struct bq24190_dev_info
*bdi
)
505 sysfs_remove_group(&bdi
->charger
->dev
.kobj
, &bq24190_sysfs_attr_group
);
508 static int bq24190_sysfs_create_group(struct bq24190_dev_info
*bdi
)
513 static inline void bq24190_sysfs_remove_group(struct bq24190_dev_info
*bdi
) {}
516 #ifdef CONFIG_REGULATOR
517 static int bq24190_set_charge_mode(struct regulator_dev
*dev
, u8 val
)
519 struct bq24190_dev_info
*bdi
= rdev_get_drvdata(dev
);
522 ret
= pm_runtime_get_sync(bdi
->dev
);
524 dev_warn(bdi
->dev
, "pm_runtime_get failed: %i\n", ret
);
525 pm_runtime_put_noidle(bdi
->dev
);
529 ret
= bq24190_write_mask(bdi
, BQ24190_REG_POC
,
530 BQ24190_REG_POC_CHG_CONFIG_MASK
,
531 BQ24190_REG_POC_CHG_CONFIG_SHIFT
, val
);
533 pm_runtime_mark_last_busy(bdi
->dev
);
534 pm_runtime_put_autosuspend(bdi
->dev
);
539 static int bq24190_vbus_enable(struct regulator_dev
*dev
)
541 return bq24190_set_charge_mode(dev
, BQ24190_REG_POC_CHG_CONFIG_OTG
);
544 static int bq24190_vbus_disable(struct regulator_dev
*dev
)
546 return bq24190_set_charge_mode(dev
, BQ24190_REG_POC_CHG_CONFIG_CHARGE
);
549 static int bq24190_vbus_is_enabled(struct regulator_dev
*dev
)
551 struct bq24190_dev_info
*bdi
= rdev_get_drvdata(dev
);
555 ret
= pm_runtime_get_sync(bdi
->dev
);
557 dev_warn(bdi
->dev
, "pm_runtime_get failed: %i\n", ret
);
558 pm_runtime_put_noidle(bdi
->dev
);
562 ret
= bq24190_read_mask(bdi
, BQ24190_REG_POC
,
563 BQ24190_REG_POC_CHG_CONFIG_MASK
,
564 BQ24190_REG_POC_CHG_CONFIG_SHIFT
, &val
);
566 pm_runtime_mark_last_busy(bdi
->dev
);
567 pm_runtime_put_autosuspend(bdi
->dev
);
569 return ret
? ret
: val
== BQ24190_REG_POC_CHG_CONFIG_OTG
;
572 static const struct regulator_ops bq24190_vbus_ops
= {
573 .enable
= bq24190_vbus_enable
,
574 .disable
= bq24190_vbus_disable
,
575 .is_enabled
= bq24190_vbus_is_enabled
,
578 static const struct regulator_desc bq24190_vbus_desc
= {
579 .name
= "usb_otg_vbus",
580 .type
= REGULATOR_VOLTAGE
,
581 .owner
= THIS_MODULE
,
582 .ops
= &bq24190_vbus_ops
,
587 static const struct regulator_init_data bq24190_vbus_init_data
= {
589 .valid_ops_mask
= REGULATOR_CHANGE_STATUS
,
593 static int bq24190_register_vbus_regulator(struct bq24190_dev_info
*bdi
)
595 struct bq24190_platform_data
*pdata
= bdi
->dev
->platform_data
;
596 struct regulator_config cfg
= { };
597 struct regulator_dev
*reg
;
601 if (pdata
&& pdata
->regulator_init_data
)
602 cfg
.init_data
= pdata
->regulator_init_data
;
604 cfg
.init_data
= &bq24190_vbus_init_data
;
605 cfg
.driver_data
= bdi
;
606 reg
= devm_regulator_register(bdi
->dev
, &bq24190_vbus_desc
, &cfg
);
609 dev_err(bdi
->dev
, "Can't register regulator: %d\n", ret
);
615 static int bq24190_register_vbus_regulator(struct bq24190_dev_info
*bdi
)
621 static int bq24190_set_config(struct bq24190_dev_info
*bdi
)
626 ret
= bq24190_read(bdi
, BQ24190_REG_CTTC
, &v
);
630 bdi
->watchdog
= ((v
& BQ24190_REG_CTTC_WATCHDOG_MASK
) >>
631 BQ24190_REG_CTTC_WATCHDOG_SHIFT
);
634 * According to the "Host Mode and default Mode" section of the
635 * manual, a write to any register causes the bq24190 to switch
636 * from default mode to host mode. It will switch back to default
637 * mode after a WDT timeout unless the WDT is turned off as well.
638 * So, by simply turning off the WDT, we accomplish both with the
641 v
&= ~BQ24190_REG_CTTC_WATCHDOG_MASK
;
643 ret
= bq24190_write(bdi
, BQ24190_REG_CTTC
, v
);
648 v
= bdi
->sys_min
/ 100 - 30; // manual section 9.5.1.2, table 9
649 ret
= bq24190_write_mask(bdi
, BQ24190_REG_POC
,
650 BQ24190_REG_POC_SYS_MIN_MASK
,
651 BQ24190_REG_POC_SYS_MIN_SHIFT
,
658 v
= bdi
->iprechg
/ 128 - 1; // manual section 9.5.1.4, table 11
659 ret
= bq24190_write_mask(bdi
, BQ24190_REG_PCTCC
,
660 BQ24190_REG_PCTCC_IPRECHG_MASK
,
661 BQ24190_REG_PCTCC_IPRECHG_SHIFT
,
668 v
= bdi
->iterm
/ 128 - 1; // manual section 9.5.1.4, table 11
669 ret
= bq24190_write_mask(bdi
, BQ24190_REG_PCTCC
,
670 BQ24190_REG_PCTCC_ITERM_MASK
,
671 BQ24190_REG_PCTCC_ITERM_SHIFT
,
680 static int bq24190_register_reset(struct bq24190_dev_info
*bdi
)
682 int ret
, limit
= 100;
686 * This prop. can be passed on device instantiation from platform code:
687 * struct property_entry pe[] =
688 * { PROPERTY_ENTRY_BOOL("disable-reset"), ... };
689 * struct i2c_board_info bi =
690 * { .type = "bq24190", .addr = 0x6b, .properties = pe, .irq = irq };
691 * struct i2c_adapter ad = { ... };
692 * i2c_add_adapter(&ad);
693 * i2c_new_device(&ad, &bi);
695 if (device_property_read_bool(bdi
->dev
, "disable-reset"))
698 /* Reset the registers */
699 ret
= bq24190_write_mask(bdi
, BQ24190_REG_POC
,
700 BQ24190_REG_POC_RESET_MASK
,
701 BQ24190_REG_POC_RESET_SHIFT
,
706 /* Reset bit will be cleared by hardware so poll until it is */
708 ret
= bq24190_read_mask(bdi
, BQ24190_REG_POC
,
709 BQ24190_REG_POC_RESET_MASK
,
710 BQ24190_REG_POC_RESET_SHIFT
,
718 usleep_range(100, 200);
724 /* Charger power supply property routines */
726 static int bq24190_charger_get_charge_type(struct bq24190_dev_info
*bdi
,
727 union power_supply_propval
*val
)
732 ret
= bq24190_read_mask(bdi
, BQ24190_REG_POC
,
733 BQ24190_REG_POC_CHG_CONFIG_MASK
,
734 BQ24190_REG_POC_CHG_CONFIG_SHIFT
,
739 /* If POC[CHG_CONFIG] (REG01[5:4]) == 0, charge is disabled */
741 type
= POWER_SUPPLY_CHARGE_TYPE_NONE
;
743 ret
= bq24190_read_mask(bdi
, BQ24190_REG_CCC
,
744 BQ24190_REG_CCC_FORCE_20PCT_MASK
,
745 BQ24190_REG_CCC_FORCE_20PCT_SHIFT
,
750 type
= (v
) ? POWER_SUPPLY_CHARGE_TYPE_TRICKLE
:
751 POWER_SUPPLY_CHARGE_TYPE_FAST
;
759 static int bq24190_charger_set_charge_type(struct bq24190_dev_info
*bdi
,
760 const union power_supply_propval
*val
)
762 u8 chg_config
, force_20pct
, en_term
;
766 * According to the "Termination when REG02[0] = 1" section of
767 * the bq24190 manual, the trickle charge could be less than the
768 * termination current so it recommends turning off the termination
771 * Note: AFAICT from the datasheet, the user will have to manually
772 * turn off the charging when in 20% mode. If its not turned off,
773 * there could be battery damage. So, use this mode at your own risk.
775 switch (val
->intval
) {
776 case POWER_SUPPLY_CHARGE_TYPE_NONE
:
779 case POWER_SUPPLY_CHARGE_TYPE_TRICKLE
:
784 case POWER_SUPPLY_CHARGE_TYPE_FAST
:
793 if (chg_config
) { /* Enabling the charger */
794 ret
= bq24190_write_mask(bdi
, BQ24190_REG_CCC
,
795 BQ24190_REG_CCC_FORCE_20PCT_MASK
,
796 BQ24190_REG_CCC_FORCE_20PCT_SHIFT
,
801 ret
= bq24190_write_mask(bdi
, BQ24190_REG_CTTC
,
802 BQ24190_REG_CTTC_EN_TERM_MASK
,
803 BQ24190_REG_CTTC_EN_TERM_SHIFT
,
809 return bq24190_write_mask(bdi
, BQ24190_REG_POC
,
810 BQ24190_REG_POC_CHG_CONFIG_MASK
,
811 BQ24190_REG_POC_CHG_CONFIG_SHIFT
, chg_config
);
814 static int bq24190_charger_get_health(struct bq24190_dev_info
*bdi
,
815 union power_supply_propval
*val
)
820 mutex_lock(&bdi
->f_reg_lock
);
822 mutex_unlock(&bdi
->f_reg_lock
);
824 if (v
& BQ24190_REG_F_NTC_FAULT_MASK
) {
825 switch (v
>> BQ24190_REG_F_NTC_FAULT_SHIFT
& 0x7) {
826 case 0x1: /* TS1 Cold */
827 case 0x3: /* TS2 Cold */
828 case 0x5: /* Both Cold */
829 health
= POWER_SUPPLY_HEALTH_COLD
;
831 case 0x2: /* TS1 Hot */
832 case 0x4: /* TS2 Hot */
833 case 0x6: /* Both Hot */
834 health
= POWER_SUPPLY_HEALTH_OVERHEAT
;
837 health
= POWER_SUPPLY_HEALTH_UNKNOWN
;
839 } else if (v
& BQ24190_REG_F_BAT_FAULT_MASK
) {
840 health
= POWER_SUPPLY_HEALTH_OVERVOLTAGE
;
841 } else if (v
& BQ24190_REG_F_CHRG_FAULT_MASK
) {
842 switch (v
>> BQ24190_REG_F_CHRG_FAULT_SHIFT
& 0x3) {
843 case 0x1: /* Input Fault (VBUS OVP or VBAT<VBUS<3.8V) */
845 * This could be over-voltage or under-voltage
846 * and there's no way to tell which. Instead
847 * of looking foolish and returning 'OVERVOLTAGE'
848 * when its really under-voltage, just return
851 health
= POWER_SUPPLY_HEALTH_UNSPEC_FAILURE
;
853 case 0x2: /* Thermal Shutdown */
854 health
= POWER_SUPPLY_HEALTH_OVERHEAT
;
856 case 0x3: /* Charge Safety Timer Expiration */
857 health
= POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE
;
859 default: /* prevent compiler warning */
862 } else if (v
& BQ24190_REG_F_BOOST_FAULT_MASK
) {
864 * This could be over-current or over-voltage but there's
865 * no way to tell which. Return 'OVERVOLTAGE' since there
866 * isn't an 'OVERCURRENT' value defined that we can return
867 * even if it was over-current.
869 health
= POWER_SUPPLY_HEALTH_OVERVOLTAGE
;
871 health
= POWER_SUPPLY_HEALTH_GOOD
;
874 val
->intval
= health
;
879 static int bq24190_charger_get_online(struct bq24190_dev_info
*bdi
,
880 union power_supply_propval
*val
)
882 u8 pg_stat
, batfet_disable
;
885 ret
= bq24190_read_mask(bdi
, BQ24190_REG_SS
,
886 BQ24190_REG_SS_PG_STAT_MASK
,
887 BQ24190_REG_SS_PG_STAT_SHIFT
, &pg_stat
);
891 ret
= bq24190_read_mask(bdi
, BQ24190_REG_MOC
,
892 BQ24190_REG_MOC_BATFET_DISABLE_MASK
,
893 BQ24190_REG_MOC_BATFET_DISABLE_SHIFT
, &batfet_disable
);
897 val
->intval
= pg_stat
&& !batfet_disable
;
902 static int bq24190_battery_set_online(struct bq24190_dev_info
*bdi
,
903 const union power_supply_propval
*val
);
904 static int bq24190_battery_get_status(struct bq24190_dev_info
*bdi
,
905 union power_supply_propval
*val
);
906 static int bq24190_battery_get_temp_alert_max(struct bq24190_dev_info
*bdi
,
907 union power_supply_propval
*val
);
908 static int bq24190_battery_set_temp_alert_max(struct bq24190_dev_info
*bdi
,
909 const union power_supply_propval
*val
);
911 static int bq24190_charger_set_online(struct bq24190_dev_info
*bdi
,
912 const union power_supply_propval
*val
)
914 return bq24190_battery_set_online(bdi
, val
);
917 static int bq24190_charger_get_status(struct bq24190_dev_info
*bdi
,
918 union power_supply_propval
*val
)
920 return bq24190_battery_get_status(bdi
, val
);
923 static int bq24190_charger_get_temp_alert_max(struct bq24190_dev_info
*bdi
,
924 union power_supply_propval
*val
)
926 return bq24190_battery_get_temp_alert_max(bdi
, val
);
929 static int bq24190_charger_set_temp_alert_max(struct bq24190_dev_info
*bdi
,
930 const union power_supply_propval
*val
)
932 return bq24190_battery_set_temp_alert_max(bdi
, val
);
935 static int bq24190_charger_get_precharge(struct bq24190_dev_info
*bdi
,
936 union power_supply_propval
*val
)
941 ret
= bq24190_read_mask(bdi
, BQ24190_REG_PCTCC
,
942 BQ24190_REG_PCTCC_IPRECHG_MASK
,
943 BQ24190_REG_PCTCC_IPRECHG_SHIFT
, &v
);
947 val
->intval
= ++v
* 128 * 1000;
951 static int bq24190_charger_get_charge_term(struct bq24190_dev_info
*bdi
,
952 union power_supply_propval
*val
)
957 ret
= bq24190_read_mask(bdi
, BQ24190_REG_PCTCC
,
958 BQ24190_REG_PCTCC_ITERM_MASK
,
959 BQ24190_REG_PCTCC_ITERM_SHIFT
, &v
);
963 val
->intval
= ++v
* 128 * 1000;
967 static int bq24190_charger_get_current(struct bq24190_dev_info
*bdi
,
968 union power_supply_propval
*val
)
973 ret
= bq24190_get_field_val(bdi
, BQ24190_REG_CCC
,
974 BQ24190_REG_CCC_ICHG_MASK
, BQ24190_REG_CCC_ICHG_SHIFT
,
975 bq24190_ccc_ichg_values
,
976 ARRAY_SIZE(bq24190_ccc_ichg_values
), &curr
);
980 ret
= bq24190_read_mask(bdi
, BQ24190_REG_CCC
,
981 BQ24190_REG_CCC_FORCE_20PCT_MASK
,
982 BQ24190_REG_CCC_FORCE_20PCT_SHIFT
, &v
);
986 /* If FORCE_20PCT is enabled, then current is 20% of ICHG value */
994 static int bq24190_charger_get_current_max(struct bq24190_dev_info
*bdi
,
995 union power_supply_propval
*val
)
997 int idx
= ARRAY_SIZE(bq24190_ccc_ichg_values
) - 1;
999 val
->intval
= bq24190_ccc_ichg_values
[idx
];
1003 static int bq24190_charger_set_current(struct bq24190_dev_info
*bdi
,
1004 const union power_supply_propval
*val
)
1007 int ret
, curr
= val
->intval
;
1009 ret
= bq24190_read_mask(bdi
, BQ24190_REG_CCC
,
1010 BQ24190_REG_CCC_FORCE_20PCT_MASK
,
1011 BQ24190_REG_CCC_FORCE_20PCT_SHIFT
, &v
);
1015 /* If FORCE_20PCT is enabled, have to multiply value passed in by 5 */
1019 return bq24190_set_field_val(bdi
, BQ24190_REG_CCC
,
1020 BQ24190_REG_CCC_ICHG_MASK
, BQ24190_REG_CCC_ICHG_SHIFT
,
1021 bq24190_ccc_ichg_values
,
1022 ARRAY_SIZE(bq24190_ccc_ichg_values
), curr
);
1025 static int bq24190_charger_get_voltage(struct bq24190_dev_info
*bdi
,
1026 union power_supply_propval
*val
)
1030 ret
= bq24190_get_field_val(bdi
, BQ24190_REG_CVC
,
1031 BQ24190_REG_CVC_VREG_MASK
, BQ24190_REG_CVC_VREG_SHIFT
,
1032 bq24190_cvc_vreg_values
,
1033 ARRAY_SIZE(bq24190_cvc_vreg_values
), &voltage
);
1037 val
->intval
= voltage
;
1041 static int bq24190_charger_get_voltage_max(struct bq24190_dev_info
*bdi
,
1042 union power_supply_propval
*val
)
1044 int idx
= ARRAY_SIZE(bq24190_cvc_vreg_values
) - 1;
1046 val
->intval
= bq24190_cvc_vreg_values
[idx
];
1050 static int bq24190_charger_set_voltage(struct bq24190_dev_info
*bdi
,
1051 const union power_supply_propval
*val
)
1053 return bq24190_set_field_val(bdi
, BQ24190_REG_CVC
,
1054 BQ24190_REG_CVC_VREG_MASK
, BQ24190_REG_CVC_VREG_SHIFT
,
1055 bq24190_cvc_vreg_values
,
1056 ARRAY_SIZE(bq24190_cvc_vreg_values
), val
->intval
);
1059 static int bq24190_charger_get_iinlimit(struct bq24190_dev_info
*bdi
,
1060 union power_supply_propval
*val
)
1064 ret
= bq24190_get_field_val(bdi
, BQ24190_REG_ISC
,
1065 BQ24190_REG_ISC_IINLIM_MASK
,
1066 BQ24190_REG_ISC_IINLIM_SHIFT
,
1067 bq24190_isc_iinlim_values
,
1068 ARRAY_SIZE(bq24190_isc_iinlim_values
), &iinlimit
);
1072 val
->intval
= iinlimit
;
1076 static int bq24190_charger_set_iinlimit(struct bq24190_dev_info
*bdi
,
1077 const union power_supply_propval
*val
)
1079 return bq24190_set_field_val(bdi
, BQ24190_REG_ISC
,
1080 BQ24190_REG_ISC_IINLIM_MASK
,
1081 BQ24190_REG_ISC_IINLIM_SHIFT
,
1082 bq24190_isc_iinlim_values
,
1083 ARRAY_SIZE(bq24190_isc_iinlim_values
), val
->intval
);
1086 static int bq24190_charger_get_property(struct power_supply
*psy
,
1087 enum power_supply_property psp
, union power_supply_propval
*val
)
1089 struct bq24190_dev_info
*bdi
= power_supply_get_drvdata(psy
);
1092 dev_dbg(bdi
->dev
, "prop: %d\n", psp
);
1094 ret
= pm_runtime_get_sync(bdi
->dev
);
1099 case POWER_SUPPLY_PROP_CHARGE_TYPE
:
1100 ret
= bq24190_charger_get_charge_type(bdi
, val
);
1102 case POWER_SUPPLY_PROP_HEALTH
:
1103 ret
= bq24190_charger_get_health(bdi
, val
);
1105 case POWER_SUPPLY_PROP_ONLINE
:
1106 ret
= bq24190_charger_get_online(bdi
, val
);
1108 case POWER_SUPPLY_PROP_STATUS
:
1109 ret
= bq24190_charger_get_status(bdi
, val
);
1111 case POWER_SUPPLY_PROP_TEMP_ALERT_MAX
:
1112 ret
= bq24190_charger_get_temp_alert_max(bdi
, val
);
1114 case POWER_SUPPLY_PROP_PRECHARGE_CURRENT
:
1115 ret
= bq24190_charger_get_precharge(bdi
, val
);
1117 case POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT
:
1118 ret
= bq24190_charger_get_charge_term(bdi
, val
);
1120 case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT
:
1121 ret
= bq24190_charger_get_current(bdi
, val
);
1123 case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX
:
1124 ret
= bq24190_charger_get_current_max(bdi
, val
);
1126 case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE
:
1127 ret
= bq24190_charger_get_voltage(bdi
, val
);
1129 case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX
:
1130 ret
= bq24190_charger_get_voltage_max(bdi
, val
);
1132 case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT
:
1133 ret
= bq24190_charger_get_iinlimit(bdi
, val
);
1135 case POWER_SUPPLY_PROP_SCOPE
:
1136 val
->intval
= POWER_SUPPLY_SCOPE_SYSTEM
;
1139 case POWER_SUPPLY_PROP_MODEL_NAME
:
1140 val
->strval
= bdi
->model_name
;
1143 case POWER_SUPPLY_PROP_MANUFACTURER
:
1144 val
->strval
= BQ24190_MANUFACTURER
;
1151 pm_runtime_mark_last_busy(bdi
->dev
);
1152 pm_runtime_put_autosuspend(bdi
->dev
);
1157 static int bq24190_charger_set_property(struct power_supply
*psy
,
1158 enum power_supply_property psp
,
1159 const union power_supply_propval
*val
)
1161 struct bq24190_dev_info
*bdi
= power_supply_get_drvdata(psy
);
1164 dev_dbg(bdi
->dev
, "prop: %d\n", psp
);
1166 ret
= pm_runtime_get_sync(bdi
->dev
);
1171 case POWER_SUPPLY_PROP_ONLINE
:
1172 ret
= bq24190_charger_set_online(bdi
, val
);
1174 case POWER_SUPPLY_PROP_TEMP_ALERT_MAX
:
1175 ret
= bq24190_charger_set_temp_alert_max(bdi
, val
);
1177 case POWER_SUPPLY_PROP_CHARGE_TYPE
:
1178 ret
= bq24190_charger_set_charge_type(bdi
, val
);
1180 case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT
:
1181 ret
= bq24190_charger_set_current(bdi
, val
);
1183 case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE
:
1184 ret
= bq24190_charger_set_voltage(bdi
, val
);
1186 case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT
:
1187 ret
= bq24190_charger_set_iinlimit(bdi
, val
);
1193 pm_runtime_mark_last_busy(bdi
->dev
);
1194 pm_runtime_put_autosuspend(bdi
->dev
);
1199 static int bq24190_charger_property_is_writeable(struct power_supply
*psy
,
1200 enum power_supply_property psp
)
1203 case POWER_SUPPLY_PROP_ONLINE
:
1204 case POWER_SUPPLY_PROP_TEMP_ALERT_MAX
:
1205 case POWER_SUPPLY_PROP_CHARGE_TYPE
:
1206 case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT
:
1207 case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE
:
1208 case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT
:
1215 static void bq24190_input_current_limit_work(struct work_struct
*work
)
1217 struct bq24190_dev_info
*bdi
=
1218 container_of(work
, struct bq24190_dev_info
,
1219 input_current_limit_work
.work
);
1221 power_supply_set_input_current_limit_from_supplier(bdi
->charger
);
1224 /* Sync the input-current-limit with our parent supply (if we have one) */
1225 static void bq24190_charger_external_power_changed(struct power_supply
*psy
)
1227 struct bq24190_dev_info
*bdi
= power_supply_get_drvdata(psy
);
1230 * The Power-Good detection may take up to 220ms, sometimes
1231 * the external charger detection is quicker, and the bq24190 will
1232 * reset to iinlim based on its own charger detection (which is not
1233 * hooked up when using external charger detection) resulting in a
1234 * too low default 500mA iinlim. Delay setting the input-current-limit
1235 * for 300ms to avoid this.
1237 queue_delayed_work(system_wq
, &bdi
->input_current_limit_work
,
1238 msecs_to_jiffies(300));
1241 static enum power_supply_property bq24190_charger_properties
[] = {
1242 POWER_SUPPLY_PROP_CHARGE_TYPE
,
1243 POWER_SUPPLY_PROP_HEALTH
,
1244 POWER_SUPPLY_PROP_ONLINE
,
1245 POWER_SUPPLY_PROP_STATUS
,
1246 POWER_SUPPLY_PROP_TEMP_ALERT_MAX
,
1247 POWER_SUPPLY_PROP_PRECHARGE_CURRENT
,
1248 POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT
,
1249 POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT
,
1250 POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX
,
1251 POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE
,
1252 POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX
,
1253 POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT
,
1254 POWER_SUPPLY_PROP_SCOPE
,
1255 POWER_SUPPLY_PROP_MODEL_NAME
,
1256 POWER_SUPPLY_PROP_MANUFACTURER
,
1259 static char *bq24190_charger_supplied_to
[] = {
1263 static const struct power_supply_desc bq24190_charger_desc
= {
1264 .name
= "bq24190-charger",
1265 .type
= POWER_SUPPLY_TYPE_USB
,
1266 .properties
= bq24190_charger_properties
,
1267 .num_properties
= ARRAY_SIZE(bq24190_charger_properties
),
1268 .get_property
= bq24190_charger_get_property
,
1269 .set_property
= bq24190_charger_set_property
,
1270 .property_is_writeable
= bq24190_charger_property_is_writeable
,
1271 .external_power_changed
= bq24190_charger_external_power_changed
,
1274 /* Battery power supply property routines */
1276 static int bq24190_battery_get_status(struct bq24190_dev_info
*bdi
,
1277 union power_supply_propval
*val
)
1279 u8 ss_reg
, chrg_fault
;
1282 mutex_lock(&bdi
->f_reg_lock
);
1283 chrg_fault
= bdi
->f_reg
;
1284 mutex_unlock(&bdi
->f_reg_lock
);
1286 chrg_fault
&= BQ24190_REG_F_CHRG_FAULT_MASK
;
1287 chrg_fault
>>= BQ24190_REG_F_CHRG_FAULT_SHIFT
;
1289 ret
= bq24190_read(bdi
, BQ24190_REG_SS
, &ss_reg
);
1294 * The battery must be discharging when any of these are true:
1295 * - there is no good power source;
1296 * - there is a charge fault.
1297 * Could also be discharging when in "supplement mode" but
1298 * there is no way to tell when its in that mode.
1300 if (!(ss_reg
& BQ24190_REG_SS_PG_STAT_MASK
) || chrg_fault
) {
1301 status
= POWER_SUPPLY_STATUS_DISCHARGING
;
1303 ss_reg
&= BQ24190_REG_SS_CHRG_STAT_MASK
;
1304 ss_reg
>>= BQ24190_REG_SS_CHRG_STAT_SHIFT
;
1307 case 0x0: /* Not Charging */
1308 status
= POWER_SUPPLY_STATUS_NOT_CHARGING
;
1310 case 0x1: /* Pre-charge */
1311 case 0x2: /* Fast Charging */
1312 status
= POWER_SUPPLY_STATUS_CHARGING
;
1314 case 0x3: /* Charge Termination Done */
1315 status
= POWER_SUPPLY_STATUS_FULL
;
1323 val
->intval
= status
;
1328 static int bq24190_battery_get_health(struct bq24190_dev_info
*bdi
,
1329 union power_supply_propval
*val
)
1334 mutex_lock(&bdi
->f_reg_lock
);
1336 mutex_unlock(&bdi
->f_reg_lock
);
1338 if (v
& BQ24190_REG_F_BAT_FAULT_MASK
) {
1339 health
= POWER_SUPPLY_HEALTH_OVERVOLTAGE
;
1341 v
&= BQ24190_REG_F_NTC_FAULT_MASK
;
1342 v
>>= BQ24190_REG_F_NTC_FAULT_SHIFT
;
1345 case 0x0: /* Normal */
1346 health
= POWER_SUPPLY_HEALTH_GOOD
;
1348 case 0x1: /* TS1 Cold */
1349 case 0x3: /* TS2 Cold */
1350 case 0x5: /* Both Cold */
1351 health
= POWER_SUPPLY_HEALTH_COLD
;
1353 case 0x2: /* TS1 Hot */
1354 case 0x4: /* TS2 Hot */
1355 case 0x6: /* Both Hot */
1356 health
= POWER_SUPPLY_HEALTH_OVERHEAT
;
1359 health
= POWER_SUPPLY_HEALTH_UNKNOWN
;
1363 val
->intval
= health
;
1367 static int bq24190_battery_get_online(struct bq24190_dev_info
*bdi
,
1368 union power_supply_propval
*val
)
1373 ret
= bq24190_read_mask(bdi
, BQ24190_REG_MOC
,
1374 BQ24190_REG_MOC_BATFET_DISABLE_MASK
,
1375 BQ24190_REG_MOC_BATFET_DISABLE_SHIFT
, &batfet_disable
);
1379 val
->intval
= !batfet_disable
;
1383 static int bq24190_battery_set_online(struct bq24190_dev_info
*bdi
,
1384 const union power_supply_propval
*val
)
1386 return bq24190_write_mask(bdi
, BQ24190_REG_MOC
,
1387 BQ24190_REG_MOC_BATFET_DISABLE_MASK
,
1388 BQ24190_REG_MOC_BATFET_DISABLE_SHIFT
, !val
->intval
);
1391 static int bq24190_battery_get_temp_alert_max(struct bq24190_dev_info
*bdi
,
1392 union power_supply_propval
*val
)
1396 ret
= bq24190_get_field_val(bdi
, BQ24190_REG_ICTRC
,
1397 BQ24190_REG_ICTRC_TREG_MASK
,
1398 BQ24190_REG_ICTRC_TREG_SHIFT
,
1399 bq24190_ictrc_treg_values
,
1400 ARRAY_SIZE(bq24190_ictrc_treg_values
), &temp
);
1408 static int bq24190_battery_set_temp_alert_max(struct bq24190_dev_info
*bdi
,
1409 const union power_supply_propval
*val
)
1411 return bq24190_set_field_val(bdi
, BQ24190_REG_ICTRC
,
1412 BQ24190_REG_ICTRC_TREG_MASK
,
1413 BQ24190_REG_ICTRC_TREG_SHIFT
,
1414 bq24190_ictrc_treg_values
,
1415 ARRAY_SIZE(bq24190_ictrc_treg_values
), val
->intval
);
1418 static int bq24190_battery_get_property(struct power_supply
*psy
,
1419 enum power_supply_property psp
, union power_supply_propval
*val
)
1421 struct bq24190_dev_info
*bdi
= power_supply_get_drvdata(psy
);
1424 dev_warn(bdi
->dev
, "warning: /sys/class/power_supply/bq24190-battery is deprecated\n");
1425 dev_dbg(bdi
->dev
, "prop: %d\n", psp
);
1427 ret
= pm_runtime_get_sync(bdi
->dev
);
1432 case POWER_SUPPLY_PROP_STATUS
:
1433 ret
= bq24190_battery_get_status(bdi
, val
);
1435 case POWER_SUPPLY_PROP_HEALTH
:
1436 ret
= bq24190_battery_get_health(bdi
, val
);
1438 case POWER_SUPPLY_PROP_ONLINE
:
1439 ret
= bq24190_battery_get_online(bdi
, val
);
1441 case POWER_SUPPLY_PROP_TECHNOLOGY
:
1442 /* Could be Li-on or Li-polymer but no way to tell which */
1443 val
->intval
= POWER_SUPPLY_TECHNOLOGY_UNKNOWN
;
1446 case POWER_SUPPLY_PROP_TEMP_ALERT_MAX
:
1447 ret
= bq24190_battery_get_temp_alert_max(bdi
, val
);
1449 case POWER_SUPPLY_PROP_SCOPE
:
1450 val
->intval
= POWER_SUPPLY_SCOPE_SYSTEM
;
1457 pm_runtime_mark_last_busy(bdi
->dev
);
1458 pm_runtime_put_autosuspend(bdi
->dev
);
1463 static int bq24190_battery_set_property(struct power_supply
*psy
,
1464 enum power_supply_property psp
,
1465 const union power_supply_propval
*val
)
1467 struct bq24190_dev_info
*bdi
= power_supply_get_drvdata(psy
);
1470 dev_warn(bdi
->dev
, "warning: /sys/class/power_supply/bq24190-battery is deprecated\n");
1471 dev_dbg(bdi
->dev
, "prop: %d\n", psp
);
1473 ret
= pm_runtime_get_sync(bdi
->dev
);
1478 case POWER_SUPPLY_PROP_ONLINE
:
1479 ret
= bq24190_battery_set_online(bdi
, val
);
1481 case POWER_SUPPLY_PROP_TEMP_ALERT_MAX
:
1482 ret
= bq24190_battery_set_temp_alert_max(bdi
, val
);
1488 pm_runtime_mark_last_busy(bdi
->dev
);
1489 pm_runtime_put_autosuspend(bdi
->dev
);
1494 static int bq24190_battery_property_is_writeable(struct power_supply
*psy
,
1495 enum power_supply_property psp
)
1500 case POWER_SUPPLY_PROP_ONLINE
:
1501 case POWER_SUPPLY_PROP_TEMP_ALERT_MAX
:
1511 static enum power_supply_property bq24190_battery_properties
[] = {
1512 POWER_SUPPLY_PROP_STATUS
,
1513 POWER_SUPPLY_PROP_HEALTH
,
1514 POWER_SUPPLY_PROP_ONLINE
,
1515 POWER_SUPPLY_PROP_TECHNOLOGY
,
1516 POWER_SUPPLY_PROP_TEMP_ALERT_MAX
,
1517 POWER_SUPPLY_PROP_SCOPE
,
1520 static const struct power_supply_desc bq24190_battery_desc
= {
1521 .name
= "bq24190-battery",
1522 .type
= POWER_SUPPLY_TYPE_BATTERY
,
1523 .properties
= bq24190_battery_properties
,
1524 .num_properties
= ARRAY_SIZE(bq24190_battery_properties
),
1525 .get_property
= bq24190_battery_get_property
,
1526 .set_property
= bq24190_battery_set_property
,
1527 .property_is_writeable
= bq24190_battery_property_is_writeable
,
1530 static void bq24190_check_status(struct bq24190_dev_info
*bdi
)
1532 const u8 battery_mask_ss
= BQ24190_REG_SS_CHRG_STAT_MASK
;
1533 const u8 battery_mask_f
= BQ24190_REG_F_BAT_FAULT_MASK
1534 | BQ24190_REG_F_NTC_FAULT_MASK
;
1535 bool alert_charger
= false, alert_battery
= false;
1536 u8 ss_reg
= 0, f_reg
= 0;
1539 ret
= bq24190_read(bdi
, BQ24190_REG_SS
, &ss_reg
);
1541 dev_err(bdi
->dev
, "Can't read SS reg: %d\n", ret
);
1547 ret
= bq24190_read(bdi
, BQ24190_REG_F
, &f_reg
);
1549 dev_err(bdi
->dev
, "Can't read F reg: %d\n", ret
);
1552 } while (f_reg
&& ++i
< 2);
1554 /* ignore over/under voltage fault after disconnect */
1555 if (f_reg
== (1 << BQ24190_REG_F_CHRG_FAULT_SHIFT
) &&
1556 !(ss_reg
& BQ24190_REG_SS_PG_STAT_MASK
))
1559 if (f_reg
!= bdi
->f_reg
) {
1561 "Fault: boost %d, charge %d, battery %d, ntc %d\n",
1562 !!(f_reg
& BQ24190_REG_F_BOOST_FAULT_MASK
),
1563 !!(f_reg
& BQ24190_REG_F_CHRG_FAULT_MASK
),
1564 !!(f_reg
& BQ24190_REG_F_BAT_FAULT_MASK
),
1565 !!(f_reg
& BQ24190_REG_F_NTC_FAULT_MASK
));
1567 mutex_lock(&bdi
->f_reg_lock
);
1568 if ((bdi
->f_reg
& battery_mask_f
) != (f_reg
& battery_mask_f
))
1569 alert_battery
= true;
1570 if ((bdi
->f_reg
& ~battery_mask_f
) != (f_reg
& ~battery_mask_f
))
1571 alert_charger
= true;
1573 mutex_unlock(&bdi
->f_reg_lock
);
1576 if (ss_reg
!= bdi
->ss_reg
) {
1578 * The device is in host mode so when PG_STAT goes from 1->0
1579 * (i.e., power removed) HIZ needs to be disabled.
1581 if ((bdi
->ss_reg
& BQ24190_REG_SS_PG_STAT_MASK
) &&
1582 !(ss_reg
& BQ24190_REG_SS_PG_STAT_MASK
)) {
1583 ret
= bq24190_write_mask(bdi
, BQ24190_REG_ISC
,
1584 BQ24190_REG_ISC_EN_HIZ_MASK
,
1585 BQ24190_REG_ISC_EN_HIZ_SHIFT
,
1588 dev_err(bdi
->dev
, "Can't access ISC reg: %d\n",
1592 if ((bdi
->ss_reg
& battery_mask_ss
) != (ss_reg
& battery_mask_ss
))
1593 alert_battery
= true;
1594 if ((bdi
->ss_reg
& ~battery_mask_ss
) != (ss_reg
& ~battery_mask_ss
))
1595 alert_charger
= true;
1596 bdi
->ss_reg
= ss_reg
;
1599 if (alert_charger
|| alert_battery
)
1600 power_supply_changed(bdi
->charger
);
1601 if (alert_battery
&& bdi
->battery
)
1602 power_supply_changed(bdi
->battery
);
1604 dev_dbg(bdi
->dev
, "ss_reg: 0x%02x, f_reg: 0x%02x\n", ss_reg
, f_reg
);
1607 static irqreturn_t
bq24190_irq_handler_thread(int irq
, void *data
)
1609 struct bq24190_dev_info
*bdi
= data
;
1612 bdi
->irq_event
= true;
1613 error
= pm_runtime_get_sync(bdi
->dev
);
1615 dev_warn(bdi
->dev
, "pm_runtime_get failed: %i\n", error
);
1616 pm_runtime_put_noidle(bdi
->dev
);
1619 bq24190_check_status(bdi
);
1620 pm_runtime_mark_last_busy(bdi
->dev
);
1621 pm_runtime_put_autosuspend(bdi
->dev
);
1622 bdi
->irq_event
= false;
1627 static int bq24190_hw_init(struct bq24190_dev_info
*bdi
)
1632 /* First check that the device really is what its supposed to be */
1633 ret
= bq24190_read_mask(bdi
, BQ24190_REG_VPRS
,
1634 BQ24190_REG_VPRS_PN_MASK
,
1635 BQ24190_REG_VPRS_PN_SHIFT
,
1640 if (v
!= BQ24190_REG_VPRS_PN_24190
&&
1641 v
!= BQ24190_REG_VPRS_PN_24192I
) {
1642 dev_err(bdi
->dev
, "Error unknown model: 0x%02x\n", v
);
1646 ret
= bq24190_register_reset(bdi
);
1650 ret
= bq24190_set_config(bdi
);
1654 return bq24190_read(bdi
, BQ24190_REG_SS
, &bdi
->ss_reg
);
1657 static int bq24190_get_config(struct bq24190_dev_info
*bdi
)
1659 const char * const s
= "ti,system-minimum-microvolt";
1660 struct power_supply_battery_info info
= {};
1663 if (device_property_read_u32(bdi
->dev
, s
, &v
) == 0) {
1665 if (v
>= BQ24190_REG_POC_SYS_MIN_MIN
1666 && v
<= BQ24190_REG_POC_SYS_MIN_MAX
)
1669 dev_warn(bdi
->dev
, "invalid value for %s: %u\n", s
, v
);
1672 if (bdi
->dev
->of_node
&&
1673 !power_supply_get_battery_info(bdi
->charger
, &info
)) {
1674 v
= info
.precharge_current_ua
/ 1000;
1675 if (v
>= BQ24190_REG_PCTCC_IPRECHG_MIN
1676 && v
<= BQ24190_REG_PCTCC_IPRECHG_MAX
)
1679 dev_warn(bdi
->dev
, "invalid value for battery:precharge-current-microamp: %d\n",
1682 v
= info
.charge_term_current_ua
/ 1000;
1683 if (v
>= BQ24190_REG_PCTCC_ITERM_MIN
1684 && v
<= BQ24190_REG_PCTCC_ITERM_MAX
)
1687 dev_warn(bdi
->dev
, "invalid value for battery:charge-term-current-microamp: %d\n",
1694 static int bq24190_probe(struct i2c_client
*client
,
1695 const struct i2c_device_id
*id
)
1697 struct i2c_adapter
*adapter
= to_i2c_adapter(client
->dev
.parent
);
1698 struct device
*dev
= &client
->dev
;
1699 struct power_supply_config charger_cfg
= {}, battery_cfg
= {};
1700 struct bq24190_dev_info
*bdi
;
1703 if (!i2c_check_functionality(adapter
, I2C_FUNC_SMBUS_BYTE_DATA
)) {
1704 dev_err(dev
, "No support for SMBUS_BYTE_DATA\n");
1708 bdi
= devm_kzalloc(dev
, sizeof(*bdi
), GFP_KERNEL
);
1710 dev_err(dev
, "Can't alloc bdi struct\n");
1714 bdi
->client
= client
;
1716 strncpy(bdi
->model_name
, id
->name
, I2C_NAME_SIZE
);
1717 mutex_init(&bdi
->f_reg_lock
);
1719 bdi
->ss_reg
= BQ24190_REG_SS_VBUS_STAT_MASK
; /* impossible state */
1720 INIT_DELAYED_WORK(&bdi
->input_current_limit_work
,
1721 bq24190_input_current_limit_work
);
1723 i2c_set_clientdata(client
, bdi
);
1725 if (client
->irq
<= 0) {
1726 dev_err(dev
, "Can't get irq info\n");
1730 pm_runtime_enable(dev
);
1731 pm_runtime_use_autosuspend(dev
);
1732 pm_runtime_set_autosuspend_delay(dev
, 600);
1733 ret
= pm_runtime_get_sync(dev
);
1735 dev_err(dev
, "pm_runtime_get failed: %i\n", ret
);
1739 charger_cfg
.drv_data
= bdi
;
1740 charger_cfg
.of_node
= dev
->of_node
;
1741 charger_cfg
.supplied_to
= bq24190_charger_supplied_to
;
1742 charger_cfg
.num_supplicants
= ARRAY_SIZE(bq24190_charger_supplied_to
),
1743 bdi
->charger
= power_supply_register(dev
, &bq24190_charger_desc
,
1745 if (IS_ERR(bdi
->charger
)) {
1746 dev_err(dev
, "Can't register charger\n");
1747 ret
= PTR_ERR(bdi
->charger
);
1751 /* the battery class is deprecated and will be removed. */
1752 /* in the interim, this property hides it. */
1753 if (!device_property_read_bool(dev
, "omit-battery-class")) {
1754 battery_cfg
.drv_data
= bdi
;
1755 bdi
->battery
= power_supply_register(dev
, &bq24190_battery_desc
,
1757 if (IS_ERR(bdi
->battery
)) {
1758 dev_err(dev
, "Can't register battery\n");
1759 ret
= PTR_ERR(bdi
->battery
);
1764 ret
= bq24190_get_config(bdi
);
1766 dev_err(dev
, "Can't get devicetree config\n");
1770 ret
= bq24190_hw_init(bdi
);
1772 dev_err(dev
, "Hardware init failed\n");
1776 ret
= bq24190_sysfs_create_group(bdi
);
1778 dev_err(dev
, "Can't create sysfs entries\n");
1782 bdi
->initialized
= true;
1784 ret
= devm_request_threaded_irq(dev
, client
->irq
, NULL
,
1785 bq24190_irq_handler_thread
,
1786 IRQF_TRIGGER_FALLING
| IRQF_ONESHOT
,
1787 "bq24190-charger", bdi
);
1789 dev_err(dev
, "Can't set up irq handler\n");
1793 ret
= bq24190_register_vbus_regulator(bdi
);
1797 enable_irq_wake(client
->irq
);
1799 pm_runtime_mark_last_busy(dev
);
1800 pm_runtime_put_autosuspend(dev
);
1805 bq24190_sysfs_remove_group(bdi
);
1808 if (!IS_ERR_OR_NULL(bdi
->battery
))
1809 power_supply_unregister(bdi
->battery
);
1810 power_supply_unregister(bdi
->charger
);
1813 pm_runtime_put_sync(dev
);
1814 pm_runtime_dont_use_autosuspend(dev
);
1815 pm_runtime_disable(dev
);
1819 static int bq24190_remove(struct i2c_client
*client
)
1821 struct bq24190_dev_info
*bdi
= i2c_get_clientdata(client
);
1824 error
= pm_runtime_get_sync(bdi
->dev
);
1826 dev_warn(bdi
->dev
, "pm_runtime_get failed: %i\n", error
);
1827 pm_runtime_put_noidle(bdi
->dev
);
1830 bq24190_register_reset(bdi
);
1831 bq24190_sysfs_remove_group(bdi
);
1833 power_supply_unregister(bdi
->battery
);
1834 power_supply_unregister(bdi
->charger
);
1836 pm_runtime_put_sync(bdi
->dev
);
1837 pm_runtime_dont_use_autosuspend(bdi
->dev
);
1838 pm_runtime_disable(bdi
->dev
);
1843 static __maybe_unused
int bq24190_runtime_suspend(struct device
*dev
)
1845 struct i2c_client
*client
= to_i2c_client(dev
);
1846 struct bq24190_dev_info
*bdi
= i2c_get_clientdata(client
);
1848 if (!bdi
->initialized
)
1851 dev_dbg(bdi
->dev
, "%s\n", __func__
);
1856 static __maybe_unused
int bq24190_runtime_resume(struct device
*dev
)
1858 struct i2c_client
*client
= to_i2c_client(dev
);
1859 struct bq24190_dev_info
*bdi
= i2c_get_clientdata(client
);
1861 if (!bdi
->initialized
)
1864 if (!bdi
->irq_event
) {
1865 dev_dbg(bdi
->dev
, "checking events on possible wakeirq\n");
1866 bq24190_check_status(bdi
);
1872 static __maybe_unused
int bq24190_pm_suspend(struct device
*dev
)
1874 struct i2c_client
*client
= to_i2c_client(dev
);
1875 struct bq24190_dev_info
*bdi
= i2c_get_clientdata(client
);
1878 error
= pm_runtime_get_sync(bdi
->dev
);
1880 dev_warn(bdi
->dev
, "pm_runtime_get failed: %i\n", error
);
1881 pm_runtime_put_noidle(bdi
->dev
);
1884 bq24190_register_reset(bdi
);
1887 pm_runtime_mark_last_busy(bdi
->dev
);
1888 pm_runtime_put_autosuspend(bdi
->dev
);
1894 static __maybe_unused
int bq24190_pm_resume(struct device
*dev
)
1896 struct i2c_client
*client
= to_i2c_client(dev
);
1897 struct bq24190_dev_info
*bdi
= i2c_get_clientdata(client
);
1901 bdi
->ss_reg
= BQ24190_REG_SS_VBUS_STAT_MASK
; /* impossible state */
1903 error
= pm_runtime_get_sync(bdi
->dev
);
1905 dev_warn(bdi
->dev
, "pm_runtime_get failed: %i\n", error
);
1906 pm_runtime_put_noidle(bdi
->dev
);
1909 bq24190_register_reset(bdi
);
1910 bq24190_set_config(bdi
);
1911 bq24190_read(bdi
, BQ24190_REG_SS
, &bdi
->ss_reg
);
1914 pm_runtime_mark_last_busy(bdi
->dev
);
1915 pm_runtime_put_autosuspend(bdi
->dev
);
1918 /* Things may have changed while suspended so alert upper layer */
1919 power_supply_changed(bdi
->charger
);
1921 power_supply_changed(bdi
->battery
);
1926 static const struct dev_pm_ops bq24190_pm_ops
= {
1927 SET_RUNTIME_PM_OPS(bq24190_runtime_suspend
, bq24190_runtime_resume
,
1929 SET_SYSTEM_SLEEP_PM_OPS(bq24190_pm_suspend
, bq24190_pm_resume
)
1932 static const struct i2c_device_id bq24190_i2c_ids
[] = {
1937 MODULE_DEVICE_TABLE(i2c
, bq24190_i2c_ids
);
1940 static const struct of_device_id bq24190_of_match
[] = {
1941 { .compatible
= "ti,bq24190", },
1942 { .compatible
= "ti,bq24192i", },
1945 MODULE_DEVICE_TABLE(of
, bq24190_of_match
);
1947 static const struct of_device_id bq24190_of_match
[] = {
1952 static struct i2c_driver bq24190_driver
= {
1953 .probe
= bq24190_probe
,
1954 .remove
= bq24190_remove
,
1955 .id_table
= bq24190_i2c_ids
,
1957 .name
= "bq24190-charger",
1958 .pm
= &bq24190_pm_ops
,
1959 .of_match_table
= of_match_ptr(bq24190_of_match
),
1962 module_i2c_driver(bq24190_driver
);
1964 MODULE_LICENSE("GPL");
1965 MODULE_AUTHOR("Mark A. Greer <mgreer@animalcreek.com>");
1966 MODULE_DESCRIPTION("TI BQ24190 Charger Driver");