From patchwork Wed Jul 12 09:42:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Jacques Hiblot X-Patchwork-Id: 787100 X-Patchwork-Delegate: jh80.chung@samsung.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3x6vK242VGz9s65 for ; Wed, 12 Jul 2017 19:48:22 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="Wko7flGA"; dkim-atps=neutral Received: by lists.denx.de (Postfix, from userid 105) id 5401EC21F9F; Wed, 12 Jul 2017 09:46:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id C1D92C21F95; Wed, 12 Jul 2017 09:43:55 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 53E61C21F97; Wed, 12 Jul 2017 09:43:43 +0000 (UTC) Received: from fllnx209.ext.ti.com (fllnx209.ext.ti.com [198.47.19.16]) by lists.denx.de (Postfix) with ESMTPS id 480A8C21EE4 for ; Wed, 12 Jul 2017 09:43:39 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx209.ext.ti.com (8.15.1/8.15.1) with ESMTP id v6C9gvfR001967; Wed, 12 Jul 2017 04:42:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1499852577; bh=cU2yrTIbNm7A6bAtcjjrTTEb79zub/36omKqjJ5V2DY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Wko7flGAUtvvVP3neA23oUCXW6W4lMkD39hpQo33M+s5HQLpOYTdKLZmPEUX9RtiP iKPlVn6LMxnKvfX4/zU8T/1cO2TfYo1N3UK4t+8PKKTNOS2PO/1UfZDZBSqJ/oz5Kc WN+dDXQzPDsx7FCs3N9BTp+xlv2E4/LaYDHIKMwo= Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v6C9gqkd019280; Wed, 12 Jul 2017 04:42:52 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.294.0; Wed, 12 Jul 2017 04:42:52 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id v6C9gpWI026118; Wed, 12 Jul 2017 04:42:51 -0500 From: Jean-Jacques Hiblot To: , , , , , Date: Wed, 12 Jul 2017 11:42:47 +0200 Message-ID: <1499852567-28165-3-git-send-email-jjhiblot@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499852567-28165-1-git-send-email-jjhiblot@ti.com> References: <1499852567-28165-1-git-send-email-jjhiblot@ti.com> MIME-Version: 1.0 Subject: [U-Boot] [PATCH 2/2] regulator: palmas: disable bypass when the LDO is enabled X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Some LDOs have a bypass capability. Make sure that the bypass is disabled when is the LDO is enabled (otherwise the voltage can't be changed). Signed-off-by: Jean-Jacques Hiblot Reviewed-by: Keerthy Reviewed-by: Tom Rini --- drivers/power/regulator/palmas_regulator.c | 36 ++++++++++++++++++++++++++++++ include/power/palmas.h | 1 + 2 files changed, 37 insertions(+) diff --git a/drivers/power/regulator/palmas_regulator.c b/drivers/power/regulator/palmas_regulator.c index 99614b0..24a7977 100644 --- a/drivers/power/regulator/palmas_regulator.c +++ b/drivers/power/regulator/palmas_regulator.c @@ -163,6 +163,38 @@ static int palmas_smps_val(struct udevice *dev, int op, int *uV) return pmic_reg_write(dev->parent, adr, ret); } +static int palmas_ldo_bypass_enable(struct udevice *dev, bool enabled) +{ + int type = dev_get_driver_data(dev_get_parent(dev)); + struct dm_regulator_uclass_platdata *p; + unsigned int adr; + int reg; + + if (type == TPS65917) { + /* bypass available only on LDO1 and LDO2 */ + if (dev->driver_data > 2) + return -ENOTSUPP; + } else if (type == TPS659038) { + /* bypass available only on LDO9 */ + if (dev->driver_data != 9) + return -ENOTSUPP; + } + + p = dev_get_uclass_platdata(dev); + adr = p->ctrl_reg; + + reg = pmic_reg_read(dev->parent, adr); + if (reg < 0) + return reg; + + if (enabled) + reg |= PALMAS_LDO_BYPASS_EN; + else + reg &= ~PALMAS_LDO_BYPASS_EN; + + return pmic_reg_write(dev->parent, adr, reg); +} + static int palmas_ldo_enable(struct udevice *dev, int op, bool *enable) { int ret; @@ -194,6 +226,10 @@ static int palmas_ldo_enable(struct udevice *dev, int op, bool *enable) ret = pmic_reg_write(dev->parent, adr, ret); if (ret) return ret; + + ret = palmas_ldo_bypass_enable(dev, false); + if (ret && (ret != -ENOTSUPP)) + return ret; } return 0; diff --git a/include/power/palmas.h b/include/power/palmas.h index bad5a35..df5f15c 100644 --- a/include/power/palmas.h +++ b/include/power/palmas.h @@ -23,3 +23,4 @@ #define PALMAS_LDO_VOLT_MAX 3300000 #define PALMAS_LDO_MODE_MASK 0x1 #define PALMAS_LDO_STATUS_MASK 0x10 +#define PALMAS_LDO_BYPASS_EN 0x40