Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp30864imu; Mon, 26 Nov 2018 07:34:30 -0800 (PST) X-Google-Smtp-Source: AJdET5clEM/kGyfqo2dPwD+oo0RDv8y8ajTbMzfSScBeQA8fSKCsG+OzTgAuLeKUbZO+nCjlsnSB X-Received: by 2002:aa7:87ce:: with SMTP id i14mr28324405pfo.20.1543246470847; Mon, 26 Nov 2018 07:34:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543246470; cv=none; d=google.com; s=arc-20160816; b=uBcgPGOeZ9JrASILtJOI2WGPfT71C27FWSFgjn+0i4Yt+basJpEQyP1tUrHnmivX3F T6e0fn3fjAxCFwV1e7e2LPhHddyUWLe3P7NPVHczUeA97nyj6zS6GU/jCSOPw/JANs8J I32BzyHaC/SFK2C0ccijhuOuFu2b62qoqe3pHi6Exrm5vHIwNXBmB2umOrJSUz5WxNfL CoOEV+FKv570FOmHqFaAeRTaTzEZk1Sb6jP2JJT9kL6Psdwjm6Wxr3VRhT4RRQbpHihJ gQcF0Lh8Hvsfyctp+NeMa0yh1IzX/Eziw1d2USuDwR96oSke5shLe1VuKrz7d7TBoopM 2N2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sJaxwR9dp0bDFiWvIN6jaRF5rF9NxoMUf4mKCwrwbIc=; b=sX1M8fVAGAPzM/O7MWOl8MGB+/nRVlR+Uu0rnWgEFhnk2xcM8V5xZvM0VIUJ08o9We bUql4r+UniIEtKquNUO6QtceuyqBQ6DWlFjJCim3dEOBGkv7RAWcxD61vlvOfdmq0h2v 0AIRg1FM8fNzN0o3Z27skJn0IbfFuv28Q9ZxwVtL0yRH4nI2OITCdQsra9/QLPK+QvRo kHwJDH90AKDxHMYss54yqTlUWaxFAgUC58RaYuelOveYvykiQzGWhhKxwfGd6GvR/9ix /66v59/1+17Y46cPrdQ/gTBHNUfTO4g+tP5Y7Bkp9/ElNAGWnUGGNAEGT6SanBsNs3Uk 6PPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@plaes.org header.s=mail header.b=K38Om2jc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a35si627490pla.226.2018.11.26.07.34.10; Mon, 26 Nov 2018 07:34:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@plaes.org header.s=mail header.b=K38Om2jc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726789AbeK0CWk (ORCPT + 99 others); Mon, 26 Nov 2018 21:22:40 -0500 Received: from plaes.org ([188.166.43.21]:49956 "EHLO plaes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726224AbeK0CWj (ORCPT ); Mon, 26 Nov 2018 21:22:39 -0500 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 Cc: Priit Laes , Olliver Schinagl 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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; } -- git-series 0.9.1