Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
tcpci_priv.h File Reference

Helper functions to use by the TCPCI-compliant drivers. More...

#include <stdint.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/usb_c/usbc.h>

Go to the source code of this file.

Data Structures

struct  tcpci_reg_dump_map
 Structure used to bind the register address to name in registers dump. More...
 

Macros

#define TCPCI_STD_REGS_SIZE   38
 Size of the array containing the standard registers used by tcpci dump command.
 

Functions

int tcpci_read_reg8 (const struct i2c_dt_spec *bus, uint8_t reg, uint8_t *value)
 Function to read the 8-bit register of TCPCI device.
 
int tcpci_write_reg8 (const struct i2c_dt_spec *bus, uint8_t reg, uint8_t value)
 Function to write a value to the 8-bit register of TCPCI device.
 
int tcpci_update_reg8 (const struct i2c_dt_spec *bus, uint8_t reg, uint8_t mask, uint8_t value)
 Function to read and update part of the 8-bit register of TCPCI device The function is NOT performing this operation atomically.
 
int tcpci_read_reg16 (const struct i2c_dt_spec *bus, uint8_t reg, uint16_t *value)
 Function to read the 16-bit register of TCPCI device.
 
int tcpci_write_reg16 (const struct i2c_dt_spec *bus, uint8_t reg, uint16_t value)
 Function to write a value to the 16-bit register of TCPCI device.
 
enum tcpc_alert tcpci_alert_reg_to_enum (uint16_t reg)
 Function that converts the TCPCI alert register to the tcpc_alert enum The hard reset value takes priority, where the rest are returned in the bit order from least significant to most significant.
 
int tcpci_tcpm_get_cc (const struct i2c_dt_spec *bus, enum tc_cc_voltage_state *cc1, enum tc_cc_voltage_state *cc2)
 Function that reads the CC status registers and converts read values to enums representing voltages state and partner detection status.
 

Variables

const struct tcpci_reg_dump_map tcpci_std_regs [38]
 Array containing the standard TCPCI registers list.
 

Detailed Description

Helper functions to use by the TCPCI-compliant drivers.

This file contains generic TCPCI functions that may be used by the drivers to TCPCI-compliant devices that want to implement vendor-specific functionality without the need to reimplement the TCPCI generic functionality and register operations.

Macro Definition Documentation

◆ TCPCI_STD_REGS_SIZE

#define TCPCI_STD_REGS_SIZE   38

Size of the array containing the standard registers used by tcpci dump command.

Function Documentation

◆ tcpci_alert_reg_to_enum()

enum tcpc_alert tcpci_alert_reg_to_enum ( uint16_t reg)

Function that converts the TCPCI alert register to the tcpc_alert enum The hard reset value takes priority, where the rest are returned in the bit order from least significant to most significant.

Parameters
regValue of the TCPCI alert register. This parameter must have value other than zero.
Returns
enum tcpc_alert Value of one of the flags being set in the alert register

◆ tcpci_read_reg16()

int tcpci_read_reg16 ( const struct i2c_dt_spec * bus,
uint8_t reg,
uint16_t * value )

Function to read the 16-bit register of TCPCI device.

Parameters
busI2C bus
regAddress of TCPCI register
valuePointer to variable that will store the register value
Returns
int Status of I2C operation, 0 in case of success

◆ tcpci_read_reg8()

int tcpci_read_reg8 ( const struct i2c_dt_spec * bus,
uint8_t reg,
uint8_t * value )

Function to read the 8-bit register of TCPCI device.

Parameters
busI2C bus
regAddress of TCPCI register
valuePointer to variable that will store the register value
Returns
int Status of I2C operation, 0 in case of success

◆ tcpci_tcpm_get_cc()

int tcpci_tcpm_get_cc ( const struct i2c_dt_spec * bus,
enum tc_cc_voltage_state * cc1,
enum tc_cc_voltage_state * cc2 )

Function that reads the CC status registers and converts read values to enums representing voltages state and partner detection status.

Parameters
busI2C bus
cc1pointer to variable where detected CC1 voltage state will be stored
cc2pointer to variable where detected CC2 voltage state will be stored
Returns
-EINVAL if cc1 or cc2 pointer is NULL
int Status of I2C operation, 0 in case of success

◆ tcpci_update_reg8()

int tcpci_update_reg8 ( const struct i2c_dt_spec * bus,
uint8_t reg,
uint8_t mask,
uint8_t value )

Function to read and update part of the 8-bit register of TCPCI device The function is NOT performing this operation atomically.

Parameters
busI2C bus
regAddress of TCPCI register
maskBitmask specifying which bits of the device register will be modified
valueValue that will be written to the device register after being ANDed with mask
Returns
int Status of I2C operation, 0 in case of success

◆ tcpci_write_reg16()

int tcpci_write_reg16 ( const struct i2c_dt_spec * bus,
uint8_t reg,
uint16_t value )

Function to write a value to the 16-bit register of TCPCI device.

Parameters
busI2C bus
regAddress of TCPCI register
valueValue that will be written to the device register
Returns
int Status of I2C operation, 0 in case of success

◆ tcpci_write_reg8()

int tcpci_write_reg8 ( const struct i2c_dt_spec * bus,
uint8_t reg,
uint8_t value )

Function to write a value to the 8-bit register of TCPCI device.

Parameters
busI2C bus
regAddress of TCPCI register
valueValue that will be written to the device register
Returns
int Status of I2C operation, 0 in case of success

Variable Documentation

◆ tcpci_std_regs

const struct tcpci_reg_dump_map tcpci_std_regs[38]
extern

Array containing the standard TCPCI registers list.

If the TCPC driver contain any vendor-specific registers, it may override the TCPCI dump_std_reg function tp dump them and should also dump the standard registers using this array.