From patchwork Thu Mar 31 01:57:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 64737 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp2910886lbc; Wed, 30 Mar 2016 18:58:49 -0700 (PDT) X-Received: by 10.66.66.167 with SMTP id g7mr11664641pat.111.1459389529130; Wed, 30 Mar 2016 18:58:49 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y19si10310810pfa.62.2016.03.30.18.58.48; Wed, 30 Mar 2016 18:58:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751786AbcCaB6s (ORCPT + 8 others); Wed, 30 Mar 2016 21:58:48 -0400 Received: from mail-pf0-f180.google.com ([209.85.192.180]:35454 "EHLO mail-pf0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754813AbcCaB5x (ORCPT ); Wed, 30 Mar 2016 21:57:53 -0400 Received: by mail-pf0-f180.google.com with SMTP id n5so56928629pfn.2 for ; Wed, 30 Mar 2016 18:57:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=//M3aW6jiapL6wIcDcYhIoAs0rmdSiwEg5oVlvIldXQ=; b=g7dQ9Kx4tCtvfZ4BR9mjTylD/EIgKT+shNonH4X3FkelfBiNLQT/TNXq4IdUDTU5UH +cqMrjk7AhO4Xsuzu5y4eNgYgpgdnAOOzXW7igNYSeq7dMGcC4rs0a52Dmg6/52fjaW8 J2m6rgZr+E8Kutmds3TIYd4gD4xUZg9C0Ym1Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=//M3aW6jiapL6wIcDcYhIoAs0rmdSiwEg5oVlvIldXQ=; b=E14stnkB4TEqUFMfULCdwnt4fb2EzrRZMcm8PNAXaoQlLxkGVBG9EXqy/r2Ono48QB OlR9c3c5SwmsA2IJSUYGHZ/L3ebXe+Bz51Pbw6s4cpuHJoWTVHAw1NFMPJmwXEYOzCZQ trXR0pgcE+AY+MAT8//+1qOZ9Cc0Y8WyrA0q9OqE+I6LsSGz5Ir38Hikya7cA/Ba6FIB 0ykgEfv9yuoyQw3Z5yAzFWf/mhkpwSn6q11bQOvHUxPqG775YLE1Pn7Uc+9YGP3xvAAV V9+0iCyl15dr1UqfW1cN1G94MfXLVteMUNyIgHbrI1HzmmxnrcZNGRrNWFjSBgHeAWFP Pksg== X-Gm-Message-State: AD7BkJIt+XC0mLFH25TtfmxhujcxndTPZtEtxu6Ll/7edjMTGPeVuC0deTWVEAiKMTVfCc5N X-Received: by 10.98.16.198 with SMTP id 67mr18068481pfq.21.1459389472789; Wed, 30 Mar 2016 18:57:52 -0700 (PDT) Received: from localhost.localdomain (pat_11.qualcomm.com. [192.35.156.11]) by smtp.gmail.com with ESMTPSA id 17sm8745395pfp.96.2016.03.30.18.57.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 30 Mar 2016 18:57:52 -0700 (PDT) From: Stephen Boyd To: Mark Brown Cc: linux-arm@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Georgi Djakov , David Collins Subject: [PATCH v2 1/2] regulator: qcom_spmi: Add slewing delays for all SMPS types Date: Wed, 30 Mar 2016 18:57:49 -0700 Message-Id: <1459389470-29365-2-git-send-email-stephen.boyd@linaro.org> X-Mailer: git-send-email 2.8.0.rc4 In-Reply-To: <1459389470-29365-1-git-send-email-stephen.boyd@linaro.org> References: <1459389470-29365-1-git-send-email-stephen.boyd@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Only the FT SMPS type regulators have slewing supported in the driver, but all types of SMPS regulators need the same support. The only difference is that some SMPS regulators don't have a step size and the step delay is typically 20, not 8. Luckily, the step size reads as 0 for the non-FT types, so we can always read that, but we need to detect which type of regulator we're using to figure out what step delay to use. Make these minor adjustments to the slew rate calculations and add support for the delay function to the appropriate regulator ops. Reported-by: Georgi Djakov Cc: David Collins Signed-off-by: Stephen Boyd --- drivers/regulator/qcom_spmi-regulator.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) -- 2.8.0.rc4 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/regulator/qcom_spmi-regulator.c b/drivers/regulator/qcom_spmi-regulator.c index 88a5dc88badc..d9cb3a2c99c0 100644 --- a/drivers/regulator/qcom_spmi-regulator.c +++ b/drivers/regulator/qcom_spmi-regulator.c @@ -246,6 +246,7 @@ enum spmi_common_control_register_index { /* Minimum voltage stepper delay for each step. */ #define SPMI_FTSMPS_STEP_DELAY 8 +#define SPMI_DEFAULT_STEP_DELAY 20 /* * The ratio SPMI_FTSMPS_STEP_MARGIN_NUM/SPMI_FTSMPS_STEP_MARGIN_DEN is used to @@ -1008,6 +1009,7 @@ static struct regulator_ops spmi_smps_ops = { .disable = spmi_regulator_common_disable, .is_enabled = spmi_regulator_common_is_enabled, .set_voltage = spmi_regulator_common_set_voltage, + .set_voltage_time_sel = spmi_regulator_set_voltage_time_sel, .get_voltage = spmi_regulator_common_get_voltage, .list_voltage = spmi_regulator_common_list_voltage, .set_mode = spmi_regulator_common_set_mode, @@ -1081,6 +1083,7 @@ static struct regulator_ops spmi_ult_lo_smps_ops = { .disable = spmi_regulator_common_disable, .is_enabled = spmi_regulator_common_is_enabled, .set_voltage = spmi_regulator_ult_lo_smps_set_voltage, + .set_voltage_time_sel = spmi_regulator_set_voltage_time_sel, .get_voltage = spmi_regulator_ult_lo_smps_get_voltage, .list_voltage = spmi_regulator_common_list_voltage, .set_mode = spmi_regulator_common_set_mode, @@ -1094,6 +1097,7 @@ static struct regulator_ops spmi_ult_ho_smps_ops = { .disable = spmi_regulator_common_disable, .is_enabled = spmi_regulator_common_is_enabled, .set_voltage = spmi_regulator_single_range_set_voltage, + .set_voltage_time_sel = spmi_regulator_set_voltage_time_sel, .get_voltage = spmi_regulator_single_range_get_voltage, .list_voltage = spmi_regulator_common_list_voltage, .set_mode = spmi_regulator_common_set_mode, @@ -1245,11 +1249,11 @@ found: return 0; } -static int spmi_regulator_ftsmps_init_slew_rate(struct spmi_regulator *vreg) +static int spmi_regulator_init_slew_rate(struct spmi_regulator *vreg) { int ret; u8 reg = 0; - int step, delay, slew_rate; + int step, delay, slew_rate, step_delay; const struct spmi_voltage_range *range; ret = spmi_vreg_read(vreg, SPMI_COMMON_REG_STEP_CTRL, ®, 1); @@ -1262,6 +1266,15 @@ static int spmi_regulator_ftsmps_init_slew_rate(struct spmi_regulator *vreg) if (!range) return -EINVAL; + switch (vreg->logical_type) { + case SPMI_REGULATOR_LOGICAL_TYPE_FTSMPS: + step_delay = SPMI_FTSMPS_STEP_DELAY; + break; + default: + step_delay = SPMI_DEFAULT_STEP_DELAY; + break; + } + step = reg & SPMI_FTSMPS_STEP_CTRL_STEP_MASK; step >>= SPMI_FTSMPS_STEP_CTRL_STEP_SHIFT; @@ -1270,7 +1283,7 @@ static int spmi_regulator_ftsmps_init_slew_rate(struct spmi_regulator *vreg) /* slew_rate has units of uV/us */ slew_rate = SPMI_FTSMPS_CLOCK_RATE * range->step_uV * (1 << step); - slew_rate /= 1000 * (SPMI_FTSMPS_STEP_DELAY << delay); + slew_rate /= 1000 * (step_delay << delay); slew_rate *= SPMI_FTSMPS_STEP_MARGIN_NUM; slew_rate /= SPMI_FTSMPS_STEP_MARGIN_DEN; @@ -1411,10 +1424,16 @@ static int spmi_regulator_of_parse(struct device_node *node, return ret; } - if (vreg->logical_type == SPMI_REGULATOR_LOGICAL_TYPE_FTSMPS) { - ret = spmi_regulator_ftsmps_init_slew_rate(vreg); + switch (vreg->logical_type) { + case SPMI_REGULATOR_LOGICAL_TYPE_FTSMPS: + case SPMI_REGULATOR_LOGICAL_TYPE_ULT_LO_SMPS: + case SPMI_REGULATOR_LOGICAL_TYPE_ULT_HO_SMPS: + case SPMI_REGULATOR_LOGICAL_TYPE_SMPS: + ret = spmi_regulator_init_slew_rate(vreg); if (ret) return ret; + default: + break; } if (vreg->logical_type != SPMI_REGULATOR_LOGICAL_TYPE_VS)