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

USB Type-C Power Path Controller device API. More...

#include <zephyr/types.h>
#include <zephyr/device.h>
#include <errno.h>

Go to the source code of this file.

Data Structures

struct  usbc_ppc_driver_api
 Structure with pointers to the functions implemented by driver. More...
 

Typedefs

typedef void(* usbc_ppc_event_cb_t) (const struct device *dev, void *data, enum usbc_ppc_event ev)
 

Enumerations

enum  usbc_ppc_event {
  USBC_PPC_EVENT_DEAD_BATTERY_ERROR = 0 , USBC_PPC_EVENT_SRC_OVERVOLTAGE , USBC_PPC_EVENT_SRC_REVERSE_CURRENT , USBC_PPC_EVENT_SRC_OVERCURRENT ,
  USBC_PPC_EVENT_SRC_SHORT , USBC_PPC_EVENT_OVER_TEMPERATURE , USBC_PPC_EVENT_BOTH_SNKSRC_ENABLED , USBC_PPC_EVENT_SNK_REVERSE_CURRENT ,
  USBC_PPC_EVENT_SNK_SHORT , USBC_PPC_EVENT_SNK_OVERVOLTAGE
}
 Type of event being notified by Power Path Controller. More...
 

Functions

static int ppc_is_dead_battery_mode (const struct device *dev)
 Check if PPC is in the dead battery mode.
 
static int ppc_exit_dead_battery_mode (const struct device *dev)
 Request the PPC to exit from the dead battery mode Return from this call doesn't mean that the PPC is not in the dead battery anymore.
 
static int ppc_is_vbus_source (const struct device *dev)
 Check if the PPC is sourcing the VBUS.
 
static int ppc_is_vbus_sink (const struct device *dev)
 Check if the PPC is sinking the VBUS.
 
static int ppc_set_snk_ctrl (const struct device *dev, bool enable)
 Set the state of VBUS sinking.
 
static int ppc_set_src_ctrl (const struct device *dev, bool enable)
 Set the state of VBUS sourcing.
 
static int ppc_set_vbus_discharge (const struct device *dev, bool enable)
 Set the state of VBUS discharging.
 
static int ppc_is_vbus_present (const struct device *dev)
 Check if VBUS is present.
 
static int ppc_set_event_handler (const struct device *dev, usbc_ppc_event_cb_t handler, void *data)
 Set the callback used to notify about PPC events.
 
static int ppc_dump_regs (const struct device *dev)
 Print the values or PPC registers.
 

Detailed Description

USB Type-C Power Path Controller device API.

Typedef Documentation

◆ usbc_ppc_event_cb_t

typedef void(* usbc_ppc_event_cb_t) (const struct device *dev, void *data, enum usbc_ppc_event ev)

Enumeration Type Documentation

◆ usbc_ppc_event

Type of event being notified by Power Path Controller.

Enumerator
USBC_PPC_EVENT_DEAD_BATTERY_ERROR 

Exit from dead-battery mode failed.

USBC_PPC_EVENT_SRC_OVERVOLTAGE 

Overvoltage detected while being in a source role.

USBC_PPC_EVENT_SRC_REVERSE_CURRENT 

Reverse current detected while being in a source role.

USBC_PPC_EVENT_SRC_OVERCURRENT 

Overcurrent detected while being in a source role.

USBC_PPC_EVENT_SRC_SHORT 

VBUS short detected while being in a source role.

USBC_PPC_EVENT_OVER_TEMPERATURE 

Chip over temperature detected

USBC_PPC_EVENT_BOTH_SNKSRC_ENABLED 

Sink and source paths enabled simultaneously.

USBC_PPC_EVENT_SNK_REVERSE_CURRENT 

Reverse current detected while being in a sink role.

USBC_PPC_EVENT_SNK_SHORT 

VBUS short detected while being in a sink role.

USBC_PPC_EVENT_SNK_OVERVOLTAGE 

