From patchwork Fri Aug 14 12:00:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 52433 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by patches.linaro.org (Postfix) with ESMTPS id 9272E2031F for ; Fri, 14 Aug 2015 12:01:11 +0000 (UTC) Received: by labth1 with SMTP id th1sf27287279lab.2 for ; Fri, 14 Aug 2015 05:01:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=Jxl6YsZWpcfzYEHe5rrDj5pFkrWg/LsfnbYS+GPNmEM=; b=cXiiaPtJ0ZZuxmy0QAatS+YQ3KiGjKbcHPICeQrwYwu13/4R1gY5XkVxu3YW09Hd95 b1JQSmCkUlQ8+bVCYwKQRElIUAoAW6cmvIUSELoHVu1pfp4C/N6gyUCsfTgUBy3ray+/ Nfo9upMkCQZfXj+POzvzOhYeuDphiu0Iuv0gZ87oRr/E33UoCkEuZQH994Y/xFvUA0u5 ZMtvY1kaaw6wZSUMWg2u2oOH2//Lx0mx07IPDy4RXZzxeep5663xDhJ16nxupZdI9HQj RcdEz2rOhCkrxaIg9/tBtXsmjHo7VtwgCR4kEbjNoOITpDHZD8EYS7odzcrS9sTtChZI aVTA== X-Gm-Message-State: ALoCoQmNKSwfY0iOJL71mt5W2KuDJ2eOfgozoZp5uj7X5Isx9VdckvBf9zzh98Yb4bwuureGYwV0 X-Received: by 10.152.120.138 with SMTP id lc10mr7147064lab.3.1439553670505; Fri, 14 Aug 2015 05:01:10 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.133 with SMTP id v5ls371413lae.63.gmail; Fri, 14 Aug 2015 05:01:10 -0700 (PDT) X-Received: by 10.152.5.105 with SMTP id r9mr33728708lar.53.1439553670325; Fri, 14 Aug 2015 05:01:10 -0700 (PDT) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id lc8si5806135lac.151.2015.08.14.05.01.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Aug 2015 05:01:10 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by lalv9 with SMTP id v9so42524574lal.0 for ; Fri, 14 Aug 2015 05:01:10 -0700 (PDT) X-Received: by 10.152.26.163 with SMTP id m3mr43391536lag.86.1439553670114; Fri, 14 Aug 2015 05:01:10 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.7.198 with SMTP id l6csp1564083lba; Fri, 14 Aug 2015 05:01:08 -0700 (PDT) X-Received: by 10.68.190.38 with SMTP id gn6mr87432309pbc.125.1439553667976; Fri, 14 Aug 2015 05:01:07 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qv6si8677987pbb.35.2015.08.14.05.01.07; Fri, 14 Aug 2015 05:01:07 -0700 (PDT) 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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754855AbbHNMBE (ORCPT + 28 others); Fri, 14 Aug 2015 08:01:04 -0400 Received: from mail-pa0-f41.google.com ([209.85.220.41]:35129 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751412AbbHNMBD (ORCPT ); Fri, 14 Aug 2015 08:01:03 -0400 Received: by pacgr6 with SMTP id gr6so58916914pac.2 for ; Fri, 14 Aug 2015 05:01:02 -0700 (PDT) X-Received: by 10.68.202.36 with SMTP id kf4mr87922466pbc.49.1439553662359; Fri, 14 Aug 2015 05:01:02 -0700 (PDT) Received: from localhost ([122.171.186.190]) by smtp.gmail.com with ESMTPSA id k8sm5642228pdn.96.2015.08.14.05.01.01 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 14 Aug 2015 05:01:01 -0700 (PDT) From: Viresh Kumar To: broonie@kernel.org Cc: linaro-kernel@lists.linaro.org, sboyd@codeaurora.org, nm@ti.com, Viresh Kumar , Liam Girdwood , linux-kernel@vger.kernel.org (open list:VOLTAGE AND CURRENT REGULATOR FRAMEWORK) Subject: [PATCH] regulator: core: Define regulator_set_voltage_triplet() Date: Fri, 14 Aug 2015 17:30:55 +0530 Message-Id: <28971ff9b110d18970fcc6291531f617cda18230.1439553400.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.4.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The OPP (Operating performance points) v2 bindings allows regulator voltage to be supplied as a triplet of voltages. Add regulator_set_voltage_triplet() API in regulator core to support that. This first tries to set a voltage between the target voltage and the upper limit, then fall back on the full range. The idea behind this is to set regulator's voltage as close to the target voltage, as possible. Based on regulator_set_voltage_tol(). Signed-off-by: Viresh Kumar --- Hi Mark, This is required for OPP-V2 bindings that we introduced recently, where the voltage can be given as a triplet of . I don't have any dependency on this until the time I update regulator support in OPP core and so sending it separately. You can take it through your tree. Ofcourse, only if it looks fine :) include/linux/regulator/consumer.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h index f8a689ed62a5..621e89315c55 100644 --- a/include/linux/regulator/consumer.h +++ b/include/linux/regulator/consumer.h @@ -552,6 +552,16 @@ static inline int regulator_count_voltages(struct regulator *regulator) } #endif +static inline int regulator_set_voltage_triplet(struct regulator *regulator, + int target_uV, int min_uV, + int max_uV) +{ + if (!regulator_set_voltage(regulator, target_uV, max_uV)) + return 0; + + return regulator_set_voltage(regulator, min_uV, max_uV); +} + static inline int regulator_set_voltage_tol(struct regulator *regulator, int new_uV, int tol_uV) {