mfd: pm8058: Modify pm8058 subdevices to pm8xxx interface
Move the following subdevices to use the pm8xxx interface -
mpp, irq, gpio, keypad, power-key, leds, othc, vibrator,
rtc, batt-alarm, thermal, upl, nfc, pwm, xoadc, regulators,
xo-buffers, charger.
This allows usage of a common driver for modules which are same
across multiple PM8XXX PMICs. It also provides flexibility
to add/remove subdevices for multiple board configurations.
Change-Id: Id9795552fc9f4a2c920c070babfaef1f4cd6ca61
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index cca1035..3590e6d 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -244,7 +244,7 @@
config BATTERY_MSM8X60
tristate "MSM8X60 battery"
- select PMIC8058_BATTALARM
+ select PMIC8XXX_BATTALARM
help
Some MSM boards have dual charging paths to charge the battery.
Say Y to enable support for the battery charging in
diff --git a/drivers/power/pmic8058-charger.c b/drivers/power/pmic8058-charger.c
index a3ce54d..70b5d59 100644
--- a/drivers/power/pmic8058-charger.c
+++ b/drivers/power/pmic8058-charger.c
@@ -15,7 +15,6 @@
#include <linux/moduleparam.h>
#include <linux/platform_device.h>
#include <linux/errno.h>
-#include <linux/mfd/pmic8058.h>
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/bitops.h>
@@ -25,8 +24,10 @@
#include <linux/slab.h>
#include <linux/msm_adc.h>
#include <linux/notifier.h>
-#include <linux/pmic8058-batt-alarm.h>
+#include <linux/mfd/pm8xxx/core.h>
+#include <linux/mfd/pmic8058.h>
#include <linux/pmic8058-charger.h>
+#include <linux/mfd/pm8xxx/batt-alarm.h>
#include <mach/msm_xo.h>
#include <mach/msm_hsusb.h>
@@ -177,7 +178,6 @@
struct pm8058_charger {
struct pmic_charger_pdata *pdata;
- struct pm8058_chip *pm_chip;
struct device *dev;
int pmic_chg_irq[PMIC_CHG_MAX_INTS];
@@ -228,7 +228,11 @@
if (rc)
goto out;
- rc = pm8058_batt_alarm_threshold_set(resume_mv, 4300);
+ rc = pm8xxx_batt_alarm_threshold_set(
+ PM8XXX_BATT_ALARM_LOWER_COMPARATOR, resume_mv);
+ if (!rc)
+ rc = pm8xxx_batt_alarm_threshold_set(
+ PM8XXX_BATT_ALARM_UPPER_COMPARATOR, 4300);
out:
mutex_unlock(&batt_alarm_lock);
@@ -255,15 +259,9 @@
static int pm_chg_get_rt_status(int irq)
{
- int count = 3;
int ret;
- while ((ret =
- pm8058_irq_get_rt_status(pm8058_chg.pm_chip, irq)) == -EAGAIN
- && count--) {
- dev_info(pm8058_chg.dev, "%s trycount=%d\n", __func__, count);
- cpu_relax();
- }
+ ret = pm8xxx_read_irq_stat(pm8058_chg.dev->parent, irq);
if (ret == -EAGAIN)
return 0;
else
@@ -281,53 +279,53 @@
u8 temp;
int temp2;
- pm8058_read(pm8058_chg.pm_chip, PM8058_CHG_CNTRL, &temp, 1);
+ pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_CNTRL, &temp);
dev_dbg(pm8058_chg.dev, "PM8058_CHG_CNTRL = 0x%x\n", temp);
- pm8058_read(pm8058_chg.pm_chip, PM8058_CHG_CNTRL_2, &temp, 1);
+ pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_CNTRL_2, &temp);
dev_dbg(pm8058_chg.dev, "PM8058_CHG_CNTRL_2 = 0x%x\n", temp);
- pm8058_read(pm8058_chg.pm_chip, PM8058_CHG_VMAX_SEL, &temp, 1);
+ pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_VMAX_SEL, &temp);
dev_dbg(pm8058_chg.dev, "PM8058_CHG_VMAX_SEL = 0x%x\n", temp);
- pm8058_read(pm8058_chg.pm_chip, PM8058_CHG_VBAT_DET, &temp, 1);
+ pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_VBAT_DET, &temp);
dev_dbg(pm8058_chg.dev, "PM8058_CHG_VBAT_DET = 0x%x\n", temp);
- pm8058_read(pm8058_chg.pm_chip, PM8058_CHG_IMAX, &temp, 1);
+ pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_IMAX, &temp);
dev_dbg(pm8058_chg.dev, "PM8058_CHG_IMAX = 0x%x\n", temp);
- pm8058_read(pm8058_chg.pm_chip, PM8058_CHG_TRICKLE, &temp, 1);
+ pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_TRICKLE, &temp);
dev_dbg(pm8058_chg.dev, "PM8058_CHG_TRICKLE = 0x%x\n", temp);
- pm8058_read(pm8058_chg.pm_chip, PM8058_CHG_ITERM, &temp, 1);
+ pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_ITERM, &temp);
dev_dbg(pm8058_chg.dev, "PM8058_CHG_ITERM = 0x%x\n", temp);
- pm8058_read(pm8058_chg.pm_chip, PM8058_CHG_TTRKL_MAX, &temp, 1);
+ pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_TTRKL_MAX, &temp);
dev_dbg(pm8058_chg.dev, "PM8058_CHG_TTRKL_MAX = 0x%x\n", temp);
- pm8058_read(pm8058_chg.pm_chip, PM8058_CHG_TCHG_MAX, &temp, 1);
+ pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_TCHG_MAX, &temp);
dev_dbg(pm8058_chg.dev, "PM8058_CHG_TCHG_MAX = 0x%x\n", temp);
- pm8058_read(pm8058_chg.pm_chip, PM8058_CHG_TEMP_THRESH, &temp, 1);
+ pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_TEMP_THRESH, &temp);
dev_dbg(pm8058_chg.dev, "PM8058_CHG_TEMP_THRESH = 0x%x\n", temp);
- pm8058_read(pm8058_chg.pm_chip, PM8058_CHG_TEMP_REG, &temp, 1);
+ pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_TEMP_REG, &temp);
dev_dbg(pm8058_chg.dev, "PM8058_CHG_TEMP_REG = 0x%x\n", temp);
- pm8058_read(pm8058_chg.pm_chip, PM8058_CHG_PULSE, &temp, 1);
+ pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_PULSE, &temp);
dev_dbg(pm8058_chg.dev, "PM8058_CHG_PULSE = 0x%x\n", temp);
- pm8058_read(pm8058_chg.pm_chip, PM8058_CHG_STATUS_CLEAR_IRQ_1,
- &temp, 1);
+ pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_STATUS_CLEAR_IRQ_1,
+ &temp);
dev_dbg(pm8058_chg.dev, "PM8058_CHG_STATUS_CLEAR_IRQ_1 = 0x%x\n", temp);
- pm8058_read(pm8058_chg.pm_chip, PM8058_CHG_STATUS_CLEAR_IRQ_3,
- &temp, 1);
+ pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_STATUS_CLEAR_IRQ_3,
+ &temp);
dev_dbg(pm8058_chg.dev, "PM8058_CHG_STATUS_CLEAR_IRQ_3 = 0x%x\n", temp);
- pm8058_read(pm8058_chg.pm_chip, PM8058_CHG_STATUS_CLEAR_IRQ_10,
- &temp, 1);
+ pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_STATUS_CLEAR_IRQ_10,
+ &temp);
dev_dbg(pm8058_chg.dev, "PM8058_CHG_STATUS_CLEAR_IRQ_10 = 0x%x\n",
temp);
- pm8058_read(pm8058_chg.pm_chip, PM8058_CHG_STATUS_CLEAR_IRQ_11,
- &temp, 1);
+ pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_STATUS_CLEAR_IRQ_11,
+ &temp);
dev_dbg(pm8058_chg.dev, "PM8058_CHG_STATUS_CLEAR_IRQ_11 = 0x%x\n",
temp);
- pm8058_read(pm8058_chg.pm_chip, PM8058_CHG_MASK_IRQ_1, &temp, 1);
+ pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_MASK_IRQ_1, &temp);
dev_dbg(pm8058_chg.dev, "PM8058_CHG_MASK_IRQ_1 = 0x%x\n", temp);
- pm8058_read(pm8058_chg.pm_chip, PM8058_CHG_MASK_IRQ_3, &temp, 1);
+ pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_MASK_IRQ_3, &temp);
dev_dbg(pm8058_chg.dev, "PM8058_CHG_MASK_IRQ_3 = 0x%x\n", temp);
- pm8058_read(pm8058_chg.pm_chip, PM8058_CHG_MASK_IRQ_10, &temp, 1);
+ pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_MASK_IRQ_10, &temp);
dev_dbg(pm8058_chg.dev, "PM8058_CHG_MASK_IRQ_10 = 0x%x\n", temp);
- pm8058_read(pm8058_chg.pm_chip, PM8058_CHG_MASK_IRQ_11, &temp, 1);
+ pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_MASK_IRQ_11, &temp);
dev_dbg(pm8058_chg.dev, "PM8058_CHG_MASK_IRQ_11 = 0x%x\n", temp);
temp2 = pm_chg_get_rt_status(pm8058_chg.pmic_chg_irq[CHGVAL_IRQ]);
@@ -405,7 +403,7 @@
u8 temp;
int ret;
- ret = pm8058_read(pm8058_chg.pm_chip, PM8058_CHG_CNTRL, &temp, 1);
+ ret = pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_CNTRL, &temp);
if (ret)
return ret;
if (value)
@@ -413,7 +411,7 @@
else
temp &= ~BIT(CHG_USB_SUSPEND);
- return pm8058_write(pm8058_chg.pm_chip, PM8058_CHG_CNTRL, &temp, 1);
+ return pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_CNTRL, temp);
}
static int pm_chg_auto_disable(int value)
@@ -421,7 +419,7 @@
u8 temp;
int ret;
- ret = pm8058_read(pm8058_chg.pm_chip, PM8058_CHG_CNTRL_2, &temp, 1);
+ ret = pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_CNTRL_2, &temp);
if (ret)
return ret;
if (value)
@@ -429,7 +427,7 @@
else
temp &= ~BIT(CHARGE_AUTO_DIS);
- return pm8058_write(pm8058_chg.pm_chip, PM8058_CHG_CNTRL_2, &temp, 1);
+ return pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_CNTRL_2, temp);
}
static int pm_chg_batt_temp_disable(int value)
@@ -437,7 +435,7 @@
u8 temp;
int ret;
- ret = pm8058_read(pm8058_chg.pm_chip, PM8058_CHG_CNTRL_2, &temp, 1);
+ ret = pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_CNTRL_2, &temp);
if (ret)
return ret;
if (value)
@@ -445,7 +443,7 @@
else
temp &= ~BIT(CHG_BATT_TEMP_DIS);
- return pm8058_write(pm8058_chg.pm_chip, PM8058_CHG_CNTRL_2, &temp, 1);
+ return pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_CNTRL_2, temp);
}
static int pm_chg_vbatdet_set(int voltage)
@@ -463,7 +461,7 @@
temp = diff / PM8058_CHG_V_STEP_MV;
dev_dbg(pm8058_chg.dev, "%s voltage=%d setting %02x\n", __func__,
voltage, temp);
- return pm8058_write(pm8058_chg.pm_chip, PM8058_CHG_VBAT_DET, &temp, 1);
+ return pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_VBAT_DET, temp);
}
static int pm_chg_imaxsel_set(int chg_current)
@@ -484,7 +482,7 @@
__func__, chg_current);
temp = 31;
}
- return pm8058_write(pm8058_chg.pm_chip, PM8058_CHG_IMAX, &temp, 1);
+ return pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_IMAX, temp);
}
#define PM8058_CHG_VMAX_MIN 3300
@@ -501,7 +499,7 @@
temp = (voltage - PM8058_CHG_V_MIN_MV) / PM8058_CHG_V_STEP_MV;
dev_dbg(pm8058_chg.dev, "%s mV=%d setting %02x\n", __func__, voltage,
temp);
- return pm8058_write(pm8058_chg.pm_chip, PM8058_CHG_VMAX_SEL, &temp, 1);
+ return pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_VMAX_SEL, temp);
}
static int pm_chg_failed_clear(int value)
@@ -509,14 +507,14 @@
u8 temp;
int ret;
- ret = pm8058_read(pm8058_chg.pm_chip, PM8058_CHG_CNTRL_2, &temp, 1);
+ ret = pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_CNTRL_2, &temp);
if (ret)
return ret;
if (value)
temp |= BIT(CHG_FAILED_CLEAR);
else
temp &= ~BIT(CHG_FAILED_CLEAR);
- return pm8058_write(pm8058_chg.pm_chip, PM8058_CHG_CNTRL_2, &temp, 1);
+ return pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_CNTRL_2, temp);
}
static int pm_chg_iterm_set(int chg_current)
@@ -524,7 +522,7 @@
u8 temp;
temp = (chg_current / PM8058_CHG_I_TERM_STEP_MA) - 1;
- return pm8058_write(pm8058_chg.pm_chip, PM8058_CHG_ITERM, &temp, 1);
+ return pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_ITERM, temp);
}
static int pm_chg_tchg_set(int minutes)
@@ -532,7 +530,7 @@
u8 temp;
temp = (minutes >> PM8058_CHG_T_TCHG_SHIFT) - 1;
- return pm8058_write(pm8058_chg.pm_chip, PM8058_CHG_TCHG_MAX, &temp, 1);
+ return pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_TCHG_MAX, temp);
}
static int pm_chg_ttrkl_set(int minutes)
@@ -540,7 +538,8 @@
u8 temp;
temp = minutes - 1;
- return pm8058_write(pm8058_chg.pm_chip, PM8058_CHG_TTRKL_MAX, &temp, 1);
+ return pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_TTRKL_MAX,
+ temp);
}
static int pm_chg_enum_done_enable(int value)
@@ -548,7 +547,7 @@
u8 temp;
int ret;
- ret = pm8058_read(pm8058_chg.pm_chip, PM8058_CHG_CNTRL_2, &temp, 1);
+ ret = pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_CNTRL_2, &temp);
if (ret)
return ret;
if (value)
@@ -556,7 +555,7 @@
else
temp &= ~BIT(ENUM_DONE);
- return pm8058_write(pm8058_chg.pm_chip, PM8058_CHG_CNTRL_2, &temp, 1);
+ return pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_CNTRL_2, temp);
}
static uint32_t get_fsm_state(void)
@@ -564,8 +563,8 @@
u8 temp;
temp = 0x00;
- pm8058_write(pm8058_chg.pm_chip, PM8058_CHG_TEST_3, &temp, 1);
- pm8058_read(pm8058_chg.pm_chip, PM8058_CHG_TEST_3, &temp, 1);
+ pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_TEST_3, temp);
+ pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_TEST_3, &temp);
return (uint32_t)temp;
}
@@ -590,7 +589,7 @@
u8 temp;
int ret;
- ret = pm8058_read(pm8058_chg.pm_chip, PM8058_CHG_CNTRL, &temp, 1);
+ ret = pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_CNTRL, &temp);
if (ret)
return ret;
if (value)
@@ -598,7 +597,7 @@
else
temp &= ~BIT(CHG_CHARGE_DIS);
- return pm8058_write(pm8058_chg.pm_chip, PM8058_CHG_CNTRL, &temp, 1);
+ return pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_CNTRL, temp);
}
static void pm8058_start_system_current(struct msm_hardware_charger *hw_chg,
@@ -734,7 +733,11 @@
case PMIC8058_CHG_STATE_ATC:
case PMIC8058_CHG_STATE_FAST_CHG:
case PMIC8058_CHG_STATE_TRKL_CHG:
- rc = pm8058_batt_alarm_state_set(0, 0);
+ rc = pm8xxx_batt_alarm_disable(
+ PM8XXX_BATT_ALARM_UPPER_COMPARATOR);
+ if (!rc)
+ rc = pm8xxx_batt_alarm_disable(
+ PM8XXX_BATT_ALARM_LOWER_COMPARATOR);
if (rc)
dev_err(pm8058_chg.dev,
"%s: unable to set alarm state\n", __func__);
@@ -863,25 +866,25 @@
}
} else {
if (pm8058_chg.present) {
- ret = pm8058_read(pm8058_chg.pm_chip,
+ ret = pm8xxx_readb(pm8058_chg.dev->parent,
PM8058_OVP_TEST_REG,
- &old, 1);
+ &old);
temp = old | BIT(FORCE_OVP_OFF);
- ret = pm8058_write(pm8058_chg.pm_chip,
+ ret = pm8xxx_writeb(pm8058_chg.dev->parent,
PM8058_OVP_TEST_REG,
- &temp, 1);
+ temp);
temp = 0xFC;
- ret = pm8058_write(pm8058_chg.pm_chip, PM8058_CHG_TEST,
- &temp, 1);
+ ret = pm8xxx_writeb(pm8058_chg.dev->parent,
+ PM8058_CHG_TEST, temp);
/* 10 ms sleep is for the VCHG to discharge */
msleep(10);
temp = 0xF0;
- ret = pm8058_write(pm8058_chg.pm_chip,
+ ret = pm8xxx_writeb(pm8058_chg.dev->parent,
PM8058_CHG_TEST,
- &temp, 1);
- ret = pm8058_write(pm8058_chg.pm_chip,
+ temp);
+ ret = pm8xxx_writeb(pm8058_chg.dev->parent,
PM8058_OVP_TEST_REG,
- &old, 1);
+ old);
pm_chg_enum_done_enable(0);
pm_chg_auto_disable(1);
@@ -904,21 +907,21 @@
pm_chg_enum_done_enable(0);
pm_chg_auto_disable(1);
- ret = pm8058_read(pm8058_chg.pm_chip,
- PM8058_OVP_TEST_REG, &old, 1);
+ ret = pm8xxx_readb(pm8058_chg.dev->parent,
+ PM8058_OVP_TEST_REG, &old);
temp = old | BIT(FORCE_OVP_OFF);
- ret = pm8058_write(pm8058_chg.pm_chip,
- PM8058_OVP_TEST_REG, &temp, 1);
+ ret = pm8xxx_writeb(pm8058_chg.dev->parent,
+ PM8058_OVP_TEST_REG, temp);
temp = 0xFC;
- ret = pm8058_write(pm8058_chg.pm_chip,
- PM8058_CHG_TEST, &temp, 1);
+ ret = pm8xxx_writeb(pm8058_chg.dev->parent,
+ PM8058_CHG_TEST, temp);
/* 10 ms sleep is for the VCHG to discharge */
msleep(10);
temp = 0xF0;
- ret = pm8058_write(pm8058_chg.pm_chip,
- PM8058_CHG_TEST, &temp, 1);
- ret = pm8058_write(pm8058_chg.pm_chip,
- PM8058_OVP_TEST_REG, &old, 1);
+ ret = pm8xxx_writeb(pm8058_chg.dev->parent,
+ PM8058_CHG_TEST, temp);
+ ret = pm8xxx_writeb(pm8058_chg.dev->parent,
+ PM8058_OVP_TEST_REG, old);
if (!is_chg_plugged_in()) {
msm_charger_notify_event(&usb_hw_chg,
@@ -983,8 +986,8 @@
u8 temp;
temp = 0x00;
- if (!pm8058_write(pm8058_chg.pm_chip, PM8058_CHG_TEST_3, &temp, 1)) {
- pm8058_read(pm8058_chg.pm_chip, PM8058_CHG_TEST_3, &temp, 1);
+ if (!pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_TEST_3, temp)) {
+ pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_TEST_3, &temp);
dev_dbg(pm8058_chg.dev, "%s state=%d\n", __func__, temp);
}
return IRQ_HANDLED;
@@ -1187,7 +1190,7 @@
"%s:couldnt find resource AUTO_CHGDONE\n", __func__);
goto err_out;
} else {
- ret = request_threaded_irq(res->start, NULL,
+ ret = request_irq(res->start,
pm8058_chg_auto_chgdone_handler,
IRQF_TRIGGER_RISING,
res->name, NULL);
@@ -1208,7 +1211,7 @@
"%s:couldnt find resource AUTO_CHGFAIL\n", __func__);
goto err_out;
} else {
- ret = request_threaded_irq(res->start, NULL,
+ ret = request_irq(res->start,
pm8058_chg_auto_chgfail_handler,
IRQF_TRIGGER_RISING, res->name, NULL);
if (ret < 0) {
@@ -1227,7 +1230,7 @@
"%s:couldnt find resource CHGSTATE\n", __func__);
goto err_out;
} else {
- ret = request_threaded_irq(res->start, NULL,
+ ret = request_irq(res->start,
pm8058_chg_chgstate_handler,
IRQF_TRIGGER_RISING, res->name, NULL);
if (ret < 0) {
@@ -1246,7 +1249,7 @@
"%s:couldnt find resource FASTCHG\n", __func__);
goto err_out;
} else {
- ret = request_threaded_irq(res->start, NULL,
+ ret = request_irq(res->start,
pm8058_chg_fastchg_handler,
IRQF_TRIGGER_RISING, res->name, NULL);
if (ret < 0) {
@@ -1265,7 +1268,7 @@
"%s:couldnt find resource CHG_END\n", __func__);
goto err_out;
} else {
- ret = request_threaded_irq(res->start, NULL,
+ ret = request_irq(res->start,
pm8058_chg_batttemp_handler,
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
res->name, NULL);
@@ -1286,7 +1289,7 @@
"%s:couldnt find resource BATT_REPLACE\n", __func__);
goto err_out;
} else {
- ret = request_threaded_irq(res->start, NULL,
+ ret = request_irq(res->start,
pm8058_chg_batt_replace_handler,
IRQF_TRIGGER_RISING, res->name, NULL);
if (ret < 0) {
@@ -1305,7 +1308,7 @@
"%s:couldnt find resource BATTCONNECT\n", __func__);
goto err_out;
} else {
- ret = request_threaded_irq(res->start, NULL,
+ ret = request_irq(res->start,
pm8058_chg_battconnect_handler,
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
res->name, NULL);
@@ -1351,7 +1354,7 @@
u8 temp;
int rc;
- rc = pm8058_read(pm8058_chg.pm_chip, PM8058_CHG_CNTRL, &temp, 1);
+ rc = pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_CNTRL, &temp);
if (rc)
return rc;
@@ -1367,7 +1370,7 @@
u8 temp;
int rc;
- rc = pm8058_read(pm8058_chg.pm_chip, PM8058_CHG_CNTRL, &temp, 1);
+ rc = pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_CNTRL, &temp);
if (rc)
return rc;
if (on)
@@ -1375,7 +1378,7 @@
else
temp &= ~BIT(CHG_CHARGE_BAT);
- return pm8058_write(pm8058_chg.pm_chip, PM8058_CHG_CNTRL, &temp, 1);
+ return pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_CNTRL, temp);
}
EXPORT_SYMBOL(pm8058_set_charge_batt);
@@ -1496,12 +1499,12 @@
u8 temp;
temp = 0xA3;
- pm8058_write(pm8058_chg.pm_chip, PM8058_CHG_TEST_2, &temp, 1);
+ pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_TEST_2, temp);
temp = 0x84;
- pm8058_write(pm8058_chg.pm_chip, PM8058_CHG_TEST_2, &temp, 1);
+ pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_TEST_2, temp);
msleep(2);
temp = 0x80;
- pm8058_write(pm8058_chg.pm_chip, PM8058_CHG_TEST_2, &temp, 1);
+ pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_TEST_2, temp);
return 0;
}
@@ -1511,7 +1514,7 @@
int ret;
u8 temp;
- ret = pm8058_read(pm8058_chg.pm_chip, i, &temp, 1);
+ ret = pm8xxx_readb(pm8058_chg.dev->parent, i, &temp);
if (ret)
return -EAGAIN;
*val = temp;
@@ -1525,7 +1528,7 @@
u8 temp;
temp = (u8) val;
- ret = pm8058_write(pm8058_chg.pm_chip, i, &temp, 1);
+ ret = pm8xxx_writeb(pm8058_chg.dev->parent, i, temp);
mb();
if (ret)
return -EAGAIN;
@@ -1821,7 +1824,11 @@
break;
/* expected case - trip of low threshold */
case 1:
- rc = pm8058_batt_alarm_state_set(0, 0);
+ rc = pm8xxx_batt_alarm_disable(
+ PM8XXX_BATT_ALARM_UPPER_COMPARATOR);
+ if (!rc)
+ rc = pm8xxx_batt_alarm_disable(
+ PM8XXX_BATT_ALARM_LOWER_COMPARATOR);
if (rc)
dev_err(pm8058_chg.dev,
"%s: unable to set alarm state\n", __func__);
@@ -1841,8 +1848,15 @@
static int pm8058_monitor_for_recharging(void)
{
+ int rc;
/* enable low comparator */
- return pm8058_batt_alarm_state_set(1, 0);
+ rc = pm8xxx_batt_alarm_disable(PM8XXX_BATT_ALARM_UPPER_COMPARATOR);
+ if (!rc)
+ return pm8xxx_batt_alarm_enable(
+ PM8XXX_BATT_ALARM_LOWER_COMPARATOR);
+
+ return rc;
+
}
static struct msm_battery_gauge pm8058_batt_gauge = {
@@ -1860,33 +1874,30 @@
int ret = 0;
temp = 0x10;
- ret |= pm8058_write(pm8058_chg.pm_chip, PM8058_CHG_TEST, &temp, 1);
- ret |= pm8058_read(pm8058_chg.pm_chip, PM8058_CHG_TEST, &old, 1);
+ ret |= pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_TEST, temp);
+ ret |= pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_TEST, &old);
old = old & ~BIT(IGNORE_LL);
temp = 0x90 | (0xF & old);
- ret |= pm8058_write(pm8058_chg.pm_chip, PM8058_CHG_TEST, &temp, 1);
+ ret |= pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_TEST, temp);
return ret;
}
static int __devinit pm8058_charger_probe(struct platform_device *pdev)
{
- struct pm8058_chip *pm_chip;
struct pmic8058_charger_data *pdata;
int rc = 0;
- pm_chip = dev_get_drvdata(pdev->dev.parent);
- if (pm_chip == NULL) {
- pr_err("%s:no parent data passed in.\n", __func__);
- return -EFAULT;
- }
-
- pm8058_chg.pm_chip = pm_chip;
pm8058_chg.pdata = pdev->dev.platform_data;
pm8058_chg.dev = &pdev->dev;
pdata = (struct pmic8058_charger_data *) pm8058_chg.pdata;
- if (pdata) {
+ if (pdata == NULL) {
+ pr_err("%s: pdata not present\n", __func__);
+ return -EINVAL;
+ }
+
+ if (pdata->charger_data_valid) {
usb_hw_chg.type = pdata->charger_type;
chg_data.charger_type = pdata->charger_type;
chg_data.max_source_current = pdata->max_source_current;
@@ -1928,7 +1939,10 @@
pm8058_chg_enable_irq(BATTTEMP_IRQ);
pm8058_chg_enable_irq(BATTCONNECT_IRQ);
- rc = pm8058_batt_alarm_state_set(0, 0);
+ rc = pm8xxx_batt_alarm_disable(PM8XXX_BATT_ALARM_UPPER_COMPARATOR);
+ if (!rc)
+ rc = pm8xxx_batt_alarm_disable(
+ PM8XXX_BATT_ALARM_LOWER_COMPARATOR);
if (rc) {
pr_err("%s: unable to set batt alarm state\n", __func__);
goto free_irq;
@@ -1938,26 +1952,31 @@
* The batt-alarm driver requires sane values for both min / max,
* regardless of whether they're both activated.
*/
- rc = pm8058_batt_alarm_threshold_set(resume_mv, 4300);
+ rc = pm8xxx_batt_alarm_threshold_set(
+ PM8XXX_BATT_ALARM_LOWER_COMPARATOR, resume_mv);
+ if (!rc)
+ rc = pm8xxx_batt_alarm_threshold_set(
+ PM8XXX_BATT_ALARM_UPPER_COMPARATOR, 4300);
if (rc) {
pr_err("%s: unable to set batt alarm threshold\n", __func__);
goto free_irq;
}
- rc = pm8058_batt_alarm_hold_time_set(PM8058_BATT_ALARM_HOLD_TIME_16_MS);
+ rc = pm8xxx_batt_alarm_hold_time_set(
+ PM8XXX_BATT_ALARM_HOLD_TIME_16_MS);
if (rc) {
pr_err("%s: unable to set batt alarm hold time\n", __func__);
goto free_irq;
}
/* PWM enabled at 2Hz */
- rc = pm8058_batt_alarm_pwm_rate_set(1, 7, 4);
+ rc = pm8xxx_batt_alarm_pwm_rate_set(1, 7, 4);
if (rc) {
pr_err("%s: unable to set batt alarm pwm rate\n", __func__);
goto free_irq;
}
- rc = pm8058_batt_alarm_register_notifier(&alarm_notifier);
+ rc = pm8xxx_batt_alarm_register_notifier(&alarm_notifier);
if (rc) {
pr_err("%s: unable to register alarm notifier\n", __func__);
goto free_irq;
@@ -1987,11 +2006,14 @@
remove_debugfs_entries();
kfree(chip);
- rc = pm8058_batt_alarm_state_set(0, 0);
+ rc = pm8xxx_batt_alarm_disable(PM8XXX_BATT_ALARM_UPPER_COMPARATOR);
+ if (!rc)
+ rc = pm8xxx_batt_alarm_disable(
+ PM8XXX_BATT_ALARM_LOWER_COMPARATOR);
if (rc)
pr_err("%s: unable to set batt alarm state\n", __func__);
- rc |= pm8058_batt_alarm_unregister_notifier(&alarm_notifier);
+ rc |= pm8xxx_batt_alarm_unregister_notifier(&alarm_notifier);
if (rc)
pr_err("%s: unable to register alarm notifier\n", __func__);
return rc;