coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
tps65090.h
Go to the documentation of this file.
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,
18 };
19 
20 enum {
21  /* Status register fields */
22  TPS65090_ST1_OTC = 1 << 0,
23  TPS65090_ST1_OCC = 1 << 1,
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_ */
Definition: device.h:76
fet_id
Definition: tps65090.h:10
@ FET2_CTRL
Definition: tps65090.h:12
@ FET5_CTRL
Definition: tps65090.h:15
@ FET4_CTRL
Definition: tps65090.h:14
@ FET3_CTRL
Definition: tps65090.h:13
@ FET1_CTRL
Definition: tps65090.h:11
@ FET6_CTRL
Definition: tps65090.h:16
@ FET7_CTRL
Definition: tps65090.h:17
@ TPS65090_ST1_STATE_MASK
Definition: tps65090.h:25
@ TPS65090_ST1_OCC
Definition: tps65090.h:23
@ TPS65090_ST1_OTC
Definition: tps65090.h:22
@ TPS65090_ST1_STATE_SHIFT
Definition: tps65090.h:24
int tps65090_set_charge_enable(unsigned int bus, int enable)
Enable / disable the battery charger.
Definition: tps65090.c:159
int tps65090_fet_disable(unsigned int bus, enum fet_id fet_id)
Disable FET.
Definition: tps65090.c:129
int tps65090_fet_enable(unsigned int bus, enum fet_id fet_id)
Enable FET.
Definition: tps65090.c:95
int tps65090_is_charging(unsigned int bus)
Check whether we have enabled battery charging.
Definition: tps65090.c:148
@ FET_ERR_NOT_READY
Definition: tps65090.h:31
@ FET_ERR_COMMS
Definition: tps65090.h:30
int tps65090_get_status(unsigned int bus)
Return the value of the status register.
Definition: tps65090.c:179
int tps65090_fet_is_enabled(unsigned int bus, enum fet_id fet_id)
Is FET enabled?
Definition: tps65090.c:134