From patchwork Mon Nov 26 15:27:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Priit Laes X-Patchwork-Id: 10698513 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 065F014E2 for ; Mon, 26 Nov 2018 15:30:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E9AC029E9C for ; Mon, 26 Nov 2018 15:30:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DCAAB29E9A; Mon, 26 Nov 2018 15:30:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.4 required=2.0 tests=BAYES_00,DKIM_ADSP_ALL, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 71DAE29EF0 for ; Mon, 26 Nov 2018 15:30:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=S8FbvBZ+aD6s5s/XN7Ka2YOxLWjHVfSSX69OHNqifSE=; b=KXktdHFYkYNGSF WxUUbTqblCBEUkltT+B7VnZmSxkY9DYRKkfSxQ/qs+ZEWzfwjZmvl8w0B/S2Phzots3cZvIktoBHV mzNiOQYtHGs5dRKINSkzp3jvf6JLti7KtIwBnO1IkgxVf1vLjYypQa9ratrCmZgpmLkRz6Nf+7gM1 9nmxKTLc8qvZmanmt72luDGLr/vlX2ZsmFeAzTdqukPpI9sPeocaSPRX77QXN9AJEt5wh5J2yCVfv whyuGgBar+qA0Ybr63yZ6WYZgNLtk8S1MtKp1lT9/Krzej/lpDEEBdwNX7PJd1WahJdXsx86TqGXn ZxamI43TdoNg4zcYryiA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gRIpy-0007Du-QR; Mon, 26 Nov 2018 15:30:14 +0000 Received: from plaes.org ([188.166.43.21]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gRIoc-0005ME-KK for linux-arm-kernel@lists.infradead.org; Mon, 26 Nov 2018 15:29:01 +0000 Received: from localhost (85.253.196.132.cable.starman.ee [85.253.196.132]) by plaes.org (Postfix) with ESMTPSA id 09268412D3; Mon, 26 Nov 2018 15:28:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=plaes.org; s=mail; t=1543246091; bh=5hAkv9e0QxqeuW+SKyUEctAb4c3snr9BKtdxWIlUSeI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K38Om2jc5cRFbi5rpE3fb8iVaF3bOnxOeVcO0xjYElXT2klsIcZuhB+JajhyGL9vm bVddAFu10sWPPafBuauxNq0hCUtxzTfbEqSiqsmNKRRydlzNTUKUzCWdHur/vMJkwl 096vCMEwjEEPmhPRXbWPJ+7OIgst/kB6mustRDVPNy07k+8fOBYB2l5O8Fps/sp5XN sZTFqQ6z5IEB0uBm4ZJBRcBtCRPKE33xdvnl/v8Ot8p4dGRDCuxdxAJRAUHhpqMc9C xDTZpDARuDW7qR3q32Qht+n5QaTYsIlnL2lEbVTTw9/V7ODIVFV8yWa3IUsWLM1Na+ /fhte626D2D8A== From: Priit Laes To: Lee Jones , Rob Herring , Mark Rutland , Chen-Yu Tsai , Maxime Ripard , Sebastian Reichel , Hans de Goede , Liam Girdwood , Mark Brown , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org Subject: [PATCH 03/14] regulator: core: enable power when setting up constraints Date: Mon, 26 Nov 2018 17:27:44 +0200 Message-Id: <1e2f8f5a5eeebd40431675675569012cb8e17473.1543245984.git-series.plaes@plaes.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181126_072851_832332_1B6404E1 X-CRM114-Status: GOOD ( 13.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Olliver Schinagl , Priit Laes Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Olliver Schinagl When a regulator is marked as always on, it is enabled early on, when checking and setting up constraints. It makes the assumption that the bootloader properly initialized the regulator, and just in case enables the regulator anyway. Some constraints however currently get missed, such as the soft-start and ramp-delay. This causes the regulator to be enabled, without the soft-start and ramp-delay being applied, which in turn can cause high-currents or other start-up problems. By moving the always-enabled constraints later in the constraints check, we can at least ensure all constraints for the regulator are followed. Signed-off-by: Olliver Schinagl Signed-off-by: Priit Laes --- drivers/regulator/core.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 2c66b52..6e14610 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1158,17 +1158,6 @@ static int set_machine_constraints(struct regulator_dev *rdev, } } - /* If the constraints say the regulator should be on at this point - * and we have control then make sure it is enabled. - */ - if (rdev->constraints->always_on || rdev->constraints->boot_on) { - ret = _regulator_do_enable(rdev); - if (ret < 0 && ret != -EINVAL) { - rdev_err(rdev, "failed to enable\n"); - return ret; - } - } - if ((rdev->constraints->ramp_delay || rdev->constraints->ramp_disable) && ops->set_ramp_delay) { ret = ops->set_ramp_delay(rdev, rdev->constraints->ramp_delay); @@ -1214,6 +1203,17 @@ static int set_machine_constraints(struct regulator_dev *rdev, } } + /* If the constraints say the regulator should be on at this point + * and we have control then make sure it is enabled. + */ + if (rdev->constraints->always_on || rdev->constraints->boot_on) { + ret = _regulator_do_enable(rdev); + if (ret < 0 && ret != -EINVAL) { + rdev_err(rdev, "failed to enable\n"); + return ret; + } + } + print_constraints(rdev); return 0; }