Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
tcpci_priv.h
Go to the documentation of this file.
1/*
2 * Copyright 2024 Google LLC
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
15
16#ifndef ZEPHYR_INCLUDE_DRIVERS_USB_C_TCPCI_PRIV_H_
17#define ZEPHYR_INCLUDE_DRIVERS_USB_C_TCPCI_PRIV_H_
18
19#include <stdint.h>
20#include <zephyr/drivers/i2c.h>
21#include <zephyr/usb_c/usbc.h>
22
34
36#define TCPCI_STD_REGS_SIZE 38
44
46#define PD_INT_REV10 0x10
48#define PD_INT_REV20 0x20
49
58int tcpci_read_reg8(const struct i2c_dt_spec *bus, uint8_t reg, uint8_t *value);
59
68int tcpci_write_reg8(const struct i2c_dt_spec *bus, uint8_t reg, uint8_t value);
69
80int tcpci_update_reg8(const struct i2c_dt_spec *bus, uint8_t reg, uint8_t mask, uint8_t value);
81
90int tcpci_read_reg16(const struct i2c_dt_spec *bus, uint8_t reg, uint16_t *value);
91
100int tcpci_write_reg16(const struct i2c_dt_spec *bus, uint8_t reg, uint16_t value);
101
111
122int tcpci_tcpm_get_cc(const struct i2c_dt_spec *bus, enum tc_cc_voltage_state *cc1,
123 enum tc_cc_voltage_state *cc2);
124
132int tcpci_tcpm_get_chip_info(const struct i2c_dt_spec *bus, struct tcpc_chip_info *chip_info);
133
141
149int tcpci_tcpm_set_bist_test_mode(const struct i2c_dt_spec *bus, bool enable);
150
160int tcpci_tcpm_transmit_data(const struct i2c_dt_spec *bus, struct pd_msg *msg,
161 const uint8_t retries);
162
170int tcpci_tcpm_select_rp_value(const struct i2c_dt_spec *bus, enum tc_rp_value rp);
171
179int tcpci_tcpm_get_rp_value(const struct i2c_dt_spec *bus, enum tc_rp_value *rp);
180
188int tcpci_tcpm_set_cc(const struct i2c_dt_spec *bus, enum tc_cc_pull pull);
189
198int tcpci_tcpm_set_drp_toggle(const struct i2c_dt_spec *bus, uint8_t pd_int_rev, bool enable);
199
209int tcpci_tcpm_set_roles(const struct i2c_dt_spec *bus, enum pd_rev_type pd_rev,
210 enum tc_power_role power_role, enum tc_data_role data_role);
211
219int tcpci_tcpm_set_rx_type(const struct i2c_dt_spec *bus, uint8_t type);
220
228int tcpci_tcpm_set_cc_polarity(const struct i2c_dt_spec *bus, enum tc_cc_polarity polarity);
229
237int tcpci_tcpm_set_vconn(const struct i2c_dt_spec *bus, bool enable);
238
248 uint16_t *status);
249
259 uint16_t mask);
260
270 uint16_t mask);
271
281int tcpci_tcpm_get_snk_ctrl(const struct i2c_dt_spec *bus, bool *sinking);
282
292int tcpci_tcpm_get_src_ctrl(const struct i2c_dt_spec *bus, bool *sourcing);
293
301int tcpci_tcpm_set_snk_ctrl(const struct i2c_dt_spec *bus, bool enable);
302
310int tcpci_tcpm_set_src_ctrl(const struct i2c_dt_spec *bus, bool enable);
311
319int tcpci_tcpm_set_debug_accessory(const struct i2c_dt_spec *bus, bool enable);
320
328int tcpci_tcpm_set_low_power_mode(const struct i2c_dt_spec *bus, bool enable);
329
330#endif /* ZEPHYR_INCLUDE_DRIVERS_USB_C_TCPCI_PRIV_H_ */
Main header file for I2C (Inter-Integrated Circuit) driver API.
pd_rev_type
Protocol revision.
Definition usbc_pd.h:871
tcpc_alert
TCPC Alert bits.
Definition usbc_tcpc.h:42
tcpc_status_reg
TCPC Status register.
Definition usbc_tcpc.h:86
tc_cc_pull
CC pull resistors.
Definition usbc_tc.h:369
tc_rp_value
Pull-Up resistor values.
Definition usbc_tc.h:355
tc_cc_voltage_state
CC Voltage status.
Definition usbc_tc.h:325
tc_data_role
Power Delivery Data Role.
Definition usbc_tc.h:423
tc_power_role
Power Delivery Power Role.
Definition usbc_tc.h:413
tc_cc_polarity
Polarity of the CC lines.
Definition usbc_tc.h:435
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Complete I2C DT information.
Definition i2c.h:121
Power Delivery message.
Definition usbc_pd.h:1052
TCPC Chip Information.
Definition usbc_tcpc.h:106
Structure used to bind the register address to name in registers dump.
Definition tcpci_priv.h:26
const char * name
Human readable name of register.
Definition tcpci_priv.h:30
uint8_t size
Size in bytes of the register.
Definition tcpci_priv.h:32
uint8_t addr
Address of I2C device register.
Definition tcpci_priv.h:28
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_tcpm_dump_std_reg(const struct i2c_dt_spec *bus)
Function to dump the standard TCPCI registers.
int tcpci_tcpm_set_rx_type(const struct i2c_dt_spec *bus, uint8_t type)
Function to set the RX type.
#define TCPCI_STD_REGS_SIZE
Size of the array containing the standard registers used by tcpci dump command.
Definition tcpci_priv.h:36
int tcpci_tcpm_set_roles(const struct i2c_dt_spec *bus, enum pd_rev_type pd_rev, enum tc_power_role power_role, enum tc_data_role data_role)
Function to set the power and data role of the PD message header.
int tcpci_tcpm_get_rp_value(const struct i2c_dt_spec *bus, enum tc_rp_value *rp)
Function to get the currently selected Rp value.
int tcpci_tcpm_set_debug_accessory(const struct i2c_dt_spec *bus, bool enable)
Function to enable or disable the debug accessory mode.
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...
int tcpci_tcpm_get_snk_ctrl(const struct i2c_dt_spec *bus, bool *sinking)
Queries the current sinking state of the TCPCI.
int tcpci_tcpm_set_drp_toggle(const struct i2c_dt_spec *bus, uint8_t pd_int_rev, bool enable)
Function to enable or disable TCPC auto dual role toggle.
int tcpci_tcpm_get_status_register(const struct i2c_dt_spec *bus, enum tcpc_status_reg reg, uint16_t *status)
Function to get the status of a specific TCPCI status register.
int tcpci_tcpm_get_chip_info(const struct i2c_dt_spec *bus, struct tcpc_chip_info *chip_info)
Function to retrieve information about the TCPCI chip.
int tcpci_tcpm_set_cc(const struct i2c_dt_spec *bus, enum tc_cc_pull pull)
Function to set the CC pull resistor and set the role as either Source or Sink.
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.
int tcpci_tcpm_set_cc_polarity(const struct i2c_dt_spec *bus, enum tc_cc_polarity polarity)
Function to set the polarity of the CC lines.
int tcpci_tcpm_transmit_data(const struct i2c_dt_spec *bus, struct pd_msg *msg, const uint8_t retries)
Function to transmit a PD (Power Delivery) message.
int tcpci_tcpm_get_src_ctrl(const struct i2c_dt_spec *bus, bool *sourcing)
Queries the current sourcing state of the TCPCI.
int tcpci_tcpm_set_low_power_mode(const struct i2c_dt_spec *bus, bool enable)
Function to enable or disable the low power mode.
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_tcpm_set_src_ctrl(const struct i2c_dt_spec *bus, bool enable)
Function to enable or disable sourcing power over VBUS.
int tcpci_tcpm_mask_status_register(const struct i2c_dt_spec *bus, enum tcpc_status_reg reg, uint16_t mask)
Function to set the mask of a TCPCI status register.
const struct tcpci_reg_dump_map tcpci_std_regs[38]
Array containing the standard TCPCI registers list.
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 pri...
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_tcpm_set_vconn(const struct i2c_dt_spec *bus, bool enable)
Function to enable or disable VCONN.
int tcpci_tcpm_set_snk_ctrl(const struct i2c_dt_spec *bus, bool enable)
Function to enable or disable sinking power over VBUS.
int tcpci_tcpm_set_bist_test_mode(const struct i2c_dt_spec *bus, bool enable)
Function to enable or disable the BIST (Built-In Self-Test) mode.
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 s...
int tcpci_tcpm_select_rp_value(const struct i2c_dt_spec *bus, enum tc_rp_value rp)
Function to select the Rp (Pull-up Resistor) value.
int tcpci_tcpm_clear_status_register(const struct i2c_dt_spec *bus, enum tcpc_status_reg reg, uint16_t mask)
Function to clear specific bits in a TCPCI status register.
USB-C Device APIs.