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: 6810411 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7B863C05AC for ; Thu, 16 Jul 2015 18:23:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9546420674 for ; Thu, 16 Jul 2015 18:23:24 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B666020673 for ; Thu, 16 Jul 2015 18:23:23 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZFnmr-0001MN-0g; Thu, 16 Jul 2015 18:21:37 +0000 Received: from mail-pa0-f52.google.com ([209.85.220.52]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZFnlW-0007W2-Hf for linux-arm-kernel@lists.infradead.org; Thu, 16 Jul 2015 18:20:15 +0000 Received: by pachj5 with SMTP id hj5so46752756pac.3 for ; Thu, 16 Jul 2015 11:19:53 -0700 (PDT) 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=MleHMFM6bLfDveTw7CFOGSOO+2dnP3F/jOBsj/Jpi8w=; b=nFU2UbxgwvYxmAMif6UXdT6mj/P791M/xEMGhghn/1/5EIsLk9bWoRT8of2xAho0jR bvEoOOyWdVeCVwEsAVFKUDYn4gfA1EZvRoxBMBOjE/+2KZ/6td/LBlQW7gZr2V9Elz7S EJRkRUz+8ipfNJAMIoKyM1kIOxEQaebzk8FszoqTb2LVCOj7PAmMQbtk+7wkJgdH2ANL t8azdy06Vg6mB6aWyTkQH18kFkLSYkWHdicTfIq5wtRpxFY3SpWjt3+myjNwjhKwHoNu cxpRoL6zhVy9UfnJM+luaU/RDkcQ0418f/33MrP2y+zuHKI15C9krMzvFieGTO1HuaEa 0yeA== X-Gm-Message-State: ALoCoQm2Dmwh9WwaXK0RyUW5mc47Iefo1YxNirw0jaqu2tNl52SEl4RsMU6MjYYqmz4PNTFbOUCA 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150716_112014_654212_B5D3C9AD X-CRM114-Status: GOOD ( 17.39 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sameo@linux.intel.com, linux-kernel@vger.kernel.org, lgirdwood@gmail.com, Vaibhav Hiremath , broonie@kernel.org, lee.jones@linaro.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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;