From patchwork Thu Jul 16 18:16:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Hiremath X-Patchwork-Id: 51199 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E59BD22A8A for ; Thu, 16 Jul 2015 18:20:21 +0000 (UTC) Received: by lagx9 with SMTP id x9sf20565566lag.2 for ; Thu, 16 Jul 2015 11:20:20 -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:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=93sC4PVKRRoArtzUMrGEbS1GBIdRzyV/z/lBbt0BuF4=; b=hXW1GlBqsprtLL92Tk5wC+S7825bDKZrFO8pNJCMENepd0JoMndLC+zpmRx653zq/4 E7sWAaiBB/HqDa9vZAwcc+xo/Tz9jWZKGLiT282SqHu4or9Met/AadROUkujnwan6fmx dKG3inNOohsh9g9te7nM21DFbpNbJ80eVPs+OQ5C5xnRDblASMV7BJVpsLBFbiOzOGND WnfNEuBouWilmpGhwtnXNq1QQTxtFO1DsSc5iLtSs59dHnnsguBe9GCq3GtO4/A4L9LO TdIta8RB2BREVf2rOV7Ln/MJdS8z9KZ2Rc+AeEftD3hUCgQhny6TvaU5Sz/sLb3T9xrw DSsw== X-Gm-Message-State: ALoCoQmcXgyA5sGlhsEOve6jJyf0rjTudPRmuseKLaKaQTrHbfykTnPCCM6fJc/DY/OQtZEEHNe2 X-Received: by 10.152.237.36 with SMTP id uz4mr5449184lac.1.1437070820542; Thu, 16 Jul 2015 11:20:20 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.37.105 with SMTP id x9ls419097laj.11.gmail; Thu, 16 Jul 2015 11:20:20 -0700 (PDT) X-Received: by 10.112.93.100 with SMTP id ct4mr10695024lbb.66.1437070820240; Thu, 16 Jul 2015 11:20:20 -0700 (PDT) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com. [209.85.217.181]) by mx.google.com with ESMTPS id xr5si7629841lbb.76.2015.07.16.11.20.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Jul 2015 11:20:20 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) client-ip=209.85.217.181; Received: by lbbzr7 with SMTP id zr7so48676812lbb.1 for ; Thu, 16 Jul 2015 11:20:20 -0700 (PDT) X-Received: by 10.152.42.177 with SMTP id p17mr10575129lal.29.1437070820071; Thu, 16 Jul 2015 11:20:20 -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.108.230 with SMTP id hn6csp422223lbb; Thu, 16 Jul 2015 11:20:18 -0700 (PDT) X-Received: by 10.68.103.164 with SMTP id fx4mr21198767pbb.125.1437070815466; Thu, 16 Jul 2015 11:20:15 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v2si902426pbz.201.2015.07.16.11.20.14; Thu, 16 Jul 2015 11:20:15 -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 S1756071AbbGPST6 (ORCPT + 28 others); Thu, 16 Jul 2015 14:19:58 -0400 Received: from mail-pd0-f181.google.com ([209.85.192.181]:34781 "EHLO mail-pd0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756021AbbGPSTy (ORCPT ); Thu, 16 Jul 2015 14:19:54 -0400 Received: by pdbbh15 with SMTP id bh15so2750147pdb.1 for ; Thu, 16 Jul 2015 11:19:53 -0700 (PDT) X-Received: by 10.66.65.229 with SMTP id a5mr21647469pat.11.1437070793767; Thu, 16 Jul 2015 11:19:53 -0700 (PDT) Received: from localhost.localdomain ([202.62.77.106]) by smtp.gmail.com with ESMTPSA id k5sm8679182pda.34.2015.07.16.11.19.50 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Jul 2015 11:19:52 -0700 (PDT) From: Vaibhav Hiremath To: linux-arm-kernel@lists.infradead.org Cc: broonie@kernel.org, lgirdwood@gmail.com, sameo@linux.intel.com, lee.jones@linaro.org, linux-kernel@vger.kernel.org, Vaibhav Hiremath Subject: [PATCH 5/5] regulator: 88pm800: Add support for configuration of dual phase on BUCK1 Date: Thu, 16 Jul 2015 23:46:58 +0530 Message-Id: <1437070618-21330-6-git-send-email-vaibhav.hiremath@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1437070618-21330-1-git-send-email-vaibhav.hiremath@linaro.org> References: <1437070618-21330-1-git-send-email-vaibhav.hiremath@linaro.org> 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: vaibhav.hiremath@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.217.181 as permitted sender) smtp.mail=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: , 88PM860 device supports dual phase mode on BUCK1 output. In normal usecase, BUCK1A and BUCK1B operates independently with 3A capacity. And they both can work as a dual phase providing 6A capacity. This patch adds support for regulator_ops.set_current_limit() callback fn, in turn enabling support for current min and max supply constraint on BUCK1 (and optionally on BUCK1B). Based on that driver enables dual-phase mode. Note that, if max current supply constraint is > 3A on BUCK1(A) then driver enables the dual-phase mode, irrespective of BUCK1B constraint. Signed-off-by: Vaibhav Hiremath --- drivers/regulator/88pm800.c | 38 ++++++++++++++++++++++++++++++++++++++ include/linux/mfd/88pm80x.h | 3 +++ 2 files changed, 41 insertions(+) diff --git a/drivers/regulator/88pm800.c b/drivers/regulator/88pm800.c index e846e4c..1da18fa 100644 --- a/drivers/regulator/88pm800.c +++ b/drivers/regulator/88pm800.c @@ -185,6 +185,43 @@ static int pm800_get_current_limit(struct regulator_dev *rdev) return info->max_ua; } +/* + * 88pm860 device supports dual-phase mode on BUCK1, where BUCK1A and BUCK1B can + * be used together to supply 6A current. Note that, independently, they can + * source 3A each. + * + * So, this function checks for max_uA for BUCK1 (only), and if it is more than + * 3A, then enable dual-phase mode. + */ +static int pm800_set_current_limit(struct regulator_dev *rdev, + int min_uA, int max_uA) +{ + struct pm800_regulators *pm800_data = + dev_get_drvdata(rdev_get_dev(rdev)->parent); + struct pm80x_chip *chip = pm800_data->chip; + int ret; + + /* Currently only supported on 88pm860 device */ + if (chip->type != CHIP_PM860) + return 0; + + if (rdev->desc->id == PM800_ID_BUCK1) { + /* If max_uA is greater that 3A, enable dual-phase on BUCK1 */ + if (max_uA > 3000000) { + ret = regmap_update_bits(chip->subchip->regmap_power, + PM860_BUCK1_MISC, + BUCK1_DUAL_PHASE_SEL, + BUCK1_DUAL_PHASE_SEL); + if (ret) { + dev_err(chip->dev, "failed to access registers\n"); + return ret; + } + } + } + + return 0; +} + static struct regulator_ops pm800_volt_range_ops = { .list_voltage = regulator_list_voltage_linear_range, .map_voltage = regulator_map_voltage_linear_range, @@ -194,6 +231,7 @@ static struct regulator_ops pm800_volt_range_ops = { .disable = regulator_disable_regmap, .is_enabled = regulator_is_enabled_regmap, .get_current_limit = pm800_get_current_limit, + .set_current_limit = pm800_set_current_limit, }; static struct regulator_ops pm800_volt_table_ops = { diff --git a/include/linux/mfd/88pm80x.h b/include/linux/mfd/88pm80x.h index a92d173..05d9bad 100644 --- a/include/linux/mfd/88pm80x.h +++ b/include/linux/mfd/88pm80x.h @@ -295,6 +295,9 @@ enum { #define PM860_BUCK4_MISC2 (0x82) #define PM860_BUCK4_FULL_DRV BIT(2) +#define PM860_BUCK1_MISC (0x8E) +#define BUCK1_DUAL_PHASE_SEL BIT(2) + struct pm80x_rtc_pdata { int vrtc; int rtc_wakeup;