devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
To: linux-arm-kernel@lists.infradead.org
Cc: robh+dt@kernel.org, devicetree@vger.kernel.org,
	k.kozlowski@samsung.com, lee.jones@linaro.org,
	broonie@kernel.org, linux-kernel@vger.kernel.org,
	Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Subject: [PATCH-v3 2/2] regulator: 88pm800: Add support for configuration of dual phase on BUCK1
Date: Mon, 24 Aug 2015 18:10:06 +0530	[thread overview]
Message-ID: <1440420006-31556-3-git-send-email-vaibhav.hiremath@linaro.org> (raw)
In-Reply-To: <1440420006-31556-1-git-send-email-vaibhav.hiremath@linaro.org>

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 updates the regulator driver to read the respective
DT property and enable dual-phase mode on BUCK1.
Note that if dual phase mode is enabled, then BUCK1B will not be
registered to the regulator framework and the current capacity of
BUCK1(A) would be set to 6A [3A of BUCK1A + 3A of BUCK1B].

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
---
 drivers/regulator/88pm800.c | 40 ++++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/88pm80x.h |  3 +++
 2 files changed, 43 insertions(+)

diff --git a/drivers/regulator/88pm800.c b/drivers/regulator/88pm800.c
index 365a154..7aca6d17 100644
--- a/drivers/regulator/88pm800.c
+++ b/drivers/regulator/88pm800.c
@@ -267,6 +267,37 @@ static struct pm800_regulator_info pm860_regulator_info[] = {
 	PM800_LDO(ldo20, LDO20, LDO_ENA1_3, 3, 10000, ldo_volt_table2),
 };
 
+static int pm800_regulator_init(struct platform_device *pdev,
+		struct pm800_regulator_info *info)
+{
+	struct pm800_regulators *pm800_data = platform_get_drvdata(pdev);
+	struct pm80x_chip *chip = pm800_data->chip;
+	int ret = 0;
+
+	/* Currently only supported on 88pm860 device */
+	if (chip->type != CHIP_PM860)
+		return 0;
+
+	if (of_property_read_bool(pdev->dev.of_node,
+				"marvell,88pm860-buck1-dualphase-en")) {
+		/* Update the constraint  to [3A (BUCK1A) + 3A (BUCK1B)] */
+		info[PM800_ID_BUCK1].max_ua = 6000000;
+		/* Remove BUCK1B from the list, as we are in dual phase mode */
+		memset(&info[PM800_ID_BUCK1B], 0, sizeof(*info));
+		/* Enable dual phase mode */
+		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 set dual-pase mode %d\n", ret);
+			return ret;
+		}
+	}
+
+	return ret;
+}
+
 static int pm800_regulator_probe(struct platform_device *pdev)
 {
 	struct pm80x_chip *chip = dev_get_drvdata(pdev->dev.parent);
@@ -311,11 +342,20 @@ static int pm800_regulator_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
+	ret = pm800_regulator_init(pdev, info);
+	if (ret) {
+		dev_err(&pdev->dev, "failed to init 88pm800 regulator device\n");
+		return ret;
+	}
+
 	config.dev = chip->dev;
 	config.regmap = pm800_data->map;
 	for (i = 0; i < PM800_ID_RG_MAX; i++) {
 		struct regulator_dev *regulator;
 
+		if (!info[i].desc.name)
+			continue;
+
 		if (pdata && pdata->num_regulators) {
 			init_data = pdata->regulators[i];
 			if (!init_data)
diff --git a/include/linux/mfd/88pm80x.h b/include/linux/mfd/88pm80x.h
index a92d173..122cfd2 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;
-- 
1.9.1

  parent reply	other threads:[~2015-08-24 12:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-24 12:40 [PATCH-v3 0/2] regulator: 88pm800: Add dual phase mode support on BUCK1 Vaibhav Hiremath
     [not found] ` <1440420006-31556-1-git-send-email-vaibhav.hiremath-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-08-24 12:40   ` [PATCH-v3 1/2] mfd: devicetree: bindings: 88pm800: Add DT property for dual phase enable Vaibhav Hiremath
     [not found]     ` <1440420006-31556-2-git-send-email-vaibhav.hiremath-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-08-24 13:02       ` Lee Jones
2015-08-24 14:54         ` Vaibhav Hiremath
     [not found]           ` <55DB3012.6010904-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-08-27 18:45             ` Mark Brown
2015-08-24 12:40 ` Vaibhav Hiremath [this message]
2015-08-25  4:48   ` [PATCH-v3 2/2] regulator: 88pm800: Add support for configuration of dual phase on BUCK1 Krzysztof Kozlowski
2015-08-25  6:23     ` Vaibhav Hiremath

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1440420006-31556-3-git-send-email-vaibhav.hiremath@linaro.org \
    --to=vaibhav.hiremath@linaro.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=k.kozlowski@samsung.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).