1 /* SPDX-License-Identifier: BSD-3-Clause or GPL-2.0-only */ 2 3 #ifndef __TPS65090_H_ 4 #define __TPS65090_H_ 5 6 /* I2C device address for TPS65090 PMU */ 7 #define TPS65090_I2C_ADDR 0x48 8 9 /* TPS65090 FET control registers */ 10 enum fet_id { 11 FET1_CTRL = 0x0f, 12 FET2_CTRL, 13 FET3_CTRL, 14 FET4_CTRL, 15 FET5_CTRL, 16 FET6_CTRL, 17 FET7_CTRL, 18 }; 19 20 enum { 21 /* Status register fields */ 22 TPS65090_ST1_OTC = 1 << 0, 23 TPS65090_ST1_OCC = 1 << 1, 24 TPS65090_ST1_STATE_SHIFT = 4, 25 TPS65090_ST1_STATE_MASK = 0xf << TPS65090_ST1_STATE_SHIFT, 26 }; 27 28 /* FET errors */ 29 enum { 30 FET_ERR_COMMS = -1, /* FET comms error */ 31 FET_ERR_NOT_READY = -2, /* FET is not yet ready - retry */ 32 }; 33 34 /** 35 * Enable FET 36 * 37 * @param bus I2C bus number the TPS65090 is on 38 * @param fet_id FET ID, value between 1 and 7 39 * return 0 on success, non-0 on failure 40 */ 41 int tps65090_fet_enable(unsigned int bus, enum fet_id fet_id); 42 43 /** 44 * Disable FET 45 * 46 * @param bus I2C bus number the TPS65090 is on 47 * @param fet_id FET ID, value between 1 and 7 48 * @return 0 on success, non-0 on failure 49 */ 50 int tps65090_fet_disable(unsigned int bus, enum fet_id fet_id); 51 52 /** 53 * Is FET enabled? 54 * 55 * @param bus I2C bus number the TPS65090 is on 56 * @param fet_id FET ID, value between 1 and 7 57 * @return 1 enabled, 0 disabled, negative value on failure 58 */ 59 int tps65090_fet_is_enabled(unsigned int bus, enum fet_id fet_id); 60 61 /** 62 * Enable / disable the battery charger 63 * 64 * @param bus I2C bus number the TPS65090 is on 65 * @param enable 0 to disable charging, non-zero to enable 66 */ 67 int tps65090_set_charge_enable(unsigned int bus, int enable); 68 69 /** 70 * Check whether we have enabled battery charging 71 * 72 * @param bus I2C bus number the TPS65090 is on 73 * @return 1 if enabled, 0 if disabled 74 */ 75 int tps65090_is_charging(unsigned int bus); 76 77 /** 78 * Return the value of the status register 79 * 80 * @param bus I2C bus number the TPS65090 is on 81 * @return status register value, or -1 on error 82 */ 83 int tps65090_get_status(unsigned int bus); 84 85 #endif /* __TPS65090_H_ */ 86