summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2012-08-07 14:37:34 +0530
committerLokesh Pathak <lpathak@nvidia.com>2012-08-08 08:58:26 -0700
commit1e1a831d0238d3bf06b9e9066912d2b150b6ddfb (patch)
tree288f86d05cfa5ade2b8efd24c670a5d39a811442 /include
parent7f9749a0050aa4bbe770f1a061f5ae8c8545dfa8 (diff)
mfd: add support for MAXIM77665
Maxim 77665 is Companion PMIC for Smartphones and Tablets. This support Flash, Fuel Gauge, Haptic, MUIC and battery charging. This patch add the core driver for interface for accessing resgister of the device. Change-Id: I7d5dff8c222147b2ca1cd21a652f593cd7294601 Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Reviewed-on: http://git-master/r/121587 Reviewed-by: Automatic_Commit_Validation_User
Diffstat (limited to 'include')
-rw-r--r--include/linux/mfd/max77665.h92
1 files changed, 92 insertions, 0 deletions
diff --git a/include/linux/mfd/max77665.h b/include/linux/mfd/max77665.h
new file mode 100644
index 000000000000..380a1a4aac0d
--- /dev/null
+++ b/include/linux/mfd/max77665.h
@@ -0,0 +1,92 @@
+/*
+ * Core driver interface for MAXIM77665
+ *
+ * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.
+
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __LINUX_MFD_MAX77665_H
+#define __LINUX_MFD_MAX77665_H
+
+#include <linux/irq.h>
+#include <linux/regmap.h>
+
+/* MAX77665 Interrups */
+enum {
+ MAX77665_IRQ_CHARGER,
+ MAX77665_IRQ_TOP_SYS,
+ MAX77665_IRQ_FLASH,
+ MAX77665_IRQ_MUIC,
+};
+
+enum {
+ MAX77665_I2C_SLAVE_PMIC,
+ MAX77665_I2C_SLAVE_MUIC,
+ MAX77665_I2C_SLAVE_HAPTIC,
+ MAX77665_I2C_SLAVE_MAX,
+};
+
+struct max77665 {
+ struct device *dev;
+ struct i2c_client *client[MAX77665_I2C_SLAVE_MAX];
+ struct regmap *regmap[MAX77665_I2C_SLAVE_MAX];
+ struct irq_chip irq_chip;
+ struct mutex irq_lock;
+ int irq_base;
+};
+
+struct max77665_platform_data {
+ int irq_base;
+};
+
+static inline int max77665_write(struct device *dev, int slv_id,
+ int reg, uint8_t val)
+{
+ struct max77665 *maxim = dev_get_drvdata(dev);
+
+ return regmap_write(maxim->regmap[slv_id], reg, val);
+}
+
+static inline int max77665_read(struct device *dev, int slv_id,
+ int reg, uint8_t *val)
+{
+ struct max77665 *maxim = dev_get_drvdata(dev);
+ unsigned int temp_val;
+ int ret;
+
+ ret = regmap_read(maxim->regmap[slv_id], reg, &temp_val);
+ if (!ret)
+ *val = temp_val;
+ return ret;
+}
+
+static inline int max77665_set_bits(struct device *dev, int slv_id,
+ int reg, uint8_t bit_num)
+{
+ struct max77665 *maxim = dev_get_drvdata(dev);
+
+ return regmap_update_bits(maxim->regmap[slv_id],
+ reg, BIT(bit_num), ~0u);
+}
+
+static inline int max77665_clr_bits(struct device *dev, int slv_id,
+ int reg, uint8_t bit_num)
+{
+ struct max77665 *maxim = dev_get_drvdata(dev);
+
+ return regmap_update_bits(maxim->regmap[slv_id],
+ reg, BIT(bit_num), 0u);
+}
+
+#endif /*__LINUX_MFD_MAX77665_H */