blob: 76bd3488fc644e9c8b636513a082708f20f64c07 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Paul Kocialkowskiaffa66f2016-02-27 19:19:13 +01002/*
3 * TWL6030 input
4 *
5 * Copyright (C) 2016 Paul Kocialkowski <contact@paulk.fr>
Paul Kocialkowskiaffa66f2016-02-27 19:19:13 +01006 */
7
8#include <twl6030.h>
9
10int twl6030_input_power_button(void)
11{
12 u8 value;
13
14 twl6030_i2c_read_u8(TWL6030_CHIP_PM, TWL6030_STS_HW_CONDITIONS, &value);
15
16 /* Power button is active low. */
17 if (value & TWL6030_STS_HW_CONDITIONS_PWRON)
18 return 0;
19
20 return 1;
21}
22
23int twl6030_input_charger(void)
24{
25 u8 value;
26
27 twl6030_i2c_read_u8(TWL6030_CHIP_CHARGER, TWL6030_CONTROLLER_STAT1,
28 &value);
29
30 if (value & TWL6030_CONTROLLER_STAT1_VAC_DET)
31 return 1;
32
33 return 0;
34}
35
36int twl6030_input_usb(void)
37{
38 u8 value;
39
40 twl6030_i2c_read_u8(TWL6030_CHIP_CHARGER, TWL6030_CONTROLLER_STAT1,
41 &value);
42
43 if (value & TWL6030_CONTROLLER_STAT1_VBUS_DET)
44 return 1;
45
46 return 0;
47}