Commit d556f21c authored by Hans de Goede's avatar Hans de Goede Committed by Sebastian Reichel

power: supply: axp288_charger: Make charger_init_hw_regs propagate i2c errors

Make charger_init_hw_regs propagate i2c errors, instead of only warning
about them and then ignoring them.
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarSebastian Reichel <sre@kernel.org>
parent 7ce7d89f
...@@ -701,59 +701,73 @@ static int axp288_charger_handle_otg_evt(struct notifier_block *nb, ...@@ -701,59 +701,73 @@ static int axp288_charger_handle_otg_evt(struct notifier_block *nb,
return NOTIFY_OK; return NOTIFY_OK;
} }
static void charger_init_hw_regs(struct axp288_chrg_info *info) static int charger_init_hw_regs(struct axp288_chrg_info *info)
{ {
int ret, cc, cv; int ret, cc, cv;
unsigned int val; unsigned int val;
/* Program temperature thresholds */ /* Program temperature thresholds */
ret = regmap_write(info->regmap, AXP20X_V_LTF_CHRG, CHRG_VLTFC_0C); ret = regmap_write(info->regmap, AXP20X_V_LTF_CHRG, CHRG_VLTFC_0C);
if (ret < 0) if (ret < 0) {
dev_warn(&info->pdev->dev, "register(%x) write error(%d)\n", dev_err(&info->pdev->dev, "register(%x) write error(%d)\n",
AXP20X_V_LTF_CHRG, ret); AXP20X_V_LTF_CHRG, ret);
return ret;
}
ret = regmap_write(info->regmap, AXP20X_V_HTF_CHRG, CHRG_VHTFC_45C); ret = regmap_write(info->regmap, AXP20X_V_HTF_CHRG, CHRG_VHTFC_45C);
if (ret < 0) if (ret < 0) {
dev_warn(&info->pdev->dev, "register(%x) write error(%d)\n", dev_err(&info->pdev->dev, "register(%x) write error(%d)\n",
AXP20X_V_HTF_CHRG, ret); AXP20X_V_HTF_CHRG, ret);
return ret;
}
/* Do not turn-off charger o/p after charge cycle ends */ /* Do not turn-off charger o/p after charge cycle ends */
ret = regmap_update_bits(info->regmap, ret = regmap_update_bits(info->regmap,
AXP20X_CHRG_CTRL2, AXP20X_CHRG_CTRL2,
CNTL2_CHG_OUT_TURNON, 1); CNTL2_CHG_OUT_TURNON, 1);
if (ret < 0) if (ret < 0) {
dev_warn(&info->pdev->dev, "register(%x) write error(%d)\n", dev_err(&info->pdev->dev, "register(%x) write error(%d)\n",
AXP20X_CHRG_CTRL2, ret); AXP20X_CHRG_CTRL2, ret);
return ret;
}
/* Enable interrupts */ /* Enable interrupts */
ret = regmap_update_bits(info->regmap, ret = regmap_update_bits(info->regmap,
AXP20X_IRQ2_EN, AXP20X_IRQ2_EN,
BAT_IRQ_CFG_BAT_MASK, 1); BAT_IRQ_CFG_BAT_MASK, 1);
if (ret < 0) if (ret < 0) {
dev_warn(&info->pdev->dev, "register(%x) write error(%d)\n", dev_err(&info->pdev->dev, "register(%x) write error(%d)\n",
AXP20X_IRQ2_EN, ret); AXP20X_IRQ2_EN, ret);
return ret;
}
ret = regmap_update_bits(info->regmap, AXP20X_IRQ3_EN, ret = regmap_update_bits(info->regmap, AXP20X_IRQ3_EN,
TEMP_IRQ_CFG_MASK, 1); TEMP_IRQ_CFG_MASK, 1);
if (ret < 0) if (ret < 0) {
dev_warn(&info->pdev->dev, "register(%x) write error(%d)\n", dev_err(&info->pdev->dev, "register(%x) write error(%d)\n",
AXP20X_IRQ3_EN, ret); AXP20X_IRQ3_EN, ret);
return ret;
}
/* Setup ending condition for charging to be 10% of I(chrg) */ /* Setup ending condition for charging to be 10% of I(chrg) */
ret = regmap_update_bits(info->regmap, ret = regmap_update_bits(info->regmap,
AXP20X_CHRG_CTRL1, AXP20X_CHRG_CTRL1,
CHRG_CCCV_ITERM_20P, 0); CHRG_CCCV_ITERM_20P, 0);
if (ret < 0) if (ret < 0) {
dev_warn(&info->pdev->dev, "register(%x) write error(%d)\n", dev_err(&info->pdev->dev, "register(%x) write error(%d)\n",
AXP20X_CHRG_CTRL1, ret); AXP20X_CHRG_CTRL1, ret);
return ret;
}
/* Disable OCV-SOC curve calibration */ /* Disable OCV-SOC curve calibration */
ret = regmap_update_bits(info->regmap, ret = regmap_update_bits(info->regmap,
AXP20X_CC_CTRL, AXP20X_CC_CTRL,
FG_CNTL_OCV_ADJ_EN, 0); FG_CNTL_OCV_ADJ_EN, 0);
if (ret < 0) if (ret < 0) {
dev_warn(&info->pdev->dev, "register(%x) write error(%d)\n", dev_err(&info->pdev->dev, "register(%x) write error(%d)\n",
AXP20X_CC_CTRL, ret); AXP20X_CC_CTRL, ret);
return ret;
}
/* Init charging current and voltage */ /* Init charging current and voltage */
info->max_cc = info->pdata->max_cc; info->max_cc = info->pdata->max_cc;
...@@ -796,15 +810,21 @@ static void charger_init_hw_regs(struct axp288_chrg_info *info) ...@@ -796,15 +810,21 @@ static void charger_init_hw_regs(struct axp288_chrg_info *info)
cv = min(info->pdata->def_cv, info->max_cv); cv = min(info->pdata->def_cv, info->max_cv);
ret = axp288_charger_set_cc(info, cc); ret = axp288_charger_set_cc(info, cc);
if (ret < 0) if (ret < 0) {
dev_warn(&info->pdev->dev, dev_err(&info->pdev->dev,
"error(%d) in setting CC\n", ret); "error(%d) in setting CC\n", ret);
return ret;
}
ret = axp288_charger_set_cv(info, cv); ret = axp288_charger_set_cv(info, cv);
if (ret < 0) if (ret < 0) {
dev_warn(&info->pdev->dev, dev_err(&info->pdev->dev,
"error(%d) in setting CV\n", ret); "error(%d) in setting CV\n", ret);
return ret;
}
} }
return 0;
} }
static int axp288_charger_probe(struct platform_device *pdev) static int axp288_charger_probe(struct platform_device *pdev)
...@@ -916,7 +936,9 @@ static int axp288_charger_probe(struct platform_device *pdev) ...@@ -916,7 +936,9 @@ static int axp288_charger_probe(struct platform_device *pdev)
} }
} }
charger_init_hw_regs(info); ret = charger_init_hw_regs(info);
if (ret)
goto intr_reg_failed;
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment