Zephyr API Documentation 4.0.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
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
48#define FIXED_5V_100MA_RDO 0x1100280a
49
85
129
147
161
173
185typedef int (*policy_cb_get_snk_cap_t)(const struct device *dev, uint32_t **pdos, int *num_pdos);
194typedef void (*policy_cb_set_src_cap_t)(const struct device *dev, const uint32_t *pdos,
195 const int num_pdos);
196
204typedef bool (*policy_cb_check_t)(const struct device *dev,
205 const enum usbc_policy_check_t policy_check);
206
215typedef bool (*policy_cb_wait_notify_t)(const struct device *dev,
216 const enum usbc_policy_wait_t wait_notify);
217
225typedef void (*policy_cb_notify_t)(const struct device *dev,
226 const enum usbc_policy_notify_t policy_notify);
227
234typedef uint32_t (*policy_cb_get_rdo_t)(const struct device *dev);
235
243typedef bool (*policy_cb_is_snk_at_default_t)(const struct device *dev);
244
258typedef int (*policy_cb_get_src_caps_t)(const struct device *dev, const uint32_t **pdos,
259 uint32_t *num_pdos);
260
268typedef enum usbc_snk_req_reply_t (*policy_cb_check_sink_request_t)(const struct device *dev,
269 const uint32_t request_msg);
270
277typedef bool (*policy_cb_is_ps_ready_t)(const struct device *dev);
278
287 const uint32_t present_contract);
288
296typedef bool (*policy_cb_change_src_caps_t)(const struct device *dev);
297
306typedef void (*policy_cb_set_port_partner_snk_cap_t)(const struct device *dev, const uint32_t *pdos,
307 const int num_pdos);
316typedef int (*policy_cb_get_src_rp_t)(const struct device *dev, enum tc_rp_value *rp);
324typedef int (*policy_cb_src_en_t)(const struct device *dev, bool en);
334int usbc_start(const struct device *dev);
335
343int usbc_suspend(const struct device *dev);
344
353int usbc_request(const struct device *dev, const enum usbc_policy_request_t req);
354
362void usbc_bypass_next_sleep(const struct device *dev);
363
370void usbc_set_dpm_data(const struct device *dev, void *dpm_data);
371
380void *usbc_get_dpm_data(const struct device *dev);
381
389
397
404void usbc_set_policy_cb_check(const struct device *dev, const policy_cb_check_t cb);
405
413void usbc_set_policy_cb_notify(const struct device *dev, const policy_cb_notify_t cb);
414
423
431
440
447void usbc_set_policy_cb_get_rdo(const struct device *dev, const policy_cb_get_rdo_t cb);
448
458
467
474void usbc_set_policy_cb_src_en(const struct device *dev, const policy_cb_src_en_t cb);
475
484
493
501 const policy_cb_is_ps_ready_t cb);
502
511
521
530
535#ifdef __cplusplus
536}
537#endif
538
539#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:53
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:165
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:89
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:151
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:133
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:61
@ REQUEST_PE_DR_SWAP
Request Policy Engine layer to perform a Data Role Swap.
Definition usbc.h:64
@ REQUEST_NOP
No request.
Definition usbc.h:55
@ REQUEST_PE_HARD_RESET_SEND
Request Policy Engine layer to send a hard reset.
Definition usbc.h:66
@ REQUEST_TC_DISABLED
Request Type-C layer to transition to Disabled State.
Definition usbc.h:57
@ REQUEST_TC_ERROR_RECOVERY
Request Type-C layer to transition to Error Recovery State.
Definition usbc.h:59
@ REQUEST_PE_GET_SRC_CAPS
Request Policy Engine layer to get Source Capabilities from port partner.
Definition usbc.h:73
@ REQUEST_PE_SOFT_RESET_SEND
Request Policy Engine layer to send a soft reset.
Definition usbc.h:68
@ REQUEST_GET_SNK_CAPS
Request Policy Engine to get Sink Capabilities from port partner.
Definition usbc.h:78
@ REQUEST_PE_GOTO_MIN
Request Policy Engine to request the port partner to source minimum power.
Definition usbc.h:83
@ SNK_REQUEST_REJECT
The sink port partner's request can not be met.
Definition usbc.h:169
@ SNK_REQUEST_VALID
The sink port partner's request can be met.
Definition usbc.h:167
@ SNK_REQUEST_WAIT
The sink port partner's request can be met at a later time.
Definition usbc.h:171
@ SOURCE_CAPABILITIES_RECEIVED
Source Capabilities Received.
Definition usbc.h:127
@ POWER_CHANGE_0A0
Sink SubPower state at 0V.
Definition usbc.h:117
@ POWER_CHANGE_1A5
Sink SubPower state a 5V / 1.5A.
Definition usbc.h:121
@ POWER_CHANGE_3A0
Sink SubPower state a 5V / 3A.
Definition usbc.h:123
@ TRANSITION_PS
Transition the Power Supply.
Definition usbc.h:107
@ POWER_CHANGE_DEF
Sink SubPower state a 5V / 500mA.
Definition usbc.h:119
@ DATA_ROLE_IS_UFP
Data Role has been set to Upstream Facing Port (UFP)
Definition usbc.h:99
@ MSG_ACCEPT_RECEIVED
Power Delivery Accept message was received.
Definition usbc.h:91
@ MSG_REJECTED_RECEIVED
Power Delivery Reject message was received.
Definition usbc.h:93
@ DATA_ROLE_IS_DFP
Data Role has been set to Downstream Facing Port (DFP)
Definition usbc.h:101
@ PROTOCOL_ERROR
Protocol Error occurred.
Definition usbc.h:111
@ SNK_TRANSITION_TO_DEFAULT
Transition the Sink to default.
Definition usbc.h:113
@ MSG_DISCARDED
Power Delivery discarded the message being transmitted.
Definition usbc.h:95
@ MSG_NOT_SUPPORTED_RECEIVED
Power Delivery Not Supported message was received.
Definition usbc.h:97
@ HARD_RESET_RECEIVED
Hard Reset Received.
Definition usbc.h:115
@ SENDER_RESPONSE_TIMEOUT
Sender Response Timeout.
Definition usbc.h:125
@ PORT_PARTNER_NOT_RESPONSIVE
Port partner is not responsive.
Definition usbc.h:109
@ PD_CONNECTED
A PD Explicit Contract is in place.
Definition usbc.h:103
@ NOT_PD_CONNECTED
No PD Explicit Contract is in place.
Definition usbc.h:105
@ WAIT_SINK_REQUEST
The port partner is unable to meet the sink request at this time.
Definition usbc.h:153
@ WAIT_POWER_ROLE_SWAP
The port partner is unable to do a Power Role Swap at this time.
Definition usbc.h:155
@ WAIT_VCONN_SWAP
The port partner is unable to do a VCONN Swap at this time.
Definition usbc.h:159
@ WAIT_DATA_ROLE_SWAP
The port partner is unable to do a Data Role Swap at this time.
Definition usbc.h:157
@ CHECK_POWER_ROLE_SWAP
Check if Power Role Swap is allowed.
Definition usbc.h:135
@ CHECK_SNK_AT_DEFAULT_LEVEL
Check if Sink is at default level.
Definition usbc.h:141
@ CHECK_SRC_PS_AT_DEFAULT_LEVEL
Check if Source Power Supply is at default level.
Definition usbc.h:145
@ CHECK_VCONN_CONTROL
Check if should control VCONN.
Definition usbc.h:143
@ CHECK_DATA_ROLE_SWAP_TO_UFP
Check if Data Role Swap to UFP is allowed.
Definition usbc.h:139
@ CHECK_DATA_ROLE_SWAP_TO_DFP
Check if Data Role Swap to DFP is allowed.
Definition usbc.h:137
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:243
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:204
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:225
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:194
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:185
uint32_t(* policy_cb_get_rdo_t)(const struct device *dev)
Callback type used to get the Request Data Object (RDO)
Definition usbc.h:234
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:215
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:286
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:258
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:296
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:316
int(* policy_cb_src_en_t)(const struct device *dev, bool en)
Callback type used to enable VBUS.
Definition usbc.h:324
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:277
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:306
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:268
int(* tcpc_vconn_discharge_cb_t)(const struct device *dev, enum tc_cc_polarity pol, bool enable)
Definition usbc_tcpc.h:123
int(* tcpc_vconn_control_cb_t)(const struct device *dev, enum tc_cc_polarity pol, bool enable)
Definition usbc_tcpc.h:121
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:412
USBC Type-C Port Controller device APIs.
USB-C VBUS device APIs.