12 #include <linux/module.h>
14 #include <linux/slab.h>
15 #include <linux/i2c.h>
22 #define MAX8925_OUT5VEN 0x54
23 #define MAX8925_OUT3VEN 0x58
24 #define MAX8925_CHG_CNTL1 0x7c
27 #define MAX8925_CHG_STAT_VSYSLOW (1 << 0)
28 #define MAX8925_CHG_STAT_MODE_MASK (3 << 2)
29 #define MAX8925_CHG_STAT_EN_MASK (1 << 4)
30 #define MAX8925_CHG_MBDET (1 << 1)
31 #define MAX8925_CHG_AC_RANGE_MASK (3 << 6)
34 #define MAX8925_ADC_RES_CNFG1 0x06
35 #define MAX8925_ADC_AVG_CNFG1 0x07
36 #define MAX8925_ADC_ACQ_CNFG1 0x08
37 #define MAX8925_ADC_ACQ_CNFG2 0x09
39 #define MAX8925_ADC_AUX2 0x62
40 #define MAX8925_ADC_VCHG 0x64
41 #define MAX8925_ADC_VBBATT 0x66
42 #define MAX8925_ADC_VMBATT 0x68
43 #define MAX8925_ADC_ISNS 0x6a
44 #define MAX8925_ADC_THM 0x6c
45 #define MAX8925_ADC_TDIE 0x6e
46 #define MAX8925_CMD_AUX2 0xc8
47 #define MAX8925_CMD_VCHG 0xd0
48 #define MAX8925_CMD_VBBATT 0xd8
49 #define MAX8925_CMD_VMBATT 0xe0
50 #define MAX8925_CMD_ISNS 0xe8
51 #define MAX8925_CMD_THM 0xf0
52 #define MAX8925_CMD_TDIE 0xf8
102 dev_dbg(chip->
dev,
"%s\n", (enable) ?
"Enable charger"
103 :
"Disable charger");
115 __set_charger(info, 1);
120 __set_charger(info, 0);
125 dev_dbg(chip->
dev,
"Battery temperature is out of range\n");
128 __set_charger(info, 0);
132 dev_dbg(chip->
dev,
"Battery temperature is in range\n");
139 dev_dbg(chip->
dev,
"Sys power is above low threshold\n");
142 __set_charger(info, 0);
146 dev_dbg(chip->
dev,
"Charging in top-off mode\n");
149 __set_charger(info, 0);
150 dev_dbg(chip->
dev,
"Safe timer is expired\n");
153 __set_charger(info, 0);
162 unsigned char buf[2] = {0, 0};
164 int meas_reg = 0,
ret;
189 ret = ((buf[0]<<8) | buf[1]) >> 4;
194 static int max8925_ac_get_prop(
struct power_supply *psy,
228 static int max8925_usb_get_prop(
struct power_supply *psy,
262 static int max8925_bat_get_prop(
struct power_supply *psy,
289 ret = ((ret * 6250) - 3125) ;
349 #define REQUEST_IRQ(_irq, _name) \
351 ret = request_threaded_irq(chip->irq_base + _irq, NULL, \
352 max8925_charger_handler, \
353 IRQF_ONESHOT, _name, info); \
355 dev_err(chip->dev, "Failed to request IRQ #%d: %d\n", \
436 pdata = pdev->
dev.platform_data;
438 dev_err(&pdev->
dev,
"platform data isn't assigned to "
449 platform_set_drvdata(pdev, info);
451 info->
ac.name =
"max8925-ac";
453 info->
ac.properties = max8925_ac_props;
455 info->
ac.get_property = max8925_ac_get_prop;
461 info->
ac.dev->parent = &pdev->
dev;
463 info->
usb.name =
"max8925-usb";
465 info->
usb.properties = max8925_usb_props;
467 info->
usb.get_property = max8925_usb_get_prop;
474 info->
usb.dev->parent = &pdev->
dev;
476 info->
battery.name =
"max8925-battery";
478 info->
battery.properties = max8925_battery_props;
480 info->
battery.get_property = max8925_bat_get_prop;
493 max8925_init_charger(chip, info);
512 max8925_deinit_charger(info);
519 .probe = max8925_power_probe,
522 .name =
"max8925-power",