Overvoltage detected while being in a sink role.

Function Documentation

◆ ppc_dump_regs()

static int ppc_dump_regs ( const struct device * dev)
inlinestatic

Print the values or PPC registers.

Parameters
devPPC device structure
Return values
0if success
-EIOif I2C communication failed
-ENOSYSif this function is not supported by the driver

◆ ppc_exit_dead_battery_mode()

static int ppc_exit_dead_battery_mode ( const struct device * dev)
inlinestatic

Request the PPC to exit from the dead battery mode Return from this call doesn't mean that the PPC is not in the dead battery anymore.

In the case of error, the driver should execute the callback with USBC_PPC_EVENT_DEAD_BATTERY_ERROR enum. To check if the PPC disabled the dead battery mode, the call to ppc_is_dead_battery_mode should be done.

Parameters
devPPC device structure
Return values
0if request was successfully sent
-EIOif I2C communication failed
-ENOSYSif this function is not supported by the driver

◆ ppc_is_dead_battery_mode()

static int ppc_is_dead_battery_mode ( const struct device * dev)
inlinestatic

Check if PPC is in the dead battery mode.

Parameters
devPPC device structure
Return values
1if PPC is in the dead battery mode
0if PPC is not in the dead battery mode
-EIOif I2C communication failed
-ENOSYSif this function is not supported by the driver

◆ ppc_is_vbus_present()

static int ppc_is_vbus_present ( const struct device * dev)
inlinestatic

Check if VBUS is present.

Parameters
devPPC device structure
Return values
1if VBUS voltage is present
0if no VBUS voltage is detected
-EIOif I2C communication failed
-ENOSYSif this function is not supported by the driver

◆ ppc_is_vbus_sink()

static int ppc_is_vbus_sink ( const struct device * dev)
inlinestatic

Check if the PPC is sinking the VBUS.

Parameters
devPPC device structure
Return values
1if the PPC is sinking the VBUS
0if the PPC is not sinking the VBUS
-EIOif I2C communication failed
-ENOSYSif this function is not supported by the driver

◆ ppc_is_vbus_source()

static int ppc_is_vbus_source ( const struct device * dev)
inlinestatic

Check if the PPC is sourcing the VBUS.

Parameters
devPPC device structure
Return values
1if the PPC is sourcing the VBUS
0if the PPC is not sourcing the VBUS
-EIOif I2C communication failed
-ENOSYSif this function is not supported by the driver

◆ ppc_set_event_handler()

static int ppc_set_event_handler ( const struct device * dev,
usbc_ppc_event_cb_t handler,
void * data )
inlinestatic

Set the callback used to notify about PPC events.

Parameters
devPPC device structure
handlerHandler that will be called with events notifications
dataPointer used as an argument to the callback
Return values
0if success
-ENOSYSif this function is not supported by the driver

◆ ppc_set_snk_ctrl()

static int ppc_set_snk_ctrl ( const struct device * dev,
bool enable )
inlinestatic

Set the state of VBUS sinking.

Parameters
devPPC device structure
enableTrue if sinking VBUS should be enabled, false if should be disabled
Return values
0if success
-EIOif I2C communication failed
-ENOSYSif this function is not supported by the driver

◆ ppc_set_src_ctrl()

static int ppc_set_src_ctrl ( const struct device * dev,
bool enable )
inlinestatic

Set the state of VBUS sourcing.

Parameters
devPPC device structure
enableTrue if sourcing VBUS should be enabled, false if should be disabled
Return values
0if success
-EIOif I2C communication failed
-ENOSYSif this function is not supported by the driver

◆ ppc_set_vbus_discharge()

static int ppc_set_vbus_discharge ( const struct device * dev,
bool enable )
inlinestatic

Set the state of VBUS discharging.

Parameters
devPPC device structure
enableTrue if VBUS discharging should be enabled, false if should be disabled
Return values
0if success
-EIOif I2C communication failed
-ENOSYSif this function is not supported by the driver