mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 2/4] regulator: anatop: add is_enabled interface
@ 2013-12-16 21:09 Anson Huang
  0 siblings, 0 replies; only message in thread
From: Anson Huang @ 2013-12-16 21:09 UTC (permalink / raw)
  To: lgirdwood, broonie; +Cc: linux-kernel

Add is_enabled interface for anatop regulator in case
some drivers need to know regulator's status.

Signed-off-by: Anson Huang <b20788@freescale.com>
---
 drivers/regulator/anatop-regulator.c |   15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c
index c734d09..770d836 100644
--- a/drivers/regulator/anatop-regulator.c
+++ b/drivers/regulator/anatop-regulator.c
@@ -97,10 +97,25 @@ static int anatop_regmap_get_voltage_sel(struct regulator_dev *reg)
 	return regulator_get_voltage_sel_regmap(reg);
 }
 
+static int anatop_regmap_is_enabled(struct regulator_dev *reg)
+{
+	struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
+	u32 val;
+
+	if (!anatop_reg->control_reg)
+		return -ENOTSUPP;
+
+	regmap_read(anatop_reg->anatop, anatop_reg->control_reg, &val);
+
+	return (val >> anatop_reg->vol_bit_shift) &
+		((1 << anatop_reg->vol_bit_width) - 1) ? 1 : 0;
+}
+
 static struct regulator_ops anatop_rops = {
 	.set_voltage_sel = anatop_regmap_set_voltage_sel,
 	.set_voltage_time_sel = anatop_regmap_set_voltage_time_sel,
 	.get_voltage_sel = anatop_regmap_get_voltage_sel,
+	.is_enabled = anatop_regmap_is_enabled,
 	.list_voltage = regulator_list_voltage_linear,
 	.map_voltage = regulator_map_voltage_linear,
 };
-- 
1.7.9.5



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-12-16  9:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-16 21:09 [PATCH 2/4] regulator: anatop: add is_enabled interface Anson Huang

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®