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