Zephyr API Documentation  3.6.0
A Scalable Open Source RTOS
3.6.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
usbc.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 The Chromium OS Authors
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
13#ifndef ZEPHYR_INCLUDE_USBC_H_
14#define ZEPHYR_INCLUDE_USBC_H_
15
16#include <zephyr/types.h>
17#include <zephyr/device.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
46#define FIXED_5V_100MA_RDO 0x1100280a
47
60
82};
83
126};
127
144};
145
158};
159
170};
171
183typedef int (*policy_cb_get_snk_cap_t)(const struct device *dev, uint32_t **pdos, int *num_pdos);
192typedef void (*policy_cb_set_src_cap_t)(const struct device *dev, const uint32_t *pdos,
193 const int num_pdos);
194
202typedef bool (*policy_cb_check_t)(const struct device *dev,
203 const enum usbc_policy_check_t policy_check);
204
213typedef bool (*policy_cb_wait_notify_t)(const struct device *dev,
214 const enum usbc_policy_wait_t wait_notify);
215
223typedef void (*policy_cb_notify_t)(const struct device *dev,
224 const enum usbc_policy_notify_t policy_notify);
225
232typedef uint32_t (*policy_cb_get_rdo_t)(const struct device *dev);
233
241typedef bool (*policy_cb_is_snk_at_default_t)(const struct device *dev);
242
256typedef int (*policy_cb_get_src_caps_t)(const struct device *dev, const uint32_t **pdos,
257 uint32_t *num_pdos);
258
266typedef enum usbc_snk_req_reply_t (*policy_cb_check_sink_request_t)(const struct device *dev,
267 const uint32_t request_msg);
268
275typedef bool (*policy_cb_is_ps_ready_t)(const struct device *dev);
276
285 const uint32_t present_contract);
286
294typedef bool (*policy_cb_change_src_caps_t)(const struct device *dev);
295
304typedef void (*policy_cb_set_port_partner_snk_cap_t)(const struct device *dev, const uint32_t *pdos,
305 const int num_pdos);
314typedef int (*policy_cb_get_src_rp_t)(const struct device *dev, enum tc_rp_value *rp);
322typedef int (*policy_cb_src_en_t)(const struct device *dev, bool en);
332int usbc_start(const struct device *dev);
333
341int usbc_suspend(const struct device *dev);
342
351int usbc_request(const struct device *dev, const enum usbc_policy_request_t req);
352
360void usbc_bypass_next_sleep(const struct device *dev);
361
368void usbc_set_dpm_data(const struct device *dev, void *dpm_data);
369
378void *usbc_get_dpm_data(const struct device *dev);
379
387
395
402void usbc_set_policy_cb_check(const struct device *dev, const policy_cb_check_t cb);
403
411void usbc_set_policy_cb_notify(const struct device *dev, const policy_cb_notify_t cb);
412
421
429
438
445void usbc_set_policy_cb_get_rdo(const struct device *dev, const policy_cb_get_rdo_t cb);
446
456
465
472void usbc_set_policy_cb_src_en(const struct device *dev, const policy_cb_src_en_t cb);
473
482
491
499 const policy_cb_is_ps_ready_t cb);
500
509
519
528
533#ifdef __cplusplus
534}
535#endif
536
537#endif /* ZEPHYR_INCLUDE_USBC_H_ */
void usbc_bypass_next_sleep(const struct device *dev)
int usbc_start(const struct device *dev)
Start the USB-C Subsystem.
usbc_policy_request_t
Device Policy Manager requests.
Definition: usbc.h:51
int usbc_request(const struct device *dev, const enum usbc_policy_request_t req)
Make a request of the USB-C Subsystem.
void usbc_set_policy_cb_set_src_cap(const struct device *dev, const policy_cb_set_src_cap_t cb)
Set the callback used to store the received Port Partner's Source Capabilities.
usbc_snk_req_reply_t
Device Policy Manager's response to a Sink Request.
Definition: usbc.h:163
void usbc_set_policy_cb_present_contract_is_valid(const struct device *dev, const policy_cb_present_contract_is_valid_t cb)
Set the callback to check if present Contract is still valid.
usbc_policy_notify_t
Device Policy Manager notifications.
Definition: usbc.h:87
void usbc_set_policy_cb_check(const struct device *dev, const policy_cb_check_t cb)
Set the callback used to check a policy.
int usbc_suspend(const struct device *dev)
Suspend the USB-C Subsystem.
void usbc_set_policy_cb_get_src_caps(const struct device *dev, const policy_cb_get_src_caps_t cb)
Set the callback used to get the Source Capabilities from the Device Policy Manager.
void usbc_set_policy_cb_get_rdo(const struct device *dev, const policy_cb_get_rdo_t cb)
Set the callback used to get the Request Data Object (RDO)
void usbc_set_policy_cb_check_sink_request(const struct device *dev, const policy_cb_check_sink_request_t cb)
Set the callback used to check if Sink request is valid.
void usbc_set_vconn_discharge_cb(const struct device *dev, const tcpc_vconn_discharge_cb_t cb)
Set the callback used to discharge VCONN.
void usbc_set_policy_cb_get_src_rp(const struct device *dev, const policy_cb_get_src_rp_t cb)
Set the callback used to get the Rp value that should be placed on the CC lines.
void usbc_set_vconn_control_cb(const struct device *dev, const tcpc_vconn_control_cb_t cb)
Set the callback used to set VCONN control.
void usbc_set_dpm_data(const struct device *dev, void *dpm_data)
Set pointer to Device Policy Manager (DPM) data.
void usbc_set_policy_cb_wait_notify(const struct device *dev, const policy_cb_wait_notify_t cb)
Set the callback used to notify Device Policy Manager of WAIT message reception.
void usbc_set_policy_cb_change_src_caps(const struct device *dev, const policy_cb_change_src_caps_t cb)
Set the callback used to request that a different set of Source Caps be sent to the Sink.
void * usbc_get_dpm_data(const struct device *dev)
Get pointer to Device Policy Manager (DPM) data.
usbc_policy_wait_t
Device Policy Manager Wait message notifications.
Definition: usbc.h:149
void usbc_set_policy_cb_notify(const struct device *dev, const policy_cb_notify_t cb)
Set the callback used to notify Device Policy Manager of a policy change.
void usbc_set_policy_cb_is_ps_ready(const struct device *dev, const policy_cb_is_ps_ready_t cb)
Set the callback used to check if Source Power Supply is ready.
void usbc_set_policy_cb_src_en(const struct device *dev, const policy_cb_src_en_t cb)
Set the callback used to enable VBUS.
void usbc_set_policy_cb_get_snk_cap(const struct device *dev, const policy_cb_get_snk_cap_t cb)
Set the callback used to get the Sink Capabilities.
void usbc_set_policy_cb_set_port_partner_snk_cap(const struct device *dev, const policy_cb_set_port_partner_snk_cap_t cb)
Set the callback used to store the Capabilities received from a Sink Port Partner.
usbc_policy_check_t
Device Policy Manager checks.
Definition: usbc.h:131
void usbc_set_policy_cb_is_snk_at_default(const struct device *dev, const policy_cb_is_snk_at_default_t cb)
Set the callback used to check if the sink power supply is at the default level.
@ REQUEST_TC_END
End of Type-C requests.
Definition: usbc.h:59
@ REQUEST_PE_DR_SWAP
Request Policy Engine layer to perform a Data Role Swap.
Definition: usbc.h:62
@ REQUEST_NOP
No request.
Definition: usbc.h:53
@ REQUEST_PE_HARD_RESET_SEND
Request Policy Engine layer to send a hard reset.
Definition: usbc.h:64
@ REQUEST_TC_DISABLED
Request Type-C layer to transition to Disabled State.
Definition: usbc.h:55
@ REQUEST_TC_ERROR_RECOVERY
Request Type-C layer to transition to Error Recovery State.
Definition: usbc.h:57
@ REQUEST_PE_GET_SRC_CAPS
Request Policy Engine layer to get Source Capabilities from port partner.
Definition: usbc.h:71
@ REQUEST_PE_SOFT_RESET_SEND
Request Policy Engine layer to send a soft reset.
Definition: usbc.h:66
@ REQUEST_GET_SNK_CAPS
Request Policy Engine to get Sink Capabilities from port partner.
Definition: usbc.h:76
@ REQUEST_PE_GOTO_MIN
Request Policy Engine to request the port partner to source minimum power.
Definition: usbc.h:81
@ SNK_REQUEST_REJECT
The sink port partner's request can not be met.
Definition: usbc.h:167
@ SNK_REQUEST_VALID
The sink port partner's request can be met.
Definition: usbc.h:165
@ SNK_REQUEST_WAIT
The sink port partner's request can be met at a later time.
Definition: usbc.h:169
@ SOURCE_CAPABILITIES_RECEIVED
Source Capabilities Received.
Definition: usbc.h:125
@ POWER_CHANGE_0A0
Sink SubPower state at 0V.
Definition: usbc.h:115
@ POWER_CHANGE_1A5
Sink SubPower state a 5V / 1.5A.
Definition: usbc.h:119
@ POWER_CHANGE_3A0
Sink SubPower state a 5V / 3A.
Definition: usbc.h:121
@ TRANSITION_PS
Transition the Power Supply.
Definition: usbc.h:105
@ POWER_CHANGE_DEF
Sink SubPower state a 5V / 500mA.
Definition: usbc.h:117
@ DATA_ROLE_IS_UFP
Data Role has been set to Upstream Facing Port (UFP)
Definition: usbc.h:97
@ MSG_ACCEPT_RECEIVED
Power Delivery Accept message was received.
Definition: usbc.h:89
@ MSG_REJECTED_RECEIVED
Power Delivery Reject message was received.
Definition: usbc.h:91
@ DATA_ROLE_IS_DFP
Data Role has been set to Downstream Facing Port (DFP)
Definition: usbc.h:99
@ PROTOCOL_ERROR
Protocol Error occurred.
Definition: usbc.h:109
@ SNK_TRANSITION_TO_DEFAULT
Transition the Sink to default.
Definition: usbc.h:111
@ MSG_DISCARDED
Power Delivery discarded the message being transmited.
Definition: usbc.h:93
@ MSG_NOT_SUPPORTED_RECEIVED
Power Delivery Not Supported message was received.
Definition: usbc.h:95
@ HARD_RESET_RECEIVED
Hard Reset Received.
Definition: usbc.h:113
@ SENDER_RESPONSE_TIMEOUT
Sender Response Timeout.
Definition: usbc.h:123
@ PORT_PARTNER_NOT_RESPONSIVE
Port partner is not responsive.
Definition: usbc.h:107
@ PD_CONNECTED
A PD Explicit Contract is in place.
Definition: usbc.h:101
@ NOT_PD_CONNECTED
No PD Explicit Contract is in place.
Definition: usbc.h:103
@ WAIT_SINK_REQUEST
The port partner is unable to meet the sink request at this time.
Definition: usbc.h:151
@ WAIT_POWER_ROLE_SWAP
The port partner is unable to do a Power Role Swap at this time.
Definition: usbc.h:153
@ WAIT_VCONN_SWAP
The port partner is unable to do a VCONN Swap at this time.
Definition: usbc.h:157
@ WAIT_DATA_ROLE_SWAP
The port partner is unable to do a Data Role Swap at this time.
Definition: usbc.h:155
@ CHECK_POWER_ROLE_SWAP
Check if Power Role Swap is allowed.
Definition: usbc.h:133
@ CHECK_SNK_AT_DEFAULT_LEVEL
Check if Sink is at default level.
Definition: usbc.h:139
@ CHECK_SRC_PS_AT_DEFAULT_LEVEL
Check if Source Power Supply is at default level.
Definition: usbc.h:143
@ CHECK_VCONN_CONTROL
Check if should control VCONN.
Definition: usbc.h:141
@ CHECK_DATA_ROLE_SWAP_TO_UFP
Check if Data Role Swap to UFP is allowed.
Definition: usbc.h:137
@ CHECK_DATA_ROLE_SWAP_TO_DFP
Check if Data Role Swap to DFP is allowed.
Definition: usbc.h:135
bool(* policy_cb_is_snk_at_default_t)(const struct device *dev)
Callback type used to check if the sink power supply is at the default level.
Definition: usbc.h:241
bool(* policy_cb_check_t)(const struct device *dev, const enum usbc_policy_check_t policy_check)
Callback type used to check a policy.
Definition: usbc.h:202
void(* policy_cb_notify_t)(const struct device *dev, const enum usbc_policy_notify_t policy_notify)
Callback type used to notify Device Policy Manager of a policy change.
Definition: usbc.h:223
void(* policy_cb_set_src_cap_t)(const struct device *dev, const uint32_t *pdos, const int num_pdos)
Callback type used to report the received Port Partner's Source Capabilities.
Definition: usbc.h:192
int(* policy_cb_get_snk_cap_t)(const struct device *dev, uint32_t **pdos, int *num_pdos)
Callback type used to get the Sink Capabilities.
Definition: usbc.h:183
uint32_t(* policy_cb_get_rdo_t)(const struct device *dev)
Callback type used to get the Request Data Object (RDO)
Definition: usbc.h:232
bool(* policy_cb_wait_notify_t)(const struct device *dev, const enum usbc_policy_wait_t wait_notify)
Callback type used to notify Device Policy Manager of WAIT message reception.
Definition: usbc.h:213
bool(* policy_cb_present_contract_is_valid_t)(const struct device *dev, const uint32_t present_contract)
Callback type used to check if present Contract is still valid.
Definition: usbc.h:284
int(* policy_cb_get_src_caps_t)(const struct device *dev, const uint32_t **pdos, uint32_t *num_pdos)
Callback type used to get the Source Capabilities from the Device Policy Manager.
Definition: usbc.h:256
bool(* policy_cb_change_src_caps_t)(const struct device *dev)
Callback type used to request that a different set of Source Caps be sent to the Sink.
Definition: usbc.h:294
int(* policy_cb_get_src_rp_t)(const struct device *dev, enum tc_rp_value *rp)
Callback type used to get the Rp value that should be placed on the CC lines.
Definition: usbc.h:314
int(* policy_cb_src_en_t)(const struct device *dev, bool en)
Callback type used to enable VBUS.
Definition: usbc.h:322
bool(* policy_cb_is_ps_ready_t)(const struct device *dev)
Callback type used to check if Source Power Supply is ready.
Definition: usbc.h:275
void(* policy_cb_set_port_partner_snk_cap_t)(const struct device *dev, const uint32_t *pdos, const int num_pdos)
Callback type used to report the Capabilities received from a Sink Port Partner.
Definition: usbc.h:304
enum usbc_snk_req_reply_t(* policy_cb_check_sink_request_t)(const struct device *dev, const uint32_t request_msg)
Callback type used to check if Sink request is valid.
Definition: usbc.h:266
int(* tcpc_vconn_discharge_cb_t)(const struct device *dev, enum tc_cc_polarity pol, bool enable)
Definition: usbc_tcpc.h:121
int(* tcpc_vconn_control_cb_t)(const struct device *dev, enum tc_cc_polarity pol, bool enable)
Definition: usbc_tcpc.h:119
tc_rp_value
Pull-Up resistor values.
Definition: usbc_tc.h:338
#define bool
Definition: stdbool.h:13
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
Runtime device structure (in ROM) per driver instance.
Definition: device.h:387
USBC Type-C Port Controller device APIs.
USB-C VBUS device APIs.