Paul Kocialkowski | f266dae | 2015-07-20 15:17:08 +0200 | [diff] [blame^] | 1 | /* |
| 2 | * TWL4030 input |
| 3 | * |
| 4 | * Copyright (C) 2015 Paul Kocialkowski <contact@paulk.fr> |
| 5 | * |
| 6 | * SPDX-License-Identifier: GPL-2.0+ |
| 7 | */ |
| 8 | |
| 9 | #include <twl4030.h> |
| 10 | |
| 11 | int twl4030_input_power_button(void) |
| 12 | { |
| 13 | u8 data; |
| 14 | |
| 15 | twl4030_i2c_read_u8(TWL4030_CHIP_PM_MASTER, |
| 16 | TWL4030_PM_MASTER_STS_HW_CONDITIONS, &data); |
| 17 | |
| 18 | if (data & TWL4030_PM_MASTER_STS_HW_CONDITIONS_PWON) |
| 19 | return 1; |
| 20 | |
| 21 | return 0; |
| 22 | } |
| 23 | |
| 24 | int twl4030_input_charger(void) |
| 25 | { |
| 26 | u8 data; |
| 27 | |
| 28 | twl4030_i2c_read_u8(TWL4030_CHIP_PM_MASTER, |
| 29 | TWL4030_PM_MASTER_STS_HW_CONDITIONS, &data); |
| 30 | |
| 31 | if (data & TWL4030_PM_MASTER_STS_HW_CONDITIONS_CHG) |
| 32 | return 1; |
| 33 | |
| 34 | return 0; |
| 35 | } |
| 36 | |
| 37 | int twl4030_input_usb(void) |
| 38 | { |
| 39 | u8 data; |
| 40 | |
| 41 | twl4030_i2c_read_u8(TWL4030_CHIP_PM_MASTER, |
| 42 | TWL4030_PM_MASTER_STS_HW_CONDITIONS, &data); |
| 43 | |
| 44 | if (data & TWL4030_PM_MASTER_STS_HW_CONDITIONS_USB || |
| 45 | data & TWL4030_PM_MASTER_STS_HW_CONDITIONS_VBUS) |
| 46 | return 1; |
| 47 | |
| 48 | return 0; |
| 49 | } |