coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
tps65090.c File Reference
#include <delay.h>
#include <types.h>
#include <console/console.h>
#include <device/i2c_simple.h>
#include "tps65090.h"
Include dependency graph for tps65090.c:

Go to the source code of this file.

Enumerations

enum  { REG_CG_CTRL0 = 4 , REG_CG_STATUS1 = 0xa }
 
enum  {
  CG_CTRL0_ENC_MASK = 0x01 , MAX_FET_NUM = 7 , MAX_CTRL_READ_TRIES = 5 , FET_CTRL_TOFET = 1 << 7 ,
  FET_CTRL_PGFET = 1 << 4 , FET_CTRL_WAIT = 3 << 2 , FET_CTRL_ADENFET = 1 << 1 , FET_CTRL_ENFET = 1 << 0
}
 

Functions

static int tps65090_i2c_write (unsigned int bus, unsigned int reg_addr, unsigned char value)
 
static int tps65090_i2c_read (unsigned int bus, unsigned int reg_addr, unsigned char *value)
 
static int tps65090_fet_set (unsigned int bus, enum fet_id fet_id, int set)
 Set the power state for a FET. More...
 
int tps65090_fet_enable (unsigned int bus, enum fet_id fet_id)
 Enable FET. More...
 
int tps65090_fet_disable (unsigned int bus, enum fet_id fet_id)
 Disable FET. More...
 
int tps65090_fet_is_enabled (unsigned int bus, enum fet_id fet_id)
 Is FET enabled? More...
 
int tps65090_is_charging (unsigned int bus)
 Check whether we have enabled battery charging. More...
 
int tps65090_set_charge_enable (unsigned int bus, int enable)
 Enable / disable the battery charger. More...
 
int tps65090_get_status (unsigned int bus)
 Return the value of the status register. More...
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
CG_CTRL0_ENC_MASK 
MAX_FET_NUM 
MAX_CTRL_READ_TRIES 
FET_CTRL_TOFET 
FET_CTRL_PGFET 
FET_CTRL_WAIT 
FET_CTRL_ADENFET 
FET_CTRL_ENFET 

Definition at line 15 of file tps65090.c.

◆ anonymous enum

anonymous enum
Enumerator
REG_CG_CTRL0 
REG_CG_STATUS1 

Definition at line 10 of file tps65090.c.

Function Documentation

◆ tps65090_fet_disable()

int tps65090_fet_disable ( unsigned int  bus,
enum fet_id  fet_id 
)

Disable FET.

Parameters
busI2C bus number the TPS65090 is on
fet_idFET ID, value between 1 and 7
Returns
0 on success, non-0 on failure

Definition at line 129 of file tps65090.c.

References tps65090_fet_set().

Here is the call graph for this function:

◆ tps65090_fet_enable()

int tps65090_fet_enable ( unsigned int  bus,
enum fet_id  fet_id 
)

Enable FET.

Parameters
busI2C bus number the TPS65090 is on
fet_idFET ID, value between 1 and 7 return 0 on success, non-0 on failure

Definition at line 95 of file tps65090.c.

References BIOS_DEBUG, FET_ERR_NOT_READY, printk, tps65090_fet_set(), and udelay().

Referenced by backlight_vdd(), lcd_vdd(), and sdmmc_vdd().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tps65090_fet_is_enabled()

int tps65090_fet_is_enabled ( unsigned int  bus,
enum fet_id  fet_id 
)

Is FET enabled?

Parameters
busI2C bus number the TPS65090 is on
fet_idFET ID, value between 1 and 7
Returns
1 enabled, 0 disabled, negative value on failure

Definition at line 134 of file tps65090.c.

References BIOS_DEBUG, FET_CTRL_ENFET, printk, and tps65090_i2c_read().

Here is the call graph for this function:

◆ tps65090_fet_set()

static int tps65090_fet_set ( unsigned int  bus,
enum fet_id  fet_id,
int  set 
)
static

Set the power state for a FET.

Parameters
bus
fet_idFet number to set (1..MAX_FET_NUM)
set1 to power on FET, 0 to power off
Returns
FET_ERR_COMMS if we got a comms error, FET_ERR_NOT_READY if the FET failed to change state. If all is ok, returns 0.

Definition at line 63 of file tps65090.c.

References BIOS_DEBUG, FET_CTRL_ADENFET, FET_CTRL_ENFET, FET_CTRL_PGFET, FET_CTRL_TOFET, FET_CTRL_WAIT, FET_ERR_COMMS, FET_ERR_NOT_READY, MAX_CTRL_READ_TRIES, printk, retry, tps65090_i2c_read(), tps65090_i2c_write(), udelay(), and value.

Referenced by tps65090_fet_disable(), and tps65090_fet_enable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tps65090_get_status()

int tps65090_get_status ( unsigned int  bus)

Return the value of the status register.

Parameters
busI2C bus number the TPS65090 is on
Returns
status register value, or -1 on error

Definition at line 179 of file tps65090.c.

References REG_CG_STATUS1, tps65090_i2c_read(), and val.

Here is the call graph for this function:

◆ tps65090_i2c_read()

static int tps65090_i2c_read ( unsigned int  bus,
unsigned int  reg_addr,
unsigned char *  value 
)
static

Definition at line 40 of file tps65090.c.

References BIOS_DEBUG, i2c_readb(), printk, TPS65090_I2C_ADDR, and value.

Referenced by tps65090_fet_is_enabled(), tps65090_fet_set(), tps65090_get_status(), tps65090_is_charging(), and tps65090_set_charge_enable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tps65090_i2c_write()

static int tps65090_i2c_write ( unsigned int  bus,
unsigned int  reg_addr,
unsigned char  value 
)
static

Definition at line 29 of file tps65090.c.

References BIOS_DEBUG, i2c_writeb(), printk, TPS65090_I2C_ADDR, and value.

Referenced by tps65090_fet_set(), and tps65090_set_charge_enable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tps65090_is_charging()

int tps65090_is_charging ( unsigned int  bus)

Check whether we have enabled battery charging.

Parameters
busI2C bus number the TPS65090 is on
Returns
1 if enabled, 0 if disabled

Definition at line 148 of file tps65090.c.

References CG_CTRL0_ENC_MASK, REG_CG_CTRL0, tps65090_i2c_read(), and val.

Here is the call graph for this function:

◆ tps65090_set_charge_enable()

int tps65090_set_charge_enable ( unsigned int  bus,
int  enable 
)

Enable / disable the battery charger.

Parameters
busI2C bus number the TPS65090 is on
enable0 to disable charging, non-zero to enable

Definition at line 159 of file tps65090.c.

References BIOS_DEBUG, CG_CTRL0_ENC_MASK, printk, REG_CG_CTRL0, tps65090_i2c_read(), tps65090_i2c_write(), and val.

Here is the call graph for this function: