mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kishon Vijay Abraham I <kishon@ti.com>
To: <lgirdwood@gmail.com>, <broonie@kernel.org>,
	<ldewangan@nvidia.com>, <sameo@linux.intel.com>,
	<linux-kernel@vger.kernel.org>, <gg@slimlogic.co.uk>,
	<ian@slimlogic.co.uk>
Cc: <kishon@ti.com>, <balbi@ti.com>
Subject: [RFC PATCH] regulator: palmas: enable all modes for SMPS10
Date: Thu, 30 May 2013 16:26:33 +0530	[thread overview]
Message-ID: <1369911393-25747-1-git-send-email-kishon@ti.com> (raw)

SMPS10 supports different modes such as BOOST mode, BYPASS mode and
SWITCH. Inorder to configure SMPS10 in these modes,
added palmas_set_mode_smps10() and palmas_get_mode_smps10() for the
consumers of SMPS10 to configure it accordingly.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
Only compile tested. Just sent a patch to get some comments
/ideas on how to handle such one off regulators.
to handle
 drivers/regulator/palmas-regulator.c |   46 ++++++++++++++++++++++++++++++++++
 include/linux/mfd/palmas.h           |    1 +
 2 files changed, 47 insertions(+)

diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c
index 87d4f13..d8d37f2 100644
--- a/drivers/regulator/palmas-regulator.c
+++ b/drivers/regulator/palmas-regulator.c
@@ -355,6 +355,50 @@ static unsigned int palmas_get_mode_smps(struct regulator_dev *dev)
 	return 0;
 }
 
+static int palmas_set_mode_smps10(struct regulator_dev *dev, unsigned int mode)
+{
+	struct palmas_pmic *pmic = rdev_get_drvdata(dev);
+	int id = rdev_get_id(dev);
+	unsigned int reg;
+
+	palmas_smps_read(pmic->palmas, palmas_regs_info[id].ctrl_addr, &reg);
+	reg &= ~PALMAS_SMPS10_CTRL_MODE_ACTIVE_MODE_MASK;
+
+	if (mode == REGULATOR_MODE_NORMAL)
+		reg |= SMPS10_BOOST_EN;
+
+	if (mode == REGULATOR_MODE_FAST)
+		reg |= SMPS10_SWITCH_EN;
+
+	if (mode == REGULATOR_MODE_IDLE)
+		reg |= SMPS10_BYPASS_EN;
+
+	palmas_smps_write(pmic->palmas, palmas_regs_info[id].ctrl_addr, reg);
+	return 0;
+}
+
+static unsigned int palmas_get_mode_smps10(struct regulator_dev *dev)
+{
+	struct palmas_pmic *pmic = rdev_get_drvdata(dev);
+	int id = rdev_get_id(dev);
+	unsigned int reg;
+	int ret = 0;
+
+	reg = pmic->current_reg_mode[id] &
+		PALMAS_SMPS10_CTRL_MODE_ACTIVE_MODE_MASK;
+
+	if (reg == SMPS10_BOOST_EN)
+		ret |= REGULATOR_MODE_NORMAL;
+
+	if (reg == SMPS10_SWITCH_EN)
+		ret |= REGULATOR_MODE_FAST;
+
+	if (reg == SMPS10_BYPASS_EN)
+		ret |= REGULATOR_MODE_IDLE;
+
+	return ret;
+}
+
 static int palmas_list_voltage_smps(struct regulator_dev *dev,
 					unsigned selector)
 {
@@ -483,6 +527,8 @@ static struct regulator_ops palmas_ops_smps10 = {
 	.is_enabled		= regulator_is_enabled_regmap,
 	.enable			= regulator_enable_regmap,
 	.disable		= regulator_disable_regmap,
+	.set_mode		= palmas_set_mode_smps10,
+	.get_mode		= palmas_get_mode_smps10,
 	.get_voltage_sel	= regulator_get_voltage_sel_regmap,
 	.set_voltage_sel	= regulator_set_voltage_sel_regmap,
 	.list_voltage		= regulator_list_voltage_linear,
diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h
index 8f21daf..4ad2b65 100644
--- a/include/linux/mfd/palmas.h
+++ b/include/linux/mfd/palmas.h
@@ -846,6 +846,7 @@ enum usb_irq_events {
 #define PALMAS_SMPS10_CTRL_MODE_SLEEP_MASK			0xf0
 #define PALMAS_SMPS10_CTRL_MODE_SLEEP_SHIFT			4
 #define PALMAS_SMPS10_CTRL_MODE_ACTIVE_MASK			0x0f
+#define PALMAS_SMPS10_CTRL_MODE_ACTIVE_MODE_MASK		0x07
 #define PALMAS_SMPS10_CTRL_MODE_ACTIVE_SHIFT			0
 
 /* Bit definitions for SMPS10_STATUS */
-- 
1.7.10.4


             reply	other threads:[~2013-05-30 10:57 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-30 10:56 Kishon Vijay Abraham I [this message]
2013-05-30 11:32 ` Mark Brown
2013-05-30 12:54   ` Kishon Vijay Abraham I
2013-06-01 18:42     ` Mark Brown
2013-05-30 13:00   ` Laxman Dewangan
2013-06-01 18:45     ` Mark Brown
2013-06-01 19:03       ` Laxman Dewangan
2013-06-01 21:05         ` Mark Brown
2013-06-04  9:08           ` Kishon Vijay Abraham I
2013-06-04  9:38             ` Mark Brown
2013-06-04  9:43               ` Kishon Vijay Abraham I
2013-06-04 10:05                 ` Mark Brown
2013-06-10  9:50                   ` Kishon Vijay Abraham I
2013-06-10 10:03                     ` Mark Brown
2013-06-10 11:03                       ` Kishon Vijay Abraham I
2013-06-10 12:49                         ` Mark Brown
2013-06-12  8:42                           ` Laxman Dewangan
2013-06-12 14:14                             ` Mark Brown
2013-06-12 14:31                               ` gg
2013-06-12 14:51                                 ` Mark Brown
2013-06-12 15:23                                   ` gg
2013-06-14 12:34                                     ` Laxman Dewangan
2013-06-18  8:27                                       ` Kishon Vijay Abraham I

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=1369911393-25747-1-git-send-email-kishon@ti.com \
    --to=kishon@ti.com \
    --cc=balbi@ti.com \
    --cc=broonie@kernel.org \
    --cc=gg@slimlogic.co.uk \
    --cc=ian@slimlogic.co.uk \
    --cc=ldewangan@nvidia.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sameo@linux.intel.com \
    /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

all inboxes | Powered by JetHome®