[PATCH V3 1/2] MFD: TPS65217: Add new mfd device for TPS65217

2012-01-04 Thread AnilKumar Ch
The TPS65217 chip is a power management IC for Portable Navigation Systems
and Tablet Computing devices. It contains the following components:

- Regulators
- White LED
- USB battery charger

This patch adds support for tps65217 mfd device. At this time only
the regulator functionality is made available.

Signed-off-by: AnilKumar Ch 
---
 drivers/mfd/Kconfig  |   15 +++
 drivers/mfd/Makefile |1 +
 drivers/mfd/tps65217.c   |  242 +
 include/linux/mfd/tps65217.h |  275 ++
 4 files changed, 533 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/tps65217.c
 create mode 100644 include/linux/mfd/tps65217.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index f1391c2..d2c55e8 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -142,6 +142,21 @@ config TPS6507X
  This driver can also be built as a module.  If so, the module
  will be called tps6507x.
 
+config MFD_TPS65217
+   tristate "TPS65217 Power Management / White LED chips"
+   depends on I2C
+   select MFD_CORE
+   select REGMAP_I2C
+   help
+ If you say yes here you get support for the TPS65217 series of
+ Power Management / White LED chips.
+ These include voltage regulators, lithium ion/polymer battery
+ charger, wled and other features that are often used in portable
+ devices.
+
+ This driver can also be built as a module.  If so, the module
+ will be called tps65217.
+
 config MFD_TPS6586X
bool "TPS6586x Power Management chips"
depends on I2C=y && GPIOLIB && GENERIC_HARDIRQS
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index b2292eb..7a6d111 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -36,6 +36,7 @@ obj-$(CONFIG_MFD_WM8994)  += wm8994-core.o wm8994-irq.o
 obj-$(CONFIG_TPS6105X) += tps6105x.o
 obj-$(CONFIG_TPS65010) += tps65010.o
 obj-$(CONFIG_TPS6507X) += tps6507x.o
+obj-$(CONFIG_MFD_TPS65217) += tps65217.o
 obj-$(CONFIG_MFD_TPS65910) += tps65910.o tps65910-irq.o
 tps65912-objs   := tps65912-core.o tps65912-irq.o
 obj-$(CONFIG_MFD_TPS65912) += tps65912.o
diff --git a/drivers/mfd/tps65217.c b/drivers/mfd/tps65217.c
new file mode 100644
index 000..f7d854e
--- /dev/null
+++ b/drivers/mfd/tps65217.c
@@ -0,0 +1,242 @@
+/*
+ * tps65217.c
+ *
+ * TPS65217 chip family multi-function driver
+ *
+ * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+/**
+ * tps65217_reg_read: Read a single tps65217 register.
+ *
+ * @tps: Device to read from.
+ * @reg: Register to read.
+ * @val: Contians the value
+ */
+int tps65217_reg_read(struct tps65217 *tps, unsigned int reg,
+   unsigned int *val)
+{
+   return regmap_read(tps->regmap, reg, val);
+}
+EXPORT_SYMBOL_GPL(tps65217_reg_read);
+
+/**
+ * tps65217_reg_write: Write a single tps65217 register.
+ *
+ * @tps65217: Device to write to.
+ * @reg: Register to write to.
+ * @val: Value to write.
+ * @level: Password protected level
+ */
+int tps65217_reg_write(struct tps65217 *tps, unsigned int reg,
+   unsigned int val, unsigned int level)
+{
+   int ret;
+   unsigned int xor_reg_val;
+
+   switch (level) {
+   case TPS65217_PROTECT_NONE:
+   return regmap_write(tps->regmap, reg, val);
+   case TPS65217_PROTECT_L1:
+   xor_reg_val = reg ^ TPS65217_PASSWORD_REGS_UNLOCK;
+   ret = regmap_write(tps->regmap, TPS65217_REG_PASSWORD,
+   xor_reg_val);
+   if (ret < 0)
+   return ret;
+
+   return regmap_write(tps->regmap, reg, val);
+   case TPS65217_PROTECT_L2:
+   xor_reg_val = reg ^ TPS65217_PASSWORD_REGS_UNLOCK;
+   ret = regmap_write(tps->regmap, TPS65217_REG_PASSWORD,
+   xor_reg_val);
+   if (ret < 0)
+   return ret;
+   ret = regmap_write(tps->regmap, reg, val);
+   if (ret < 0)
+   return ret;
+   ret = regmap_write(tps->regmap, TPS65217_REG_PASSWORD,
+   xor_reg_val);
+   if

Re: [PATCH V3 1/2] MFD: TPS65217: Add new mfd device for TPS65217

2012-01-08 Thread Mark Brown
On Wed, Jan 04, 2012 at 03:22:15PM +0530, AnilKumar Ch wrote:
> The TPS65217 chip is a power management IC for Portable Navigation Systems
> and Tablet Computing devices. It contains the following components:

Reviwed-by: Mark Brown 
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html