summaryrefslogtreecommitdiff
path: root/drivers/input/twl4030.c
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2015-07-20 15:17:08 +0200
committerTom Rini <trini@konsulko.com>2015-08-12 20:47:35 -0400
commit7d5ac91832918a5fda0277aacb8c62421efdeaa2 (patch)
tree928da385cc21facbdd7c3a655e5090675cc01472 /drivers/input/twl4030.c
parent6dc443e6d7bc2e7e9e2145ba5657dbf309c27c62 (diff)
downloadu-boot-imx-7d5ac91832918a5fda0277aacb8c62421efdeaa2.zip
u-boot-imx-7d5ac91832918a5fda0277aacb8c62421efdeaa2.tar.gz
u-boot-imx-7d5ac91832918a5fda0277aacb8c62421efdeaa2.tar.bz2
input: TWL4030 input support for power button, USB and charger
This adds support for detecting a few inputs exported by the TWL4030. Currently-supported inputs are the power button, USB and charger presence. Reviewed-by: Tom Rini <trini@konsulko.com> Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
Diffstat (limited to 'drivers/input/twl4030.c')
-rw-r--r--drivers/input/twl4030.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/drivers/input/twl4030.c b/drivers/input/twl4030.c
new file mode 100644
index 0000000..a5ded35
--- /dev/null
+++ b/drivers/input/twl4030.c
@@ -0,0 +1,49 @@
+/*
+ * TWL4030 input
+ *
+ * Copyright (C) 2015 Paul Kocialkowski <contact@paulk.fr>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <twl4030.h>
+
+int twl4030_input_power_button(void)
+{
+ u8 data;
+
+ twl4030_i2c_read_u8(TWL4030_CHIP_PM_MASTER,
+ TWL4030_PM_MASTER_STS_HW_CONDITIONS, &data);
+
+ if (data & TWL4030_PM_MASTER_STS_HW_CONDITIONS_PWON)
+ return 1;
+
+ return 0;
+}
+
+int twl4030_input_charger(void)
+{
+ u8 data;
+
+ twl4030_i2c_read_u8(TWL4030_CHIP_PM_MASTER,
+ TWL4030_PM_MASTER_STS_HW_CONDITIONS, &data);
+
+ if (data & TWL4030_PM_MASTER_STS_HW_CONDITIONS_CHG)
+ return 1;
+
+ return 0;
+}
+
+int twl4030_input_usb(void)
+{
+ u8 data;
+
+ twl4030_i2c_read_u8(TWL4030_CHIP_PM_MASTER,
+ TWL4030_PM_MASTER_STS_HW_CONDITIONS, &data);
+
+ if (data & TWL4030_PM_MASTER_STS_HW_CONDITIONS_USB ||
+ data & TWL4030_PM_MASTER_STS_HW_CONDITIONS_VBUS)
+ return 1;
+
+ return 0;
+}