summaryrefslogtreecommitdiffstats
path: root/include/mfd
diff options
context:
space:
mode:
authorAlexander Aring <a.aring@phytec.de>2011-12-21 08:50:28 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2011-12-21 12:46:01 +0100
commit5c115f335ec06fa1fd8a28740790a622e500a304 (patch)
treea565f58cd6047911b3d136f6a0e978603a0ea984 /include/mfd
parent8007b25bdfa353cbce71c849a41f474604648ebf (diff)
downloadbarebox-5c115f335ec06fa1fd8a28740790a622e500a304.tar.gz
barebox-5c115f335ec06fa1fd8a28740790a622e500a304.tar.xz
twl-core: abstract twl4030 and add twlcore driver
Add a general twl device driver twlcore to call i2c send/write functions. Abstract twl4030 to call twlcore functions. Fixed some code-styling issues pointed out by checkpatch. Signed-off-by: Alexander Aring <a.aring@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/mfd')
-rw-r--r--include/mfd/twl-core.h30
-rw-r--r--include/mfd/twl4030.h35
2 files changed, 53 insertions, 12 deletions
diff --git a/include/mfd/twl-core.h b/include/mfd/twl-core.h
new file mode 100644
index 0000000000..2ab6169433
--- /dev/null
+++ b/include/mfd/twl-core.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2011 Alexander Aring <a.aring@phytec.de>
+ *
+ * Based on:
+ * Copyright (C) 2010 Michael Grzeschik <mgr@pengutronix.de>
+ * Copyright (C) 2010 Sascha Hauer <sha@pengutronix.de>
+ *
+ * This file is released under the GPLv2
+ *
+ */
+
+#ifndef __I2C_TWLCORE_H__
+#define __I2C_TWLCORE_H__
+
+#include <common.h>
+#include <i2c/i2c.h>
+#include <linux/err.h>
+
+struct twlcore {
+ struct cdev cdev;
+ struct i2c_client *client;
+};
+
+extern struct file_operations twl_fops;
+
+extern int twlcore_reg_read(struct twlcore *twlcore, u16 reg, u8 *val);
+extern int twlcore_reg_write(struct twlcore *twlcore, u16 reg, u8 val);
+extern int twlcore_set_bits(struct twlcore *twlcore, u16 reg, u8 mask, u8 val);
+
+#endif /* __I2C_TWLCORE_H__ */
diff --git a/include/mfd/twl4030.h b/include/mfd/twl4030.h
index 3fef4d9ad6..bc54ea66a1 100644
--- a/include/mfd/twl4030.h
+++ b/include/mfd/twl4030.h
@@ -6,12 +6,10 @@
*
*/
-#ifndef __I2C_TWL4030_H
-#define __I2C_TWL4030_H
+#ifndef __I2C_TWL4030_H__
+#define __I2C_TWL4030_H__
-#include <common.h>
-#include <i2c/i2c.h>
-#include <linux/err.h>
+#include <mfd/twl-core.h>
/* LED */
#define TWL4030_LED_LEDEN_LEDAON (1 << 0)
@@ -76,7 +74,7 @@ enum twl4030_reg {
TWL4030_PM_RECEIVER_VAUX2_VSEL_18 = 0x05,
TWL4030_PM_RECEIVER_VAUX3_VSEL_28 = 0x03,
TWL4030_PM_RECEIVER_VPLL2_VSEL_18 = 0x05,
- TWL4030_PM_RECEIVER_VDAC_VSEL_18 = 0x03,
+ TWL4030_PM_RECEIVER_VDAC_VSEL_18 = 0x03,
TWL4030_PM_RECEIVER_VMMC1_VSEL_30 = 0x02,
/*
@@ -448,14 +446,27 @@ enum twl4030_reg {
};
struct twl4030 {
- struct cdev cdev;
- struct i2c_client *client;
+ struct twlcore core;
};
extern struct twl4030 *twl4030_get(void);
-extern int twl4030_reg_read(struct twl4030 *twl4030, u16 reg, u8 *val);
-extern int twl4030_reg_write(struct twl4030 *twl4030, u16 reg, u8 val);
-extern int twl4030_set_bits(struct twl4030 *twl4030, enum twl4030_reg reg, u8 mask, u8 val);
+static inline int twl4030_reg_read(struct twl4030 *twl4030,
+ enum twl4030_reg reg, u8 *val)
+{
+ return twlcore_reg_read(&(twl4030->core), reg, val);
+}
-#endif /* __I2C_TWL4030_H */
+static inline int twl4030_reg_write(struct twl4030 *twl4030,
+ enum twl4030_reg reg, u8 val)
+{
+ return twlcore_reg_write(&(twl4030->core), reg, val);
+}
+
+static inline int twl4030_set_bits(struct twl4030 *twl4030,
+ enum twl4030_reg reg, u8 mask, u8 val)
+{
+ return twlcore_set_bits(&(twl4030->core), reg, mask, val);
+}
+
+#endif /* __I2C_TWL4030_H__ */