diff options
author | Rong Dian <b38775@freescale.com> | 2012-07-13 13:07:38 +0800 |
---|---|---|
committer | Terry Lv <r65388@freescale.com> | 2012-07-25 13:10:49 +0800 |
commit | 546ebdd01050a591a036cbdc17cc26cca6e9bee6 (patch) | |
tree | b3d4ad1cd1129a49a4985f43f4d80199ef4fac65 /drivers/power | |
parent | 30293bc62550ebc14bb3848c5f9c326f7e792e69 (diff) |
ENGR00216998: battery: add usb charger voltage offset sysfs interface
add usb charger voltage offset sysfs interface
Signed-off-by: Rong Dian <b38775@freescale.com>
Diffstat (limited to 'drivers/power')
-rwxr-xr-x | drivers/power/sabresd_battery.c | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/drivers/power/sabresd_battery.c b/drivers/power/sabresd_battery.c index 0e748cd345a9..dd839868dc01 100755 --- a/drivers/power/sabresd_battery.c +++ b/drivers/power/sabresd_battery.c @@ -68,6 +68,8 @@ typedef struct { static int cpu_type_flag; static int offset_discharger; static int offset_charger; +static int offset_usb_charger; + static battery_capacity chargingTable[] = { {4060, 99}, @@ -225,7 +227,12 @@ u32 calibration_voltage(struct max8903_data *data) /* ADC offset when battery is discharger*/ volt[i] = max11801_read_adc()-offset_discharger; } else { - volt[i] = max11801_read_adc()-offset_charger; + if (data->charger_online == 1) + volt[i] = max11801_read_adc()-offset_charger; + else if (data->usb_charger_online == 1) + volt[i] = max11801_read_adc()-offset_usb_charger; + else if (data->charger_online == 1 && data->usb_charger_online == 1) + volt[i] = max11801_read_adc()-offset_charger; } } if (cpu_type_flag == 0) { @@ -233,7 +240,12 @@ u32 calibration_voltage(struct max8903_data *data) /* ADC offset when battery is discharger*/ volt[i] = max11801_read_adc()-offset_discharger; } else { - volt[i] = max11801_read_adc()-offset_charger; + if (data->charger_online == 1) + volt[i] = max11801_read_adc()-offset_charger; + else if (data->usb_charger_online == 1) + volt[i] = max11801_read_adc()-offset_usb_charger; + else if (data->charger_online == 1 && data->usb_charger_online == 1) + volt[i] = max11801_read_adc()-offset_charger; } } } @@ -515,6 +527,22 @@ static ssize_t max8903_voltage_offset_charger_store(struct device *dev, return count; } +static ssize_t max8903_voltage_offset_usb_charger_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return sprintf(buf, "read offset_usb_charger:%04d\n", + offset_usb_charger); +} + +static ssize_t max8903_voltage_offset_usb_charger_store(struct device *dev, + struct device_attribute *attr, const char *buf, + size_t count) +{ + offset_usb_charger = simple_strtoul(buf, NULL, 10); + pr_info("read offset_charger:%04d\n", offset_usb_charger); + return count; +} + static struct device_attribute max8903_discharger_dev_attr = { .attr = { .name = "max8903_ctl_offset_discharger", @@ -533,6 +561,15 @@ static struct device_attribute max8903_charger_dev_attr = { .store = max8903_voltage_offset_charger_store, }; +static struct device_attribute max8903_usb_charger_dev_attr = { + .attr = { + .name = "max8903_ctl_offset_usb_charger", + .mode = S_IRUSR | S_IWUSR, + }, + .show = max8903_voltage_offset_usb_charger_show, + .store = max8903_voltage_offset_usb_charger_store, +}; + static __devinit int max8903_probe(struct platform_device *pdev) { struct max8903_data *data; @@ -734,13 +771,18 @@ static __devinit int max8903_probe(struct platform_device *pdev) ret = device_create_file(&pdev->dev, &max8903_charger_dev_attr); if (ret) dev_err(&pdev->dev, "create device file failed!\n"); + ret = device_create_file(&pdev->dev, &max8903_usb_charger_dev_attr); + if (ret) + dev_err(&pdev->dev, "create device file failed!\n"); if (cpu_type_flag == 1) { offset_discharger = 1694; offset_charger = 1900; + offset_usb_charger = 1685; } if (cpu_type_flag == 0) { offset_discharger = 1464; offset_charger = 1485; + offset_usb_charger = 1285; } max8903_charger_update_status(data); |