]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
input: TWL4030 input support for power button, USB and charger
authorPaul Kocialkowski <contact@paulk.fr>
Mon, 20 Jul 2015 13:17:08 +0000 (15:17 +0200)
committerTom Rini <trini@konsulko.com>
Thu, 13 Aug 2015 00:47:35 +0000 (20:47 -0400)
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>
drivers/input/Makefile
drivers/input/twl4030.c [new file with mode: 0644]
include/twl4030.h

index a8e9be2f7fd28787c3dd76fb9ca0f68da9f2c898..24fec9b83ef1e6ea6d8a773775c31b7d7949c098 100644 (file)
@@ -7,6 +7,7 @@
 
 obj-$(CONFIG_I8042_KBD) += i8042.o
 obj-$(CONFIG_TEGRA_KEYBOARD) += tegra-kbc.o
+obj-$(CONFIG_TWL4030_INPUT) += twl4030.o
 obj-$(CONFIG_CROS_EC_KEYB) += cros_ec_keyb.o
 ifdef CONFIG_PS2KBD
 obj-y += keyboard.o pc_keyb.o
diff --git a/drivers/input/twl4030.c b/drivers/input/twl4030.c
new file mode 100644 (file)
index 0000000..a5ded35
--- /dev/null
@@ -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;
+}
index 2d0ca18bbfb6d2b31561eda350109e9cd83b2fbf..a4d5fbdb617b52458d3e2ef23a817e40f9b0758c 100644 (file)
 #define TWL4030_PM_MASTER_SW_EVENTS_DEVSLP             (1 << 1)
 #define TWL4030_PM_MASTER_SW_EVENTS_DEVOFF             (1 << 0)
 
+/* HW conditions */
+#define TWL4030_PM_MASTER_STS_HW_CONDITIONS_PWON       (1 << 0)
+#define TWL4030_PM_MASTER_STS_HW_CONDITIONS_CHG                (1 << 1)
+#define TWL4030_PM_MASTER_STS_HW_CONDITIONS_USB                (1 << 2)
+#define TWL4030_PM_MASTER_STS_HW_CONDITIONS_VBUS       (1 << 7)
+
 /* Power transition */
 #define TWL4030_PM_MASTER_CFG_TRANSITION_STARTON_PWON  (1 << 0)
 #define TWL4030_PM_MASTER_CFG_TRANSITION_STARTON_CHG   (1 << 1)
@@ -669,6 +675,14 @@ void twl4030_power_init(void);
 /* For initializing mmc power */
 void twl4030_power_mmc_init(int dev_index);
 
+/*
+ * Input
+ */
+
+int twl4030_input_power_button(void);
+int twl4030_input_charger(void);
+int twl4030_input_usb(void);
+
 /*
  * LED
  */