From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753024AbcD0N7r (ORCPT ); Wed, 27 Apr 2016 09:59:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34550 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752986AbcD0N7p (ORCPT ); Wed, 27 Apr 2016 09:59:45 -0400 From: Hans de Goede To: Mark Brown , Liam Girdwood , Maxime Ripard , Chen-Yu Tsai Cc: Linux Kernel Mailing List , Hans de Goede Subject: [PATCH v2 3/3] regulator: axp20x: Fix axp22x ldo_io registration error on cold boot Date: Wed, 27 Apr 2016 15:59:28 +0200 Message-Id: <1461765568-15828-4-git-send-email-hdegoede@redhat.com> In-Reply-To: <1461765568-15828-1-git-send-email-hdegoede@redhat.com> References: <1461765568-15828-1-git-send-email-hdegoede@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The maximum supported voltage for ldo_io# is 3.3V, but on cold boot the selector comes up at 0x1f, which maps to 3.8V. This causes _regulator_get_voltage() to fail with -EINVAL which causes regulator registration to fail when constrains are used: [ 1.467788] vcc-touchscreen: failed to get the current voltage(-22) [ 1.474209] axp20x-regulator axp20x-regulator: Failed to register ldo_io1 [ 1.483363] axp20x-regulator: probe of axp20x-regulator failed with error -22 This commits makes axp20x_probe fix-up the selector values in the chip before registering regulators avoiding the above errors. Signed-off-by: Hans de Goede --- drivers/regulator/axp20x-regulator.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c index 89f6842..5ddaa82 100644 --- a/drivers/regulator/axp20x-regulator.c +++ b/drivers/regulator/axp20x-regulator.c @@ -347,6 +347,7 @@ static int axp20x_regulator_probe(struct platform_device *pdev) .driver_data = axp20x, }; int ret, i, nregulators; + unsigned int reg, sel; u32 workmode; const char *axp22x_dc1_name = axp22x_regulators[AXP22X_DCDC1].name; const char *axp22x_dc5_name = axp22x_regulators[AXP22X_DCDC5].name; @@ -361,6 +362,24 @@ static int axp20x_regulator_probe(struct platform_device *pdev) case AXP223_ID: regulators = axp22x_regulators; nregulators = AXP22X_REG_ID_MAX; + /* + * On cold boot ldo_io# sel is 0x1f which is out of spec, + * fix this up here to avoid _regulator_get_voltage returning + * -EINVAL when applying constraints. + */ + for (reg = AXP22X_LDO_IO0_V_OUT; + reg <= AXP22X_LDO_IO1_V_OUT; reg += 2) { + ret = regmap_read(axp20x->regmap, reg, &sel); + if (ret) + return ret; + sel &= 0x1f; + if (sel > 0x1a) { + ret = regmap_update_bits(axp20x->regmap, reg, + 0x1f, 0x1a); + if (ret) + return ret; + } + } break; default: dev_err(&pdev->dev, "Unsupported AXP variant: %ld\n", -- 2.7.4